game/txt/hlp/pennvOLD.hlp
game/txt/nws/base.nws
COPYRITE
-Configure
I18N
INSTALL
MANIFEST
README.SQL
README.SSL
UPGRADING
-config_h.SH
confmagic.h
options.h.dist
hdrs/access.h
hdrs/malias.h
hdrs/match.h
hdrs/mushdb.h
+hdrs/mushlua.h
hdrs/mushtype.h
hdrs/mymalloc.h
hdrs/mysocket.h
src/warnings.c
src/wild.c
src/wiz.c
+src/mushlua.c
+src/mushlua.i
utils/clwrapper.sh
utils/customize.pl
utils/fixdepend.pl
utils/ln-dir.sh
utils/make_access_cnf.sh
utils/mkcmds.sh.SH
-utils/mkvershlp.pl
utils/penn-install
utils/update-cnf.pl
utils/update.pl
win32/patches.h
win32/pennmush.dsp
win32/pennmush.dsw
+Configure Portability tool
+config_h.SH Produces config.h
+game/lua/path.lua
+game/lua/README
+game/lua/test.lua
+game/mush.lua
+game/txt/changes/0.5b
+game/txt/changes/0.65b
+game/txt/changes/0.66b
+game/txt/changes/0.67
+game/txt/changes/0.6b
+game/txt/changes/0.70
+game/txt/changes/0.70-1
+game/txt/changes/0.70-2
+game/txt/changes/0.70-3
+game/txt/changes/0.71
+game/txt/changes/0.71p1
+game/txt/changes/0.71p2
+game/txt/changes/0.71p3
+game/txt/changes/0.72
+game/txt/changes/0.72p1
+game/txt/changes/0.72p2
+game/txt/changes/0.72p4
+game/txt/changes/0.73
+game/txt/changes/0.73p1
+game/txt/changes/0.73p2
+game/txt/changes/0.80
+game/txt/changes/kv0.0.1a
+game/txt/changes/kv0.0.2a
+game/txt/changes/kv0.0.3b
+game/txt/changes/kv0.0.4b
+game/txt/genchanges.rb
+game/txt/hlp/cobra_vts.hlp
+game/txt/nws/index.nws
+lua/COPYRIGHT
+lua/etc/all.c
+lua/etc/lua.hpp
+lua/etc/lua.ico
+lua/etc/lua.pc
+lua/etc/luavs.bat
+lua/etc/Makefile
+lua/etc/min.c
+lua/etc/noparser.c
+lua/etc/README
+lua/etc/strict.lua
+lua/HISTORY
+lua/INSTALL
+lua/Makefile
+lua/README
+lua/src/lapi.c
+lua/src/lapi.h
+lua/src/lapi.o
+lua/src/lauxlib.c
+lua/src/lauxlib.h
+lua/src/lauxlib.o
+lua/src/lbaselib.c
+lua/src/lbaselib.o
+lua/src/lcode.c
+lua/src/lcode.h
+lua/src/lcode.o
+lua/src/ldblib.c
+lua/src/ldblib.o
+lua/src/ldebug.c
+lua/src/ldebug.h
+lua/src/ldebug.o
+lua/src/ldo.c
+lua/src/ldo.h
+lua/src/ldo.o
+lua/src/ldump.c
+lua/src/ldump.o
+lua/src/lfunc.c
+lua/src/lfunc.h
+lua/src/lfunc.o
+lua/src/lgc.c
+lua/src/lgc.h
+lua/src/lgc.o
+lua/src/liblua.a
+lua/src/linit.c
+lua/src/linit.o
+lua/src/liolib.c
+lua/src/liolib.o
+lua/src/llex.c
+lua/src/llex.h
+lua/src/llex.o
+lua/src/llimits.h
+lua/src/lmathlib.c
+lua/src/lmathlib.o
+lua/src/lmem.c
+lua/src/lmem.h
+lua/src/lmem.o
+lua/src/loadlib.c
+lua/src/loadlib.o
+lua/src/lobject.c
+lua/src/lobject.h
+lua/src/lobject.o
+lua/src/lopcodes.c
+lua/src/lopcodes.h
+lua/src/lopcodes.o
+lua/src/loslib.c
+lua/src/loslib.o
+lua/src/lparser.c
+lua/src/lparser.h
+lua/src/lparser.o
+lua/src/lstate.c
+lua/src/lstate.h
+lua/src/lstate.o
+lua/src/lstring.c
+lua/src/lstring.h
+lua/src/lstring.o
+lua/src/lstrlib.c
+lua/src/lstrlib.o
+lua/src/ltable.c
+lua/src/ltable.h
+lua/src/ltable.o
+lua/src/ltablib.c
+lua/src/ltablib.o
+lua/src/ltm.c
+lua/src/ltm.h
+lua/src/ltm.o
+lua/src/lua
+lua/src/luac
+lua/src/lua.c
+lua/src/luac.c
+lua/src/luac.o
+lua/src/luaconf.h
+lua/src/lua.h
+lua/src/lualib.h
+lua/src/lua.o
+lua/src/lundump.c
+lua/src/lundump.h
+lua/src/lundump.o
+lua/src/lvm.c
+lua/src/lvm.h
+lua/src/lvm.o
+lua/src/lzio.c
+lua/src/lzio.h
+lua/src/lzio.o
+lua/src/Makefile
+lua/src/print.c
+lua/src/print.o
+lua/test/bisect.lua
+lua/test/cf.lua
+lua/test/echo.lua
+lua/test/env.lua
+lua/test/factorial.lua
+lua/test/fibfor.lua
+lua/test/fib.lua
+lua/test/globals.lua
+lua/test/hello.lua
+lua/test/life.lua
+lua/test/luac.lua
+lua/test/printf.lua
+lua/test/README
+lua/test/readonly.lua
+lua/test/sieve.lua
+lua/test/sort.lua
+lua/test/table.lua
+lua/test/trace-calls.lua
+lua/test/trace-globals.lua
+lua/test/xd.lua
+src/.indent.pro
+src/mushlua_wrappers.c
+utils/makedist.sh
+utils/preparedist.sh
+utils/transition.c
+win32/switches.h
+++ /dev/null
-game/data/README
-game/README
-game/access.README
-game/aliascnf.dst
-game/getdate.README
-game/getdate.template
-game/mushcnf.dst
-game/namescnf.dst
-game/restart.dst
-game/restrictcnf.dst
-game/log/README
-game/save/README
-game/txt/evt/index.evt
-game/txt/evt/pennmush.evt
-game/txt/Makefile
-game/txt/README
-game/txt/changes.txt
-game/txt/compose.sh.SH
-game/txt/connect.txt
-game/txt/down.txt
-game/txt/full.txt
-game/txt/guest.txt
-game/txt/index-files.pl
-game/txt/motd.txt
-game/txt/newuser.txt
-game/txt/quit.txt
-game/txt/register.txt
-game/txt/hlp/cobra_attr.hlp
-game/txt/hlp/cobra_chat.hlp
-game/txt/hlp/cobra_cmd.hlp
-game/txt/hlp/cobra_code.hlp
-game/txt/hlp/cobra_conf.hlp
-game/txt/hlp/cobra_division.hlp
-game/txt/hlp/cobra_flag.hlp
-game/txt/hlp/cobra_func.hlp
-game/txt/hlp/cobra_mail.hlp
-game/txt/hlp/cobra_pueb.hlp
-game/txt/hlp/cobramush.hlp
-game/txt/hlp/cobratop.hlp
-game/txt/hlp/index.hlp
-game/txt/hlp/pennv174.hlp
-game/txt/hlp/pennv175.hlp
-game/txt/hlp/pennv176.hlp
-game/txt/hlp/pennv177.hlp
-game/txt/hlp/pennv180.hlp
-game/txt/hlp/pennvOLD.hlp
-game/txt/nws/base.nws
-COPYRITE
-I18N
-INSTALL
-MANIFEST
-Makefile.SH
-Patchlevel
-README
-README.SQL
-README.SSL
-UPGRADING
-confmagic.h
-options.h.dist
-hdrs/access.h
-hdrs/ansi.h
-hdrs/atr_tab.h
-hdrs/attrib.h
-hdrs/boolexp.h
-hdrs/bufferq.h
-hdrs/case.h
-hdrs/chunk.h
-hdrs/command.h
-hdrs/compile.h
-hdrs/conf.h
-hdrs/copyrite.h
-hdrs/cron.h
-hdrs/csrimalloc.h
-hdrs/dbdefs.h
-hdrs/dbio.h
-hdrs/division.h
-hdrs/extchat.h
-hdrs/externs.h
-hdrs/extmail.h
-hdrs/flags.h
-hdrs/function.h
-hdrs/game.h
-hdrs/getpgsiz.h
-hdrs/help.h
-hdrs/htab.h
-hdrs/ident.h
-hdrs/intrface.h
-hdrs/lock.h
-hdrs/log.h
-hdrs/malias.h
-hdrs/match.h
-hdrs/mushdb.h
-hdrs/mushtype.h
-hdrs/mymalloc.h
-hdrs/mysocket.h
-hdrs/myssl.h
-hdrs/oldflags.h
-hdrs/parse.h
-hdrs/pcre.h
-hdrs/privtab.h
-hdrs/ptab.h
-hdrs/pueblo.h
-hdrs/shs.h
-hdrs/strtree.h
-hdrs/version.h
-hints/a-u-x.sh
-hints/aix.sh
-hints/darwin.sh
-hints/darwin-fink.sh
-hints/dec_osf.sh
-hints/freebsd.sh
-hints/hpux-gcc.sh
-hints/hpux.sh
-hints/irix.sh
-hints/irix_6.sh
-hints/linux_2.sh
-hints/mingw32.sh
-hints/next.sh
-hints/openbsd.sh
-hints/os2.sh
-hints/solaris_2.sh
-hints/sunos_4.sh
-hints/ultrix.sh
-hints/win32-gcc.sh
-hints/win32.sh
-os2/GCCOPT.CMD
-os2/Makefile
-os2/Penn-OS2.htm
-os2/config.h
-po/Makefile
-src/Makefile.SH
-src/SWITCHES
-src/access.c
-src/announce.c
-src/atr_tab.c
-src/attrib.c
-src/boolexp.c
-src/bsd.c
-src/bufferq.c
-src/chunk.c
-src/cmdlocal.dst
-src/cmds.c
-src/command.c
-src/comp_h.c
-src/comp_w.c
-src/comp_w8.c
-src/compress.c
-src/conf.c
-src/cque.c
-src/create.c
-src/cron.c
-src/csrimalloc.c
-src/db.c
-src/destroy.c
-src/division.c
-src/extchat.c
-src/extmail.c
-src/filecopy.c
-src/flaglocal.dst
-src/flags.c
-src/funcrypt.c
-src/function.c
-src/fundb.c
-src/fundiv.c
-src/funlist.c
-src/funlocal.dst
-src/funmath.c
-src/funmisc.c
-src/funstr.c
-src/funtime.c
-src/funufun.c
-src/game.c
-src/gmalloc.c
-src/help.c
-src/htab.c
-src/ident.c
-src/info_slave.c
-src/local.dst
-src/lock.c
-src/log.c
-src/look.c
-src/malias.c
-src/match.c
-src/memcheck.c
-src/move.c
-src/mycrypt.c
-src/mymalloc.c
-src/mysocket.c
-src/myssl.c
-src/notify.c
-src/parse.c
-src/pcre.c
-src/player.c
-src/plyrlist.c
-src/portmsg.c
-src/predicat.c
-src/privtab.c
-src/prog.c
-src/ptab.c
-src/rob.c
-src/rplog.c
-src/services.c
-src/set.c
-src/shs.c
-src/sig.c
-src/speech.c
-src/sql.c
-src/strdup.c
-src/strtree.c
-src/strutil.c
-src/switchinc.c
-src/tables.c
-src/timer.c
-src/unparse.c
-src/utils.c
-src/version.c
-src/warnings.c
-src/wild.c
-src/wiz.c
-utils/clwrapper.sh
-utils/customize.pl
-utils/fixdepend.pl
-utils/gentables.c
-utils/ln-dir.sh
-utils/make_access_cnf.sh
-utils/mkcmds.sh.SH
-utils/mkvershlp.pl
-utils/penn-install
-utils/update-cnf.pl
-utils/update.pl
-win32/README.mingw
-win32/README.txt
-win32/cmds.h
-win32/cobramush.sln
-win32/config.h
-win32/confmagic.h
-win32/funs.h
-win32/options.h
-win32/patches.h
-win32/pennmush.dsp
-win32/pennmush.dsw
-Configure Portability tool
-config_h.SH Produces config.h
# This section of the file should be automatically configured by
# the Configure script. If it doesn't work, you might try starting
# from the Makefile.old that's included instead, and reporting
-# your problem (including this Makefile) to pennmush-bugs@pennmush.org
+# your problem (including this Makefile) to devteam@cobramush.org
#
# If you want to profile the code, add -pg -a -DPROFILING to CCFLAGS
# and (probably) remove -O
GLOBAL_INSTALL=/usr/libexec/cobramush
# Where to install with 'make debianinstall'
-DEB_INSTALL=$(DESTDIR)/usr/lib/pennmush/game
+DEB_INSTALL=$(DESTDIR)/usr/lib/cobramush/game
DEB_BIN=$(DESTDIR)/usr/games
all: config.h options.h autogen game/mush.cnf
access:
utils/make_access_cnf.sh game
-pennmush.pot:
- (cd src; make ../po/pennmush.pot)
+cobramush.pot:
+ (cd src; make ../po/cobramush.pot)
localized:
-echo "Localizing for your locale..."
(cd src; make announce "CC=$(CC)" "CCFLAGS=$(CCFLAGS)" \
"LDFLAGS=$(LDFLAGS)" "CLIBS=$(CLIBS)" )
-versions: CHANGES*
- -@rm -rf CHANGES*~ CHANGES*bak
- @utils/mkvershlp.pl game/txt/hlp CHANGES*
+versions: game/txt/changes/*
+ -@rm -rf game/txt/changes.txt
+ (cd game/txt && ruby genchanges.rb)
safety:
- $(CP) src/*.c /var/pennmush-bak/src
- $(CP) hdrs/*.h /var/pennmush-bak/hdrs
- $(CP) * /var/pennmush-bak
+ $(CP) src/*.c /var/cobramush-bak/src
+ $(CP) hdrs/*.h /var/cobramush-bak/hdrs
+ $(CP) * /var/cobramush-bak
distdepend: hdrs/funs.h hdrs/cmds.h
(cd src; make depend "CC=$(CC)" "CCFLAGS=$(CCFLAGS)" \
@make versions > /dev/null 2>&1
@make touchswitches > /dev/null 2>&1
@make autogen > /dev/null 2>&1
- @(prcs diff -r$(VS) -N pennmush `cat MANIFEST` | grep -v 'Index:')
+ @(prcs diff -r$(VS) -N cobramush `cat MANIFEST` | grep -v 'Index:')
checkin: versions autogen
@prcs checkin
@touch src/SWITCHES
dist.tar: indent distclean versions touchswitches autogen
- makedist -c pennmush
- tar -cvf /tmp/dist.tar pennmush
+ makedist -c cobramush
+ tar -cvf /tmp/dist.tar cobramush
-pgp -sb /tmp/dist.tar
- -rm -rf pennmush
+ -rm -rf cobramush
CSRImalloc.tar.Z:
(cd src/CSRI; make clean)
;;
esac
else
- echo "Can not find LUA source directory. Check your CobraMUSH installation.">&4
+ echo "Can not find LUA source directory. Check your LUA installation.">&4
exit 1
fi
* It's organized into a linked list of access rules.
*/
struct access {
- char host[BUFFER_LEN]; /**< The host pattern */
- char comment[BUFFER_LEN]; /**< A comment about the rule */
- dbref who; /**< Who created this rule if sitelock used */
- int can; /**< Bitflags of what the host can do */
- int cant; /**< Bitflags of what the host can't do */
- struct access *next; /**< Pointer to next rule in the list */
+ char host[BUFFER_LEN]; /**< The host pattern */
+ char comment[BUFFER_LEN]; /**< A comment about the rule */
+ dbref who; /**< Who created this rule if sitelock used */
+ int can; /**< Bitflags of what the host can do */
+ int cant; /**< Bitflags of what the host can't do */
+ struct access *next; /**< Pointer to next rule in the list */
};
/* These flags are can/can't - a site may or may not be allowed to do them */
-#define ACS_CONNECT 0x1 /* Connect to non-guests */
-#define ACS_CREATE 0x2 /* Create new players */
-#define ACS_GUEST 0x4 /* Connect to guests */
-#define ACS_REGISTER 0x8 /* Site can use the 'register' command */
+#define ACS_CONNECT 0x1 /* Connect to non-guests */
+#define ACS_CREATE 0x2 /* Create new players */
+#define ACS_GUEST 0x4 /* Connect to guests */
+#define ACS_REGISTER 0x8 /* Site can use the 'register' command */
/* These flags are set in the 'can' bit, but they mark special processing */
-#define ACS_SITELOCK 0x10 /* Marker for where to insert @sitelock */
-#define ACS_SUSPECT 0x20 /* All players from this site get SUSPECT */
-#define ACS_DENY_SILENT 0x40 /* Don't log failed attempts */
-#define ACS_REGEXP 0x80 /* Treat the host pattern as a regexp */
+#define ACS_SITELOCK 0x10 /* Marker for where to insert @sitelock */
+#define ACS_SUSPECT 0x20 /* All players from this site get SUSPECT */
+#define ACS_DENY_SILENT 0x40 /* Don't log failed attempts */
+#define ACS_REGEXP 0x80 /* Treat the host pattern as a regexp */
-#define ACS_GOD 0x100 /* God can connect from this site */
-#define ACS_DIRECTOR 0x200 /* Directors can connect from this site */
-#define ACS_ADMIN 0x400 /* Admins can connect from this site */
+#define ACS_GOD 0x100 /* God can connect from this site */
+#define ACS_DIRECTOR 0x200 /* Directors can connect from this site */
+#define ACS_ADMIN 0x400 /* Admins can connect from this site */
/* This is the usual default access */
#define ACS_DEFAULT (ACS_CONNECT|ACS_CREATE|ACS_GUEST)
int site_can_access(const char *hname, int flag, dbref who);
struct access *site_check_access(const char *hname, dbref who, int *rulenum);
int format_access(struct access *ap, int rulenum,
- dbref who
- __attribute__ ((__unused__)), char *buff, char **bp);
+ dbref who
+ __attribute__ ((__unused__)), char *buff, char **bp);
int add_access_sitelock(dbref player, const char *host, dbref who, int can,
- int cant);
+ int cant);
int remove_access_sitelock(const char *pattern);
void do_list_access(dbref player);
int parse_access_options
(const char *opts, dbref *who, int *can, int *cant, dbref player);
-#endif /* __ACCESS_H */
+#endif /* __ACCESS_H */
#define ANSI_END "m"
-#endif /* __ANSI_H */
+#endif /* __ANSI_H */
{NULL, 0, NULL_CHUNK_REFERENCE, 0, TRUE_BOOLEXP, TRUE_BOOLEXP, 0, NULL}
};
-#endif /* __ATR_TAB_H */
+#endif /* __ATR_TAB_H */
*/
struct attr {
- char const *name; /**< Name of attribute */
- int flags; /**< Attribute flags */
- chunk_reference_t data; /**< The attribute's value, compressed */
- dbref creator; /**< The attribute's creator's dbref */
- boolexp write_lock; /**< Attribute lock set */
- boolexp read_lock; /**< Attribute read lock */
- time_t last_modified; /**< Timestamp of last modification */
- ATTR *next; /**< Pointer to next attribute in list */
+ char const *name; /**< Name of attribute */
+ int flags; /**< Attribute flags */
+ chunk_reference_t data; /**< The attribute's value, compressed */
+ dbref creator; /**< The attribute's creator's dbref */
+ boolexp write_lock; /**< Attribute lock set */
+ boolexp read_lock; /**< Attribute read lock */
+ time_t last_modified; /**< Timestamp of last modification */
+ ATTR *next; /**< Pointer to next attribute in list */
};
struct aget_oi {
- ATTR *attribute_part;
- dbref found_on;
+ ATTR *attribute_part;
+ dbref found_on;
};
extern ATTR *atr_match(char const *string);
extern ATTR *atr_sub_branch(ATTR *branch);
extern void atr_new_add(dbref thing, char const *RESTRICT atr,
- char const *RESTRICT s, dbref player, int flags,
- unsigned char derefs, boolexp wlock, boolexp rlock,
- time_t modtime);
+ char const *RESTRICT s, dbref player, int flags,
+ unsigned char derefs, boolexp wlock, boolexp rlock,
+ time_t modtime);
extern int atr_add(dbref thing, char const *RESTRICT atr,
- char const *RESTRICT s, dbref player, int flags);
+ char const *RESTRICT s, dbref player, int flags);
extern int atr_clr(dbref thing, char const *atr, dbref player);
extern ATTR *atr_get(dbref thing, char const *atr);
extern ATTR *atr_get_noparent(dbref thing, char const *atr);
typedef int (*aig_func) (dbref, dbref, dbref, const char *, ATTR *, void *);
extern int atr_iter_get(dbref player, dbref thing, char const *name,
- int mortal, aig_func func, void *args);
+ int mortal, aig_func func, void *args);
extern ATTR *atr_complete_match(dbref player, char const *atr, dbref privs);
extern void atr_free(dbref thing);
extern void atr_cpy(dbref dest, dbref source);
extern char const *convert_atr(int oldatr);
extern int atr_comm_match(dbref thing, dbref player, int type, int end,
- char const *str, int just_match, char *atrname,
- char **abp, dbref *errobj);
+ char const *str, int just_match, char *atrname,
+ char **abp, dbref *errobj);
extern int atr_comm_divmatch(dbref thing, dbref player, int type, int end,
- char const *str, int just_match, char *atrname,
- char **abp, dbref *errobj);
+ char const *str, int just_match, char *atrname,
+ char **abp, dbref *errobj);
extern int one_comm_match(dbref thing, dbref player, const char *atr,
const char *str);
extern int do_set_atr(dbref thing, char const *RESTRICT atr,
extern void do_atrchown(dbref player, char const *arg1, char const *arg2);
extern int string_to_atrflag(dbref player, const char *p);
extern int string_to_atrflagsets(dbref player, const char *p, int *setbits,
- int *clrbits);
+ int *clrbits);
extern const char *atrflag_to_string(int mask);
extern void init_atr_name_tree(void);
extern int can_read_attr_internal(dbref player, dbref obj, ATTR *attr);
extern int can_write_attr_internal(dbref player, dbref obj, ATTR *attr,
- int safe);
+ int safe);
extern unsigned const char *atr_get_compressed_data(ATTR *atr);
extern char *atr_value(ATTR *atr);
extern char *
/* possible attribute flags */
-#define AF_ODARK 0x1 /* OBSOLETE! Leave here but don't use */
-#define AF_INTERNAL 0x2 /* no one can see it or set it */
-#define AF_PRIVILEGE 0x4 /* Only privileged players can change it */
-#define AF_NUKED 0x8 /* OBSOLETE! Leave here but don't use */
-#define AF_LOCKED 0x10 /* Only creator of attrib can change it. */
-#define AF_NOPROG 0x20 /* won't be searched for $ commands. */
-#define AF_MDARK 0x40 /* Only admins can see it */
-#define AF_PRIVATE 0x80 /* Children don't inherit it */
-#define AF_NOCOPY 0x100 /* atr_cpy (for @clone) doesn't copy it */
-#define AF_VISUAL 0x200 /* Everyone can see this attribute */
-#define AF_REGEXP 0x400 /* Match $/^ patterns using regexps */
-#define AF_CASE 0x800 /* Match $/^ patterns case-sensitive */
-#define AF_SAFE 0x1000 /* This attribute may not be modified */
-#define AF_STATIC 0x10000 /* OBSOLETE! Leave here but don't use */
-#define AF_COMMAND 0x20000 /* INTERNAL: value starts with $ */
-#define AF_LISTEN 0x40000 /* INTERNAL: value starts with ^ */
-#define AF_NODUMP 0x80000 /* INTERNAL: attribute is not saved */
-#define AF_LISTED 0x100000 /* INTERNAL: Used in @list attribs */
-#define AF_PREFIXMATCH 0x200000 /* Subject to prefix-matching */
-#define AF_VEILED 0x400000 /* On ex, show presence, not value */
-#define AF_DEBUG 0x800000 /* Show debug when evaluated */
-#define AF_NEARBY 0x1000000 /* Override AF_VISUAL if remote */
-#define AF_PUBLIC 0x2000000 /* Override SAFER_UFUN */
-#define AF_ANON 0x4000000 /* INTERNAL: Attribute doesn't exist in the database */
-#define AF_POWINHERIT 0x8000000 /* Execute with powers of object it's on */
-#define AF_MHEAR 0x20000000 /* ^-listens can be triggered by %! */
-#define AF_AHEAR 0x40000000 /* ^-listens can be triggered by anyone */
+#define AF_ODARK 0x1 /* OBSOLETE! Leave here but don't use */
+#define AF_INTERNAL 0x2 /* no one can see it or set it */
+#define AF_PRIVILEGE 0x4 /* Only privileged players can change it */
+#define AF_NUKED 0x8 /* OBSOLETE! Leave here but don't use */
+#define AF_LOCKED 0x10 /* Only creator of attrib can change it. */
+#define AF_NOPROG 0x20 /* won't be searched for $ commands. */
+#define AF_MDARK 0x40 /* Only admins can see it */
+#define AF_PRIVATE 0x80 /* Children don't inherit it */
+#define AF_NOCOPY 0x100 /* atr_cpy (for @clone) doesn't copy it */
+#define AF_VISUAL 0x200 /* Everyone can see this attribute */
+#define AF_REGEXP 0x400 /* Match $/^ patterns using regexps */
+#define AF_CASE 0x800 /* Match $/^ patterns case-sensitive */
+#define AF_SAFE 0x1000 /* This attribute may not be modified */
+#define AF_STATIC 0x10000 /* OBSOLETE! Leave here but don't use */
+#define AF_COMMAND 0x20000 /* INTERNAL: value starts with $ */
+#define AF_LISTEN 0x40000 /* INTERNAL: value starts with ^ */
+#define AF_NODUMP 0x80000 /* INTERNAL: attribute is not saved */
+#define AF_LISTED 0x100000 /* INTERNAL: Used in @list attribs */
+#define AF_PREFIXMATCH 0x200000 /* Subject to prefix-matching */
+#define AF_VEILED 0x400000 /* On ex, show presence, not value */
+#define AF_DEBUG 0x800000 /* Show debug when evaluated */
+#define AF_NEARBY 0x1000000 /* Override AF_VISUAL if remote */
+#define AF_PUBLIC 0x2000000 /* Override SAFER_UFUN */
+#define AF_ANON 0x4000000 /* INTERNAL: Attribute doesn't exist in the database */
+#define AF_POWINHERIT 0x8000000 /* Execute with powers of object it's on */
+#define AF_MHEAR 0x20000000 /* ^-listens can be triggered by %! */
+#define AF_AHEAR 0x40000000 /* ^-listens can be triggered by anyone */
/* external predefined attributes. */
extern ATTR attr[];
#define AL_CREATOR(alist) ((alist)->creator)
#define AL_FLAGS(alist) ((alist)->flags)
#define AL_DEREFS(alist) ((alist)->data?chunk_derefs((alist)->data):0)
-#define AL_WLock(alist) ((alist)->write_lock)
-#define AL_RLock(alist) ((alist)->read_lock)
-#define AL_MODTIME(alist) ((alist)->last_modified)
+#define AL_WLock(alist) ((alist)->write_lock)
+#define AL_RLock(alist) ((alist)->read_lock)
+#define AL_MODTIME(alist) ((alist)->last_modified)
/* Errors from ok_player_alias */
-#define OPAE_SUCCESS 1
-#define OPAE_INVALID -1
-#define OPAE_TOOMANY -2
-#define OPAE_NULL -3
+#define OPAE_SUCCESS 1
+#define OPAE_INVALID -1
+#define OPAE_TOOMANY -2
+#define OPAE_NULL -3
-#endif /* __ATTRIB_H */
+#endif /* __ATTRIB_H */
extern int eval_boolexp(dbref player, boolexp b, dbref target, unsigned char *switches);
extern boolexp parse_boolexp(dbref player, const char *buf, lock_type ltype);
extern boolexp parse_boolexp_d(dbref player, const char *buf, lock_type ltype,
- int derefs);
+ int derefs);
extern void free_boolexp(boolexp b);
boolexp getboolexp(FILE * f, const char *ltype);
void putboolexp(FILE * f, boolexp b);
from unparse_boolexp.() For @decompile. */
};
extern char *unparse_boolexp(dbref player, boolexp b, enum u_b_f flag);
-#endif /* BOOLEXP_H */
+#endif /* BOOLEXP_H */
typedef struct bufferq BUFFERQ;
struct bufferq {
- char *buffer; /**< Pointer to start of buffer */
- char *buffer_end; /**< Pointer to insertion point in buffer */
- int buffer_size; /**< Size allocated to buffer, in bytes */
- int num_buffered; /**< Number of strings in the buffer */
- char last_string[BUFFER_LEN]; /**< Cache of last string inserted */
- char last_type; /**< Cache of type of last string inserted */
+ char *buffer; /**< Pointer to start of buffer */
+ char *buffer_end; /**< Pointer to insertion point in buffer */
+ int buffer_size; /**< Size allocated to buffer, in bytes */
+ int num_buffered; /**< Number of strings in the buffer */
+ char last_string[BUFFER_LEN]; /**< Cache of last string inserted */
+ char last_type; /**< Cache of type of last string inserted */
};
#define BufferQSize(b) ((b)->buffer_size)
extern BUFFERQ *reallocate_bufferq(BUFFERQ * bq, int lines);
extern void free_bufferq(BUFFERQ * bq);
extern void add_to_bufferq(BUFFERQ * bq, int type, dbref player,
- const char *msg);
+ const char *msg);
extern char *iter_bufferq(BUFFERQ * bq, char **p, dbref *player, int *type,
- time_t * timestamp);
+ time_t * timestamp);
extern int bufferq_lines(BUFFERQ * bq);
extern int isempty_bufferq(BUFFERQ * bq);
#endif
#define DOWNCASE(x) (isupper((unsigned char)x) ? tolower((unsigned char)x) : (x))
#define UPCASE(x) (islower((unsigned char)x) ? toupper((unsigned char)x) : (x))
#endif
-#endif /* CASE_H */
+#endif /* CASE_H */
#define NULL_CHUNK_REFERENCE 0
chunk_reference_t chunk_create(unsigned char const *data, u_int_16 len,
- unsigned char derefs);
+ unsigned char derefs);
void chunk_delete(chunk_reference_t reference);
u_int_16 chunk_fetch(chunk_reference_t reference,
- unsigned char *buffer, u_int_16 buffer_len);
+ unsigned char *buffer, u_int_16 buffer_len);
u_int_16 chunk_len(chunk_reference_t reference);
unsigned char chunk_derefs(chunk_reference_t reference);
void chunk_migration(int count, chunk_reference_t ** references);
void chunk_fork_child(void);
void chunk_fork_done(void);
-#endif /* _CHUNK_H_ */
+#endif /* _CHUNK_H_ */
#define CMD_T_PLAYER 0x10000000
#define CMD_T_ANY 0xF4000000
#define CMD_T_GOD 0x08000000
-#define CMD_T_DIVISION 0x04000000
+#define CMD_T_DIVISION 0x04000000
/* Any unknown or undefined switches will be passed in switches, instead of causing error */
#define CMD_T_SWITCHES 0x02000000
/* Command will fail if object is fixed */
#define CMD_T_NOFIXED 0x00200000
-#define CMD_T_NORPMODE 0x00002000
+#define CMD_T_NORPMODE 0x00002000
/* INTERNAL : Command is listed in @list commands */
#define CMD_T_LISTED 0x00080000
char *args_left[MAX_ARG] __attribute__ ((__unused__)), \
char *arg_right __attribute__ ((__unused__)), \
char *args_right[MAX_ARG] __attribute__ ((__unused__)), \
- int fromport)
+ int fromport)
/** Common command prototype macro */
#define COMMAND_PROTO(command_name) \
typedef struct command_info COMMAND_INFO;
typedef void (*command_func) (COMMAND_INFO *, dbref, dbref, switch_mask, char *,
- char *, char *, char *, char *[MAX_ARG], char *,
- char *[MAX_ARG], int fromport);
+ char *, char *, char *, char *[MAX_ARG], char *,
+ char *[MAX_ARG], int fromport);
/** A hook specification.
*/
struct hook_data {
- dbref obj; /**< Object where the hook attribute is stored. */
- char *attrname; /**< Attribute name of the hook attribute */
+ dbref obj; /**< Object where the hook attribute is stored. */
+ char *attrname; /**< Attribute name of the hook attribute */
};
/** A command.
* This structure represents a command in the table of available commands.
*/
struct command_info {
- const char *name; /**< Canonical name of the command */
- const char *restrict_message; /**< Message sent when command is restricted */
- command_func func; /**< Function to call when command is run */
- unsigned int type; /**< Types of objects that can use the command */
- switch_mask sw; /**< Bitflags of switches this command can take */
+ const char *name; /**< Canonical name of the command */
+ const char *restrict_message; /**< Message sent when command is restricted */
+ command_func func; /**< Function to call when command is run */
+ unsigned int type; /**< Types of objects that can use the command */
+ switch_mask sw; /**< Bitflags of switches this command can take */
boolexp lock;
/** Hooks on this command.
*/
struct {
- struct hook_data before; /**< Hook to evaluate before command */
- struct hook_data after; /**< Hook to evaluate after command */
- struct hook_data ignore; /**< Hook to evaluate to decide if we should ignore hardcoded command */
- struct hook_data override; /**< Hook to override command with $command */
+ struct hook_data before; /**< Hook to evaluate before command */
+ struct hook_data after; /**< Hook to evaluate after command */
+ struct hook_data ignore; /**< Hook to evaluate to decide if we should ignore hardcoded command */
+ struct hook_data override; /**< Hook to override command with $command */
} hooks;
};
* added dynamically, outside of this array.
*/
struct command_list {
- const char *name; /**< Command name */
- const char *switches; /**< Space-separated list of switch names */
- command_func func; /**< Function to call when command is run */
- unsigned int type; /**< Types of objects that can use the command */
+ const char *name; /**< Command name */
+ const char *switches; /**< Space-separated list of switch names */
+ command_func func; /**< Function to call when command is run */
+ unsigned int type; /**< Types of objects that can use the command */
const char *command_lock; /**< Command Lock Boolexp */
};
* associates switch names with switch numbers
*/
struct switch_value {
- const char *name; /**< Name of the switch */
- int value; /**< Number of the switch */
+ const char *name; /**< Name of the switch */
+ int value; /**< Number of the switch */
};
typedef struct com_sort_struc COMSORTSTRUC;
* to command data.
*/
struct com_sort_struc {
- struct com_sort_struc *next; /**< Pointer to next in list */
- COMMAND_INFO *cmd; /**< Command data */
+ struct com_sort_struc *next; /**< Pointer to next in list */
+ COMMAND_INFO *cmd; /**< Command data */
};
/** Permissions for commands.
* (e.g. "player") with the appropriate bitmask
*/
struct command_perms_t {
- const char *name; /**< Permission name */
- unsigned int type; /**< Bitmask for this permission */
+ const char *name; /**< Permission name */
+ unsigned int type; /**< Bitmask for this permission */
};
#define SWITCH_NONE 0
extern void generic_command_failure(dbref player, dbref cause, char *string, int fromport);
extern int command_lock(const char *command, const char *lock);
-#endif /* __COMMAND_H */
+#endif /* __COMMAND_H */
void NORETURN WIN32_CDECL Win32_Exit(int exit_code);
#endif
-#endif /* __COMPILE_H */
+#endif /* __COMPILE_H */
#include "htab.h"
/* TwinCheck Ooref define */
-#define OOREF(x,y,z) ((ooref == NOTHING || x == ooref) ? (y) : (z && y))
+#define OOREF(x,y,z) ((ooref == NOTHING || x == ooref) ? (y) : (z && y))
-#define OOREF_DECL char __ooref_set = 0
+#define OOREF_DECL char __ooref_set = 0
-#define ENTER_OOREF if(options.twinchecks && ooref == NOTHING) { \
- ooref = executor; \
- __ooref_set = 1; \
- }
+#define ENTER_OOREF if(options.twinchecks && ooref == NOTHING) { \
+ ooref = executor; \
+ __ooref_set = 1; \
+ }
-#define LEAVE_OOREF if(__ooref_set) { \
- ooref = NOTHING; \
- __ooref_set = 0; \
- }
+#define LEAVE_OOREF if(__ooref_set) { \
+ ooref = NOTHING; \
+ __ooref_set = 0; \
+ }
/* New Guest Setup Configuration */
-#define GUEST_KEYWORD "GUEST"
-#define GUEST_DESCRIBE "A newcomer to this world, treat it with kindness."
+#define GUEST_KEYWORD "GUEST"
+#define GUEST_DESCRIBE "A newcomer to this world, treat it with kindness."
/* limit on player name length */
#define PLAYER_NAME_LIMIT (options.player_name_len)
#define ATTRIBUTE_NAME_LIMIT 1024
/* Loose limit on command/function name length */
#define COMMAND_NAME_LIMIT 64
-#define MAX_ZONES 30
+#define MAX_ZONES 30
#define NUM_SWITCH_BYTES 22
#define MAX_DIVISION_DEPTH 1000
*/
#define SPILLOVER_THRESHOLD 0
/* #define SPILLOVER_THRESHOLD (MAX_OUTPUT / 2) */
-#define COMMAND_TIME_MSEC 1000 /* time slice length in milliseconds */
-#define COMMAND_BURST_SIZE 100 /* commands allowed per user in a burst */
-#define COMMANDS_PER_TIME 1 /* commands per time slice after burst */
+#define COMMAND_TIME_MSEC 1000 /* time slice length in milliseconds */
+#define COMMAND_BURST_SIZE 100 /* commands allowed per user in a burst */
+#define COMMANDS_PER_TIME 1 /* commands per time slice after burst */
/* Set this somewhere near the recursion limit */
typedef struct options_table OPTTAB;
typedef int (*config_func) (const char *opt, const char *val, void *loc,
- int maxval, int source);
+ int maxval, int source);
/** Runtime configuration parameter.
* This structure represents a runtime configuration option.
*/
typedef struct confparm {
- const char *name; /**< name of option. */
+ const char *name; /**< name of option. */
/** the function handler. */
config_func handler;
- void *loc; /**< place to put this option. */
- int max; /**< max: string length, integer value. */
- int overridden; /**< Has the default been overridden? */
- const char *group; /**< The option's group name */
+ void *loc; /**< place to put this option. */
+ int max; /**< max: string length, integer value. */
+ int overridden; /**< Has the default been overridden? */
+ const char *group; /**< The option's group name */
} COBRA_CONF;
/** Runtime configuration options.
* that are typically set in mush.cnf.
*/
struct options_table {
- char mud_name[128]; /**< The name of the mush */
- int port; /**< The port to listen for connections */
- int ssl_port; /**< The port to listen for SSL connections */
- char input_db[256]; /**< Name of the input database file */
- char output_db[256]; /**< Name of the output database file */
- char flagdb[256]; /**<Name of flag database file */
- char crash_db[256]; /**< Name of the panic database file */
+ char mud_name[128]; /**< The name of the mush */
+ int port; /**< The port to listen for connections */
+ int ssl_port; /**< The port to listen for SSL connections */
+ char input_db[256]; /**< Name of the input database file */
+ char output_db[256]; /**< Name of the output database file */
+ char flagdb[256]; /**<Name of flag database file */
+ char crash_db[256]; /**< Name of the panic database file */
#ifdef USE_MAILER
- char mail_db[256]; /**< Name of the mail database file */
+ char mail_db[256]; /**< Name of the mail database file */
#endif
- dbref player_start; /**< The room in which new players are created */
+ dbref player_start; /**< The room in which new players are created */
dbref guest_start; /**<The room in which new guests are created */
- dbref master_room; /**< The master room for global commands/exits */
+ dbref master_room; /**< The master room for global commands/exits */
dbref sql_master; /**< SQL Cmd Master Room */
- dbref ancestor_room; /**< The ultimate parent room */
- dbref ancestor_exit; /**< The ultimate parent exit */
- dbref ancestor_thing; /**< The ultimate parent thing */
+ dbref ancestor_room; /**< The ultimate parent room */
+ dbref ancestor_exit; /**< The ultimate parent exit */
+ dbref ancestor_thing; /**< The ultimate parent thing */
dbref ancestor_player; /**< The ultimate parent player */
- dbref powerless; /**< known powerless object */
- int idle_timeout; /**< Maximum idle time allowed, in minutes */
- int idle_time; /** Time for the system to consider player 'idle' used in conjuntion with @AUNIDLE */
- int unconnected_idle_timeout; /**< Maximum idle time for connections without dbrefs, in minutes */
+ dbref powerless; /**< known powerless object */
+ int idle_timeout; /**< Maximum idle time allowed, in minutes */
+ int idle_time; /** Time for the system to consider player 'idle' used in conjuntion with @AUNIDLE */
+ int unconnected_idle_timeout; /**< Maximum idle time for connections without dbrefs, in minutes */
int keepalive_timeout; /**< Number of seconds between TCP keepalive pings */
- int dump_interval; /**< Interval between database dumps, in seconds */
+ int dump_interval; /**< Interval between database dumps, in seconds */
char dump_message[256]; /**< Message shown at start of nonforking dump */
char dump_complete[256]; /**< Message shown at end of nonforking dump */
- time_t dump_counter; /**< Time since last dump */
- int ident_timeout; /**< Timeout for ident lookups */
- int max_logins; /**< Maximum total logins allowed at once */
- int max_guests; /**< Maximum guests logins allowed at once */
- int whisper_loudness; /**< % chance that a noisy whisper is overheard */
- int blind_page; /**< Does page default to page/blind? */
- int page_aliases; /**< Does page include aliases? */
- int paycheck; /**< Number of pennies awarded each day of connection */
- int guest_paycheck; /**< Paycheck for guest connections */
- int starting_money; /**< Number of pennies for newly created players */
- int starting_quota; /**< Object quota for newly created players */
+ time_t dump_counter; /**< Time since last dump */
+ int ident_timeout; /**< Timeout for ident lookups */
+ int max_logins; /**< Maximum total logins allowed at once */
+ int max_guests; /**< Maximum guests logins allowed at once */
+ int whisper_loudness; /**< % chance that a noisy whisper is overheard */
+ int blind_page; /**< Does page default to page/blind? */
+ int page_aliases; /**< Does page include aliases? */
+ int paycheck; /**< Number of pennies awarded each day of connection */
+ int guest_paycheck; /**< Paycheck for guest connections */
+ int starting_money; /**< Number of pennies for newly created players */
+ int starting_quota; /**< Object quota for newly created players */
int player_queue_limit; /**< Maximum commands a player can queue at once */
- int queue_chunk; /**< Number of commands run from queue when no input from sockets is waiting */
- int active_q_chunk; /**< Number of commands run from queue when input from sockets is waiting */
- int func_nest_lim; /**< Maximum function recursion depth */
- int func_invk_lim; /**< Maximum number of function invocations */
- int call_lim; /**< Maximum parser calls allowed in a queue cycle */
- char log_wipe_passwd[256]; /**< Password for logwipe command */
- char money_singular[32]; /**< Currency unit name, singular */
- char money_plural[32]; /**< Currency unit name, plural */
- char compressprog[256]; /**< Program to compress database dumps */
- char uncompressprog[256]; /**< Program to uncompress database dumps */
- char compresssuff[256]; /**< Suffix for compressed dump files */
- char chatdb[256]; /**< Name of the chat database file */
- int max_player_chans; /**< Number of channels a player can create */
- int max_channels; /**< Total maximum allowed channels */
- int chan_cost; /**< Cost to create a channel */
- char connect_file[2][256]; /**< Names of text and html connection files */
- char motd_file[2][256]; /**< Names of text and html motd files */
- char newuser_file[2][256]; /**< Names of text and html new user files */
- char register_file[2][256]; /**< Names of text and html registration files */
- char quit_file[2][256]; /**< Names of text and html disconnection files */
- char down_file[2][256]; /**< Names of text and html server down files */
- char full_file[2][256]; /**< Names of text and html server full files */
- char guest_file[2][256]; /**< Names of text and html guest files */
- int log_commands; /**< Should we log all commands? */
- int log_forces; /**< Should we log force commands? */
- int support_pueblo; /**< Should the MUSH send Pueblo tags? */
- int login_allow; /**< Are mortals allowed to log in? */
- int guest_allow; /**< Are guests allowed to log in? */
- int create_allow; /**< Can new players be created? */
- int reverse_shs; /**< Should the SHS routines assume little-endian byte order? */
- char player_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created players. */
- char room_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created rooms. */
- char exit_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created exits. */
- char thing_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created things. */
- char channel_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created channels. */
- int warn_interval; /**< Interval between warning checks */
- time_t warn_counter; /**< Time since last warning check */
- dbref base_room; /**< Room which floating checks consider as the base */
- dbref default_home; /**< Home for the homeless */
- int use_dns; /**< Should we use DNS lookups? */
- char dump_warning_1min[256]; /**< 1 minute nonforking dump warning message */
- char dump_warning_5min[256]; /**< 5 minute nonforking dump warning message */
- int noisy_whisper; /**< Does whisper default to whisper/noisy? */
- int possessive_get; /**< Can possessive get be used? */
- int possessive_get_d; /**< Can possessive get be used on disconnected players? */
- int really_safe; /**< Does the SAFE flag protect objects from nuke */
- int destroy_possessions; /**< Are the possessions of a nuked player nuked? */
- int null_eq_zero; /**< Is null string treated as 0 in math functions? */
- int tiny_booleans; /**< Do strings and db#'s evaluate as false, like TinyMUSH? */
- int tiny_trim_fun; /**< Does the trim function take arguments in TinyMUSH order? */
- int tiny_math; /**< Can you use strings in math functions, like TinyMUSH? */
- int twinchecks; /**< Do twin checks for @force & attribute commands? */
- int adestroy; /**< Is the adestroy attribute available? */
- int amail; /**< Is the amail attribute available? */
- int mail_limit; /**< Maximum number of mail messages per player */
- int player_listen; /**< Does listen work on players? */
- int player_ahear; /**< Does ahear work on players? */
- int startups; /**< Is startup run on startups? */
- int room_connects; /**< Do players trigger aconnect/adisconnect on their location? */
- int ansi_names; /**< Are object names shown in bold? */
- int comma_exit_list; /**< Should exit lists be itemized? */
- int count_all; /**< Are hidden players included in total player counts? */
- int exits_connect_rooms; /**< Does the presence of an exit make a room connected? */
- int zone_control; /**< Are only ZMPs allowed to determine zone-based control? */
- int link_to_object; /**< Can exits be linked to objects? */
- int owner_queues; /**< Are queues tracked by owner or individual object? */
- int dark_noaenter; /**< Do DARK players trigger aenters? */
- int use_ident; /**< Should we do ident checks on connections? */
- char ip_addr[64]; /**< What ip address should the server bind to? */
- char ssl_ip_addr[64]; /**< What ip address should the server bind to? */
- int player_name_spaces; /**< Can players have multiword names? */
- int max_aliases; /**< Maximum allowed aliases per player */
- int forking_dump; /**< Should we fork to dump? */
- int restrict_building; /**< Is the builder power required to build? */
- int free_objects; /**< If builder power is required, can you create without it? */
- int flags_on_examine; /**< Are object flags shown when it's examined? */
- int ex_public_attribs; /**< Are visual attributes shown on examine? */
- int full_invis; /**< Are DARK players anonymous? */
- int silent_pemit; /**< Does pemit default to pemit/silent? */
- dbref max_dbref; /**< Maximum allowable database size */
- int chat_strip_quote; /**< Should we strip initial quotes in chat? */
- char wall_prefix[256]; /**< Prefix for wall announcements */
- int announce_connects; /**< Should dis/connects be announced? */
- char access_file[256]; /**< Name of file of access control rules */
- char names_file[256]; /**< Name of file of forbidden player names */
- int object_cost; /**< Cost to create an object */
- int exit_cost; /**< Cost to create an exit */
+ int queue_chunk; /**< Number of commands run from queue when no input from sockets is waiting */
+ int active_q_chunk; /**< Number of commands run from queue when input from sockets is waiting */
+ int func_nest_lim; /**< Maximum function recursion depth */
+ int func_invk_lim; /**< Maximum number of function invocations */
+ int call_lim; /**< Maximum parser calls allowed in a queue cycle */
+ char log_wipe_passwd[256]; /**< Password for logwipe command */
+ char money_singular[32]; /**< Currency unit name, singular */
+ char money_plural[32]; /**< Currency unit name, plural */
+ char compressprog[256]; /**< Program to compress database dumps */
+ char uncompressprog[256]; /**< Program to uncompress database dumps */
+ char compresssuff[256]; /**< Suffix for compressed dump files */
+ char chatdb[256]; /**< Name of the chat database file */
+ int max_player_chans; /**< Number of channels a player can create */
+ int max_channels; /**< Total maximum allowed channels */
+ int chan_cost; /**< Cost to create a channel */
+ char connect_file[2][256]; /**< Names of text and html connection files */
+ char motd_file[2][256]; /**< Names of text and html motd files */
+ char newuser_file[2][256]; /**< Names of text and html new user files */
+ char register_file[2][256]; /**< Names of text and html registration files */
+ char quit_file[2][256]; /**< Names of text and html disconnection files */
+ char down_file[2][256]; /**< Names of text and html server down files */
+ char full_file[2][256]; /**< Names of text and html server full files */
+ char guest_file[2][256]; /**< Names of text and html guest files */
+ int log_commands; /**< Should we log all commands? */
+ int log_forces; /**< Should we log force commands? */
+ int support_pueblo; /**< Should the MUSH send Pueblo tags? */
+ int login_allow; /**< Are mortals allowed to log in? */
+ int guest_allow; /**< Are guests allowed to log in? */
+ int create_allow; /**< Can new players be created? */
+ int reverse_shs; /**< Should the SHS routines assume little-endian byte order? */
+ char player_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created players. */
+ char room_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created rooms. */
+ char exit_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created exits. */
+ char thing_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created things. */
+ char channel_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on newly created channels. */
+ int warn_interval; /**< Interval between warning checks */
+ time_t warn_counter; /**< Time since last warning check */
+ dbref base_room; /**< Room which floating checks consider as the base */
+ dbref default_home; /**< Home for the homeless */
+ int use_dns; /**< Should we use DNS lookups? */
+ char dump_warning_1min[256]; /**< 1 minute nonforking dump warning message */
+ char dump_warning_5min[256]; /**< 5 minute nonforking dump warning message */
+ int noisy_whisper; /**< Does whisper default to whisper/noisy? */
+ int possessive_get; /**< Can possessive get be used? */
+ int possessive_get_d; /**< Can possessive get be used on disconnected players? */
+ int really_safe; /**< Does the SAFE flag protect objects from nuke */
+ int destroy_possessions; /**< Are the possessions of a nuked player nuked? */
+ int null_eq_zero; /**< Is null string treated as 0 in math functions? */
+ int tiny_booleans; /**< Do strings and db#'s evaluate as false, like TinyMUSH? */
+ int tiny_trim_fun; /**< Does the trim function take arguments in TinyMUSH order? */
+ int tiny_math; /**< Can you use strings in math functions, like TinyMUSH? */
+ int twinchecks; /**< Do twin checks for @force & attribute commands? */
+ int adestroy; /**< Is the adestroy attribute available? */
+ int amail; /**< Is the amail attribute available? */
+ int mail_limit; /**< Maximum number of mail messages per player */
+ int player_listen; /**< Does listen work on players? */
+ int player_ahear; /**< Does ahear work on players? */
+ int startups; /**< Is startup run on startups? */
+ int room_connects; /**< Do players trigger aconnect/adisconnect on their location? */
+ int ansi_names; /**< Are object names shown in bold? */
+ int comma_exit_list; /**< Should exit lists be itemized? */
+ int count_all; /**< Are hidden players included in total player counts? */
+ int exits_connect_rooms; /**< Does the presence of an exit make a room connected? */
+ int zone_control; /**< Are only ZMPs allowed to determine zone-based control? */
+ int link_to_object; /**< Can exits be linked to objects? */
+ int owner_queues; /**< Are queues tracked by owner or individual object? */
+ int dark_noaenter; /**< Do DARK players trigger aenters? */
+ int use_ident; /**< Should we do ident checks on connections? */
+ char ip_addr[64]; /**< What ip address should the server bind to? */
+ char ssl_ip_addr[64]; /**< What ip address should the server bind to? */
+ int player_name_spaces; /**< Can players have multiword names? */
+ int max_aliases; /**< Maximum allowed aliases per player */
+ int forking_dump; /**< Should we fork to dump? */
+ int restrict_building; /**< Is the builder power required to build? */
+ int free_objects; /**< If builder power is required, can you create without it? */
+ int flags_on_examine; /**< Are object flags shown when it's examined? */
+ int ex_public_attribs; /**< Are visual attributes shown on examine? */
+ int full_invis; /**< Are DARK players anonymous? */
+ int silent_pemit; /**< Does pemit default to pemit/silent? */
+ dbref max_dbref; /**< Maximum allowable database size */
+ int chat_strip_quote; /**< Should we strip initial quotes in chat? */
+ char wall_prefix[256]; /**< Prefix for wall announcements */
+ int announce_connects; /**< Should dis/connects be announced? */
+ char access_file[256]; /**< Name of file of access control rules */
+ char names_file[256]; /**< Name of file of forbidden player names */
+ int object_cost; /**< Cost to create an object */
+ int exit_cost; /**< Cost to create an exit */
int division_cost; /**< Cost to create a division */
- int link_cost; /**< Cost to link an exit */
- int room_cost; /**< Cost to dig a room */
- int queue_cost; /**< Deposit to queue a command */
- int quota_cost; /**< Number of objects per quota unit */
- int find_cost; /**< Cost to create an object */
- int page_cost; /**< Cost to create an object */
- int kill_default_cost; /**< Default cost to use 'kill' */
- int kill_min_cost; /**< Minimum cost to use 'kill' */
- int kill_bonus; /**< Percentage of cost paid to victim of 'kill' */
- int queue_loss; /**< 1/queue_loss chance of a command costing a penny */
- int max_pennies; /**< Maximum pennies a player can have */
- int max_guest_pennies; /**< Maximum pennies a guest can have */
- int max_depth; /**< Maximum container depth */
- int max_parents; /**< Maximum parent depth */
- int purge_interval; /**< Time between automatic purges */
- time_t purge_counter; /**< Time since last automatic purge */
- int dbck_interval; /**< Time between automatic dbcks */
- time_t dbck_counter; /**< Time since last automatic dbck */
- int max_attrcount; /**< Maximum number of attributes per object */
- int float_precision; /**< Precision of floating point display */
- int newline_one_char; /**< Should a newline be counted as 1 character or 2? */
- int player_name_len; /**< Maximum length of player names */
- int queue_entry_cpu_time; /**< Maximum cpu time allowed per queue entry */
- int ascii_names; /**< Are object names restricted to ascii characters? */
- int max_global_fns; /**< Maximum number of functions */
- char chunk_swap_file[256]; /**< Name of the attribute swap file */
- int chunk_cache_memory; /**< Memory to use for the attribute cache */
- int chunk_migrate_amount; /**< Number of attrs to migrate each second */
- int read_remote_desc; /**< Can players read DESCRIBE attribute remotely? */
+ int link_cost; /**< Cost to link an exit */
+ int room_cost; /**< Cost to dig a room */
+ int queue_cost; /**< Deposit to queue a command */
+ int quota_cost; /**< Number of objects per quota unit */
+ int find_cost; /**< Cost to create an object */
+ int page_cost; /**< Cost to create an object */
+ int kill_default_cost; /**< Default cost to use 'kill' */
+ int kill_min_cost; /**< Minimum cost to use 'kill' */
+ int kill_bonus; /**< Percentage of cost paid to victim of 'kill' */
+ int queue_loss; /**< 1/queue_loss chance of a command costing a penny */
+ int max_pennies; /**< Maximum pennies a player can have */
+ int max_guest_pennies; /**< Maximum pennies a guest can have */
+ int max_depth; /**< Maximum container depth */
+ int max_parents; /**< Maximum parent depth */
+ int purge_interval; /**< Time between automatic purges */
+ time_t purge_counter; /**< Time since last automatic purge */
+ int dbck_interval; /**< Time between automatic dbcks */
+ time_t dbck_counter; /**< Time since last automatic dbck */
+ int max_attrcount; /**< Maximum number of attributes per object */
+ int float_precision; /**< Precision of floating point display */
+ int newline_one_char; /**< Should a newline be counted as 1 character or 2? */
+ int player_name_len; /**< Maximum length of player names */
+ int queue_entry_cpu_time; /**< Maximum cpu time allowed per queue entry */
+ int ascii_names; /**< Are object names restricted to ascii characters? */
+ int max_global_fns; /**< Maximum number of functions */
+ char chunk_swap_file[256]; /**< Name of the attribute swap file */
+ int chunk_cache_memory; /**< Memory to use for the attribute cache */
+ int chunk_migrate_amount; /**< Number of attrs to migrate each second */
+ int read_remote_desc; /**< Can players read DESCRIBE attribute remotely? */
#ifdef HAS_OPENSSL
- char ssl_private_key_file[256]; /**< File to load the server's cert from */
- char ssl_ca_file[256]; /**< File to load the CA certs from */
- int ssl_require_client_cert; /**< Are clients required to present certs? */
+ char ssl_private_key_file[256]; /**< File to load the server's cert from */
+ char ssl_ca_file[256]; /**< File to load the CA certs from */
+ int ssl_require_client_cert; /**< Are clients required to present certs? */
#endif
- int mem_check; /**< Turn on the memory allocation checker? */
- int use_quota; /**< Are quotas enabled? */
- int empty_attrs; /**< Are empty attributes preserved? */
+ int mem_check; /**< Turn on the memory allocation checker? */
+ int use_quota; /**< Are quotas enabled? */
+ int empty_attrs; /**< Are empty attributes preserved? */
int function_side_effects; /**< Turn on side effect functions? */
char error_log[256]; /**< File to log connections */
char connect_log[256]; /**< File to log connections */
- char wizard_log[256]; /**< File to log wizard commands */
+ char wizard_log[256]; /**< File to log wizard commands */
char command_log[256]; /**< File to log suspect commands */
char trace_log[256]; /**< File to log trace data */
char checkpt_log[256]; /**< File to log checkpoint data */
extern HASHTAB local_options;
extern COBRA_CONF *add_config(const char *name, config_func handler, void *loc,
- int max, const char *group);
+ int max, const char *group);
extern COBRA_CONF *new_config(void);
extern COBRA_CONF *get_config(const char *name);
int cf_bool(const char *opt, const char *val, void *loc, int maxval,
- int source);
+ int source);
int cf_str(const char *opt, const char *val, void *loc, int maxval, int source);
int cf_int(const char *opt, const char *val, void *loc, int maxval, int source);
int cf_dbref(const char *opt, const char *val, void *loc, int maxval,
- int source);
+ int source);
int cf_flag(const char *opt, const char *val, void *loc, int maxval,
- int source);
+ int source);
int cf_time(const char *opt, const char *val, void *loc, int maxval,
- int source);
+ int source);
#define NUMQ 36
#define TINYPORT (options.port)
#define SSLPORT (options.ssl_port)
#define PLAYER_START (options.player_start)
-#define GUEST_START (options.guest_start)
+#define GUEST_START (options.guest_start)
#define MASTER_ROOM (options.master_room)
#define ANCESTOR_ROOM (options.ancestor_room)
#define ANCESTOR_EXIT (options.ancestor_exit)
#define READ_REMOTE_DESC (options.read_remote_desc)
-#define GUEST_PREFIX (options.guest_prefix)
+#define GUEST_PREFIX (options.guest_prefix)
#define GST_NUMBERING (options.guest_roman_numeral)
#define GUEST_NUMBER(x) (const char *) (GST_NUMBERING ? ArabicToRoman(x) : unparse_number((NVAL) x))
#define PLAYER_DEF_POWERGROUP (options.player_powergroup)
typedef struct globals_table GLOBALTAB;
struct globals_table {
- int database_loaded; /**< True after the database has been read. */
- char dumpfile[200]; /**< File name to dump database to */
- time_t start_time; /**< MUSH start time (since process exec'd) */
- time_t first_start_time; /**< MUSH start time (since last shutdown) */
- time_t last_dump_time; /**< Time of last successful db save */
- int reboot_count; /**< Number of reboots so far */
- int paranoid_dump; /**< if paranoid, scan before dumping */
- int paranoid_checkpt; /**< write out an okay message every x objs */
- long indb_flags; /**< flags set in the input database */
- int on_second; /**< is it time for per-second processes? */
+ int database_loaded; /**< True after the database has been read. */
+ char dumpfile[200]; /**< File name to dump database to */
+ time_t start_time; /**< MUSH start time (since process exec'd) */
+ time_t first_start_time; /**< MUSH start time (since last shutdown) */
+ time_t last_dump_time; /**< Time of last successful db save */
+ int reboot_count; /**< Number of reboots so far */
+ int paranoid_dump; /**< if paranoid, scan before dumping */
+ int paranoid_checkpt; /**< write out an okay message every x objs */
+ long indb_flags; /**< flags set in the input database */
+ int on_second; /**< is it time for per-second processes? */
};
extern GLOBALTAB globals;
-#endif /* __CONF_H */
+#endif /* __CONF_H */
#include "externs.h"
#include "command.h"
-#define CRON_SPEC_SEP ' '
-#define CRON_NUM_SEP ','
-#define CRON_SKIP_SEP '/'
-#define CRON_RANGE_SEP '-'
-#define CRON_WILDCARD '*'
-
-#define CRON_MINUTE_MAX 59
-#define CRON_HOUR_MAX 23
-#define CRON_DAY_MAX 30
-#define CRON_MONTH_MAX 11
-#define CRON_WDAY_MAX 6
-
-#define CRON_GLOBAL -1
-
-#define CRON_NAME_LEN 32
-#define CRON_FORMAT_LEN 128
-
-#define CF_COMMAND 0x1
-#define CF_FUNCTION 0x2
-#define CF_HALT 0x4
-
-#define CRON_Command(job) ((job)->type & CF_COMMAND)
-#define CRON_Function(job) ((job)->type & CF_FUNCTION)
-#define CRON_Halt(job) ((job)->type & CF_HALT)
-
-#define CF_DEFAULT (0)
-
-#define CM_JANUARY 0
-#define CM_FEBRUARY 1
-#define CM_MARCH 2
-#define CM_APRIL 3
-#define CM_MAY 4
-#define CM_JUNE 5
-#define CM_JULY 6
-#define CM_AUGUST 7
-#define CM_SEPTEMBER 8
-#define CM_OCTOBER 9
-#define CM_NOVEMBER 10
-#define CM_DECEMBER 11
-
-#define CD_SUNDAY 0
-#define CD_MONDAY 1
-#define CD_TUESDAY 2
-#define CD_WEDNESDAY 3
-#define CD_THURSDAY 4
-#define CD_FRIDAY 5
-#define CD_SATURDAY 6
+#define CRON_SPEC_SEP ' '
+#define CRON_NUM_SEP ','
+#define CRON_SKIP_SEP '/'
+#define CRON_RANGE_SEP '-'
+#define CRON_WILDCARD '*'
+
+#define CRON_MINUTE_MAX 59
+#define CRON_HOUR_MAX 23
+#define CRON_DAY_MAX 30
+#define CRON_MONTH_MAX 11
+#define CRON_WDAY_MAX 6
+
+#define CRON_GLOBAL -1
+
+#define CRON_NAME_LEN 32
+#define CRON_FORMAT_LEN 128
+
+#define CF_COMMAND 0x1
+#define CF_FUNCTION 0x2
+#define CF_HALT 0x4
+
+#define CRON_Command(job) ((job)->type & CF_COMMAND)
+#define CRON_Function(job) ((job)->type & CF_FUNCTION)
+#define CRON_Halt(job) ((job)->type & CF_HALT)
+
+#define CF_DEFAULT (0)
+
+#define CM_JANUARY 0
+#define CM_FEBRUARY 1
+#define CM_MARCH 2
+#define CM_APRIL 3
+#define CM_MAY 4
+#define CM_JUNE 5
+#define CM_JULY 6
+#define CM_AUGUST 7
+#define CM_SEPTEMBER 8
+#define CM_OCTOBER 9
+#define CM_NOVEMBER 10
+#define CM_DECEMBER 11
+
+#define CD_SUNDAY 0
+#define CD_MONDAY 1
+#define CD_TUESDAY 2
+#define CD_WEDNESDAY 3
+#define CD_THURSDAY 4
+#define CD_FRIDAY 5
+#define CD_SATURDAY 6
typedef struct named_value NVALUE;
typedef struct named_value_alias NVALUE_ALIAS;
#define cfree(p) trace__free((p), __FILE__, __LINE__)
#define free(p) trace__free((p), __FILE__, __LINE__)
-#else /* CSRI_TRACE */
+#else /* CSRI_TRACE */
extern univptr_t malloc _((size_t nbytes));
extern univptr_t calloc _((size_t nelem, size_t elsize));
extern Free_t free _((univptr_t cp));
extern Free_t cfree _((univptr_t cp));
-#endif /* CSRI_TRACE */
+#endif /* CSRI_TRACE */
extern void mal_debug _((int level));
extern void mal_dumpleaktrace _((FILE * fp));
#ifndef alloca
#define alloca(n) __builtin_alloca(n)
#endif
-#endif /* __GNUC__ */
+#endif /* __GNUC__ */
#ifdef sparc
#define alloca(n) __builtin_alloca(n)
-#endif /* sparc */
+#endif /* sparc */
-#endif /* __CSRIMALLOC_H__ */ /* Do not add anything after this line */
+#endif /* __CSRIMALLOC_H__ */ /* Do not add anything after this line */
extern int depth;
-extern dbref first_free; /* pointer to free list */
+extern dbref first_free; /* pointer to free list */
/*-------------------------------------------------------------------------
* Database access macros
#define IsRoom(x) (!!(Typeof(x) & TYPE_ROOM))
#define IsThing(x) (!!(Typeof(x) & TYPE_THING))
#define IsExit(x) (!!(Typeof(x) & TYPE_EXIT))
-#define IsDivision(x) (GoodObject(x) && !!(Typeof(x) & TYPE_DIVISION))
+#define IsDivision(x) (GoodObject(x) && !!(Typeof(x) & TYPE_DIVISION))
#define IsMasterDivision(x) (GoodObject(x) && IsDivision(x) && Division(x) == NOTHING)
/* Was Destroyed() */
#define Leave_Behind(x) has_flag_by_name(x, "LEAVE_BEHIND", TYPE_THING | TYPE_PLAYER)
/* Can guy talk? */
-#define Mute(x) (has_flag_by_name(x, "MUTE", TYPE_THING | TYPE_PLAYER | TYPE_ROOM))
-#define IsMuted(x,y) (Mute(x) || Mute(Location(x)))
-#define CanSpeak(x,y) (!Mute(x) && (Admin(x) || Loud(x) || (!Mute(y) && eval_lock(x, y, Speech_Lock))))
+#define Mute(x) (has_flag_by_name(x, "MUTE", TYPE_THING | TYPE_PLAYER | TYPE_ROOM))
+#define IsMuted(x,y) (Mute(x) || Mute(Location(x)))
+#define CanSpeak(x,y) (!Mute(x) && (Admin(x) || Loud(x) || (!Mute(y) && eval_lock(x, y, Speech_Lock))))
/******* Player toggles */
-#define Connected(x) (IS(x, TYPE_PLAYER, "CONNECTED")) /* 0x200 */
-#define Track_Money(x) (IS(x, TYPE_PLAYER, "TRACK_MONEY"))
-#define Inheritable(x) (IS(x, TYPE_PLAYER, "INHERITABLE"))
-#define ZMaster(x) (IS(x, TYPE_PLAYER, "ZONE")) /* 0x800 */
+#define Connected(x) (IS(x, TYPE_PLAYER, "CONNECTED")) /* 0x200 */
+#define Track_Money(x) (IS(x, TYPE_PLAYER, "TRACK_MONEY"))
+#define Inheritable(x) (IS(x, TYPE_PLAYER, "INHERITABLE"))
+#define ZMaster(x) (IS(x, TYPE_PLAYER, "ZONE")) /* 0x800 */
#define Unregistered(x) (LEVEL(x) <= LEVEL_UNREGISTERED)
#define Fixed(x) (IS(Owner(x), TYPE_PLAYER, "FIXED"))
#ifdef RPMODE_SYS
-#define RPMODE(x) (IS(Owner(x), TYPE_PLAYER, "RPMODE"))
-#define Blind(x) (IS(x, TYPE_PLAYER, "BLIND") && (ICRoom(Location(x)) || RPAPPROVED(Location(x))))
-#define ICRoom(x) (IS(x, TYPE_ROOM, "ICFUNCS"))
-#define RPAPPROVED(x) (IS(x, TYPE_THING, "RPAPPROVED"))
-#define Paralyzed(x) (IS(x, TYPE_PLAYER, "PARALYZED") && (ICRoom(Location(x)) || RPAPPROVED(Location(x))))
+#define RPMODE(x) (IS(Owner(x), TYPE_PLAYER, "RPMODE"))
+#define Blind(x) (IS(x, TYPE_PLAYER, "BLIND") && (ICRoom(Location(x)) || RPAPPROVED(Location(x))))
+#define ICRoom(x) (IS(x, TYPE_ROOM, "ICFUNCS"))
+#define RPAPPROVED(x) (IS(x, TYPE_THING, "RPAPPROVED"))
+#define Paralyzed(x) (IS(x, TYPE_PLAYER, "PARALYZED") && (ICRoom(Location(x)) || RPAPPROVED(Location(x))))
#define IsParalyzed(x) (Paralyzed(x) || Paralyzed(Owner(x)))
#else
-#define RPMODE(x) (Fixed(x))
+#define RPMODE(x) (Fixed(x))
#endif
/* Flags that apply to players, and all their stuff,
#define Gagged(x) (IS(Owner(x), TYPE_PLAYER, "GAGGED"))
#define ShowAnsi(x) (IS(Owner(x), TYPE_PLAYER, "ANSI"))
#define ShowAnsiColor(x) (IS(Owner(x), TYPE_PLAYER, "COLOR"))
-#define InProg(x) (IS(x, TYPE_PLAYER, "INPROGRAM"))
+#define InProg(x) (IS(x, TYPE_PLAYER, "INPROGRAM"))
/******* Thing toggles */
#define DestOk(x) (IS(x, TYPE_THING, "DESTROY_OK"))
#define NoLeave(x) (IS(x, TYPE_THING, "NOLEAVE"))
#define ThingListen(x) (IS(x, TYPE_THING, "MONITOR"))
#define ThingInhearit(x) \
- (IS(x, TYPE_THING, "LISTEN_PARENT")) /* 0x80 */
+ (IS(x, TYPE_THING, "LISTEN_PARENT")) /* 0x80 */
#define ThingZTel(x) (IS(x, TYPE_THING, "Z_TEL"))
/******* Room toggles */
-#define Floating(x) (IS(x, TYPE_ROOM, "FLOATING")) /* 0x8 */
-#define Abode(x) (IS(x, TYPE_ROOM, "ABODE")) /* 0x10 */
-#define JumpOk(x) (IS(x, TYPE_ROOM, "JUMP_OK")) /* 0x20 */
-#define NoTel(x) (IS(x, TYPE_ROOM, "NO_TEL")) /* 0x40 */
-#define RoomListen(x) (IS(x, TYPE_ROOM, "LISTENER")) /* 0x100 */
-#define RoomZTel(x) (IS(x, TYPE_ROOM, "Z_TEL")) /* 0x200 */
-#define RoomInhearit(x) (IS(x, TYPE_ROOM, "LISTEN_PARENT")) /* 0x400 */
+#define Floating(x) (IS(x, TYPE_ROOM, "FLOATING")) /* 0x8 */
+#define Abode(x) (IS(x, TYPE_ROOM, "ABODE")) /* 0x10 */
+#define JumpOk(x) (IS(x, TYPE_ROOM, "JUMP_OK")) /* 0x20 */
+#define NoTel(x) (IS(x, TYPE_ROOM, "NO_TEL")) /* 0x40 */
+#define RoomListen(x) (IS(x, TYPE_ROOM, "LISTENER")) /* 0x100 */
+#define RoomZTel(x) (IS(x, TYPE_ROOM, "Z_TEL")) /* 0x200 */
+#define RoomInhearit(x) (IS(x, TYPE_ROOM, "LISTEN_PARENT")) /* 0x400 */
-#define Uninspected(x) (IS(x, TYPE_ROOM, "UNINSPECTED")) /* 0x1000 */
+#define Uninspected(x) (IS(x, TYPE_ROOM, "UNINSPECTED")) /* 0x1000 */
#define ZTel(x) (ThingZTel(x) || RoomZTel(x))
/******* Exit toggles */
-#define Cloudy(x) (IS(x, TYPE_EXIT, "CLOUDY")) /* 0x8 */
+#define Cloudy(x) (IS(x, TYPE_EXIT, "CLOUDY")) /* 0x8 */
/* Flags anything can have */
#define Going_Twice(x) (has_flag_by_name(x, "GOING_TWICE", NOTYPE))
#define Halted(x) (has_flag_by_name(x, "HALT", NOTYPE))
#define Haven(x) (has_flag_by_name(x, "HAVEN", NOTYPE))
-#define Inherit(x) (has_flag_by_name(x, "INHERIT", TYPE_THING|TYPE_EXIT|TYPE_ROOM))
+#define Inherit(x) (has_flag_by_name(x, "INHERIT", TYPE_THING|TYPE_EXIT|TYPE_ROOM))
#define Light(x) (has_flag_by_name(x, "LIGHT", NOTYPE))
#define LinkOk(x) (has_flag_by_name(x, "LINK_OK", NOTYPE))
-#define Loud(x) (has_flag_by_name(x, "LOUD", NOTYPE))
+#define Loud(x) (has_flag_by_name(x, "LOUD", NOTYPE))
#define Mistrust(x) (has_flag_by_name(x, "MISTRUST", TYPE_THING|TYPE_EXIT|TYPE_ROOM))
#define NoCommand(x) (has_flag_by_name(x, "NO_COMMAND", NOTYPE))
#define NoWarn(x) (has_flag_by_name(x, "NOWARN", NOTYPE))
/* Non-mortal checks */
#define TC_God(x) ((x) == GOD)
-#define God(x) OOREF(x,TC_God(x),TC_God(ooref))
-#define TC_Director(x) (God(x) || (LEVEL(x) >= LEVEL_DIRECTOR && div_powover(x,x,"Privilege")))
-#define Director(x) OOREF(x,TC_Director(x),TC_Director(ooref))
-#define TC_Admin(x) (LEVEL(x) >= LEVEL_ADMIN && div_powover(x,x,"Privilege"))
-#define Admin(x) OOREF(x,TC_Admin(x), TC_Admin(ooref))
+#define God(x) OOREF(x,TC_God(x),TC_God(ooref))
+#define TC_Director(x) (God(x) || (LEVEL(x) >= LEVEL_DIRECTOR && div_powover(x,x,"Privilege")))
+#define Director(x) OOREF(x,TC_Director(x),TC_Director(ooref))
+#define TC_Admin(x) (LEVEL(x) >= LEVEL_ADMIN && div_powover(x,x,"Privilege"))
+#define Admin(x) OOREF(x,TC_Admin(x), TC_Admin(ooref))
#define IsQuiet(x) (Quiet(x) || Quiet(Owner(x)))
#define AreQuiet(x,y) (Quiet(x) || (Quiet(y) && (Owner(y) == x)))
(Audible(x) && atr_get_noparent(x,"FORWARDLIST")))
/* Was Dark() */
#define TC_DarkLegal(x) (Dark(x) && (Admin(x) || !Alive(x)))
-#define DarkLegal(x) OOREF(x,TC_DarkLegal(x), TC_DarkLegal(ooref))
+#define DarkLegal(x) OOREF(x,TC_DarkLegal(x), TC_DarkLegal(ooref))
/* This is carefully ordered, from most to least likely. Hopefully. */
/* AF_PUBLIC overrides SAFER_UFUN */
#define TC_CanEvalAttr(x,y,a) (CanEval(x,y) || AF_Public(a))
-#define CanEvalAttr(x,y,a) OOREF(x,TC_CanEvalAttr(x,y,a), TC_CanEvalAttr(ooref,y,a))
+#define CanEvalAttr(x,y,a) OOREF(x,TC_CanEvalAttr(x,y,a), TC_CanEvalAttr(ooref,y,a))
/* Note that this is a utility to determine the objects which may or may */
/* not be controlled, rather than a strict check for the INHERIT flag */
*
*/
struct object {
- const char *name; /**< The name of the object */
+ const char *name; /**< The name of the object */
/** An overloaded pointer.
* For things and players, points to container object.
* For exits, points to destination.
* For rooms, points to drop-to.
*/
dbref location;
- dbref contents; /**< Pointer to first item */
+ dbref contents; /**< Pointer to first item */
/** An overloaded pointer.
* For things and players, points to home.
* For rooms, points to first exit.
* For exits, points to source room.
*/
dbref exits;
- dbref next; /**< pointer to next in contents/exits chain */
- dbref parent; /**< pointer to parent object */
- struct lock_list *locks; /**< list of locks set on the object */
- dbref owner; /**< who controls this object */
- dbref zone; /**< zone master object number */
- int penn; /**< number of pennies object contains */
- int warnings; /**< bitflags of warning types */
- time_t creation_time; /**< Time/date of object creation */
+ dbref next; /**< pointer to next in contents/exits chain */
+ dbref parent; /**< pointer to parent object */
+ struct lock_list *locks; /**< list of locks set on the object */
+ dbref owner; /**< who controls this object */
+ dbref zone; /**< zone master object number */
+ int penn; /**< number of pennies object contains */
+ int warnings; /**< bitflags of warning types */
+ time_t creation_time; /**< Time/date of object creation */
/** Last modifiction time.
* For players, the number of failed logins.
* For other objects, the time/date of last modification to its attributes.
*/
time_t modification_time;
const char *lastmod; /**< Last Modification */
- int attrcount; /**< Number of attribs on the object */
- int type; /**< Object's type */
- object_flag_type flags; /**< Pointer to flag bit array */
- DIVISION division; /**< Division info for object */
+ int attrcount; /**< Number of attribs on the object */
+ int type; /**< Object's type */
+ object_flag_type flags; /**< Pointer to flag bit array */
+ DIVISION division; /**< Division info for object */
#ifdef RPMODE_SYS
struct rplog_t rplog;
#endif /* RPMODE_SYS */
- ALIST *list; /**< list of attributes on the object */
+ ALIST *list; /**< list of attributes on the object */
};
/** A structure to hold database statistics.
* counts of various objects in the database.
*/
struct db_stat_info {
- int total; /**< Total count */
- int players; /**< Player count */
- int rooms; /**< Room count */
- int exits; /**< Exit count */
- int things; /**< Thing count */
- int divisions; /**< Division count */
+ int total; /**< Total count */
+ int players; /**< Player count */
+ int rooms; /**< Room count */
+ int exits; /**< Exit count */
+ int things; /**< Thing count */
+ int divisions; /**< Division count */
int channels; /**< Channel count */
- int garbage; /**< Garbage count */
+ int garbage; /**< Garbage count */
};
extern struct object *db;
extern void *set_objdata(dbref thing, const char *keybase, void *data);
extern void clear_objdata(dbref thing);
extern void convert_object_powers(dbref, int); /* the code is in division.c..
- * but proto put here cause it uses the object struct
- */
+ * but proto put here cause it uses the object struct
+ */
#define DOLIST(var, first)\
for((var) = (first); GoodObject((var)); (var) = Next(var))
* stored in a doubly-linked list sorted by message recipient.
*/
struct mail {
- struct mail *next; /**< Pointer to next message */
- struct mail *prev; /**< Pointer to previous message */
- dbref to; /**< Recipient dbref */
- dbref from; /**< Sender's dbref */
- time_t from_ctime; /**< Sender's creation time */
- chunk_reference_t msgid; /**< Message text, compressed */
- time_t time; /**< Message date/time */
- unsigned char *subject; /**< Message subject, compressed */
- int read; /**< Bitflags of message status */
+ struct mail *next; /**< Pointer to next message */
+ struct mail *prev; /**< Pointer to previous message */
+ dbref to; /**< Recipient dbref */
+ dbref from; /**< Sender's dbref */
+ time_t from_ctime; /**< Sender's creation time */
+ chunk_reference_t msgid; /**< Message text, compressed */
+ time_t time; /**< Message date/time */
+ unsigned char *subject; /**< Message subject, compressed */
+ int read; /**< Bitflags of message status */
};
typedef struct mail MAIL;
if (SW_ISSET(sw, SWITCH_SPOOF) && (controls(player, cause) || Can_Nspemit(player))) \
player = cause;
-#endif /* __DBDEFS_H */
+#endif /* __DBDEFS_H */
extern void putref(FILE * f, long int ref);
extern void putstring(FILE * f, const char *s);
extern void db_write_labeled_string(FILE * f, char const *label,
- char const *value);
+ char const *value);
extern void db_write_labeled_number(FILE * f, char const *label, int value);
extern void db_write_labeled_dbref(FILE * f, char const *label, dbref value);
extern void db_write_flag_db(FILE *);
extern const char *getstring_noalloc(FILE * f);
extern long getref(FILE * f);
extern void db_read_this_labeled_string(FILE * f, const char *label,
- char **val);
+ char **val);
extern void db_read_labeled_string(FILE * f, char **label, char **val);
extern void db_read_this_labeled_number(FILE * f, const char *label, int *val);
extern void db_read_labeled_number(FILE * f, char **label, int *val);
#define _DIVISION_H_
/* LIMITS {{{1 */
-#define MAX_LEVEL 30
+#define MAX_LEVEL 30
#define DP_BYTES ((ps_tab.powerbits >> 3)+1) /* Spots for powers (DP_BYTES * 8) == Max Powers. This is uped automatically */
-#define MAX_DIVREC 12 /* Max Division Command Recursion */
+#define MAX_DIVREC 12 /* Max Division Command Recursion */
/* PowerScope Levels {{{1 */
-#define YES 3
-#define YESLTE 2
-#define YESLT 1
-#define NO 0
+#define YES 3
+#define YESLTE 2
+#define YESLT 1
+#define NO 0
/* PREDEFINED LEVELS {{{1 */
-#define LEVEL_GOD 30
-#define LEVEL_DIRECTOR 29 /* This fills the spot for wizard status */
-#define LEVEL_ADMIN 28
+#define LEVEL_GOD 30
+#define LEVEL_DIRECTOR 29 /* This fills the spot for wizard status */
+#define LEVEL_ADMIN 28
#define LEVEL_SYSCODER 27
#define LEVEL_SYSBUILDER 26
#define LEVEL_GENERALBUILDER 25
-#define LEVEL_EMPHEAD 24
+#define LEVEL_EMPHEAD 24
#define LEVEL_EMPADMIN 23
#define LEVEL_EMPBUILDER 22
#define LEVEL_RPADMIN 21
#define LEVEL_GUEST 1
/* Old CobraMUSH PowerBits {{{1 - Kept for compatibility */
-#define POW_DIVISION 1 /* @DIVCREATE/@DIVDELETE */
-#define POW_ATTACH 2 /* @ATTACH & @DETACH LTE */
-#define POW_ATTACH_LT 3 /* @ATTACH LT */
-#define POW_BCREATE 4 /* @PCREATE/BUILDER & @NEWPASS BUILDER */
-#define POW_EMPOWER 5 /* @EMPOWER RANKS LT */
-#define POW_MODIFY 6 /* Full MODIFY */
-#define POW_MODIFY_LTE 7 /* LTE */
-#define POW_MODIFY_LT 8 /* LT */
-#define POW_RERANK 9 /* RERANK LTE */
-#define POW_RERANK_LT 10 /* RERANKK LT */
-#define POW_SEE_ALL 11 /* Full SeeAll */
-#define POW_SEE_ALL_LTE 12 /* SeeAll LTE */
-#define POW_SEE_ALL_LT 13 /* SeeAll LT */
-#define POW_SUMMON 14 /* Summon other players to your location */
-#define POW_SUMMON_LT 15 /* Summon players of lower class level */
-#define POW_JOIN 16 /* Join other players */
-#define POW_JOIN_LT 17 /* Join other players of lower class level */
-#define POW_ANNOUNCE 18 /* Power to use @ann, @gann and @dann */
-#define POW_PRIVILEGE 19 /* Expands the functionality of basic powerz */
-#define POW_TPORT_T 20 /* Tport Anything */
-#define POW_TPORT_T_LTE 21 /* Tport Anything LTE */
-#define POW_TPORT_T_LT 22 /* Tport Anything LT */
-#define POW_TPORT_O 23 /* Tport Anywhere */
-#define POW_TPORT_O_LTE 24 /* Tport Anywhere LTE */
-#define POW_TPORT_O_LT 25 /* Tport Anywhere LT */
-#define POW_EMPIRE 26 /* Able to use empire related commands */
+#define POW_DIVISION 1 /* @DIVCREATE/@DIVDELETE */
+#define POW_ATTACH 2 /* @ATTACH & @DETACH LTE */
+#define POW_ATTACH_LT 3 /* @ATTACH LT */
+#define POW_BCREATE 4 /* @PCREATE/BUILDER & @NEWPASS BUILDER */
+#define POW_EMPOWER 5 /* @EMPOWER RANKS LT */
+#define POW_MODIFY 6 /* Full MODIFY */
+#define POW_MODIFY_LTE 7 /* LTE */
+#define POW_MODIFY_LT 8 /* LT */
+#define POW_RERANK 9 /* RERANK LTE */
+#define POW_RERANK_LT 10 /* RERANKK LT */
+#define POW_SEE_ALL 11 /* Full SeeAll */
+#define POW_SEE_ALL_LTE 12 /* SeeAll LTE */
+#define POW_SEE_ALL_LT 13 /* SeeAll LT */
+#define POW_SUMMON 14 /* Summon other players to your location */
+#define POW_SUMMON_LT 15 /* Summon players of lower class level */
+#define POW_JOIN 16 /* Join other players */
+#define POW_JOIN_LT 17 /* Join other players of lower class level */
+#define POW_ANNOUNCE 18 /* Power to use @ann, @gann and @dann */
+#define POW_PRIVILEGE 19 /* Expands the functionality of basic powerz */
+#define POW_TPORT_T 20 /* Tport Anything */
+#define POW_TPORT_T_LTE 21 /* Tport Anything LTE */
+#define POW_TPORT_T_LT 22 /* Tport Anything LT */
+#define POW_TPORT_O 23 /* Tport Anywhere */
+#define POW_TPORT_O_LTE 24 /* Tport Anywhere LTE */
+#define POW_TPORT_O_LT 25 /* Tport Anywhere LT */
+#define POW_EMPIRE 26 /* Able to use empire related commands */
/* 27 was a YV Only Power */
-#define POW_MANAGEMENT 28 /* ability to use game management commands */
-#define POW_CEMIT 29 /* Can @cemit */
-#define POW_NOQUOTA 30 /* Has no quota restrictions */
-#define POW_PCREATE 31 /* Can @pcreate */
-#define POW_GFUNCS 32 /* Can add global @functions */
-#define POW_SEARCH 33 /* Can @search anything in divscope */
-#define POW_SEARCH_LTE 34 /* Can @search anything LTE " */
-#define POW_SEARCH_LT 35 /* Can @seach LT */
-#define POW_HALT 36 /* Can @halt in divscope */
-#define POW_HALT_LTE 37 /* @halt LTE */
-#define POW_HALT_LT 38 /* @halt LT */
-#define POW_IDLE 39 /* no inactivity timeout */
-#define POW_PS 40 /* Can look at anyones queuein divscope */
-#define POW_PS_LTE 41 /* Can look at LTE queue */
-#define POW_PS_LT 42 /* Can look at LT queue */
-#define POW_QUEUE 43 /* queue limit of db_top */
-#define POW_PEMIT 44 /* Can @pemit HAVEN players */
-#define POW_PEMIT_LTE 45 /* @pemit LTE */
-#define POW_PEMIT_LT 46 /* @pe LT */
-#define POW_CQUOTAS 47 /* Can change quotas in divscope */
-#define POW_CQUOTAS_LTE 48 /* LTE */
-#define POW_CQUOTAS_LT 49 /* LT */
-#define POW_LOGIN 50 /* Login anytime */
-#define POW_HIDE 51 /* Can @hide */
-#define POW_NOPAY 52 /* need no money */
-#define POW_BUILD 53 /* Can use builder commands */
-#define POW_LFINGERS 54 /* can grab stuff remotely */
-#define POW_LFINGERS_LTE 55 /* LTE */
-#define POW_LFINGERS_LT 56 /* LT */
-#define POW_BOOT 57 /* can @boot */
-#define POW_BOOT_LTE 58 /* LTE */
-#define POW_BOOT_LT 59 /* LT */
-#define POW_POLL 60 /* can use @poll */
-#define POW_LANY 61 /* Can @link to any room */
-#define POW_LANY_LTE 62 /* Can @link to any room LTE */
-#define POW_LANY_LT 63 /* Can @link to any room LT */
-#define POW_OANY 64 /* Can @open an exit from any room */
-#define POW_OANY_LTE 65 /* LTE */
-#define POW_OANY_LT 66 /* LT */
-#define POW_CPRIV 67 /* Can use admin channels */
-#define POW_EANNOUNCE 68 /* @Eannounce */
-#define POW_DANNOUNCE 69 /* @DAnnounce */
-#define POW_NEWPASS 70 /* @newpass */
-#define POW_NEWPASS_LTE 71 /* LTE */
-#define POW_NEWPASS_LT 72 /* LT */
-#define POW_VQUOTAS 73 /* Can @quota playerz */
-#define POW_VQUOTAS_LTE 74
-#define POW_VQUOTAS_LT 75
-#define POW_MAIL 76 /* Mail Administrator */
-#define POW_MAIL_LTE 77
-#define POW_MAIL_LT 78
-#define POW_COMBAT 79 /* Combat */
-#define POW_COMBAT_LTE 80
-#define POW_COMBAT_LT 81
-#define POW_PROG 82 /* @Program */
-#define POW_PROG_LTE 83
-#define POW_PROG_LT 84
-#define POW_PROGL 85 /* Prog Lock */
-#define POW_PROGL_LTE 86
-#define POW_PROGL_LT 87
-#define POW_POWLSET 88 /* @powerlevel */
-#define POW_POWLSET_LTE 89
-#define POW_POWLSET_LT 90
-#define POW_PASS_LOCKS 91 /* Pass all locks */
-#define POW_PASS_LOCKS_LTE 92
-#define POW_PASS_LOCKS_LT 93
-#define POW_PWHO 94 /* Can get PrivWho */
+#define POW_MANAGEMENT 28 /* ability to use game management commands */
+#define POW_CEMIT 29 /* Can @cemit */
+#define POW_NOQUOTA 30 /* Has no quota restrictions */
+#define POW_PCREATE 31 /* Can @pcreate */
+#define POW_GFUNCS 32 /* Can add global @functions */
+#define POW_SEARCH 33 /* Can @search anything in divscope */
+#define POW_SEARCH_LTE 34 /* Can @search anything LTE " */
+#define POW_SEARCH_LT 35 /* Can @seach LT */
+#define POW_HALT 36 /* Can @halt in divscope */
+#define POW_HALT_LTE 37 /* @halt LTE */
+#define POW_HALT_LT 38 /* @halt LT */
+#define POW_IDLE 39 /* no inactivity timeout */
+#define POW_PS 40 /* Can look at anyones queuein divscope */
+#define POW_PS_LTE 41 /* Can look at LTE queue */
+#define POW_PS_LT 42 /* Can look at LT queue */
+#define POW_QUEUE 43 /* queue limit of db_top */
+#define POW_PEMIT 44 /* Can @pemit HAVEN players */
+#define POW_PEMIT_LTE 45 /* @pemit LTE */
+#define POW_PEMIT_LT 46 /* @pe LT */
+#define POW_CQUOTAS 47 /* Can change quotas in divscope */
+#define POW_CQUOTAS_LTE 48 /* LTE */
+#define POW_CQUOTAS_LT 49 /* LT */
+#define POW_LOGIN 50 /* Login anytime */
+#define POW_HIDE 51 /* Can @hide */
+#define POW_NOPAY 52 /* need no money */
+#define POW_BUILD 53 /* Can use builder commands */
+#define POW_LFINGERS 54 /* can grab stuff remotely */
+#define POW_LFINGERS_LTE 55 /* LTE */
+#define POW_LFINGERS_LT 56 /* LT */
+#define POW_BOOT 57 /* can @boot */
+#define POW_BOOT_LTE 58 /* LTE */
+#define POW_BOOT_LT 59 /* LT */
+#define POW_POLL 60 /* can use @poll */
+#define POW_LANY 61 /* Can @link to any room */
+#define POW_LANY_LTE 62 /* Can @link to any room LTE */
+#define POW_LANY_LT 63 /* Can @link to any room LT */
+#define POW_OANY 64 /* Can @open an exit from any room */
+#define POW_OANY_LTE 65 /* LTE */
+#define POW_OANY_LT 66 /* LT */
+#define POW_CPRIV 67 /* Can use admin channels */
+#define POW_EANNOUNCE 68 /* @Eannounce */
+#define POW_DANNOUNCE 69 /* @DAnnounce */
+#define POW_NEWPASS 70 /* @newpass */
+#define POW_NEWPASS_LTE 71 /* LTE */
+#define POW_NEWPASS_LT 72 /* LT */
+#define POW_VQUOTAS 73 /* Can @quota playerz */
+#define POW_VQUOTAS_LTE 74
+#define POW_VQUOTAS_LT 75
+#define POW_MAIL 76 /* Mail Administrator */
+#define POW_MAIL_LTE 77
+#define POW_MAIL_LT 78
+#define POW_COMBAT 79 /* Combat */
+#define POW_COMBAT_LTE 80
+#define POW_COMBAT_LT 81
+#define POW_PROG 82 /* @Program */
+#define POW_PROG_LTE 83
+#define POW_PROG_LT 84
+#define POW_PROGL 85 /* Prog Lock */
+#define POW_PROGL_LTE 86
+#define POW_PROGL_LT 87
+#define POW_POWLSET 88 /* @powerlevel */
+#define POW_POWLSET_LTE 89
+#define POW_POWLSET_LT 90
+#define POW_PASS_LOCKS 91 /* Pass all locks */
+#define POW_PASS_LOCKS_LTE 92
+#define POW_PASS_LOCKS_LT 93
+#define POW_PWHO 94 /* Can get PrivWho */
#define POW_CHOWN 95 /* Can @chown/preserve */
#define POW_CHOWN_LTE 96
#define POW_CHOWN_LT 97
-#define POW_NSPEMIT 98 /* NsPemit */
-#define POW_NSPEMIT_LTE 99
-#define POW_NSPEMIT_LT 100
-#define POW_SQL 101 /* SQL Ok power */
-#define POW_RCACHE 102 /* @READCACHE power */
-#define POW_RPEMIT 103 /* Can RPMode Emit */
-#define POW_RPCHAT 104 /* Can Chat in RPMODE */
-#define POW_RPTEL 105 /* RPTEL.. extension to tport powers to move something in RPMODE */
-#define POW_PUEBLO_SEND 106 /* Can send pueblo tags */
-#define POW_MANY_ATTRIBS 107 /* Can have more than max_attrs_per_obj */
+#define POW_NSPEMIT 98 /* NsPemit */
+#define POW_NSPEMIT_LTE 99
+#define POW_NSPEMIT_LT 100
+#define POW_SQL 101 /* SQL Ok power */
+#define POW_RCACHE 102 /* @READCACHE power */
+#define POW_RPEMIT 103 /* Can RPMode Emit */
+#define POW_RPCHAT 104 /* Can Chat in RPMODE */
+#define POW_RPTEL 105 /* RPTEL.. extension to tport powers to move something in RPMODE */
+#define POW_PUEBLO_SEND 106 /* Can send pueblo tags */
+#define POW_MANY_ATTRIBS 107 /* Can have more than max_attrs_per_obj */
/* TYPEDEF {{{1 */
/* MACROS {{{1 */
-#define DIV(x) (((db[x].division.object == -1) && !IsPlayer(x)) ? DIV(Owner(x)) : db[x].division)
-#define SDIV(x) (db[x].division)
+#define DIV(x) (((db[x].division.object == -1) && !IsPlayer(x)) ? DIV(Owner(x)) : db[x].division)
+#define SDIV(x) (db[x].division)
#define DPBITS(x) (SDIV(x).dp_bytes)
-#define Division(x) (db[x].division.object)
-#define SLEVEL(x) (SDIV(x).level)
-#define LEVEL(x) (God(x) ? LEVEL_GOD : SDIV(x).level)
-#define div_cansee(x,y) ((Owns(x,y) && LEVEL(x) >= LEVEL(y)) ||div_powover(x,y,"See_All"))
+#define Division(x) (db[x].division.object)
+#define SLEVEL(x) (SDIV(x).level)
+#define LEVEL(x) (God(x) ? LEVEL_GOD : SDIV(x).level)
+#define div_cansee(x,y) ((Owns(x,y) && LEVEL(x) >= LEVEL(y)) ||div_powover(x,y,"See_All"))
#define DPBIT_SET(m,n) (m[(n) >> 3] |= (1 << ((n) & 0x7)))
#define DPBIT_CLR(m,n) (m[(n) >> 3] &= ~(1 << ((n) & 0x7)))
#define DPBIT_ISSET(m,n) (m[(n) >> 3] & (1 << ((n) & 0x7)))
#define DPBIT_ZERO(m) memset(m, 0, DP_BYTES)
-#define powergroup_find(key) (POWERGROUP *) ptab_find(ps_tab.powergroups, key)
-#define find_power(key) (POWER *) ptab_find(ps_tab.powers, key)
+#define powergroup_find(key) (POWERGROUP *) ptab_find(ps_tab.powergroups, key)
+#define find_power(key) (POWER *) ptab_find(ps_tab.powers, key)
/* Check for DPBITS() before you do anything otherwise we might crash from old code */
#define TAKE_DPBIT(m,n) ((void) (DPBITS(m) && (SDIV(m).dp_bytes[(n) >> 3] &= ~(1 << ((n) & 0x7)))))
#define GIVE_DPBIT(m,n) if(!DPBITS(m)) \
- DPBITS(m) = new_power_bitmask(); \
+ DPBITS(m) = new_power_bitmask(); \
((void) (DPBITS(m) && (SDIV(m).dp_bytes[(n) >> 3] |= (1 << ((n) & 0x7)))))
#define HAS_DPBIT(m,n) (God(m) || DPBIT_ISSET(DPBITS(m), n))
/* Division Struct on each object */
struct div_table {
- dbref object; /* division object */
- int level; /* rank in division system(classheld in an attribute) */
- div_pbits dp_bytes; /* division flags/powerz */
+ dbref object; /* division object */
+ int level; /* rank in division system(classheld in an attribute) */
+ div_pbits dp_bytes; /* division flags/powerz */
struct power_group_list *powergroups;
};
/* old powers conversion table */
struct old_division_power_entry_t {
- const char *name; /* power name */
- int flag_yes; /* yes flag */
- int flag_lte; /* yeslte */
- int flag_lt; /* yeslt */
+ const char *name; /* power name */
+ int flag_yes; /* yes flag */
+ int flag_lte; /* yeslte */
+ int flag_lt; /* yeslt */
};
/* new powers */
/* vim:ts=8 fdm=marker
*/
-#endif /* _DIVISION_H_ */
+#endif /* _DIVISION_H_ */
* Each chat channel maintains a linked list of users.
*/
struct chanuser {
- dbref who; /**< Dbref of joined object */
- long int type; /**< Bitflags for this user */
- char title[CU_TITLE_LEN]; /**< User's channel title */
- struct chanuser *next; /**< Pointer to next user in list */
+ dbref who; /**< Dbref of joined object */
+ long int type; /**< Bitflags for this user */
+ char title[CU_TITLE_LEN]; /**< User's channel title */
+ struct chanuser *next; /**< Pointer to next user in list */
};
/* Flags and macros for channel users */
-#define CU_QUIET 0x1 /* Do not hear connection messages */
-#define CU_HIDE 0x2 /* Do not appear on the user list */
-#define CU_GAG 0x4 /* Do not hear any messages */
+#define CU_QUIET 0x1 /* Do not hear connection messages */
+#define CU_HIDE 0x2 /* Do not appear on the user list */
+#define CU_GAG 0x4 /* Do not hear any messages */
#define CU_DEFAULT_FLAGS 0x0
/* channel_broadcast flags */
-#define CB_CHECKQUIET 0x1 /* Check for quiet flag on recipients */
-#define CB_NOSPOOF 0x2 /* Use nospoof emits */
-#define CB_PRESENCE 0x4 /* This is a presence message, not sound */
+#define CB_CHECKQUIET 0x1 /* Check for quiet flag on recipients */
+#define CB_NOSPOOF 0x2 /* Use nospoof emits */
+#define CB_PRESENCE 0x4 /* This is a presence message, not sound */
#define CUdbref(u) ((u)->who)
#define CUtype(u) ((u)->type)
* into a sorted linked list.
*/
struct channel {
- char name[CHAN_NAME_LEN]; /**< Channel name */
- char title[CHAN_TITLE_LEN]; /**< Channel description */
- long int type; /**< Channel flags */
- long int cost; /**< What it cost to make this channel */
- long int creator; /**< This is who paid the cost for the channel */
- long int cobj; /**< Channel object or #-1 */
- long int num_users; /**< Number of connected users */
- long int max_users; /**< Maximum allocated users */
- struct chanuser *users; /**< Linked list of current users */
- long int num_messages; /**< How many messages handled by this chan since startup */
- boolexp joinlock; /**< Who may join */
- boolexp speaklock; /**< Who may speak */
- boolexp modifylock; /**< Who may change things and boot people */
- boolexp seelock; /**< Who can see this in a list */
- boolexp hidelock; /**< Who may hide from view */
- struct channel *next; /**< Next channel in linked list */
- BUFFERQ *bufferq; /**< Pointer to channel recall buffer queue */
+ char name[CHAN_NAME_LEN]; /**< Channel name */
+ char title[CHAN_TITLE_LEN]; /**< Channel description */
+ long int type; /**< Channel flags */
+ long int cost; /**< What it cost to make this channel */
+ long int creator; /**< This is who paid the cost for the channel */
+ long int cobj; /**< Channel object or #-1 */
+ long int num_users; /**< Number of connected users */
+ long int max_users; /**< Maximum allocated users */
+ struct chanuser *users; /**< Linked list of current users */
+ long int num_messages; /**< How many messages handled by this chan since startup */
+ boolexp joinlock; /**< Who may join */
+ boolexp speaklock; /**< Who may speak */
+ boolexp modifylock; /**< Who may change things and boot people */
+ boolexp seelock; /**< Who can see this in a list */
+ boolexp hidelock; /**< Who may hide from view */
+ struct channel *next; /**< Next channel in linked list */
+ BUFFERQ *bufferq; /**< Pointer to channel recall buffer queue */
};
/** A list of channels on an object.
* with each object
*/
struct chanlist {
- CHAN *chan; /**< Channel data */
- struct chanlist *next; /**< Next channel in list */
+ CHAN *chan; /**< Channel data */
+ struct chanlist *next; /**< Next channel in list */
};
#define Chanlist(x) ((struct chanlist *)get_objdata(x, "CHANNELS"))
/** A structure for passing channel data to notify_anything */
struct na_cpass {
- CHANUSER *u; /**< Pointer to channel user */
- int checkquiet; /**< Should quiet property be checked? */
+ CHANUSER *u; /**< Pointer to channel user */
+ int checkquiet; /**< Should quiet property be checked? */
};
/* Channel type flags and macros */
-#define CHANNEL_PLAYER 0x1 /* Players may join */
-#define CHANNEL_OBJECT 0x2 /* Objects may join */
-#define CHANNEL_DISABLED 0x4 /* Channel is turned off */
-#define CHANNEL_QUIET 0x8 /* No broadcasts connect/disconnect */
-#define CHANNEL_ADMIN 0x10 /* Admins only */
-#define CHANNEL_DIRECTOR 0x20 /* Directors only */
-#define CHANNEL_CANHIDE 0x40 /* Can non-DARK players hide here? */
-#define CHANNEL_OPEN 0x80 /* Can you speak if you're not joined? */
-#define CHANNEL_NOTITLES 0x100 /* Don't show titles of speakers */
-#define CHANNEL_NONAMES 0x200 /* Don't show names of speakers */
-#define CHANNEL_NOCEMIT 0x400 /* Disallow @cemit */
-#define CHANNEL_COBJ 0x800 /* Channel with a channel object */
-#define CHANNEL_INTERACT 0x1000 /* Filter channel output through interactions */
+#define CHANNEL_PLAYER 0x1 /* Players may join */
+#define CHANNEL_OBJECT 0x2 /* Objects may join */
+#define CHANNEL_DISABLED 0x4 /* Channel is turned off */
+#define CHANNEL_QUIET 0x8 /* No broadcasts connect/disconnect */
+#define CHANNEL_ADMIN 0x10 /* Admins only */
+#define CHANNEL_DIRECTOR 0x20 /* Directors only */
+#define CHANNEL_CANHIDE 0x40 /* Can non-DARK players hide here? */
+#define CHANNEL_OPEN 0x80 /* Can you speak if you're not joined? */
+#define CHANNEL_NOTITLES 0x100 /* Don't show titles of speakers */
+#define CHANNEL_NONAMES 0x200 /* Don't show names of speakers */
+#define CHANNEL_NOCEMIT 0x400 /* Disallow @cemit */
+#define CHANNEL_COBJ 0x800 /* Channel with a channel object */
+#define CHANNEL_INTERACT 0x1000 /* Filter channel output through interactions */
#define CHANNEL_DEFAULT_FLAGS (CHANNEL_PLAYER)
#define CL_JOIN 0x1
#define CL_SPEAK 0x2
(eval_chan_lock(c,p,CLOCK_MOD))))
#define Chan_Can_See(c,p) \
((Admin(p) || See_All(p)) || (Chan_Can_Access(c,p) && \
- (eval_chan_lock(c,p,CLOCK_SEE))))
+ (eval_chan_lock(c,p,CLOCK_SEE))))
#define Chan_Can_Hide(c,p) \
(Can_Hide(p) || (Channel_CanHide(c) && Chan_Can_Access(c,p) && \
- (eval_chan_lock(c,p,CLOCK_HIDE))))
+ (eval_chan_lock(c,p,CLOCK_HIDE))))
#define Chan_Can_Nuke(c,p) (ChanCreator(c) == (p) || div_powover(p, ChanCreator(c), "Chat"))
#define Chan_Can_Decomp(c,p) (See_All(p) || (ChanCreator(c) == (p)))
extern void do_chan_desc(dbref player, const char *name, const char *title);
extern void do_chan_title(dbref player, const char *name, const char *title);
extern void do_chan_recall(dbref player, const char *name, char *lineinfo[],
- int quiet);
+ int quiet);
extern void do_chan_buffer(dbref player, const char *name, const char *lines);
extern void init_chat(void);
extern void do_channel
(dbref player, char *name, const char *perms, int flag);
extern enum cmatch_type find_channel(const char *p, CHAN **chan, dbref player);
extern enum cmatch_type find_channel_partial(const char *p, CHAN **chan,
- dbref player);
+ dbref player);
extern void do_channel_list(dbref player, const char *partname);
extern int do_chat_by_name
(dbref player, const char *name, const char *msg, int source);
};
-#endif /* CHAT_SYSTEM */
-#endif /* __EXTCHAT_H */
+#endif /* CHAT_SYSTEM */
+#endif /* __EXTCHAT_H */
#endif
/* General Messages */
-#define MSG_HUH T("Huh? (Type \"Help\" for Help.)")
+#define MSG_HUH T("Huh? (Type \"Help\" for Help.)")
/* these symbols must be defined by the interface */
extern time_t mudtime;
-#define FOPEN_READ "rb" /**< Arguments to fopen when reading */
+#define FOPEN_READ "rb" /**< Arguments to fopen when reading */
#define FOPEN_WRITE "wb" /**< Arguments to fopen when writing */
-extern int shutdown_flag; /* if non-zero, interface should shut down */
+extern int shutdown_flag; /* if non-zero, interface should shut down */
extern void emergency_shutdown(void);
-extern void boot_desc(DESC *d); /* remove a player */
-extern DESC *player_desc(dbref player); /* find descriptors */
-extern DESC *inactive_desc(dbref player); /* find descriptors */
-extern DESC *port_desc(int port); /* find descriptors */
+extern void boot_desc(DESC *d); /* remove a player */
+extern DESC *player_desc(dbref player); /* find descriptors */
+extern DESC *inactive_desc(dbref player); /* find descriptors */
+extern DESC *port_desc(int port); /* find descriptors */
extern void WIN32_CDECL flag_broadcast(const char *flag1,
- const char *flag2, const char *fmt, ...)
+ const char *flag2, const char *fmt, ...)
__attribute__ ((__format__(__printf__, 3, 4)));
extern void raw_notify(dbref player, const char *msg);
extern void notify_list(dbref speaker, dbref thing, const char *atr,
- const char *msg, int flags);
+ const char *msg, int flags);
extern dbref short_page(const char *match);
extern dbref visible_short_page(dbref player, const char *match);
extern void do_doing(dbref player, const char *message);
/* the following symbols are provided by game.c */
extern void process_command(dbref player, char *command,
- dbref cause, dbref realcause, int from_port);
+ dbref cause, dbref realcause, int from_port);
extern void init_qids();
extern int init_game_dbs(void);
extern void init_game_postdb(const char *conf);
#ifdef WIN32
/* From timer.c */
extern void init_timer(void);
-#endif /* WIN32 */
+#endif /* WIN32 */
/* From attrib.c */
extern dbref atr_on_obj;
extern void sql_shutdown(void);
/* The #defs for our notify_anything hacks.. Errr. Functions */
-#define NA_NORELAY 0x0001 /**< Don't relay sound */
-#define NA_NOENTER 0x0002 /**< No newline at end */
-#define NA_NOLISTEN 0x0004 /**< Implies NORELAY. Sorta. */
-#define NA_NOPENTER 0x0010 /**< No newline, Pueblo-stylee */
-#define NA_PONLY 0x0020 /**< Pueblo-only */
-#define NA_PUPPET 0x0040 /**< Ok to puppet */
-#define NA_PUPPET2 0x0080 /**< Message to a player from a puppet */
-#define NA_MUST_PUPPET 0x0100 /**< Ok to puppet even in same room */
-#define NA_INTER_HEAR 0x0200 /**< Message is auditory in nature */
-#define NA_INTER_SEE 0x0400 /**< Message is visual in nature */
-#define NA_INTER_PRESENCE 0x0800 /**< Message is about presence */
-#define NA_NOSPOOF 0x1000 /**< Message comes via a NO_SPOOF object. */
-#define NA_PARANOID 0x2000 /**< Message comes via a PARANOID object. */
-#define NA_NOPREFIX 0x4000 /**< Don't use @prefix when forwarding */
-#define NA_INTER_LOCK 0x10000 /**< Message subject to @lock/interact even if not otherwise marked */
-#define NA_INTERACTION (NA_INTER_HEAR|NA_INTER_SEE|NA_INTER_PRESENCE|NA_INTER_LOCK) /**< Message follows interaction rules */
-#define NA_SPOOF 0x8000 /**< @ns* message, overrides NOSPOOF */
+#define NA_NORELAY 0x0001 /**< Don't relay sound */
+#define NA_NOENTER 0x0002 /**< No newline at end */
+#define NA_NOLISTEN 0x0004 /**< Implies NORELAY. Sorta. */
+#define NA_NOPENTER 0x0010 /**< No newline, Pueblo-stylee */
+#define NA_PONLY 0x0020 /**< Pueblo-only */
+#define NA_PUPPET 0x0040 /**< Ok to puppet */
+#define NA_PUPPET2 0x0080 /**< Message to a player from a puppet */
+#define NA_MUST_PUPPET 0x0100 /**< Ok to puppet even in same room */
+#define NA_INTER_HEAR 0x0200 /**< Message is auditory in nature */
+#define NA_INTER_SEE 0x0400 /**< Message is visual in nature */
+#define NA_INTER_PRESENCE 0x0800 /**< Message is about presence */
+#define NA_NOSPOOF 0x1000 /**< Message comes via a NO_SPOOF object. */
+#define NA_PARANOID 0x2000 /**< Message comes via a PARANOID object. */
+#define NA_NOPREFIX 0x4000 /**< Don't use @prefix when forwarding */
+#define NA_INTER_LOCK 0x10000 /**< Message subject to @lock/interact even if not otherwise marked */
+#define NA_INTERACTION (NA_INTER_HEAR|NA_INTER_SEE|NA_INTER_PRESENCE|NA_INTER_LOCK) /**< Message follows interaction rules */
+#define NA_SPOOF 0x8000 /**< @ns* message, overrides NOSPOOF */
#define NA_EVALONCONTACT 0x20000
/** A notify_anything lookup function type definition */
typedef dbref (*na_lookup) (dbref, void *);
extern void notify_anything(dbref speaker, na_lookup func,
- void *fdata,
- char *(*nsfunc) (dbref,
- na_lookup func,
- void *, int), int flags,
- const char *message);
+ void *fdata,
+ char *(*nsfunc) (dbref,
+ na_lookup func,
+ void *, int), int flags,
+ const char *message);
extern void notify_anything_format(dbref speaker, na_lookup func,
- void *fdata,
- char *(*nsfunc) (dbref,
- na_lookup func,
- void *, int), int flags,
- const char *fmt, ...)
+ void *fdata,
+ char *(*nsfunc) (dbref,
+ na_lookup func,
+ void *, int), int flags,
+ const char *fmt, ...)
__attribute__ ((__format__(__printf__, 6, 7)));
extern void notify_anything_loc(dbref speaker, na_lookup func,
- void *fdata,
- char *(*nsfunc) (dbref,
- na_lookup func,
- void *, int), int flags,
- const char *message, dbref loc);
+ void *fdata,
+ char *(*nsfunc) (dbref,
+ na_lookup func,
+ void *, int), int flags,
+ const char *message, dbref loc);
extern dbref na_one(dbref current, void *data);
extern dbref na_next(dbref current, void *data);
extern dbref na_loc(dbref current, void *data);
char ucom[BUFFER_LEN]; /**< evaluated command */
int break_called; /**< Has the break command been called? */
char break_replace[BUFFER_LEN]; /**< What to replace the break with */
- struct real_pcre *re_code; /**< The compiled re */
- int re_subpatterns; /**< The number of re subpatterns */
- int *re_offsets; /**< The offsets for the subpatterns */
- char *re_from; /**< The positions of the subpatterns */
+ struct real_pcre *re_code; /**< The compiled re */
+ int re_subpatterns; /**< The number of re subpatterns */
+ int *re_offsets; /**< The offsets for the subpatterns */
+ char *re_from; /**< The positions of the subpatterns */
HASHTAB namedregs;
HASHTAB namedregsnxt;
};
extern int queue_attribute_base
(dbref executor, const char *atrname, dbref enactor, int noparent);
extern ATTR *queue_attribute_getatr(dbref executor, const char *atrname,
- int noparent);
+ int noparent);
extern int queue_attribute_useatr(dbref executor, ATTR *a, dbref enactor);
/** Queue the code in an attribute, including parent objects */
/** Queue the code in an attribute, excluding parent objects */
#define queue_attribute_noparent(a,b,c) queue_attribute_base(a,b,c,1)
extern void dequeue_semaphores(dbref thing, char const *aname, int count,
- int all, int drain);
+ int all, int drain);
extern void shutdown_queues(void);
extern void do_hourly(void);
extern dbref do_dig(dbref player, const char *name, char **argv, int tport);
extern dbref do_create(dbref player, char *name, int cost);
extern dbref do_real_open(dbref player, const char *direction,
- const char *linkto, dbref pseudo);
+ const char *linkto, dbref pseudo);
extern void do_open(dbref player, const char *direction, char **links);
extern void do_link(dbref player, const char *name, const char *room_name,
- int preserve);
+ int preserve);
extern void do_unlink(dbref player, const char *name);
extern dbref do_clone(dbref player, char *name, char *newname, int preserve);
extern void copy_zone(dbref executor, dbref zmo);
extern dbref lookup_player_name(const char *name);
/* from player.c */
extern dbref create_player(const char *name, const char *password,
- const char *host, const char *ip);
+ const char *host, const char *ip);
extern dbref connect_player(const char *name, const char *password,
- const char *host, const char *ip, char *errbuf);
+ const char *host, const char *ip, char *errbuf);
extern void check_last(dbref player, const char *host, const char *ip);
extern void check_lastfailed(dbref player, const char *host);
void add_player_alias(dbref player, const char *alias);
void delete_player(dbref player, const char *alias);
void reset_player_list(dbref player, const char *oldname, const char *oldalias,
- const char *name, const char *alias);
+ const char *name, const char *alias);
/* From predicat.c */
extern int pay_quota(dbref, int);
extern int could_doit(dbref player, dbref thing);
extern int did_it(dbref player, dbref thing, const char *what,
- const char *def, const char *owhat, const char *odef,
- const char *awhat, dbref loc);
+ const char *def, const char *owhat, const char *odef,
+ const char *awhat, dbref loc);
extern int did_it_with(dbref player, dbref thing, const char *what,
- const char *def, const char *owhat, const char *odef,
- const char *awhat, dbref loc, dbref env0, dbref env1,
- int flags);
+ const char *def, const char *owhat, const char *odef,
+ const char *awhat, dbref loc, dbref env0, dbref env1,
+ int flags);
extern int did_it_interact(dbref player, dbref thing, const char *what,
- const char *def, const char *owhat,
- const char *odef, const char *awhat, dbref loc,
- int flags);
+ const char *def, const char *owhat,
+ const char *odef, const char *awhat, dbref loc,
+ int flags);
extern int real_did_it(dbref player, dbref thing, const char *what,
- const char *def, const char *owhat, const char *odef,
- const char *awhat, dbref loc, char *myenv[10],
- int flags);
+ const char *def, const char *owhat, const char *odef,
+ const char *awhat, dbref loc, char *myenv[10],
+ int flags);
extern int can_see(dbref player, dbref thing, int can_see_loc);
extern int controls(dbref who, dbref what);
extern int can_pay_fees(dbref who, int pennies);
extern int ok_tag_attribute(dbref player, char *params);
extern dbref parse_match_possessor(dbref player, const char **str);
extern void page_return(dbref player, dbref target, const char *type,
- const char *message, const char *def);
+ const char *message, const char *def);
extern char *grep_util(dbref player, dbref thing, char *pattern,
- char *lookfor, int len, int insensitive);
+ char *lookfor, int len, int insensitive);
extern dbref where_is(dbref thing);
extern int charge_action(dbref player, dbref thing, const char *awhat);
dbref first_visible(dbref player, dbref thing);
/* From set.c */
extern void chown_object(dbref player, dbref thing, dbref newowner,
- int preserve);
+ int preserve);
/* From speech.c */
const char *spname(dbref thing);
extern void notify_except(dbref first, dbref exception, const char *msg,
- int flags);
+ int flags);
extern void notify_except2(dbref first, dbref exc1, dbref exc2,
- const char *msg, int flags);
+ const char *msg, int flags);
/* Return thing/PREFIX + msg */
extern void make_prefixstr(dbref thing, const char *msg, char *tbuf1);
extern int filter_found(dbref thing, const char *msg, int flag);
extern char *split_token(char **sp, char sep);
extern char *chopstr(const char *str, size_t lim);
extern int string_prefix(const char *RESTRICT string,
- const char *RESTRICT prefix);
+ const char *RESTRICT prefix);
extern const char *string_match(const char *src, const char *sub);
extern char *strupper(const char *s);
extern char *strlower(const char *s);
/** A string, with ansi attributes broken out from the text */
typedef struct {
- char text[BUFFER_LEN]; /**< Text of the string */
- char *codes[BUFFER_LEN]; /**< Ansi codes associated with each char of text */
- size_t len; /**< Length of text */
+ char text[BUFFER_LEN]; /**< Text of the string */
+ char *codes[BUFFER_LEN]; /**< Ansi codes associated with each char of text */
+ size_t len; /**< Length of text */
} ansi_string;
extern int safe_fill(char x, size_t n, char *buff, char **bp);
/* Append an accented string */
extern int safe_accent(const char *RESTRICT base,
- const char *RESTRICT tmplate, size_t len, char *buff,
- char **bp);
+ const char *RESTRICT tmplate, size_t len, char *buff,
+ char **bp);
extern char *str_escaped_chr(const char *RESTRICT string, char escape_chr);
extern char *replace_string
(const char *RESTRICT old, const char *RESTRICT newbit,
const char *RESTRICT string) __attribute_malloc__;
extern char *replace_string2(const char *old[2], const char *newbits[2],
- const char *RESTRICT string)
+ const char *RESTRICT string)
__attribute_malloc__;
- extern const char *standard_tokens[2]; /* ## and #@ */
+ extern const char *standard_tokens[2]; /* ## and #@ */
extern char *trim_space_sep(char *str, char sep);
extern int do_wordcount(char *str, char sep);
extern char *remove_word(char *list, char *word, char sep);
extern char *next_in_list(const char **head);
extern void safe_itemizer(int cur_num, int done, const char *delim,
- const char *conjoin, const char *space,
- char *buff, char **bp);
+ const char *conjoin, const char *space,
+ char *buff, char **bp);
extern char *show_time(time_t t, int utc);
extern char *show_tm(struct tm *t);
/** This structure associates html entities and base ascii representations */
typedef struct {
- const char *base; /**< Base ascii representation */
- const char *entity; /**< HTML entity */
+ const char *base; /**< Base ascii representation */
+ const char *entity; /**< HTML entity */
} accent_info;
extern accent_info accent_table[];
/* From utils.c */
extern void parse_attrib(dbref player, char *str, dbref *thing,
- ATTR **attrib);
+ ATTR **attrib);
extern void parse_anon_attrib(dbref player, char *str, dbref *thing,
- ATTR **attrib);
+ ATTR **attrib);
extern void free_anon_attrib(ATTR *attrib);
typedef struct _ufun_attrib {
dbref thing;
char *errmess;
} ufun_attrib;
extern int fetch_ufun_attrib(char *attrname, dbref executor,
- ufun_attrib * ufun, int accept_lambda);
+ ufun_attrib * ufun, int accept_lambda);
extern int call_ufun(ufun_attrib * ufun, char **wenv_args, int wenv_argc,
- char *ret, dbref executor, dbref enactor,
- PE_Info * pe_info);
+ char *ret, dbref executor, dbref enactor,
+ PE_Info * pe_info);
extern int member(dbref thing, dbref list);
extern int recursive_member(dbref disallow, dbref from, int count);
extern dbref remove_first(dbref first, dbref what);
extern dbref reverse(dbref list);
extern Malloc_t mush_malloc(size_t size,
- const char *check) __attribute_malloc__;
+ const char *check) __attribute_malloc__;
extern void mush_free(Malloc_t RESTRICT ptr, const char *RESTRICT check);
extern long get_random_long(long low, long high);
extern char *fullalias(dbref it);
/* From wild.c */
extern int local_wild_match_case(const char *RESTRICT s,
- const char *RESTRICT d, int cs);
+ const char *RESTRICT d, int cs);
extern int wildcard(const char *s);
extern int quick_wild_new(const char *RESTRICT tstr,
- const char *RESTRICT dstr, int cs);
+ const char *RESTRICT dstr, int cs);
extern int regexp_match_case(const char *RESTRICT s, const char *RESTRICT d,
- int cs);
+ int cs);
extern int quick_regexp_match(const char *RESTRICT s,
- const char *RESTRICT d, int cs);
+ const char *RESTRICT d, int cs);
extern int wild_match_case(const char *RESTRICT s, const char *RESTRICT d,
- int cs);
+ int cs);
extern int quick_wild(const char *RESTRICT tsr, const char *RESTRICT dstr);
extern int atr_wild(const char *RESTRICT tstr, const char *RESTRICT dstr);
/** Default (case-sensitive) regex match */
extern void save_global_env(const char *funcname, char *preserve[]);
extern void restore_global_env(const char *funcname, char *preserve[]);
extern void save_global_nxt(const char *funcname, char *preservew[],
- char *preserver[], char *valw[], char *valr[]);
+ char *preserver[], char *valw[], char *valr[]);
extern void restore_global_nxt(const char *funcname, char *preservew[],
- char *preserver[], char *valw[],
- char *valr[]);
+ char *preserver[], char *valw[],
+ char *valr[]);
extern int delim_check(char *buff, char **bp, int nfargs, char **fargs,
- int sep_arg, char *sep);
+ int sep_arg, char *sep);
extern int get_gender(dbref player);
extern int gencomp(dbref player, char *a, char *b, char *sort_type);
extern const char *do_get_attrib(dbref executor, dbref thing,
- const char *aname);
+ const char *aname);
extern char *ArabicToRoman(int);
extern int RomanToArabic(char *);
/* funlist.c */
void do_gensort(dbref player, char *keys[], char *strs[], int n,
- char *sort_type);
+ char *sort_type);
/* sig.c */
/** Type definition for signal handlers */
/* Block all signals en masse. */
void block_signals(void);
-#endif /* __EXTERNS_H */
+#endif /* __EXTERNS_H */
#define M_FORWARD 0x0080
/* 0x0100 - 0x0F00 reserved for folder numbers */
#define M_FMASK 0xF0FF
-#define M_ALL 0x1000 /* In mail_selector, all msgs in all folders */
-#define M_MSUNREAD 0x2000 /* Mail selectors */
+#define M_ALL 0x1000 /* In mail_selector, all msgs in all folders */
+#define M_MSUNREAD 0x2000 /* Mail selectors */
#define M_REPLY 0x4000
-#define M_FOLDER 0x8000 /* In mail selector, all msgs in cur folder */
+#define M_FOLDER 0x8000 /* In mail selector, all msgs in cur folder */
/* 0x4000 - 0x8000 available */
#define MAX_FOLDERS 15
* messages. Messages can be selected in several ways.
*/
struct mail_selector {
- int low; /**< Minimum message number */
- int high; /**< Maximum message number */
- mail_flag flags; /**< Message flags */
- dbref player; /**< Message sender's dbref */
- int days; /**< Target message age in days */
- int day_comp; /**< Direction of comparison to target age */
+ int low; /**< Minimum message number */
+ int high; /**< Maximum message number */
+ mail_flag flags; /**< Message flags */
+ dbref player; /**< Message sender's dbref */
+ int days; /**< Target message age in days */
+ int day_comp; /**< Direction of comparison to target age */
};
typedef int folder_array[MAX_FOLDERS + 1];
extern void desc_mail_set(dbref player, struct mail *mp);
extern void desc_mail_clear(void);
-#endif /* _EXTMAIL_H */
+#endif /* _EXTMAIL_H */
* available for setting on objects in the game.
*/
struct flag_info {
- const char *name; /**< Name of the flag */
- char letter; /**< Flag character, which may be nul */
- int type; /**< Bitflags of object types this flag applies to */
- int bitpos; /**< Bit position assigned to this flag for now */
- int perms; /**< Bitflags of who can set this flag */
- int negate_perms; /**< Bitflags of who can clear this flag */
+ const char *name; /**< Name of the flag */
+ char letter; /**< Flag character, which may be nul */
+ int type; /**< Bitflags of object types this flag applies to */
+ int bitpos; /**< Bit position assigned to this flag for now */
+ int perms; /**< Bitflags of who can set this flag */
+ int negate_perms; /**< Bitflags of who can clear this flag */
};
typedef struct flag_alias FLAG_ALIAS;
* A simple structure that associates an alias with a canonical flag name.
*/
struct flag_alias {
- const char *alias; /**< The alias name */
- const char *realname; /**< The real name of the flag */
+ const char *alias; /**< The alias name */
+ const char *realname; /**< The real name of the flag */
};
typedef struct flagspace FLAGSPACE;
* a set of flags, powers, or whatever.
*/
struct flagspace {
- PTAB *tab; /**< Prefix table storing flags by name/alias */
- FLAG **flags; /**< Variable-length array of pointers to canonical flags, indexed by bit */
- int flagbits; /**< Current length of the flags array */
- FLAG *flag_table; /**< Pointer to flag table */
- FLAG_ALIAS *flag_alias_table; /**< Pointer to flag alias table */
+ PTAB *tab; /**< Prefix table storing flags by name/alias */
+ FLAG **flags; /**< Variable-length array of pointers to canonical flags, indexed by bit */
+ int flagbits; /**< Current length of the flags array */
+ FLAG *flag_table; /**< Pointer to flag table */
+ FLAG_ALIAS *flag_alias_table; /**< Pointer to flag alias table */
};
extern const char *flag_description(dbref player, dbref thing);
extern int sees_flag(dbref privs, dbref thing, const char *name);
extern void set_flag(dbref player, dbref thing, const char *flag, int negate,
- int hear, int listener);
+ int hear, int listener);
extern int flaglist_check(const char *ns, dbref player, dbref it, const char *fstr, int type);
extern int flaglist_check_long(const char *ns, dbref player, dbref it, const char *fstr,
- int type);
+ int type);
extern FLAG *match_flag(const char *name);
extern const char *show_command_flags(object_flag_type flags, div_pbits powers);
extern void twiddle_flag_internal(const char *ns, dbref thing, const char *flag, int negate);
extern int has_any_bits(const char *ns, object_flag_type source, object_flag_type bitmask);
extern object_flag_type string_to_bits(const char *ns, const char *str);
extern const char *bits_to_string(const char *ns, object_flag_type bitmask, dbref privs,
- dbref thing);
+ dbref thing);
extern void flag_write_all(FILE *, const char *);
extern void flag_read_all(FILE *, const char *);
extern int type_from_old_flags(long old_flags);
extern object_flag_type flags_from_old_flags(long old_flags, long old_toggles,
- int type);
+ int type);
extern FLAG *add_flag(const char *name, const char letter, int type,
- int perms, int negate_perms);
+ int perms, int negate_perms);
extern void do_list_flags(dbref player, const char *arg, int lc);
extern char *list_all_flags(const char *ns, const char *name, dbref privs, int which);
extern void do_flag_info(const char *ns, dbref player, const char *name);
extern void do_flag_alias(dbref player, const char *name, const char *alias);
extern void do_flag_enable(dbref player, const char *name);
extern void do_flag_restrict(dbref player, const char *name,
- char *args_right[]);
+ char *args_right[]);
extern void do_flag_add(dbref player, const char *name, char *args_right[]);
extern void do_flag_letter(dbref player, const char *name, const char *letter);
extern void do_flag_type(const char *ns, dbref player, const char *name, char *type_string);
#define TYPE_PLAYER 0x8
#define TYPE_GARBAGE 0x10
#define TYPE_MARKED 0x20
-#define TYPE_DIVISION 0x40
+#define TYPE_DIVISION 0x40
#define NOTYPE 0xFFFF
#define ALLTYPES (0 | TYPE_ROOM | TYPE_THING | TYPE_EXIT | TYPE_PLAYER | TYPE_DIVISION)
* Flag permissions
*/
-#define F_ANY 0x10 /* can be set by anyone - obsolete now */
-#define F_OWNED 0x40 /* can be set on owned objects */
-#define F_PRIVILEGE 0x80 /* can only be set by privileged players */
-#define F_GOD 0x200 /* can only be set by God */
-#define F_INTERNAL 0x400 /* only the game can set this */
-#define F_DARK 0x800 /* only God can see this flag */
-#define F_MDARK 0x1000 /* admin/God can see this flag */
-#define F_ODARK 0x2000 /* owner/admin/God can see this flag */
-#define F_DISABLED 0x4000 /* flag can't be used */
-/* RESERVED 0x8000 */
-#define F_SELF 0x10000 /* can set on self, regardless of the above */
+#define F_ANY 0x10 /* can be set by anyone - obsolete now */
+#define F_OWNED 0x40 /* can be set on owned objects */
+#define F_PRIVILEGE 0x80 /* can only be set by privileged players */
+#define F_GOD 0x200 /* can only be set by God */
+#define F_INTERNAL 0x400 /* only the game can set this */
+#define F_DARK 0x800 /* only God can see this flag */
+#define F_MDARK 0x1000 /* admin/God can see this flag */
+#define F_ODARK 0x2000 /* owner/admin/God can see this flag */
+#define F_DISABLED 0x4000 /* flag can't be used */
+/* RESERVED 0x8000 */
+#define F_SELF 0x10000 /* can set on self, regardless of the above */
/* we don't use these anymore.. but kept aroudn for DB conversion */
-#endif /* __FLAGS_H */
+#endif /* __FLAGS_H */
#endif
typedef void (*function_func) (FUN *, char *, char **, int, char *[], int[],
- dbref, dbref, dbref, const char *, PE_Info *);
+ dbref, dbref, dbref, const char *, PE_Info *);
/** A calling pointer to a function.
* This union holds either a pointer to a function's code or
* the offset of the function in the user-defined function table.
*/
union fun_call {
- function_func fun; /**< Pointer to compiled function code */
- size_t offset; /**< Offset into user-defined function table */
+ function_func fun; /**< Pointer to compiled function code */
+ size_t offset; /**< Offset into user-defined function table */
};
/** A function.
* This structure represents a mushcode function.
*/
struct fun {
- const char *name; /**< Function name */
- union fun_call where; /**< Where to find the function to call it */
- int minargs; /**< Minimum arguments required, or 0 */
+ const char *name; /**< Function name */
+ union fun_call where; /**< Where to find the function to call it */
+ int minargs; /**< Minimum arguments required, or 0 */
/** Maximum arguments allowed.
* Maximum arguments allowed. If there is no limit, this is INT_MAX.
* If this is negatve, the final argument to the function can contain
* is the absolute value of this variable.
*/
int maxargs;
- unsigned int flags; /**< Bitflags of function */
+ unsigned int flags; /**< Bitflags of function */
boolexp lock; /* Usability lock */
};
* This structure represents an entry in the user-defined function table.
*/
struct userfn_entry {
- char *fn; /**< Name of the function */
- dbref thing; /**< Dbref of object where the function is defined */
- char *name; /**< Name of attribute where the function is defined */
- unsigned int flags; /**< Bitflags of function */
+ char *fn; /**< Name of the function */
+ dbref thing; /**< Dbref of object where the function is defined */
+ char *name; /**< Name of attribute where the function is defined */
+ unsigned int flags; /**< Bitflags of function */
};
extern USERFN_ENTRY *userfn_tab;
extern void do_userfn(char *buff, char **bp,
- dbref obj, ATTR *attrib,
- int nargs, char **args,
- dbref executor, dbref caller, dbref enactor,
- PE_Info * pe_info);
+ dbref obj, ATTR *attrib,
+ int nargs, char **args,
+ dbref executor, dbref caller, dbref enactor,
+ PE_Info * pe_info);
extern FUN *func_hash_lookup(const char *name);
extern int check_func(dbref player, FUN *fp);
extern int restrict_function(const char *name, const char *restrict);
extern int alias_function(const char *function, const char *alias);
extern void do_function_restrict(dbref player, const char *name,
- const char *restrict);
+ const char *restrict);
extern void do_function_restore(dbref player, const char *name);
extern void do_list_functions(dbref player, int lc);
extern char *list_functions(void);
int arglen[], dbref executor, dbref caller, dbref enactor, \
char const *called_as, PE_Info *pe_info)
extern void function_add(const char *name, function_func fun, int minargs,
- int maxargs, int ftype);
+ int maxargs, int ftype);
#endif
#define CHECK_GLOBAL 0x200
/* hash table stuff */
-extern void init_func_hashtab(void); /* eval.c */
-extern void init_math_hashtab(void); /* funmath.c */
-extern void init_aname_table(void); /* atr_tab.c */
-extern void init_flagspaces(void); /* flags.c */
-extern void init_flag_table(const char *ns); /* flags.c */
-extern void init_tag_hashtab(void); /* funstr.c */
-extern void init_pronouns(void); /* funstr.c */
+extern void init_func_hashtab(void); /* eval.c */
+extern void init_math_hashtab(void); /* funmath.c */
+extern void init_aname_table(void); /* atr_tab.c */
+extern void init_flagspaces(void); /* flags.c */
+extern void init_flag_table(const char *ns); /* flags.c */
+extern void init_tag_hashtab(void); /* funstr.c */
+extern void init_pronouns(void); /* funstr.c */
/* From bsd.c */
extern void fcache_init(void);
/* From command.c */
enum hook_type { HOOK_BEFORE, HOOK_AFTER, HOOK_IGNORE, HOOK_OVERRIDE };
extern void do_hook(dbref player, char *command, char *obj, char *attrname,
- enum hook_type flag);
+ enum hook_type flag);
extern void do_hook_list(dbref player, char *command);
/* From look.c */
enum exam_type { EXAM_NORMAL, EXAM_BRIEF, EXAM_MORTAL };
extern void do_examine(dbref player, const char *name, enum exam_type flag,
- int all);
+ int all);
extern void do_inventory(dbref player);
extern void do_find(dbref player, const char *name, char **argv);
extern void do_whereis(dbref player, const char *name);
extern void do_sweep(dbref player, const char *arg1);
enum ent_type { ENT_EXITS, ENT_THINGS, ENT_PLAYERS, ENT_ROOMS, ENT_ALL };
extern void do_entrances(dbref player, const char *where, char **argv,
- enum ent_type val);
+ enum ent_type val);
enum dec_type { DEC_NORMAL, DEC_DB, DEC_FLAG, DEC_ATTR };
extern void do_decompile(dbref player, const char *name, const char *prefix,
- enum dec_type dbflag, int skipdef);
+ enum dec_type dbflag, int skipdef);
/* From move.c */
extern void do_get(dbref player, const char *what);
/* From player.c */
extern void do_password(dbref player, dbref cause,
- const char *old, const char *newobj);
+ const char *old, const char *newobj);
/* From predicat.c */
extern void do_switch
extern void do_chown
(dbref player, const char *name, const char *newobj, int preserve);
extern int do_chzone(dbref player, const char *name, const char *newobj,
- int noisy);
+ int noisy);
extern int do_set(dbref player, const char *name, char *flag);
extern void do_cpattr
(dbref player, char *oldpair, char **newpair, int move, int noflagcopy);
enum edit_type { EDIT_FIRST, EDIT_ALL} ;
extern void do_gedit(dbref player, char *it, char **argv,
- enum edit_type target, int doit);
+ enum edit_type target, int doit);
extern void do_trigger(dbref player, char *object, char **argv);
extern void do_use(dbref player, const char *what);
extern void do_parent(dbref player, char *name, char *parent_name);
extern void do_pose(dbref player, const char *tbuf1, int space);
enum wall_type { WALL_ALL };
extern void do_wall(dbref player, const char *message, enum wall_type target,
- int emit);
+ int emit);
extern void do_page(dbref player, const char *arg1, const char *arg2,
- dbref cause, int noeval, int multipage, int override,
- int has_eq);
+ dbref cause, int noeval, int multipage, int override,
+ int has_eq);
extern void do_page_port(dbref player, const char *arg1, const char *arg2);
extern void do_think(dbref player, const char *message);
#define PEMIT_SILENT 0x1
extern void do_pemit
(dbref player, const char *arg1, const char *arg2, int flags);
extern void do_pemit_list(dbref player, char *list, const char *message,
- int flags);
+ int flags);
extern void do_remit(dbref player, char *arg1, const char *arg2, int flags);
extern void do_lemit(dbref player, const char *tbuf1, int flags);
extern void do_zemit(dbref player, const char *arg1, const char *arg2,
- int flags);
+ int flags);
extern void do_oemit_list(dbref player, char *arg1, const char *arg2,
- int flags);
+ int flags);
extern void do_teach(dbref player, dbref cause, const char *tbuf1);
/* From wiz.c */
/* From version.c */
extern void do_version(dbref player);
-#endif /* __GAME_H */
+#endif /* __GAME_H */
#define getpagesize() NBPG * CLSIZE
#ifndef CLSIZE
#define CLSIZE 1
-#endif /* no CLSIZE */
-#else /* no NBPG */
+#endif /* no CLSIZE */
+#else /* no NBPG */
#ifdef NBPC
#define getpagesize() NBPC
-#else /* no NBPC either? Bummer */
+#else /* no NBPC either? Bummer */
#ifdef PAGESIZE
#define getpagesize() PAGESIZE
-#else /* Sigh. Time for a total guess. */
+#else /* Sigh. Time for a total guess. */
#define getpagesize() 1024
-#endif /* no PAGESIZE */
-#endif /* no NBPC */
-#endif /* no NBPG */
-#endif /* no EXEC_PAGESIZE */
-#endif /* no PAGESIZE_VALUE */
-#endif /* not HAS_GETPAGESIZE */
+#endif /* no PAGESIZE */
+#endif /* no NBPC */
+#endif /* no NBPG */
+#endif /* no EXEC_PAGESIZE */
+#endif /* no PAGESIZE_VALUE */
+#endif /* not HAS_GETPAGESIZE */
-#endif /* __GETPGSIZ_H */
+#endif /* __GETPGSIZ_H */
*
*/
typedef struct {
- long pos; /**< Position of topic in help file, in bytes */
- char topic[TOPIC_NAME_LEN + 1]; /**< name of topic of help entry */
+ long pos; /**< Position of topic in help file, in bytes */
+ char topic[TOPIC_NAME_LEN + 1]; /**< name of topic of help entry */
} help_indx;
/** A help command.
* file and an in-memory index.
*/
typedef struct {
- char *command; /**< The name of the help command */
- char *file; /**< The file of help text */
- int admin; /**< Is this an admin-only help command? */
- help_indx *indx; /**< An array of help index entries */
- size_t entries; /**< Number of entries in the help file */
+ char *command; /**< The name of the help command */
+ char *file; /**< The file of help text */
+ int admin; /**< Is this an admin-only help command? */
+ help_indx *indx; /**< An array of help index entries */
+ size_t entries; /**< Number of entries in the help file */
} help_file;
extern void add_help_file
(const char *command_name, const char *filename, int admin);
extern void help_reindex(dbref player);
-#endif /* __HELP_H */
+#endif /* __HELP_H */
/** A hash table entry.
*/
struct hashentry {
- struct hashentry *next; /**< Pointer to next entry */
- void *data; /**< Data for this entry */
+ struct hashentry *next; /**< Pointer to next entry */
+ void *data; /**< Data for this entry */
/* int extra_size; */
- char key[SOME_KEY_LEN]; /**< Key for this entry */
+ char key[SOME_KEY_LEN]; /**< Key for this entry */
};
#define HASHENT_SIZE (sizeof(HASHENT)-SOME_KEY_LEN)
/** A hash table.
*/
struct hashtable {
- int hashsize; /**< Size of hash table */
- int mask; /**< Mask for entries in table */
- int entries; /**< Number of entries stored */
- HASHENT **buckets; /**< Pointer to pointer to entries */
- int last_hval; /**< State for hashfirst & hashnext. */
- HASHENT *last_entry; /**< State for hashfirst & hashnext. */
- int entry_size; /**< Size of each entry */
+ int hashsize; /**< Size of hash table */
+ int mask; /**< Mask for entries in table */
+ int entries; /**< Number of entries stored */
+ HASHENT **buckets; /**< Pointer to pointer to entries */
+ int last_hval; /**< State for hashfirst & hashnext. */
+ HASHENT *last_entry; /**< State for hashfirst & hashnext. */
+ int entry_size; /**< Size of each entry */
};
#define get_hashmask(x) hash_getmask(x)
* This structure stores the result of an ident call.
*/
typedef struct {
- char *identifier; /**< Normally user name */
- char *opsys; /**< Operating system */
- char *charset; /**< Character set */
+ char *identifier; /**< Normally user name */
+ char *opsys; /**< Operating system */
+ char *charset; /**< Character set */
} IDENT;
/* High-level calls */
extern char *ident_id(int fd, int *timeout);
extern IDENT *ident_query(struct sockaddr *laddr, socklen_t llen,
- struct sockaddr *raddr, socklen_t rlen,
- int *timeout);
+ struct sockaddr *raddr, socklen_t rlen,
+ int *timeout);
void ident_free(IDENT *id);
* An object's locks are represented as a linked list of these structures.
*/
struct lock_list {
- lock_type type; /**< Type of lock */
- boolexp key; /**< Lock value ("key") */
- dbref creator; /**< Dbref of lock creator */
- int flags; /**< Lock flags */
- struct lock_list *next; /**< Pointer to next lock in object's list */
+ lock_type type; /**< Type of lock */
+ boolexp key; /**< Lock value ("key") */
+ dbref creator; /**< Dbref of lock creator */
+ int flags; /**< Lock flags */
+ struct lock_list *next; /**< Pointer to next lock in object's list */
};
/* Our table of lock types, attributes, and default flags */
* This structure represents a lock in the table of lock types
*/
struct lock_msg_info {
- lock_type type; /**< Type of lock */
- const char *succbase; /**< Base name of success attribute */
- const char *failbase; /**< Base name of failure attribute */
+ lock_type type; /**< Type of lock */
+ const char *succbase; /**< Base name of success attribute */
+ const char *failbase; /**< Base name of failure attribute */
};
-#define LF_VISUAL 0x1 /* Anyone can see this lock with lock()/elock() */
-#define LF_PRIVATE 0x2 /* This lock doesn't get inherited */
-#define LF_PRIVILEGE 0x4 /* Only privileged players can set/unset it */
-#define LF_LOCKED 0x8 /* Only the lock's owner can set/unset it */
-#define LF_NOCLONE 0x10 /* This lock isn't copied in @clone */
-#define LF_OX 0x20 /* This lock's success messages includes OX*. */
-#define LF_NOSUCCACTION 0x40 /* This lock doesn't have an @a-action for success. */
-#define LF_NOFAILACTION 0x80 /* This lock doesn't have an @a-action for failure */
-#define LF_OWNER 0x100 /* Lock can only be set/unset by object's owner */
+#define LF_VISUAL 0x1 /* Anyone can see this lock with lock()/elock() */
+#define LF_PRIVATE 0x2 /* This lock doesn't get inherited */
+#define LF_PRIVILEGE 0x4 /* Only privileged players can set/unset it */
+#define LF_LOCKED 0x8 /* Only the lock's owner can set/unset it */
+#define LF_NOCLONE 0x10 /* This lock isn't copied in @clone */
+#define LF_OX 0x20 /* This lock's success messages includes OX*. */
+#define LF_NOSUCCACTION 0x40 /* This lock doesn't have an @a-action for success. */
+#define LF_NOFAILACTION 0x80 /* This lock doesn't have an @a-action for failure */
+#define LF_OWNER 0x100 /* Lock can only be set/unset by object's owner */
/* lock.c */
boolexp getlock(dbref thing, lock_type type);
const lock_list *get_lockproto(lock_type type);
int add_lock(dbref player, dbref thing, lock_type type, boolexp key, int flags);
int add_lock_raw(dbref player, dbref thing, lock_type type,
- boolexp key, int flags);
+ boolexp key, int flags);
void free_locks(lock_list *ll);
int eval_lock(dbref player, dbref thing, lock_type ltype);
int fail_lock(dbref player, dbref thing, lock_type ltype, const char *def,
- dbref loc);
+ dbref loc);
void do_unlock(dbref player, const char *name, lock_type type);
void do_lock(dbref player, const char *name, const char *keyname,
- lock_type type);
+ lock_type type);
void init_locks(void);
void clone_locks(dbref player, dbref orig, dbref clone);
void do_lset(dbref player, char *what, char *flags);
extern const lock_type Zone_Lock;
extern const lock_type Page_Lock;
extern const lock_type Tport_Lock;
-extern const lock_type Speech_Lock; /* Who can speak aloud in me */
-extern const lock_type Listen_Lock; /* Who can trigger ^s/ahears on me */
-extern const lock_type Command_Lock; /* Who can use $commands on me */
-extern const lock_type Parent_Lock; /* Who can @parent to me */
-extern const lock_type Link_Lock; /* Who can @link to me */
-extern const lock_type Leave_Lock; /* Who can leave me */
-extern const lock_type Drop_Lock; /* Who can drop me */
-extern const lock_type Give_Lock; /* Who can give me */
-extern const lock_type Mail_Lock; /* Who can @mail me */
-extern const lock_type Follow_Lock; /* Who can follow me */
-extern const lock_type Examine_Lock; /* Who can examine visual me */
-extern const lock_type Chzone_Lock; /* Who can @chzone to this object? */
-extern const lock_type Forward_Lock; /* Who can @forwardlist to object? */
-extern const lock_type Control_Lock; /* Who can control this object? */
-extern const lock_type Dropto_Lock; /* Who follows the dropto of this room? */
-extern const lock_type Destroy_Lock; /* Who can @dest me if I'm dest_ok? */
+extern const lock_type Speech_Lock; /* Who can speak aloud in me */
+extern const lock_type Listen_Lock; /* Who can trigger ^s/ahears on me */
+extern const lock_type Command_Lock; /* Who can use $commands on me */
+extern const lock_type Parent_Lock; /* Who can @parent to me */
+extern const lock_type Link_Lock; /* Who can @link to me */
+extern const lock_type Leave_Lock; /* Who can leave me */
+extern const lock_type Drop_Lock; /* Who can drop me */
+extern const lock_type Give_Lock; /* Who can give me */
+extern const lock_type Mail_Lock; /* Who can @mail me */
+extern const lock_type Follow_Lock; /* Who can follow me */
+extern const lock_type Examine_Lock; /* Who can examine visual me */
+extern const lock_type Chzone_Lock; /* Who can @chzone to this object? */
+extern const lock_type Forward_Lock; /* Who can @forwardlist to object? */
+extern const lock_type Control_Lock; /* Who can control this object? */
+extern const lock_type Dropto_Lock; /* Who follows the dropto of this room? */
+extern const lock_type Destroy_Lock; /* Who can @dest me if I'm dest_ok? */
extern const lock_type Interact_Lock;
-extern const lock_type MailForward_Lock; /* Who can forward mail to me */
+extern const lock_type MailForward_Lock; /* Who can forward mail to me */
extern const lock_type Take_Lock;
/* channel locks */
#ifdef NEWCHAT
/* The only locktypes we don't pass Use and Command */
#define IS_passlock_type(ltp) (strcasecmp(ltp, Use_Lock) && strcasecmp(ltp, Command_Lock))
-#endif /* __LOCK_H */
+#endif /* __LOCK_H */
#define LT_WIZ 2
#define LT_CONN 3
#define LT_TRACE 4
-#define LT_RPAGE 5 /* Obsolete */
+#define LT_RPAGE 5 /* Obsolete */
#define LT_CHECK 6
#define LT_HUH 7
#define LA_CMD 0
#define LA_PE 1
#define LA_LOCK 2
-#define ACTIVITY_LOG_SIZE 3 /* In BUFFER_LEN-size lines */
+#define ACTIVITY_LOG_SIZE 3 /* In BUFFER_LEN-size lines */
extern void log_activity(int type, dbref player, const char *action);
extern void notify_activity(dbref player, int num_lines, int dump);
extern const char *last_activity(void);
extern int last_activity_type(void);
-#endif /* LOG_H */
+#endif /* LOG_H */
#define _MALIAS_H
-#define MALIAS_TOKEN '+' /* Initial char for alias names */
+#define MALIAS_TOKEN '+' /* Initial char for alias names */
-#define ALIAS_MEMBERS 0x1 /* Only those on the alias */
-#define ALIAS_ADMIN 0x2 /* Only admin/powered */
-#define ALIAS_OWNER 0x4 /* Only the owner */
+#define ALIAS_MEMBERS 0x1 /* Only those on the alias */
+#define ALIAS_ADMIN 0x2 /* Only admin/powered */
+#define ALIAS_OWNER 0x4 /* Only the owner */
/** A mail alias.
* This structure represents a mail alias (or mailing list).
*/
struct mail_alias {
- char *name; /**< Name of the alias */
- unsigned char *desc; /**< Description */
- int size; /**< Size of the members array */
- dbref *members; /**< Pointer to an array of dbrefs of list members */
- int nflags; /**< Permissions for who can use/see alias name */
- int mflags; /**< Permissions for who can list alias members */
- dbref owner; /**< Who owns (controls) this alias */
+ char *name; /**< Name of the alias */
+ unsigned char *desc; /**< Description */
+ int size; /**< Size of the members array */
+ dbref *members; /**< Pointer to an array of dbrefs of list members */
+ int nflags; /**< Permissions for who can use/see alias name */
+ int mflags; /**< Permissions for who can list alias members */
+ dbref owner; /**< Who owns (controls) this alias */
};
extern void save_malias(FILE * fp);
extern void malias_cleanup(dbref player);
extern void do_malias_set(dbref player, char *alias, char *tolist);
-#else /* MAIL_ALIASES */
+#else /* MAIL_ALIASES */
/* We still need this one */
void load_malias(FILE * fp);
#define match_thing(player,name) \
noisy_match_result((player), (name), NOTYPE, MAT_EVERYTHING)
-#endif /* __MATCH_H */
+#endif /* __MATCH_H */
/* Power macros */
#include "flags.h"
-#define LastMod(x) (db[x].lastmod)
+#define LastMod(x) (db[x].lastmod)
#define TC_Builder(x) (command_check_byname(x, "@dig"))
-#define Builder(x) OOREF(x,TC_Builder(x), TC_Builder(ooref))
+#define Builder(x) OOREF(x,TC_Builder(x), TC_Builder(ooref))
#define TC_CanModify(x,y) (x == y || div_powover(x,y,"Modify"))
-#define CanModify(x,y) OOREF(x,TC_CanModify(x,y), TC_CanModify(ooref,y))
+#define CanModify(x,y) OOREF(x,TC_CanModify(x,y), TC_CanModify(ooref,y))
#define TC_Site(x) (God(x) || div_powover(x,x,"Site") || (Inherit_Powers(x) && div_powover(Owner(x),Owner(x),"Site")))
-#define Site(x) OOREF(x, TC_Site(x), TC_Site(ooref))
+#define Site(x) OOREF(x, TC_Site(x), TC_Site(ooref))
#define Guest(x) (LEVEL(x) == LEVEL_GUEST) /* Guest needs no twincheck */
#define TC_Tel_Anywhere(x) (God(x))
-#define Tel_Anywhere(x) OOREF(x,TC_Tel_Anywhere(x),TC_Tel_Anywhere(ooref))
+#define Tel_Anywhere(x) OOREF(x,TC_Tel_Anywhere(x),TC_Tel_Anywhere(ooref))
#define Tel_Anything(x) (God(x)) /* This needs no twincheck. This is already accounted for in dbdefs.h */
#define Tel_Where(x,y) (Tel_Anywhere(x) || OOREF(x,div_powover(x,y,"Tel_Place"),div_powover(ooref,y,"Tel_Place")))
#define Tel_Thing(x,y) (Tel_Anything(x) || OOREF(x,div_powover(x,y,"Tel_Thing"),div_powover(ooref,y,"Tel_Thing")))
-#define TC_RPTEL(x) (div_powover(x,x, "RPTel") || (Inherit_Powers(x) && div_powover(Owner(x), Owner(x), "RPTel")))
-#define Can_RPTEL(x) OOREF(x,TC_RPTEL(x), TC_RPTEL(x))
-#define Can_BCREATE(x) (OOREF(x,div_powover(x,x, "BCreate"), div_powover(ooref, ooref, "BCreate")))
+#define TC_RPTEL(x) (div_powover(x,x, "RPTel") || (Inherit_Powers(x) && div_powover(Owner(x), Owner(x), "RPTel")))
+#define Can_RPTEL(x) OOREF(x,TC_RPTEL(x), TC_RPTEL(x))
+#define Can_BCREATE(x) (OOREF(x,div_powover(x,x, "BCreate"), div_powover(ooref, ooref, "BCreate")))
#define See_All(x) (God(x))
-#define CanNewpass(x,y) OOREF(x,div_powover(x,y,"Newpass"), div_powover(ooref,y,"Newpass"))
+#define CanNewpass(x,y) OOREF(x,div_powover(x,y,"Newpass"), div_powover(ooref,y,"Newpass"))
/* #define CanSee(x,y) (God(x) || div_powover(x,y,POW_SEE_ALL)) */
#define Prived(x) OOREF(x,div_powover(x,x,"Privilege"),div_powover(ooref,ooref,"Privilege"))
#define Priv_Who(x) (OOREF(x,div_powover(x,x,"PrivWho"),div_powover(ooref,ooref, "PrivWho")) || Site(x))
#define Can_Idle(x) (div_powover(x,x,"Idle")) /* this won't either */
#define Pass_Lock(x,y) OOREF(x,div_powover(x,y,"Pass_Locks"),div_powover(ooref,y,"Pass_Locks"))
#define TC_IsMailAdmin(x) (God(x) || (check_power_yescode(DPBITS(x),find_power("MailAdmin")) > 0))
-#define MailAdministrator(x) OOREF(x,TC_IsMailAdmin(x),TC_IsMailAdmin(ooref))
+#define MailAdministrator(x) OOREF(x,TC_IsMailAdmin(x),TC_IsMailAdmin(ooref))
#define MailAdmin(x,y) OOREF(x,div_powover(x,y,"MailAdmin"),div_powover(ooref,y,"MailAdmin"))
#define TC_Long_Fingers(x) (div_powover(x,x,"Remote") || (Inherit_Powers(x) && div_powover(Owner(x),Owner(x), "Remote")))
#define Long_Fingers(x) OOREF(x,TC_Long_Fingers(x),TC_Long_Fingers(ooref))
#define HaltAny(x) (Director(x) && OOREF(x,div_powover(x,x,"Halt"),div_powover(ooref,ooref,"Halt")))
#define CanHalt(x,y) OOREF(x,div_powover(x,y,"Halt"),div_powover(ooref,y,"Halt"))
-#define CanNuke(x,y) OOREF(x,div_powover(x,y,"Nuke"),div_powover(ooref, y, "Nuke"))
+#define CanNuke(x,y) OOREF(x,div_powover(x,y,"Nuke"),div_powover(ooref, y, "Nuke"))
#define TC_NoPay(x) (div_powover(x,x,"NoPay") || div_powover(Owner(x),Owner(x),"NoPay"))
-#define NoPay(x) OOREF(x,TC_NoPay(x),TC_NoPay(ooref))
+#define NoPay(x) OOREF(x,TC_NoPay(x),TC_NoPay(ooref))
#define TC_MoneyAdmin(x) (NoPay(x) && Prived(x))
-#define MoneyAdmin(x) OOREF(x,TC_MoneyAdmin(x),TC_MoneyAdmin(ooref))
+#define MoneyAdmin(x) OOREF(x,TC_MoneyAdmin(x),TC_MoneyAdmin(ooref))
#define TC_NoQuota(x) (div_powover(x,x,"NoQuota") || div_powover(Owner(x),Owner(x),"NoQuota"))
-#define TC_DNoQuota(x) (!!has_power(x, "NoQuota"))
-#define NoQuota(x) (IsDivision(x) ? OOREF(x,TC_DNoQuota(x), TC_DNoQuota(ooref)) : OOREF(x,TC_NoQuota(x),TC_NoQuota(ooref)))
+#define TC_DNoQuota(x) (!!has_power(x, "NoQuota"))
+#define NoQuota(x) (IsDivision(x) ? OOREF(x,TC_DNoQuota(x), TC_DNoQuota(ooref)) : OOREF(x,TC_NoQuota(x),TC_NoQuota(ooref)))
#define CanSearch(x,y) OOREF(x,(Owner(x) == Owner(y) || div_powover(x,y,"Search")),(Owner(ooref) == Owner(y) || div_powover(ooref,y,"Search") ))
#define Global_Funcs(x) OOREF(x,div_powover(x,x,"GFuncs"),div_powover(ooref,ooref,"GFuncs"))
#define Create_Player(x) OOREF(x,div_powover(x,x,"PCreate"),div_powover(ooref,ooref,"PCreate"))
#define Can_Announce(x) OOREF(x,div_powover(x,x,"Announce"),div_powover(ooref,ooref,"Announce"))
#define TC_Can_Cemit(x) (div_powover(x,x,"Cemit") || (Inherit_Powers(x) && div_powover(Owner(x),Owner(x),"Cemit")))
-#define Can_Cemit(x) OOREF(x,TC_Can_Cemit(x),TC_Can_Cemit(ooref))
-#define Can_Pemit(x,y) OOREF(x,div_powover(x,y,"Pemit"),div_powover(ooref,y,"Pemit"))
+#define Can_Cemit(x) OOREF(x,TC_Can_Cemit(x),TC_Can_Cemit(ooref))
+#define Can_Pemit(x,y) OOREF(x,div_powover(x,y,"Pemit"),div_powover(ooref,y,"Pemit"))
#define Can_Nspemit(x) (div_powover(x,x,"Can_NsPemit"))
#define CanProg(x,y) OOREF(x,div_powover(x,y,"Program"),div_powover(ooref,y,"Program"))
#define CanProgLock(x,y) OOREF(x,div_powover(x,y,"ProgLock"),div_powover(ooref,y,"ProgLock"))
-#define Sql_Ok(x) (Director(x) || OOREF(x,div_powover(x,x,"SQL_Ok"),div_powover(ooref,ooref,"SQL_Ok")))
-#define Many_Attribs(x) (OOREF(x,div_powover(x,x,"Many_Attribs"),div_powover(ooref,ooref,"Many_Attribs")))
-#define Can_Pueblo_Send(x) (Director(x) || OOREF(x,div_powover(x,x,"Pueblo_Send"),div_powover(ooref,ooref,"Pueblo_Send")))
-#define Can_RPEMIT(x) (div_powover(x,x, "RPEmit") || (Inherit_Powers(x) || div_powover(Owner(x),Owner(x), "RPEmit")) ||Admin(x))
-#define Can_RPCHAT(x) (div_powover(x, x, "RPChat") || (Inherit_Powers(x) || div_powover(Owner(x),Owner(x), "RPChat")) || Admin(x))
-#define Inherit_Powers(x) (Inherit(x) && Inheritable(Owner(x)))
+#define Sql_Ok(x) (Director(x) || OOREF(x,div_powover(x,x,"SQL_Ok"),div_powover(ooref,ooref,"SQL_Ok")))
+#define Many_Attribs(x) (OOREF(x,div_powover(x,x,"Many_Attribs"),div_powover(ooref,ooref,"Many_Attribs")))
+#define Can_Pueblo_Send(x) (Director(x) || OOREF(x,div_powover(x,x,"Pueblo_Send"),div_powover(ooref,ooref,"Pueblo_Send")))
+#define Can_RPEMIT(x) (div_powover(x,x, "RPEmit") || (Inherit_Powers(x) || div_powover(Owner(x),Owner(x), "RPEmit")) ||Admin(x))
+#define Can_RPCHAT(x) (div_powover(x, x, "RPChat") || (Inherit_Powers(x) || div_powover(Owner(x),Owner(x), "RPChat")) || Admin(x))
+#define Inherit_Powers(x) (Inherit(x) && Inheritable(Owner(x)))
#define CanChown(x,y) (OOREF(x,div_powover(x,y,"Chown"),div_powover(ooref,y,"Chown")))
/* Permission macros */
!(f->perms & (F_DARK | F_MDARK | F_DISABLED))) || \
((div_cansee(p,t) && Admin(p)) && !(f->perms & (F_DARK | F_DISABLED))) || \
God(p)))
-#define Can_See_Flag(p,t,f) OOREF(p,TC_Can_See_Flag(p,t,f),TC_Can_See_Flag(ooref,t,f))
+#define Can_See_Flag(p,t,f) OOREF(p,TC_Can_See_Flag(p,t,f),TC_Can_See_Flag(ooref,t,f))
/* Can p locate x? */
int unfindable(dbref);
(controls(p,x) || nearby(p,x) || CanSee(p,x) \
|| (command_check_byname(p, "@whereis") && (IsPlayer(x) && !Unfind(x) \
&& !unfindable(Location(x))))) && (Unfind(x) ? LEVEL(p) >= LEVEL(x) : 1)
-#define Can_Locate(p,x) OOREF(p,TC_Can_Locate(p,x),TC_Can_Locate(ooref,x))
+#define Can_Locate(p,x) OOREF(p,TC_Can_Locate(p,x),TC_Can_Locate(ooref,x))
#define TC_Can_Examine(p,x) (controls(p,x)|| \
div_cansee(p,x) || (Visual(x) && eval_lock(p,x,Examine_Lock)))
-#define Can_Examine(p,x) OOREF(p,TC_Can_Examine(p,x),TC_Can_Examine(ooref,x))
-#define CanSee(p,x) Can_Examine(p,x)
+#define Can_Examine(p,x) OOREF(p,TC_Can_Examine(p,x),TC_Can_Examine(ooref,x))
+#define CanSee(p,x) Can_Examine(p,x)
- /***< UnUsed macro?
- * - RLB
+ /***< UnUsed macro?
+ * - RLB
#define TC_can_link(p,x) (controls(p,x) || \
(IsExit(x) && (Location(x) == NOTHING)))
- */
+ */
/* Can p link an exit to x? */
#define TC_can_link_to(p,x) \
&& (!NO_LINK_TO_OBJECT || IsRoom(x)))
#define can_link_to(p,x) OOREF(p,TC_can_link_to(p,x),TC_can_link_to(ooref,x))
- /* DivRead needs no TC designation */
+ /* DivRead needs no TC designation */
#define Can_DivRead_Attr(p,x,a) ((div_cansee(p,x) && !(a->flags & AF_MDARK)) \
|| (div_cansee(p,x) && \
(div_powover(p,p,"Privilege")|| (Inherit_Powers(p) \
- &&( div_powover(Owner(p), Owner(p),"Privilege" ))))))
+ &&( div_powover(Owner(p), Owner(p),"Privilege" ))))))
/* can p access attribute a on object x? */
#define TC_Can_Read_Attr(p,x,a) can_read_attr_internal(p,x,a)
/* can p write attribute a on object x, assuming p may modify x?
*/
#define TC_Can_Write_Attr(p,x,a) can_write_attr_internal((p), (x), (a), 1)
-#define Can_Write_Attr(p,x,a) OOREF(p,TC_Can_Write_Attr(p,x,a),TC_Can_Write_Attr(ooref,x,a))
+#define Can_Write_Attr(p,x,a) OOREF(p,TC_Can_Write_Attr(p,x,a),TC_Can_Write_Attr(ooref,x,a))
#define TC_Can_Write_Attr_Ignore_Safe(p,x,a) can_write_attr_internal(p,x,a, 0)
#define Can_Write_Attr_Ignore_Safe(p,x,a) \
- OOREF(p,TC_Can_Write_Attr_Ignore_Safe(p,x,a), TC_Can_Write_Attr_Ignore_Safe(ooref,x,a))
+ OOREF(p,TC_Can_Write_Attr_Ignore_Safe(p,x,a), TC_Can_Write_Attr_Ignore_Safe(ooref,x,a))
/*
#define Can_Write_Attr(p,x,a) \
(God(p) || \
/* How many pennies can you have? */
#define TC_Max_Pennies(p) (Guest(p) ? MAX_GUEST_PENNIES : MAX_PENNIES)
-#define Max_Pennies(p) OOREF(p,TC_Max_Pennies(p),TC_Max_Pennies(ooref))
+#define Max_Pennies(p) OOREF(p,TC_Max_Pennies(p),TC_Max_Pennies(ooref))
#define TC_Paycheck(p) (Guest(p) ? GUEST_PAY_CHECK : PAY_CHECK)
-#define Paycheck(p) OOREF(p,TC_Paycheck(p), TC_Paycheck(ooref))
+#define Paycheck(p) OOREF(p,TC_Paycheck(p), TC_Paycheck(ooref))
/* DB flag macros - these should be defined whether or not the
* corresponding system option is defined
#define DBF_AF_NODUMP 0x8000
#define DBF_SPIFFY_LOCKS 0x10000
#define DBF_NEW_FLAGS 0x20000
-#define DBF_DIVISIONS 0x40000
-#define DBF_LABELS 0x100000
-#define DBF_NEW_ATR_LOCK 0x200000
-#define DBF_ATR_MODTIME 0x400000
+#define DBF_DIVISIONS 0x40000
+#define DBF_LABELS 0x100000
+#define DBF_NEW_ATR_LOCK 0x200000
+#define DBF_ATR_MODTIME 0x400000
#define FLAG_DBF_CQUOTA_RENAME 0x01 /* Rename CQuota Power to SetQuotas */
-#define HAS_COBRADBFLAG(x,y) (!(x & DBF_TYPE_GARBAGE) && (x & y)) /* Macro exists so cobra & penn dbflags can exist as same DBFs */
+#define HAS_COBRADBFLAG(x,y) (!(x & DBF_TYPE_GARBAGE) && (x & y)) /* Macro exists so cobra & penn dbflags can exist as same DBFs */
#define IS_COBRA_DB(x) (!(x & DBF_TYPE_GARBAGE))
#define RDBF_TTYPE 0x02
#define RDBF_PUEBLO_CHECKSUM 0x04
/* Available: 0x08 - 0x8000 */
-#define RDBF_SU_EXIT_PATH 0x00010000
+#define RDBF_SU_EXIT_PATH 0x00010000
-#endif /* __DB_H */
+#endif /* __DB_H */
typedef long int warn_type;
/* special dbref's */
-#define NOTHING (-1) /* null dbref */
-#define AMBIGUOUS (-2) /* multiple possibilities, for matchers */
-#define HOME (-3) /* virtual room, represents mover's home */
-#define ANY_OWNER (-2) /* For lstats and @stat */
+#define NOTHING (-1) /* null dbref */
+#define AMBIGUOUS (-2) /* multiple possibilities, for matchers */
+#define HOME (-3) /* virtual room, represents mover's home */
+#define ANY_OWNER (-2) /* For lstats and @stat */
#define INTERACT_SEE 0x1
* this struct unless you _really_ want to get your hands dirty.
*/
struct pe_info {
- int fun_invocations; /**< Invocation count */
- int fun_depth; /**< Recursion count */
- int nest_depth; /**< Depth of function nesting, for DEBUG */
- int call_depth; /**< Function call counter */
- Debug_Info *debug_strings; /**< DEBUG infromation */
- int arg_count; /**< Number of arguments passed to function */
+ int fun_invocations; /**< Invocation count */
+ int fun_depth; /**< Recursion count */
+ int nest_depth; /**< Depth of function nesting, for DEBUG */
+ int call_depth; /**< Function call counter */
+ Debug_Info *debug_strings; /**< DEBUG infromation */
+ int arg_count; /**< Number of arguments passed to function */
};
/* new attribute foo */
/* from prog.c */
typedef struct prog_info_t {
- dbref object; /* object the program is located on */
- ATTR *atr; /* attribute to handle the program */
- int lock; /* whether or not the player is locked in the program */
- int (*function)(); /* For internal programs. Function to goto next */
+ dbref object; /* object the program is located on */
+ ATTR *atr; /* attribute to handle the program */
+ int lock; /* whether or not the player is locked in the program */
+ int (*function)(); /* For internal programs. Function to goto next */
} PROG;
typedef struct su_exit_path_t {
/** A text block
*/
struct text_block {
- int nchars; /**< Number of characters in the block */
- struct text_block *nxt; /**< Pointer to next block in queue */
- unsigned char *start; /**< Start of text */
- unsigned char *buf; /**< Current position in text */
+ int nchars; /**< Number of characters in the block */
+ struct text_block *nxt; /**< Pointer to next block in queue */
+ unsigned char *start; /**< Start of text */
+ unsigned char *buf; /**< Current position in text */
};
/** A queue of text blocks.
*/
struct text_queue {
- struct text_block *head; /**< Pointer to the head of the queue */
- struct text_block **tail; /**< Pointer to pointer to tail of the queue */
+ struct text_block *head; /**< Pointer to the head of the queue */
+ struct text_block **tail; /**< Pointer to pointer to tail of the queue */
};
* with a lot of other relevant information.
*/
struct descriptor_data {
- int descriptor; /**< Connection socket (fd) */
- int connected; /**< Connection status */
- char addr[101]; /**< Hostname of connection source */
- char ip[101]; /**< IP address of connection source */
- dbref player; /**< Dbref of player associated with connection */
- dbref snooper[MAX_SNOOPS]; /**< dbrefs of snoopers */
- unsigned char *output_prefix; /**< Text to show before output */
- unsigned char *output_suffix; /**< Text to show after output */
- int output_size; /**< Size of output left to send */
- struct text_queue output; /**< Output text queue */
- struct text_queue input; /**< Input text queue */
- unsigned char *raw_input; /**< Pointer to start of next raw input */
- unsigned char *raw_input_at; /**< Pointer to position in raw input */
- int (*input_handler)(DESC *, char *); /**< Pointer to input handler */
- long connected_at; /**< Time of connection */
- long last_time; /**< Time of last activity */
+ int descriptor; /**< Connection socket (fd) */
+ int connected; /**< Connection status */
+ char addr[101]; /**< Hostname of connection source */
+ char ip[101]; /**< IP address of connection source */
+ dbref player; /**< Dbref of player associated with connection */
+ dbref snooper[MAX_SNOOPS]; /**< dbrefs of snoopers */
+ unsigned char *output_prefix; /**< Text to show before output */
+ unsigned char *output_suffix; /**< Text to show after output */
+ int output_size; /**< Size of output left to send */
+ struct text_queue output; /**< Output text queue */
+ struct text_queue input; /**< Input text queue */
+ unsigned char *raw_input; /**< Pointer to start of next raw input */
+ unsigned char *raw_input_at; /**< Pointer to position in raw input */
+ int (*input_handler)(DESC *, char *); /**< Pointer to input handler */
+ long connected_at; /**< Time of connection */
+ long last_time; /**< Time of last activity */
long idle_total; /**< Total Idle Secs Expended.. This / Idle_Times == Idle Average for session */
int unidle_times; /**< Amoutn of Times unidled from 10 seconds */
- int quota; /**< Quota of commands allowed */
- int cmds; /**< Number of commands sent */
- int hide; /**< Hide status */
- char doing[DOING_LEN]; /**< Player's doing string */
+ int quota; /**< Quota of commands allowed */
+ int cmds; /**< Number of commands sent */
+ int hide; /**< Hide status */
+ char doing[DOING_LEN]; /**< Player's doing string */
#ifdef NT_TCP
/* these are for the Windows NT TCP/IO */
- char input_buffer[512]; /**< WinNT: buffer for reading */
- char output_buffer[512]; /**< WinNT: buffer for writing */
- OVERLAPPED InboundOverlapped; /**< WinNT: for asynchronous reading */
- OVERLAPPED OutboundOverlapped; /**< WinNT: for asynchronous writing */
- BOOL bWritePending; /**< WinNT: true if in process of writing */
- BOOL bConnectionDropped; /**< WinNT: true if we cannot send to player */
- BOOL bConnectionShutdown; /**< WinNT: true if connection has been shutdown */
+ char input_buffer[512]; /**< WinNT: buffer for reading */
+ char output_buffer[512]; /**< WinNT: buffer for writing */
+ OVERLAPPED InboundOverlapped; /**< WinNT: for asynchronous reading */
+ OVERLAPPED OutboundOverlapped; /**< WinNT: for asynchronous writing */
+ BOOL bWritePending; /**< WinNT: true if in process of writing */
+ BOOL bConnectionDropped; /**< WinNT: true if we cannot send to player */
+ BOOL bConnectionShutdown; /**< WinNT: true if connection has been shutdown */
#endif
- struct descriptor_data *next; /**< Next descriptor in linked list */
- struct descriptor_data *prev; /**< Previous descriptor in linked list */
+ struct descriptor_data *next; /**< Next descriptor in linked list */
+ struct descriptor_data *prev; /**< Previous descriptor in linked list */
#ifdef USE_MAILER
- struct mail *mailp; /**< Pointer to start of player's mail chain */
+ struct mail *mailp; /**< Pointer to start of player's mail chain */
#endif
- int conn_flags; /**< Flags of connection (telnet status, etc.) */
- unsigned long input_chars; /**< Characters received */
- unsigned long output_chars; /**< Characters sent */
- int width; /**< Screen width */
- int height; /**< Screen height */
- char *ttype; /**< Terminal type */
- SU_PATH *su_exit_path; /**< Su Exit Path */
+ int conn_flags; /**< Flags of connection (telnet status, etc.) */
+ unsigned long input_chars; /**< Characters received */
+ unsigned long output_chars; /**< Characters sent */
+ int width; /**< Screen width */
+ int height; /**< Screen height */
+ char *ttype; /**< Terminal type */
+ SU_PATH *su_exit_path; /**< Su Exit Path */
#ifdef HAS_OPENSSL
- SSL *ssl; /**< SSL object */
- int ssl_state; /**< Keep track of state of SSL object */
+ SSL *ssl; /**< SSL object */
+ int ssl_state; /**< Keep track of state of SSL object */
#endif
char checksum[PUEBLO_CHECKSUM_LEN+1]; /**<Pueblo checksum */
char prompt_info[1]; /* prompt info. 0 - in prompt, 1 - fed prompt */
#include "csrimalloc.h"
#endif
-#endif /* _MYMALLOC_H */
+#endif /* _MYMALLOC_H */
#endif
#include <winsock.h>
#include <io.h>
-#undef EINTR /* Clashes with errno.h */
+#undef EINTR /* Clashes with errno.h */
#define EINTR WSAEINTR
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
/** Information about a host.
*/
struct hostname_info {
- const char *hostname; /**< Host's name */
- const char *port; /**< Host's source port */
+ const char *hostname; /**< Host's name */
+ const char *port; /**< Host's source port */
};
/** A union for sockaddr manipulation */
union sockaddr_u {
- struct sockaddr addr; /**< A sockaddr structure */
- char data[MAXSOCKADDR]; /**< A byte array representation */
+ struct sockaddr addr; /**< A sockaddr structure */
+ char data[MAXSOCKADDR]; /**< A byte array representation */
};
/* What htons expects. Is this even used anymore? */
(Port_t port, union sockaddr_u *addr, socklen_t *len, const char *host);
/* Connect somewhere */
int make_socket_conn(const char *host, struct sockaddr *myiterface,
- socklen_t myilen, Port_t port, int *timeout);
+ socklen_t myilen, Port_t port, int *timeout);
void make_nonblocking(int s);
void set_keepalive(int s);
int connect_nonb
#else
extern void shutdownsock(DESC *d);
extern BOOL GetErrorMessage(const DWORD dwError, LPTSTR lpszError, const UINT
- nMaxError);
+ nMaxError);
#endif
*/
struct addrinfo {
- int ai_flags; /**< AI_PASSIVE, AI_CANONNAME */
- int ai_family; /**< PF_xxx */
- int ai_socktype; /**< SOCK_xxx */
- int ai_protocol; /**< IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /**< length of ai_addr */
- char *ai_canonname; /**< canonical name for host */
- struct sockaddr *ai_addr; /**< binary address */
- struct addrinfo *ai_next; /**< next structure in linked list */
+ int ai_flags; /**< AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /**< PF_xxx */
+ int ai_socktype; /**< SOCK_xxx */
+ int ai_protocol; /**< IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /**< length of ai_addr */
+ char *ai_canonname; /**< canonical name for host */
+ struct sockaddr *ai_addr; /**< binary address */
+ struct addrinfo *ai_next; /**< next structure in linked list */
};
struct addrinfo;
- /* following for getaddrinfo() */
-#define AI_PASSIVE 1 /* socket is intended for bind() + listen() */
-#define AI_CANONNAME 2 /* return canonical name */
-
- /* error returns */
-#define EAI_ADDRFAMILY 1 /* address family for host not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with host */
-#define EAI_NONAME 8 /* host nor service provided, or not known */
-#define EAI_SERVICE 9 /* service not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error returned in errno */
+ /* following for getaddrinfo() */
+#define AI_PASSIVE 1 /* socket is intended for bind() + listen() */
+#define AI_CANONNAME 2 /* return canonical name */
+
+ /* error returns */
+#define EAI_ADDRFAMILY 1 /* address family for host not supported */
+#define EAI_AGAIN 2 /* temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NODATA 7 /* no address associated with host */
+#define EAI_NONAME 8 /* host nor service provided, or not known */
+#define EAI_SERVICE 9 /* service not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error returned in errno */
int getaddrinfo(const char *hostname, const char *servname,
- const struct addrinfo *hintsp, struct addrinfo **result);
+ const struct addrinfo *hintsp, struct addrinfo **result);
/* If we don't have getaddrinfo, we won't have these either... */
void freeaddrinfo(struct addrinfo *old);
-#endif /* HAS_GETADDRINFO */
+#endif /* HAS_GETADDRINFO */
#ifndef HAS_GAI_STRERROR
const char *gai_strerror(int errval);
#endif
-#ifndef HAS_GETNAMEINFO /* following for getnameinfo() */
+#ifndef HAS_GETNAMEINFO /* following for getnameinfo() */
#ifndef __APPLE__
/* Apple has these in netdb.h */
-#define NI_MAXHOST 1025 /* max hostname returned */
-#define NI_MAXSERV 32 /* max service name returned */
-
-#define NI_NOFQDN 1 /* do not return FQDN */
-#define NI_NUMERICHOST 2 /* return numeric form of hostname */
-#define NI_NAMEREQD 4 /* return error if hostname not found */
-#define NI_NUMERICSERV 8 /* return numeric form of service name */
-#define NI_DGRAM 16 /* datagram service for getservbyname() */
+#define NI_MAXHOST 1025 /* max hostname returned */
+#define NI_MAXSERV 32 /* max service name returned */
+
+#define NI_NOFQDN 1 /* do not return FQDN */
+#define NI_NUMERICHOST 2 /* return numeric form of hostname */
+#define NI_NAMEREQD 4 /* return error if hostname not found */
+#define NI_NUMERICSERV 8 /* return numeric form of service name */
+#define NI_DGRAM 16 /* datagram service for getservbyname() */
#endif
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
- size_t hostlen, char *serv, size_t servlen, int flags);
-#endif /* HAS_GETNAMEINFO */
+ size_t hostlen, char *serv, size_t servlen, int flags);
+#endif /* HAS_GETNAMEINFO */
-#endif /* MYSOCKET_H */
+#endif /* MYSOCKET_H */
int ssl_need_handshake(int state);
int ssl_want_write(int state);
int ssl_read(SSL * ssl, int state, int net_read_ready, int net_write_ready,
- char *buf, int bufsize, int *bytes_read);
+ char *buf, int bufsize, int *bytes_read);
int ssl_write(SSL * ssl, int state, int net_read_ready, int net_write_ready,
- unsigned char *buf, int bufsize, int *offset);
+ unsigned char *buf, int bufsize, int *offset);
void ssl_write_session(FILE * fp, SSL * ssl);
void ssl_read_session(FILE * fp);
void ssl_write_ssl(FILE * fp, SSL * ssl);
SSL *ssl_read_ssl(FILE * fp, int sock);
-#endif /* HAS_OPENSSL */
-#endif /* _MYSSL_H */
+#endif /* HAS_OPENSSL */
+#endif /* _MYSSL_H */
#define OLD_TYPE_PLAYER 0x3
#define OLD_TYPE_DIVISION 0x4
#define OLD_TYPE_GARBAGE 0x6
-#define OLD_NOTYPE 0x7 /* no particular type */
-#define OLD_TYPE_MASK 0x7 /* room for expansion */
+#define OLD_NOTYPE 0x7 /* no particular type */
+#define OLD_TYPE_MASK 0x7 /* room for expansion */
/* -- empty slot 0x8 -- */
-#define LINK_OK 0x20 /* anybody can link to this room */
-#define DARK 0x40 /* contents of room are not printed */
- /* exit doesn't appear as 'obvious' */
-#define VERBOSE 0x80 /* print out command before executing it */
-#define STICKY 0x100 /* goes home when dropped */
-#define TRANSPARENTED 0x200 /* can look through exit to see next room,
- * or room "long exit display.
- * We don't call it TRANSPARENT because
- * that's a Solaris macro
- */
-#define HAVEN 0x400 /* this room disallows kills in it */
- /* on a player, disallow paging, */
-#define QUIET 0x800 /* On an object, will not emit 'set'
- * messages.. on a player.. will not see ANY
- * set messages
- */
-#define HALT 0x1000 /* object cannot perform actions */
-#define UNFIND 0x2000 /* object cannot be found (or found in */
-#define GOING 0x4000 /* object is available for recycling */
-#define ACCESSED 0x8000 /* Obsolete - only for conversion */
+#define LINK_OK 0x20 /* anybody can link to this room */
+#define DARK 0x40 /* contents of room are not printed */
+ /* exit doesn't appear as 'obvious' */
+#define VERBOSE 0x80 /* print out command before executing it */
+#define STICKY 0x100 /* goes home when dropped */
+#define TRANSPARENTED 0x200 /* can look through exit to see next room,
+ * or room "long exit display.
+ * We don't call it TRANSPARENT because
+ * that's a Solaris macro
+ */
+#define HAVEN 0x400 /* this room disallows kills in it */
+ /* on a player, disallow paging, */
+#define QUIET 0x800 /* On an object, will not emit 'set'
+ * messages.. on a player.. will not see ANY
+ * set messages
+ */
+#define HALT 0x1000 /* object cannot perform actions */
+#define UNFIND 0x2000 /* object cannot be found (or found in */
+#define GOING 0x4000 /* object is available for recycling */
+#define ACCESSED 0x8000 /* Obsolete - only for conversion */
/* -- empty slot 0x8000, once your db is converted -- */
-#define MARKED 0x10000 /* flag used to trace db checking of room
- * linkages. */
-#define NOWARN 0x20000 /* Object will not cause warnings.
- * If set on a player, player will not
- * get warnings (independent of player's
- * @warning setting
- */
-
-#define CHOWN_OK 0x40000 /* object can be 'stolen' and made yours */
-#define ENTER_OK 0x80000 /* object basically acts like a room with
- * only one exit (leave), on players
- * means that items can be given freely, AND
- * taken from!
- */
-#define VISUAL 0x100000 /* People other than owners can see
- * property list of object.
- */
-#define LIGHT 0x200000 /* Visible in DARK rooms */
-
-#define LOOK_OPAQUE 0x800000 /* Objects inside object will not be
- * seen on a look.
- */
-
-#define DEBUGGING 0x2000000 /* returns parser evals */
-#define SAFE 0x4000000 /* cannot be destroyed */
-#define STARTUP 0x8000000 /* Used for converting old dbs */
+#define MARKED 0x10000 /* flag used to trace db checking of room
+ * linkages. */
+#define NOWARN 0x20000 /* Object will not cause warnings.
+ * If set on a player, player will not
+ * get warnings (independent of player's
+ * @warning setting
+ */
+
+#define CHOWN_OK 0x40000 /* object can be 'stolen' and made yours */
+#define ENTER_OK 0x80000 /* object basically acts like a room with
+ * only one exit (leave), on players
+ * means that items can be given freely, AND
+ * taken from!
+ */
+#define VISUAL 0x100000 /* People other than owners can see
+ * property list of object.
+ */
+#define LIGHT 0x200000 /* Visible in DARK rooms */
+
+#define LOOK_OPAQUE 0x800000 /* Objects inside object will not be
+ * seen on a look.
+ */
+
+#define DEBUGGING 0x2000000 /* returns parser evals */
+#define SAFE 0x4000000 /* cannot be destroyed */
+#define STARTUP 0x8000000 /* Used for converting old dbs */
/* -- empty slot 0x8000000, if your db is already converted -- */
-#define AUDIBLE 0x10000000 /* rooms are flagged as having emitter
- * exits. exits act like emitters,
- * sound propagates to the exit dest.
- */
-#define NO_COMMAND 0x20000000 /* don't check for $commands */
-
-#define GOING_TWICE 0x40000000 /* Marked for destruction, but
- * spared once. */
+#define AUDIBLE 0x10000000 /* rooms are flagged as having emitter
+ * exits. exits act like emitters,
+ * sound propagates to the exit dest.
+ */
+#define NO_COMMAND 0x20000000 /* don't check for $commands */
+
+#define GOING_TWICE 0x40000000 /* Marked for destruction, but
+ * spared once. */
/* -- empty slot 0x80000000 -- */
/*--------------------------------------------------------------------------
* Player flags
*/
-#define PLAYER_TERSE 0x8 /* suppress autolook messages */
-#define PLAYER_MYOPIC 0x10 /* look at everything as if player
- * doesn't control it.
- */
-#define PLAYER_NOSPOOF 0x20 /* sees origin of emits */
-#define PLAYER_SUSPECT 0x40 /* notifies of a player's name changes,
- * (dis)connects, and possible logs
- * logs commands.
- */
-#define PLAYER_GAGGED 0x80 /* can only move */
-#define PLAYER_MONITOR 0x100 /* sees (dis)connects broadcasted */
-#define PLAYER_CONNECT 0x200 /* connected to game */
-#define PLAYER_ANSI 0x400 /* enable sending of ansi control
- * sequences (for examine).
- */
-#define PLAYER_ZONE 0x800 /* Zone Master (zone control owner) */
-#define PLAYER_FIXED 0x4000 /* can't @tel or home */
+#define PLAYER_TERSE 0x8 /* suppress autolook messages */
+#define PLAYER_MYOPIC 0x10 /* look at everything as if player
+ * doesn't control it.
+ */
+#define PLAYER_NOSPOOF 0x20 /* sees origin of emits */
+#define PLAYER_SUSPECT 0x40 /* notifies of a player's name changes,
+ * (dis)connects, and possible logs
+ * logs commands.
+ */
+#define PLAYER_GAGGED 0x80 /* can only move */
+#define PLAYER_MONITOR 0x100 /* sees (dis)connects broadcasted */
+#define PLAYER_CONNECT 0x200 /* connected to game */
+#define PLAYER_ANSI 0x400 /* enable sending of ansi control
+ * sequences (for examine).
+ */
+#define PLAYER_ZONE 0x800 /* Zone Master (zone control owner) */
+#define PLAYER_FIXED 0x4000 /* can't @tel or home */
#ifdef ONLINE_REG
-#define PLAYER_UNREG 0x8000 /* Not yet registered */
+#define PLAYER_UNREG 0x8000 /* Not yet registered */
#endif
#ifdef VACATION_FLAG
-#define PLAYER_VACATION 0x10000 /* On vacation */
+#define PLAYER_VACATION 0x10000 /* On vacation */
#endif
-#define PLAYER_COLOR 0x80000 /* ANSI color ok */
-#define PLAYER_NOACCENTS 0x100000 /* Strip accented text on output */
-#define PLAYER_PARANOID 0x200000 /* Paranoid nospoof */
-#define PLAYER_PROG 0x400000
+#define PLAYER_COLOR 0x80000 /* ANSI color ok */
+#define PLAYER_NOACCENTS 0x100000 /* Strip accented text on output */
+#define PLAYER_PARANOID 0x200000 /* Paranoid nospoof */
+#define PLAYER_PROG 0x400000
* Thing flags
*/
-#define THING_DEST_OK 0x8 /* can be destroyed by anyone */
-#define THING_PUPPET 0x10 /* echoes to its owner */
-#define THING_LISTEN 0x20 /* checks for ^ patterns */
-#define THING_NOLEAVE 0x40 /* Can't be left */
-#define THING_INHEARIT 0x80 /* checks parent chain for ^ patterns */
-#define THING_Z_TEL 0x100 /* If set on ZMO players may only @tel
- within the zone */
+#define THING_DEST_OK 0x8 /* can be destroyed by anyone */
+#define THING_PUPPET 0x10 /* echoes to its owner */
+#define THING_LISTEN 0x20 /* checks for ^ patterns */
+#define THING_NOLEAVE 0x40 /* Can't be left */
+#define THING_INHEARIT 0x80 /* checks parent chain for ^ patterns */
+#define THING_Z_TEL 0x100 /* If set on ZMO players may only @tel
+ within the zone */
/*--------------------------------------------------------------------------
* Room flags
*/
-#define ROOM_FLOATING 0x8 /* room is not linked to rest of
- * MUSH. Don't blather about it.
- */
-#define ROOM_ABODE 0x10 /* players may link themselves here */
-#define ROOM_JUMP_OK 0x20 /* anyone may @teleport to here */
-#define ROOM_NO_TEL 0x40 /* mortals cannot @tel from here */
-#define ROOM_TEMPLE 0x80 /* objects dropped here are sacrificed
- * (destroyed) and player gets money.
- * Now used only for conversion.
- */
-#define ROOM_LISTEN 0x100 /* checks for ^ patterns */
-#define ROOM_Z_TEL 0x200 /* If set on a room, players may
- * only @tel to another room in the
- * same zone
- */
-#define ROOM_INHEARIT 0x400 /* checks parent chain for ^ patterns */
-
-#define ROOM_UNINSPECT 0x1000 /* Not inspected */
+#define ROOM_FLOATING 0x8 /* room is not linked to rest of
+ * MUSH. Don't blather about it.
+ */
+#define ROOM_ABODE 0x10 /* players may link themselves here */
+#define ROOM_JUMP_OK 0x20 /* anyone may @teleport to here */
+#define ROOM_NO_TEL 0x40 /* mortals cannot @tel from here */
+#define ROOM_TEMPLE 0x80 /* objects dropped here are sacrificed
+ * (destroyed) and player gets money.
+ * Now used only for conversion.
+ */
+#define ROOM_LISTEN 0x100 /* checks for ^ patterns */
+#define ROOM_Z_TEL 0x200 /* If set on a room, players may
+ * only @tel to another room in the
+ * same zone
+ */
+#define ROOM_INHEARIT 0x400 /* checks parent chain for ^ patterns */
+
+#define ROOM_UNINSPECT 0x1000 /* Not inspected */
/*--------------------------------------------------------------------------
* Exit flags
*/
-#define EXIT_CLOUDY 0x8 /* Looking through a cloudy transparent
- * exit shows the room's desc, not contents.
- * Looking through a cloudy !trans exit,
- * shows the room's contents, not desc
- */
+#define EXIT_CLOUDY 0x8 /* Looking through a cloudy transparent
+ * exit shows the room's desc, not contents.
+ * Looking through a cloudy !trans exit,
+ * shows the room's contents, not desc
+ */
-#endif /* __OLDFLAGS_H */
+#endif /* __OLDFLAGS_H */
#define HUGE_NVAL HUGE_DOUBLE
/* These are some common error messages. */
-extern char e_int[]; /* #-1 ARGUMENT MUST BE INTEGER */
-extern char e_ints[]; /* #-1 ARGUMENTS MUST BE INTEGERS */
-extern char e_uint[]; /* #-1 ARGUMENT MUST BE POSITIVE INTEGER */
-extern char e_uints[]; /* #-1 ARGUMENTS MUST BE POSITIVE INTEGERS */
-extern char e_num[]; /* #-1 ARGUMENT MUST BE NUMBER */
-extern char e_nums[]; /* #-1 ARGUMENTS MUST BE NUMBERS */
-extern char e_perm[]; /* #-1 PERMISSION DENIED */
-extern char e_atrperm[]; /* #-1 NO PERMISSION TO GET ATTRIBUTE */
-extern char e_match[]; /* #-1 NO MATCH */
-extern char e_notvis[]; /* #-1 NO SUCH OBJECT VISIBLE */
-extern char e_disabled[]; /* #-1 FUNCTION DISABLED */
-extern char e_range[]; /* #-1 OUT OF RANGE */
+extern char e_int[]; /* #-1 ARGUMENT MUST BE INTEGER */
+extern char e_ints[]; /* #-1 ARGUMENTS MUST BE INTEGERS */
+extern char e_uint[]; /* #-1 ARGUMENT MUST BE POSITIVE INTEGER */
+extern char e_uints[]; /* #-1 ARGUMENTS MUST BE POSITIVE INTEGERS */
+extern char e_num[]; /* #-1 ARGUMENT MUST BE NUMBER */
+extern char e_nums[]; /* #-1 ARGUMENTS MUST BE NUMBERS */
+extern char e_perm[]; /* #-1 PERMISSION DENIED */
+extern char e_atrperm[]; /* #-1 NO PERMISSION TO GET ATTRIBUTE */
+extern char e_match[]; /* #-1 NO MATCH */
+extern char e_notvis[]; /* #-1 NO SUCH OBJECT VISIBLE */
+extern char e_disabled[]; /* #-1 FUNCTION DISABLED */
+extern char e_range[]; /* #-1 OUT OF RANGE */
/* The following routines all take strings as arguments, and return
* data of the appropriate types.
/* process_expression() evaluates expressions. What a concept. */
int process_expression(char *buff, char **bp, char const **str,
- dbref executor, dbref caller, dbref enactor,
- int eflags, int tflags, PE_Info * pe_info);
+ dbref executor, dbref caller, dbref enactor,
+ int eflags, int tflags, PE_Info * pe_info);
/* buff is a pointer to a BUFFER_LEN string to contain the expression
* result. *bp is the point in buff at which the result should be written.
#define PE_DEFAULT (PE_COMPRESS_SPACES | PE_STRIP_BRACES | \
PE_DOLLAR | PE_EVALUATE | PE_FUNCTION_CHECK)
#define PE_UDEFAULT (PE_COMPRESS_SPACES | PE_STRIP_BRACES | \
- PE_EVALUATE | PE_FUNCTION_CHECK)
+ PE_EVALUATE | PE_FUNCTION_CHECK)
/* PE_COMPRESS_SPACES strips leading and trailing spaces, and reduces sets
* of internal spaces to one space.
extern void start_cpu_timer(void);
extern void reset_cpu_timer(void);
-#endif /* !_PARSE_H_ */
+#endif /* !_PARSE_H_ */
#define PCRE_ERROR_NOMEMORY (-6)
#define PCRE_ERROR_NOSUBSTRING (-7)
#define PCRE_ERROR_MATCHLIMIT (-8)
-#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
+#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
#define PCRE_ERROR_BADUTF8 (-10)
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
#define PCRE_ERROR_PARTIAL (-12)
#define PCRE_INFO_CAPTURECOUNT 2
#define PCRE_INFO_BACKREFMAX 3
#define PCRE_INFO_FIRSTBYTE 4
-#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
+#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
#define PCRE_INFO_FIRSTTABLE 5
#define PCRE_INFO_LASTLITERAL 6
#define PCRE_INFO_NAMEENTRYSIZE 7
/* Types */
- struct real_pcre; /* declaration; the definition is private */
+ struct real_pcre; /* declaration; the definition is private */
typedef struct real_pcre pcre;
/* The structure for passing additional data to pcre_exec(). This is defined in
such as way as to be extensible. */
typedef struct pcre_extra {
- unsigned long int flags; /* Bits for which fields are set */
- void *study_data; /* Opaque data from pcre_study() */
- unsigned long int match_limit; /* Maximum number of calls to match() */
- void *callout_data; /* Data passed back in callouts */
- const unsigned char *tables; /* Pointer to character tables */
+ unsigned long int flags; /* Bits for which fields are set */
+ void *study_data; /* Opaque data from pcre_study() */
+ unsigned long int match_limit; /* Maximum number of calls to match() */
+ void *callout_data; /* Data passed back in callouts */
+ const unsigned char *tables; /* Pointer to character tables */
} pcre_extra;
/* The structure for passing out data via the pcre_callout_function. We use a
without modification. */
typedef struct pcre_callout_block {
- int version; /* Identifies version of block */
+ int version; /* Identifies version of block */
/* ------------------------ Version 0 ------------------------------- */
- int callout_number; /* Number compiled into pattern */
- int *offset_vector; /* The offset vector */
- const char *subject; /* The subject being matched */
- int subject_length; /* The length of the subject */
- int start_match; /* Offset to start of this match attempt */
- int current_position; /* Where we currently are in the subject */
- int capture_top; /* Max current capture */
- int capture_last; /* Most recently closed capture */
- void *callout_data; /* Data passed in with the call */
+ int callout_number; /* Number compiled into pattern */
+ int *offset_vector; /* The offset vector */
+ const char *subject; /* The subject being matched */
+ int subject_length; /* The length of the subject */
+ int start_match; /* Offset to start of this match attempt */
+ int current_position; /* Where we currently are in the subject */
+ int capture_top; /* Max current capture */
+ int capture_last; /* Most recently closed capture */
+ void *callout_data; /* Data passed in with the call */
/* ------------------- Added for Version 1 -------------------------- */
- int pattern_position; /* Offset to next item in the pattern */
- int next_item_length; /* Length of next item in the pattern */
+ int pattern_position; /* Offset to next item in the pattern */
+ int next_item_length; /* Length of next item in the pattern */
/* ------------------------------------------------------------------ */
} pcre_callout_block;
/* Exported PCRE functions */
extern pcre *pcre_compile(const char *, int, const char **,
- int *, const unsigned char *);
+ int *, const unsigned char *);
extern int pcre_copy_substring(const char *, int *, int, int, char *, int);
extern int pcre_exec(const pcre *, const pcre_extra *,
- const char *, int, int, int, int *, int);
+ const char *, int, int, int, int *, int);
extern const unsigned char *pcre_maketables(void);
extern pcre_extra *pcre_study(const pcre *, int, const char **);
extern int pcre_fullinfo(const pcre * argument_re,
- const pcre_extra * extra_data, int what,
- void *where);
+ const pcre_extra * extra_data, int what,
+ void *where);
extern int pcre_get_stringnumber(const pcre * code, const char *stringname);
extern int
pcre_copy_named_substring(const pcre * code, const char *subject,
- int *ovector, int stringcount,
- const char *stringname, char *buffer, int size);
+ int *ovector, int stringcount,
+ const char *stringname, char *buffer, int size);
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
-#endif /* End of pcre.h */
+#endif /* End of pcre.h */
* a string of restrictions into a bitmask.
*/
struct priv_info {
- const char *name; /**< Name of the privilege */
- char letter; /**< One-letter abbreviation */
- long int bits_to_set; /**< Bitflags required to set this privilege */
- long int bits_to_show; /**< Bitflags required to see this privilege */
+ const char *name; /**< Name of the privilege */
+ char letter; /**< One-letter abbreviation */
+ long int bits_to_set; /**< Bitflags required to set this privilege */
+ long int bits_to_show; /**< Bitflags required to see this privilege */
};
#define PrivName(x) ((x)->name)
extern int string_to_privs(PRIV *table, const char *str, long int origprivs);
extern int list_to_privs(PRIV *table, const char *str, long int origprivs);
extern int string_to_privsets(PRIV *table, const char *str, int *setprivs,
- int *clrprivs);
+ int *clrprivs);
extern int letter_to_privs(PRIV *table, const char *str, long int origprivs);
extern const char *privs_to_string(PRIV *table, int privs);
extern const char *privs_to_letters(PRIV *table, int privs);
-#endif /* __PRIVTAB_H */
+#endif /* __PRIVTAB_H */
* data is looked up by the best matching prefix of the given key.
*/
typedef struct ptab {
- int state; /**< Internal table state */
- int len; /**< Table size */
- int maxlen; /**< Maximum table size */
- int current; /**< Internal table state */
- struct ptab_entry **tab; /**< Pointer to array of entries */
+ int state; /**< Internal table state */
+ int len; /**< Table size */
+ int maxlen; /**< Maximum table size */
+ int current; /**< Internal table state */
+ struct ptab_entry **tab; /**< Pointer to array of entries */
} PTAB;
#define ptab_firstentry(x) ptab_firstentry_new(x,NULL)
#define ptab_nextentry(x) ptab_nextentry_new(x,NULL)
-#endif /* PTAB_H */
+#endif /* PTAB_H */
int safe_tag(char const *a_tag, char *buf, char **bp);
int safe_tag_cancel(char const *a_tag, char *buf, char **bp);
int safe_tag_wrap(char const *a_tag, char const *params,
- char const *data, char *buf, char **bp, dbref player);
+ char const *data, char *buf, char **bp, dbref player);
/* Please STAY SANE when modifying.
* Making this something like 'x' and 'y' is a BAD IDEA
/* Start & Cancel raw mud text */
/* Use this for when we go into pueblo displaying shit */
#define PUEBLO_CMT(buf,bp) safe_str("</XCH_MUDTEXT>", buf, bp); \
- safe_str("<IMG XCH_MODE=HTML>", buf, bp);
+ safe_str("<IMG XCH_MODE=HTML>", buf, bp);
/* Use this when we go back to normal shit */
#define PUEBLO_SMT(buf, bp) safe_str("<IMG XCH_MODE=TEXT>", buf, bp);
/** An shs digest.
*/
typedef struct {
- LONG digest[5]; /**< message digest */
- LONG countLo; /**< 64-bit bit count, low half */
- LONG countHi; /**< 64-bit bit count, high half */
- LONG data[16]; /**< SHS data buffer */
- BYTE reverse_wanted; /**< true to reverse (little_endian) false to not */
+ LONG digest[5]; /**< message digest */
+ LONG countLo; /**< 64-bit bit count, low half */
+ LONG countHi; /**< 64-bit bit count, high half */
+ LONG data[16]; /**< SHS data buffer */
+ BYTE reverse_wanted; /**< true to reverse (little_endian) false to not */
} SHS_INFO;
void shsInit(SHS_INFO *shsInfo);
* This is a node in a red/black binary strtree.
*/
struct strnode {
- StrNode *left; /**< Pointer to left child */
- StrNode *right; /**< Pointer to right child */
- unsigned char info; /**< Red/black and other internal state */
- char string[BUFFER_LEN]; /**< Node label (value) */
+ StrNode *left; /**< Pointer to left child */
+ StrNode *right; /**< Pointer to right child */
+ unsigned char info; /**< Red/black and other internal state */
+ char string[BUFFER_LEN]; /**< Node label (value) */
};
typedef struct strtree StrTree;
* A red/black binary tree of strings.
*/
struct strtree {
- StrNode *root; /**< Pointer to root node */
- size_t count; /**< Number of nodes in the tree */
- size_t mem; /**< Memory used by the tree */
+ StrNode *root; /**< Pointer to root node */
+ size_t count; /**< Number of nodes in the tree */
+ size_t mem; /**< Memory used by the tree */
};
void st_init(StrTree *root);
extmail.c filecopy.c flaglocal.c flags.c funcrypt.c function.c \
fundb.c fundiv.c funlist.c funlocal.c funmath.c funmisc.c funstr.c funtime.c \
funufun.c game.c help.c htab.c ident.c local.c lock.c log.c look.c \
- malias.c match.c memcheck.c move.c mycrypt.c mymalloc.c mysocket.c \
+ malias.c match.c memcheck.c move.c mushlua.c mushlua_wrappers.c mycrypt.c mymalloc.c mysocket.c \
myssl.c notify.c parse.c pcre.c player.c plyrlist.c \
predicat.c privtab.c prog.o ptab.c rob.c rplog.c services.c set.c shs.c \
sig.c speech.c sql.c strdup.c strtree.c strutil.c tables.c timer.c unparse.c \
utils.c version.c warnings.c wild.c wiz.c
-# Add LUA files
-C_FILES+= mushlua.c mushlua_wrappers.c
H_FILES = ../config.h ../confmagic.h ../hdrs/ansi.h ../hdrs/atr_tab.h \
../hdrs/attrib.h ../hdrs/boolexp.h ../hdrs/bufferq.h ../hdrs/case.h \
../hdrs/function.h ../hdrs/game.h ../hdrs/getpgsiz.h ../hdrs/help.h \
../hdrs/htab.h ../hdrs/htab.h ../hdrs/ident.h ../hdrs/lock.h \
../hdrs/log.h ../hdrs/log.h ../hdrs/malias.h ../hdrs/match.h \
- ../hdrs/mushdb.h ../hdrs/mushtype.h \
+ ../hdrs/mushdb.h ../hdrs/mushlua.h ../hdrs/mushtype.h \
../hdrs/mymalloc.h ../hdrs/mysocket.h ../hdrs/myssl.h \
../hdrs/parse.h ../hdrs/pcre.h ../hdrs/privtab.h ../hdrs/ptab.h \
../hdrs/strtree.h ../hdrs/version.h ../options.h ../hdrs/division.h ../hdrs/cron.h
-H_FILES += ../hdrs/mushlua.h
# .o versions of above - these are used in the build
COMMON_O_FILES=access.o atr_tab.o attrib.o boolexp.o bufferq.o \
extmail.o filecopy.o flaglocal.o flags.o funcrypt.o function.o \
fundb.o funlist.o fundiv.o funlocal.o funmath.o funmisc.o funstr.o funtime.o \
funufun.o game.o help.o htab.o ident.o local.o lock.o log.o look.o \
- malias.o match.o memcheck.o move.o mycrypt.o mymalloc.o mysocket.o \
- myssl.o notify.o parse.o pcre.o player.o plyrlist.o predicat.o privtab.o \
- prog.o ptab.o rob.o rplog.o services.o set.o shs.o sig.o speech.o sql.o \
- strdup.o strtree.o strutil.o tables.o timer.o unparse.o utils.o version.o warnings.o \
+ malias.o match.o memcheck.o move.o mushlua.o mushlua_wrappers.o mycrypt.o mymalloc.o \
+ mysocket.o myssl.o notify.o parse.o pcre.o player.o plyrlist.o predicat.o privtab.o \
+ prog.o ptab.o rob.o rplog.o services.o set.o shs.o sig.o speech.o sql.o strdup.o \
+ strtree.o strutil.o tables.o timer.o unparse.o utils.o version.o warnings.o \
wild.o wiz.o
-COMMON_O_FILES+= mushlua.o mushlua_wrappers.o
+
O_FILES=$(COMMON_O_FILES) bsd.o
CONSOLE_O_FILES=$(COMMON_O_FILES) console.o
echo "********************************************************"; \
fi
+mushlua_wrappers.c: mushlua.i
+ @echo "Generating mushlua_wrappers.c"
+ -swig -o mushlua_wrappers.c -lua mushlua.i
+
local.c: local.dst
@if [ ! -f local.c ]; then \
cp local.dst local.c; \
* This structure is used to build a table of access control flags.
*/
struct a_acsflag {
- const char *name; /**< Name of the access flag */
- int toggle; /**< Is this a negatable flag? */
- int flag; /**< Bitmask of the flag */
+ const char *name; /**< Name of the access flag */
+ int toggle; /**< Is this a negatable flag? */
+ int flag; /**< Bitmask of the flag */
};
static acsflag acslist[] = {
{"connect", 1, ACS_CONNECT},
static int
add_access_node(const char *host, const dbref who, const int can,
- const int cant, const char *comment)
+ const int cant, const char *comment)
{
struct access *end;
struct access *tmp;
while (fgets(buf, BUFFER_LEN, fp)) {
/* Strip end of line if it's \r\n or \n */
if ((p = strchr(buf, '\r')))
- *p = '\0';
+ *p = '\0';
else if ((p = strchr(buf, '\n')))
- *p = '\0';
+ *p = '\0';
/* Find beginning of line; ignore blank lines */
p = buf;
if (*p && isspace((unsigned char) *p))
- p++;
+ p++;
if (*p && *p != '#') {
- can = cant = 0;
- comment = NULL;
- /* Is this the @sitelock entry? */
- if (!strncasecmp(p, "@sitelock", 9)) {
- if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, ""))
- do_log(LT_ERR, GOD, GOD, T("Failed to add sitelock node!"));
- } else {
- if ((comment = strchr(p, '#'))) {
- *comment++ = '\0';
- while (*comment && isspace((unsigned char) *comment))
- comment++;
- }
- /* Move past the host name */
- while (*p && !isspace((unsigned char) *p))
- p++;
- if (*p)
- *p++ = '\0';
- if (!parse_access_options(p, &who, &can, &cant, NOTHING))
- /* Nothing listed, so assume we can't do anything! */
- cant = ACS_DEFAULT;
- if (!add_access_node(buf, who, can, cant, comment))
- do_log(LT_ERR, GOD, GOD, T("Failed to add access node!"));
- }
+ can = cant = 0;
+ comment = NULL;
+ /* Is this the @sitelock entry? */
+ if (!strncasecmp(p, "@sitelock", 9)) {
+ if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, ""))
+ do_log(LT_ERR, GOD, GOD, T("Failed to add sitelock node!"));
+ } else {
+ if ((comment = strchr(p, '#'))) {
+ *comment++ = '\0';
+ while (*comment && isspace((unsigned char) *comment))
+ comment++;
+ }
+ /* Move past the host name */
+ while (*p && !isspace((unsigned char) *p))
+ p++;
+ if (*p)
+ *p++ = '\0';
+ if (!parse_access_options(p, &who, &can, &cant, NOTHING))
+ /* Nothing listed, so assume we can't do anything! */
+ cant = ACS_DEFAULT;
+ if (!add_access_node(buf, who, can, cant, comment))
+ do_log(LT_ERR, GOD, GOD, T("Failed to add access node!"));
+ }
}
}
retval = 1;
} else {
for (ap = access_top; ap; ap = ap->next) {
if (strcmp(ap->host, "@sitelock") == 0) {
- fprintf(fp, "@sitelock\n");
- continue;
+ fprintf(fp, "@sitelock\n");
+ continue;
}
fprintf(fp, "%s %d ", ap->host, ap->who);
switch (ap->can) {
case ACS_SITELOCK:
- break;
+ break;
case ACS_DEFAULT:
- fprintf(fp, "DEFAULT ");
- break;
+ fprintf(fp, "DEFAULT ");
+ break;
default:
- for (c = acslist; c->name; c++)
- if (ap->can & c->flag)
- fprintf(fp, "%s ", c->name);
- break;
+ for (c = acslist; c->name; c++)
+ if (ap->can & c->flag)
+ fprintf(fp, "%s ", c->name);
+ break;
}
switch (ap->cant) {
case ACS_DEFAULT:
- fprintf(fp, "NONE ");
- break;
+ fprintf(fp, "NONE ");
+ break;
default:
- for (c = acslist; c->name; c++)
- if (c->toggle && (ap->cant & c->flag))
- fprintf(fp, "!%s ", c->name);
- break;
+ for (c = acslist; c->name; c++)
+ if (c->toggle && (ap->cant & c->flag))
+ fprintf(fp, "!%s ", c->name);
+ break;
}
if (ap->comment && *ap->comment)
- fprintf(fp, "# %s\n", ap->comment);
+ fprintf(fp, "# %s\n", ap->comment);
else
- fprintf(fp, "\n");
+ fprintf(fp, "\n");
}
fclose(fp);
#ifdef WIN32
for (ap = access_top; ap; ap = ap->next) {
if (!(ap->can & ACS_SITELOCK)
- && ((ap->can & ACS_REGEXP)
- ? (regexp_match_case(ap->host, hname, 0)
- || (p && regexp_match_case(ap->host, p, 0))
+ && ((ap->can & ACS_REGEXP)
+ ? (regexp_match_case(ap->host, hname, 0)
+ || (p && regexp_match_case(ap->host, p, 0))
#ifdef FORCE_IPV4
- || regexp_match_case(ip4_to_ip6(ap->host), hname, 0)
- || (p && regexp_match_case(ip4_to_ip6(ap->host), p, 0))
+ || regexp_match_case(ip4_to_ip6(ap->host), hname, 0)
+ || (p && regexp_match_case(ip4_to_ip6(ap->host), p, 0))
#endif
- )
- : (quick_wild(ap->host, hname)
- || (p && quick_wild(ap->host, p))
+ )
+ : (quick_wild(ap->host, hname)
+ || (p && quick_wild(ap->host, p))
#ifdef FORCE_IPV4
- || quick_wild(ip4_to_ip6(ap->host), hname)
- || (p && quick_wild(ip4_to_ip6(ap->host), p))
+ || quick_wild(ip4_to_ip6(ap->host), hname)
+ || (p && quick_wild(ip4_to_ip6(ap->host), p))
#endif
- ))
- && (ap->who == AMBIGUOUS || ap->who == who)) {
+ ))
+ && (ap->who == AMBIGUOUS || ap->who == who)) {
/* Got one */
if (flag & ACS_CONNECT) {
- if ((ap->cant & ACS_GOD) && God(who)) /* God can't connect from here */
- return 0;
- else if ((ap->cant & ACS_DIRECTOR) && Director(who))
- /* Directors can't connect from here */
- return 0;
- else if ((ap->cant & ACS_ADMIN) && Admin(who))
- /* Admins can't connect from here */
- return 0;
+ if ((ap->cant & ACS_GOD) && God(who)) /* God can't connect from here */
+ return 0;
+ else if ((ap->cant & ACS_DIRECTOR) && Director(who))
+ /* Directors can't connect from here */
+ return 0;
+ else if ((ap->cant & ACS_ADMIN) && Admin(who))
+ /* Admins can't connect from here */
+ return 0;
}
if (ap->cant && ((ap->cant & flag) == flag))
- return 0;
+ return 0;
if (ap->can && (ap->can & flag))
- return 1;
+ return 1;
/* Hmm. We don't know if we can or not, so continue */
break;
for (ap = access_top; ap; ap = ap->next) {
(*rulenum)++;
if (!(ap->can & ACS_SITELOCK)
- && ((ap->can & ACS_REGEXP)
- ? (regexp_match_case(ap->host, hname, 0)
- || (p && regexp_match_case(ap->host, p, 0))
+ && ((ap->can & ACS_REGEXP)
+ ? (regexp_match_case(ap->host, hname, 0)
+ || (p && regexp_match_case(ap->host, p, 0))
#ifdef FORCE_IPV4
- || regexp_match_case(ip4_to_ip6(ap->host), hname, 0)
- || (p && regexp_match_case(ip4_to_ip6(ap->host), p, 0))
+ || regexp_match_case(ip4_to_ip6(ap->host), hname, 0)
+ || (p && regexp_match_case(ip4_to_ip6(ap->host), p, 0))
#endif
- )
- : (quick_wild(ap->host, hname)
- || (p && quick_wild(ap->host, p))
+ )
+ : (quick_wild(ap->host, hname)
+ || (p && quick_wild(ap->host, p))
#ifdef FORCE_IPV4
- || quick_wild(ip4_to_ip6(ap->host), hname)
- || (p && quick_wild(ip4_to_ip6(ap->host), p))
+ || quick_wild(ip4_to_ip6(ap->host), hname)
+ || (p && quick_wild(ip4_to_ip6(ap->host), p))
#endif
- ))
- && (ap->who == AMBIGUOUS || ap->who == who)) {
+ ))
+ && (ap->who == AMBIGUOUS || ap->who == who)) {
/* Got one */
return ap;
}
*/
int
format_access(struct access *ap, int rulenum,
- dbref who __attribute__ ((__unused__)), char *buff, char **bp)
+ dbref who __attribute__ ((__unused__)), char *buff, char **bp)
{
if (ap) {
safe_format(buff, bp, T("Matched line %d: %s %s"), rulenum, ap->host,
- (ap->can & ACS_REGEXP) ? "(regexp)" : "");
+ (ap->can & ACS_REGEXP) ? "(regexp)" : "");
safe_chr('\n', buff, bp);
safe_format(buff, bp, T("Comment: %s"), ap->comment);
safe_chr('\n', buff, bp);
*/
int
add_access_sitelock(dbref player, const char *host, dbref who, int can,
- int cant)
+ int cant)
{
struct access *end;
struct access *tmp;
tmp->cant = cant;
strcpy(tmp->host, host);
sprintf(tmp->comment, "By %s(#%d) on %s", Name(player), player,
- show_time(mudtime, 0));
+ show_time(mudtime, 0));
tmp->next = NULL;
if (!access_top) {
if (end->can != ACS_SITELOCK) {
/* We're at the end and there's no sitelock marker. Add one */
if (!add_access_node("@sitelock", AMBIGUOUS, ACS_SITELOCK, 0, ""))
- return 0;
+ return 0;
end = end->next;
} else {
/* We're in the middle, so be sure we keep the list linked */
n++;
mush_free(ap, "struct_access");
if (prev)
- prev->next = next;
+ prev->next = next;
else
- access_top = next;
+ access_top = next;
} else {
prev = ap;
}
if (ap->can != ACS_SITELOCK) {
bp = flaglist;
for (c = acslist; c->name; c++) {
- if (c->flag == ACS_DEFAULT)
- continue;
- if (ap->can & c->flag) {
- safe_chr(' ', flaglist, &bp);
- safe_str(c->name, flaglist, &bp);
- }
- if (c->toggle && (ap->cant & c->flag)) {
- safe_chr(' ', flaglist, &bp);
- safe_chr('!', flaglist, &bp);
- safe_str(c->name, flaglist, &bp);
- }
+ if (c->flag == ACS_DEFAULT)
+ continue;
+ if (ap->can & c->flag) {
+ safe_chr(' ', flaglist, &bp);
+ safe_str(c->name, flaglist, &bp);
+ }
+ if (c->toggle && (ap->cant & c->flag)) {
+ safe_chr(' ', flaglist, &bp);
+ safe_chr('!', flaglist, &bp);
+ safe_str(c->name, flaglist, &bp);
+ }
}
*bp = '\0';
notify_format(player,
- "%3d SITE: %-20s DBREF: %-6s FLAGS:%s", rulenum,
- ap->host, unparse_dbref(ap->who), flaglist);
+ "%3d SITE: %-20s DBREF: %-6s FLAGS:%s", rulenum,
+ ap->host, unparse_dbref(ap->who), flaglist);
notify_format(player, " COMMENT: %s", ap->comment);
} else {
notify(player,
- T
- ("---- @sitelock will add sites immediately below this line ----"));
+ T
+ ("---- @sitelock will add sites immediately below this line ----"));
}
}
*/
int
parse_access_options(const char *opts, dbref *who, int *can, int *cant,
- dbref player)
+ dbref player)
{
char myopts[BUFFER_LEN];
char *p;
while ((w = split_token(&p, ' '))) {
found = 0;
- if (first && who) { /* Check for a character */
+ if (first && who) { /* Check for a character */
first = 0;
- if (is_integer(w)) { /* We have a dbref */
- *who = parse_integer(w);
- if (*who != AMBIGUOUS && !GoodObject(*who))
- *who = AMBIGUOUS;
- continue;
+ if (is_integer(w)) { /* We have a dbref */
+ *who = parse_integer(w);
+ if (*who != AMBIGUOUS && !GoodObject(*who))
+ *who = AMBIGUOUS;
+ continue;
}
}
/* Found a negated warning */
w++;
for (c = acslist; c->name; c++) {
- if (c->toggle && !strncasecmp(w, c->name, strlen(c->name))) {
- *cant |= c->flag;
- found++;
- }
+ if (c->toggle && !strncasecmp(w, c->name, strlen(c->name))) {
+ *cant |= c->flag;
+ found++;
+ }
}
} else {
/* None is special */
if (!strncasecmp(w, "NONE", 4)) {
- *cant = ACS_DEFAULT;
- found++;
+ *cant = ACS_DEFAULT;
+ found++;
} else {
- for (c = acslist; c->name; c++) {
- if (!strncasecmp(w, c->name, strlen(c->name))) {
- *can |= c->flag;
- found++;
- }
- }
+ for (c = acslist; c->name; c++) {
+ if (!strncasecmp(w, c->name, strlen(c->name))) {
+ *can |= c->flag;
+ found++;
+ }
+ }
}
}
/* At this point, we haven't matched any warnings. */
if (!found) {
if (GoodObject(player))
- notify_format(player, T("Unknown access option: %s"), w);
+ notify_format(player, T("Unknown access option: %s"), w);
else
- do_log(LT_ERR, GOD, GOD, T("Unknown access flag: %s"), w);
+ do_log(LT_ERR, GOD, GOD, T("Unknown access flag: %s"), w);
} else {
totalfound += found;
}
extern char **environ;
extern int errno;
-char *Name; /* name of this program for error messages */
+char *Name; /* name of this program for error messages */
char msg[2048];
int
long ct;
int opt;
- Name = argv[0]; /* save name of program for error messages */
- sin.sin_port = htons((u_short) PORT); /* Assume PORT */
+ Name = argv[0]; /* save name of program for error messages */
+ sin.sin_port = htons((u_short) PORT); /* Assume PORT */
argc--, argv++;
- if (argc > 0) { /* unless specified on command-line */
+ if (argc > 0) { /* unless specified on command-line */
sin.sin_port = atoi(*argv);
sin.sin_port = htons((u_short) sin.sin_port);
}
strcat(msg, tmp);
}
msg[2048] = '\0';
- signal(SIGHUP, SIG_IGN); /* get socket, bind port to it */
+ signal(SIGHUP, SIG_IGN); /* get socket, bind port to it */
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
perror("announce: socket");;
}
if ((foo = fork()) != 0) {
fprintf(stderr, "announce: pid %d running on port %d\n", foo,
- ntohs((u_short) sin.sin_port));
+ ntohs((u_short) sin.sin_port));
exit(0);
} else {
setpriority(PRIO_PROCESS, getpid(), 10);
}
- if (listen(s, 1) < 0) { /* start listening on port */
+ if (listen(s, 1) < 0) { /* start listening on port */
perror("announce: listen");
exit(1);
}
foo = sizeof sin;
- for (;;) { /* loop forever, accepting requests & printing msg */
+ for (;;) { /* loop forever, accepting requests & printing msg */
ns = accept(s, &sin, &foo);
if (ns < 0) {
perror("announce: accept");
sleep(5);
close(ns);
}
-} /* main */
+} /* main */
/** An alias for an attribute.
*/
typedef struct atr_alias {
- const char *alias; /**< The alias. */
- const char *realname; /**< The attribute's canonical name. */
+ const char *alias; /**< The alias. */
+ const char *realname; /**< The attribute's canonical name. */
} ATRALIAS;
if (SW_ISSET(swi, SWITCH_RETROACTIVE) && !SW_ISSET(swi, SWITCH_DEFAULTS)) {
for (i = 0; i < db_top; i++) {
if ((ap2 = atr_get_noparent(i, name))) {
- free_boolexp(SW_ISSET(swi, SWITCH_WRITE) ? AL_WLock(ap2) : AL_RLock(ap2));
- if(SW_ISSET(swi, SWITCH_WRITE))
- AL_WLock(ap2) = dup_bool(AL_WLock(ap));
- else
- AL_RLock(ap2) = dup_bool(AL_RLock(ap));
+ free_boolexp(SW_ISSET(swi, SWITCH_WRITE) ? AL_WLock(ap2) : AL_RLock(ap2));
+ if(SW_ISSET(swi, SWITCH_WRITE))
+ AL_WLock(ap2) = dup_bool(AL_WLock(ap));
+ else
+ AL_RLock(ap2) = dup_bool(AL_RLock(ap));
}
}
}
if (retroactive) {
for (i = 0; i < db_top; i++) {
if ((ap2 = atr_get_noparent(i, name))) {
- AL_FLAGS(ap2) = flags;
- AL_CREATOR(ap2) = player;
+ AL_FLAGS(ap2) = flags;
+ AL_CREATOR(ap2) = player;
}
}
}
notify_format(player, T("%s -- Attribute permissions now: %s"), name,
- privs_to_string(attr_privs_view, flags));
+ privs_to_string(attr_privs_view, flags));
}
ap = (ATTR *) ptab_find_exact(&ptab_attrib, newname);
if (ap) {
notify_format(player,
- T("The name %s is already used in the attribute table."),
- newname);
+ T("The name %s is already used in the attribute table."),
+ newname);
return;
}
/* Is the old name a real attribute? */
ptab_insert(&ptab_attrib, newname, ap);
ptab_end_inserts(&ptab_attrib);
notify_format(player,
- T("Renamed %s to %s in attribute table."), old, newname);
+ T("Renamed %s to %s in attribute table."), old, newname);
return;
}
}
notify_format(player, "Attribute: %s", ap == catchall ? "Default Attribute" : AL_NAME(ap));
notify_format(player,
- " Flags: %s", privs_to_string(attr_privs_view,
- AL_FLAGS(ap)));
+ " Flags: %s", privs_to_string(attr_privs_view,
+ AL_FLAGS(ap)));
notify_format(player, " Creator: %s", unparse_dbref(AL_CREATOR(ap)));
/* Now Locks */
if(!(AL_RLock(ap) == TRUE_BOOLEXP))
/*
#define Cannot_Write_This_Attr(p,a,o,s,n) (!God(p) && AF_Internal(a) || \
- (s && AF_Safe(a)) || \
- ( ((AL_FLAGS(a) & AF_PRIVILEGE) && !(Prived(p) || (Inherit_Powers(p) && Prived(Owner(p)) ))) || \
- !( (controls(p, o) && ( (Owner(o) == Owner(lo)) || controls(p,lo)) && catchall && AL_WLock(a) == TRUE_BOOLEXP ? \
- AL_CREATOR(catchall) : AL_CREATOR(a)))) || ((AL_WLock(a) == TRUE_BOOLEXP && (!n || !catchall || \
- (AL_WLock(catchall) == TRUE_BOOLEXP))) && controls(p,o) ) || ((AL_WLock(a) != TRUE_BOOLEXP ? \
- eval_boolexp(p, AL_WLock(a), o, NULL) : (n && catchall && AL_WLock(catchall) != TRUE_BOOLEXP && \
- eval_boolexp(p, AL_WLock(catchall), o, NULL))) ))
- */
+ (s && AF_Safe(a)) || \
+ ( ((AL_FLAGS(a) & AF_PRIVILEGE) && !(Prived(p) || (Inherit_Powers(p) && Prived(Owner(p)) ))) || \
+ !( (controls(p, o) && ( (Owner(o) == Owner(lo)) || controls(p,lo)) && catchall && AL_WLock(a) == TRUE_BOOLEXP ? \
+ AL_CREATOR(catchall) : AL_CREATOR(a)))) || ((AL_WLock(a) == TRUE_BOOLEXP && (!n || !catchall || \
+ (AL_WLock(catchall) == TRUE_BOOLEXP))) && controls(p,o) ) || ((AL_WLock(a) != TRUE_BOOLEXP ? \
+ eval_boolexp(p, AL_WLock(a), o, NULL) : (n && catchall && AL_WLock(catchall) != TRUE_BOOLEXP && \
+ eval_boolexp(p, AL_WLock(catchall), o, NULL))) ))
+ */
/*
return 1;
if(AF_Mdark(attr) && !(Admin(player)
- || (Inherit_Powers(player) && Admin(Owner(player)))))
+ || (Inherit_Powers(player) && Admin(Owner(player)))))
return 1;
if(ns_chk && catchall && !controls(player, AL_CREATOR(catchall)) && AL_WLock(catchall) != TRUE_BOOLEXP &&
AL_NAME(atr) = missing_name;
set_default_flags(atr, flags, lock_owner, ns_chk);
if(lock_owner == NOTHING)
- lock_owner = AL_CREATOR(atr);
+ lock_owner = AL_CREATOR(atr);
num_new++;
}
if (Cannot_Write_This_Attr(player, atr, obj, 1, ns_chk, lock_owner)) {
*s++ = '\0';
if (type == '^' && !AF_Ahear(ptr)) {
if ((thing == player && !AF_Mhear(ptr))
- || (thing != player && AF_Mhear(ptr)))
- continue;
+ || (thing != player && AF_Mhear(ptr)))
+ continue;
}
if (AF_Regexp(ptr)) {
continue;
*s++ = '\0';
if (type == '^' && !AF_Ahear(ptr)) {
- if ((thing == player && !AF_Mhear(ptr))
- || (thing != player && AF_Mhear(ptr)))
- continue;
+ if ((thing == player && !AF_Mhear(ptr))
+ || (thing != player && AF_Mhear(ptr)))
+ continue;
}
if (AF_Regexp(ptr)) {
/* Old alias - we're allowed to change to a different case */
strcpy(tbuf1, atr_value(old));
if (s && !*s) {
- notify_format(player, T("'%s' is not a valid alias."), s);
- return -1;
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ return -1;
}
if (s && strcasecmp(s, tbuf1)) {
- int opae_res = ok_player_alias(s, player, thing);
- switch (opae_res) {
- case OPAE_INVALID:
- notify_format(player, T("'%s' is not a valid alias."), s);
- break;
- case OPAE_TOOMANY:
- notify_format(player, T("'%s' contains too many aliases."), s);
- break;
- case OPAE_NULL:
- notify_format(player, T("Null aliases are not valid."));
- break;
- }
- if (opae_res != OPAE_SUCCESS)
- return -1;
+ int opae_res = ok_player_alias(s, player, thing);
+ switch (opae_res) {
+ case OPAE_INVALID:
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ break;
+ case OPAE_TOOMANY:
+ notify_format(player, T("'%s' contains too many aliases."), s);
+ break;
+ case OPAE_NULL:
+ notify_format(player, T("Null aliases are not valid."));
+ break;
+ }
+ if (opae_res != OPAE_SUCCESS)
+ return -1;
}
} else {
/* No old alias */
if (s && *s) {
- int opae_res = ok_player_alias(s, player, thing);
- switch (opae_res) {
- case OPAE_INVALID:
- notify_format(player, T("'%s' is not a valid alias."), s);
- break;
- case OPAE_TOOMANY:
- notify_format(player, T("'%s' contains too many aliases."), s);
- break;
- case OPAE_NULL:
- notify_format(player, T("Null aliases are not valid."));
- break;
- }
- if (opae_res != OPAE_SUCCESS)
- return -1;
+ int opae_res = ok_player_alias(s, player, thing);
+ switch (opae_res) {
+ case OPAE_INVALID:
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ break;
+ case OPAE_TOOMANY:
+ notify_format(player, T("'%s' contains too many aliases."), s);
+ break;
+ case OPAE_NULL:
+ notify_format(player, T("Null aliases are not valid."));
+ break;
+ }
+ if (opae_res != OPAE_SUCCESS)
+ return -1;
}
}
} else if (s && *s && (!strcmp(name, "FORWARDLIST")
- || !strcmp(name, "MAILFORWARDLIST")
+ || !strcmp(name, "MAILFORWARDLIST")
|| !strcmp(name, "DEBUGFORWARDLIST"))) {
/* You can only set this to dbrefs of things you're allowed to
* forward to. If you get one wrong, we puke.
return -1;
}
if ((!strcmp(name, "FORWARDLIST") || !strcmp(name, "DEBUGFORWARDLIST"))
- && !Can_Forward(thing, fwd)) {
+ && !Can_Forward(thing, fwd)) {
notify_format(player, T("I don't think #%d wants to hear from %s."),
- fwd, Name(thing));
+ fwd, Name(thing));
return -1;
}
if (!strcmp(name, "MAILFORWARDLIST") && !Can_MailForward(thing, fwd)) {
- notify_format(player, T("I don't think #%d wants %s's mail."), fwd,
- Name(thing));
+ notify_format(player, T("I don't think #%d wants %s's mail."), fwd,
+ Name(thing));
return -1;
}
}
: atr_clr(thing, name, player);
if (res == AE_SAFE) {
notify_format(player, T("Attribute %s is SAFE. Set it !SAFE to modify it."),
- name);
+ name);
return 0;
} else if (res == AE_BADNAME) {
notify(player, T("That's not a very good name for an attribute."));
if(!Admin(player)
&& (AF_Mdark(atr)
- || !(cansee
- || ((AF_Visual(atr)
- || ((AL_RLock(atr) != TRUE_BOOLEXP) && r_lock))
- && (!AF_Nearby(atr) || canlook))
- || (!visible && !Mistrust(player)
- && (Owner(AL_CREATOR(atr)) == Owner(player))))))
+ || !(cansee
+ || ((AF_Visual(atr)
+ || ((AL_RLock(atr) != TRUE_BOOLEXP) && r_lock))
+ && (!AF_Nearby(atr) || canlook))
+ || (!visible && !Mistrust(player)
+ && (Owner(AL_CREATOR(atr)) == Owner(player))))))
return 0;
/* If the attribute isn't on a branch, then that's also easy. */
eval_boolexp(dbref player /* The player trying to pass */ ,
boolexp b /* The boolexp */ ,
dbref target /* The object with the lock */,
- unsigned char * switches)
+ unsigned char * switches)
{
static int boolexp_recursion = 0;
boolexp_recursion--;
break;
case OP_TSWITCHES:
- if(switches) {
- SWITCH_VALUE *sw_val;
- r = 0;
+ if(switches) {
+ SWITCH_VALUE *sw_val;
+ r = 0;
for(sw_val = switch_list; sw_val->name != NULL; sw_val++)
- if(SW_ISSET(switches, sw_val->value)
- && !strcasecmp(sw_val->name, (char *) bytecode + arg)) {
- r = 1;
- break;
- }
- } else
- r = 1;
- break;
+ if(SW_ISSET(switches, sw_val->value)
+ && !strcasecmp(sw_val->name, (char *) bytecode + arg)) {
+ r = 1;
+ break;
+ }
+ } else
+ r = 1;
+ break;
case OP_TFLAG:
/* Note that both fields of a boolattr struct are upper-cased */
if (sees_flag(target, player, (char *) bytecode + arg))
}
break;
case OP_TDBREFLIST:
- {
- char *idstr, *curr, *orig;
- dbref mydb;
-
- r = 0;
- a = atr_get(target, (char *) bytecode + arg);
- if (!a)
- break;
-
- orig = safe_atr_value(a);
- idstr = trim_space_sep(orig, ' ');
-
- while ((curr = split_token(&idstr, ' ')) != NULL) {
- mydb = parse_objid(curr);
- if (mydb == player) {
- r = 1;
- break;
- }
- }
- free((Malloc_t) orig);
- }
- break;
+ {
+ char *idstr, *curr, *orig;
+ dbref mydb;
+
+ r = 0;
+ a = atr_get(target, (char *) bytecode + arg);
+ if (!a)
+ break;
+
+ orig = safe_atr_value(a);
+ idstr = trim_space_sep(orig, ' ');
+
+ while ((curr = split_token(&idstr, ' ')) != NULL) {
+ mydb = parse_objid(curr);
+ if (mydb == player) {
+ r = 1;
+ break;
+ }
+ }
+ free((Malloc_t) orig);
+ }
+ break;
default:
do_log(LT_ERR, 0, 0, "Bad boolexp opcode %d %d in object #%d",
op, arg, target);
safe_format(boolexp_buf, &buftop, "HOSTNAME^%s", bytecode + arg);
break;
case OP_TSWITCHES:
- safe_format(boolexp_buf, &buftop, "SWITCHES^%s", bytecode + arg);
- break;
+ safe_format(boolexp_buf, &buftop, "SWITCHES^%s", bytecode + arg);
+ break;
case OP_TDBREFLIST:
- safe_format(boolexp_buf, &buftop, "DBREFLIST^%s", bytecode + arg);
- break;
+ safe_format(boolexp_buf, &buftop, "DBREFLIST^%s", bytecode + arg);
+ break;
}
}
}
#define EWOULDBLOCK WSAEWOULDBLOCK
#define MAXHOSTNAMELEN 32
#define LC_MESSAGES 6
-#pragma warning( disable : 4761) /* disable warning re conversion */
-#else /* !WIN32 */
+#pragma warning( disable : 4761) /* disable warning re conversion */
+#else /* !WIN32 */
#ifdef I_SYS_FILE
#include <sys/file.h>
#endif
#ifdef I_SYS_STAT
#include <sys/stat.h>
#endif
-#endif /* !WIN32 */
+#endif /* !WIN32 */
#include <time.h>
#ifdef I_SYS_WAIT
#include <sys/wait.h>
#define FD_CLR(n,p) (*p &= ~(1<<(n)))
/** Check a bit in an fd_set */
#define FD_ISSET(n,p) (*p & (1<<(n)))
-#endif /* defines for BSD 4.2 */
+#endif /* defines for BSD 4.2 */
#ifdef HAS_GETRUSAGE
void rusage_stats(void);
#endif
-int que_next(void); /* from cque.c */
+int que_next(void); /* from cque.c */
-void dispatch(void); /* from timer.c */
-dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */
+void dispatch(void); /* from timer.c */
+dbref email_register_player(const char *name, const char *email, const char *host, const char *ip); /* from player.c */
static int extrafd;
-int shutdown_flag = 0; /**< Is it time to shut down? */
+int shutdown_flag = 0; /**< Is it time to shut down? */
#ifdef CHAT_SYSTEM
void chat_player_announce(dbref player, char *msg, int ungag);
#endif /* CHAT_SYSTEM */
static int login_number = 0;
static int under_limit = 1;
-char cf_motd_msg[BUFFER_LEN]; /**< The message of the day */
-char cf_downmotd_msg[BUFFER_LEN]; /**< The down message */
-char cf_fullmotd_msg[BUFFER_LEN]; /**< The 'mush full' message */
+char cf_motd_msg[BUFFER_LEN]; /**< The message of the day */
+char cf_downmotd_msg[BUFFER_LEN]; /**< The down message */
+char cf_fullmotd_msg[BUFFER_LEN]; /**< The 'mush full' message */
static char poll_msg[DOING_LEN];
-char confname[BUFFER_LEN]; /**< Name of the config file */
-char errlog[BUFFER_LEN]; /**< Name of the error log file */
+char confname[BUFFER_LEN]; /**< Name of the config file */
+char errlog[BUFFER_LEN]; /**< Name of the error log file */
/* Default Connection flags for certain clients
*/
/* Telnet codes */
#ifndef COMPILE_CONSOLE
-#define IAC 255 /**< interpret as command: */
-#define GOAHEAD 249 /**< Go Ahead command */
-#define NOP 241 /**< no operation */
-#define AYT 246 /**< are you there? */
-#define DONT 254 /**< you are not to use option */
-#define DO 253 /**< please, you use option */
-#define WONT 252 /**< I won't use option */
-#define WILL 251 /**< I will use option */
-#define SB 250 /**< interpret as subnegotiation */
-#define SE 240 /**< end sub negotiation */
-#define TN_SGA 3 /**< Suppress go-ahead */
-#define TN_LINEMODE 34 /**< Line mode */
-#define TN_NAWS 31 /**< Negotiate About Window Size */
-#define TN_TTYPE 24 /**< Ask for termial type information */
+#define IAC 255 /**< interpret as command: */
+#define GOAHEAD 249 /**< Go Ahead command */
+#define NOP 241 /**< no operation */
+#define AYT 246 /**< are you there? */
+#define DONT 254 /**< you are not to use option */
+#define DO 253 /**< please, you use option */
+#define WONT 252 /**< I won't use option */
+#define WILL 251 /**< I will use option */
+#define SB 250 /**< interpret as subnegotiation */
+#define SE 240 /**< end sub negotiation */
+#define TN_SGA 3 /**< Suppress go-ahead */
+#define TN_LINEMODE 34 /**< Line mode */
+#define TN_NAWS 31 /**< Negotiate About Window Size */
+#define TN_TTYPE 24 /**< Ask for termial type information */
static void test_telnet(DESC *d);
static void setup_telnet(DESC *d);
static int handle_telnet(DESC *d, unsigned char **q, unsigned char *qend);
#endif
-DESC *descriptor_list = NULL; /**< The linked list of descriptors */
+DESC *descriptor_list = NULL; /**< The linked list of descriptors */
#ifndef COMPILE_CONSOLE
static int sock;
#ifdef HAS_OPENSSL
static int sslsock = 0;
-SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */
+SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */
#endif
#ifdef WIN32
static WSADATA wsadata;
#endif
static int maxd = 0;
#endif /* COMPILE_CONSOLE */
-int restarting = 0; /**< Are we restarting the server after a reboot? */
+int restarting = 0; /**< Are we restarting the server after a reboot? */
static int ndescriptors = 0;
extern const unsigned char *tables;
#ifdef INFO_SLAVE
static fd_set info_pending;
static int info_slave;
-Pid_t info_slave_pid = -1; /**< Process id of the info_slave process */
-int info_slave_state = 0; /**< State of the info_slave process */
+Pid_t info_slave_pid = -1; /**< Process id of the info_slave process */
+int info_slave_state = 0; /**< State of the info_slave process */
static int info_query_spill, info_reap_spill;
static time_t info_queue_time = 0;
#endif
#endif
-sig_atomic_t signal_shutdown_flag = 0; /**< Have we caught a shutdown signal? */
-sig_atomic_t signal_dump_flag = 0; /**< Have we caught a dump signal? */
+sig_atomic_t signal_shutdown_flag = 0; /**< Have we caught a shutdown signal? */
+sig_atomic_t signal_dump_flag = 0; /**< Have we caught a dump signal? */
#ifdef HAS_GETRLIMIT
static void init_rlimit(void);
/** A block of cached text. */
typedef struct fblock {
- unsigned char *buff; /**< Pointer to the block as a string */
- size_t len; /**< Length of buff */
+ unsigned char *buff; /**< Pointer to the block as a string */
+ size_t len; /**< Length of buff */
} FBLOCK;
/** The complete collection of cached text files. */
struct fcache_entries {
- FBLOCK connect_fcache[2]; /**< connect.txt and connect.html */
- FBLOCK motd_fcache[2]; /**< motd.txt and motd.html */
- FBLOCK newuser_fcache[2]; /**< newuser.txt and newuser.html */
- FBLOCK register_fcache[2]; /**< register.txt and register.html */
- FBLOCK quit_fcache[2]; /**< quit.txt and quit.html */
- FBLOCK down_fcache[2]; /**< down.txt and down.html */
- FBLOCK full_fcache[2]; /**< full.txt and full.html */
- FBLOCK guest_fcache[2]; /**< guest.txt and guest.html */
+ FBLOCK connect_fcache[2]; /**< connect.txt and connect.html */
+ FBLOCK motd_fcache[2]; /**< motd.txt and motd.html */
+ FBLOCK newuser_fcache[2]; /**< newuser.txt and newuser.html */
+ FBLOCK register_fcache[2]; /**< register.txt and register.html */
+ FBLOCK quit_fcache[2]; /**< quit.txt and quit.html */
+ FBLOCK down_fcache[2]; /**< down.txt and down.html */
+ FBLOCK full_fcache[2]; /**< full.txt and full.html */
+ FBLOCK guest_fcache[2]; /**< guest.txt and guest.html */
};
void feed_snoop(DESC *, const char *, char );
static int dump_messages(DESC *d, dbref player, int new);
static int check_connect(DESC *d, const char *msg);
static void parse_connect(const char *msg, char *command, char *user,
- char *pass);
+ char *pass);
static void close_sockets(void);
dbref find_player_by_desc(int port);
static DESC *lookup_desc(dbref executor, const char *name);
void WIN32_CDECL signal_shutdown(int sig);
void WIN32_CDECL signal_dump(int sig);
void reaper(int sig);
-extern Pid_t forked_dump_pid; /**< Process id of forking dump process */
+extern Pid_t forked_dump_pid; /**< Process id of forking dump process */
static void dump_users(DESC *call_by, char *match, int doing);
static const char *time_format_1(long int dt);
static const char *time_format_2(long int dt);
#endif
return;
}
-#endif /* HAS_GETRLIMIT */
+#endif /* HAS_GETRLIMIT */
#ifndef BOOLEXP_DEBUGGING
#ifdef WIN32SERVICES
*/
int
main(int argc, char **argv)
-#endif /* WIN32SERVICES */
+#endif /* WIN32SERVICES */
{
#ifdef AUTORESTART
FILE *id;
exit(1);
}
}
-#endif /* WIN32 */
+#endif /* WIN32 */
#ifdef HAS_GETRLIMIT
- init_rlimit(); /* unlimit file descriptors */
+ init_rlimit(); /* unlimit file descriptors */
#endif
/* These are FreeBSDisms to fix floating point exceptions */
#ifdef HAS_GETRUSAGE
rusage_stats();
-#endif /* HAS_RUSAGE */
+#endif /* HAS_RUSAGE */
do_rawlog(LT_ERR, T("MUSH shutdown completed."));
#ifdef WIN32SERVICES
shutdown_checkpoint();
#endif
- WSACleanup(); /* clean up */
+ WSACleanup(); /* clean up */
#else
#ifdef __APPLE__
unlink("runid");
exit(0);
#endif
}
-#endif /* BOOLEXP_DEBUGGING */
+#endif /* BOOLEXP_DEBUGGING */
/** Close and reopen the logfiles - called on SIGHUP */
void
newerr = fopen(errlog, "a");
if (!newerr) {
fprintf(stderr,
- T("Unable to open %s. Error output continues to stderr.\n"),
- errlog);
+ T("Unable to open %s. Error output continues to stderr.\n"),
+ errlog);
} else {
if (!freopen(errlog, "a", stderr)) {
printf(T("Ack! Failed reopening stderr!"));
for (d = descriptor_list; d; d = d->next) {
d->quota += COMMANDS_PER_TIME * nslices;
if (d->quota > COMMAND_BURST_SIZE)
- d->quota = COMMAND_BURST_SIZE;
+ d->quota = COMMAND_BURST_SIZE;
}
}
}
static const char *empabb(dbref player) {
static char str[4];
ATTR *a;
- /*
+ /*
dbref start, end, last;
- */
- dbref start;
+ */
+ dbref start;
memset(str, '\0', 4);
goto bad_empabb_value;
start = SDIV(player).object;
- /*
+ /*
for(last = end = start; GoodObject(end) && IsDivision(end) &&
!has_flag_by_name(end, "EMPIRE", TYPE_DIVISION) ; last = end, end = SDIV(end).object)
;
end = last;
else end = start;
}
- */
+ */
/* K, end is the empire we're grabbing this off of */
a = atr_get(start, "ALIAS");
if(!a)
sslsock = make_socket(sslport, NULL, NULL, SSL_IP_ADDR);
ssl_master_socket = ssl_setup_socket(sslsock);
if (sslsock >= maxd)
- maxd = sslsock + 1;
+ maxd = sslsock + 1;
}
#endif
}
#ifndef COMPILE_CONSOLE
avail_descriptors = how_many_fds() - 4;
#ifdef INFO_SLAVE
- avail_descriptors -= 2; /* reserve some more for setting up the slave */
+ avail_descriptors -= 2; /* reserve some more for setting up the slave */
FD_ZERO(&info_pending);
#endif
#endif /* COMPILE_CONSOLE */
for (d = descriptor_list; d; d = d->next) {
if (d->input.head) {
- timeout.tv_sec = slice_timeout.tv_sec;
- timeout.tv_usec = slice_timeout.tv_usec;
+ timeout.tv_sec = slice_timeout.tv_sec;
+ timeout.tv_usec = slice_timeout.tv_usec;
#ifdef COMPILE_CONSOLE
} else {
- if(d->descriptor == 0)
- FD_SET(STDIN_FILENO, &input_set);
- else
- FD_SET(d->descriptor, &input_set);
+ if(d->descriptor == 0)
+ FD_SET(STDIN_FILENO, &input_set);
+ else
+ FD_SET(d->descriptor, &input_set);
}
if (d->output.head) {
- if(d->descriptor == 0)
- FD_SET(STDOUT_FILENO, &output_set);
- else
- FD_SET(d->descriptor, &output_set);
+ if(d->descriptor == 0)
+ FD_SET(STDOUT_FILENO, &output_set);
+ else
+ FD_SET(d->descriptor, &output_set);
}
#else /* COMPILE_CONSOLE */
} else
- FD_SET(d->descriptor, &input_set);
+ FD_SET(d->descriptor, &input_set);
if (d->output.head)
- FD_SET(d->descriptor, &output_set);
+ FD_SET(d->descriptor, &output_set);
#endif /* COMPILE_CONSOLE */
}
if (errno != EINTR)
#endif
{
- perror("select");
- return;
+ perror("select");
+ return;
}
#ifndef COMPILE_CONSOLE
#ifdef INFO_SLAVE
now = mudtime;
if (info_slave_state == 2 && now > info_queue_time + 30) {
- /* rerun any pending queries that got lost */
- info_queue_time = now;
- for (newsock = 0; newsock < maxd; newsock++)
- if (FD_ISSET(newsock, &info_pending))
- query_info_slave(newsock);
+ /* rerun any pending queries that got lost */
+ info_queue_time = now;
+ for (newsock = 0; newsock < maxd; newsock++)
+ if (FD_ISSET(newsock, &info_pending))
+ query_info_slave(newsock);
}
#endif
#endif /* COMPILE_CONSOLE */
/* if !found then time for robot commands */
if (!found) {
- do_top(options.queue_chunk);
- continue;
+ do_top(options.queue_chunk);
+ continue;
} else {
- do_top(options.active_q_chunk);
+ do_top(options.active_q_chunk);
}
now = mudtime;
#ifndef COMPILE_CONSOLE
#ifdef INFO_SLAVE
if (info_slave_state > 0 && FD_ISSET(info_slave, &input_set)) {
- if (info_slave_state == 1)
- promote_info_slave();
- else {
- reap_info_slave();
- }
+ if (info_slave_state == 1)
+ promote_info_slave();
+ else {
+ reap_info_slave();
+ }
} else if (info_slave_state == 2 && now > info_queue_time + 30) {
- /* rerun any pending queries that got lost */
- info_queue_time = now;
- for (newsock = 0; newsock < maxd; newsock++)
- if (FD_ISSET(newsock, &info_pending))
- query_info_slave(newsock);
+ /* rerun any pending queries that got lost */
+ info_queue_time = now;
+ for (newsock = 0; newsock < maxd; newsock++)
+ if (FD_ISSET(newsock, &info_pending))
+ query_info_slave(newsock);
}
if (FD_ISSET(sock, &input_set)) {
- addr_len = sizeof(addr);
- newsock = accept(sock, (struct sockaddr *) &addr, &addr_len);
- if (newsock < 0) {
- if (test_connection(newsock) < 0)
- continue; /* this should _not_ be return. */
- }
- ndescriptors++;
- query_info_slave(newsock);
- if (newsock >= maxd)
- maxd = newsock + 1;
+ addr_len = sizeof(addr);
+ newsock = accept(sock, (struct sockaddr *) &addr, &addr_len);
+ if (newsock < 0) {
+ if (test_connection(newsock) < 0)
+ continue; /* this should _not_ be return. */
+ }
+ ndescriptors++;
+ query_info_slave(newsock);
+ if (newsock >= maxd)
+ maxd = newsock + 1;
}
#ifdef HAS_OPENSSL
if (sslsock && FD_ISSET(sslsock, &input_set)) {
- addr_len = sizeof(addr);
- newsock = accept(sslsock, (struct sockaddr *) &addr, &addr_len);
- if (newsock < 0) {
- if (test_connection(newsock) < 0)
- continue; /* this should _not_ be return. */
- }
- ndescriptors++;
- query_info_slave(newsock);
- if (newsock >= maxd)
- maxd = newsock + 1;
+ addr_len = sizeof(addr);
+ newsock = accept(sslsock, (struct sockaddr *) &addr, &addr_len);
+ if (newsock < 0) {
+ if (test_connection(newsock) < 0)
+ continue; /* this should _not_ be return. */
+ }
+ ndescriptors++;
+ query_info_slave(newsock);
+ if (newsock >= maxd)
+ maxd = newsock + 1;
}
#endif
-#else /* INFO_SLAVE */
+#else /* INFO_SLAVE */
if (FD_ISSET(sock, &input_set)) {
- if (!(newd = new_connection(sock, &result, 0))) {
- if (test_connection(result) < 0)
- continue; /* this should _not_ be return. */
- } else {
- ndescriptors++;
- if (newd->descriptor >= maxd)
- maxd = newd->descriptor + 1;
- }
+ if (!(newd = new_connection(sock, &result, 0))) {
+ if (test_connection(result) < 0)
+ continue; /* this should _not_ be return. */
+ } else {
+ ndescriptors++;
+ if (newd->descriptor >= maxd)
+ maxd = newd->descriptor + 1;
+ }
}
#ifdef HAS_OPENSSL
if (sslsock && FD_ISSET(sslsock, &input_set)) {
- if (!(newd = new_connection(sslsock, &result, 1))) {
- if (test_connection(result) < 0)
- continue; /* this should _not_ be return. */
- } else {
- ndescriptors++;
- if (newd->descriptor >= maxd)
- maxd = newd->descriptor + 1;
- }
+ if (!(newd = new_connection(sslsock, &result, 1))) {
+ if (test_connection(result) < 0)
+ continue; /* this should _not_ be return. */
+ } else {
+ ndescriptors++;
+ if (newd->descriptor >= maxd)
+ maxd = newd->descriptor + 1;
+ }
}
#endif
#endif
#endif /* COMPILE_CONSOLE */
for (d = descriptor_list; d; d = dnext) {
- dnext = d->next;
+ dnext = d->next;
#ifdef COMPILE_CONSOLE
- if (d->descriptor == 0) {
- input_ready = FD_ISSET(STDIN_FILENO, &input_set);
- output_ready = FD_ISSET(STDOUT_FILENO, &output_set);
- } else {
- input_ready = FD_ISSET(d->descriptor, &input_set);
- output_ready = FD_ISSET(d->descriptor, &output_set);
- }
- if (input_ready) {
- if (!process_input(d, output_ready)) {
- shutdownsock(d);
- if(d->descriptor == 0)
- return;
- continue;
- }
- }
- if (output_ready) {
- if (!process_output(d)) {
- shutdownsock(d);
- if (d->descriptor == 0)
- return;
- }
- }
+ if (d->descriptor == 0) {
+ input_ready = FD_ISSET(STDIN_FILENO, &input_set);
+ output_ready = FD_ISSET(STDOUT_FILENO, &output_set);
+ } else {
+ input_ready = FD_ISSET(d->descriptor, &input_set);
+ output_ready = FD_ISSET(d->descriptor, &output_set);
+ }
+ if (input_ready) {
+ if (!process_input(d, output_ready)) {
+ shutdownsock(d);
+ if(d->descriptor == 0)
+ return;
+ continue;
+ }
+ }
+ if (output_ready) {
+ if (!process_output(d)) {
+ shutdownsock(d);
+ if (d->descriptor == 0)
+ return;
+ }
+ }
#else /* COMPILE_CONSOLE */
- input_ready = FD_ISSET(d->descriptor, &input_set);
- output_ready = FD_ISSET(d->descriptor, &output_set);
- if (input_ready) {
- if (!process_input(d, output_ready)) {
- shutdownsock(d);
- continue;
- }
- }
- if (output_ready) {
- if (!process_output(d)) {
- shutdownsock(d);
- }
- }
+ input_ready = FD_ISSET(d->descriptor, &input_set);
+ output_ready = FD_ISSET(d->descriptor, &output_set);
+ if (input_ready) {
+ if (!process_input(d, output_ready)) {
+ shutdownsock(d);
+ continue;
+ }
+ }
+ if (output_ready) {
+ if (!process_output(d)) {
+ shutdownsock(d);
+ }
+ }
#endif /* COMPILE_CONSOLE */
}
}
*bp = '\0';
if (Forbidden_Site(tbuf1) || Forbidden_Site(tbuf2)) {
if (!Deny_Silent_Site(tbuf1, AMBIGUOUS)
- || !Deny_Silent_Site(tbuf2, AMBIGUOUS)) {
+ || !Deny_Silent_Site(tbuf2, AMBIGUOUS)) {
do_log(LT_CONN, 0, 0, "[%d/%s/%s] %s (%s %s)", newsock, tbuf1, tbuf2,
- T("Refused connection"), T("remote port"),
- hi ? hi->port : T("(unknown)"));
+ T("Refused connection"), T("remote port"),
+ hi ? hi->port : T("(unknown)"));
}
shutdown(newsock, 2);
closesocket(newsock);
return 0;
}
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Connection opened."), newsock, tbuf1,
- tbuf2);
+ tbuf2);
set_keepalive(newsock);
return initializesock(newsock, tbuf1, tbuf2, use_ssl);
}
if ((fh = CreateFile(filename, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
+ OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
return -1;
if (!GetFileInformationByHandle(fh, &sb)) {
if (fstat(fd, &sb) < 0) {
do_log(LT_ERR, 0, 0, T("Couldn't get the size of text file '%s'"),
- filename);
+ filename);
close(fd);
reserve_fd();
return -1;
if (!(fb->buff = mush_malloc(sb.st_size, "fcache_data"))) {
do_log(LT_ERR, 0, 0, T("Couldn't allocate %d bytes of memory for '%s'!"),
- (int) sb.st_size, filename);
+ (int) sb.st_size, filename);
close(fd);
reserve_fd();
return -1;
reserve_fd();
fb->len = sb.st_size;
}
-#endif /* Posix read code */
+#endif /* Posix read code */
return fb->len;
}
if (player != NOTHING) {
notify_format(player,
- T
- ("%s sizes: NewUser...%d Connect...%d Guest...%d Motd...%d Quit...%d Register...%d Down...%d Full...%d"),
- i ? "HTMLFile" : "File", new, conn, guest, motd, quit,
- reg, down, full);
+ T
+ ("%s sizes: NewUser...%d Connect...%d Guest...%d Motd...%d Quit...%d Register...%d Down...%d Full...%d"),
+ i ? "HTMLFile" : "File", new, conn, guest, motd, quit,
+ reg, down, full);
}
}
if (d->connected) {
fcache_dump(d, fcache.quit_fcache, NULL);
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Logout by %s(#%d) <Connection not dropped>"),
- d->descriptor, d->addr, d->ip, Name(d->player), d->player);
+ T("[%d/%s/%s] Logout by %s(#%d) <Connection not dropped>"),
+ d->descriptor, d->addr, d->ip, Name(d->player), d->player);
if(d->last_time > 0) {
d->idle_total += difftime(mudtime, d->last_time);
d->unidle_times++;
}
snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at),
- d->idle_total, d->unidle_times, d->cmds);
+ d->idle_total, d->unidle_times, d->cmds);
tbuf1[strlen(tbuf1)+1] = '\0';
(void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, NOTHING);
announce_disconnect(d->player);
if (MAX_LOGINS) {
login_number--;
if (!under_limit && (login_number < MAX_LOGINS)) {
- under_limit = 1;
- do_log(LT_CONN, 0, 0,
- T("Below maximum player limit of %d. Logins enabled."),
- MAX_LOGINS);
+ under_limit = 1;
+ do_log(LT_CONN, 0, 0,
+ T("Below maximum player limit of %d. Logins enabled."),
+ MAX_LOGINS);
}
}
} else {
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Logout, never connected. <Connection not dropped>"),
- d->descriptor, d->addr, d->ip);
+ T("[%d/%s/%s] Logout, never connected. <Connection not dropped>"),
+ d->descriptor, d->addr, d->ip);
}
- process_output(d); /* flush our old output */
+ process_output(d); /* flush our old output */
/* pretend we have a new connection */
d->input_handler = do_command;
d->connected = 0;
if (d->connected) {
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Logout by %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(d->player), d->player);
+ d->descriptor, d->addr, d->ip, Name(d->player), d->player);
if (d->connected != 2) {
fcache_dump(d, fcache.quit_fcache, NULL);
/* Player was not allowed to log in from the connect screen */
if(d->last_time > 0) {
- d->idle_total += difftime(mudtime, d->last_time);
- d->unidle_times++;
+ d->idle_total += difftime(mudtime, d->last_time);
+ d->unidle_times++;
}
snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - d->connected_at),
- d->idle_total , d->unidle_times, d->cmds);
+ d->idle_total , d->unidle_times, d->cmds);
tbuf1[strlen(tbuf1)+1] = '\0';
(void) atr_add(d->player, "LASTACTIVITY", tbuf1, GOD, NOTHING);
announce_disconnect(d->player);
if (MAX_LOGINS) {
login_number--;
if (!under_limit && (login_number < MAX_LOGINS)) {
- under_limit = 1;
- do_log(LT_CONN, 0, 0,
- T("Below maximum player limit of %d. Logins enabled."),
- MAX_LOGINS);
+ under_limit = 1;
+ do_log(LT_CONN, 0, 0,
+ T("Below maximum player limit of %d. Logins enabled."),
+ MAX_LOGINS);
}
}
} else {
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Connection closed, never connected."),
- d->descriptor, d->addr, d->ip);
+ d->descriptor, d->addr, d->ip);
}
process_output(d);
clearstrings(d);
if (d->descriptor != 0) {
if (d->prev)
d->prev->next = d->next;
- else /* d was the first one! */
+ else /* d was the first one! */
descriptor_list = d->next;
if (d->next)
d->next->prev = d->prev;
closesocket(d->descriptor);
if (d->prev)
d->prev->next = d->next;
- else /* d was the first one! */
+ else /* d was the first one! */
descriptor_list = d->next;
if (d->next)
d->next->prev = d->prev;
/* ARGSUSED */
static DESC *
initializesock(int s, char *addr, char *ip, int use_ssl
- __attribute__ ((__unused__)))
+ __attribute__ ((__unused__)))
{
DESC *d;
int n;
return;
}
if (getnameinfo(&addr.addr, opt, NULL, 0, num, sizeof num,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
perror("getting address of slave stream socket");
fflush(stderr);
closesocket(info_slave);
info_slave = socks[0];
closesocket(socks[1]);
do_rawlog(LT_ERR,
- "Spawning info slave using socketpair, pid %d, ident %d",
- child, USE_IDENT);
+ "Spawning info slave using socketpair, pid %d, ident %d",
+ child, USE_IDENT);
#else
do_rawlog(LT_ERR, "Spawning info slave on port %s, pid %d, ident %d",
- num, child, USE_IDENT);
+ num, child, USE_IDENT);
#endif
} else {
/* Close unneeded fds and sockets */
for (n = 3; n < maxd; n++) {
if (n == fileno(stderr))
- continue;
+ continue;
#ifdef HAS_SOCKETPAIR
if (n == socks[1])
- continue;
+ continue;
#endif
close(n);
}
#endif
if (!USE_IDENT)
execl("./info_slave", "./info_slave", num, "-1", USE_DNS ? "1" : "0",
- (char *) NULL);
+ (char *) NULL);
else
execl("./info_slave", "./info_slave", num, tprintf("%d", IDENT_TIMEOUT),
- USE_DNS ? "1" : "0", (char *) NULL);
+ USE_DNS ? "1" : "0", (char *) NULL);
perror("execing info slave");
exit(1);
}
do_rawlog(LT_ERR, "Accepted info slave from unix-domain socket");
#else
if (getnameinfo(&addr.addr, addr_len, NULL, 0, port, sizeof port,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
perror("getting info slave port number");
} else {
do_rawlog(LT_ERR, "Accepted info slave from port %s", port);
{
int size, slen;
socklen_t llen, rlen;
- static char buf[1024]; /* overkill */
+ static char buf[1024]; /* overkill */
union sockaddr_u laddr, raddr;
char *bp;
struct hostname_info *hi;
if (Forbidden_Site(buf)) {
char port[NI_MAXSERV];
if (getnameinfo(&raddr.addr, rlen, NULL, 0, port, sizeof port,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0)
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0)
perror("getting remote port number");
else {
if (!Deny_Silent_Site(buf, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0, T("[%d/%s] Refused connection (remote port %s)"),
- fd, buf, port);
+ do_log(LT_CONN, 0, 0, T("[%d/%s] Refused connection (remote port %s)"),
+ fd, buf, port);
}
}
shutdown(fd, 2);
reap_info_slave(void)
{
int fd, len, size;
- static char buf[10000]; /* overkill */
+ static char buf[10000]; /* overkill */
char *bp, *bp2;
struct iovec dat[2];
*bp2++ = '\0';
/* buf is ip addr, bp is local port^ident info */
if ((bp = strchr(bp2, '^')))
- *bp++ = '\0';
+ *bp++ = '\0';
}
/* Now, either buf = ipaddr, bp2 = port, bp = ident info,
* or buf = ipaddr, bp2 = port
*/
if (Forbidden_Site(buf) || (bp && Forbidden_Site(bp))) {
if (!Deny_Silent_Site(buf, AMBIGUOUS) || !Deny_Silent_Site(bp, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Refused connection."), fd,
- bp ? bp : "", buf);
+ do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Refused connection."), fd,
+ bp ? bp : "", buf);
}
shutdown(fd, 2);
closesocket(fd);
return;
}
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Connection opened."), fd,
- bp ? bp : "", buf);
+ bp ? bp : "", buf);
set_keepalive(fd);
(void) initializesock(fd, bp ? bp : buf, buf, (atoi(bp2) == SSLPORT));
}
if (d->ssl) {
cnt = 0;
d->ssl_state = ssl_write(d->ssl, d->ssl_state, input_ready, 1, cur->start,
- cur->nchars, &cnt);
+ cur->nchars, &cnt);
if (ssl_want_write(d->ssl_state))
- return 1; /* Need to retry */
+ return 1; /* Need to retry */
} else {
#endif
#endif /* COMPILE_CONSOLE */
cnt = send(d->descriptor, cur->start, cur->nchars, 0);
if (cnt < 0) {
#ifdef WIN32
- if (cnt == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
+ if (cnt == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
#else
#ifdef EAGAIN
- if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
+ if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
#else
- if (errno == EWOULDBLOCK)
+ if (errno == EWOULDBLOCK)
#endif
#endif
- return 1;
- return 0;
+ return 1;
+ return 0;
}
#ifndef COMPILE_CONSOLE
#ifdef HAS_OPENSSL
d->output_chars += cnt;
if (cnt == cur->nchars) {
if (!cur->nxt)
- d->output.tail = qp;
+ d->output.tail = qp;
*qp = cur->nxt;
#ifdef DEBUG
do_rawlog(LT_ERR, "free_text_block(0x%x) at 2.", cur);
-#endif /* DEBUG */
+#endif /* DEBUG */
free_text_block(cur);
- continue; /* do not adv ptr */
+ continue; /* do not adv ptr */
}
cur->nchars -= cnt;
cur->start += cnt;
unsigned char extra_options[6] = "\xFF\xFD\x1F" "\xFF\xFD\x18";
d->conn_flags &= ~CONN_TELNET_QUERY;
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Switching to Telnet mode."),
- d->descriptor, d->addr, d->ip);
+ d->descriptor, d->addr, d->ip);
queue_newwrite(d, extra_options, 6);
process_output(d);
}
/* *(*q - q) == IAC at this point. */
switch (**q) {
- case SB: /* Sub-option */
+ case SB: /* Sub-option */
if (*q >= qend)
return -1;
(*q)++;
if (**q == TN_LINEMODE) {
if ((*q + 2) >= qend)
- return -1;
+ return -1;
*q += 2;
while (*q < qend && **q != SE)
- (*q)++;
+ (*q)++;
if (*q >= qend)
- return -1;
+ return -1;
} else if (**q == TN_NAWS) {
/* Learn what size window the client is using. */
union {
- short s;
- unsigned char bytes[2];
+ short s;
+ unsigned char bytes[2];
} raw;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
/* Width */
if (**q == IAC) {
- raw.bytes[0] = IAC;
- if (*q >= qend)
- return -1;
- (*q)++;
+ raw.bytes[0] = IAC;
+ if (*q >= qend)
+ return -1;
+ (*q)++;
} else
- raw.bytes[0] = **q;
+ raw.bytes[0] = **q;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
if (**q == IAC) {
- raw.bytes[1] = IAC;
- if (*q >= qend)
- return -1;
- (*q)++;
+ raw.bytes[1] = IAC;
+ if (*q >= qend)
+ return -1;
+ (*q)++;
} else
- raw.bytes[1] = **q;
+ raw.bytes[1] = **q;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
d->width = ntohs(raw.s);
/* Height */
if (**q == IAC) {
- raw.bytes[0] = IAC;
- if (*q >= qend)
- return -1;
- (*q)++;
+ raw.bytes[0] = IAC;
+ if (*q >= qend)
+ return -1;
+ (*q)++;
} else
- raw.bytes[0] = **q;
+ raw.bytes[0] = **q;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
if (**q == IAC) {
- raw.bytes[1] = IAC;
- if (*q >= qend)
- return -1;
- (*q)++;
+ raw.bytes[1] = IAC;
+ if (*q >= qend)
+ return -1;
+ (*q)++;
} else
- raw.bytes[1] = **q;
+ raw.bytes[1] = **q;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
d->height = ntohs(raw.s);
/* IAC SE */
if (*q + 1 >= qend)
- return -1;
+ return -1;
(*q)++;
} else if (**q == TN_TTYPE) {
/* Read the terminal type: TERMINAL-TYPE IS blah IAC SE */
char tbuf[BUFFER_LEN], *bp = tbuf;
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
/* Skip IS */
if (*q >= qend)
- return -1;
+ return -1;
(*q)++;
/* Read up to IAC SE */
while (1) {
- if (*q >= qend)
- return -1;
- if (**q == IAC) {
- if (*q + 1 >= qend)
- return -1;
- if (*(*q + 1) == IAC) {
- safe_chr((char) IAC, tbuf, &bp);
- (*q)++;
- } else
- break;
- } else
- safe_chr(**q, tbuf, &bp);
- (*q)++;
+ if (*q >= qend)
+ return -1;
+ if (**q == IAC) {
+ if (*q + 1 >= qend)
+ return -1;
+ if (*(*q + 1) == IAC) {
+ safe_chr((char) IAC, tbuf, &bp);
+ (*q)++;
+ } else
+ break;
+ } else
+ safe_chr(**q, tbuf, &bp);
+ (*q)++;
}
while (*q < qend && **q != SE)
- (*q)++;
+ (*q)++;
*bp = '\0';
mush_free(d->ttype, "terminal description");
d->ttype = mush_strdup(tbuf, "terminal description");
/* We have the terminal type, now set any defaults if we find 'em */
for(i = 0 ; client_maps[i].terminal != NULL; i++)
- if(!strcmp(client_maps[i].terminal, d->ttype)) {
- d->conn_flags |= client_maps[i].flags;
- break;
- }
+ if(!strcmp(client_maps[i].terminal, d->ttype)) {
+ d->conn_flags |= client_maps[i].flags;
+ break;
+ }
} else {
while (*q < qend && **q != SE)
- (*q)++;
+ (*q)++;
}
break;
- case NOP: /* No-op */
+ case NOP: /* No-op */
if (*q >= qend)
return -1;
#ifdef DEBUG_TELNET
fprintf(stderr, "Got IAC NOP\n");
#endif
break;
- case AYT: /* Are you there? */
+ case AYT: /* Are you there? */
if (*q >= qend)
return -1;
else {
static unsigned char ayt_reply[] =
- "\r\n*** AYT received, I'm here ***\r\n";
+ "\r\n*** AYT received, I'm here ***\r\n";
queue_newwrite(d, ayt_reply, u_strlen(ayt_reply));
process_output(d);
}
break;
- case WILL: /* Client is willing to do something, or confirming */
+ case WILL: /* Client is willing to do something, or confirming */
setup_telnet(d);
if (*q >= qend)
return -1;
queue_newwrite(d, reply, 6);
} else if (**q == TN_SGA || **q == TN_NAWS) {
/* This is good to be at. */
- } else { /* Refuse options we don't handle */
+ } else { /* Refuse options we don't handle */
unsigned char reply[3];
reply[0] = IAC;
reply[1] = DONT;
process_output(d);
}
break;
- case DO: /* Client is asking us to do something */
+ case DO: /* Client is asking us to do something */
setup_telnet(d);
if (*q >= qend)
return -1;
process_output(d);
}
break;
- case WONT: /* Client won't do something we want. */
- case DONT: /* Client doesn't want us to do something */
+ case WONT: /* Client won't do something we want. */
+ case DONT: /* Client doesn't want us to do something */
setup_telnet(d);
#ifdef DEBUG_TELNET
fprintf(stderr, "Got IAC %s 0x%x\n", **q == WONT ? "WONT" : "DONT",
- *(*q + 1));
+ *(*q + 1));
#endif
if (*q + 1 >= qend)
return -1;
(*q)++;
break;
- default: /* Also catches IAC IAC for a literal 255 */
+ default: /* Also catches IAC IAC for a literal 255 */
return 0;
}
return 1;
if (!d->raw_input) {
d->raw_input =
(unsigned char *) mush_malloc(sizeof(char) * MAX_COMMAND_LEN,
- "descriptor_raw_input");
+ "descriptor_raw_input");
if (!d->raw_input)
mush_panic("Out of memory");
d->raw_input_at = d->raw_input;
*/
*p = '\0';
if (p > d->raw_input)
- save_command(d, d->raw_input);
+ save_command(d, d->raw_input);
p = d->raw_input;
if (((q + 1) < qend) && (*(q + 1) == '\n'))
- q++; /* For clients that work */
+ q++; /* For clients that work */
} else if (*q == '\n') {
*p = '\0';
if (p > d->raw_input)
- save_command(d, d->raw_input);
+ save_command(d, d->raw_input);
p = d->raw_input;
} else if (*q == '\b') {
if (p > d->raw_input)
- p--;
+ p--;
#ifndef COMPILE_CONSOLE
- } else if ((unsigned char) *q == IAC) { /* Telnet option foo */
+ } else if ((unsigned char) *q == IAC) { /* Telnet option foo */
if (q >= qend)
- break;
+ break;
q++;
if (!TELNET_ABLE(d) || handle_telnet(d, &q, qend) == 0) {
- if (p < pend && isprint(*q))
- *p++ = *q;
+ if (p < pend && isprint(*q))
+ *p++ = *q;
}
#endif /* COMPILE_CONSOLE */
} else if (p < pend && isprint(*q)) {
if (ssl_need_handshake(d->ssl_state)) {
d->ssl_state = ssl_handshake(d->ssl);
if (d->ssl_state < 0) {
- /* Fatal error */
- ssl_close_connection(d->ssl);
- d->ssl = NULL;
- d->ssl_state = 0;
- return 0;
+ /* Fatal error */
+ ssl_close_connection(d->ssl);
+ d->ssl = NULL;
+ d->ssl_state = 0;
+ return 0;
} else if (ssl_need_handshake(d->ssl_state)) {
- /* We're still not ready to send to this connection. Alas. */
- return 1;
+ /* We're still not ready to send to this connection. Alas. */
+ return 1;
}
}
/* Insure that we're not in a state where we need an SSL_accept() */
if (ssl_need_accept(d->ssl_state)) {
d->ssl_state = ssl_accept(d->ssl);
if (d->ssl_state < 0) {
- /* Fatal error */
- ssl_close_connection(d->ssl);
- d->ssl = NULL;
- d->ssl_state = 0;
- return 0;
+ /* Fatal error */
+ ssl_close_connection(d->ssl);
+ d->ssl = NULL;
+ d->ssl_state = 0;
+ return 0;
} else if (ssl_need_accept(d->ssl_state)) {
- /* We're still not ready to send to this connection. Alas. */
- return 1;
+ /* We're still not ready to send to this connection. Alas. */
+ return 1;
}
}
/* It's an SSL connection, proceed accordingly */
d->ssl_state =
ssl_read(d->ssl, d->ssl_state, 1, output_ready, tbuf1, sizeof tbuf1,
- &got);
+ &got);
if (d->ssl_state < 0) {
/* Fatal error */
ssl_close_connection(d->ssl);
#else
if ((errno == EWOULDBLOCK) || (errno == EINTR))
#endif
- return 1;
+ return 1;
else
- return 0;
+ return 0;
}
#ifndef COMPILE_CONSOLE
#ifdef HAS_OPENSSL
do {
nprocessed = 0;
for (cdesc = descriptor_list; cdesc;
- cdesc = (nprocessed > 0 && retval > 0) ? cdesc->next : dnext) {
+ cdesc = (nprocessed > 0 && retval > 0) ? cdesc->next : dnext) {
dnext = cdesc->next;
if (cdesc->quota > 0 && (t = cdesc->input.head)) {
- cdesc->quota--;
- nprocessed++;
- start_cpu_timer();
- feed_snoop(cdesc,(const char *) t->start, 0);
- /* check AUNIDLE */
- if(options.idle_time && ((mudtime - cdesc->last_time) > options.idle_time)) {
- if(atr_get(cdesc->player, "AUNIDLE"))
- queue_attribute_noparent(cdesc->player, "AUNIDLE", cdesc->player);
- if(GoodObject(Division(cdesc->player)) && atr_get(Division(cdesc->player), "AUNIDLE"))
- queue_attribute(Division(cdesc->player), "AUNIDLE", cdesc->player);
- }
- retval = cdesc->input_handler(cdesc, (char *) t->start);
- reset_cpu_timer();
- if(retval == -1 && do_su_exit(cdesc))
- retval = 1;
-
- if (retval == 0) {
- shutdownsock(cdesc);
- } else if (retval == -1) {
- logout_sock(cdesc);
- } else {
- cdesc->input.head = t->nxt;
- if (!cdesc->input.head)
- cdesc->input.tail = &cdesc->input.head;
- if (t) {
+ cdesc->quota--;
+ nprocessed++;
+ start_cpu_timer();
+ feed_snoop(cdesc,(const char *) t->start, 0);
+ /* check AUNIDLE */
+ if(options.idle_time && ((mudtime - cdesc->last_time) > options.idle_time)) {
+ if(atr_get(cdesc->player, "AUNIDLE"))
+ queue_attribute_noparent(cdesc->player, "AUNIDLE", cdesc->player);
+ if(GoodObject(Division(cdesc->player)) && atr_get(Division(cdesc->player), "AUNIDLE"))
+ queue_attribute(Division(cdesc->player), "AUNIDLE", cdesc->player);
+ }
+ retval = cdesc->input_handler(cdesc, (char *) t->start);
+ reset_cpu_timer();
+ if(retval == -1 && do_su_exit(cdesc))
+ retval = 1;
+
+ if (retval == 0) {
+ shutdownsock(cdesc);
+ } else if (retval == -1) {
+ logout_sock(cdesc);
+ } else {
+ cdesc->input.head = t->nxt;
+ if (!cdesc->input.head)
+ cdesc->input.tail = &cdesc->input.head;
+ if (t) {
#ifdef DEBUG
- do_rawlog(LT_ERR, "free_text_block(0x%x) at 5.", t);
-#endif /* DEBUG */
- free_text_block(t);
- }
- }
+ do_rawlog(LT_ERR, "free_text_block(0x%x) at 5.", t);
+#endif /* DEBUG */
+ free_text_block(t);
+ }
+ }
}
}
} while (nprocessed > 0);
} else if (!strncmp(command, "SCREENHEIGHT", 12)) {
d->height = parse_integer(command + 12);
} else if (SUPPORT_PUEBLO
- && !strncmp(command, PUEBLO_COMMAND, strlen(PUEBLO_COMMAND))) {
+ && !strncmp(command, PUEBLO_COMMAND, strlen(PUEBLO_COMMAND))) {
parse_puebloclient(d, command);
if (!(d->conn_flags & CONN_HTML)) {
queue_newwrite(d, (unsigned char *) PUEBLO_SEND, strlen(PUEBLO_SEND));
process_output(d);
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Switching to Pueblo mode."),
- d->descriptor, d->addr, d->ip);
+ d->descriptor, d->addr, d->ip);
d->conn_flags |= CONN_HTML;
if (!d->connected)
- welcome_user(d);
+ welcome_user(d);
}
} else {
if (d->connected) {
/* Clear %0-%9 and r(0) - r(9) */
for (j = 0; j < 10; j++)
- global_eval_context.wenv[j] = (char *) NULL;
+ global_eval_context.wenv[j] = (char *) NULL;
for (j = 0; j < NUMQ; j++)
- global_eval_context.renv[j][0] = '\0';
+ global_eval_context.renv[j][0] = '\0';
clear_namedregs(&global_eval_context.namedregs);
global_eval_context.process_command_port = d->descriptor;
global_eval_context.cplr = NOTHING;
} else {
if (!check_connect(d, command))
- return 0;
+ return 0;
}
}
return 1;
p += 5;
if ((end = strchr(p, '"'))) {
if ((end > p) && ((end - p) <= PUEBLO_CHECKSUM_LEN)) {
- /* Got it! */
- strncpy(d->checksum, p, end - p);
- d->checksum[end - p] = '\0';
+ /* Got it! */
+ strncpy(d->checksum, p, end - p);
+ d->checksum[end - p] = '\0';
}
}
}
if (under_limit && (login_number > MAX_LOGINS)) {
under_limit = 0;
do_rawlog(LT_CONN,
- T("Limit of %d players reached. Logins disabled.\n"),
- MAX_LOGINS);
+ T("Limit of %d players reached. Logins disabled.\n"),
+ MAX_LOGINS);
}
}
/* give players a message on connection */
if (!options.login_allow) {
fcache_dump(d, fcache.down_fcache, NULL);
if (*cf_downmotd_msg)
- raw_notify(player, cf_downmotd_msg);
+ raw_notify(player, cf_downmotd_msg);
} else if (MAX_LOGINS && !under_limit) {
fcache_dump(d, fcache.full_fcache, NULL);
if (*cf_fullmotd_msg)
- raw_notify(player, cf_fullmotd_msg);
+ raw_notify(player, cf_fullmotd_msg);
}
if (!Can_Login(player)) {
/* when the connection has been refused, we want to update the
if (tmpd->player == player) {
num++;
if (is_hidden)
- tmpd->hide = 1;
+ tmpd->hide = 1;
}
}
/* give permanent text messages */
if (ModTime(player))
notify_format(player, T("%ld failed connections since last login."),
- ModTime(player));
+ ModTime(player));
ModTime(player) = (time_t) 0;
- announce_connect(player, isnew, num); /* broadcast connect message */
- check_last(player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */
+ announce_connect(player, isnew, num); /* broadcast connect message */
+ check_last(player, d->addr, d->ip); /* set Last, Lastsite, give paycheck */
/* Check folder 0, not silently (i.e. Report lack of mail, too) */
queue_eol(d);
#ifdef USE_MAILER
if (string_prefix("connect", command)) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Failed connect to '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Connected to %s(#%d) in %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(player), player,
- Name(Location(player)), Location(player));
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ Name(Location(player)), Location(player));
/* Check if we're fake siting this guy.. */
if(has_flag_by_name(player, "WEIRDSITE", TYPE_PLAYER)) {
- ATTR *a;
- a = atr_get(player, "LASTSITE");
- strncpy(d->addr, !a ? "localhost" : atr_value(a), 100);
+ ATTR *a;
+ a = atr_get(player, "LASTSITE");
+ strncpy(d->addr, !a ? "localhost" : atr_value(a), 100);
}
if ((dump_messages(d, player, 0)) == 0) {
- d->connected = 2;
- return 0;
+ d->connected = 2;
+ return 0;
}
}
} else if (!strcasecmp(command, "cd")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Failed connect to '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Connected dark to %s(#%d) in %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(player), player,
- Name(Location(player)), Location(player));
+ T("[%d/%s/%s] Connected dark to %s(#%d) in %s(#%d)"),
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ Name(Location(player)), Location(player));
/* Set player dark */
d->connected = 1;
d->player = player;
set_flag(player, player, "DARK", 0, 0, 0);
if ((dump_messages(d, player, 0)) == 0) {
- d->connected = 2;
- return 0;
+ d->connected = 2;
+ return 0;
}
}
} else if (!strcasecmp(command, "cv")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Failed connect to '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Connected to %s(#%d) in %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(player), player,
- Name(Location(player)), Location(player));
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ Name(Location(player)), Location(player));
/* Set player !dark */
d->connected = 1;
d->player = player;
set_flag(player, player, "DARK", 1, 0, 0);
if ((dump_messages(d, player, 0)) == 0) {
- d->connected = 2;
- return 0;
+ d->connected = 2;
+ return 0;
}
}
} else if (!strcasecmp(command, "ch")) {
if ((player =
- connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
+ connect_player(user, password, d->addr, d->ip, errbuf)) == NOTHING) {
queue_string_eol(d, errbuf);
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Failed connect to '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Connected hidden to %s(#%d) in %s(#%d)"),
- d->descriptor, d->addr, d->ip, Name(player), player,
- Name(Location(player)), Location(player));
+ T("[%d/%s/%s] Connected hidden to %s(#%d) in %s(#%d)"),
+ d->descriptor, d->addr, d->ip, Name(player), player,
+ Name(Location(player)), Location(player));
/* Set player hidden */
d->connected = 1;
d->player = player;
if (Can_Hide(player))
- d->hide = 1;
+ d->hide = 1;
if ((dump_messages(d, player, 0)) == 0) {
- d->connected = 2;
- return 0;
+ d->connected = 2;
+ return 0;
}
}
if (!Site_Can_Create(d->addr) || !Site_Can_Create(d->ip)) {
fcache_dump(d, fcache.register_fcache, NULL);
if (!Deny_Silent_Site(d->addr, AMBIGUOUS)
- && !Deny_Silent_Site(d->ip, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Refused create for '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ && !Deny_Silent_Site(d->ip, AMBIGUOUS)) {
+ do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Refused create for '%s'."),
+ d->descriptor, d->addr, d->ip, user);
}
return 0;
}
if (!options.login_allow || !options.create_allow) {
if (!options.login_allow)
- fcache_dump(d, fcache.down_fcache, NULL);
+ fcache_dump(d, fcache.down_fcache, NULL);
else
- fcache_dump(d, fcache.register_fcache, NULL);
+ fcache_dump(d, fcache.register_fcache, NULL);
do_rawlog(LT_CONN,
- "REFUSED CREATION for %s from %s on descriptor %d.\n",
- user, d->addr, d->descriptor);
+ "REFUSED CREATION for %s from %s on descriptor %d.\n",
+ user, d->addr, d->descriptor);
return 0;
} else if (MAX_LOGINS && !under_limit) {
fcache_dump(d, fcache.full_fcache, NULL);
do_rawlog(LT_CONN,
- "REFUSED CREATION for %s from %s on descriptor %d.\n",
- user, d->addr, d->descriptor);
+ "REFUSED CREATION for %s from %s on descriptor %d.\n",
+ user, d->addr, d->descriptor);
return 0;
}
player = create_player(user, password, d->addr, d->ip);
if (player == NOTHING) {
queue_string_eol(d, T(create_fail));
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Failed create for '%s' (bad name)."),
- d->descriptor, d->addr, d->ip, user);
+ T("[%d/%s/%s] Failed create for '%s' (bad name)."),
+ d->descriptor, d->addr, d->ip, user);
} else if (player == AMBIGUOUS) {
queue_string_eol(d, T(password_fail));
do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Failed create for '%s' (bad password)."),
- d->descriptor, d->addr, d->ip, user);
+ T("[%d/%s/%s] Failed create for '%s' (bad password)."),
+ d->descriptor, d->addr, d->ip, user);
} else {
do_log(LT_CONN, 0, 0, "[%d/%s/%s] Created %s(#%d)",
- d->descriptor, d->addr, d->ip, Name(player), player);
+ d->descriptor, d->addr, d->ip, Name(player), player);
if ((dump_messages(d, player, 1)) == 0) {
- d->connected = 2;
- return 0;
+ d->connected = 2;
+ return 0;
}
- } /* successful player creation */
+ } /* successful player creation */
} else if (string_prefix("register", command)) {
if (!Site_Can_Register(d->addr) || !Site_Can_Register(d->ip)) {
fcache_dump(d, fcache.register_fcache, NULL);
if (!Deny_Silent_Site(d->addr, AMBIGUOUS)
- && !Deny_Silent_Site(d->ip, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Refused registration (bad site) for '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ && !Deny_Silent_Site(d->ip, AMBIGUOUS)) {
+ do_log(LT_CONN, 0, 0,
+ T("[%d/%s/%s] Refused registration (bad site) for '%s'."),
+ d->descriptor, d->addr, d->ip, user);
}
return 0;
}
if (!options.create_allow) {
fcache_dump(d, fcache.register_fcache, NULL);
do_rawlog(LT_CONN,
- "Refused registration (creation disabled) for %s from %s on descriptor %d.\n",
- user, d->addr, d->descriptor);
+ "Refused registration (creation disabled) for %s from %s on descriptor %d.\n",
+ user, d->addr, d->descriptor);
return 0;
}
if ((player = email_register_player(user, password, d->addr, d->ip)) ==
- NOTHING) {
+ NOTHING) {
queue_string_eol(d, T(register_fail));
do_log(LT_CONN, 0, 0, T("[%d/%s/%s] Failed registration for '%s'."),
- d->descriptor, d->addr, d->ip, user);
+ d->descriptor, d->addr, d->ip, user);
} else {
queue_string_eol(d, T(register_success));
do_log(LT_CONN, 0, 0, "[%d/%s/%s] Registered %s(#%d) to %s",
- d->descriptor, d->addr, d->ip, Name(player), player, password);
+ d->descriptor, d->addr, d->ip, Name(player), player, password);
}
/* Whether it succeeds or fails, leave them connected */
for (; *msg && ((*msg == '\"') || isspace(*msg)); msg++) ;
while (*msg && (*msg != '\"')) {
while (*msg && !isspace(*msg) && (*msg != '\"'))
- *p++ = *msg++;
+ *p++ = *msg++;
if (*msg == '\"') {
- msg++;
- while (*msg && isspace(*msg))
- msg++;
- break;
+ msg++;
+ while (*msg && isspace(*msg))
+ msg++;
+ break;
}
while (*msg && isspace(*msg))
- msg++;
+ msg++;
if (*msg && (*msg != '\"'))
- *p++ = ' ';
+ *p++ = ' ';
}
} else
while (*msg && isprint(*msg) && !isspace(*msg))
send(d->descriptor, T(shutdown_message), strlen(T(shutdown_message)), 0);
send(d->descriptor, "\r\n", 2, 0);
if (shutdown(d->descriptor, 2) < 0)
- perror("shutdown");
+ perror("shutdown");
closesocket(d->descriptor);
}
#else /* COMPILE_CONSOLE */
switch (key) {
case 1:
safe_format(tbuf, &tbp, T("From afar, %s%s%s"), Name(player), gap,
- message + 1);
+ message + 1);
notify_format(player, T("Long distance to %s: %s%s%s"),
- target != NOTHING ? Name(target) :
- T("a connecting player"), Name(player), gap, message + 1);
+ target != NOTHING ? Name(target) :
+ T("a connecting player"), Name(player), gap, message + 1);
break;
case 3:
safe_format(tbuf, &tbp, T("%s pages: %s"), Name(player), message);
notify_format(player, T("You paged %s with '%s'."),
- target != NOTHING ? Name(target) :
- T("a connecting player"), message);
+ target != NOTHING ? Name(target) :
+ T("a connecting player"), message);
break;
}
*tbp = '\0';
if (d->player == player) {
numd++;
if (now - d->last_time > 60)
- in = d;
+ in = d;
}
}
if (numd > 1)
if (forked_dump_pid > -1 && pid == forked_dump_pid) {
/* Most failures are handled by the forked mush already */
if (WIFSIGNALED(my_stat)) {
- do_rawlog(LT_ERR, T("ERROR! forking dump exited with signal %d"),
- WTERMSIG(my_stat));
+ do_rawlog(LT_ERR, T("ERROR! forking dump exited with signal %d"),
+ WTERMSIG(my_stat));
} else if (WIFEXITED(my_stat) && WEXITSTATUS(my_stat) == 0) {
- time(&globals.last_dump_time);
- if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
- flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
+ time(&globals.last_dump_time);
+ if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
+ flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
}
forked_dump_pid = -1;
}
reload_sig_handler(SIGCHLD, reaper);
}
-#endif /* !WIN32 */
+#endif /* !WIN32 */
static void
for (d = descriptor_list; d; d = d->next) {
if (d->connected) {
if (!GoodObject(d->player))
- continue;
+ continue;
if (COUNT_ALL || !Hidden(d) || call_by->player == d->player )
- count++;
+ count++;
}
}
queue_string_eol(call_by, tprintf("Name: %s", options.mud_name));
queue_string_eol(call_by,
- tprintf("Uptime: %s", show_time(globals.first_start_time, 0)));
+ tprintf("Uptime: %s", show_time(globals.first_start_time, 0)));
queue_string_eol(call_by, tprintf("Connected: %d", count));
queue_string_eol(call_by, tprintf("Size: %d", db_top));
queue_string_eol(call_by, tprintf("Version: CobraMUSH v%s [%s]", VERSION,
- VBRANCH));
+ VBRANCH));
#ifdef PATCHES
queue_string_eol(call_by, tprintf("Patches: %s", PATCHES));
#endif
strcpy(poll_msg, "Doing");
if (ShowAnsi(call_by->player))
sprintf(tbuf2, "%s%-16s %4s %10s %6s %s%s\n", ANSI_HILITE,
- T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg, ANSI_NORMAL);
+ T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg, ANSI_NORMAL);
else
sprintf(tbuf2, "%-16s %4s %10s %6s %s\n",
- T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg);
+ T("Player Name"), T("Aff"), T("On For"), T("Idle"), poll_msg);
queue_string(call_by, tbuf2);
} else if (doing == 2) {
sprintf(tbuf2, "%s%-16s %6s %9s %5s %5s Des Sent Recv Pend%s\n", ShowAnsi(call_by->player) ? ANSI_HILITE :
- "", T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"),
- ShowAnsi(call_by->player) ? ANSI_NORMAL : "");
+ "", T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"),
+ ShowAnsi(call_by->player) ? ANSI_NORMAL : "");
queue_string(call_by, tbuf2);
} else {
sprintf(tbuf2, "%s%-16s %6s %9s %5s %5s Des Host%s\n", ShowAnsi(call_by->player) ? ANSI_HILITE : "",
- T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"), ShowAnsi(call_by->player) ? ANSI_NORMAL : "");
+ T("Player Name"), T("Loc #"), T("On For"), T("Idle"), T("Cmds"), ShowAnsi(call_by->player) ? ANSI_NORMAL : "");
queue_string(call_by, tbuf2);
}
for (d = descriptor_list; d; d = d->next) {
if (d->connected) {
if (!GoodObject(d->player))
- continue;
+ continue;
if (COUNT_ALL || (!Hidden(d) || call_by->player == d->player
- || (call_by->player && Priv_Who(call_by->player)))) {
- count++;
+ || (call_by->player && Priv_Who(call_by->player)))) {
+ count++;
#ifdef COLOREDWHO
- tcount++;
+ tcount++;
#endif
}
if (match && !(string_prefix(Name(d->player), match)))
- continue;
+ continue;
csite = CanSee(call_by->player, d->player);
if (call_by->connected && doing == 0 && call_by->player
- && Priv_Who(call_by->player)) {
+ && Priv_Who(call_by->player)) {
if (Hidden(d) && !csite)
continue;
- sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), csite ? d->cmds : 0,
- csite ? d->descriptor : 0,
+ sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
+ Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), csite ? d->cmds : 0,
+ csite ? d->descriptor : 0,
#ifdef COMPILE_CONSOLE
- ' ',
+ ' ',
#else /* COMPILE_CONSOLE */
#ifdef HAS_OPENSSL
- d->ssl ? 'S' : ' ',
+ d->ssl ? 'S' : ' ',
#else
- ' ',
+ ' ',
#endif
#endif /* COMPILE_CONSOLE */
- csite ? d->addr : "---");
- tbuf1[78] = '\0';
- if (Dark(d->player)) {
- tbuf1[71] = '\0';
- strcat(tbuf1, " (Dark)");
- } else if (Hidden(d)) {
- tbuf1[71] = '\0';
- strcat(tbuf1, " (Hide)");
- }
+ csite ? d->addr : "---");
+ tbuf1[78] = '\0';
+ if (Dark(d->player)) {
+ tbuf1[71] = '\0';
+ strcat(tbuf1, " (Dark)");
+ } else if (Hidden(d)) {
+ tbuf1[71] = '\0';
+ strcat(tbuf1, " (Hide)");
+ }
} else if (call_by->connected && doing == 2 && call_by->player
- && Priv_Who(call_by->player)) {
- sprintf(tbuf1, "%-16s %6s %9s %5s %5d %3d%c %5lu %7lu %5d",
- tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
- Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), csite ? d->cmds : 0,
- csite ? d->descriptor : 0,
+ && Priv_Who(call_by->player)) {
+ sprintf(tbuf1, "%-16s %6s %9s %5s %5d %3d%c %5lu %7lu %5d",
+ tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""),
+ Can_Locate(call_by->player, d->player) ? unparse_dbref(Location(d->player)) : "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), csite ? d->cmds : 0,
+ csite ? d->descriptor : 0,
#ifdef COMPILE_CONSOLE
- ' ',
+ ' ',
#else /* COMPILE_CONSOLE */
#ifdef HAS_OPENSSL
- d->ssl ? 'S' : ' ',
+ d->ssl ? 'S' : ' ',
#else
- ' ',
+ ' ',
#endif
#endif /* COMPILE_CONSOLE */
- csite ? d->input_chars : 0, csite ? d->output_chars : 0,
- csite ? d->output_size : 0);
+ csite ? d->input_chars : 0, csite ? d->output_chars : 0,
+ csite ? d->output_size : 0);
} else {
- if (!Hidden(d)
- || call_by->player == d->player ||
- (call_by->player && Priv_Who(call_by->player) && (doing))) {
- sprintf(tbuf1, "%-16s %4s %10s %4s%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""), empabb(d->player),
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time),
- (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' '))
- , d->doing);
- }
+ if (!Hidden(d)
+ || call_by->player == d->player ||
+ (call_by->player && Priv_Who(call_by->player) && (doing))) {
+ sprintf(tbuf1, "%-16s %4s %10s %4s%c %s", tprintf("%s%s", Name(d->player), InProg(d->player) ? "(P)" : ""), empabb(d->player),
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time),
+ (Dark(d->player) ? 'D' : (Hidden(d) ? 'H' : ' '))
+ , d->doing);
+ }
}
if (!Hidden(d) || (call_by->player && Priv_Who(call_by->player))) {
#ifdef COLOREDWHO
- if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount % 2 ? "" : ANSI_HILITE),
- (tcount % 2 ? ANSI_CYAN : ANSI_WHITE),
- tbuf1, ANSI_NORMAL));
+ if(ShowAnsiColor(call_by->player))
+ queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount % 2 ? "" : ANSI_HILITE),
+ (tcount % 2 ? ANSI_CYAN : ANSI_WHITE),
+ tbuf1, ANSI_NORMAL));
- else
+ else
#endif
- queue_string(call_by, tbuf1);
- queue_newwrite(call_by, (unsigned char *) "\r\n", 2);
+ queue_string(call_by, tbuf1);
+ queue_newwrite(call_by, (unsigned char *) "\r\n", 2);
}
} else if (call_by->player && Priv_Who(call_by->player) && doing != 1
- && (!match || !*match)) {
+ && (!match || !*match)) {
#ifdef COLOREDWHO
tcount++;
#endif
if (doing == 0) {
- /* Privileged WHO for non-logged in connections */
- sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s", T("Connecting..."),
- "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), d->cmds, d->descriptor,
+ /* Privileged WHO for non-logged in connections */
+ sprintf(tbuf1, "%-16s %6s %9s %5s %4d %3d%c %s", T("Connecting..."),
+ "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), d->cmds, d->descriptor,
#ifdef COMPILE_CONSOLE
- ' ',
+ ' ',
#else /* COMPILE_CONSOLE */
- #ifdef HAS_OPENSSL
- d->ssl ? 'S' : ' ',
- #else
- ' ',
- #endif
+ #ifdef HAS_OPENSSL
+ d->ssl ? 'S' : ' ',
+ #else
+ ' ',
+ #endif
#endif /* COMPILE_CONSOLE */
- d->addr);
- tbuf1[78] = '\0';
+ d->addr);
+ tbuf1[78] = '\0';
} else {
- /* SESSION for non-logged in connections */
- sprintf(tbuf1, "%-16s %5s %9s %5s %5d %3d%c %5lu %7lu %5d",
- T("Connecting..."), "#-1",
- time_format_1(now - d->connected_at),
- time_format_2(now - d->last_time), d->cmds, d->descriptor,
+ /* SESSION for non-logged in connections */
+ sprintf(tbuf1, "%-16s %5s %9s %5s %5d %3d%c %5lu %7lu %5d",
+ T("Connecting..."), "#-1",
+ time_format_1(now - d->connected_at),
+ time_format_2(now - d->last_time), d->cmds, d->descriptor,
#ifdef COMPILE_CONSOLE
- ' ',
+ ' ',
#else /* COMPILE_CONSOLE */
- #ifdef HAS_OPENSSL
- d->ssl ? 'S' : ' ',
- #else
- ' ',
- #endif
+ #ifdef HAS_OPENSSL
+ d->ssl ? 'S' : ' ',
+ #else
+ ' ',
+ #endif
#endif /* COMPILE_CONSOLE */
- d->input_chars, d->output_chars, d->output_size);
+ d->input_chars, d->output_chars, d->output_size);
}
#ifdef COLOREDWHO
if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL,tcount % 2 ? "" : ANSI_HILITE,
- tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
+ queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL,tcount % 2 ? "" : ANSI_HILITE,
+ tcount % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
else
#endif
- queue_string(call_by, tbuf1);
+ queue_string(call_by, tbuf1);
queue_newwrite(call_by, (unsigned char *) "\r\n", 2);
}
}
#ifdef COLOREDWHO
if(ShowAnsiColor(call_by->player))
- queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount+1) % 2 ? "" : ANSI_HILITE ,
- (tcount+1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
+ queue_string(call_by, tprintf("%s%s%s%s%s", ANSI_NORMAL, (tcount+1) % 2 ? "" : ANSI_HILITE ,
+ (tcount+1) % 2 ? ANSI_CYAN : ANSI_WHITE, tbuf1, ANSI_NORMAL));
else
#endif
- queue_string(call_by, tbuf1);
+ queue_string(call_by, tbuf1);
if (SUPPORT_PUEBLO && (call_by->conn_flags & CONN_HTML)) {
queue_newwrite(call_by, (unsigned char *) "\n</PRE>\n", 8);
queue_newwrite(call_by, (unsigned char *) "<img xch_mode=purehtml>", 23);
time_format_1(long dt)
{
register struct tm *delta;
- time_t holder; /* A hack for 64bit SGI */
+ time_t holder; /* A hack for 64bit SGI */
static char buf[64];
if (dt < 0)
dt = 0;
delta = gmtime(&holder);
if (delta->tm_yday > 0) {
sprintf(buf, "%dd %02d:%02d",
- delta->tm_yday, delta->tm_hour, delta->tm_min);
+ delta->tm_yday, delta->tm_hour, delta->tm_min);
} else {
sprintf(buf, "%02d:%02d", delta->tm_hour, delta->tm_min);
}
/* Redundant, but better for translators */
if (Dark(player)) {
sprintf(tbuf1, (num > 1) ? T("%s has DARK-reconnected.") :
- T("%s has DARK-connected."), Name(player));
+ T("%s has DARK-connected."), Name(player));
} else if (hidden(player)) {
sprintf(tbuf1, (num > 1) ? T("%s has HIDDEN-reconnected.") :
- T("%s has HIDDEN-connected."), Name(player));
+ T("%s has HIDDEN-connected."), Name(player));
} else {
sprintf(tbuf1, (num > 1) ? T("%s has reconnected.") :
- T("%s has connected."), Name(player));
+ T("%s has connected."), Name(player));
}
/* send out messages */
case TYPE_ROOM:
/* check every object in the room for a connect action */
DOLIST(obj, Contents(zone)) {
- (void) queue_attribute(obj, "ACONNECT", player);
+ (void) queue_attribute(obj, "ACONNECT", player);
}
break;
default:
do_log(LT_ERR, 0, 0,
- T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
- Name(player), player, Typeof(zone));
+ T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
+ Name(player), player, Typeof(zone));
}
}
/* now try the master room */
if (ANNOUNCE_CONNECTS) {
if (!Dark(player))
- notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
+ notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
/* notify contents */
notify_except(Contents(player), player, tbuf1, 0);
}
(void) queue_attribute(SDIV(player).object, "ADISCONNECT", player);
if (ROOM_CONNECTS)
if (IsRoom(loc) || IsThing(loc)) {
- (void) queue_attribute(loc, "ADISCONNECT", player);
+ (void) queue_attribute(loc, "ADISCONNECT", player);
}
/* do the zone of the player's location's possible adisconnect */
if ((zone = Zone(loc)) != NOTHING) {
switch (Typeof(zone)) {
case TYPE_DIVISION:
case TYPE_THING:
- (void) queue_attribute(zone, "ADISCONNECT", player);
- break;
+ (void) queue_attribute(zone, "ADISCONNECT", player);
+ break;
case TYPE_ROOM:
- /* check every object in the room for a connect action */
- DOLIST(obj, Contents(zone)) {
- (void) queue_attribute(obj, "ADISCONNECT", player);
- }
- break;
+ /* check every object in the room for a connect action */
+ DOLIST(obj, Contents(zone)) {
+ (void) queue_attribute(obj, "ADISCONNECT", player);
+ }
+ break;
default:
- do_log(LT_ERR, 0, 0,
- T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
- Name(player), player, Typeof(zone));
+ do_log(LT_ERR, 0, 0,
+ T("Invalid zone #%d for %s(#%d) has bad type %d"), zone,
+ Name(player), player, Typeof(zone));
}
}
/* now try the master room */
if (ANNOUNCE_CONNECTS) {
if (!Dark(player))
- notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
+ notify_except(Contents(loc), player, tbuf1, NA_INTER_PRESENCE);
/* notify contents */
notify_except(Contents(player), player, tbuf1, 0);
}
/* Redundant, but better for translators */
if (Dark(player)) {
sprintf(tbuf1, (num < 2) ? T("%s has DARK-disconnected.") :
- T("%s has partially DARK-disconnected."), Name(player));
+ T("%s has partially DARK-disconnected."), Name(player));
} else if (hidden(player)) {
sprintf(tbuf1, (num < 2) ? T("%s has HIDDEN-disconnected.") :
- T("%s has partially HIDDEN-disconnected."), Name(player));
+ T("%s has partially HIDDEN-disconnected."), Name(player));
} else {
sprintf(tbuf1, (num < 2) ? T("%s has disconnected.") :
- T("%s has partially disconnected."), Name(player));
+ T("%s has partially disconnected."), Name(player));
}
if (!Dark(player))
flag_broadcast(0, "MONITOR", "%s %s", T("GAME:"), tbuf1);
if (!Site(player) && key != MOTD_LIST) {
notify(player,
- T
- ("You may get 15 minutes of fame and glory in life, but not right now."));
+ T
+ ("You may get 15 minutes of fame and glory in life, but not right now."));
return;
}
switch (key) {
/* now smash undesirable characters and truncate */
for (i = 0; i < DOING_LEN; i++) {
if ((buf[i] == '\r') || (buf[i] == '\n') ||
- (buf[i] == '\t') || (buf[i] == BEEP_CHAR))
+ (buf[i] == '\t') || (buf[i] == BEEP_CHAR))
buf[i] = ' ';
}
buf[DOING_LEN - 1] = '\0';
strcpy(d->doing, buf);
if (strlen(message) >= DOING_LEN) {
notify_format(player,
- T("Doing set. %zu characters lost."),
- strlen(message) - (DOING_LEN - 1));
+ T("Doing set. %zu characters lost."),
+ strlen(message) - (DOING_LEN - 1));
} else
notify(player, T("Doing set."));
}
strncpy(poll_msg, remove_markup(message, NULL), DOING_LEN - 1);
for (i = 0; i < DOING_LEN; i++) {
if ((poll_msg[i] == '\r') || (poll_msg[i] == '\n') ||
- (poll_msg[i] == '\t') || (poll_msg[i] == BEEP_CHAR))
+ (poll_msg[i] == '\t') || (poll_msg[i] == BEEP_CHAR))
poll_msg[i] = ' ';
}
poll_msg[DOING_LEN - 1] = '\0';
if (strlen(message) >= DOING_LEN) {
poll_msg[DOING_LEN - 1] = 0;
notify_format(player,
- T("Poll set to '%s'. %zu characters lost."), poll_msg,
- strlen(message) - (DOING_LEN - 1));
+ T("Poll set to '%s'. %zu characters lost."), poll_msg,
+ strlen(message) - (DOING_LEN - 1));
} else
notify_format(player, T("Poll set to: %s"), poll_msg);
do_log(LT_WIZ, player, NOTHING, T("Poll Set to '%s'."), poll_msg);
for (d = descriptor_list; d; d = d->next) {
if (d->connected) {
if (match && !string_prefix(Name(d->player), match))
- continue;
+ continue;
if (!strcasecmp(Name(d->player), match)) {
- count = 1;
- who1 = d->player;
- break;
+ count = 1;
+ who1 = d->player;
+ break;
}
if (who1 == NOTHING || d->player != who1) {
- who1 = d->player;
- count++;
+ who1 = d->player;
+ count++;
}
}
}
if(xwho) {
if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) {
- safe_str(T(e_int), buff, bp);
- return;
+ safe_str(T(e_int), buff, bp);
+ return;
}
start = parse_integer(args[0]) - 1;
DESC_ITER_CONN(d) {
if (!Hidden(d) || (powered && CanSee(victim,d->player))) {
if(xwho && start) {
- start--;
- continue;
+ start--;
+ continue;
} else if(xwho && !count)
- break;
+ break;
else if(xwho && count)
- count--;
+ count--;
if (first)
- first = 0;
+ first = 0;
else
- safe_chr(' ', buff, bp);
+ safe_chr(' ', buff, bp);
safe_dbref(d->player, buff, bp);
if(objid) {
- safe_chr(':', buff, bp);
- safe_integer(CreTime(d->player), buff, bp);
+ safe_chr(':', buff, bp);
+ safe_integer(CreTime(d->player), buff, bp);
}
}
}
int fd = parse_integer(name);
DESC_ITER_CONN(d) {
if (d->descriptor == fd) {
- if (Priv_Who(executor) || d->player == executor
- || (Inherit_Powers(executor) && Priv_Who(Owner(executor))))
- return d;
- else
- return NULL;
+ if (Priv_Who(executor) || d->player == executor
+ || (Inherit_Powers(executor) && Priv_Who(Owner(executor))))
+ return d;
+ else
+ return NULL;
}
}
return NULL;
dbref target = lookup_player(name);
if (target == NOTHING) {
target = match_result(executor, name, TYPE_PLAYER,
- MAT_ABSOLUTE | MAT_PLAYER | MAT_ME);
+ MAT_ABSOLUTE | MAT_PLAYER | MAT_ME);
}
if (!GoodObject(target) || !Connected(target))
return NULL;
else {
/* walk the descriptor list looking for a match of a dbref */
DESC_ITER_CONN(d) {
- if ((d->player == target) &&
- (!Hidden(d) || Priv_Who(executor) ||
- (Inherit_Powers(executor) && Priv_Who(Owner(executor)))) &&
- (!match || (d->last_time > match->last_time)))
- match = d;
+ if ((d->player == target) &&
+ (!Hidden(d) || Priv_Who(executor) ||
+ (Inherit_Powers(executor) && Priv_Who(Owner(executor)))) &&
+ (!match || (d->last_time > match->last_time)))
+ match = d;
}
return match;
}
DESC *d, *match = NULL;
DESC_ITER_CONN(d) {
if ((d->player == player) && !Hidden(d) && (!match ||
- (d->connected_at >
- match->connected_at)))
+ (d->connected_at >
+ match->connected_at)))
match = d;
}
if (match) {
DESC *d, *match = NULL;
DESC_ITER_CONN(d) {
if ((d->player == player) && (!match ||
- (d->connected_at > match->connected_at)))
+ (d->connected_at > match->connected_at)))
match = d;
}
if (match) {
DESC *d, *match = NULL;
DESC_ITER_CONN(d) {
if ((d->player == player) && !Hidden(d) &&
- (!match || (d->last_time > match->last_time)))
+ (!match || (d->last_time > match->last_time)))
match = d;
}
if (match) {
DESC_ITER_CONN(d) {
if (Zone(Location(d->player)) == zone &&
- (!Hidden(d) || (powered && CanSee(victim, d->player))) ) {
- if (first) {
- first = 0;
- } else {
- safe_chr(' ', buff, bp);
- }
- safe_dbref(d->player, buff, bp);
+ (!Hidden(d) || (powered && CanSee(victim, d->player))) ) {
+ if (first) {
+ first = 0;
+ } else {
+ safe_chr(' ', buff, bp);
+ }
+ safe_dbref(d->player, buff, bp);
}
}
}
if (match->player == executor || Site(executor)) {
safe_str(match->ttype, buff, bp);
if (match->conn_flags & CONN_HTML)
- safe_str(" pueblo", buff, bp);
+ safe_str(" pueblo", buff, bp);
if (match->conn_flags & CONN_TELNET)
- safe_str(" telnet", buff, bp);
+ safe_str(" telnet", buff, bp);
#ifndef COMPILE_CONSOLE
#ifdef HAS_OPENSSL
if (sslsock && match->ssl)
- safe_str(" ssl", buff, bp);
+ safe_str(" ssl", buff, bp);
#endif
#endif
} else
if(match) {
safe_number((difftime(mudtime, match->last_time) >= 300) ?
- (match->unidle_times+1) : match->unidle_times, buff, bp);
+ (match->unidle_times+1) : match->unidle_times, buff, bp);
} else
safe_str("-1", buff, bp);
}
int first = 1;
if (!Priv_Who(executor)
- && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
+ && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
safe_str(T(e_perm), buff, bp);
return;
}
target = lookup_player(args[0]);
if (target == NOTHING) {
target = match_result(executor, args[0], TYPE_PLAYER,
- MAT_ABSOLUTE | MAT_PLAYER | MAT_ME);
+ MAT_ABSOLUTE | MAT_PLAYER | MAT_ME);
}
if (target != executor && !Priv_Who(executor)
- && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
+ && !(Inherit_Powers(executor) && Priv_Who(Owner(executor)))) {
/* This should probably be a safe_str */
notify(executor, T("Permission denied."));
return;
DESC_ITER_CONN(d) {
if (d->player == target) {
if (first)
- first = 0;
+ first = 0;
else
- safe_chr(' ', buff, bp);
+ safe_chr(' ', buff, bp);
safe_integer(d->descriptor, buff, bp);
}
}
if (Can_Hide(player)) {
DESC_ITER_CONN(d) {
if (d->player == player)
- d->hide = hide;
+ d->hide = hide;
}
}
if (hide)
if ((d->conn_flags & CONN_TELNET_QUERY) && idle_for > 60)
d->conn_flags &= ~CONN_TELNET_QUERY;
if(d->connected && GoodObject(d->player) && ((a = atr_get(d->player, "IDLE_TIMEOUT"))!=NULL)) {
- memset(tbuf, '\0', BUFFER_LEN);
- strncpy(tbuf, atr_value(a), BUFFER_LEN-1);
- idle = atoi(tbuf);
- if(idle > 0)
- goto after_idle_atr_check;
+ memset(tbuf, '\0', BUFFER_LEN);
+ strncpy(tbuf, atr_value(a), BUFFER_LEN-1);
+ idle = atoi(tbuf);
+ if(idle > 0)
+ goto after_idle_atr_check;
}
idle = INACTIVITY_LIMIT ? INACTIVITY_LIMIT : INT_MAX;
after_idle_atr_check:
if ((d->connected) ? (idle_for > idle ) : (idle_for > unconnected_idle)) {
if (!d->connected)
- shutdownsock(d);
+ shutdownsock(d);
else if (!Can_Idle(d->player)) {
- queue_string(d, T("\n*** Inactivity timeout ***\n"));
- do_log(LT_CONN, 0, 0,
- T("[%d/%s/%s] Logout by %s(#%d) <Inactivity Timeout>"),
- d->descriptor, d->addr, d->ip, Name(d->player), d->player);
- boot_desc(d);
+ queue_string(d, T("\n*** Inactivity timeout ***\n"));
+ do_log(LT_CONN, 0, 0,
+ T("[%d/%s/%s] Logout by %s(#%d) <Inactivity Timeout>"),
+ d->descriptor, d->addr, d->ip, Name(d->player), d->player);
+ boot_desc(d);
} else if (Unfind(d->player)) {
- if ((Can_Hide(d->player)) && (!Hidden(d))) {
- queue_string(d,
- T
- ("\n*** Inactivity limit reached. You are now HIDDEN. ***\n"));
- d->hide = 1;
- }
+ if ((Can_Hide(d->player)) && (!Hidden(d))) {
+ queue_string(d,
+ T
+ ("\n*** Inactivity limit reached. You are now HIDDEN. ***\n"));
+ d->hide = 1;
+ }
}
}
}
DESC_ITER_CONN(d) {
if (d->player == player) {
if (Hidden(d))
- return 1;
+ return 1;
else
- return 0;
+ return 0;
}
}
return 0;
}
#define fclose(x) f_close(x)
-#endif /* SUN_OS */
+#endif /* SUN_OS */
#ifdef COMPILE_CONSOLE
void
#ifdef HAS_SYSCONF
errno = 0;
if ((open_max = sysconf(_SC_OPEN_MAX)) < 0) {
- if (errno == 0) /* Value was indeterminate */
+ if (errno == 0) /* Value was indeterminate */
open_max = 0;
}
if (open_max)
*/
open_max = 0;
return getdtablesize();
-#endif /* WIN 32 */
+#endif /* WIN 32 */
}
#ifdef HAS_OPENSSL
DESC *d;
SU_PATH *exit_path;
long flags = RDBF_SCREENSIZE | RDBF_TTYPE | RDBF_PUEBLO_CHECKSUM
- | RDBF_SU_EXIT_PATH;
+ | RDBF_SU_EXIT_PATH;
if (setjmp(db_err)) {
flag_broadcast(0, 0, T("GAME: Error writing reboot database!"));
exit(0);
putref(f, d->idle_total);
putref(f, d->unidle_times);
if (GoodObject(d->player))
- putref(f, d->player);
+ putref(f, d->player);
else
- putref(f, -1);
+ putref(f, -1);
putref(f, d->last_time);
if (d->output_prefix)
- putstring(f, (char *) d->output_prefix);
+ putstring(f, (char *) d->output_prefix);
else
- putstring(f, "__NONE__");
+ putstring(f, "__NONE__");
if (d->output_suffix)
- putstring(f, (char *) d->output_suffix);
+ putstring(f, (char *) d->output_suffix);
else
- putstring(f, "__NONE__");
+ putstring(f, "__NONE__");
putstring(f, d->addr);
putstring(f, d->ip);
putstring(f, d->doing);
for(exit_path = d->su_exit_path; exit_path; exit_path = exit_path->next)
putref(f, exit_path->player);
putref(f, NOTHING);
- } /* for loop */
+ } /* for loop */
putref(f, 0);
putstring(f, poll_msg);
* If not, assume we're using the original format, in which the
* sock appears first
* */
- c = getc(f); /* Skip the V */
+ c = getc(f); /* Skip the V */
if (c == 'V') {
flags = getref(f);
} else {
* separate list.
*/
if (closed)
- closed->prev = d;
+ closed->prev = d;
d->next = closed;
d->prev = NULL;
closed = d;
} else {
if (descriptor_list)
- descriptor_list->prev = d;
+ descriptor_list->prev = d;
d->next = descriptor_list;
d->prev = NULL;
descriptor_list = d;
if (d->connected && d->player && GoodObject(d->player) &&
- IsPlayer(d->player))
- set_flag_internal(d->player, "CONNECTED");
+ IsPlayer(d->player))
+ set_flag_internal(d->player, "CONNECTED");
else if ((!d->player || !GoodObject(d->player)) && d->connected) {
- d->connected = 0;
- d->player = 0;
+ d->connected = 0;
+ d->player = 0;
}
/* If they were in a program, get them back into it */
if(d->connected && InProg(d->player))
prog_load_desc(d);
}
- } /* while loop */
+ } /* while loop */
/* Now announce disconnects of everyone who's not really here */
while (closed) {
}
snprintf(tbuf1, BUFFER_LEN-1, "%ld %ld %d %d", (mudtime - closed->connected_at),
- closed->idle_total , closed->unidle_times, closed->cmds);
+ closed->idle_total , closed->unidle_times, closed->cmds);
tbuf1[strlen(tbuf1)+1] = '\0';
(void) atr_add(closed->player, "LASTACTIVITY", tbuf1, GOD, NOTHING);
announce_disconnect(closed->player);
char buf[BUFFER_LEN], *bp;
if(SW_ISSET(sw, SWITCH_LIST)) {
- descn = atoi(arg_left);
+ descn = atoi(arg_left);
- bp = buf;
+ bp = buf;
- d = port_desc(descn);
+ d = port_desc(descn);
if (LEVEL(player) <= 28) {
- notify(player, MSG_HUH);
- return;
- }
- /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
- if(!d || (d && !IsPlayer(d->player))) {
- notify(player, "There is no one connected on that descriptor.");
- return;
- }
-
- for(sn = 0, n = 0; n < MAX_SNOOPS; n++)
- if(d->snooper[n] != -1) {
- memset(snooplist[sn], '\0', BUFFER_LEN);
- snprintf(snooplist[sn++], BUFFER_LEN-1, "%s", Name(d->snooper[n]));
- }
- *snooplist[sn] = '\0';
-
- for(n = 0; n < sn; n++) {
- if(n != 0)
- safe_str(", ", buf, &bp);
- if(n == (sn-1) && sn > 1)
- safe_str("& ", buf, &bp);
- safe_str(snooplist[n], buf, &bp);
- }
- *bp = '\0';
- notify_format(player, "%s is being snooped on by: %s", Name(d->player), buf);
+ notify(player, MSG_HUH);
+ return;
+ }
+ /* make sure teh desc exists and they're connected (no spying on 'em at the connect screen!) */
+ if(!d || (d && !IsPlayer(d->player))) {
+ notify(player, "There is no one connected on that descriptor.");
+ return;
+ }
+
+ for(sn = 0, n = 0; n < MAX_SNOOPS; n++)
+ if(d->snooper[n] != -1) {
+ memset(snooplist[sn], '\0', BUFFER_LEN);
+ snprintf(snooplist[sn++], BUFFER_LEN-1, "%s", Name(d->snooper[n]));
+ }
+ *snooplist[sn] = '\0';
+
+ for(n = 0; n < sn; n++) {
+ if(n != 0)
+ safe_str(", ", buf, &bp);
+ if(n == (sn-1) && sn > 1)
+ safe_str("& ", buf, &bp);
+ safe_str(snooplist[n], buf, &bp);
+ }
+ *bp = '\0';
+ notify_format(player, "%s is being snooped on by: %s", Name(d->player), buf);
} else {
if(*arg_left== '!') {
}
if(on) {
- if((d->player == player)) {
- notify(player, "You can't snoop yourself.");
- return;
- }
+ if((d->player == player)) {
+ notify(player, "You can't snoop yourself.");
+ return;
+ }
switch(set_snoop(player,d)) {
case -1: /* Too Many */
} else {
for(on = n = 0; n < MAX_SNOOPS; n++)
if(d->snooper[n] == player) {
- d->snooper[n] = -1;
- on = 1;
+ d->snooper[n] = -1;
+ on = 1;
}
notify(player, on ? "Snoop deactivated." : "Snooping Error.");
}
continue;
if(dir == 1) /* player sees */
notify_format((dbref) d->snooper[n], T("%s%s<-%s %s"),
- object_header(d->snooper[n],d->player),
- ANSI_BLUE, ANSI_NORMAL, snstr);
+ object_header(d->snooper[n],d->player),
+ ANSI_BLUE, ANSI_NORMAL, snstr);
else /* player types */
notify_format((dbref) d->snooper[n], T("%s%s->%s %s%s"),
- object_header(d->snooper[n],d->player),
- ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL);
+ object_header(d->snooper[n],d->player),
+ ANSI_BLUE, ANSI_RED, snstr, ANSI_NORMAL);
}
}
if(!strcasecmp(cmd->name, "@SD")) {
target = match_result(player, arg_left, TYPE_DIVISION, MAT_EVERYTHING);
if(!GoodObject(target) || Typeof(target) != TYPE_DIVISION) {
- notify(player, "No such division.");
- return;
+ notify(player, "No such division.");
+ return;
}
/* Check to see if special conditions exist, where they can enter without a password */
if(controls(player, target)) { /* condition 1: they control it */
- /* trigger did_it on exiting division.. Possibly save their exiting values, for if they come back in? */
- did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
- add_to_div_exit_path(player, Division(player));
- Division(player) = target;
- /* triger did_it on incoming division.. to i guess set 'em for something.. *shrugs* */
- did_it(player, Division(player), "SDIN", tprintf("You have switched into Division: %s", object_header(player, Division(player)))
- , NULL, NULL, "ASDIN", Location(player));
- return;
+ /* trigger did_it on exiting division.. Possibly save their exiting values, for if they come back in? */
+ did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
+ add_to_div_exit_path(player, Division(player));
+ Division(player) = target;
+ /* triger did_it on incoming division.. to i guess set 'em for something.. *shrugs* */
+ did_it(player, Division(player), "SDIN", tprintf("You have switched into Division: %s", object_header(player, Division(player)))
+ , NULL, NULL, "ASDIN", Location(player));
+ return;
}
/* get least idle desc */
DESC_ITER_CONN(d)
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
- match = d;
+ if ((d->player == player) && (!match || (d->last_time > match->last_time)))
+ match = d;
/* We're only entering using a password at this moment */
#ifdef COMPILE_CONSOLE
- queue_newwrite(match, (unsigned char *) T("Password: "), 13);
+ queue_newwrite(match, (unsigned char *) T("Password: "), 13);
#else /* COMPILE_CONSOLE */
- queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
- IAC, GOAHEAD), 13);
+ queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
+ IAC, GOAHEAD), 13);
#endif /* COMPILE_CONSOLE */
- if(!PromptConnection(match))
- queue_newwrite(match, (unsigned char *) "\r\n", 3);
+ if(!PromptConnection(match))
+ queue_newwrite(match, (unsigned char *) "\r\n", 3);
- match->input_handler = password_handler;
- match->pinfo.object = target;
- match->pinfo.function = &pw_div_connect;
- match->pinfo.lock = 0x40;
+ match->input_handler = password_handler;
+ match->pinfo.object = target;
+ match->pinfo.function = &pw_div_connect;
+ match->pinfo.lock = 0x40;
} else {
target = lookup_player(arg_left);
if(target == NOTHING) {
- notify(player, "No such player.");
- return;
+ notify(player, "No such player.");
+ return;
}
do_log(LT_WIZ, player, target, "** @SU ATTEMPT **");
/* get least idle desc */
DESC_ITER_CONN(d)
- if ((d->player == player) && (!match || (d->last_time > match->last_time)))
- match = d;
+ if ((d->player == player) && (!match || (d->last_time > match->last_time)))
+ match = d;
/* Step 2. Find if we can get in without a pass, if
* we need a pass. Throw them into password_handler() internal
* prompt
*/
if(div_powover(player, target, "@SU")) {
- do_log(LT_WIZ, player, target, "** @SU SUCCESS **");
- /* Phase 3a. Put Guy in user */
- add_to_exit_path(match, player);
- announce_disconnect(player);
- match->player = target;
+ do_log(LT_WIZ, player, target, "** @SU SUCCESS **");
+ /* Phase 3a. Put Guy in user */
+ add_to_exit_path(match, player);
+ announce_disconnect(player);
+ match->player = target;
#ifdef USE_MAILER
- match->mailp = find_exact_starting_point(target);
-#endif
- is_hidden = Can_Hide(target) && Dark(target);
- DESC_ITER_CONN(d)
- if(d->player == player) {
- num++;
- if(is_hidden)
- d->hide = 1;
- }
-
- if(ModTime(target))
- notify_format(target, T("%ld failed connections since last login."), ModTime(target));
- announce_connect(target, 0, num);
- check_last(target, match->addr, match->ip); /* set last, lastsite, give paycheck */
- queue_eol(match);
+ match->mailp = find_exact_starting_point(target);
+#endif
+ is_hidden = Can_Hide(target) && Dark(target);
+ DESC_ITER_CONN(d)
+ if(d->player == player) {
+ num++;
+ if(is_hidden)
+ d->hide = 1;
+ }
+
+ if(ModTime(target))
+ notify_format(target, T("%ld failed connections since last login."), ModTime(target));
+ announce_connect(target, 0, num);
+ check_last(target, match->addr, match->ip); /* set last, lastsite, give paycheck */
+ queue_eol(match);
#ifdef USE_MAILER
- if(command_check_byname(target, "@MAIL"))
- check_mail(target, 0, 0);
- set_player_folder(target, 0);
+ if(command_check_byname(target, "@MAIL"))
+ check_mail(target, 0, 0);
+ set_player_folder(target, 0);
#endif
- do_look_around(target);
- if(Haven(target))
- notify(player, T("Your HAVEN flag is set. You cannot receive pages."));
+ do_look_around(target);
+ if(Haven(target))
+ notify(player, T("Your HAVEN flag is set. You cannot receive pages."));
} else {
- /* Part 3b. Put guy in password program */
+ /* Part 3b. Put guy in password program */
#ifdef COMPILE_CONSOLE
- queue_newwrite(match, (unsigned char *) T("Password: "), 13);
+ queue_newwrite(match, (unsigned char *) T("Password: "), 13);
#else /* COMPILE_CONSOLE */
- queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
- IAC, GOAHEAD), 13);
+ queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"),
+ IAC, GOAHEAD), 13);
#endif /* COMPILE_CONSOLE */
- if(!PromptConnection(match))
- queue_newwrite(match, (unsigned char *) "\r\n", 3);
+ if(!PromptConnection(match))
+ queue_newwrite(match, (unsigned char *) "\r\n", 3);
- match->input_handler = password_handler;
- match->pinfo.object = target;
- match->pinfo.function = &pw_player_connect;
- match->pinfo.lock = 0x40;
+ match->input_handler = password_handler;
+ match->pinfo.object = target;
+ match->pinfo.function = &pw_player_connect;
+ match->pinfo.lock = 0x40;
}
}
} else {
divrcd = atr_get(player, "XYXX_DIVRCD");
if(divrcd == NULL) {
- notify(player, "You have not switched into any divisions.");
- return;
+ notify(player, "You have not switched into any divisions.");
+ return;
}
cnt = list2arr(p_buf, BUFFER_LEN / 2, safe_atr_value(divrcd), ' ');
if(cnt < 1) {
- notify(player, "You have not switched into any divisions.");
- return;
+ notify(player, "You have not switched into any divisions.");
+ return;
}
/* Set them into cnt-1 if its good */
div_obj = parse_number(p_buf[cnt-1]);
if(GoodObject(div_obj) && IsDivision(div_obj)) {
- /* Trigger ASDOUT */
- did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
- Division(player) = div_obj;
- /* Trigger SDIN */
- did_it(player, Division(player), "SDIN", tprintf("You have went back to your other division: %s", object_header(player, div_obj))
- , NULL, NULL, "ASDIN", Location(player));
+ /* Trigger ASDOUT */
+ did_it(player, Division(player), "SDOUT", NULL, NULL, NULL, "ASDOUT", Location(player));
+ Division(player) = div_obj;
+ /* Trigger SDIN */
+ did_it(player, Division(player), "SDIN", tprintf("You have went back to your other division: %s", object_header(player, div_obj))
+ , NULL, NULL, "ASDIN", Location(player));
}
/* now chop off last one, and arr2list() */
if(cnt == 1) { /* clear the attribute */
- atr_clr(player, "XYXX_DIVRCD", GOD);
+ atr_clr(player, "XYXX_DIVRCD", GOD);
} else {
- memset(tbuf, '\0', BUFFER_LEN);
- tbp = tbuf;
- sep[0] = ' ';
- sep[1] = '\0';
- arr2list(p_buf, cnt-1, tbuf, &tbp, sep);
- /* Add the attribute back */
- (void) atr_add(player, "XYXX_DIVRCD", tbuf, GOD, NOTHING);
+ memset(tbuf, '\0', BUFFER_LEN);
+ tbp = tbuf;
+ sep[0] = ' ';
+ sep[1] = '\0';
+ arr2list(p_buf, cnt-1, tbuf, &tbp, sep);
+ /* Add the attribute back */
+ (void) atr_add(player, "XYXX_DIVRCD", tbuf, GOD, NOTHING);
}
} else {
notify(player, "Must specify what player you wish to @su into.");
path_entry = d->su_exit_path;
while(path_entry)
if(GoodObject(path_entry->player) && IsPlayer(path_entry->player))
- break;
+ break;
else { /* Guess the guy got nuked along the way.. free the spot */
- mark_path = path_entry;
- path_entry = path_entry->next;
- mush_free(mark_path, "SU_PATH_ENTRY");
+ mark_path = path_entry;
+ path_entry = path_entry->next;
+ mush_free(mark_path, "SU_PATH_ENTRY");
}
d->su_exit_path = path_entry;
if(!path_entry)
is_hidden = Can_Hide(d->player) && Dark(d->player);
DESC_ITER_CONN(c)
if(c->player == d->player) {
- num++;
- if(is_hidden)
- c->hide = 1;
+ num++;
+ if(is_hidden)
+ c->hide = 1;
}
if(ModTime(d->player))
notify_format(d->player, T("%ld failed connections since last login."), ModTime(d->player));
{
if (player == NOTHING) {
flag_broadcast(0, 0,
- T
- ("GAME: Reboot w/o disconnect from game account, please wait."));
+ T
+ ("GAME: Reboot w/o disconnect from game account, please wait."));
} else {
flag_broadcast(0, 0,
- T
- ("GAME: Reboot w/o disconnect by %s, please wait."),
- Name(Owner(player)));
+ T
+ ("GAME: Reboot w/o disconnect by %s, please wait."),
+ Name(Owner(player)));
}
if (flag) {
globals.paranoid_dump = 1;
execl("netmush", "netmush", confname, NULL);
#else
execl("cobramush.exe", "cobramush.exe", "/run", NULL);
-#endif /* WIN32 */
- exit(1); /* Shouldn't ever get here, but just in case... */
+#endif /* WIN32 */
+ exit(1); /* Shouldn't ever get here, but just in case... */
}
*/
char *
iter_bufferq(BUFFERQ * bq, char **p, dbref *player, int *type,
- time_t * timestamp)
+ time_t * timestamp)
{
static char tbuf1[BUFFER_LEN];
int size;
return NULL;
if (!*p)
- *p = bq->buffer; /* Reset to beginning */
+ *p = bq->buffer; /* Reset to beginning */
memcpy(&size, *p, sizeof(size));
*p += sizeof(size);
#include "confmagic.h"
#ifdef WIN32
-#pragma warning( disable : 4761) /* disable warning re conversion */
+#pragma warning( disable : 4761) /* disable warning re conversion */
#endif
/* A whole bunch of debugging #defines. */
/* debug... */
#ifdef CHUNK_DEBUG
#define ASSERT(x) assert(x)
-#else /* CHUNK_DEBUG */
-static int ignore; /**< Used to shut up compiler warnings when not asserting */
+#else /* CHUNK_DEBUG */
+static int ignore; /**< Used to shut up compiler warnings when not asserting */
#define ASSERT(x) ignore++
-#endif /* CHUNK_DEBUG */
+#endif /* CHUNK_DEBUG */
/*
* Sizes, limits, etc.
* the rest of the 64K bytes of the region contain chunks.
*/
typedef struct region_header {
- u_int_16 region_id; /**< will be INVALID_REGION_ID if not in use */
- u_int_16 first_free; /**< offset of 1st free chunk */
- struct region_header *prev; /**< linked list prev for LRU cache */
- struct region_header *next; /**< linked list next for LRU cache */
+ u_int_16 region_id; /**< will be INVALID_REGION_ID if not in use */
+ u_int_16 first_free; /**< offset of 1st free chunk */
+ struct region_header *prev; /**< linked list prev for LRU cache */
+ struct region_header *next; /**< linked list next for LRU cache */
} RegionHeader;
#define FIRST_CHUNK_OFFSET_IN_REGION sizeof(RegionHeader)
/** In-memory (never paged) region info. */
typedef struct region {
- u_int_16 used_count; /**< number of used chunks */
- u_int_16 free_count; /**< number of free chunks */
- u_int_16 free_bytes; /**< number of free bytes (with headers) */
- u_int_16 largest_free_chunk; /**< largest single free chunk */
- unsigned int total_derefs; /**< total of all used chunk derefs */
- unsigned int period_last_touched; /**< "this" period, for deref counts;
+ u_int_16 used_count; /**< number of used chunks */
+ u_int_16 free_count; /**< number of free chunks */
+ u_int_16 free_bytes; /**< number of free bytes (with headers) */
+ u_int_16 largest_free_chunk; /**< largest single free chunk */
+ unsigned int total_derefs; /**< total of all used chunk derefs */
+ unsigned int period_last_touched; /**< "this" period, for deref counts;
we don't page in regions to update
counts on period change! */
- RegionHeader *in_memory; /**< cache entry; NULL if paged out */
- u_int_16 oddballs[NUM_ODDBALLS]; /**< chunk offsets with odd derefs */
+ RegionHeader *in_memory; /**< cache entry; NULL if paged out */
+ u_int_16 oddballs[NUM_ODDBALLS]; /**< chunk offsets with odd derefs */
} Region;
#define RegionDerefs(region) \
/*
* Info about all regions
*/
-static u_int_32 region_count; /**< regions in use */
-static u_int_32 region_array_len; /**< length of regions array */
-static Region *regions; /**< regions array, realloced as (rarely) needed */
+static u_int_32 region_count; /**< regions in use */
+static u_int_32 region_array_len; /**< length of regions array */
+static Region *regions; /**< regions array, realloced as (rarely) needed */
/*
* regions presently in memory
*/
-static u_int_32 cached_region_count; /**< number of regions in cache */
-static RegionHeader *cache_head; /**< most recently used region */
-static RegionHeader *cache_tail; /**< least recently used region */
+static u_int_32 cached_region_count; /**< number of regions in cache */
+static RegionHeader *cache_head; /**< most recently used region */
+static RegionHeader *cache_tail; /**< least recently used region */
/*
* statistics
*/
-static int stat_used_short_count; /**< How many short chunks? */
-static int stat_used_short_bytes; /**< How much space in short chunks? */
-static int stat_used_medium_count; /**< How many medium chunks? */
-static int stat_used_medium_bytes; /**< How much space in medium chunks? */
-static int stat_used_long_count; /**< How many long chunks? */
-static int stat_used_long_bytes; /**< How much space in long chunks? */
-static int stat_deref_count; /**< Dereferences this period */
-static int stat_deref_maxxed; /**< Number of chunks with max derefs */
+static int stat_used_short_count; /**< How many short chunks? */
+static int stat_used_short_bytes; /**< How much space in short chunks? */
+static int stat_used_medium_count; /**< How many medium chunks? */
+static int stat_used_medium_bytes; /**< How much space in medium chunks? */
+static int stat_used_long_count; /**< How many long chunks? */
+static int stat_used_long_bytes; /**< How much space in long chunks? */
+static int stat_deref_count; /**< Dereferences this period */
+static int stat_deref_maxxed; /**< Number of chunks with max derefs */
/** histogram for average derefs of regions being paged in/out */
static int stat_paging_histogram[CHUNK_DEREF_MAX + 1];
-static int stat_page_out; /**< Number of page-outs */
-static int stat_page_in; /**< Number of page-ins */
-static int stat_migrate_slide; /**< Number of slide migrations */
-static int stat_migrate_move; /**< Number of move migrations */
-static int stat_migrate_away; /**< Number of chunk evictions */
-static int stat_create; /**< Number of chunk creations */
-static int stat_delete; /**< Number of chunk deletions */
+static int stat_page_out; /**< Number of page-outs */
+static int stat_page_in; /**< Number of page-ins */
+static int stat_migrate_slide; /**< Number of slide migrations */
+static int stat_migrate_move; /**< Number of move migrations */
+static int stat_migrate_away; /**< Number of chunk evictions */
+static int stat_create; /**< Number of chunk creations */
+static int stat_delete; /**< Number of chunk deletions */
/*
* migration globals that are used for holding relevant data...
*/
-static int m_count; /**< The used length for the arrays. */
+static int m_count; /**< The used length for the arrays. */
static chunk_reference_t **m_references; /**< The passed-in references array. */
#ifdef CHUNK_PARANOID
rolling_pos = (rolling_pos + 1) % ROLLING_LOG_SIZE;
#else
if (format)
- return; /* shut up the compiler warning */
+ return; /* shut up the compiler warning */
#endif
}
rhp = rp->in_memory;
fprintf(fp, "region: id:%04x period:%-8x deref:%-8x (%-2x per chunk)\n",
- region, rp->period_last_touched, rp->total_derefs,
- RegionDerefs(region));
+ region, rp->period_last_touched, rp->total_derefs,
+ RegionDerefs(region));
fprintf(fp, " #used:%-4x #free:%-4x fbytes:%-4x hole:%-4x ",
- rp->used_count, rp->free_count, rp->free_bytes,
- rp->largest_free_chunk);
+ rp->used_count, rp->free_count, rp->free_bytes,
+ rp->largest_free_chunk);
if (rhp)
fprintf(fp, "first:%-4x h_id:%-4x\n", rhp->first_free, rhp->region_id);
else
if (rhp) {
for (offset = FIRST_CHUNK_OFFSET_IN_REGION;
- offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
+ offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
fprintf(fp, "chunk:%c%4s %-6s off:%04x full:%04x ",
- migratable(region, offset) ? '*' : ' ',
- ChunkIsFree(region, offset) ? "FREE" : "",
- ChunkIsShort(region, offset) ? "SHORT" :
- (ChunkIsMedium(region, offset) ? "MEDIUM" : "LONG"),
- offset, ChunkFullLen(region, offset));
+ migratable(region, offset) ? '*' : ' ',
+ ChunkIsFree(region, offset) ? "FREE" : "",
+ ChunkIsShort(region, offset) ? "SHORT" :
+ (ChunkIsMedium(region, offset) ? "MEDIUM" : "LONG"),
+ offset, ChunkFullLen(region, offset));
if (ChunkIsFree(region, offset)) {
- fprintf(fp, "next:%04x\n", ChunkNextFree(region, offset));
+ fprintf(fp, "next:%04x\n", ChunkNextFree(region, offset));
} else {
- fprintf(fp, "doff:%04x len:%04x ",
- ChunkDataPtr(region, offset) - (unsigned char *) rhp,
- ChunkLen(region, offset));
- count = ChunkDerefs(region, offset);
- if (count == 0xFF) {
- fprintf(fp, "deref:many\n");
- } else {
- fprintf(fp, "deref:%04x\n", count);
- }
+ fprintf(fp, "doff:%04x len:%04x ",
+ ChunkDataPtr(region, offset) - (unsigned char *) rhp,
+ ChunkLen(region, offset));
+ count = ChunkDerefs(region, offset);
+ if (count == 0xFF) {
+ fprintf(fp, "deref:many\n");
+ } else {
+ fprintf(fp, "deref:%04x\n", count);
+ }
}
}
}
pos < REGION_SIZE; pos += ChunkFullLen(region, pos)) {
if (pos == offset) {
if (ChunkIsFree(region, pos))
- mush_panic("Invalid reference to free chunk as used");
+ mush_panic("Invalid reference to free chunk as used");
return;
}
}
if (region >= region_count) {
do_rawlog(LT_ERR, "region 0x%04x is not valid: region_count is 0x%04x",
- region, region_count);
+ region, region_count);
return 0;
}
result = 1;
rp = regions + region;
if (rp->used_count > REGION_SIZE / MIN_REMNANT_LEN) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: chunk count is ludicrous: 0x%04x",
- region, rp->used_count);
+ "region 0x%04x is not valid: chunk count is ludicrous: 0x%04x",
+ region, rp->used_count);
result = 0;
}
if (rp->free_count > REGION_SIZE / MIN_REMNANT_LEN) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: free count is ludicrous: 0x%04x",
- region, rp->free_count);
+ "region 0x%04x is not valid: free count is ludicrous: 0x%04x",
+ region, rp->free_count);
result = 0;
}
if (rp->largest_free_chunk > rp->free_bytes) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: largest free chunk > free bytes:"
- " 0x%04x > 0x%04x",
- region, rp->largest_free_chunk, rp->free_bytes);
+ "region 0x%04x is not valid: largest free chunk > free bytes:"
+ " 0x%04x > 0x%04x",
+ region, rp->largest_free_chunk, rp->free_bytes);
result = 0;
}
if (!rp->in_memory)
if (rhp->region_id != region) {
do_rawlog(LT_ERR, "region 0x%04x is not valid: region in cache is 0x%04x",
- region, rhp->region_id);
+ region, rhp->region_id);
result = 0;
}
dump = 0;
offset < REGION_SIZE; offset += len) {
if (was_free && ChunkIsFree(region, offset)) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: uncoalesced free chunk:"
- " 0x%04x (see map)", region, offset);
+ "region 0x%04x is not valid: uncoalesced free chunk:"
+ " 0x%04x (see map)", region, offset);
result = 0;
dump = 1;
}
free_count++;
free_bytes += len;
if (largest_free < len)
- largest_free = len;
+ largest_free = len;
if (next_free != offset) {
- do_rawlog(LT_ERR,
- "region 0x%04x is not valid: free chain broken:"
- " 0x%04x, expecting 0x%04x (see map)",
- region, offset, next_free);
- result = 0;
- dump = 1;
+ do_rawlog(LT_ERR,
+ "region 0x%04x is not valid: free chain broken:"
+ " 0x%04x, expecting 0x%04x (see map)",
+ region, offset, next_free);
+ result = 0;
+ dump = 1;
}
next_free = ChunkNextFree(region, offset);
} else {
used_count++;
total_derefs += ChunkDerefs(region, offset);
if (ChunkIsMedium(region, offset) &&
- ChunkLen(region, offset) <= MAX_SHORT_CHUNK_LEN) {
- do_rawlog(LT_ERR,
- "region 0x%04x is not valid: medium chunk too small:"
- " 0x%04x (see map)", region, offset);
- result = 0;
- dump = 1;
+ ChunkLen(region, offset) <= MAX_SHORT_CHUNK_LEN) {
+ do_rawlog(LT_ERR,
+ "region 0x%04x is not valid: medium chunk too small:"
+ " 0x%04x (see map)", region, offset);
+ result = 0;
+ dump = 1;
}
if (ChunkIsLong(region, offset) &&
- ChunkLen(region, offset) <= MAX_MEDIUM_CHUNK_LEN) {
- do_rawlog(LT_ERR,
- "region 0x%04x is not valid: long chunk too small:"
- " 0x%04x (see map)", region, offset);
- result = 0;
- dump = 1;
+ ChunkLen(region, offset) <= MAX_MEDIUM_CHUNK_LEN) {
+ do_rawlog(LT_ERR,
+ "region 0x%04x is not valid: long chunk too small:"
+ " 0x%04x (see map)", region, offset);
+ result = 0;
+ dump = 1;
}
}
}
if (offset != REGION_SIZE) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: last chunk past bounds (see map)",
- region);
+ "region 0x%04x is not valid: last chunk past bounds (see map)",
+ region);
result = 0;
}
if (next_free != 0) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: free chain unterminated:"
- " expecting 0x%04x (see map)", region, next_free);
+ "region 0x%04x is not valid: free chain unterminated:"
+ " expecting 0x%04x (see map)", region, next_free);
result = 0;
dump = 1;
}
if (rp->used_count != used_count) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: used count is wrong:"
- " 0x%04x should be 0x%04x", region, rp->used_count, used_count);
+ "region 0x%04x is not valid: used count is wrong:"
+ " 0x%04x should be 0x%04x", region, rp->used_count, used_count);
result = 0;
}
if (rp->total_derefs != total_derefs) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: total derefs is wrong:"
- " 0x%04x should be 0x%04x",
- region, rp->total_derefs, total_derefs);
+ "region 0x%04x is not valid: total derefs is wrong:"
+ " 0x%04x should be 0x%04x",
+ region, rp->total_derefs, total_derefs);
result = 0;
}
if (rp->free_count != free_count) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: free count is wrong:"
- " 0x%04x should be 0x%04x", region, rp->free_count, free_count);
+ "region 0x%04x is not valid: free count is wrong:"
+ " 0x%04x should be 0x%04x", region, rp->free_count, free_count);
result = 0;
}
if (rp->free_bytes != free_bytes) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: free bytes is wrong:"
- " 0x%04x should be 0x%04x", region, rp->free_bytes, free_bytes);
+ "region 0x%04x is not valid: free bytes is wrong:"
+ " 0x%04x should be 0x%04x", region, rp->free_bytes, free_bytes);
result = 0;
}
if (rp->largest_free_chunk != largest_free) {
do_rawlog(LT_ERR,
- "region 0x%04x is not valid: largest free is wrong:"
- " 0x%04x should be 0x%04x",
- region, rp->largest_free_chunk, largest_free);
+ "region 0x%04x is not valid: largest free is wrong:"
+ " 0x%04x should be 0x%04x",
+ region, rp->largest_free_chunk, largest_free);
result = 0;
}
if (dump) {
*/
static void
write_used_chunk(u_int_16 region, u_int_16 offset, u_int_16 full_len,
- unsigned char const *data, u_int_16 data_len,
- unsigned char derefs)
+ unsigned char const *data, u_int_16 data_len,
+ unsigned char derefs)
{
unsigned char *cptr = ChunkPointer(region, offset);
if (full_len <= MAX_SHORT_CHUNK_LEN + CHUNK_SHORT_DATA_OFFSET) {
*/
static void
write_free_chunk(u_int_16 region, u_int_16 offset, u_int_16 full_len,
- u_int_16 next)
+ u_int_16 next)
{
unsigned char *cptr = ChunkPointer(region, offset);
if (full_len <= MAX_SHORT_CHUNK_LEN + CHUNK_SHORT_DATA_OFFSET) {
else {
u_int_16 hole;
for (hole = rp->in_memory->first_free;
- hole; hole = ChunkNextFree(region, hole))
- if (ChunkNextFree(region, hole) == offset)
- break;
+ hole; hole = ChunkNextFree(region, hole))
+ if (ChunkNextFree(region, hole) == offset)
+ break;
ASSERT(hole);
write_next_free(region, hole, ChunkNextFree(region, offset));
}
if (align == 1) {
rp->free_bytes -= full_len;
write_free_chunk(region, offset + full_len,
- hole_len - full_len, ChunkNextFree(region, offset));
+ hole_len - full_len, ChunkNextFree(region, offset));
if (rp->in_memory->first_free == offset)
rp->in_memory->first_free += full_len;
else {
u_int_16 hole;
for (hole = rp->in_memory->first_free;
- hole; hole = ChunkNextFree(region, hole))
- if (ChunkNextFree(region, hole) == offset)
- break;
+ hole; hole = ChunkNextFree(region, hole))
+ if (ChunkNextFree(region, hole) == offset)
+ break;
ASSERT(hole);
write_next_free(region, hole, offset + full_len);
}
} else {
rp->free_bytes -= full_len;
write_free_chunk(region, offset,
- hole_len - full_len, ChunkNextFree(region, offset));
+ hole_len - full_len, ChunkNextFree(region, offset));
if (rp->largest_free_chunk == hole_len)
rp->largest_free_chunk = largest_hole(region);
return offset + hole_len - full_len;
remaining -= done;
pos += done;
if (!remaining)
- return;
+ return;
}
#ifndef WIN32
if (done == -1 && errno == EAGAIN)
}
#ifdef WIN32
mush_panicf("chunk swap file read, %d remaining, GetLastError %d",
- remaining, GetLastError());
+ remaining, GetLastError());
#else
mush_panicf("chunk swap file read, %zu remaining, errno %d: %s",
- remaining, errno, strerror(errno));
+ remaining, errno, strerror(errno));
#endif
}
remaining -= done;
pos += done;
if (!remaining)
- return;
+ return;
}
#ifndef WIN32
if (done == -1 && errno == EAGAIN)
}
#ifdef WIN32
mush_panicf("chunk swap file write, %d remaining, GetLastError %d",
- remaining, GetLastError());
+ remaining, GetLastError());
#else
mush_panicf("chunk swap file write, %zu remaining, errno %d: %s",
- remaining, errno, strerror(errno));
+ remaining, errno, strerror(errno));
#endif
}
find_oddballs(rhp->region_id);
#ifdef DEBUG_CHUNK_PAGING
do_rawlog(LT_TRACE, "CHUNK: Paging out region %04x (offset %08x)",
- rhp->region_id, (unsigned) file_offset);
+ rhp->region_id, (unsigned) file_offset);
#endif
write_cache_region(swap_fd, rhp, rhp->region_id);
/* keep statistics */
/* page it in */
#ifdef DEBUG_CHUNK_PAGING
do_rawlog(LT_TRACE, "CHUNK: Paging in region %04x (offset %08x)",
- region, (unsigned) file_offset);
+ region, (unsigned) file_offset);
#endif
read_cache_region(swap_fd, rhp, region);
/* link the region to its cache entry */
if (shift > 8) {
rp->total_derefs = 0;
for (offset = FIRST_CHUNK_OFFSET_IN_REGION;
- offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
- ChunkDerefs(region, offset) = 0;
+ offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
+ ChunkDerefs(region, offset) = 0;
}
} else {
rp->total_derefs = 0;
for (offset = FIRST_CHUNK_OFFSET_IN_REGION;
- offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
- if (ChunkIsFree(region, offset))
- continue;
- ChunkDerefs(region, offset) >>= shift;
- rp->total_derefs += ChunkDerefs(region, offset);
+ offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
+ if (ChunkIsFree(region, offset))
+ continue;
+ ChunkDerefs(region, offset) >>= shift;
+ rp->total_derefs += ChunkDerefs(region, offset);
}
}
rp->period_last_touched = curr_period;
#endif
regions = (Region *) realloc(regions, region_array_len * sizeof(Region));
if (!regions)
- mush_panic("chunk: region array realloc failure");
+ mush_panic("chunk: region array realloc failure");
}
region = region_count;
region_count++;
regions[region].in_memory->region_id = region;
regions[region].in_memory->first_free = FIRST_CHUNK_OFFSET_IN_REGION;
write_free_chunk(region, FIRST_CHUNK_OFFSET_IN_REGION,
- regions[region].free_bytes, 0);
+ regions[region].free_bytes, 0);
touch_cache_region(regions[region].in_memory);
return region;
j = NUM_ODDBALLS;
while (j--) {
if (!rp->oddballs[j])
- continue;
+ continue;
d2 = abs(mean - ChunkDerefs(region, rp->oddballs[j]));
if (d1 < d2)
- break;
+ break;
if (j < NUM_ODDBALLS - 1)
- rp->oddballs[j + 1] = rp->oddballs[j];
+ rp->oddballs[j + 1] = rp->oddballs[j];
}
j++;
if (j >= NUM_ODDBALLS)
rp = regions + region;
free_bytes += rp->free_bytes;
if (!FitsInSpace(full_len, rp->largest_free_chunk) &&
- !(rp->free_count == 2 &&
- rp->free_bytes - rp->largest_free_chunk == full_len))
+ !(rp->free_count == 2 &&
+ rp->free_bytes - rp->largest_free_chunk == full_len))
continue;
if (region == old_region)
#endif
best_region = create_region();
} else if (best_score > (1 << LONLINESS_LIMIT) + IN_MEMORY_BIAS &&
- (free_bytes * 100 / (REGION_CAPACITY * region_count)) <
- FREE_PERCENT_LIMIT) {
+ (free_bytes * 100 / (REGION_CAPACITY * region_count)) <
+ FREE_PERCENT_LIMIT) {
#ifdef DEBUG_CHUNK_REGION_CREATE
do_rawlog(LT_TRACE, "find_best_region chose to create region %04x", region);
#endif
*/
static u_int_16
find_best_offset(u_int_16 full_len, u_int_16 region,
- u_int_16 old_region, u_int_16 old_offset)
+ u_int_16 old_region, u_int_16 old_offset)
{
u_int_16 fits, offset;
offset = ChunkNextFree(region, offset)) {
if (region == old_region) {
if (offset > old_offset)
- break;
+ break;
if (offset + ChunkFullLen(region, offset) == old_offset)
- return fits ? fits : offset;
+ return fits ? fits : offset;
}
if (ChunkFullLen(region, offset) == full_len)
return offset;
stat_used_medium_count * CHUNK_MEDIUM_DATA_OFFSET +
stat_used_long_count * CHUNK_LONG_DATA_OFFSET;
STAT_OUT(tprintf
- ("Chunks: %10d allocated (%10d bytes, %10d (%2d%%) overhead)",
- used_count, used_bytes, overhead,
- used_bytes ? overhead * 100 / used_bytes : 0));
+ ("Chunks: %10d allocated (%10d bytes, %10d (%2d%%) overhead)",
+ used_count, used_bytes, overhead,
+ used_bytes ? overhead * 100 / used_bytes : 0));
overhead = stat_used_short_count * CHUNK_SHORT_DATA_OFFSET;
STAT_OUT(tprintf
- (" %10d short (%10d bytes, %10d (%2d%%) overhead)",
- stat_used_short_count, stat_used_short_bytes, overhead,
- stat_used_short_bytes ? overhead * 100 /
- stat_used_short_bytes : 0));
+ (" %10d short (%10d bytes, %10d (%2d%%) overhead)",
+ stat_used_short_count, stat_used_short_bytes, overhead,
+ stat_used_short_bytes ? overhead * 100 /
+ stat_used_short_bytes : 0));
overhead = stat_used_medium_count * CHUNK_MEDIUM_DATA_OFFSET;
STAT_OUT(tprintf
- (" %10d medium (%10d bytes, %10d (%2d%%) overhead)",
- stat_used_medium_count, stat_used_medium_bytes, overhead,
- stat_used_medium_bytes ? overhead * 100 /
- stat_used_medium_bytes : 0));
+ (" %10d medium (%10d bytes, %10d (%2d%%) overhead)",
+ stat_used_medium_count, stat_used_medium_bytes, overhead,
+ stat_used_medium_bytes ? overhead * 100 /
+ stat_used_medium_bytes : 0));
overhead = stat_used_long_count * CHUNK_LONG_DATA_OFFSET;
STAT_OUT(tprintf
- (" %10d long (%10d bytes, %10d (%2d%%) overhead)",
- stat_used_long_count, stat_used_long_bytes, overhead,
- stat_used_long_bytes ? overhead * 100 / stat_used_long_bytes : 0));
+ (" %10d long (%10d bytes, %10d (%2d%%) overhead)",
+ stat_used_long_count, stat_used_long_bytes, overhead,
+ stat_used_long_bytes ? overhead * 100 / stat_used_long_bytes : 0));
STAT_OUT(tprintf
- (" %10d free (%10d bytes, %10d (%2d%%) fragmented)",
- free_count, free_bytes, free_bytes - free_large,
- free_bytes ? (free_bytes - free_large) * 100 / free_bytes : 0));
+ (" %10d free (%10d bytes, %10d (%2d%%) fragmented)",
+ free_count, free_bytes, free_bytes - free_large,
+ free_bytes ? (free_bytes - free_large) * 100 / free_bytes : 0));
overhead = region_count * REGION_SIZE + region_array_len * sizeof(Region);
STAT_OUT(tprintf("Storage: %10d total (%2d%% saturation)",
- overhead, used_bytes * 100 / overhead));
+ overhead, used_bytes * 100 / overhead));
STAT_OUT(tprintf("Regions: %10d total, %8d cached",
- region_count, cached_region_count));
+ region_count, cached_region_count));
STAT_OUT(tprintf("Paging: %10d out, %10d in",
- stat_page_out, stat_page_in));
+ stat_page_out, stat_page_in));
STAT_OUT(" ");
STAT_OUT(tprintf("Period: %10d (%10d accesses so far, %10d chunks at max)",
- curr_period, stat_deref_count, stat_deref_maxxed));
+ curr_period, stat_deref_count, stat_deref_maxxed));
STAT_OUT(tprintf("Activity: %10d creates, %10d deletes this period",
- stat_create, stat_delete));
+ stat_create, stat_delete));
STAT_OUT(tprintf("Migration: %10d moves this period",
- stat_migrate_slide + stat_migrate_move));
+ stat_migrate_slide + stat_migrate_move));
STAT_OUT(tprintf(" %10d slide %10d move",
- stat_migrate_slide, stat_migrate_move));
+ stat_migrate_slide, stat_migrate_move));
STAT_OUT(tprintf(" %10d in region%10d out of region",
- stat_migrate_slide + stat_migrate_move - stat_migrate_away,
- stat_migrate_away));
+ stat_migrate_slide + stat_migrate_move - stat_migrate_away,
+ stat_migrate_away));
}
/** Show just the page counts.
{
const char *s;
STAT_OUT(tprintf("Paging: %10d out, %10d in",
- stat_page_out, stat_page_in));
+ stat_page_out, stat_page_in));
}
/** Display the per-region stats.
}
for (rid = 0; rid < region_count; rid++) {
STAT_OUT(tprintf
- ("region:%4d #used:%5d #free:%5d "
- "fbytes:%04x largest:%04x deref:%3d",
- rid, regions[rid].used_count, regions[rid].free_count,
- regions[rid].free_bytes, regions[rid].largest_free_chunk,
- RegionDerefs(rid)));
+ ("region:%4d #used:%5d #free:%5d "
+ "fbytes:%04x largest:%04x deref:%3d",
+ rid, regions[rid].used_count, regions[rid].free_count,
+ regions[rid].free_bytes, regions[rid].largest_free_chunk,
+ RegionDerefs(rid)));
}
}
if (k > max) {
sprintf(num, "(%d)", k);
if (j < 32) {
- if (j < pen)
- ante = 18;
- else
- ante = 19;
- memcpy(buffer[ante] + j + 1, num, strlen(num));
- pen = j + strlen(num) + 1;
+ if (j < pen)
+ ante = 18;
+ else
+ ante = 19;
+ memcpy(buffer[ante] + j + 1, num, strlen(num));
+ pen = j + strlen(num) + 1;
} else {
- if (j - (int) strlen(num) < pen)
- ante = 18;
- else
- ante = 19;
- memcpy(buffer[ante] + j - strlen(num), num, strlen(num));
- pen = j;
+ if (j - (int) strlen(num) < pen)
+ ante = 18;
+ else
+ ante = 19;
+ memcpy(buffer[ante] + j - strlen(num), num, strlen(num));
+ pen = j;
}
}
}
t = m_references[j];
for (k = j; k--;) {
if (m_references[k][0] < t[0])
- break;
+ break;
m_references[k + 1] = m_references[k];
}
m_references[k + 1] = t;
u_int_16 o_len, len, next, other, prev, o_off, o_oth;
debug_log("migrate_slide %d (%08x) to %04x%04x",
- which, m_references[which][0], region, offset);
+ which, m_references[which][0], region, offset);
bring_in_region(region);
memmove(ChunkPointer(region, offset), ChunkPointer(region, other), o_len);
#ifdef DEBUG_CHUNK_MIGRATE
do_rawlog(LT_TRACE, "CHUNK: Sliding chunk %08x to %04x%04x",
- m_references[which][0], region, offset);
+ m_references[which][0], region, offset);
#endif
m_references[which][0] = ChunkReference(region, offset);
other = offset + o_len;
memmove(ChunkPointer(region, prev), ChunkPointer(region, other), o_len);
#ifdef DEBUG_CHUNK_MIGRATE
do_rawlog(LT_TRACE, "CHUNK: Sliding chunk %08x to %04x%04x",
- m_references[which][0], region, prev);
+ m_references[which][0], region, prev);
#endif
m_references[which][0] = ChunkReference(region, prev);
}
if (!region_is_valid(region)) {
do_rawlog(LT_TRACE, "Invalid region after migrate_slide!");
do_rawlog(LT_TRACE, "Was moving %04x%04x to %04x%04x (became %08x)...",
- region, o_oth, region, o_off, m_references[which][0]);
+ region, o_oth, region, o_off, m_references[which][0]);
do_rawlog(LT_TRACE, "Chunk length %04x into hole length %04x", o_len, len);
debug_dump_region(region, tracelog_fp);
dump_debug_log(tracelog_fp);
Region *srp;
debug_log("migrate_move %d (%08x) to %04x%04x, alignment %d",
- which, m_references[which][0], region, offset, align);
+ which, m_references[which][0], region, offset, align);
s_reg = ChunkReferenceToRegion(m_references[which][0]);
s_off = ChunkReferenceToOffset(m_references[which][0]);
if (!FitsInSpace(s_len, ChunkFullLen(region, offset))) {
dump_debug_log(tracelog_fp);
mush_panicf("Trying to migrate into too small a hole: %04x into %04x!",
- s_len, length);
+ s_len, length);
}
#endif
memcpy(ChunkPointer(region, offset), ChunkPointer(s_reg, s_off), s_len);
#ifdef DEBUG_CHUNK_MIGRATE
do_rawlog(LT_TRACE, "CHUNK: moving chunk %08x to %04x%04x",
- m_references[which][0], region, offset);
+ m_references[which][0], region, offset);
#endif
m_references[which][0] = ChunkReference(region, offset);
rp->total_derefs += ChunkDerefs(region, offset);
if (!region_is_valid(region)) {
do_rawlog(LT_TRACE, "Invalid region after migrate_move!");
do_rawlog(LT_TRACE, "Was moving %04x%04x to %04x%04x (became %04x%04x)...",
- s_reg, s_off, region, o_off, region, offset);
+ s_reg, s_off, region, o_off, region, offset);
do_rawlog(LT_TRACE, "Chunk length %04x into hole length %04x, alignment %d",
- s_len, length, align);
+ s_len, length, align);
debug_dump_region(region, tracelog_fp);
mush_panic("Invalid region after migrate_move!");
}
best_region = find_best_region(length, derefs, region);
best_offset = find_best_offset(length, best_region, region, offset);
if (best_offset)
- migrate_move(best_region, best_offset, j, 1);
+ migrate_move(best_region, best_offset, j, 1);
if (best_region != region)
- stat_migrate_away++;
+ stat_migrate_away++;
}
}
migrate_sort();
*/
u_int_16
chunk_fetch(chunk_reference_t reference,
- unsigned char *buffer, u_int_16 buffer_len)
+ unsigned char *buffer, u_int_16 buffer_len)
{
u_int_16 region, offset, len;
region = ChunkReferenceToRegion(reference);
/* Make sure we have something to migrate, in the region. */
for (k = 0; k < m_count; k++)
if (ChunkReferenceToRegion(m_references[k][0]) == region)
- break;
+ break;
if (k >= m_count)
continue;
if (!regions[region].in_memory) {
/* If not in memory, see if we've got an oddball. */
while (k < m_count) {
- if (ChunkReferenceToRegion(m_references[k][0]) != region)
- break;
- offset = ChunkReferenceToOffset(m_references[k][0]);
- for (l = 0; l < NUM_ODDBALLS; l++) {
- if (regions[region].oddballs[l] == offset) {
- /* Yup, have an oddball... that's worth bringing it in. */
- bring_in_region(region);
- goto do_migrate;
- }
- }
- k++;
+ if (ChunkReferenceToRegion(m_references[k][0]) != region)
+ break;
+ offset = ChunkReferenceToOffset(m_references[k][0]);
+ for (l = 0; l < NUM_ODDBALLS; l++) {
+ if (regions[region].oddballs[l] == offset) {
+ /* Yup, have an oddball... that's worth bringing it in. */
+ bring_in_region(region);
+ goto do_migrate;
+ }
+ }
+ k++;
}
} else {
do_migrate:
#ifdef WIN32
swap_fd = CreateFile(CHUNK_SWAP_FILE, GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (swap_fd == INVALID_HANDLE_VALUE)
mush_panicf("Cannot open swap file: %d", GetLastError());
#else
/*
command_add("@DEBUGCHUNK", CMD_T_ANY | CMD_T_GOD, 0, 0, 0,
switchmask("ALL BRIEF FULL"), cmd_debugchunk);
- */
+ */
do_rawlog(LT_TRACE, "CHUNK: chunk subsystem initialized");
}
break;
case CSTATS_REGIONG:
chunk_histogram(player, chunk_regionhist(),
- "Chart number of regions (y) vs. references (x)");
+ "Chart number of regions (y) vs. references (x)");
break;
case CSTATS_PAGINGG:
chunk_histogram(player, stat_paging_histogram,
- "Chart pages in/out (y) vs. references (x)");
+ "Chart pages in/out (y) vs. references (x)");
break;
case CSTATS_FREESPACEG:
chunk_histogram(player, chunk_freehist(),
- "Chart region free space (y) vs. references (x)");
+ "Chart region free space (y) vs. references (x)");
break;
case CSTATS_REGION:
chunk_region_statistics(player);
if (shift > 8) {
rp->total_derefs = 0;
for (offset = FIRST_CHUNK_OFFSET_IN_REGION;
- offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
- ChunkDerefs(region, offset) = 0;
+ offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
+ ChunkDerefs(region, offset) = 0;
}
} else {
rp->total_derefs = 0;
for (offset = FIRST_CHUNK_OFFSET_IN_REGION;
- offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
- if (ChunkIsFree(region, offset))
- continue;
- ChunkDerefs(region, offset) >>= shift;
- rp->total_derefs += ChunkDerefs(region, offset);
+ offset < REGION_SIZE; offset += ChunkFullLen(region, offset)) {
+ if (ChunkIsFree(region, offset))
+ continue;
+ ChunkDerefs(region, offset) >>= shift;
+ rp->total_derefs += ChunkDerefs(region, offset);
}
}
rp->period_last_touched = curr_period;
unlink(child_filename);
swap_fd_child = -1;
}
-#endif /* !WIN32 */
+#endif /* !WIN32 */
{
#ifdef EXAMPLE
command_add("@SILLY", CMD_T_ANY, NULL, NULL, "NOISY NOEVAL",
- cmd_local_silly);
+ cmd_local_silly);
#endif
}
void do_poor(dbref player, char *arg1);
void do_list_memstats(dbref player);
-#define DOL_MAP 1 /**< dolist/map bitflag */
-#define DOL_NOTIFY 2 /**< dolist/notify bitflag */
-#define DOL_DELIM 4 /**< dolist/delim bitflag */
+#define DOL_MAP 1 /**< dolist/map bitflag */
+#define DOL_NOTIFY 2 /**< dolist/notify bitflag */
+#define DOL_DELIM 4 /**< dolist/delim bitflag */
void do_dolist(dbref player, char *list, char *command,
- dbref cause, unsigned int flags);
+ dbref cause, unsigned int flags);
void do_list(dbref player, char *arg, int lc);
void do_writelog(dbref player, char *str, int ltype);
void do_readcache(dbref player);
COMMAND (cmd_attribute) {
if (SW_ISSET(sw, SWITCH_ACCESS))
- do_attribute_access(player, arg_left, arg_right,
- SW_ISSET(sw, SWITCH_RETROACTIVE));
+ do_attribute_access(player, arg_left, arg_right,
+ SW_ISSET(sw, SWITCH_RETROACTIVE));
else if(SW_ISSET(sw, SWITCH_LOCK)) {
if(SW_ISSET(sw, SWITCH_DEFAULTS))
do_attribute_lock(player, NULL, arg_left, sw);
return;
}
if (!config_set(arg_left, arg_right, 1, 0)
- && !config_set(arg_left, arg_right, 1, 1))
+ && !config_set(arg_left, arg_right, 1, 1))
notify(player, T("Couldn't set that option"));
else
notify(player, T("Option set."));
/* @dec/tf overrides @dec/prefix */
ATTR *a;
if (((a = atr_get_noparent(player, "TFPREFIX")) != NULL) &&
- AL_STR(a) && *AL_STR(a)) {
+ AL_STR(a) && *AL_STR(a)) {
strcpy(prefix, atr_value(a));
} else {
strcpy(prefix, "FugueEdit > ");
COMMAND (cmd_edit) {
do_gedit(player, arg_left, args_right,
- SW_ISSET(sw, SWITCH_FIRST) ? EDIT_FIRST : EDIT_ALL,
- SW_ISSET(sw, SWITCH_CHECK) ? 0 : 1);
+ SW_ISSET(sw, SWITCH_FIRST) ? EDIT_FIRST : EDIT_ALL,
+ SW_ISSET(sw, SWITCH_CHECK) ? 0 : 1);
}
COMMAND (cmd_elock) {
if (SW_ISSET(sw, SWITCH_ROOM)) {
do_lemit(player, arg_left,
- (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags);
+ (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags);
} else {
if(Admin(player) || !RPMODE(player) || Can_RPEMIT(player))
- do_emit(player, arg_left, spflags);
+ do_emit(player, arg_left, spflags);
else notify(player, "You can't do that in RPMODE.");
}
}
split = 1;
saved = args_right[2];
if ((args_right[2] = strchr(args_right[1], '/')) == NULL) {
- notify(player, T("#-1 INVALID SECOND ARGUMENT"));
- return;
+ notify(player, T("#-1 INVALID SECOND ARGUMENT"));
+ return;
}
*args_right[2]++ = '\0';
}
do_function(player, NULL, NULL, 0);
if (split) {
if (args_right[2])
- *--args_right[2] = '/';
+ *--args_right[2] = '/';
args_right[2] = saved;
}
}
COMMAND (cmd_grep) {
do_grep(player, arg_left, arg_right, ((SW_ISSET(sw, SWITCH_IPRINT))
- || (SW_ISSET(sw, SWITCH_PRINT))),
- ((SW_ISSET(sw, SWITCH_IPRINT))
- || (SW_ISSET(sw, SWITCH_ILIST))));
+ || (SW_ISSET(sw, SWITCH_PRINT))),
+ ((SW_ISSET(sw, SWITCH_IPRINT))
+ || (SW_ISSET(sw, SWITCH_ILIST))));
}
COMMAND (cmd_halt) {
int spflags = !strcmp(cmd->name, "@NSLEMIT") ? PEMIT_SPOOF : 0;
SPOOF(player, cause, sw);
do_lemit(player, arg_left,
- (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags);
+ (SW_ISSET(sw, SWITCH_SILENT) * PEMIT_SILENT) | spflags);
}
COMMAND (cmd_link) {
else if (SW_ISSET(sw, SWITCH_UNTAG))
do_mail_untag(player, arg_left);
else if (SW_ISSET(sw, SWITCH_FWD) || SW_ISSET(sw, SWITCH_FORWARD)
- || SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig) {
+ || SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig) {
/* These commands are not allowed to gagged players */
if (Gagged(player)) {
notify(player, T("You cannot do that while gagged."));
do_mail_fwd(player, arg_left, arg_right);
else if (SW_ISSET(sw, SWITCH_SEND) || silent || urgent || nosig)
do_mail_send(player, arg_left, arg_right,
- urgent ? M_URGENT : 0, silent, nosig);
+ urgent ? M_URGENT : 0, silent, nosig);
} else
- do_mail(player, arg_left, arg_right); /* Does its own gagged check */
+ do_mail(player, arg_left, arg_right); /* Does its own gagged check */
}
do_scan(player, arg_left, CHECK_GLOBAL);
else
do_scan(player, arg_left, CHECK_INVENTORY | CHECK_NEIGHBORS |
- CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_GLOBAL);
+ CHECK_SELF | CHECK_HERE | CHECK_ZONE | CHECK_GLOBAL);
}
COMMAND (cmd_search) {
COMMAND (cmd_select) {
do_switch(player, arg_left, args_right, cause, 1,
- SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP));
+ SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP));
}
COMMAND (cmd_set) {
COMMAND (cmd_switch) {
do_switch(player, arg_left, args_right, cause, SW_ISSET(sw, SWITCH_FIRST),
- SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP));
+ SW_ISSET(sw, SWITCH_NOTIFY), SW_ISSET(sw, SWITCH_REGEXP));
}
COMMAND (cmd_squota) {
notify(player, T("You can't teleport to nothing!"));
else
do_teleport(player, arg_left, arg_right, (SW_ISSET(sw, SWITCH_SILENT)),
- (SW_ISSET(sw, SWITCH_INSIDE)));
+ (SW_ISSET(sw, SWITCH_INSIDE)));
}
COMMAND (cmd_trigger) {
do_page_port(player, arg_left, arg_right);
else
do_page(player, arg_left, arg_right, cause, SW_ISSET(sw, SWITCH_NOEVAL),
- !(SW_ISSET(sw, SWITCH_BLIND) ||
- (!(SW_ISSET(sw, SWITCH_LIST)) && (BLIND_PAGE))),
- SW_ISSET(sw, SWITCH_OVERRIDE), has_eq);
+ !(SW_ISSET(sw, SWITCH_BLIND) ||
+ (!(SW_ISSET(sw, SWITCH_LIST)) && (BLIND_PAGE))),
+ SW_ISSET(sw, SWITCH_OVERRIDE), has_eq);
}
COMMAND (cmd_pose) {
COMMAND (cmd_whisper) {
do_whisper(player, arg_left, arg_right,
- (SW_ISSET(sw, SWITCH_NOISY) ||
- (!SW_ISSET(sw, SWITCH_SILENT) && NOISY_WHISPER)));
+ (SW_ISSET(sw, SWITCH_NOISY) ||
+ (!SW_ISSET(sw, SWITCH_SILENT) && NOISY_WHISPER)));
}
COMMAND (cmd_use) {
/* If it's &attr obj, we must pass a NULL. If &attr obj=, pass "" */
if (rhs_present) {
do_set_atr(thing, switches, arg_right, player,
- 0x1 | (SW_ISSET(sw, SWITCH_NOEVAL) ? 0 : 0x02));
+ 0x1 | (SW_ISSET(sw, SWITCH_NOEVAL) ? 0 : 0x02));
} else {
do_set_atr(thing, switches, NULL, player, 1);
}
COMMAND (cmd_warn_on_missing) {
notify_format(Owner(player),
- T
- ("No command found in code by %s - don't start code with functions."),
- unparse_dbref(player));
+ T
+ ("No command found in code by %s - don't start code with functions."),
+ unparse_dbref(player));
return;
}
#include "cmds.h"
#include "confmagic.h"
-PTAB ptab_command; /**< Prefix table for command names. */
-PTAB ptab_command_perms; /**< Prefix table for command permissions */
+PTAB ptab_command; /**< Prefix table for command names. */
+PTAB ptab_command_perms; /**< Prefix table for command permissions */
-HASHTAB htab_reserved_aliases; /**< Hash table for reserved command aliases */
+HASHTAB htab_reserved_aliases; /**< Hash table for reserved command aliases */
static const char *command_isattr(char *command);
static int command_check(dbref player, COMMAND_INFO *cmd, switch_mask sw);
static int switch_find(COMMAND_INFO *cmd, char *sw);
static void strccat(char *buff, char **bp, const char *from);
static int has_hook(struct hook_data *hook);
-extern int global_fun_invocations; /**< Counter for function invocations */
-extern int global_fun_recursions; /**< Counter for function recursion */
+extern int global_fun_invocations; /**< Counter for function invocations */
+extern int global_fun_recursions; /**< Counter for function recursion */
int run_hook(dbref player, dbref cause, struct hook_data *hook,
- char *saveregs[], int save);
+ char *saveregs[], int save);
int command_lock(const char *name, const char *lock);
/** The list of standard commands. Additional commands can be added
}
static int
switch_find(COMMAND_INFO *cmd, char *sw)
- {
+ {
SWITCH_VALUE *sw_val;
int len;
if (!cmd) {
while (sw_val->name) {
if (strcmp(sw_val->name, sw) == 0)
- return sw_val->value;
+ return sw_val->value;
sw_val++;
}
return 0;
} else {
while (sw_val->name) {
- if (SW_ISSET(cmd->sw, sw_val->value) && (strncmp(sw_val->name, sw, len) == 0))
- return sw_val->value;
+ if (SW_ISSET(cmd->sw, sw_val->value) && (strncmp(sw_val->name, sw, len) == 0))
+ return sw_val->value;
sw_val++;
}
}
ptab_start_inserts(&ptab_command);
ptab_insert(&ptab_command, name,
- make_command(name, type, sw, func, command_lock));
+ make_command(name, type, sw, func, command_lock));
ptab_end_inserts(&ptab_command);
return command_find(name);
}
ptab_start_inserts(&ptab_command);
for (cmd = commands; cmd->name; cmd++) {
ptab_insert(&ptab_command, cmd->name,
- make_command(cmd->name, cmd->type, switchmask(cmd->switches),
- cmd->func, cmd->command_lock));
+ make_command(cmd->name, cmd->type, switchmask(cmd->switches),
+ cmd->func, cmd->command_lock));
}
ptab_end_inserts(&ptab_command);
*/
void
command_argparse(dbref player, dbref realcause, dbref cause, char **from, char *to,
- char *argv[], COMMAND_INFO *cmd, int right_side,
- int forcenoparse)
+ char *argv[], COMMAND_INFO *cmd, int right_side,
+ int forcenoparse)
{
int parse, split, args, i, done;
char *t, *f;
while (*f == ' ')
f++;
process_expression(to, &t, (const char **) &f, player, realcause, cause,
- parse, (split | args), NULL);
+ parse, (split | args), NULL);
*t = '\0';
if (args) {
argv[i] = aold;
if (*f)
- f++;
+ f++;
i++;
t++;
if (i == MAX_ARG)
- done = 1;
+ done = 1;
}
if (split && (*f == '=')) {
rhs_present = 1;
if (*p == '[') {
if ((cmd = command_find("WARN_ON_MISSING"))) {
if (!(cmd->type & CMD_T_DISABLED)) {
- cmd->func(cmd, player, cause, sw, string, NULL, NULL, ls, lsa, rs, rsa, fromport);
- command_parse_free_args;
- return NULL;
+ cmd->func(cmd, player, cause, sw, string, NULL, NULL, ls, lsa, rs, rsa, fromport);
+ command_parse_free_args;
+ return NULL;
}
}
}
case SAY_TOKEN:
replacer = "SAY";
if (CHAT_STRIP_QUOTE)
- p--; /* Since 'say' strips out the '"' */
+ p--; /* Since 'say' strips out the '"' */
break;
case POSE_TOKEN:
replacer = "POSE";
while (*p == ' ')
p++;
process_expression(command, &c, (const char **) &p, player, realcause,
- cause, noevtoken ? PE_NOTHING :
- ((PE_DEFAULT & ~PE_FUNCTION_CHECK)
- | PE_COMMAND_BRACES),
- PT_SPACE, NULL);
+ cause, noevtoken ? PE_NOTHING :
+ ((PE_DEFAULT & ~PE_FUNCTION_CHECK)
+ | PE_COMMAND_BRACES),
+ PT_SPACE, NULL);
*c = '\0';
strcpy(commandraw, command);
upcasestr(command);
} else {
c = command;
while ((*c) && (*c != '/') && (*c != ' '))
- c++;
+ c++;
b = *c;
*c = '\0';
cmd = command_find(command);
*c = b;
/* Is this for internal use? If so, players can't use it! */
if (cmd && (cmd->type & CMD_T_INTERNAL))
- cmd = NULL;
+ cmd = NULL;
}
}
if (!cmd || (cmd->type & CMD_T_DISABLED)) {
if (*p) {
if (*p == ' ') {
- safe_chr(' ', commandraw, &c2);
- p++;
+ safe_chr(' ', commandraw, &c2);
+ p++;
}
process_expression(commandraw, &c2, (const char **) &p, player, realcause,
- cause, noevtoken ? PE_NOTHING :
- ((PE_DEFAULT & ~PE_FUNCTION_CHECK) |
- PE_COMMAND_BRACES), PT_DEFAULT, NULL);
+ cause, noevtoken ? PE_NOTHING :
+ ((PE_DEFAULT & ~PE_FUNCTION_CHECK) |
+ PE_COMMAND_BRACES), PT_DEFAULT, NULL);
}
*c2 = '\0';
command_parse_free_args;
t = swtch;
c++;
while ((*c) && (*c != ' ') && (*c != '/'))
- *t++ = *c++;
+ *t++ = *c++;
*t = '\0';
switchnum = switch_find(cmd, upcasestr(swtch));
if (!switchnum) {
- if (cmd->type & CMD_T_SWITCHES) {
- if (*swp)
- strcat(swp, " ");
- strcat(swp, swtch);
- } else {
- if (se == switch_err)
- safe_format(switch_err, &se,
- T("%s doesn't know switch %s."), cmd->name, swtch);
- }
+ if (cmd->type & CMD_T_SWITCHES) {
+ if (*swp)
+ strcat(swp, " ");
+ strcat(swp, swtch);
+ } else {
+ if (se == switch_err)
+ safe_format(switch_err, &se,
+ T("%s doesn't know switch %s."), cmd->name, swtch);
+ }
} else {
- SW_SET(sw, switchnum);
+ SW_SET(sw, switchnum);
}
}
}
/* Special case: eqsplit, noeval of rhs only */
command_argparse(player, realcause, cause, &p, ls, lsa, cmd, 0, 0);
command_argparse(player, realcause, cause, &p, rs, rsa, cmd, 1, 1);
- SW_SET(sw, SWITCH_NOEVAL); /* Needed for ATTRIB_SET */
+ SW_SET(sw, SWITCH_NOEVAL); /* Needed for ATTRIB_SET */
} else {
noeval = SW_ISSET(sw, SWITCH_NOEVAL) || noevtoken;
if (cmd->type & CMD_T_EQSPLIT) {
char *savep = p;
command_argparse(player, realcause, cause, &p, ls, lsa, cmd, 0, noeval);
if (noeval && !noevtoken && *p) {
- /* oops, we have a right hand side, should have evaluated */
- p = savep;
- command_argparse(player, realcause, cause, &p, ls, lsa, cmd, 0, 0);
+ /* oops, we have a right hand side, should have evaluated */
+ p = savep;
+ command_argparse(player, realcause, cause, &p, ls, lsa, cmd, 0, 0);
}
command_argparse(player, realcause, cause, &p, rs, rsa, cmd, 1, noeval);
} else {
if (cmd->type & CMD_T_ARGS) {
int lsa_index;
if (lsa[1]) {
- safe_str(lsa[1], commandraw, &c2);
- for (lsa_index = 2; lsa[lsa_index]; lsa_index++) {
- safe_chr(',', commandraw, &c2);
- safe_str(lsa[lsa_index], commandraw, &c2);
+ safe_str(lsa[1], commandraw, &c2);
+ for (lsa_index = 2; lsa[lsa_index]; lsa_index++) {
+ safe_chr(',', commandraw, &c2);
+ safe_str(lsa[lsa_index], commandraw, &c2);
}
}
} else {
if (cmd->type & CMD_T_EQSPLIT) {
safe_chr('=', commandraw, &c2);
if (cmd->type & CMD_T_RS_ARGS) {
- int rsa_index;
- /* This is counterintuitive, but rsa[]
- * starts at 1. */
- if (rsa[1]) {
- safe_str(rsa[1], commandraw, &c2);
- for (rsa_index = 2; rsa[rsa_index]; rsa_index++) {
- safe_chr(',', commandraw, &c2);
- safe_str(rsa[rsa_index], commandraw, &c2);
- }
- }
+ int rsa_index;
+ /* This is counterintuitive, but rsa[]
+ * starts at 1. */
+ if (rsa[1]) {
+ safe_str(rsa[1], commandraw, &c2);
+ for (rsa_index = 2; rsa[rsa_index]; rsa_index++) {
+ safe_chr(',', commandraw, &c2);
+ safe_str(rsa[rsa_index], commandraw, &c2);
+ }
+ }
} else {
safe_str(rs, commandraw, &c2);
}
#ifdef NEVER
/* We used to do this, but we're not sure why */
process_expression(commandraw, &c2, (const char **) &p, player, realcause,
- cause, noevtoken ? PE_NOTHING :
- ((PE_DEFAULT & ~PE_FUNCTION_CHECK) |
- PE_COMMAND_BRACES), PT_DEFAULT, NULL);
+ cause, noevtoken ? PE_NOTHING :
+ ((PE_DEFAULT & ~PE_FUNCTION_CHECK) |
+ PE_COMMAND_BRACES), PT_DEFAULT, NULL);
#endif
}
*c2 = '\0';
if (run_hook(player, cause, &cmd->hooks.ignore, saveregs, 1)) {
/* If we have a hook/override, we use that instead */
if (!has_hook(&cmd->hooks.override) ||
- !one_comm_match(cmd->hooks.override.obj, player,
- cmd->hooks.override.attrname, commandraw)) {
- /* Otherwise, we do hook/before, the command, and hook/after */
- /* But first, let's see if we had an invalid switch */
- if (*switch_err) {
- notify(player, switch_err);
- free_global_regs("hook.regs", saveregs);
- command_parse_free_args;
- return NULL;
- }
- run_hook(player, cause, &cmd->hooks.before, saveregs, 1);
- cmd->func(cmd, player, cause, sw, string, swp, ap, ls, lsa, rs, rsa, fromport);
- run_hook(player, cause, &cmd->hooks.after, saveregs, 0);
+ !one_comm_match(cmd->hooks.override.obj, player,
+ cmd->hooks.override.attrname, commandraw)) {
+ /* Otherwise, we do hook/before, the command, and hook/after */
+ /* But first, let's see if we had an invalid switch */
+ if (*switch_err) {
+ notify(player, switch_err);
+ free_global_regs("hook.regs", saveregs);
+ command_parse_free_args;
+ return NULL;
+ }
+ run_hook(player, cause, &cmd->hooks.before, saveregs, 1);
+ cmd->func(cmd, player, cause, sw, string, swp, ap, ls, lsa, rs, rsa, fromport);
+ run_hook(player, cause, &cmd->hooks.after, saveregs, 0);
}
/* Either way, we might log */
if (cmd->type & CMD_T_LOGARGS)
- do_log(LT_CMD, player, cause, "%s", string);
+ do_log(LT_CMD, player, cause, "%s", string);
else if (cmd->type & CMD_T_LOGNAME)
- do_log(LT_CMD, player, cause, "%s", commandraw);
+ do_log(LT_CMD, player, cause, "%s", commandraw);
} else {
retval = commandraw;
}
if ((c = ptab_find(&ptab_command_perms, restriction))) {
if (clear)
- command->type &= ~c->type;
+ command->type &= ~c->type;
else
- command->type |= c->type;
+ command->type |= c->type;
}
restriction = tp;
}
*(message++) = '\0';
if((message = trim_space_sep(message, ' ')) && *message) {
if(command->restrict_message)
- mush_free((Malloc_t) command->restrict_message, "cmd_restrict_message");
+ mush_free((Malloc_t) command->restrict_message, "cmd_restrict_message");
command->restrict_message = mush_strdup(message, "cmd_restrict_message");
}
}
init_global_regs(saveregs);
if (run_hook(player, cause, &cmd->hooks.ignore, saveregs, 1)) {
/* If we have a hook/override, we use that instead */
- if (!has_hook(&cmd->hooks.override) ||
- !one_comm_match(cmd->hooks.override.obj, player,
- cmd->hooks.override.attrname, "HUH_COMMAND")) {
- /* Otherwise, we do hook/before, the command, and hook/after */
- run_hook(player, cause, &cmd->hooks.before, saveregs, 1);
-
- cmd->func(cmd, player, cause, sw, raw, switches, args_raw,
- arg_left, args_left, arg_right, args_right, fromport);
- run_hook(player, cause, &cmd->hooks.after, saveregs, 0);
- }
+ if (!has_hook(&cmd->hooks.override) ||
+ !one_comm_match(cmd->hooks.override.obj, player,
+ cmd->hooks.override.attrname, "HUH_COMMAND")) {
+ /* Otherwise, we do hook/before, the command, and hook/after */
+ run_hook(player, cause, &cmd->hooks.before, saveregs, 1);
+
+ cmd->func(cmd, player, cause, sw, raw, switches, args_raw,
+ arg_left, args_left, arg_right, args_right, fromport);
+ run_hook(player, cause, &cmd->hooks.after, saveregs, 0);
+ }
}
free_global_regs("hook.regs", saveregs);
return;
notify(player, T("Bad command name."));
} else {
command_add(mush_strdup(name, "command_add"),
- flags, (flags & CMD_T_NOPARSE ? NULL : "NOEVAL"),
- cmd_unimplemented, NULL);
+ flags, (flags & CMD_T_NOPARSE ? NULL : "NOEVAL"),
+ cmd_unimplemented, NULL);
notify_format(player, T("Command %s added."), name);
}
} else {
upcasestr(name);
command = command_find_exact(name);
if(!command) {
- notify(player, T("No such command."));
- return;
+ notify(player, T("No such command."));
+ return;
}
if (strcasecmp(command->name, name) == 0) {
/* This is the command, not an alias */
flags |= SW_ISSET(sw, SWITCH_EQSPLIT) ? CMD_T_EQSPLIT : 0;
if (SW_ISSET(sw, SWITCH_NOEVAL))
notify(player,
- T
- ("WARNING: /NOEVAL no longer creates a Noparse command.\n Use /NOPARSE if that's what you meant."));
+ T
+ ("WARNING: /NOEVAL no longer creates a Noparse command.\n Use /NOPARSE if that's what you meant."));
do_command_add(player, arg_left, flags);
return;
}
if (SW_ISSET(sw, SWITCH_ALIAS)) {
if (Director(player)) {
if (!ok_command_name(upcasestr(arg_right))) {
- notify(player, "I can't alias a command to that!");
+ notify(player, "I can't alias a command to that!");
} else if (!alias_command(arg_left, arg_right)) {
- notify(player, "Unable to set alias.");
+ notify(player, "Unable to set alias.");
} else {
- if (!SW_ISSET(sw, SWITCH_QUIET))
- notify(player, "Alias set.");
+ if (!SW_ISSET(sw, SWITCH_QUIET))
+ notify(player, "Alias set.");
}
} else {
notify(player, T("Permission denied."));
if(SW_ISSET(sw, SWITCH_LOCK)) {
if(arg_right && *arg_right) {
- boolexp key;
-
- key = parse_boolexp(player, arg_right, "Command");
- if(key != TRUE_BOOLEXP) {
- if(command->lock != TRUE_BOOLEXP)
- free_boolexp(command->lock);
- command->lock = key;
- notify(player, "Command locked.");
- } else notify(player, T("I don't understand that key."));
+ boolexp key;
+
+ key = parse_boolexp(player, arg_right, "Command");
+ if(key != TRUE_BOOLEXP) {
+ if(command->lock != TRUE_BOOLEXP)
+ free_boolexp(command->lock);
+ command->lock = key;
+ notify(player, "Command locked.");
+ } else notify(player, T("I don't understand that key."));
} else {
- if(command->lock != TRUE_BOOLEXP)
- free_boolexp(command->lock);
- command->lock = TRUE_BOOLEXP;
- notify(player, "Command unlocked.");
+ if(command->lock != TRUE_BOOLEXP)
+ free_boolexp(command->lock);
+ command->lock = TRUE_BOOLEXP;
+ notify(player, "Command unlocked.");
}
return;
}
if (SW_ISSET(sw, SWITCH_RESTRICT)) {
if (!arg_right || !arg_right[0]) {
- notify(player, T("How do you want to restrict the command?"));
- return;
+ notify(player, T("How do you want to restrict the command?"));
+ return;
}
if (!restrict_command(arg_left, arg_right))
- notify(player, T("Restrict attempt failed."));
+ notify(player, T("Restrict attempt failed."));
}
if ((command->func == cmd_command) && (command->type & CMD_T_DISABLED)) {
}
if (!SW_ISSET(sw, SWITCH_QUIET)) {
notify_format(player,
- "Name : %s (%s)", command->name,
- (command->type & CMD_T_DISABLED) ? "Disabled" : "Enabled");
+ "Name : %s (%s)", command->name,
+ (command->type & CMD_T_DISABLED) ? "Disabled" : "Enabled");
if ((command->type & CMD_T_ANY) == CMD_T_ANY)
safe_strl("Any", 3, buff, &bp);
else {
buff[0] = '\0';
if (command->type & CMD_T_ROOM)
- strccat(buff, &bp, "Room");
+ strccat(buff, &bp, "Room");
if (command->type & CMD_T_THING)
- strccat(buff, &bp, "Thing");
+ strccat(buff, &bp, "Thing");
if (command->type & CMD_T_EXIT)
- strccat(buff, &bp, "Exit");
+ strccat(buff, &bp, "Exit");
if (command->type & CMD_T_PLAYER)
- strccat(buff, &bp, "Player");
+ strccat(buff, &bp, "Player");
if (command->type & CMD_T_DIVISION)
- strccat(buff, &bp, "Division");
+ strccat(buff, &bp, "Division");
}
*bp = '\0';
notify_format(player, "Types : %s", buff);
bp = buff;
for (sw_val = switch_list; sw_val->name; sw_val++)
if (SW_ISSET(command->sw, sw_val->value))
- strccat(buff, &bp, sw_val->name);
+ strccat(buff, &bp, sw_val->name);
*bp = '\0';
notify_format(player, "Switches : %s", buff);
buff[0] = '\0';
bp = buff;
if (command->type & CMD_T_LS_ARGS) {
if (command->type & CMD_T_LS_SPACE)
- strccat(buff, &bp, "Space-Args");
+ strccat(buff, &bp, "Space-Args");
else
- strccat(buff, &bp, "Args");
+ strccat(buff, &bp, "Args");
}
if (command->type & CMD_T_LS_NOPARSE)
strccat(buff, &bp, "Noparse");
buff[0] = '\0';
bp = buff;
if (command->type & CMD_T_RS_ARGS) {
- if (command->type & CMD_T_RS_SPACE)
- strccat(buff, &bp, "Space-Args");
- else
- strccat(buff, &bp, "Args");
+ if (command->type & CMD_T_RS_SPACE)
+ strccat(buff, &bp, "Space-Args");
+ else
+ strccat(buff, &bp, "Args");
}
if (command->type & CMD_T_RS_NOPARSE)
- strccat(buff, &bp, "Noparse");
+ strccat(buff, &bp, "Noparse");
*bp = '\0';
notify_format(player, "Rightside : %s", buff);
} else {
/* God doesn't get fucked with */
if(LEVEL(player) >= LEVEL_GOD)
- return 1;
+ return 1;
/* If disabled, return silently */
if (cmd->type & CMD_T_DISABLED)
return 0;
}
#ifdef RPMODE_SYS
if((cmd->type & CMD_T_NORPMODE) && RPMODE(player)) {
- mess = T("You cannot do that while in RPMODE");
- goto send_error;
+ mess = T("You cannot do that while in RPMODE");
+ goto send_error;
}
#endif
if ((cmd->type & CMD_T_NOGUEST) && Guest(player)) {
ok = 1;
if(!God(player) && !eval_boolexp(player, cmd->lock, player, switches) ) {
- mess = T("Permission denied.");
- goto send_error;
+ mess = T("Permission denied.");
+ goto send_error;
}
return ok;
*/
int
run_hook(dbref player, dbref cause, struct hook_data *hook, char *saveregs[],
- int save)
+ int save)
{
ATTR *atr;
char *code;
bp = buff;
process_expression(buff, &bp, &cp, hook->obj, cause, player, PE_DEFAULT,
- PT_DEFAULT, NULL);
+ PT_DEFAULT, NULL);
*bp = '\0';
if (save)
*/
void
do_hook(dbref player, char *command, char *obj, char *attrname,
- enum hook_type flag)
+ enum hook_type flag)
{
COMMAND_INFO *cmd;
struct hook_data *h;
if (Site(player)) {
if (GoodObject(cmd->hooks.before.obj))
notify_format(player, "@hook/before: #%d/%s",
- cmd->hooks.before.obj, cmd->hooks.before.attrname);
+ cmd->hooks.before.obj, cmd->hooks.before.attrname);
if (GoodObject(cmd->hooks.after.obj))
notify_format(player, "@hook/after: #%d/%s", cmd->hooks.after.obj,
- cmd->hooks.after.attrname);
+ cmd->hooks.after.attrname);
if (GoodObject(cmd->hooks.ignore.obj))
notify_format(player, "@hook/ignore: #%d/%s",
- cmd->hooks.ignore.obj, cmd->hooks.ignore.attrname);
+ cmd->hooks.ignore.obj, cmd->hooks.ignore.attrname);
if (GoodObject(cmd->hooks.override.obj))
notify_format(player, "@hook/override: #%d/%s",
- cmd->hooks.override.obj, cmd->hooks.override.attrname);
+ cmd->hooks.override.obj, cmd->hooks.override.attrname);
}
}
#include "mymalloc.h"
#include "confmagic.h"
#ifdef WIN32
-#pragma warning( disable : 4244) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4244) /* NJG: disable warning re conversion */
#endif
-#define TABLE_SIZE 256 /**< allow all characters */
-#define EOS 0 /**< use null code for end of string */
-#define CHAR_BITS 8 /**< number of bits in char */
-#define CHAR_MASK 255 /**< mask for just one char */
-#define CODE_BITS 25 /**< max number of bits in code */
+#define TABLE_SIZE 256 /**< allow all characters */
+#define EOS 0 /**< use null code for end of string */
+#define CHAR_BITS 8 /**< number of bits in char */
+#define CHAR_MASK 255 /**< mask for just one char */
+#define CODE_BITS 25 /**< max number of bits in code */
#ifndef SAMPLE_SIZE
-#define SAMPLE_SIZE 0 /**< sample entire database */
+#define SAMPLE_SIZE 0 /**< sample entire database */
#endif
/** A node in the huffman compression tree. */
typedef struct cnode {
- struct cnode *left; /**< Left child node. */
- struct cnode *right; /**< Right child node. */
- unsigned char c; /**< character at this node. */
+ struct cnode *left; /**< Left child node. */
+ struct cnode *right; /**< Right child node. */
+ unsigned char c; /**< character at this node. */
} CNode;
static CNode *ctop;
/* Part 1 - how long will the compressed string be? */
for (p = (const unsigned char *) s; p && *p; p++)
bits += ltable[*p];
- bits += CHAR_BITS * 2 - 1; /* add space for the ending \0 */
+ bits += CHAR_BITS * 2 - 1; /* add space for the ending \0 */
needed_length = bits / CHAR_BITS;
/* Part 2 - Actually get around to compressing the data... */
if ((count >= 7) || ((count >= 3) && !node->left && !node->right)) {
ctop = (CNode *) malloc((unsigned) sizeof(CNode));
if (!ctop) {
- do_rawlog(LT_ERR,
- "Cannot allocate memory for compression tree. Aborting.");
- exit(1);
+ do_rawlog(LT_ERR,
+ "Cannot allocate memory for compression tree. Aborting.");
+ exit(1);
}
ctop->left = node->left;
ctop->right = node->right;
#endif
if (numbits > CODE_BITS) {
do_rawlog(LT_ERR, "Illegal compression code length (%d). Aborting.",
- numbits);
+ numbits);
exit(1);
}
} else {
table[total].node = (CNode *) malloc((unsigned) sizeof(CNode));
if (!table[total].node) {
do_rawlog(LT_ERR,
- "Cannot allocate memory for compression tree. Aborting.");
+ "Cannot allocate memory for compression tree. Aborting.");
exit(1);
}
table[total].node->c = total;
#ifdef STANDALONE
for (indx = 0; indx < TABLE_SIZE; indx++) {
printf(isprint(indx) ? "Frequency for '%c': %d\n"
- : "Frequency for %d: %d\n", (unsigned char) indx, table[indx].freq);
+ : "Frequency for %d: %d\n", (unsigned char) indx, table[indx].freq);
}
#endif
*/
for (indx = 2; indx < TABLE_SIZE; indx++) {
for (count = indx;
- (count > 1) && (table[count - 1].freq < table[count].freq); count--) {
+ (count > 1) && (table[count - 1].freq < table[count].freq); count--) {
temp = table[count].freq;
table[count].freq = table[count - 1].freq;
table[count - 1].freq = temp;
node = (CNode *) malloc((unsigned) sizeof(CNode));
if (!node) {
do_rawlog(LT_ERR,
- "Cannot allocate memory for compression tree. Aborting.");
+ "Cannot allocate memory for compression tree. Aborting.");
exit(1);
}
node->left = table[indx].node;
table[indx - 1].freq += table[indx].freq;
table[indx - 1].node = node;
for (count = indx - 1;
- (count > 1) && (table[count - 1].freq <= table[count].freq); count--) {
+ (count > 1) && (table[count - 1].freq <= table[count].freq); count--) {
temp = table[count].freq;
table[count].freq = table[count - 1].freq;
table[count - 1].freq = temp;
/* Force a 1 at fifth position on the left edge of tree. (Or terminating
* 1 for the all 0 code.)
*/
- node = table[1].node; /* top of tree */
+ node = table[1].node; /* top of tree */
for (count = 0; node->left && (count < 4); count++)
node = node->left;
ctop = (CNode *) malloc((unsigned) sizeof(CNode));
/* Part 4(e): Finally add in EOS as 00000000.
*/
- node = table[1].node; /* top of tree */
+ node = table[1].node; /* top of tree */
for (count = 0; count < 8; count++) {
if (!node->left) {
ctop = (CNode *) malloc((unsigned) sizeof(CNode));
if (!ctop) {
- do_rawlog(LT_ERR,
- "Cannot allocate memory for compression tree. Aborting.");
- exit(1);
+ do_rawlog(LT_ERR,
+ "Cannot allocate memory for compression tree. Aborting.");
+ exit(1);
}
ctop->left = (CNode *) NULL;
ctop->right = (CNode *) NULL;
p1 = otherbuf;
while (p1 && *p1) {
for (count = 0; count < 8; count++)
- printf("%d", (*p1 >> count) & 1);
+ printf("%d", (*p1 >> count) & 1);
p1++;
}
printf("\n");
printf("Text: %s!\n", newbuffer);
printf("Strcoll(orig,uncomp) = %d\n", strcoll(newbuffer, buffer));
printf("strlen(orig) = %d, strlen(uncomp) = %d\n", strlen(buffer),
- strlen(newbuffer));
+ strlen(newbuffer));
p1 = buffer;
p2 = newbuffer;
/*
#include "mymalloc.h"
#include "confmagic.h"
-#define MAXTABLE 32768 /**< Maximum words in the table */
-#define MAXWORDS 100 /**< Maximum size of a word */
-#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */
+#define MAXTABLE 32768 /**< Maximum words in the table */
+#define MAXWORDS 100 /**< Maximum size of a word */
+#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */
-#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */
+#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */
-#define TABLE_FLAG 0x80 /**< Distinguish a table */
-#define TABLE_MASK 0x7F /**< Mask out words within a table */
+#define TABLE_FLAG 0x80 /**< Distinguish a table */
+#define TABLE_MASK 0x7F /**< Mask out words within a table */
/* Table of words */
int init_compress(FILE * f);
#ifdef COMP_STATS
void compress_stats(long *entries, long *mem_used,
- long *total_uncompressed, long *total_compressed);
+ long *total_uncompressed, long *total_compressed);
#endif
static unsigned int hash_fn(const char *s, int hashtab_mask);
char *p;
int i, j;
- word[wordpos++] = 0; /* word's trailing null */
+ word[wordpos++] = 0; /* word's trailing null */
/* Don't bother putting single or double letter words in the table */
(words[i] || (i & 0xFF) == 0) && j < COLLISION_LIMIT; i++, j++)
if (words[i])
if (strcmp(word, words[i]) == 0) {
- *b++ = (i >> 8) | TABLE_FLAG;
- *b++ = i & 0xFF;
- return;
+ *b++ = (i >> 8) | TABLE_FLAG;
+ *b++ = i & 0xFF;
+ return;
}
/* not in table, add to it */
if ((i & 0xFF) == 0) {
- i++; /* make sure we don't have a null in the message */
+ i++; /* make sure we don't have a null in the message */
j++;
}
/* Can't add to table if full */
*b++ = (i >> 8) | TABLE_FLAG;
*b++ = i & 0xFF;
-} /* end of output_previous_word */
+} /* end of output_previous_word */
/** Word-compress a string.
*
while (*p) {
if (!(isdigit(*p) || isalpha(*p)) || wordpos >= MAXWORDS) {
if (wordpos) {
- word[wordpos++] = *p & 0x7F; /* add trailing punctuation */
- output_previous_word();
- wordpos = 0;
+ word[wordpos++] = *p & 0x7F; /* add trailing punctuation */
+ output_previous_word();
+ wordpos = 0;
} else
- *b++ = *p & 0x7F;
+ *b++ = *p & 0x7F;
} else
word[wordpos++] = *p & 0x7F;
p++;
if (wordpos)
output_previous_word();
- *b = 0; /* trailing null */
+ *b = 0; /* trailing null */
#ifdef COMP_STATS
- total_comp += u_strlen(buf); /* calculate size of compressed text */
- total_uncomp += strlen(s); /* calculate size of uncompressed text */
+ total_comp += u_strlen(buf); /* calculate size of compressed text */
+ total_uncomp += strlen(s); /* calculate size of uncompressed text */
#endif
return u_strdup(buf);
-} /* end of compress; */
+} /* end of compress; */
/** Word-uncompress a string.
if (c & TABLE_FLAG) {
i = ((c & TABLE_MASK) << 8) | *(++p);
if (i >= MAXTABLE || words[i] == NULL) {
- static int panicking = 0;
- if (panicking) {
- do_rawlog(LT_ERR,
- "Error in string decompression occurred during panic dump.");
- exit(1);
- } else {
- panicking = 1; /* don't panic from within panic */
- do_rawlog(LT_ERR, "Error in string decompression, i = %i", i);
- mush_panic("Fatal error in decompression");
- }
+ static int panicking = 0;
+ if (panicking) {
+ do_rawlog(LT_ERR,
+ "Error in string decompression occurred during panic dump.");
+ exit(1);
+ } else {
+ panicking = 1; /* don't panic from within panic */
+ do_rawlog(LT_ERR, "Error in string decompression, i = %i", i);
+ mush_panic("Fatal error in decompression");
+ }
}
strncpy((char *) b, words[i], words_len[i]);
b += words_len[i] - 1;
p++;
}
- *b++ = 0; /* trailing null */
+ *b++ = 0; /* trailing null */
return buf;
-} /* end of uncompress; */
+} /* end of uncompress; */
/** Word-uncompress a string, allocating memory.
* this function should be used when you're doing something like
*/
void
compress_stats(long *entries, long *mem_used, long *total_uncompressed,
- long *total_compressed)
+ long *total_compressed)
{
*entries = total_entries;
#include "mymalloc.h"
#include "confmagic.h"
-#define MAXTABLE 32768 /**< Maximum words in the table */
-#define MAXWORDS 100 /**< Maximum length of a word */
-#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */
+#define MAXTABLE 32768 /**< Maximum words in the table */
+#define MAXWORDS 100 /**< Maximum length of a word */
+#define COLLISION_LIMIT 20 /**< Maximum allowed collisions */
-#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */
+#define COMPRESS_HASH_MASK 0x7FFF /**< 32767 in hex */
-#define MARKER_CHAR 0x06 /**< Separates words. This char is the only one that can't be represented */
-#define TABLE_FLAG 0x80 /**< Distinguishes a table */
-#define TABLE_MASK 0x7F /**< Mask out words within a table */
+#define MARKER_CHAR 0x06 /**< Separates words. This char is the only one that can't be represented */
+#define TABLE_FLAG 0x80 /**< Distinguishes a table */
+#define TABLE_MASK 0x7F /**< Mask out words within a table */
/* Table of words */
int init_compress(FILE * f);
#ifdef COMP_STATS
void compress_stats(long *entries, long *mem_used,
- long *total_uncompressed, long *total_compressed);
+ long *total_uncompressed, long *total_compressed);
#endif
static unsigned int hash_fn(const char *s, int hashtab_mask);
char *p;
int i, j;
- word[wordpos++] = 0; /* word's trailing null */
+ word[wordpos++] = 0; /* word's trailing null */
/* Don't bother putting few-letter words in the table */
(words[i] || (i & 0xFF) == 0) && j < COLLISION_LIMIT; i++, j++)
if (words[i])
if (strcmp(word, words[i]) == 0) {
- *b++ = MARKER_CHAR;
- *b++ = (i >> 8) | TABLE_FLAG;
- *b++ = i & 0xFF;
- return;
+ *b++ = MARKER_CHAR;
+ *b++ = (i >> 8) | TABLE_FLAG;
+ *b++ = i & 0xFF;
+ return;
}
/* not in table, add to it */
if ((i & 0xFF) == 0) {
- i++; /* make sure we don't have a null in the message */
+ i++; /* make sure we don't have a null in the message */
j++;
}
/* Can't add to table if full */
*b++ = (i >> 8) | TABLE_FLAG;
*b++ = i & 0xFF;
-} /* end of output_previous_word */
+} /* end of output_previous_word */
/** Word-compress a string.
*
while (*p) {
if (!(isdigit(*p) || isalpha(*p)) || wordpos >= MAXWORDS) {
if (wordpos) {
- word[wordpos++] = *p; /* add trailing punctuation */
- output_previous_word();
- wordpos = 0;
+ word[wordpos++] = *p; /* add trailing punctuation */
+ output_previous_word();
+ wordpos = 0;
} else
- *b++ = *p;
+ *b++ = *p;
} else
word[wordpos++] = *p;
p++;
if (wordpos)
output_previous_word();
- *b = 0; /* trailing null */
+ *b = 0; /* trailing null */
#ifdef COMP_STATS
- total_comp += u_strlen(buf); /* calculate size of compressed text */
- total_uncomp += strlen(s); /* calculate size of uncompressed text */
+ total_comp += u_strlen(buf); /* calculate size of compressed text */
+ total_uncomp += strlen(s); /* calculate size of uncompressed text */
#endif
return u_strdup(buf);
-} /* end of compress; */
+} /* end of compress; */
/** Word-uncompress a string.
c = *p;
i = ((c & TABLE_MASK) << 8) | *(++p);
if (i >= MAXTABLE || words[i] == NULL) {
- static int panicking = 0;
- if (panicking) {
- fprintf(stderr,
- "Error in string decompression occurred during panic dump.\n");
- exit(1);
- } else {
- panicking = 1; /* don't panic from within panic */
- fprintf(stderr, "Error in string decompression, i = %i\n", i);
- mush_panic("Fatal error in decompression");
- }
+ static int panicking = 0;
+ if (panicking) {
+ fprintf(stderr,
+ "Error in string decompression occurred during panic dump.\n");
+ exit(1);
+ } else {
+ panicking = 1; /* don't panic from within panic */
+ fprintf(stderr, "Error in string decompression, i = %i\n", i);
+ mush_panic("Fatal error in decompression");
+ }
}
strncpy((char *) b, words[i], words_len[i]);
b += words_len[i] - 1;
p++;
}
- *b++ = 0; /* trailing null */
+ *b++ = 0; /* trailing null */
return buf;
-} /* end of uncompress; */
+} /* end of uncompress; */
/** Word-uncompress a string, allocating memory.
* this function should be used when you're doing something like
*/
void
compress_stats(long *entries, long *mem_used, long *total_uncompressed,
- long *total_compressed)
+ long *total_compressed)
{
*entries = total_entries;
#if defined(COMPRESSION_TYPE) && (COMPRESSION_TYPE == 0)
/* No compression */
-char ucbuff[BUFFER_LEN]; /**< Dummy buffer for no compression */
+char ucbuff[BUFFER_LEN]; /**< Dummy buffer for no compression */
#elif (COMPRESSION_TYPE == 1) || (COMPRESSION_TYPE == 2)
/* Huffman compression */
*/
char ucbuff[BUFFER_LEN];
-#endif /* Compression type checks */
+#endif /* Compression type checks */
#include "function.h"
#include "confmagic.h"
-time_t mudtime; /**< game time, in seconds */
+time_t mudtime; /**< game time, in seconds */
static void show_compile_options(dbref player);
static char *config_list_helper(dbref player, COBRA_CONF *cp, int lc);
static char *config_list_helper2(dbref player, COBRA_CONF *cp, int lc);
-OPTTAB options; /**< The table of configuration options */
-HASHTAB local_options; /**< Hash table for local config options */
+OPTTAB options; /**< The table of configuration options */
+HASHTAB local_options; /**< Hash table for local config options */
int config_set(const char *opt, char *val, int source, int restrictions);
void conf_default_set(void);
* the display of configuration options.
*/
typedef struct confgroupparm {
- const char *name; /**< name of group */
- const char *desc; /**< description of group */
- int viewperms; /**< who can view this group */
+ const char *name; /**< name of group */
+ const char *desc; /**< description of group */
+ int viewperms; /**< who can view this group */
} COBRA_CONFGROUP;
/** The table of all configuration groups. */
*/
COBRA_CONF *
add_config(const char *name, config_func handler, void *loc, int max,
- const char *group)
+ const char *group)
{
COBRA_CONF *cnf;
if ((cnf = get_config(name)))
*/
int
cf_bool(const char *opt, const char *val, void *loc,
- int maxval __attribute__ ((__unused__)), int source)
+ int maxval __attribute__ ((__unused__)), int source)
{
/* enter boolean parameter */
!strcasecmp(val, "1"))
*((int *) loc) = 1;
else if (!strcasecmp(val, "no") || !strcasecmp(val, "false") ||
- !strcasecmp(val, "0"))
+ !strcasecmp(val, "0"))
*((int *) loc) = 0;
else {
if (source == 0) {
n = maxval;
if (source == 0) {
do_rawlog(LT_ERR, T("CONFIG: option %s value limited to #%d\n"), opt,
- maxval);
+ maxval);
}
}
if (source && (!GoodObject(n) || IsGarbage(n))) {
do_rawlog(LT_ERR,
- T("CONFIG: attempt to set option %s to a bad dbref (#%d)"),
- opt, n);
+ T("CONFIG: attempt to set option %s to a bad dbref (#%d)"),
+ opt, n);
return 0;
}
*((dbref *) loc) = n;
n = maxval;
if (source == 0) {
do_rawlog(LT_ERR, T("CONFIG: option %s value limited to %d\n"), opt,
- maxval);
+ maxval);
}
}
*((int *) loc) = n;
switch (*end) {
case '\0':
if (in_minutes)
- secs += n * 60;
+ secs += n * 60;
else
- secs += n;
- goto done; /* Sigh. What I wouldn't give for named loops in C */
+ secs += n;
+ goto done; /* Sigh. What I wouldn't give for named loops in C */
case 's':
case 'S':
secs += n;
break;
default:
if (source == 0)
- do_rawlog(LT_ERR, T("CONFIG: Unknown time interval in option %s"), opt);
+ do_rawlog(LT_ERR, T("CONFIG: Unknown time interval in option %s"), opt);
return 0;
}
val = end + 1;
secs = maxval;
if (source == 0) {
do_rawlog(LT_ERR, T("CONFIG: option %s value limited to %d\n"), opt,
- maxval);
+ maxval);
}
}
*((int *) loc) = secs;
len = maxval - total - 1;
if (len <= 0) {
if (source == 0)
- do_rawlog(LT_ERR, T("CONFIG: option %s value overflow\n"), opt);
+ do_rawlog(LT_ERR, T("CONFIG: option %s value overflow\n"), opt);
return 0;
}
if (source == 0)
char *p;
if (!val)
- return 0; /* NULL val is no good, but "" is ok */
+ return 0; /* NULL val is no good, but "" is ok */
/* Was this "restrict_command <command> <restriction>"? If so, do it */
if(!strcasecmp(opt, "lock_command")) {
if(*p) {
*p++ = '\0';
if(!command_lock(val, p)) {
- if(source == 0)
- do_rawlog(LT_ERR, T("CONFIG: Invalid command or lock bool expression for %s.\n"), val);
- return 0;
+ if(source == 0)
+ do_rawlog(LT_ERR, T("CONFIG: Invalid command or lock bool expression for %s.\n"), val);
+ return 0;
}
} else {
if(source == 0)
- do_rawlog(LT_ERR, T("CONFIG: lock_command %s requires a lock boolexp.\n"), val);
- return 0;
+ do_rawlog(LT_ERR, T("CONFIG: lock_command %s requires a lock boolexp.\n"), val);
+ return 0;
}
return 1;
} else if (!strcasecmp(opt, "restrict_command")) {
if (*p) {
*p++ = '\0';
if (!restrict_command(val, p)) {
- if (source == 0) {
- do_rawlog(LT_ERR,
- T("CONFIG: Invalid command or restriction for %s.\n"), val);
- }
- return 0;
+ if (source == 0) {
+ do_rawlog(LT_ERR,
+ T("CONFIG: Invalid command or restriction for %s.\n"), val);
+ }
+ return 0;
}
} else {
if (source == 0) {
- do_rawlog(LT_ERR,
- T
- ("CONFIG: restrict_command %s requires a restriction value.\n"),
- val);
+ do_rawlog(LT_ERR,
+ T
+ ("CONFIG: restrict_command %s requires a restriction value.\n"),
+ val);
}
return 0;
}
if (*p) {
*p++ = '\0';
if (!restrict_function(val, p)) {
- if (source == 0) {
- do_rawlog(LT_ERR,
- T("CONFIG: Invalid function or restriction for %s.\n"),
- val);
- }
- return 0;
+ if (source == 0) {
+ do_rawlog(LT_ERR,
+ T("CONFIG: Invalid function or restriction for %s.\n"),
+ val);
+ }
+ return 0;
}
} else {
if (source == 0) {
- do_rawlog(LT_ERR,
- T
- ("CONFIG: restrict_function %s requires a restriction value.\n"),
- val);
+ do_rawlog(LT_ERR,
+ T
+ ("CONFIG: restrict_function %s requires a restriction value.\n"),
+ val);
}
return 0;
}
if (*p) {
*p++ = '\0';
if (!alias_command(val, p)) {
- if (source == 0) {
- do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
- }
- return 0;
+ if (source == 0) {
+ do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
+ }
+ return 0;
}
} else {
if (source == 0) {
- do_rawlog(LT_ERR,
- T("CONFIG: command_alias %s requires an alias.\n"), val);
+ do_rawlog(LT_ERR,
+ T("CONFIG: command_alias %s requires an alias.\n"), val);
}
return 0;
}
if (*p) {
*p++ = '\0';
if (!alias_attribute(val, p)) {
- if (source == 0) {
- do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
- }
- return 0;
+ if (source == 0) {
+ do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
+ }
+ return 0;
}
} else {
if (source == 0) {
- do_rawlog(LT_ERR,
- T("CONFIG: attribute_alias %s requires an alias.\n"), val);
+ do_rawlog(LT_ERR,
+ T("CONFIG: attribute_alias %s requires an alias.\n"), val);
}
return 0;
}
if (*p) {
*p++ = '\0';
if (!alias_function(val, p)) {
- if (source == 0) {
- do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
- }
- return 0;
+ if (source == 0) {
+ do_rawlog(LT_ERR, T("CONFIG: Couldn't alias %s to %s.\n"), p, val);
+ }
+ return 0;
}
} else {
if (source == 0) {
- do_rawlog(LT_ERR,
- T("CONFIG: function_alias %s requires an alias.\n"), val);
+ do_rawlog(LT_ERR,
+ T("CONFIG: function_alias %s requires an alias.\n"), val);
}
return 0;
}
return 1;
} else if (!strcasecmp(opt, "help_command")
- || !strcasecmp(opt, "ahelp_command")) {
+ || !strcasecmp(opt, "ahelp_command")) {
char *comm, *file;
int admin = !strcasecmp(opt, "ahelp_command");
if (!restrictions)
return 0;
if (!val || !*val) {
do_rawlog(LT_ERR,
- T
- ("CONFIG: help_command requires a command name and file name.\n"));
+ T
+ ("CONFIG: help_command requires a command name and file name.\n"));
return 0;
}
comm = val;
return 1;
} else {
do_rawlog(LT_ERR,
- T
- ("CONFIG: help_command requires a command name and file name.\n"));
+ T
+ ("CONFIG: help_command requires a command name and file name.\n"));
return 0;
}
} else if (restrictions) {
for (cp = conftable; cp->name; cp++) {
int i = 0;
if ((!source || (cp->group && strcmp(cp->group, "files") != 0
- && strcmp(cp->group, "messages") != 0))
- && !strcasecmp(cp->name, opt)) {
+ && strcmp(cp->group, "messages") != 0))
+ && !strcasecmp(cp->name, opt)) {
i = cp->handler(opt, val, cp->loc, cp->max, source);
if (i)
- cp->overridden = 1;
+ cp->overridden = 1;
return i;
}
}
cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
int i = 0;
if ((!source || (cp->group && strcmp(cp->group, "files") != 0
- && strcmp(cp->group, "messages") != 0))
- && !strcasecmp(cp->name, opt)) {
+ && strcmp(cp->group, "messages") != 0))
+ && !strcasecmp(cp->name, opt)) {
i = cp->handler(opt, val, cp->loc, cp->max, source);
if (i)
- cp->overridden = 1;
+ cp->overridden = 1;
return i;
}
}
options.ancestor_exit = -1;
options.ancestor_thing = -1;
options.ancestor_player = -1;
- options.powerless = 1; /* This is bad, they should change this ASAP when they start a game */
+ options.powerless = 1; /* This is bad, they should change this ASAP when they start a game */
options.idle_timeout = 0;
options.idle_time = 0;
options.unconnected_idle_timeout = 300;
options.keepalive_timeout = 300;
options.dump_interval = 3601;
strcpy(options.dump_message,
- T("GAME: Dumping database. Game may freeze for a minute"));
+ T("GAME: Dumping database. Game may freeze for a minute"));
strcpy(options.dump_complete, T("GAME: Dump complete. Time in."));
options.ident_timeout = 5;
options.max_logins = 128;
strcpy(options.compressprog, "compress");
strcpy(options.uncompressprog, "uncompress");
strcpy(options.compresssuff, ".Z");
-#endif /* WIN32 */
+#endif /* WIN32 */
strcpy(options.connect_file[0], "txt/connect.txt");
strcpy(options.motd_file[0], "txt/motd.txt");
strcpy(options.newuser_file[0], "txt/newuser.txt");
options.warn_interval = 3600;
options.use_dns = 1;
strcpy(options.dump_warning_1min,
- T("GAME: Database will be dumped in 1 minute."));
+ T("GAME: Database will be dumped in 1 minute."));
strcpy(options.dump_warning_5min,
- T("GAME: Database will be dumped in 5 minutes."));
+ T("GAME: Database will be dumped in 5 minutes."));
options.noisy_whisper = 0;
options.possessive_get = 1;
options.possessive_get_d = 1;
char tbuf1[BUFFER_LEN];
char *p, *q, *s;
- static char cfile[BUFFER_LEN]; /* Remember the last one */
+ static char cfile[BUFFER_LEN]; /* Remember the last one */
if (conf_recursion == 0) {
if (conf && *conf)
strcpy(cfile, conf);
fp = fopen(conf, FOPEN_READ);
if (fp == NULL) {
do_rawlog(LT_ERR, T("ERROR: Cannot open configuration file %s."),
- (conf && *conf) ? conf : "Unknown");
+ (conf && *conf) ? conf : "Unknown");
return 0;
}
do_rawlog(LT_ERR, "Reading %s", conf);
*/
for (p = tbuf1; *p && (*p != '\n') && (*p != '\r'); p++) ;
- *p = '\0'; /* strip the end of line char(s) */
- for (p = tbuf1; *p && isspace((unsigned char) *p); p++) /* strip spaces */
+ *p = '\0'; /* strip the end of line char(s) */
+ for (p = tbuf1; *p && isspace((unsigned char) *p); p++) /* strip spaces */
;
- for (q = p; *q && !isspace((unsigned char) *q); q++) /* move over command */
+ for (q = p; *q && !isspace((unsigned char) *q); q++) /* move over command */
;
if (*q)
- *q++ = '\0'; /* split off command */
- for (; *q && isspace((unsigned char) *q); q++) /* skip spaces */
+ *q++ = '\0'; /* split off command */
+ for (; *q && isspace((unsigned char) *q); q++) /* skip spaces */
;
/* If the first character of the value is a #, and that is
followed by a number, treat it as a dbref instead of a
comment. */
if (*q == '#' && isdigit((unsigned char) *(q + 1))) {
- for (s = q + 1; *s && (*s != '#'); s++) /* look for a real comment */
- ;
+ for (s = q + 1; *s && (*s != '#'); s++) /* look for a real comment */
+ ;
} else {
- for (s = q; *s && (*s != '#'); s++) /* look for comment */
- ;
+ for (s = q; *s && (*s != '#'); s++) /* look for comment */
+ ;
}
- if (*s) /* if found nuke it */
+ if (*s) /* if found nuke it */
*s = '\0';
- for (s = s - 1; (s >= q) && isspace((unsigned char) *s); s--) /* smash trailing stuff */
+ for (s = s - 1; (s >= q) && isspace((unsigned char) *s); s--) /* smash trailing stuff */
*s = '\0';
- if (strlen(p) != 0) { /* skip blank lines */
+ if (strlen(p) != 0) { /* skip blank lines */
/* Handle include filename directives separetly */
if (strcasecmp(p, "include") == 0) {
- conf_recursion++;
- if (conf_recursion > 10) {
- do_rawlog(LT_ERR, T("CONFIG: include depth too deep in file %s"),
- conf);
- } else {
- config_file_startup(q, restrictions);
- }
- conf_recursion--;
+ conf_recursion++;
+ if (conf_recursion > 10) {
+ do_rawlog(LT_ERR, T("CONFIG: include depth too deep in file %s"),
+ conf);
+ } else {
+ config_file_startup(q, restrictions);
+ }
+ conf_recursion--;
} else
- config_set(p, q, 0, restrictions);
+ config_set(p, q, 0, restrictions);
}
fgets(tbuf1, BUFFER_LEN, fp);
}
if (conf_recursion == 0) {
for (cp = conftable; cp->name; cp++) {
if (!cp->overridden) {
- do_rawlog(LT_ERR,
- T
- ("CONFIG: directive '%s' missing from cnf file, using default value."),
- cp->name);
+ do_rawlog(LT_ERR,
+ T
+ ("CONFIG: directive '%s' missing from cnf file, using default value."),
+ cp->name);
}
}
for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
- cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
+ cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
if (!cp->overridden) {
- do_rawlog(LT_ERR,
- T
- ("CONFIG: local directive '%s' missing from cnf file. using default value."),
- cp->name);
+ do_rawlog(LT_ERR,
+ T
+ ("CONFIG: local directive '%s' missing from cnf file. using default value."),
+ cp->name);
}
}
/* if we're on Win32, complain about compression */
if ((options.compressprog && *options.compressprog)) {
do_rawlog(LT_ERR,
- T
- ("CONFIG: compression program is specified but not used in Win32, ignoring"),
- options.compressprog);
+ T
+ ("CONFIG: compression program is specified but not used in Win32, ignoring"),
+ options.compressprog);
}
if (((options.compresssuff && *options.compresssuff))) {
do_rawlog(LT_ERR,
- T
- ("CONFIG: compression suffix is specified but not used in Win32, ignoring"),
- options.compresssuff);
+ T
+ ("CONFIG: compression suffix is specified but not used in Win32, ignoring"),
+ options.compresssuff);
}
/* Also remove the compression options */
int found = 0;
for (cgp = confgroups; cgp->name; cgp++) {
if (string_prefix(T(cgp->name), type)
- && Can_View_Config_Group(player, cgp)) {
- found = 1;
- break;
+ && Can_View_Config_Group(player, cgp)) {
+ found = 1;
+ break;
}
}
if (!found) {
/* It wasn't a group. Is is one or more specific options? */
for (cp = conftable; cp->name; cp++) {
- if (cp->group && string_prefix(cp->name, type)) {
- notify(player, config_list_helper(player, cp, lc));
- found = 1;
- }
+ if (cp->group && string_prefix(cp->name, type)) {
+ notify(player, config_list_helper(player, cp, lc));
+ found = 1;
+ }
}
if (!found) {
- /* Ok, maybe a local option? */
- for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
- cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
- if (cp->group && !strcasecmp(cp->name, type)) {
- notify(player, config_list_helper(player, cp, lc));
- found = 1;
- }
- }
+ /* Ok, maybe a local option? */
+ for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
+ cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
+ if (cp->group && !strcasecmp(cp->name, type)) {
+ notify(player, config_list_helper(player, cp, lc));
+ found = 1;
+ }
+ }
}
if (!found) {
- /* Wasn't found at all. Ok. */
- notify(player, T("I only know the following types of options:"));
- for (cgp = confgroups; cgp->name; cgp++) {
- if (Can_View_Config_Group(player, cgp))
- notify_format(player, " %-15s %s", T(cgp->name), cgp->desc);
- }
+ /* Wasn't found at all. Ok. */
+ notify(player, T("I only know the following types of options:"));
+ for (cgp = confgroups; cgp->name; cgp++) {
+ if (Can_View_Config_Group(player, cgp))
+ notify_format(player, " %-15s %s", T(cgp->name), cgp->desc);
+ }
}
} else {
/* Show all entries of that type */
notify(player, cgp->desc);
if (string_prefix("compile", type))
- show_compile_options(player);
+ show_compile_options(player);
else {
- for (cp = conftable; cp->name; cp++) {
- if (cp->group && !strcmp(cp->group, cgp->name)) {
- notify(player, config_list_helper(player, cp, lc));
- }
- }
- for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
- cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
- if (cp->group && !strcasecmp(cp->group, cgp->name)) {
- notify(player, config_list_helper(player, cp, lc));
- }
- }
+ for (cp = conftable; cp->name; cp++) {
+ if (cp->group && !strcmp(cp->group, cgp->name)) {
+ notify(player, config_list_helper(player, cp, lc));
+ }
+ }
+ for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
+ cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
+ if (cp->group && !strcasecmp(cp->group, cgp->name)) {
+ notify(player, config_list_helper(player, cp, lc));
+ }
+ }
}
}
} else {
/* If we're here, we ran @config without a type. */
notify(player,
- T("Use: @config/list <type of options> where type is one of:"));
+ T("Use: @config/list <type of options> where type is one of:"));
for (cgp = confgroups; cgp->name; cgp++) {
if (Can_View_Config_Group(player, cgp))
- notify_format(player, " %-15s %s", T(cgp->name), cgp->desc);
+ notify_format(player, " %-15s %s", T(cgp->name), cgp->desc);
}
}
if (SUPPORT_PUEBLO)
safe_format(result, &bp, " %-40s %s", MAYBE_LC(cp->name), (char *) cp->loc);
else if (cp->handler == cf_int)
safe_format(result, &bp, " %-40s %d", MAYBE_LC(cp->name),
- *((int *) cp->loc));
+ *((int *) cp->loc));
else if (cp->handler == cf_time) {
div_t n;
int secs = *(int *) cp->loc;
safe_format(result, &bp, "%ds", secs);
} else if (cp->handler == cf_bool)
safe_format(result, &bp, " %-40s %s", MAYBE_LC(cp->name),
- (*((int *) cp->loc) ? "Yes" : "No"));
+ (*((int *) cp->loc) ? "Yes" : "No"));
else if (cp->handler == cf_dbref)
safe_format(result, &bp, " %-40s #%d", MAYBE_LC(cp->name),
- *((dbref *) cp->loc));
+ *((dbref *) cp->loc));
*bp = '\0';
return result;
}
/* This one doesn't return the names */
static char *
config_list_helper2(dbref player __attribute__ ((__unused__)), COBRA_CONF *cp, int lc
- __attribute__ ((__unused__)))
+ __attribute__ ((__unused__)))
{
static char result[BUFFER_LEN];
char *bp = result;
if (args[0] && *args[0]) {
for (cp = conftable; cp->name; cp++) {
if (cp->group && !strcasecmp(cp->name, args[0])) {
- safe_str(config_list_helper2(executor, cp, 0), buff, bp);
- return;
+ safe_str(config_list_helper2(executor, cp, 0), buff, bp);
+ return;
}
}
for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
- cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
+ cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
if (cp->group && !strcasecmp(cp->name, args[0])) {
- safe_str(config_list_helper2(executor, cp, 0), buff, bp);
- return;
+ safe_str(config_list_helper2(executor, cp, 0), buff, bp);
+ return;
}
}
safe_str(T("#-1 NO SUCH CONFIG OPTION"), buff, bp);
safe_chr(' ', buff, bp);
}
for (cp = (COBRA_CONF *) hash_firstentry(&local_options); cp;
- cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
+ cp = (COBRA_CONF *) hash_nextentry(&local_options)) {
safe_str(cp->name, buff, bp);
safe_chr(' ', buff, bp);
}
for (cp = conftable; cp->name; cp++) {
if (cp->group && !strcasecmp(cp->name, param)) {
if (cp->handler == cf_bool) {
- cf_bool(param, (state ? "yes" : "no"), cp->loc, cp->max, 1);
- if (state == 0)
- notify(player, T("Disabled."));
- else
- notify(player, T("Enabled."));
- do_log(LT_WIZ, player, NOTHING, "%s %s",
- cp->name, (state) ? "ENABLED" : "DISABLED");
+ cf_bool(param, (state ? "yes" : "no"), cp->loc, cp->max, 1);
+ if (state == 0)
+ notify(player, T("Disabled."));
+ else
+ notify(player, T("Enabled."));
+ do_log(LT_WIZ, player, NOTHING, "%s %s",
+ cp->name, (state) ? "ENABLED" : "DISABLED");
} else
- notify(player, T("That isn't a on/off option."));
+ notify(player, T("That isn't a on/off option."));
return;
}
}
#ifdef USE_MAILER
notify(player,
- T(" The extended built-in MUSH mailing system is being used."));
+ T(" The extended built-in MUSH mailing system is being used."));
#ifdef ALLOW_NOSUBJECT
notify(player,
- T(" Messages without subject lines have subject (no subject)"));
+ T(" Messages without subject lines have subject (no subject)"));
#else
notify(player,
- T
- (" Messages without subject lines use the beginning of the message as subject"));
+ T
+ (" Messages without subject lines use the beginning of the message as subject"));
#endif
#else
notify(player, T(" The built-in MUSH mailing system is not being used."));
#include "confmagic.h"
-#define MAX_QID 16384
+#define MAX_QID 16384
extern dbref global_parent_depth[1];
EVAL_CONTEXT global_eval_context;
-enum qid_flags qid_table[MAX_QID]; /**< List of flagged qids. */
-int qid_cnt; /**< What QID we're at */
+enum qid_flags qid_table[MAX_QID]; /**< List of flagged qids. */
+int qid_cnt; /**< What QID we're at */
/** A queue entry.
* This structure reprsents a queue entry on a linked list of queue
* entries (a queue). It is used for all of the queues.
*/
typedef struct bque {
- struct bque *next; /**< pointer to next entry on queue */
- dbref player; /**< player who will do command */
- dbref queued; /**< object whose QUEUE gets incremented for this command */
- dbref cause; /**< player causing command (for %N) */
- dbref realcause; /** most of the time same as cause.. except for divisions. */
- dbref ooref; /**< Used when doing twin checks */
- dbref sem; /**< semaphore object to block on */
- char *semattr; /**< semaphore attribute to block on */
- int left; /**< seconds left until execution */
- char *env[10]; /**< environment, from wild match */
- char *rval[NUMQ]; /**< environment, from setq() */
- char *comm; /**< command to be executed */
+ struct bque *next; /**< pointer to next entry on queue */
+ dbref player; /**< player who will do command */
+ dbref queued; /**< object whose QUEUE gets incremented for this command */
+ dbref cause; /**< player causing command (for %N) */
+ dbref realcause; /** most of the time same as cause.. except for divisions. */
+ dbref ooref; /**< Used when doing twin checks */
+ dbref sem; /**< semaphore object to block on */
+ char *semattr; /**< semaphore attribute to block on */
+ int left; /**< seconds left until execution */
+ char *env[10]; /**< environment, from wild match */
+ char *rval[NUMQ]; /**< environment, from setq() */
+ char *comm; /**< command to be executed */
#ifdef _SWMP_
int sql_env[2]; /**< sql environment 0- Query ID, 1-Auth ID */
#endif
- char fqueued; /**< function inserted into queue */
+ char fqueued; /**< function inserted into queue */
enum qid_flags qid; /**< queue identification # */
HASHTAB namedregs;
} BQUE;
void free_qentry(BQUE *point);
static int pay_queue(dbref player, const char *command);
int wait_que(dbref player, int wait, char *command,
- dbref cause, dbref sem, const char *semattr, int until, char finvoc);
+ dbref cause, dbref sem, const char *semattr, int until, char finvoc);
void init_qids();
int create_qid();
int que_next(void);
static void show_queue(dbref player, dbref victim, int q_type,
- int q_quiet, int q_all, BQUE *q_ptr, int *tot, int *self,
- int *del);
+ int q_quiet, int q_all, BQUE *q_ptr, int *tot, int *self,
+ int *del);
static void check_qsigs(BQUE **qchk);
static void do_raw_restart(dbref victim);
static int waitable_attr(dbref thing, const char *atr);
static void shutdown_a_queue(BQUE **head, BQUE **tail);
-extern sig_atomic_t cpu_time_limit_hit; /**< Have we used too much CPU? */
+extern sig_atomic_t cpu_time_limit_hit; /**< Have we used too much CPU? */
/** Attribute flags to be set or checked on attributes to be used
* as semaphores.
void init_qids() {
- int i;
+ int i;
- /* set whole thing to NULL */
- for(i = 0; i < MAX_QID; i++)
- qid_table[i] = QID_FALSE;
- qid_table[MAX_QID] = '\0';
- qid_cnt = 0;
+ /* set whole thing to NULL */
+ for(i = 0; i < MAX_QID; i++)
+ qid_table[i] = QID_FALSE;
+ qid_table[MAX_QID] = '\0';
+ qid_cnt = 0;
}
int create_qid() { /* find an unused QID */
- int i;
-
- for(i = 0; i < MAX_QID; i++)
- if(qid_table[i] == QID_FALSE)
- break;
- /* No Good QID */
- if(qid_table[i] != QID_FALSE || i == MAX_QID)
- return -1;
- if(i > qid_cnt) /* set this so we don't go too high looking for a qid */
- qid_cnt = i;
- /* flag the QID entry & return it */
- qid_table[i] = QID_ACTIVE;
- return i;
+ int i;
+
+ for(i = 0; i < MAX_QID; i++)
+ if(qid_table[i] == QID_FALSE)
+ break;
+ /* No Good QID */
+ if(qid_table[i] != QID_FALSE || i == MAX_QID)
+ return -1;
+ if(i > qid_cnt) /* set this so we don't go too high looking for a qid */
+ qid_cnt = i;
+ /* flag the QID entry & return it */
+ qid_table[i] = QID_ACTIVE;
+ return i;
}
/* Returns true if the attribute on thing can be used as a semaphore.
if (!atr || !*atr)
return 0;
a = atr_get_noparent(thing, atr);
- if (!a) { /* Attribute isn't set */
+ if (!a) { /* Attribute isn't set */
a = atr_match(atr);
- if (!a) /* It's not a built in attribute */
+ if (!a) /* It's not a built in attribute */
return 1;
- return !strcmp(AL_NAME(a), "SEMAPHORE"); /* Only allow SEMAPHORE for now */
- } else { /* Attribute is set. Check for proper owner and flags and value */
+ return !strcmp(AL_NAME(a), "SEMAPHORE"); /* Only allow SEMAPHORE for now */
+ } else { /* Attribute is set. Check for proper owner and flags and value */
if ((AL_CREATOR(a) == GOD) && (AL_FLAGS(a) == SEMAPHORE_FLAGS)) {
char *v = atr_value(a);
if (!*v || is_integer(v))
- return 1;
+ return 1;
else
- return 0;
+ return 0;
} else {
return 0;
}
}
- return 0; /* Not reached */
+ return 0; /* Not reached */
}
static int
add_to_sem(dbref player, int am, const char *name)
{
return (add_to_generic
- (player, am, name ? name : "SEMAPHORE", SEMAPHORE_FLAGS));
+ (player, am, name ? name : "SEMAPHORE", SEMAPHORE_FLAGS));
}
static int
/* first free up the QID */
qid_table[point->qid] = QID_FALSE;
if(point->qid == qid_cnt) {
- for(a = qid_cnt; a > -1; a--)
- if(qid_table[a] != QID_FALSE)
- break;
- if(qid_table[a] != QID_FALSE)
- qid_cnt = a;
- else /* nothing on the queue at all.. set us down to 0 */
- qid_cnt = 0;
+ for(a = qid_cnt; a > -1; a--)
+ if(qid_table[a] != QID_FALSE)
+ break;
+ if(qid_table[a] != QID_FALSE)
+ qid_cnt = a;
+ else /* nothing on the queue at all.. set us down to 0 */
+ qid_cnt = 0;
}
for (a = 0; a < 10; a++)
if (point->env[a]) {
char *preserveq[NUMQ];
HASHTAB preserve_namedregs;
save_global_nxt("pay_queue_save", preserve_wnxt, preserve_rnxt, val_wnxt,
- val_rnxt);
+ val_rnxt);
save_global_regs("pay_queue_save", preserveq);
save_global_env("pay_queue_save", preserves);
init_namedregs(&preserve_namedregs);
copy_namedregs(&preserve_namedregs, &global_eval_context.namedregs);
clear_namedregs(&global_eval_context.namedregs);
notify_format(Owner(player),
- T("GAME: Object %s(%s) lost a %s to queue loss."),
- Name(player), unparse_dbref(player), MONEY);
+ T("GAME: Object %s(%s) lost a %s to queue loss."),
+ Name(player), unparse_dbref(player), MONEY);
copy_namedregs(&global_eval_context.namedregs, &preserve_namedregs);
free_namedregs(&preserve_namedregs);
restore_global_regs("pay_queue_save", preserveq);
restore_global_env("pay_queue_save", preserves);
restore_global_nxt("pay_queue_save", preserve_wnxt, preserve_rnxt, val_wnxt,
- val_rnxt);
+ val_rnxt);
}
if (queue_limit(QUEUE_PER_OWNER ? Owner(player) : player)) {
notify_format(Owner(player),
- T("Runaway object: %s(%s). Commands halted."),
- Name(player), unparse_dbref(player));
+ T("Runaway object: %s(%s). Commands halted."),
+ Name(player), unparse_dbref(player));
do_log(LT_TRACE, player, player, T("Runaway object %s executing: %s"),
- unparse_dbref(player), command);
+ unparse_dbref(player), command);
/* Refund the queue costs */
giveto(player, QUEUE_COST);
add_to(QUEUE_PER_OWNER ? Owner(player) : player, -1);
int qid;
if (!IsPlayer(player) && (Halted(player)))
return;
- if (!pay_queue(player, command)) /* make sure player can afford to do it */
+ if (!pay_queue(player, command)) /* make sure player can afford to do it */
return;
if((qid = create_qid()) == -1) /* No room for a process ID, don't do anything */
- return;
+ return;
tmp = (BQUE *) mush_malloc(sizeof(BQUE), "BQUE");
tmp->qid = qid;
tmp->comm = mush_strdup(command, "bqueue_comm");
if (!IsPlayer(division) && (Halted(division)))
return;
if((qid = create_qid()) == -1) /* No room to process shit.. don't do shit */
- return;
+ return;
tmp = (BQUE *) mush_malloc(sizeof(BQUE), "BQUE");
tmp->qid = qid;
tmp->comm = mush_strdup(command, "bqueue_comm");
*/
int
queue_attribute_base(dbref executor, const char *atrname, dbref enactor,
- int noparent)
+ int noparent)
{
ATTR *a;
queue_attribute_getatr(dbref executor, const char *atrname, int noparent)
{
return (noparent ? atr_get_noparent(executor, strupper(atrname)) :
- atr_get(executor, strupper(atrname)));
+ atr_get(executor, strupper(atrname)));
}
int
}
local_ooref = ooref;
if(options.twinchecks && ( ((global_parent_depth[0] < 1 && global_parent_depth[1] != executor) ||
- global_parent_depth[1] != NOTHING) &&
- !has_flag_by_name(global_parent_depth[1], "AUTH_PARENT", NOTYPE) )) ooref = AL_CREATOR(a);
+ global_parent_depth[1] != NOTHING) &&
+ !has_flag_by_name(global_parent_depth[1], "AUTH_PARENT", NOTYPE) )) ooref = AL_CREATOR(a);
/* Now we're going to do a little magick... If we caught powinhearit isn't nothing we're using div_parse_que instead */
if(GoodObject(powinherit))
div_parse_que(powinherit, command, executor, enactor);
*/
int
wait_que(dbref player, int wait, char *command, dbref cause, dbref sem,
- const char *semattr, int until, char finvoc)
+ const char *semattr, int until, char finvoc)
{
BQUE *tmp;
int a, qid;
parse_que(player, command, cause);
return 0;
}
- if (!pay_queue(player, command)) /* make sure player can afford to do it */
+ if (!pay_queue(player, command)) /* make sure player can afford to do it */
return -1;
if((qid = create_qid()) < 0) /* can't obtain a QID */
- return -1;
+ return -1;
tmp = (BQUE *) mush_malloc(sizeof(BQUE), "BQUE");
tmp->qid = qid;
tmp->comm = mush_strdup(command, "bqueue_comm");
if (wait >= 0)
tmp->left = mudtime + wait;
else
- tmp->left = 0; /* semaphore wait without a timeout */
+ tmp->left = 0; /* semaphore wait without a timeout */
}
tmp->sem = sem;
if (sem == NOTHING) {
BQUE *point, *trail = NULL;
for (point = qwait;
- point && (point->left <= tmp->left); point = point->next)
+ point && (point->left <= tmp->left); point = point->next)
trail = point;
tmp->next = point;
point->left = 0;
if (IsPlayer(point->cause)) {
if (qlast) {
- qlast->next = point;
- qlast = point;
+ qlast->next = point;
+ qlast = point;
} else
- qlast = qfirst = point;
+ qlast = qfirst = point;
} else {
if (qllast) {
- qllast->next = point;
- qllast = point;
+ qllast->next = point;
+ qllast = point;
} else
- qllast = qlfirst = point;
+ qllast = qlfirst = point;
}
}
for (point = qsemfirst, trail = NULL; point; point = next) {
if (point->left == 0 || point->left > mudtime) {
next = (trail = point)->next;
- continue; /* skip non-timed, frozen, and those that haven't gone off yet */
+ continue; /* skip non-timed, frozen, and those that haven't gone off yet */
}
if (trail != NULL)
trail->next = next = point->next;
point->next = NULL;
if (IsPlayer(point->cause)) {
if (qlast) {
- qlast->next = point;
- qlast = point;
+ qlast->next = point;
+ qlast = point;
} else
- qlast = qfirst = point;
+ qlast = qfirst = point;
} else {
if (qllast) {
- qllast->next = point;
- qllast = point;
+ qllast->next = point;
+ qllast = point;
} else
- qllast = qlfirst = point;
+ qllast = qlfirst = point;
}
}
}
add_to(entry->queued, -1);
entry->player = 0;
if (IsPlayer(global_eval_context.cplr) || !Halted(global_eval_context.cplr)) {
- for (a = 0; a < 10; a++)
- global_eval_context.wenv[a] = entry->env[a];
- for (a = 0; a < NUMQ; a++) {
- if (entry->rval[a])
- strcpy(global_eval_context.renv[a], entry->rval[a]);
- else
- global_eval_context.renv[a][0] = '\0';
- }
+ for (a = 0; a < 10; a++)
+ global_eval_context.wenv[a] = entry->env[a];
+ for (a = 0; a < NUMQ; a++) {
+ if (entry->rval[a])
+ strcpy(global_eval_context.renv[a], entry->rval[a]);
+ else
+ global_eval_context.renv[a][0] = '\0';
+ }
copy_namedregs(&global_eval_context.namedregs, &entry->namedregs);
- global_eval_context.process_command_port = 0;
- s = entry->comm;
- global_eval_context.break_called = 0;
- break_count = 100;
- *(global_eval_context.break_replace) = '\0';
- start_cpu_timer();
- while (!cpu_time_limit_hit && *s) {
- r = global_eval_context.ccom;
- local_ooref = ooref;
- ooref = entry->ooref;
- if(!entry->fqueued) {
- process_expression(global_eval_context.ccom, &r, &s, global_eval_context.cplr, entry->cause,
- entry->realcause, PE_NOTHING, PT_SEMI, NULL);
- *r = '\0';
- if (*s == ';')
- s++;
- strcpy(tbuf, global_eval_context.ccom);
- process_command(global_eval_context.cplr, tbuf, entry->cause, entry->realcause, 0);
- if(global_eval_context.break_called) {
- global_eval_context.break_called = 0;
- s = global_eval_context.break_replace;
- if(!*global_eval_context.break_replace) {
- ooref = local_ooref;
- break;
- }
- break_count--;
- if(!break_count) {
- notify(global_eval_context.cplr, T("@break recursion exceeded."));
- ooref = local_ooref;
- break;
- }
- }
- } else {
- process_expression(global_eval_context.ccom, &r, &s, global_eval_context.cplr, entry->cause, entry->realcause, PE_DEFAULT,
- PT_DEFAULT, (PE_Info *) NULL);
- *r = '\0';
- notify(global_eval_context.cplr, global_eval_context.ccom);
- }
- ooref = local_ooref;
- }
- reset_cpu_timer();
+ global_eval_context.process_command_port = 0;
+ s = entry->comm;
+ global_eval_context.break_called = 0;
+ break_count = 100;
+ *(global_eval_context.break_replace) = '\0';
+ start_cpu_timer();
+ while (!cpu_time_limit_hit && *s) {
+ r = global_eval_context.ccom;
+ local_ooref = ooref;
+ ooref = entry->ooref;
+ if(!entry->fqueued) {
+ process_expression(global_eval_context.ccom, &r, &s, global_eval_context.cplr, entry->cause,
+ entry->realcause, PE_NOTHING, PT_SEMI, NULL);
+ *r = '\0';
+ if (*s == ';')
+ s++;
+ strcpy(tbuf, global_eval_context.ccom);
+ process_command(global_eval_context.cplr, tbuf, entry->cause, entry->realcause, 0);
+ if(global_eval_context.break_called) {
+ global_eval_context.break_called = 0;
+ s = global_eval_context.break_replace;
+ if(!*global_eval_context.break_replace) {
+ ooref = local_ooref;
+ break;
+ }
+ break_count--;
+ if(!break_count) {
+ notify(global_eval_context.cplr, T("@break recursion exceeded."));
+ ooref = local_ooref;
+ break;
+ }
+ }
+ } else {
+ process_expression(global_eval_context.ccom, &r, &s, global_eval_context.cplr, entry->cause, entry->realcause, PE_DEFAULT,
+ PT_DEFAULT, (PE_Info *) NULL);
+ *r = '\0';
+ notify(global_eval_context.cplr, global_eval_context.ccom);
+ }
+ ooref = local_ooref;
+ }
+ reset_cpu_timer();
}
}
free_qentry(entry);
}
for (point = qsemfirst; point; point = point->next) {
- if (point->left == 0) /* no timeout */
+ if (point->left == 0) /* no timeout */
continue;
curr = point->left - mudtime;
if (curr <= 2)
static int
drain_helper(dbref player __attribute__ ((__unused__)), dbref thing,
- dbref parent __attribute__ ((__unused__)),
- char const *pattern __attribute__ ((__unused__)), ATTR *atr,
- void *args __attribute__ ((__unused__)))
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern __attribute__ ((__unused__)), ATTR *atr,
+ void *args __attribute__ ((__unused__)))
{
if (waitable_attr(thing, AL_NAME(atr)))
(void) atr_clr(thing, AL_NAME(atr), GOD);
*/
void
dequeue_semaphores(dbref thing, char const *aname, int count, int all,
- int drain)
+ int drain)
{
BQUE **point;
BQUE *entry;
if (qsemlast == entry) {
qsemlast = qsemfirst;
if (qsemlast)
- while (qsemlast->next)
- qsemlast = qsemlast->next;
+ while (qsemlast->next)
+ qsemlast = qsemlast->next;
}
/* Update bookkeeping */
free_qentry(entry);
} else if (IsPlayer(entry->cause)) {
if (qlast) {
- qlast->next = entry;
- qlast = entry;
+ qlast->next = entry;
+ qlast = entry;
} else {
- qlast = qfirst = entry;
+ qlast = qfirst = entry;
}
} else {
if (qllast) {
- qllast->next = entry;
- qllast = entry;
+ qllast->next = entry;
+ qllast = entry;
} else {
- qllast = qlfirst = entry;
+ qllast = qlfirst = entry;
}
}
}
if (pos) {
if (SW_ISSET(sw, SWITCH_ANY)) {
notify(player,
- T
- ("You may not specify a semaphore attribute with the ANY switch."));
+ T
+ ("You may not specify a semaphore attribute with the ANY switch."));
return;
}
*pos++ = '\0';
if (arg_right && *arg_right) {
if (all) {
notify(player,
- T("You may not specify a semaphore count with the ALL switch."));
+ T("You may not specify a semaphore count with the ALL switch."));
return;
}
if (!is_uinteger(arg_right)) {
if (aname) {
tcount = strchr(aname, '/');
if (!tcount) {
- if (is_strict_integer(aname)) { /* Timeout */
- tcount = aname;
- aname = (char *) "SEMAPHORE";
- } else { /* Attribute */
- upcasestr(aname);
+ if (is_strict_integer(aname)) { /* Timeout */
+ tcount = aname;
+ aname = (char *) "SEMAPHORE";
+ } else { /* Attribute */
+ upcasestr(aname);
}
- } else { /* attribute/timeout */
+ } else { /* attribute/timeout */
*tcount++ = '\0';
upcasestr(aname);
}
num = 0;
if (num <= 0) {
thing = NOTHING;
- waitfor = -1; /* just in case there was a timeout given */
+ waitfor = -1; /* just in case there was a timeout given */
}
qid = wait_que(player, waitfor, arg2, cause, thing, aname, until, finvoc);
mush_free(arg2, "strip_braces.buff");
static void
show_queue(dbref player, dbref victim, int q_type, int q_quiet, int q_all,
- BQUE *q_ptr, int *tot, int *self, int *del)
+ BQUE *q_ptr, int *tot, int *self, int *del)
{
BQUE *tmp;
for (tmp = q_ptr; tmp; tmp = tmp->next) {
else if (q_all || (Owner(tmp->player) == victim)) {
(*self)++;
if (!q_quiet && (CanSeeQ(player, victim)
- || Owns(tmp->player, player))) {
- switch (q_type) {
- case 1: /* wait queue */
- notify_format(player, "[QID: %d%s/%ld]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
- tmp->left - mudtime, unparse_object(player, tmp->player), tmp->comm);
- break;
- case 2: /* semaphore queue */
- if (tmp->left != 0) {
- notify_format(player, "[QID: %d%s/#%d/%s/%ld]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
- tmp->sem, tmp->semattr, tmp->left - mudtime,
- unparse_object(player, tmp->player), tmp->comm);
- } else {
- notify_format(player, "[QID: %d%s/#%d/%s]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
- tmp->sem, tmp->semattr, unparse_object(player, tmp->player),
- tmp->comm);
- }
- break;
- default: /* player or object queue */
- notify_format(player, "[QID: %d%s] %s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
- unparse_object(player, tmp->player), tmp->comm);
- }
+ || Owns(tmp->player, player))) {
+ switch (q_type) {
+ case 1: /* wait queue */
+ notify_format(player, "[QID: %d%s/%ld]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
+ tmp->left - mudtime, unparse_object(player, tmp->player), tmp->comm);
+ break;
+ case 2: /* semaphore queue */
+ if (tmp->left != 0) {
+ notify_format(player, "[QID: %d%s/#%d/%s/%ld]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
+ tmp->sem, tmp->semattr, tmp->left - mudtime,
+ unparse_object(player, tmp->player), tmp->comm);
+ } else {
+ notify_format(player, "[QID: %d%s/#%d/%s]%s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
+ tmp->sem, tmp->semattr, unparse_object(player, tmp->player),
+ tmp->comm);
+ }
+ break;
+ default: /* player or object queue */
+ notify_format(player, "[QID: %d%s] %s:%s", tmp->qid, qid_table[tmp->qid] == QID_FREEZE ? "(F)" : "",
+ unparse_object(player, tmp->player), tmp->comm);
+ }
}
}
}
victim = player;
else
victim = match_result(player, what, TYPE_PLAYER,
- MAT_PLAYER | MAT_ABSOLUTE | MAT_ME);
+ MAT_PLAYER | MAT_ABSOLUTE | MAT_ME);
}
if (!CanSeeQ(player, victim))
victim = player;
if (!quick) {
if (all == QUEUE_ALL)
- notify(player, T("Queue for : all"));
+ notify(player, T("Queue for : all"));
else
- notify_format(player, T("Queue for : %s"), Name(victim));
+ notify_format(player, T("Queue for : %s"), Name(victim));
}
victim = Owner(victim);
if (!quick)
if (!quick)
notify(player, T("------------ Queue Done ------------"));
notify_format(player,
- "Totals: Player...%d/%d[%ddel] Object...%d/%d[%ddel] Wait...%d/%d Semaphore...%d/%d",
- pq, tpq, dpq, oq, toq, doq, wq, twq, sq, tsq);
+ "Totals: Player...%d/%d[%ddel] Object...%d/%d[%ddel] Wait...%d/%d Semaphore...%d/%d",
+ pq, tpq, dpq, oq, toq, doq, wq, twq, sq, tsq);
}
}
if(qid_table[point->qid] == QID_ACTIVE) { /* don't have to bother with these */
trail = save;
save = point->next;
- qid_chk_t[point->qid] = 1;
+ qid_chk_t[point->qid] = 1;
continue;
} else if(qid_chk_t[point->qid] == 1) {
- trail = save;
- save = point->next;
- continue;
- }
- qid_chk_t[point->qid] = 1;
+ trail = save;
+ save = point->next;
+ continue;
+ }
+ qid_chk_t[point->qid] = 1;
/* see what type of PID or on. */
switch(qid_table[point->qid]) { /* Check for all possible re-sort signals */
case QID_FREEZE:
continue;
}
- /* detach the process for a second */
- /*
+ /* detach the process for a second */
+ /*
last = save;
save = (trail->next = point->next);
trail = last;
- */
+ */
if(*qchk == point) { /* its the first one.. so adjust the next one to be the first one */
*qchk = save = point->next;
- } else {
- trail->next = save = point->next;
- trail = trail;
- }
- /* detach. */
+ } else {
+ trail->next = save = point->next;
+ trail = trail;
+ }
+ /* detach. */
point->next = NULL;
- /* retach it */
+ /* retach it */
for(last = NULL, next = *qchk; next != NULL && (next->left <= point->left); next = next->next)
last = next;
point->next = next;
* return queue process we found
*/
BQUE *find_qid(int qid, BQUE **qlist, BQUE **qprev) {
- BQUE *qproc;
-
- for(*qprev = qproc = qfirst; qproc; *qprev = qproc, qproc = qproc->next)
- if(qproc->qid == qid) {
- return qproc;
- }
- for(*qprev = qproc = qlfirst; qproc; *qprev = qproc, qproc = qproc->next)
- if(qproc->qid == qid) {
- return qproc;
- }
- for(*qprev = NULL, qproc = qwait; qproc; *qprev = qproc, qproc = qproc->next)
- if(qproc->qid == qid) {
- *qlist = qwait;
- return qproc;
- }
- for(*qprev = NULL, qproc = qsemfirst; qproc; *qprev = qproc, qproc = qproc->next)
- if(qproc->qid == qid) {
- *qlist = qsemfirst;
- return qproc;
- }
-
- return NULL;
+ BQUE *qproc;
+
+ for(*qprev = qproc = qfirst; qproc; *qprev = qproc, qproc = qproc->next)
+ if(qproc->qid == qid) {
+ return qproc;
+ }
+ for(*qprev = qproc = qlfirst; qproc; *qprev = qproc, qproc = qproc->next)
+ if(qproc->qid == qid) {
+ return qproc;
+ }
+ for(*qprev = NULL, qproc = qwait; qproc; *qprev = qproc, qproc = qproc->next)
+ if(qproc->qid == qid) {
+ *qlist = qwait;
+ return qproc;
+ }
+ for(*qprev = NULL, qproc = qsemfirst; qproc; *qprev = qproc, qproc = qproc->next)
+ if(qproc->qid == qid) {
+ *qlist = qsemfirst;
+ return qproc;
+ }
+
+ return NULL;
}
int do_signal_qid(dbref signalby, int qid, enum qid_flags qflags, int time) {
- BQUE *qproc, *qprev, *qsave;
+ BQUE *qproc, *qprev, *qsave;
- /* Signal a QID with such & such signal */
+ /* Signal a QID with such & such signal */
- /* First Quick Check to make sure its a valid QID */
- if(qid > qid_cnt || qid >= MAX_QID || qid_table[qid] == QID_FALSE)
- return -1;
- qproc = find_qid(qid, &qsave, &qprev);
- if(!qproc || qproc->qid != qid)
- return -1;
- /* Check Signals */
- switch(qflags) {
- case QID_FREEZE:
- if(controls(signalby, qproc->player))
- qid_table[qid] = QID_FREEZE;
- else
- return -3;
- break;
- case QID_CONT:
- if(controls(signalby, qproc->player))
- qid_table[qid] = QID_ACTIVE;
- else
- return -3;
- break;
- case QID_QUERY_T:
- if(!controls(signalby, qproc->player))
- return -3;
- if(qsave == qwait || qsave == qsemfirst) {
- return (qproc->left - mudtime);
- } else return -3;
- case QID_TIME: /* modify queue time */
- if(!controls(signalby, qproc->player))
- return -3;
- if(time < 0) /* can't wait negative amount of time */
- return 0;
- if(!qsave) /* We don't adjust time of regular queue thingies */
- return -2;
- qproc->left = mudtime + time;
- /* this will let it stay frozen if it is */
- if(qid_table[qid] == QID_ACTIVE)
- qid_table[qid] = QID_TIME;
- break;
- case QID_KILL:
- if(!controls(signalby, qproc->player) && !CanHalt(signalby, qproc->player))
- return -3;
- add_to(QUEUE_PER_OWNER ? Owner(qproc->player) : qproc->player, -1);
- giveto(Owner(qproc->player), QUEUE_COST);
- if(!qsave) { /* This is all we have to do for these, isn't that great? */
- qproc->player = NOTHING;
- } else { /* Wait queues or semas
- * we have to kill 'em completely from this point */
- if(qprev)
- qprev->next = qproc->next;
- else {
- if(qsave == qwait)
- qwait = qproc->next;
- else {
- qsemfirst = qproc->next;
- add_to_sem(qproc->sem, -1, qproc->semattr);
- }
- }
- free_qentry(qproc);
- }
- break;
- default:
- return -2; /* Not a valid signal */
-
- }
- return 1;
+ /* First Quick Check to make sure its a valid QID */
+ if(qid > qid_cnt || qid >= MAX_QID || qid_table[qid] == QID_FALSE)
+ return -1;
+ qproc = find_qid(qid, &qsave, &qprev);
+ if(!qproc || qproc->qid != qid)
+ return -1;
+ /* Check Signals */
+ switch(qflags) {
+ case QID_FREEZE:
+ if(controls(signalby, qproc->player))
+ qid_table[qid] = QID_FREEZE;
+ else
+ return -3;
+ break;
+ case QID_CONT:
+ if(controls(signalby, qproc->player))
+ qid_table[qid] = QID_ACTIVE;
+ else
+ return -3;
+ break;
+ case QID_QUERY_T:
+ if(!controls(signalby, qproc->player))
+ return -3;
+ if(qsave == qwait || qsave == qsemfirst) {
+ return (qproc->left - mudtime);
+ } else return -3;
+ case QID_TIME: /* modify queue time */
+ if(!controls(signalby, qproc->player))
+ return -3;
+ if(time < 0) /* can't wait negative amount of time */
+ return 0;
+ if(!qsave) /* We don't adjust time of regular queue thingies */
+ return -2;
+ qproc->left = mudtime + time;
+ /* this will let it stay frozen if it is */
+ if(qid_table[qid] == QID_ACTIVE)
+ qid_table[qid] = QID_TIME;
+ break;
+ case QID_KILL:
+ if(!controls(signalby, qproc->player) && !CanHalt(signalby, qproc->player))
+ return -3;
+ add_to(QUEUE_PER_OWNER ? Owner(qproc->player) : qproc->player, -1);
+ giveto(Owner(qproc->player), QUEUE_COST);
+ if(!qsave) { /* This is all we have to do for these, isn't that great? */
+ qproc->player = NOTHING;
+ } else { /* Wait queues or semas
+ * we have to kill 'em completely from this point */
+ if(qprev)
+ qprev->next = qproc->next;
+ else {
+ if(qsave == qwait)
+ qwait = qproc->next;
+ else {
+ qsemfirst = qproc->next;
+ add_to_sem(qproc->sem, -1, qproc->semattr);
+ }
+ }
+ free_qentry(qproc);
+ }
+ break;
+ default:
+ return -2; /* Not a valid signal */
+
+ }
+ return 1;
}
else
player = victim;
quiet_notify(Owner(player),
- tprintf("%s: %s(#%d).", T("Halted"), Name(player), player));
+ tprintf("%s: %s(#%d).", T("Halted"), Name(player), player));
for (tmp = qfirst; tmp; tmp = tmp->next)
if (GoodObject(tmp->player)
- && ((tmp->player == player)
- || (Owner(tmp->player) == player))) {
+ && ((tmp->player == player)
+ || (Owner(tmp->player) == player))) {
num--;
giveto(player, QUEUE_COST);
tmp->player = NOTHING;
}
for (tmp = qlfirst; tmp; tmp = tmp->next)
if (GoodObject(tmp->player)
- && ((tmp->player == player)
- || (Owner(tmp->player) == player))) {
+ && ((tmp->player == player)
+ || (Owner(tmp->player) == player))) {
num--;
giveto(player, QUEUE_COST);
tmp->player = NOTHING;
/* remove wait q stuff */
for (point = qwait; point; point = next) {
if (((point->player == player)
- || (Owner(point->player) == player))) {
+ || (Owner(point->player) == player))) {
num--;
giveto(player, QUEUE_COST);
if (trail)
- trail->next = next = point->next;
+ trail->next = next = point->next;
else
- qwait = next = point->next;
+ qwait = next = point->next;
free_qentry(point);
} else
next = (trail = point)->next;
for (point = qsemfirst, trail = NULL; point; point = next) {
if (((point->player == player)
- || (Owner(point->player) == player))) {
+ || (Owner(point->player) == player))) {
num--;
giveto(player, QUEUE_COST);
if (trail)
- trail->next = next = point->next;
+ trail->next = next = point->next;
else
- qsemfirst = next = point->next;
+ qsemfirst = next = point->next;
if (point == qsemlast)
- qsemlast = trail;
+ qsemlast = trail;
add_to_sem(point->sem, -1, point->semattr);
free_qentry(point);
} else
do_halt(player, "", player);
else {
if ((victim =
- noisy_match_result(player, arg1, NOTYPE,
- MAT_OBJECTS | MAT_HERE)) == NOTHING)
+ noisy_match_result(player, arg1, NOTYPE,
+ MAT_OBJECTS | MAT_HERE)) == NOTHING)
return;
if (!Owns(player, victim) && !CanHalt(player, victim)) {
notify(player, T("Permission denied."));
do_halt(player, arg2, victim);
if (IsPlayer(victim)) {
if (victim == player) {
- notify(player, T("All of your objects have been halted."));
+ notify(player, T("All of your objects have been halted."));
} else {
- notify_format(player,
- T("All objects for %s have been halted."), Name(victim));
- notify_format(victim,
- T("All of your objects have been halted by %s."),
- Name(player));
+ notify_format(player,
+ T("All objects for %s have been halted."), Name(victim));
+ notify_format(victim,
+ T("All of your objects have been halted by %s."),
+ Name(player));
}
} else {
if (Owner(victim) != player) {
- notify_format(player, "%s: %s's %s(%s)", T("Halted"),
- Name(Owner(victim)), Name(victim), unparse_dbref(victim));
- notify_format(Owner(victim),
- "%s: %s(%s), by %s", T("Halted"),
- Name(victim), unparse_dbref(victim), Name(player));
+ notify_format(player, "%s: %s's %s(%s)", T("Halted"),
+ Name(Owner(victim)), Name(victim), unparse_dbref(victim));
+ notify_format(Owner(victim),
+ "%s: %s(%s), by %s", T("Halted"),
+ Name(victim), unparse_dbref(victim), Name(player));
}
if (*arg2 == '\0')
- set_flag_internal(victim, "HALT");
+ set_flag_internal(victim, "HALT");
}
}
}
dbref victim;
if (!HaltAny(player)) {
notify(player,
- T("You do not have the power to bring the world to a halt."));
+ T("You do not have the power to bring the world to a halt."));
return;
}
for (victim = 0; victim < db_top; victim++) {
if (IsPlayer(victim)) {
notify_format(victim,
- T("Your objects have been globally halted by %s"),
- Name(player));
+ T("Your objects have been globally halted by %s"),
+ Name(player));
do_halt(victim, "", victim);
}
}
}
if (IsPlayer(thing)) {
notify_format(thing,
- T("Your objects are being globally restarted by %s"),
- Name(player));
+ T("Your objects are being globally restarted by %s"),
+ Name(player));
}
}
}
if (IsPlayer(victim)) {
for (thing = 0; thing < db_top; thing++) {
if ((Owner(thing) == victim) && !IsGarbage(thing)
- && !(Halted(thing)))
- (void) queue_attribute_noparent(thing, "STARTUP", thing);
+ && !(Halted(thing)))
+ (void) queue_attribute_noparent(thing, "STARTUP", thing);
}
} else {
/* A single object */
do_raw_restart(player);
} else {
if ((victim =
- noisy_match_result(player, arg1, NOTYPE, MAT_OBJECTS)) == NOTHING)
+ noisy_match_result(player, arg1, NOTYPE, MAT_OBJECTS)) == NOTHING)
return;
if (!Owns(player, victim) && !CanHalt(player, victim)) {
notify(player, T("Permission denied."));
}
if (Owner(victim) != player) {
if (IsPlayer(victim)) {
- notify_format(player,
- T("All objects for %s are being restarted."),
- Name(victim));
- notify_format(victim,
- T("All of your objects are being restarted by %s."),
- Name(player));
+ notify_format(player,
+ T("All objects for %s are being restarted."),
+ Name(victim));
+ notify_format(victim,
+ T("All of your objects are being restarted by %s."),
+ Name(player));
} else {
- notify_format(player,
- "Restarting: %s's %s(%s)",
- Name(Owner(victim)), Name(victim), unparse_dbref(victim));
- notify_format(Owner(victim),
- "Restarting: %s(%s), by %s",
- Name(victim), unparse_dbref(victim), Name(player));
+ notify_format(player,
+ "Restarting: %s's %s(%s)",
+ Name(Owner(victim)), Name(victim), unparse_dbref(victim));
+ notify_format(Owner(victim),
+ "Restarting: %s(%s), by %s",
+ Name(victim), unparse_dbref(victim), Name(player));
}
} else {
if (victim == player)
- notify(player, T("All of your objects are being restarted."));
+ notify(player, T("All of your objects are being restarted."));
else
- notify_format(player, "Restarting: %s(%s)", Name(victim),
- unparse_dbref(victim));
+ notify_format(player, "Restarting: %s(%s)", Name(victim),
+ unparse_dbref(victim));
}
do_halt(player, "", victim);
do_raw_restart(victim);
}
FUNCTION(fun_wait) {
- char tbuf[BUFFER_LEN], *tbp;
- const char *p;
-
- if(!args[0] || !*args[0] || !args[1] || !*args[1])
- safe_str("#-1", buff, bp);
- else if(!command_check_byname(executor, "@wait"))
- safe_str("#-1 PERMISSION DENIED", buff, bp);
- else {
- tbp = tbuf;
- p = args[0];
- process_expression(tbuf, &tbp, &p, executor, caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info);
- *tbp = '\0';
- safe_integer(do_wait(executor, caller, tbuf, args[1], 0, 1), buff, bp);
- }
+ char tbuf[BUFFER_LEN], *tbp;
+ const char *p;
+
+ if(!args[0] || !*args[0] || !args[1] || !*args[1])
+ safe_str("#-1", buff, bp);
+ else if(!command_check_byname(executor, "@wait"))
+ safe_str("#-1 PERMISSION DENIED", buff, bp);
+ else {
+ tbp = tbuf;
+ p = args[0];
+ process_expression(tbuf, &tbp, &p, executor, caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info);
+ *tbp = '\0';
+ safe_integer(do_wait(executor, caller, tbuf, args[1], 0, 1), buff, bp);
+ }
}
static dbref parse_linkable_room(dbref player, const char *room_name);
static dbref check_var_link(const char *dest_name);
static dbref clone_object(dbref player, dbref thing, const char *newname,
- int preserve);
+ int preserve);
struct db_stat_info current_state; /**< Current stats for database */
if (!strcasecmp(room_name, "here")) {
room = IsExit(player) ? Source(player) : Location(player);
} else if (!strcasecmp(room_name, "home")) {
- return HOME; /* HOME is always linkable */
+ return HOME; /* HOME is always linkable */
} else {
room = parse_dbref(room_name);
}
*/
dbref
do_real_open(dbref player, const char *direction, const char *linkto,
- dbref pseudo)
+ dbref pseudo)
{
dbref loc =
(pseudo !=
if (linkto && *linkto != '\0') {
notify(player, T("Trying to link..."));
if ((loc = check_var_link(linkto)) == NOTHING)
- loc = parse_linkable_room(player, linkto);
+ loc = parse_linkable_room(player, linkto);
if (loc != NOTHING) {
- if (!payfor(player, LINK_COST)) {
- notify_format(player, T("You don't have enough %s to link."), MONIES);
- } else {
- /* it's ok, link it */
- Location(new_exit) = loc;
- notify_format(player, T("Linked exit #%d to #%d"), new_exit, loc);
- }
+ if (!payfor(player, LINK_COST)) {
+ notify_format(player, T("You don't have enough %s to link."), MONIES);
+ } else {
+ /* it's ok, link it */
+ Location(new_exit) = loc;
+ notify_format(player, T("Linked exit #%d to #%d"), new_exit, loc);
+ }
}
}
current_state.exits++;
} else {
switch (Typeof(exit_l)) {
case TYPE_EXIT:
- old_loc = Location(exit_l);
- Location(exit_l) = NOTHING;
- notify_format(player, T("Unlinked exit #%d (Used to lead to %s)."),
- exit_l, unparse_object(player, old_loc));
- break;
+ old_loc = Location(exit_l);
+ Location(exit_l) = NOTHING;
+ notify_format(player, T("Unlinked exit #%d (Used to lead to %s)."),
+ exit_l, unparse_object(player, old_loc));
+ break;
case TYPE_ROOM:
- Location(exit_l) = NOTHING;
- notify(player, T("Dropto removed."));
- break;
+ Location(exit_l) = NOTHING;
+ notify(player, T("Dropto removed."));
+ break;
default:
- notify(player, T("You can't unlink that!"));
- break;
+ notify(player, T("You can't unlink that!"));
+ break;
}
}
}
switch (Typeof(thing)) {
case TYPE_EXIT:
if ((room = check_var_link(room_name)) == NOTHING)
- room = parse_linkable_room(player, room_name);
+ room = parse_linkable_room(player, room_name);
if (room == NOTHING)
- return;
+ return;
if (GoodObject(room) && !can_link_to(player, room)) {
- notify(player, T("Permission denied."));
- break;
+ notify(player, T("Permission denied."));
+ break;
}
/* We may link an exit if it's unlinked and we pass the link-lock
* or if we control it.
*/
if (!(controls(player, thing)
- || ((Location(thing) == NOTHING)
- && eval_lock(player, thing, Link_Lock)))) {
- notify(player, T("Permission denied."));
- return;
+ || ((Location(thing) == NOTHING)
+ && eval_lock(player, thing, Link_Lock)))) {
+ notify(player, T("Permission denied."));
+ return;
}
if (preserve && !OOREF(player,div_powover(player, player, "Link"), div_powover(ooref,ooref, "Link"))) {
- notify(player, T("Permission denied."));
- return;
+ notify(player, T("Permission denied."));
+ return;
}
/* handle costs */
if (Owner(thing) == Owner(player)) {
- if (!payfor(player, LINK_COST)) {
- notify_format(player, T("It costs %d %s to link this exit."),
- LINK_COST, ((LINK_COST == 1) ? MONEY : MONIES));
- return;
- }
+ if (!payfor(player, LINK_COST)) {
+ notify_format(player, T("It costs %d %s to link this exit."),
+ LINK_COST, ((LINK_COST == 1) ? MONEY : MONIES));
+ return;
+ }
} else {
- if (!payfor(player, LINK_COST + EXIT_COST)) {
- int a = LINK_COST + EXIT_COST;
- notify_format(player, T("It costs %d %s to link this exit."), a,
- ((a == 1) ? MONEY : MONIES));
- return;
- } else if (!preserve) {
- /* pay the owner for his loss */
- giveto(Owner(thing), EXIT_COST);
- chown_object(player, thing, player, 0);
- }
+ if (!payfor(player, LINK_COST + EXIT_COST)) {
+ int a = LINK_COST + EXIT_COST;
+ notify_format(player, T("It costs %d %s to link this exit."), a,
+ ((a == 1) ? MONEY : MONIES));
+ return;
+ } else if (!preserve) {
+ /* pay the owner for his loss */
+ giveto(Owner(thing), EXIT_COST);
+ chown_object(player, thing, player, 0);
+ }
}
/* link has been validated and paid for; do it */
if (!preserve) {
- Owner(thing) = Owner(player);
- Zone(thing) = Zone(player);
+ Owner(thing) = Owner(player);
+ Zone(thing) = Zone(player);
SDIV(thing).object = SDIV(player).object;
SLEVEL(thing) = LEVEL(player);
}
/* notify the player */
notify_format(player, T("Linked exit #%d to %s"), thing,
- unparse_object(player, room));
+ unparse_object(player, room));
break;
case TYPE_DIVISION:
case TYPE_PLAYER:
case TYPE_THING:
if ((room =
- noisy_match_result(player, room_name, NOTYPE, MAT_EVERYTHING)) < 0) {
- notify(player, T("No match."));
- return;
+ noisy_match_result(player, room_name, NOTYPE, MAT_EVERYTHING)) < 0) {
+ notify(player, T("No match."));
+ return;
}
if (IsExit(room)) {
- notify(player, T("That is an exit."));
- return;
+ notify(player, T("That is an exit."));
+ return;
}
if (thing == room) {
- notify(player, T("You may not link something to itself."));
- return;
+ notify(player, T("You may not link something to itself."));
+ return;
}
/* abode */
if (!controls(player, room) && !Abode(room)) {
- notify(player, T("Permission denied."));
- break;
+ notify(player, T("Permission denied."));
+ break;
}
if (!controls(player, thing)) {
- notify(player, T("Permission denied."));
+ notify(player, T("Permission denied."));
} else if (room == HOME) {
- notify(player, T("Can't set home to home."));
+ notify(player, T("Can't set home to home."));
} else {
- /* do the link */
- Home(thing) = room; /* home */
- if (!Quiet(player) && !(Quiet(thing) && (Owner(thing) == player)))
- notify(player, T("Home set."));
+ /* do the link */
+ Home(thing) = room; /* home */
+ if (!Quiet(player) && !(Quiet(thing) && (Owner(thing) == player)))
+ notify(player, T("Home set."));
}
break;
case TYPE_ROOM:
if ((room = parse_linkable_room(player, room_name)) == NOTHING)
- return;
+ return;
if ((room != HOME) && (!IsRoom(room))) {
- notify(player, T("That is not a room!"));
- return;
+ notify(player, T("That is not a room!"));
+ return;
}
if (!controls(player, thing)) {
- notify(player, T("Permission denied."));
+ notify(player, T("Permission denied."));
} else {
- /* do the link, in location */
- Location(thing) = room; /* dropto */
- notify(player, T("Dropto set."));
+ /* do the link, in location */
+ Location(thing) = room; /* dropto */
+ notify(player, T("Dropto set."));
}
break;
default:
notify(player, "Internal error: weird object type.");
do_log(LT_ERR, NOTHING, NOTHING,
- T("Weird object! Type of #%d is %d"), thing, Typeof(thing));
+ T("Weird object! Type of #%d is %d"), thing, Typeof(thing));
break;
}
}
* and Z_TEL checking */
char roomstr[MAX_COMMAND_LEN];
sprintf(roomstr, "#%d", room);
- do_teleport(player, "me", roomstr, 0, 0); /* if flag, move the player */
+ do_teleport(player, "me", roomstr, 0, 0); /* if flag, move the player */
}
return room;
}
/* initialize everything */
set_name(thing, name);
- if (!IsExit(player)) /* Exits shouldn't have contents! */
+ if (!IsExit(player)) /* Exits shouldn't have contents! */
Location(thing) = player;
else
Location(thing) = Source(player);
/* home is here (if we can link to it) or player's home */
if ((loc = Location(player)) != NOTHING &&
- (controls(player, loc) || Abode(loc))) {
- Home(thing) = loc; /* home */
+ (controls(player, loc) || Abode(loc))) {
+ Home(thing) = loc; /* home */
} else {
- Home(thing) = Home(player); /* home */
+ Home(thing) = Home(player); /* home */
}
/* link it in */
#endif
DPBITS(clone) = NULL;
if (!preserve) {
- Warnings(clone) = 0; /* zap warnings */
+ Warnings(clone) = 0; /* zap warnings */
} else if (Warnings(clone) || DPBITS(clone)) {
notify(player, T("Warning: @CLONE/PRESERVE on an object with powers or warnings."));
}
}
if (preserve && !Director(player)) {
notify(player,
- T("You cannot @CLONE/PRESERVE. Use normal @CLONE instead."));
+ T("You cannot @CLONE/PRESERVE. Use normal @CLONE instead."));
return NOTHING;
}
/* make sure owner can afford it */
clone = clone_object(player, thing, newname, preserve);
notify_format(player, T("Cloned: Object %s."), unparse_dbref(clone));
if (IsRoom(player))
- moveto(clone, player);
+ moveto(clone, player);
else
- moveto(clone, Location(player));
+ moveto(clone, Location(player));
current_state.things++;
local_data_clone(clone, thing);
real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING,
- global_eval_context.wenv, 0);
+ global_eval_context.wenv, 0);
return clone;
}
return NOTHING;
current_state.rooms++;
local_data_clone(clone, thing);
real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING,
- global_eval_context.wenv, 0);
+ global_eval_context.wenv, 0);
return clone;
}
return NOTHING;
db[clone].rplog.status = 0;
#endif /* RPMODE_SYS */
if (!preserve) {
- Warnings(clone) = 0; /* zap warnings */
+ Warnings(clone) = 0; /* zap warnings */
} else {
- Warnings(clone) = Warnings(thing);
+ Warnings(clone) = Warnings(thing);
}
if (Warnings(clone) || DPBITS(clone))
notify(player, T("Warning: @CLONE/PRESERVE on an exit with powers or warnings."));
if(IsRoom(cur) && Zone(cur) == zmo) {
num_rooms++;
for(i = Exits(cur); i != NOTHING; i = Next(i))
- num_exits++;
+ num_exits++;
}
oldrooms = (dbref *) mush_malloc(sizeof(dbref) * num_rooms, "copy_zone");
bp = buf;
for(cur = 0; cur < da_sz; cur++) {
for(i = 0; i < num_rooms; i++)
- if(da_vals[cur] == oldrooms[i]) {
- safe_str(unparse_dbref(newrooms[i]), buf, &bp);
- if((cur+1) < da_sz) safe_chr(' ', buf, &bp);
- break;
- }
+ if(da_vals[cur] == oldrooms[i]) {
+ safe_str(unparse_dbref(newrooms[i]), buf, &bp);
+ if((cur+1) < da_sz) safe_chr(' ', buf, &bp);
+ break;
+ }
if(i == num_rooms) {
- for(i = 0; i < num_exits; i++)
- if(da_vals[cur] == oldexits[i]) {
- safe_str(unparse_dbref(newexits[i]), buf, &bp);
- if((cur+1) < da_sz) safe_chr(' ', buf, &bp);
- break;
- }
- if(i == num_exits)
- safe_str("#-1 ", buf, &bp);
+ for(i = 0; i < num_exits; i++)
+ if(da_vals[cur] == oldexits[i]) {
+ safe_str(unparse_dbref(newexits[i]), buf, &bp);
+ if((cur+1) < da_sz) safe_chr(' ', buf, &bp);
+ break;
+ }
+ if(i == num_exits)
+ safe_str("#-1 ", buf, &bp);
}
}
*bp = '\0';
while(fp_h && which < CS_TASK ) {
if(fp_t && (fp_t = strchr(fp_h, ' ')))
- *fp_t++ = '\0';
+ *fp_t++ = '\0';
switch(which) {
- case CS_MINUTE:
- spec = parse_spec((const char *) fp_h, CRON_MINUTE_MAX, NULL, NULL, NULL, NULL);
- memcpy(&job->spec.minute, &spec, sizeof(job->spec.minute));
- break;
- case CS_HOUR:
- spec = parse_spec((const char *) fp_h, CRON_HOUR_MAX, NULL, NULL, NULL, NULL);
- memcpy(&job->spec.hour, &spec, sizeof(job->spec.hour));
- break;
- case CS_DAY:
- spec = parse_spec((const char *) fp_h, CRON_DAY_MAX, NULL, NULL, NULL, NULL);
- memcpy(&job->spec.day, &spec, sizeof job->spec.day);
- break;
- case CS_MONTH:
- spec = parse_spec((const char *) fp_h, CRON_MONTH_MAX, month_table, month_alias_table, NULL, NULL);
- memcpy(&job->spec.month, &spec, sizeof(job->spec.month));
- break;
- case CS_WDAY:
- spec = parse_spec((const char *) fp_h, CRON_DAY_MAX, wday_table, wday_alias_table, NULL, NULL);
- memcpy(&job->spec.wday, &spec, sizeof(job->spec.wday));
- break;
+ case CS_MINUTE:
+ spec = parse_spec((const char *) fp_h, CRON_MINUTE_MAX, NULL, NULL, NULL, NULL);
+ memcpy(&job->spec.minute, &spec, sizeof(job->spec.minute));
+ break;
+ case CS_HOUR:
+ spec = parse_spec((const char *) fp_h, CRON_HOUR_MAX, NULL, NULL, NULL, NULL);
+ memcpy(&job->spec.hour, &spec, sizeof(job->spec.hour));
+ break;
+ case CS_DAY:
+ spec = parse_spec((const char *) fp_h, CRON_DAY_MAX, NULL, NULL, NULL, NULL);
+ memcpy(&job->spec.day, &spec, sizeof job->spec.day);
+ break;
+ case CS_MONTH:
+ spec = parse_spec((const char *) fp_h, CRON_MONTH_MAX, month_table, month_alias_table, NULL, NULL);
+ memcpy(&job->spec.month, &spec, sizeof(job->spec.month));
+ break;
+ case CS_WDAY:
+ spec = parse_spec((const char *) fp_h, CRON_DAY_MAX, wday_table, wday_alias_table, NULL, NULL);
+ memcpy(&job->spec.wday, &spec, sizeof(job->spec.wday));
+ break;
}
which++;
fp_h = fp_t;
end = job->object;
}
do {
- /* Job owner must control object to do it */
- if(controls(job->owner,start)) {
+ /* Job owner must control object to do it */
+ if(controls(job->owner,start)) {
if (CRON_Command(job)) {
- queue_attribute(start, job->attrib, job->owner);
+ queue_attribute(start, job->attrib, job->owner);
} else if (CRON_Function(job)) {
- /* TODO: Review this section & possibly rewrite to make sure its secure. */
- bp = buff;
- a = (ATTR *) atr_get(start, job->attrib);
- if (!a) {
- start++;
- continue;
- }
- s = (char *) safe_atr_value(a);
- if (!s) {
- start++;
- continue;
- }
+ /* TODO: Review this section & possibly rewrite to make sure its secure. */
+ bp = buff;
+ a = (ATTR *) atr_get(start, job->attrib);
+ if (!a) {
+ start++;
+ continue;
+ }
+ s = (char *) safe_atr_value(a);
+ if (!s) {
+ start++;
+ continue;
+ }
sp = s;
process_expression(buff, &bp, &sp, start, start, start, PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
- free(s);
+ free(s);
} else {
stop = 1;
continue;
}
- }
+ }
start++;
} while (start < end && !stop);
}
#include "conf.h"
#include "externs.h"
#include "mymalloc.h"
-#include "csrimalloc.h" /* Must be after mymalloc.h! */
+#include "csrimalloc.h" /* Must be after mymalloc.h! */
#ifdef CSRI_TRACE
#undef malloc(x)
* sprintf().
*/
-#if 0 /* can't win with this one */
+#if 0 /* can't win with this one */
extern int sprintf proto((char *, const char *, ...));
#endif
#define caddr_t char *
extern caddr_t sbrk proto((int));
-#ifdef _SC_PAGESIZE /* Solaris 2.x, SVR4? */
+#ifdef _SC_PAGESIZE /* Solaris 2.x, SVR4? */
#define getpagesize() sysconf(_SC_PAGESIZE)
-#else /* ! _SC_PAGESIZE */
-#ifdef _SC_PAGE_SIZE /* HP, IBM */
+#else /* ! _SC_PAGESIZE */
+#ifdef _SC_PAGE_SIZE /* HP, IBM */
#define getpagesize() sysconf(_SC_PAGE_SIZE)
-#else /* ! _SC_PAGE_SIZE */
+#else /* ! _SC_PAGE_SIZE */
#ifndef getpagesize
extern int getpagesize proto((void));
-#endif /* getpagesize */
-#endif /* _SC_PAGE_SIZE */
-#endif /* _SC_PAGESIZE */
+#endif /* getpagesize */
+#endif /* _SC_PAGE_SIZE */
+#endif /* _SC_PAGESIZE */
-#ifdef _AIX /* IBM AIX doesn't declare sbrk, but is STDHEADERS. */
+#ifdef _AIX /* IBM AIX doesn't declare sbrk, but is STDHEADERS. */
extern caddr_t sbrk proto((int));
#endif
extern caddr_t mmap proto((caddr_t, size_t, int, int, int, off_t));
#endif
-#endif /* EXTERNS_H__ */ /* Do not add anything after this line */
+#endif /* EXTERNS_H__ */ /* Do not add anything after this line */
/* $Id: csrimalloc.c,v 1.2 2005-12-13 20:34:11 ari Exp $ */
#ifndef __ASSERT_H__
#define ASSERT_SP(p, s, s2, sp)
#define ASSERT_EP(p, s, s2, ep)
#endif
-#endif /* __ASSERT_H__ */ /* Do not add anything after this line */
+#endif /* __ASSERT_H__ */ /* Do not add anything after this line */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
/* a number used normally for size of a shift */
#if gcos
#define BITSPERBYTE 9
-#else /* ! gcos */
+#else /* ! gcos */
#define BITSPERBYTE 8
-#endif /* gcos */
-#endif /* BITSPERBYTE */
+#endif /* gcos */
+#endif /* BITSPERBYTE */
#ifndef BITS
#define BITS(type) (BITSPERBYTE * (int) sizeof(type))
-#endif /* BITS */
+#endif /* BITS */
/* size_t with only the high-order bit turned on */
#define HIBITSZ (((size_t) 1) << (BITS(size_t) - 1))
-#endif /* __ALIGN_H__ */ /* Do not add anything after this line */
+#endif /* __ALIGN_H__ */ /* Do not add anything after this line */
/*
* We assume that FREE is a 0 bit, and the tag for a free block, Or'ing the
#define DEF_SBRKUNITS 1024
-union word { /* basic unit of storage */
- size_t size; /* size of this block + 1 bit status */
- union word *next; /* next free block */
- union word *prev; /* prev free block */
- univptr_t ptr; /* stops lint complaining, keeps alignment */
+union word { /* basic unit of storage */
+ size_t size; /* size of this block + 1 bit status */
+ union word *next; /* next free block */
+ union word *prev; /* prev free block */
+ univptr_t ptr; /* stops lint complaining, keeps alignment */
char c;
int i;
char *cp;
char **cpp;
int *ip;
int **ipp;
- ALIGN; /* alignment stuff - wild fun */
+ ALIGN; /* alignment stuff - wild fun */
};
typedef union word Word;
#ifdef CSRI_DEBUG
#define REALSIZE(sp) (((sp)+1)->size)
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
#define NEXT(ep) (((ep)-1)->next)
#define PREV(ep) (((ep)-2)->prev)
* free block header uses extra words in the block itself
*/
#ifdef CSRI_DEBUG
-#define HEADERWORDS 2 /* Start boundary tag + real size in bytes */
-#else /* ! CSRI_DEBUG */
-#define HEADERWORDS 1 /* Start boundary tag */
-#endif /* CSRI_DEBUG */
+#define HEADERWORDS 2 /* Start boundary tag + real size in bytes */
+#else /* ! CSRI_DEBUG */
+#define HEADERWORDS 1 /* Start boundary tag */
+#endif /* CSRI_DEBUG */
#define TRAILERWORDS 1
-#define FREEHEADERWORDS 1 /* Start boundary tag */
+#define FREEHEADERWORDS 1 /* Start boundary tag */
-#define FREETRAILERWORDS 3 /* next and prev, end boundary tag */
+#define FREETRAILERWORDS 3 /* next and prev, end boundary tag */
#define ALLOC_OVERHEAD (HEADERWORDS + TRAILERWORDS)
#define FREE_OVERHEAD (FREEHEADERWORDS + FREETRAILERWORDS)
* tags that are permanantly marked allocated, so that no attempt is
* made to coalesce past them. See the code in dumpheap for more info.
*/
-#define ARENASTART 2 /* next ptr + fake start tag */
+#define ARENASTART 2 /* next ptr + fake start tag */
#ifdef CSRI_DEBUG
/*
* REALSIZE word
*/
#define FIXEDOVERHEAD (1 + ALLOC_OVERHEAD)
-#else /* ! CSRI_DEBUG */
+#else /* ! CSRI_DEBUG */
/* 1 for prev link, 1 for next link, + header and trailer */
#define FIXEDOVERHEAD (2 + ALLOC_OVERHEAD)
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
/*
* Check that pointer is safe to dereference i.e. actually points
*/
#ifndef u_char
#define u_char unsigned char
-#endif /* u_char */
+#endif /* u_char */
#define MAGIC_BYTE ((u_char) '\252')
*/
#define TOO_SMALL(sp) (SIZE(sp) < ALLOC_OVERHEAD)
-#else /* ! CSRI_DEBUG */
+#else /* ! CSRI_DEBUG */
#define SET_REALSIZE(sp, n)
#define VALID_MAGIC(sp) (1)
#define TOO_SMALL(sp) (0)
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
/*
* Check that a free list ptr points to a block with something pointing
#define fputs(s, f) write(fileno(f), (s), strlen(s))
#define setvbuf(f, s, n, l) __nothing()
#define fflush(f) __nothing()
-#endif /* USESTDIO */
+#endif /* USESTDIO */
#ifdef CSRI_TRACE
/*
} else \
_malloc_debugging += 0
-#else /* !CSRI_DEBUG */
+#else /* !CSRI_DEBUG */
#define CHECKHEAP()
#define CHECKFREEPTR(ep, msg)
#define CHECKALLOCPTR(sp, msg)
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
#define FREEMAGIC '\125'
* variable accessed in a way not obvious to the compiler", so should
* be called volatile. Amazing - a use for const volatile...
*/
-#ifndef RCSID /* define RCSID(x) to nothing if don't want the rcs headers */
+#ifndef RCSID /* define RCSID(x) to nothing if don't want the rcs headers */
#if defined(lint) || defined(__STRICT_ANSI__)
#define RCSID(x)
#else
#endif
#endif
-#endif /* __DEFS_H__ */ /* Do not add anything after this line */
+#endif /* __DEFS_H__ */ /* Do not add anything after this line */
/* Author: Mark Moraes <moraes@csri.toronto.edu> */
#ifdef CSRI_PROFILESIZES
#define _malloc_scount __MALC_scount
-#endif /* CSRI_PROFILESIZES */
+#endif /* CSRI_PROFILESIZES */
#ifdef CSRI_DEBUG
/*
* malloc/free/realloc/memalign. (the rest call these)
*/
#define _malloc_debugging __MALD_debugging
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
#define _malloc_version __MALE_version
#define _malloc_memfunc __MALF_memfunc
-#endif /* SHORTNAMES */ /* Do not add anything after this line */
-#endif /* __GLOBALRENAME_H__ */ /* Do not add anything after this line */
+#endif /* SHORTNAMES */ /* Do not add anything after this line */
+#endif /* __GLOBALRENAME_H__ */ /* Do not add anything after this line */
const char *_malloc_version =
"CSRI, University of Toronto Malloc Version 1.18alpha";
* you want to format something before printing. We don't want stdio
* calling malloc() if we can help it
*/
-int _malloc_tracing = 0; /* No tracing */
+int _malloc_tracing = 0; /* No tracing */
char _malloc_statsbuf[128];
int _malloc_leaktrace = 0;
#ifdef CSRI_PROFILESIZES
int _malloc_scount[MAXPROFILESIZE];
-#endif /* CSRI_PROFILESIZES */
+#endif /* CSRI_PROFILESIZES */
#ifdef CSRI_DEBUG
/*
* malloc/free/realloc/memalign. (the rest call these)
*/
int _malloc_debugging = 0;
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
univptr_t (*_malloc_memfunc) proto((size_t)) = _mal_sbrk;
extern Word *_malloc_mem;
extern int
- _malloc_tracing; /* No tracing */
+ _malloc_tracing; /* No tracing */
extern char
_malloc_statsbuf[];
#ifdef CSRI_PROFILESIZES
extern int
_malloc_scount[];
-#endif /* CSRI_PROFILESIZES */
+#endif /* CSRI_PROFILESIZES */
#ifdef CSRI_DEBUG
/*
*/
extern int
_malloc_debugging;
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
extern
univptr_t (*_malloc_memfunc) proto((size_t));
extern int
__m_prblock proto((univptr_t, int, FILE *));
-#endif /* __GLOBALS_H__ */ /* Do not add anything after this line */
+#endif /* __GLOBALS_H__ */ /* Do not add anything after this line */
/*
** sptree.h: The following type declarations provide the binary tree
struct _spblk *uplink;
univptr_t
- key; /* formerly time/timetyp */
+ key; /* formerly time/timetyp */
univptr_t
- data; /* formerly aux/auxtype */
+ data; /* formerly aux/auxtype */
univptr_t
datb;
} SPBLK;
typedef struct {
- SPBLK *root; /* root node */
+ SPBLK *root; /* root node */
/* Statistics, not strictly necessary, but handy for tuning */
int
- lookups; /* number of splookup()s */
+ lookups; /* number of splookup()s */
int
- lkpcmps; /* number of lookup comparisons */
+ lkpcmps; /* number of lookup comparisons */
int
- enqs; /* number of spenq()s */
+ enqs; /* number of spenq()s */
int
- enqcmps; /* compares in spenq */
+ enqcmps; /* compares in spenq */
int
splays;
#undef __proto
-#endif /* SPTREE_H */
+#endif /* SPTREE_H */
#ifndef __CSRI_TRACE_H__
#define __CSRI_TRACE_H__
else \
_malloc_leaktrace += 0
-#endif /* __CSRI_TRACE_H__ */ /* Do not add anything after this line */
+#endif /* __CSRI_TRACE_H__ */ /* Do not add anything after this line */
#include "confmagic.h"
trace__free _((univptr_t cp, const char *fname, int linenum));
void
trace__cfree _((univptr_t cp, const char *fname, int linenum));
-#else /* CSRI_TRACE */
+#else /* CSRI_TRACE */
univptr_t
malloc _((size_t nbytes));
univptr_t
erealloc _((univptr_t ptr, size_t nbytes));
Free_t free _((univptr_t cp));
Free_t cfree _((univptr_t cp));
-#endif /* CSRI_TRACE */
+#endif /* CSRI_TRACE */
int
__m_botch
RECORD_FILE_AND_LINE((univptr_t) cp, fname, linenum);
return (cp);
}
-#endif /* CSRI_TRACE */
+#endif /* CSRI_TRACE */
int
__nothing()
{
const char *filename;
int linenumber, is_end_ptr;
{
- static char linebuf[32]; /* Enough for a BIG linenumber! */
+ static char linebuf[32]; /* Enough for a BIG linenumber! */
static int notagain = 0;
if (notagain == 0) {
* tried to unbuffer it
*/
(void) fflush(stderr);
- notagain++; /* just in case abort() tries to cleanup */
+ notagain++; /* just in case abort() tries to cleanup */
abort();
}
- return 0; /* SHOULDNTHAPPEN */
+ return 0; /* SHOULDNTHAPPEN */
}
/* Author: Mark Moraes <moraes@csri.toronto.edu> */
Word *blkend;
ulong tag;
ulong blksize;
- char buf[512]; /* long enough for the sprintfs below */
+ char buf[512]; /* long enough for the sprintfs below */
if (blk == NULL)
return 0;
blkend = blk + blksize - 1;
}
(void) sprintf(buf, " %s blk: 0x%lx to 0x%lx, %lu (0x%lx) words",
- tag == FREE ? "Free" : "Allocated", (ulong) blk,
- (ulong) blkend, blksize, blksize);
+ tag == FREE ? "Free" : "Allocated", (ulong) blk,
+ (ulong) blkend, blksize, blksize);
(void) fputs(buf, fp);
if (is_end_ptr && !PTR_IN_HEAP(blk)) {
sprintf(buf, " ** start pointer 0x%lx not in heap\n", (ulong) blk);
char *cp;
(void) sprintf(buf, " next=0x%lx, prev=0x%lx\n",
- (ulong) NEXT(blkend), (ulong) PREV(blkend));
+ (ulong) NEXT(blkend), (ulong) PREV(blkend));
(void) fputs(buf, fp);
/* Make sure free block is filled with FREEMAGIC */
n = (blksize - FREE_OVERHEAD) * sizeof(Word);
#ifdef CSRI_DEBUG
for (i = 0; i < n; i++, cp++) {
if (*cp != FREEMAGIC) {
- (void) fputs(" ** modified after free().\n", fp);
- break;
+ (void) fputs(" ** modified after free().\n", fp);
+ break;
}
}
#endif
}
if (!VALID_START_SIZE_FIELD(blk)) {
sprintf(buf, " ** bad size field: tags = 0x%x, 0x%x\n",
- (unsigned int) SIZEFIELD(blk), (unsigned int) SIZEFIELD(blkend));
+ (unsigned int) SIZEFIELD(blk), (unsigned int) SIZEFIELD(blkend));
(void) fputs(buf, fp);
return 0;
}
REGISTER Word *blk;
REGISTER Word *blkend;
int i;
- char buf[512]; /* long enough for the sprintfs below */
+ char buf[512]; /* long enough for the sprintfs below */
- if (_malloc_loword == NULL) { /* Nothing malloc'ed yet */
+ if (_malloc_loword == NULL) { /* Nothing malloc'ed yet */
(void) fputs("Null heap - nothing malloc'ed yet\n", fp);
return;
}
}
if (_malloc_rovers[MAXBINS] != NULL) {
(void) sprintf(buf, " ** rover terminator is 0x%lx, fixing\n",
- (ulong) _malloc_rovers[MAXBINS]);
+ (ulong) _malloc_rovers[MAXBINS]);
(void) fputs(buf, fp);
_malloc_rovers[MAXBINS] = NULL;
}
for (ptr = _malloc_mem; ptr != NULL; ptr = ptr->next) {
/* print the arena */
(void) sprintf(buf, "Arena from 0x%lx to 0x%lx, %lu (0x%lx) words\n",
- (ulong) ptr, (ulong) (ptr + SIZE(ptr + 1)),
- (ulong) SIZE(ptr + 1) + 1, (ulong) SIZE(ptr + 1) + 1);
+ (ulong) ptr, (ulong) (ptr + SIZE(ptr + 1)),
+ (ulong) SIZE(ptr + 1) + 1, (ulong) SIZE(ptr + 1) + 1);
(void) fputs(buf, fp);
(void) sprintf(buf, "Next arena is 0x%lx\n", (ulong) ptr->next);
(void) fputs(buf, fp);
(void) fflush(fp);
ASSERT(SIZEFIELD(ptr + 1) == SIZEFIELD(ptr + SIZE(ptr + 1)),
- "mal_dumpheap: corrupt malloc arena");
+ "mal_dumpheap: corrupt malloc arena");
blkend = ptr + SIZE(ptr + 1);
for (blk = ptr + ARENASTART; blk < blkend; blk += SIZE(blk)) {
if (!__m_prblock((univptr_t) blk, 0, fp)) {
- __m_botch("mal_dumpheap: corrupt block", "",
- (univptr_t) 0, 0, __FILE__, __LINE__);
+ __m_botch("mal_dumpheap: corrupt block", "",
+ (univptr_t) 0, 0, __FILE__, __LINE__);
}
}
}
*/
if (nbytes > 0) {
ASSERT(p > lastsbrk,
- "system call error? sbrk returned value lower than previous calls");
+ "system call error? sbrk returned value lower than previous calls");
lastsbrk = p;
}
return p;
}
mmf.i_size = stbuf.st_size;
mmf.i_data = mmap((caddr_t) 0, mmf.i_size, PROT_READ | PROT_WRITE,
- MAP_SHARED, mmf.i_fd, (off_t) 0);
+ MAP_SHARED, mmf.i_fd, (off_t) 0);
if (mmf.i_data == (caddr_t) - 1)
return (univptr_t) -1;
mmf.i_end = mmf.i_data + mmf.i_size;
(void) madvise(mmf.i_data, mmf.i_size, MADV_RANDOM);
return mmf.i_data;
}
-#else /* !HAVE_MMAP */
+#else /* !HAVE_MMAP */
univptr_t
_mal_mmap(nbytes)
size_t nbytes __attribute__ ((__unused__));
return (univptr_t) -1;
}
-#endif /* HAVE_MMAP */
+#endif /* HAVE_MMAP */
void
mal_mmap(fname)
if ((unsigned long) spblk->datb < min_num)
return;
(void) sprintf(_malloc_statsbuf, "%s%8lu %8lu(0x%08lx)\n",
- (char *) spblk->data, (unsigned long) spblk->datb,
- (unsigned long) spblk->key, (unsigned long) spblk->key);
+ (char *) spblk->data, (unsigned long) spblk->datb,
+ (unsigned long) spblk->key, (unsigned long) spblk->key);
(void) fputs(_malloc_statsbuf, dumpfp);
}
global_nbytes = 0;
__spscan(__m_count, (SPBLK *) NULL, sp);
(void) sprintf(_malloc_statsbuf,
- "%% %lu bytes %lu mallocs %p vm\n",
- global_nbytes, nmallocs, sbrk(0));
+ "%% %lu bytes %lu mallocs %p vm\n",
+ global_nbytes, nmallocs, sbrk(0));
(void) fputs(_malloc_statsbuf, fp);
(void) fflush(fp);
}
*/
#define EXCESS 3
sbrkwords = (size_t) (((nwords + EXCESS) / _malloc_sbrkunits + 1) *
- _malloc_sbrkunits);
+ _malloc_sbrkunits);
morecore = sbrkwords * sizeof(Word) + SBRKEXTRA;
if ((cp = (*_malloc_memfunc) (morecore)) == (univptr_t) -1)
return (0);
spare = (char *) (ptr + sbrkwords);
nspare = (morecore - sbrkwords * sizeof(Word));
PRCSRI_TRACE(sprintf(_malloc_statsbuf, "sbrk %lu\n",
- (ulong) sbrkwords * sizeof(Word)));
+ (ulong) sbrkwords * sizeof(Word)));
/*
* If the new chunk adjoins _malloc_hiword, then _malloc_hiword
SIZEFIELD(ptr) = ALLOCED | sbrkwords;
_malloc_hiword += sbrkwords - 1;
PRCSRI_TRACE(sprintf(_malloc_statsbuf, "heapend 0x%lx\n",
- (ulong) _malloc_hiword));
+ (ulong) _malloc_hiword));
SIZEFIELD(_malloc_hiword) = ALLOCED | sbrkwords;
/* * Subtract 2 for the special arena end tags. */
LINK(ptr, sbrkwords, _malloc_lastbin)
_malloc_rovers[_malloc_lastbin] = ptr;
while (_malloc_rovers[_malloc_firstbin] == NULL &&
- _malloc_firstbin < MAXBINS - 1)
+ _malloc_firstbin < MAXBINS - 1)
_malloc_firstbin++;
return (1);
}
errno = EINVAL;
return (NULL);
}
-#endif /* SVID_MALLOC_0 */
+#endif /* SVID_MALLOC_0 */
required = ALLOC_OVERHEAD + (nbytes + sizeof(Word) - 1) / sizeof(Word);
if (required < (size_t) _malloc_minchunk)
CHECKFREEPTR(search, "while searching in malloc()");
searchsize = FREESIZE(search);
if (searchsize >= required) {
- break;
+ break;
} else {
- search = NEXT(search);
+ search = NEXT(search);
}
} while (search != start);
}
p = search - searchsize + 1;
SIZEFIELD(p) = SIZEFIELD(p + required - 1) = ALLOCMASK(required);
PRCSRI_TRACE(sprintf
- (_malloc_statsbuf, "+ %lu %lu 0x%lx\n", (ulong) nbytes,
- (ulong) (required - ALLOC_OVERHEAD) * sizeof(Word),
- (ulong) (p + HEADERWORDS)));
+ (_malloc_statsbuf, "+ %lu %lu 0x%lx\n", (ulong) nbytes,
+ (ulong) (required - ALLOC_OVERHEAD) * sizeof(Word),
+ (ulong) (p + HEADERWORDS)));
COUNTSIZE(required);
SET_REALSIZE(p, nbytes);
return ((univptr_t) (p + HEADERWORDS));
sizep0 = SIZE(p0);
DMEMSET(p0 + FREEHEADERWORDS, sizep0 - FREE_OVERHEAD);
PRCSRI_TRACE(sprintf(_malloc_statsbuf, "- %lu 0x%lx\n",
- (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word),
- (ulong) (p0 + HEADERWORDS)));
+ (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word),
+ (ulong) (p0 + HEADERWORDS)));
p1 = p0 - 1;
/*
SIZEFIELD(p2 - sizep0 + 1) = SIZEFIELD(p2) = FREEMASK(sizep0);
/* Smash p0's old end tag and p2's old start tag. */
DMEMSET(p0 - FREETRAILERWORDS + 1, FREETRAILERWORDS + FREEHEADERWORDS);
- p0 = p2; /* p0 just vanished - became part of p2 */
+ p0 = p2; /* p0 just vanished - became part of p2 */
}
if (TAG(p1) == FREE) {
/*
SIZEFIELD(p0) = SIZEFIELD(p0 + sizep0 - 1) = ALLOCMASK(sizep0);
SET_REALSIZE(p0, nbytes);
PRCSRI_TRACE(sprintf(_malloc_statsbuf, "++ %lu %lu 0x%lx\n",
- (ulong) nbytes,
- (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word),
- (ulong) cp));
+ (ulong) nbytes,
+ (ulong) (sizep0 - ALLOC_OVERHEAD) * sizeof(Word),
+ (ulong) cp));
CHECKHEAP();
return (cp);
}
size_t blksize;
#ifdef CSRI_DEBUG
int tmp_debugging = _malloc_debugging;
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
if (alignment < sizeof(int) || !is_power_of_2(alignment) || size == 0) {
errno = EINVAL;
return (NULL);
}
if (alignment < sizeof(Word))
- return (malloc(size)); /* We guarantee this alignment anyway */
+ return (malloc(size)); /* We guarantee this alignment anyway */
/*
* Life starts to get complicated - need to get a block large
* enough to hold a block 'size' long, starting on an 'alignment'
SET_REALSIZE(p1, size);
if (after > 0) {
/* We can now free the block after the memaligned block. */
- p1 += blksize + ALLOC_OVERHEAD; /* SIZE(p1) */
+ p1 += blksize + ALLOC_OVERHEAD; /* SIZE(p1) */
/*
* p1 now points to the space after the memaligned block. we
* fix the size, mark it alloced, and call free - the block
* call free().
*/
_malloc_debugging = 0;
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
free((univptr_t) (p1 + HEADERWORDS));
}
if (addr != cp) {
}
#ifdef CSRI_DEBUG
_malloc_debugging = tmp_debugging;
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
return (addr);
}
}
_malloc_debugging = level;
}
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
/*
* Allows you to control the number of system calls made, which might
* sure we print the heap start for xmem analysis.
*/
PRCSRI_TRACE(sprintf(_malloc_statsbuf, "heapstart 0x%lx\n",
- (ulong) _malloc_loword));
+ (ulong) _malloc_loword));
}
} else {
/* For symmetry */
for (i = 1; i < MAXPROFILESIZE; i++) {
if (_malloc_scount[i] > 0) {
(void) sprintf(buf, "%lu: %lu\n", (ulong) i * sizeof(Word),
- (ulong) _malloc_scount[i]);
+ (ulong) _malloc_scount[i]);
(void) fputs(buf, fp);
_malloc_scount[i] = 0;
}
}
if (_malloc_scount[0] > 0) {
(void) sprintf(buf, ">= %lu: %lu\n",
- (ulong) MAXPROFILESIZE * sizeof(Word),
- (ulong) _malloc_scount[0]);
+ (ulong) MAXPROFILESIZE * sizeof(Word),
+ (ulong) _malloc_scount[0]);
(void) fputs(buf, fp);
_malloc_scount[0] = 0;
}
(void) fflush(fp);
}
-#endif /* CSRI_PROFILESIZES */
+#endif /* CSRI_PROFILESIZES */
/* Author: Mark Moraes <moraes@csri.toronto.edu> */
REGISTER Word *ptr, *p, *blk, *blkend;
int i;
- if (_malloc_loword == NULL) /* Nothing malloc'ed yet */
+ if (_malloc_loword == NULL) /* Nothing malloc'ed yet */
return (0);
for (i = 0; i < MAXBINS; i++) {
* despite similar appearance of the test
*/
ASSERT(SIZEFIELD(ptr + 1) == SIZEFIELD(ptr + SIZE(ptr + 1)),
- "corrupt malloc arena");
+ "corrupt malloc arena");
blkend = ptr + SIZE(ptr + 1);
for (blk = ptr + ARENASTART; blk < blkend; blk += SIZE(blk)) {
ASSERT_SP(PTR_IN_HEAP(blk), "corrupt pointer", "", blk);
ASSERT_SP(VALID_START_SIZE_FIELD(blk), "corrupt SIZE field", "", blk);
if (TAG(blk) == FREE) {
- p = blk + FREESIZE(blk) - 1;
- ASSERT_EP(VALID_NEXT_PTR(p), "corrupt NEXT pointer", "", p);
- ASSERT_EP(VALID_PREV_PTR(p), "corrupt PREV pointer", "", p);
- if (fullcheck) {
- /* Make sure all free blocks are filled with FREEMAGIC */
- int n;
- char *cp;
-
- n = (SIZE(blk) - FREE_OVERHEAD) * sizeof(Word);
- cp = (char *) (blk + FREEHEADERWORDS);
- for (i = 0; i < n; i++, cp++) {
- ASSERT_SP(*cp == FREEMAGIC,
- "free block modified after free()", "", blk);
- }
- }
+ p = blk + FREESIZE(blk) - 1;
+ ASSERT_EP(VALID_NEXT_PTR(p), "corrupt NEXT pointer", "", p);
+ ASSERT_EP(VALID_PREV_PTR(p), "corrupt PREV pointer", "", p);
+ if (fullcheck) {
+ /* Make sure all free blocks are filled with FREEMAGIC */
+ int n;
+ char *cp;
+
+ n = (SIZE(blk) - FREE_OVERHEAD) * sizeof(Word);
+ cp = (char *) (blk + FREEHEADERWORDS);
+ for (i = 0; i < n; i++, cp++) {
+ ASSERT_SP(*cp == FREEMAGIC,
+ "free block modified after free()", "", blk);
+ }
+ }
} else {
- ASSERT_SP(VALID_MAGIC(blk), "overwritten end of block", "", blk);
+ ASSERT_SP(VALID_MAGIC(blk), "overwritten end of block", "", blk);
}
}
}
return (0);
}
-#endif /* CSRI_DEBUG */
+#endif /* CSRI_DEBUG */
/*
* This file contains a few splay tree routines snarfed from David
return (x);
-} /* spfhead */
+} /* spfhead */
while (x->leftlink != NULL)
x = x->leftlink;
next = x;
- } else { /* x == NULL */
+ } else { /* x == NULL */
x = n->uplink;
next = NULL;
while (x != NULL) {
if (x->leftlink == n) {
- next = x;
- x = NULL;
+ next = x;
+ x = NULL;
} else {
- n = x;
- x = n->uplink;
+ n = x;
+ x = n->uplink;
}
}
}
return (next);
-} /* spfnext */
+} /* spfnext */
char *
sloops = q->splays ? (float) q->splayloops / q->splays : 0;
(void) sprintf(buf, "f(%d %4.2f) i(%d %4.2f) s(%d %4.2f)",
- q->lookups, llen, q->enqs, elen, q->splays, sloops);
+ q->lookups, llen, q->enqs, elen, q->splays, sloops);
return buf;
}
splay(n, q);
x = spdeq(&q->root->rightlink);
- if (x == NULL) { /* empty right subtree */
+ if (x == NULL) { /* empty right subtree */
q->root = q->root->leftlink;
if (q->root)
q->root->uplink = NULL;
- } else { /* non-empty right subtree */
+ } else { /* non-empty right subtree */
x->uplink = NULL;
x->leftlink = q->root->leftlink;
x->rightlink = q->root->rightlink;
q->root = x;
}
spfree(n, q);
-} /* spdelete */
+} /* spdelete */
/*
REGISTER SPBLK *n;
REGISTER SPTREE *q;
{
- REGISTER SPBLK *left; /* the rightmost node in the left tree */
- REGISTER SPBLK *right; /* the leftmost node in the right tree */
- REGISTER SPBLK *next; /* the root of the unsplit part */
+ REGISTER SPBLK *left; /* the rightmost node in the left tree */
+ REGISTER SPBLK *right; /* the leftmost node in the right tree */
+ REGISTER SPBLK *next; /* the root of the unsplit part */
REGISTER SPBLK *temp;
REGISTER univptr_t key;
n->uplink = NULL;
next = q->root;
q->root = n;
- if (next == NULL) { /* trivial enq */
+ if (next == NULL) { /* trivial enq */
n->leftlink = NULL;
n->rightlink = NULL;
- } else { /* difficult enq */
+ } else { /* difficult enq */
key = n->key;
left = n;
right = n;
if (COMPARE(next->key, key) > 0)
goto two;
- one: /* assert next->key <= key */
+ one: /* assert next->key <= key */
- do { /* walk to the right in the left tree */
+ do { /* walk to the right in the left tree */
temp = next->rightlink;
if (temp == NULL) {
- left->rightlink = next;
- next->uplink = left;
- right->leftlink = NULL;
- goto done; /* job done, entire tree split */
+ left->rightlink = next;
+ next->uplink = left;
+ right->leftlink = NULL;
+ goto done; /* job done, entire tree split */
}
q->enqcmps++;
if (COMPARE(temp->key, key) > 0) {
- left->rightlink = next;
- next->uplink = left;
- left = next;
- next = temp;
- goto two; /* change sides */
+ left->rightlink = next;
+ next->uplink = left;
+ left = next;
+ next = temp;
+ goto two; /* change sides */
}
next->rightlink = temp->leftlink;
if (temp->leftlink != NULL)
- temp->leftlink->uplink = next;
+ temp->leftlink->uplink = next;
left->rightlink = temp;
temp->uplink = left;
temp->leftlink = next;
left = temp;
next = temp->rightlink;
if (next == NULL) {
- right->leftlink = NULL;
- goto done; /* job done, entire tree split */
+ right->leftlink = NULL;
+ goto done; /* job done, entire tree split */
}
q->enqcmps++;
- } while (COMPARE(next->key, key) <= 0); /* change sides */
+ } while (COMPARE(next->key, key) <= 0); /* change sides */
- two: /* assert next->key > key */
+ two: /* assert next->key > key */
- do { /* walk to the left in the right tree */
+ do { /* walk to the left in the right tree */
temp = next->leftlink;
if (temp == NULL) {
- right->leftlink = next;
- next->uplink = right;
- left->rightlink = NULL;
- goto done; /* job done, entire tree split */
+ right->leftlink = next;
+ next->uplink = right;
+ left->rightlink = NULL;
+ goto done; /* job done, entire tree split */
}
q->enqcmps++;
if (COMPARE(temp->key, key) <= 0) {
- right->leftlink = next;
- next->uplink = right;
- right = next;
- next = temp;
- goto one; /* change sides */
+ right->leftlink = next;
+ next->uplink = right;
+ right = next;
+ next = temp;
+ goto one; /* change sides */
}
next->leftlink = temp->rightlink;
if (temp->rightlink != NULL)
- temp->rightlink->uplink = next;
+ temp->rightlink->uplink = next;
right->leftlink = temp;
temp->uplink = right;
temp->rightlink = next;
right = temp;
next = temp->leftlink;
if (next == NULL) {
- left->rightlink = NULL;
- goto done; /* job done, entire tree split */
+ left->rightlink = NULL;
+ goto done; /* job done, entire tree split */
}
q->enqcmps++;
- } while (COMPARE(next->key, key) > 0); /* change sides */
+ } while (COMPARE(next->key, key) > 0); /* change sides */
goto one;
- done: /* split is done, branches of n need reversal */
+ done: /* split is done, branches of n need reversal */
temp = n->leftlink;
n->leftlink = n->rightlink;
return (n);
-} /* spenq */
+} /* spenq */
/*----------------
*/
static SPBLK *
spdeq(np)
- SPBLK **np; /* pointer to a node pointer */
+ SPBLK **np; /* pointer to a node pointer */
{
- REGISTER SPBLK *deq; /* one to return */
- REGISTER SPBLK *next; /* the next thing to deal with */
- REGISTER SPBLK *left; /* the left child of next */
- REGISTER SPBLK *farleft; /* the left child of left */
- REGISTER SPBLK *farfarleft; /* the left child of farleft */
+ REGISTER SPBLK *deq; /* one to return */
+ REGISTER SPBLK *next; /* the next thing to deal with */
+ REGISTER SPBLK *left; /* the left child of next */
+ REGISTER SPBLK *farleft; /* the left child of left */
+ REGISTER SPBLK *farfarleft; /* the left child of farleft */
if (np == NULL || *np == NULL) {
deq = NULL;
*np = next->rightlink;
if (*np != NULL)
- (*np)->uplink = NULL;
+ (*np)->uplink = NULL;
} else
- for (;;) { /* left is not null */
- /* next is not it, left is not NULL, might be it */
- farleft = left->leftlink;
- if (farleft == NULL) {
- deq = left;
- next->leftlink = left->rightlink;
- if (left->rightlink != NULL)
- left->rightlink->uplink = next;
- break;
- }
- /* next, left are not it, farleft is not NULL, might be it */
- farfarleft = farleft->leftlink;
- if (farfarleft == NULL) {
- deq = farleft;
- left->leftlink = farleft->rightlink;
- if (farleft->rightlink != NULL)
- farleft->rightlink->uplink = left;
- break;
- }
- /* next, left, farleft are not it, rotate */
- next->leftlink = farleft;
- farleft->uplink = next;
- left->leftlink = farleft->rightlink;
- if (farleft->rightlink != NULL)
- farleft->rightlink->uplink = left;
- farleft->rightlink = left;
- left->uplink = farleft;
- next = farleft;
- left = farfarleft;
+ for (;;) { /* left is not null */
+ /* next is not it, left is not NULL, might be it */
+ farleft = left->leftlink;
+ if (farleft == NULL) {
+ deq = left;
+ next->leftlink = left->rightlink;
+ if (left->rightlink != NULL)
+ left->rightlink->uplink = next;
+ break;
+ }
+ /* next, left are not it, farleft is not NULL, might be it */
+ farfarleft = farleft->leftlink;
+ if (farfarleft == NULL) {
+ deq = farleft;
+ left->leftlink = farleft->rightlink;
+ if (farleft->rightlink != NULL)
+ farleft->rightlink->uplink = left;
+ break;
+ }
+ /* next, left, farleft are not it, rotate */
+ next->leftlink = farleft;
+ farleft->uplink = next;
+ left->leftlink = farleft->rightlink;
+ if (farleft->rightlink != NULL)
+ farleft->rightlink->uplink = left;
+ farleft->rightlink = left;
+ left->uplink = farleft;
+ next = farleft;
+ left = farfarleft;
}
}
return (deq);
-} /* spdeq */
+} /* spdeq */
/*----------------
SPTREE *q;
{
- REGISTER SPBLK *up; /* points to the node being dealt with */
- REGISTER SPBLK *prev; /* a descendent of up, already dealt with */
- REGISTER SPBLK *upup; /* the parent of up */
- REGISTER SPBLK *upupup; /* the grandparent of up */
- REGISTER SPBLK *left; /* the top of left subtree being built */
- REGISTER SPBLK *right; /* the top of right subtree being built */
+ REGISTER SPBLK *up; /* points to the node being dealt with */
+ REGISTER SPBLK *prev; /* a descendent of up, already dealt with */
+ REGISTER SPBLK *upup; /* the parent of up */
+ REGISTER SPBLK *upupup; /* the grandparent of up */
+ REGISTER SPBLK *left; /* the top of left subtree being built */
+ REGISTER SPBLK *right; /* the top of right subtree being built */
left = n->leftlink;
right = n->rightlink;
n into the left subtree, all to right into the right subtree */
upup = up->uplink;
- if (up->leftlink == prev) { /* up is to the right of n */
- if (upup != NULL && upup->leftlink == up) { /* rotate */
- upupup = upup->uplink;
- upup->leftlink = up->rightlink;
- if (upup->leftlink != NULL)
- upup->leftlink->uplink = upup;
- up->rightlink = upup;
- upup->uplink = up;
- if (upupup == NULL)
- q->root = up;
- else if (upupup->leftlink == upup)
- upupup->leftlink = up;
- else
- upupup->rightlink = up;
- up->uplink = upupup;
- upup = upupup;
+ if (up->leftlink == prev) { /* up is to the right of n */
+ if (upup != NULL && upup->leftlink == up) { /* rotate */
+ upupup = upup->uplink;
+ upup->leftlink = up->rightlink;
+ if (upup->leftlink != NULL)
+ upup->leftlink->uplink = upup;
+ up->rightlink = upup;
+ upup->uplink = up;
+ if (upupup == NULL)
+ q->root = up;
+ else if (upupup->leftlink == upup)
+ upupup->leftlink = up;
+ else
+ upupup->rightlink = up;
+ up->uplink = upupup;
+ upup = upupup;
}
up->leftlink = right;
if (right != NULL)
- right->uplink = up;
+ right->uplink = up;
right = up;
- } else { /* up is to the left of n */
- if (upup != NULL && upup->rightlink == up) { /* rotate */
- upupup = upup->uplink;
- upup->rightlink = up->leftlink;
- if (upup->rightlink != NULL)
- upup->rightlink->uplink = upup;
- up->leftlink = upup;
- upup->uplink = up;
- if (upupup == NULL)
- q->root = up;
- else if (upupup->rightlink == upup)
- upupup->rightlink = up;
- else
- upupup->leftlink = up;
- up->uplink = upupup;
- upup = upupup;
+ } else { /* up is to the left of n */
+ if (upup != NULL && upup->rightlink == up) { /* rotate */
+ upupup = upup->uplink;
+ upup->rightlink = up->leftlink;
+ if (upup->rightlink != NULL)
+ upup->rightlink->uplink = upup;
+ up->leftlink = upup;
+ upup->uplink = up;
+ if (upupup == NULL)
+ q->root = up;
+ else if (upupup->rightlink == upup)
+ upupup->rightlink = up;
+ else
+ upupup->leftlink = up;
+ up->uplink = upupup;
+ upup = upupup;
}
up->rightlink = left;
if (left != NULL)
- left->uplink = up;
+ left->uplink = up;
left = up;
}
prev = up;
q->root = n;
n->uplink = NULL;
-} /* splay */
+} /* splay */
#define MAYBE_GET(f,x) \
(indb_flags & (x)) ? getref(f) : 0
-long indb_flags; /**< What flags are in the db we read at startup? */
-long flagdb_flags; /**< What flags are in the flag db we read at startup? */
+long indb_flags; /**< What flags are in the db we read at startup? */
+long flagdb_flags; /**< What flags are in the flag db we read at startup? */
int loading_db = 0; /**< Are we loading the database? */
-char db_timestamp[100]; /**< Time the read database was saved. */
+char db_timestamp[100]; /**< Time the read database was saved. */
struct object *db = NULL; /**< The object db array */
-dbref db_top = 0; /**< The number of objects in the db array */
+dbref db_top = 0; /**< The number of objects in the db array */
-dbref errobj; /**< Dbref of object on which an error has occurred */
+dbref errobj; /**< Dbref of object on which an error has occurred */
-int dbline = 0; /**< Line of the database file being read */
+int dbline = 0; /**< Line of the database file being read */
int use_flagfile = 0; /**< Use seperate file for flags */
/** String that markes the end of dumps */
#ifndef DB_INITIAL_SIZE
#define DB_INITIAL_SIZE 5000 /**< Initial size for db array */
-#endif /* DB_INITIAL_SIZE */
+#endif /* DB_INITIAL_SIZE */
dbref db_size = DB_INITIAL_SIZE; /**< Current size of db array */
-HASHTAB htab_objdata; /**< Object data hash table */
+HASHTAB htab_objdata; /**< Object data hash table */
HASHTAB htab_objdata_keys; /**< Object data keys hash table */
static void db_grow(dbref newtop);
static void db_write_powers(FILE * f);
static dbref db_read_oldstyle(FILE * f);
-StrTree object_names; /**< String tree of object names */
+StrTree object_names; /**< String tree of object names */
StrTree _clastmods;
extern StrTree atr_names;
/* make the initial one */
db_size = (db_init) ? db_init : DB_INITIAL_SIZE;
while (db_top > db_size)
- db_size *= 2;
+ db_size *= 2;
if ((db = (struct object *)
- malloc(db_size * sizeof(struct object))) == NULL) {
- do_rawlog(LT_ERR, "ERROR: out of memory while creating database!");
- abort();
+ malloc(db_size * sizeof(struct object))) == NULL) {
+ do_rawlog(LT_ERR, "ERROR: out of memory while creating database!");
+ abort();
}
}
/* maybe grow it */
if (db_top > db_size) {
/* make sure it's big enough */
while (db_top > db_size)
- db_size *= 2;
+ db_size *= 2;
if ((newdb = (struct object *)
- realloc(db, db_size * sizeof(struct object))) == NULL) {
- do_rawlog(LT_ERR, "ERROR: out of memory while extending database!");
- abort();
+ realloc(db, db_size * sizeof(struct object))) == NULL) {
+ do_rawlog(LT_ERR, "ERROR: out of memory while extending database!");
+ abort();
}
db = newdb;
}
c = getc(f);
while (isspace(c)) {
if (c == '\n')
- dbline++;
+ dbline++;
c = getc(f);
}
if (c == '#') {
while ((c = getc(f)) != '\n' && c != EOF) {
- /* nothing */
+ /* nothing */
}
if (c == '\n')
- dbline++;
+ dbline++;
}
} while (c != EOF && isspace(c));
p = lbuf;
do {
- if (c != '_' && c != '-' && c != '!' && c != '.' && c != '>' && c != '<' && c != '#' && /* these really should only be first time */
- !isalnum(c)) {
+ if (c != '_' && c != '-' && c != '!' && c != '.' && c != '>' && c != '<' && c != '#' && /* these really should only be first time */
+ !isalnum(c)) {
do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in label, line %d",
- c, c, dbline);
+ c, c, dbline);
longjmp(db_err, 1);
}
safe_chr(c, lbuf, &p);
do_rawlog(LT_ERR, T("DB: Unexpected EOF at line %d"), dbline);
else
do_rawlog(LT_ERR, T("DB: Missing value for '%s' at line %d"), lbuf,
- dbline);
+ dbline);
longjmp(db_err, 1);
}
for (;;) {
c = getc(f);
if (c == '"')
- break;
+ break;
if (c == '\\')
- c = getc(f);
+ c = getc(f);
if (c == EOF) {
- do_rawlog(LT_ERR, "DB: Unclosed quoted string starting on line %d",
- sline);
- longjmp(db_err, 1);
+ do_rawlog(LT_ERR, "DB: Unclosed quoted string starting on line %d",
+ sline);
+ longjmp(db_err, 1);
}
if (c == '\0')
- do_rawlog(LT_ERR,
- "DB: warning: null in quoted string, remainder lost, line %d",
- dbline);
+ do_rawlog(LT_ERR,
+ "DB: warning: null in quoted string, remainder lost, line %d",
+ dbline);
if (c == '\n')
- dbline++;
+ dbline++;
safe_chr(c, vbuf, &p);
}
do {
c = getc(f);
if (c != EOF && !isspace(c)) {
- do_rawlog(LT_ERR, "DB: Garbage after quoted string, line %d", dbline);
- longjmp(db_err, 1);
+ do_rawlog(LT_ERR, "DB: Garbage after quoted string, line %d", dbline);
+ longjmp(db_err, 1);
}
} while (c != '\n' && c != EOF);
} else {
/* non-quoted value */
do {
if (c != '_' && c != '-' && c != '!' && c != '.' &&
- c != '#' && !isalnum(c) && !isspace(c)) {
- do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in value, line %d",
- c, c, dbline);
- longjmp(db_err, 1);
+ c != '#' && !isalnum(c) && !isspace(c)) {
+ do_rawlog(LT_ERR, "DB: Illegal character '%c'(%d) in value, line %d",
+ c, c, dbline);
+ longjmp(db_err, 1);
}
safe_chr(c, vbuf, &p);
c = getc(f);
if (strcmp(readlabel, label)) {
do_rawlog(LT_ERR,
- T("DB: error: Got label '%s', expected label '%s' at line %d"),
- readlabel, label, dbline);
+ T("DB: error: Got label '%s', expected label '%s' at line %d"),
+ readlabel, label, dbline);
longjmp(db_err, 1);
}
}
if (strcmp(readlabel, label)) {
do_rawlog(LT_ERR,
- T("DB: error: Got label '%s', expected label '%s' at line %d"),
- readlabel, label, dbline);
+ T("DB: error: Got label '%s', expected label '%s' at line %d"),
+ readlabel, label, dbline);
longjmp(db_err, 1);
}
if (strcmp(readlabel, label)) {
do_rawlog(LT_ERR,
- T("DB: error: Got label '%s', expected label '%s' at line %d"),
- readlabel, label, dbline);
+ T("DB: error: Got label '%s', expected label '%s' at line %d"),
+ readlabel, label, dbline);
longjmp(db_err, 1);
}
if (strcmp(readlabel, label)) {
do_rawlog(LT_ERR,
- T("DB: error: Got label '%s', expected label '%s' at line %d"),
- readlabel, label, dbline);
+ T("DB: error: Got label '%s', expected label '%s' at line %d"),
+ readlabel, label, dbline);
longjmp(db_err, 1);
}
*val = qparse_dbref(readvalue);
strcpy(name, AL_NAME(list));
for (p = name; *p; p++) {
if (!isprint((unsigned char) *p) || isspace((unsigned char) *p)) {
- *p = '!';
- fixmemdb = err = 1;
+ *p = '!';
+ fixmemdb = err = 1;
}
}
if (err) {
* number to the end. Give up if we can't find one < 10000
*/
if (atr_get_noparent(i, name)) {
- count = 0;
- do {
- name[BUFFER_LEN - 6] = '\0';
- sprintf(tbuf1, "%s%d", name, count);
- count++;
- } while (count < 10000 && atr_get_noparent(i, tbuf1));
- strcpy(name, tbuf1);
+ count = 0;
+ do {
+ name[BUFFER_LEN - 6] = '\0';
+ sprintf(tbuf1, "%s%d", name, count);
+ count++;
+ } while (count < 10000 && atr_get_noparent(i, tbuf1));
+ strcpy(name, tbuf1);
}
do_rawlog(LT_CHECK,
- T(" * Bad attribute name on #%d. Changing name to %s.\n"),
- i, name);
+ T(" * Bad attribute name on #%d. Changing name to %s.\n"),
+ i, name);
err = 0;
}
/* check the owner */
lastp = '\0';
for (p = tbuf1; *p; p++) {
if (!isprint((unsigned char) *p)) {
- if (!isspace((unsigned char) *p)) {
- *p = '!';
- err = 1;
- }
+ if (!isspace((unsigned char) *p)) {
+ *p = '!';
+ err = 1;
+ }
}
lastp = *p;
}
if (err) {
fixmemdb = 1;
do_rawlog(LT_CHECK,
- T(" * Bad text in attribute %s on #%d. Changed to:\n"), name,
- i);
+ T(" * Bad text in attribute %s on #%d. Changed to:\n"), name,
+ i);
do_rawlog(LT_CHECK, "%s\n", tbuf1);
}
db_write_labeled_string(f, "value", tbuf1);
} else if (c != '"') {
for (;;) {
if ((c == '\0') || (c == EOF) ||
- ((c == '\n') && ((p == buf) || (p[-1] != '\r')))) {
- *p = '\0';
- if (c == '\n')
- dbline++;
- return buf;
+ ((c == '\n') && ((p == buf) || (p[-1] != '\r')))) {
+ *p = '\0';
+ if (c == '\n')
+ dbline++;
+ return buf;
}
safe_chr(c, buf, &p);
c = fgetc(f);
for (;;) {
c = fgetc(f);
if (c == '"') {
- /* It's a closing quote if it's followed by \r or \n */
- c = fgetc(f);
- if (c == '\r') {
- /* Get a possible \n, too */
- if ((c = fgetc(f)) != '\n')
- ungetc(c, f);
- else
- dbline++;
- } else if (c != '\n')
- ungetc(c, f);
- *p = '\0';
- return buf;
+ /* It's a closing quote if it's followed by \r or \n */
+ c = fgetc(f);
+ if (c == '\r') {
+ /* Get a possible \n, too */
+ if ((c = fgetc(f)) != '\n')
+ ungetc(c, f);
+ else
+ dbline++;
+ } else if (c != '\n')
+ ungetc(c, f);
+ *p = '\0';
+ return buf;
} else if (c == '\\') {
- c = fgetc(f);
+ c = fgetc(f);
}
if ((c == '\0') || (c == EOF)) {
- *p = '\0';
- return buf;
+ *p = '\0';
+ return buf;
}
safe_chr(c, buf, &p);
}
do_rawlog(LT_ERR, T("ERROR: Invalid lock format on object #%d"), i);
return;
}
- b = getboolexp(f, buf); /* Which will clobber a '\n' */
+ b = getboolexp(f, buf); /* Which will clobber a '\n' */
if (b == TRUE_BOOLEXP) {
/* getboolexp() would already have complained. */
return;
memset(byte_buf, 0, BUFFER_LEN);
bp = byte_buf;
- (void) fgetc(f); /* Skip the leading " */
+ (void) fgetc(f); /* Skip the leading " */
for(;;) {
i = fgetc(f);
if(i == '\"') {
tbuf1[0] = '\0';
while (1)
switch (c = getc(f)) {
- case ']': /* new style attribs, read name then value */
+ case ']': /* new style attribs, read name then value */
/* Using getstring_noalloc here will cause problems with attribute
names starting with ". This is probably a better fix than just
disallowing " in attribute names. */
fgets(tbuf1, BUFFER_LEN + 150, f);
if (!(p = strchr(tbuf1, '^'))) {
- do_rawlog(LT_ERR, T("ERROR: Bad format on new attributes. object #%d"),
- i);
- return -1;
+ do_rawlog(LT_ERR, T("ERROR: Bad format on new attributes. object #%d"),
+ i);
+ return -1;
}
*p++ = '\0';
if (!(q = strchr(p, '^'))) {
- do_rawlog(LT_ERR,
- T("ERROR: Bad format on new attribute %s. object #%d"),
- tbuf1, i);
- return -1;
+ do_rawlog(LT_ERR,
+ T("ERROR: Bad format on new attribute %s. object #%d"),
+ tbuf1, i);
+ return -1;
}
*q++ = '\0';
flags = atoi(q);
flags &= ~AF_NUKED;
flags &= ~AF_STATIC;
if (!(indb_flags & DBF_AF_VISUAL)) {
- /* Remove AF_ODARK flag. If it wasn't there, set AF_VISUAL */
- if (!(flags & AF_ODARK))
- flags |= AF_VISUAL;
- flags &= ~AF_ODARK;
+ /* Remove AF_ODARK flag. If it wasn't there, set AF_VISUAL */
+ if (!(flags & AF_ODARK))
+ flags |= AF_VISUAL;
+ flags &= ~AF_ODARK;
}
/* Read in the deref count for the attribute, or set it to 0 if not
present. */
q = strchr(q, '^');
if (q++)
- derefs = atoi(q);
+ derefs = atoi(q);
else
- derefs = 0;
+ derefs = 0;
/* We add the attribute assuming that atoi(p) is an ok dbref
* since we haven't loaded the whole db and can't really tell
* if it is or not. We'll fix this up at the end of the load
* attributes (which, if not built-in attrs, have a flag val of 0.)
*/
break;
- case '>': /* old style attribs, die noisily */
+ case '>': /* old style attribs, die noisily */
do_rawlog(LT_ERR, T("ERROR: old-style attribute format in object %d"), i);
return -1;
break;
- case '<': /* end of list */
+ case '<': /* end of list */
if ('\n' != getc(f)) {
- do_rawlog(LT_ERR, T("ERROR: no line feed after < on object %d"), i);
- return -1;
+ do_rawlog(LT_ERR, T("ERROR: no line feed after < on object %d"), i);
+ return -1;
}
return count;
default:
if (c == EOF) {
- do_rawlog(LT_ERR, T("ERROR: Unexpected EOF on file."));
- return -1;
+ do_rawlog(LT_ERR, T("ERROR: Unexpected EOF on file."));
+ return -1;
}
do_rawlog(LT_ERR,
- T
- ("ERROR: Bad character %c (%d) in attribute list on object %d"),
- c, c, i);
+ T
+ ("ERROR: Bad character %c (%d) in attribute list on object %d"),
+ c, c, i);
do_rawlog(LT_ERR,
- T(" (expecting ], >, or < as first character of the line.)"));
+ T(" (expecting ], >, or < as first character of the line.)"));
if (*tbuf1)
- do_rawlog(LT_ERR, T(" Last attribute read was: %s"), tbuf1);
+ do_rawlog(LT_ERR, T(" Last attribute read was: %s"), tbuf1);
else
- do_rawlog(LT_ERR, T(" No attributes had been read yet."));
+ do_rawlog(LT_ERR, T(" No attributes had been read yet."));
return -1;
}
}
while((c = fgetc(f)) != EOF) {
if(c == '+') {
- c = fgetc(f);
- if(c == 'F') {
- (void) getstring_noalloc(f);
- flag_read_all(f, "FLAG");
- } else if(c == 'P'){
- (void) getstring_noalloc(f);
- powers_read_all(f);
- }else {
- do_rawlog(LT_ERR, T("Unrecgonized database format"));
- return -1;
- }
+ c = fgetc(f);
+ if(c == 'F') {
+ (void) getstring_noalloc(f);
+ flag_read_all(f, "FLAG");
+ } else if(c == 'P'){
+ (void) getstring_noalloc(f);
+ powers_read_all(f);
+ }else {
+ do_rawlog(LT_ERR, T("Unrecgonized database format"));
+ return -1;
+ }
} else if(c == '*'){
char buff[80];
ungetc('*', f);
fgets(buff, sizeof buff, f);
if(strcmp(buff, EOD) != 0){
- do_rawlog(LT_ERR, T("ERROR: No end of dump entry."));
- return -1;
+ do_rawlog(LT_ERR, T("ERROR: No end of dump entry."));
+ return -1;
} else {
- do_rawlog(LT_ERR, T("READING: done"));
- break;
+ do_rawlog(LT_ERR, T("READING: done"));
+ break;
}
} else {
do_rawlog(LT_ERR, T("Unrecognized database format"));
break;
/* Use the MUSH 2.0 header stuff to see what's in this db */
case '+':
- c = getc(f); /* Skip the V */
+ c = getc(f); /* Skip the V */
if (c == 'F') {
- (void) getstring_noalloc(f);
- flag_read_all(f, "FLAG");
+ (void) getstring_noalloc(f);
+ flag_read_all(f, "FLAG");
} else {
- do_rawlog(LT_ERR, T("Unrecognized database format!"));
- return -1;
+ do_rawlog(LT_ERR, T("Unrecognized database format!"));
+ return -1;
}
break;
/* old fashioned database */
case '#':
- case '&': /* zone oriented database */
+ case '&': /* zone oriented database */
do_rawlog(LT_ERR, T("ERROR: old style database."));
return -1;
break;
/* new database */
- case '!': /* non-zone oriented database */
+ case '!': /* non-zone oriented database */
/* make space */
i = getref(f);
db_grow(i + 1);
if (indb_flags & DBF_DIVISIONS) {
o->division.object = getref(f);
o->division.level = getref(f);
- /* This is the spot for poweres.. read it to NULL ville */
- getref(f);
- /* Read Old Style and convert */
+ /* This is the spot for poweres.. read it to NULL ville */
+ getref(f);
+ /* Read Old Style and convert */
old_dp_bytes = getbytes(f);
- o->division.dp_bytes = (div_pbits) convert_old_cobra_powers(old_dp_bytes);
+ o->division.dp_bytes = (div_pbits) convert_old_cobra_powers(old_dp_bytes);
} else {
o->division.object = -1;
o->division.level = 1;
}
s_Pennies(i, getref(f));
if (indb_flags & DBF_NEW_FLAGS) {
- o->type = getref(f);
- o->flags = string_to_bits("FLAG", getstring_noalloc(f));
+ o->type = getref(f);
+ o->flags = string_to_bits("FLAG", getstring_noalloc(f));
} else {
- int old_flags, old_toggles;
- old_flags = getref(f);
- old_toggles = getref(f);
- if ((o->type = type_from_old_flags(old_flags)) < 0) {
- do_rawlog(LT_ERR, T("Unable to determine type of #%d\n"), i);
- return -1;
- }
- o->flags =
- flags_from_old_flags(old_flags, old_toggles, o->type);
+ int old_flags, old_toggles;
+ old_flags = getref(f);
+ old_toggles = getref(f);
+ if ((o->type = type_from_old_flags(old_flags)) < 0) {
+ do_rawlog(LT_ERR, T("Unable to determine type of #%d\n"), i);
+ return -1;
+ }
+ o->flags =
+ flags_from_old_flags(old_flags, old_toggles, o->type);
}
/* We need to have flags in order to do this right, which is why
*/
switch (Typeof(i)) {
case TYPE_PLAYER:
- current_state.players++;
- current_state.garbage--;
- break;
+ current_state.players++;
+ current_state.garbage--;
+ break;
case TYPE_THING:
- current_state.things++;
- current_state.garbage--;
- break;
+ current_state.things++;
+ current_state.garbage--;
+ break;
case TYPE_EXIT:
- current_state.exits++;
- current_state.garbage--;
- break;
+ current_state.exits++;
+ current_state.garbage--;
+ break;
case TYPE_ROOM:
- current_state.rooms++;
- current_state.garbage--;
- break;
+ current_state.rooms++;
+ current_state.garbage--;
+ break;
case TYPE_DIVISION:
current_state.divisions++;
current_state.garbage--;
}
if (IsPlayer(i) && (strlen(o->name) > (Size_t) PLAYER_NAME_LIMIT)) {
- char buff[BUFFER_LEN + 1]; /* The name plus a NUL */
- strncpy(buff, o->name, PLAYER_NAME_LIMIT);
- buff[PLAYER_NAME_LIMIT] = '\0';
- set_name(i, buff);
- do_rawlog(LT_CHECK,
- T(" * Name of #%d is longer than the maximum, truncating.\n"),
- i);
+ char buff[BUFFER_LEN + 1]; /* The name plus a NUL */
+ strncpy(buff, o->name, PLAYER_NAME_LIMIT);
+ buff[PLAYER_NAME_LIMIT] = '\0';
+ set_name(i, buff);
+ do_rawlog(LT_CHECK,
+ T(" * Name of #%d is longer than the maximum, truncating.\n"),
+ i);
} else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) {
- char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */
- strncpy(buff, o->name, OBJECT_NAME_LIMIT);
- buff[OBJECT_NAME_LIMIT] = '\0';
- set_name(i, buff);
- do_rawlog(LT_CHECK,
- T(" * Name of #%d is longer than the maximum, truncating.\n"),
- i);
+ char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */
+ strncpy(buff, o->name, OBJECT_NAME_LIMIT);
+ buff[OBJECT_NAME_LIMIT] = '\0';
+ set_name(i, buff);
+ do_rawlog(LT_CHECK,
+ T(" * Name of #%d is longer than the maximum, truncating.\n"),
+ i);
}
if (!(indb_flags & DBF_VALUE_IS_COST) && IsThing(i))
- s_Pennies(i, (Pennies(i) + 1) * 5);
+ s_Pennies(i, (Pennies(i) + 1) * 5);
if(!(indb_flags & DBF_DIVISIONS)) {
- opbits = getref(f); /* save old pows to c to pass to conversion after object is read*/
- convert_object_powers(i, opbits);
+ opbits = getref(f); /* save old pows to c to pass to conversion after object is read*/
+ convert_object_powers(i, opbits);
}
/* Remove the STARTUP and ACCESSED flags */
if (!(indb_flags & DBF_NO_STARTUP_FLAG)) {
- clear_flag_internal(i, "STARTUP");
- clear_flag_internal(i, "ACCESSED");
+ clear_flag_internal(i, "STARTUP");
+ clear_flag_internal(i, "ACCESSED");
}
/* Clear the GOING flags. If it was scheduled for destruction
/* If there are channels in the db, read 'em in */
/* We don't support this anymore, so we just discard them */
if (!(indb_flags & DBF_NO_CHAT_SYSTEM))
- temp = getref(f);
+ temp = getref(f);
else
- temp = 0;
+ temp = 0;
/* If there are warnings in the db, read 'em in */
temp = MAYBE_GET(f, DBF_WARNINGS);
/* If there are creation times in the db, read 'em in */
temp_time = MAYBE_GET(f, DBF_CREATION_TIMES);
if (temp_time)
- o->creation_time = (time_t) temp_time;
+ o->creation_time = (time_t) temp_time;
else
- o->creation_time = mudtime;
+ o->creation_time = mudtime;
temp_time = MAYBE_GET(f, DBF_CREATION_TIMES);
if (temp_time || IsPlayer(i))
- o->modification_time = (time_t) temp_time;
+ o->modification_time = (time_t) temp_time;
else
- o->modification_time = o->creation_time;
+ o->modification_time = o->creation_time;
/* read attribute list for item */
if ((o->attrcount = get_list(f, i)) < 0) {
- do_rawlog(LT_ERR, T("ERROR: bad attribute list object %d"), i);
- return -1;
+ do_rawlog(LT_ERR, T("ERROR: bad attribute list object %d"), i);
+ return -1;
}
if (!(indb_flags & DBF_AF_NODUMP)) {
- /* Clear QUEUE and SEMAPHORE attributes */
- atr_clr(i, "QUEUE", GOD);
- atr_clr(i, "SEMAPHORE", GOD);
+ /* Clear QUEUE and SEMAPHORE attributes */
+ atr_clr(i, "QUEUE", GOD);
+ atr_clr(i, "SEMAPHORE", GOD);
}
/* check to see if it's a player */
if (IsPlayer(i)) {
- add_player(i);
- clear_flag_internal(i, "CONNECTED");
+ add_player(i);
+ clear_flag_internal(i, "CONNECTED");
}
break;
case '*':
{
- char buff[80];
- ungetc('*', f);
- fgets(buff, sizeof buff, f);
- if (strcmp(buff, EOD) != 0) {
- do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1);
- return -1;
- } else {
- if(!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) {
- dbref master_division;
- /* Final Step of DB Conversion
- * We're gonna first Create the Master Division
- * Second we're gonna loop through the database
- * set all players except unregistered players to the master division
- * and set all levels appropriate
- **/
- i = GOD;
- master_division = new_object();
- set_name(master_division, "Master Division");
- Type(master_division) = TYPE_DIVISION;
- PUSH(master_division, Contents(i));
- Owner(master_division) = i;
- CreTime(master_division) = ModTime(master_division) = mudtime;
- atr_new_add(master_division, "DESCRIBE",
- "This is the master division that comes before all divisions.", i,
- AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
- current_state.divisions++;
- SLEVEL(master_division) = LEVEL_DIRECTOR;
- SLEVEL(i) = LEVEL_GOD;
- /* Division & God Setup now run through the database & set everyitng else up */
- for(i = 0; i < db_top; i++)
- {
- if(has_flag_by_name(i, "UNREGISTERED", TYPE_PLAYER)){
- SLEVEL(i) = LEVEL_UNREGISTERED;
- clear_flag_internal(i, "UNREGISTERED");
- } else if(i != master_division) {
- SDIV(i).object = master_division;
- if(!has_flag_by_name(i, "WIZARD", NOTYPE) &&
- !has_flag_by_name(i, "ROYALTY", NOTYPE) && SLEVEL(i) != -500) {
- SLEVEL(i) = LEVEL_PLAYER;
- } else if(SLEVEL(i) == -500) {
- SLEVEL(i) = LEVEL_GUEST;
- } else { /* They look like wizard or royalty.. Set 'em to 29 */
- SLEVEL(i) = LEVEL_DIRECTOR;
- }
- }
- }
- do_rawlog(LT_ERR, T("DB Conversion complete"));
- }
- do_rawlog(LT_ERR, "READING: done");
- loading_db = 0;
- fix_free_list();
- dbck();
- log_mem_check();
- return db_top;
- }
+ char buff[80];
+ ungetc('*', f);
+ fgets(buff, sizeof buff, f);
+ if (strcmp(buff, EOD) != 0) {
+ do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1);
+ return -1;
+ } else {
+ if(!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) {
+ dbref master_division;
+ /* Final Step of DB Conversion
+ * We're gonna first Create the Master Division
+ * Second we're gonna loop through the database
+ * set all players except unregistered players to the master division
+ * and set all levels appropriate
+ **/
+ i = GOD;
+ master_division = new_object();
+ set_name(master_division, "Master Division");
+ Type(master_division) = TYPE_DIVISION;
+ PUSH(master_division, Contents(i));
+ Owner(master_division) = i;
+ CreTime(master_division) = ModTime(master_division) = mudtime;
+ atr_new_add(master_division, "DESCRIBE",
+ "This is the master division that comes before all divisions.", i,
+ AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
+ current_state.divisions++;
+ SLEVEL(master_division) = LEVEL_DIRECTOR;
+ SLEVEL(i) = LEVEL_GOD;
+ /* Division & God Setup now run through the database & set everyitng else up */
+ for(i = 0; i < db_top; i++)
+ {
+ if(has_flag_by_name(i, "UNREGISTERED", TYPE_PLAYER)){
+ SLEVEL(i) = LEVEL_UNREGISTERED;
+ clear_flag_internal(i, "UNREGISTERED");
+ } else if(i != master_division) {
+ SDIV(i).object = master_division;
+ if(!has_flag_by_name(i, "WIZARD", NOTYPE) &&
+ !has_flag_by_name(i, "ROYALTY", NOTYPE) && SLEVEL(i) != -500) {
+ SLEVEL(i) = LEVEL_PLAYER;
+ } else if(SLEVEL(i) == -500) {
+ SLEVEL(i) = LEVEL_GUEST;
+ } else { /* They look like wizard or royalty.. Set 'em to 29 */
+ SLEVEL(i) = LEVEL_DIRECTOR;
+ }
+ }
+ }
+ do_rawlog(LT_ERR, T("DB Conversion complete"));
+ }
+ do_rawlog(LT_ERR, "READING: done");
+ loading_db = 0;
+ fix_free_list();
+ dbck();
+ log_mem_check();
+ return db_top;
+ }
}
default:
do_rawlog(LT_ERR, T("ERROR: failed object %d"), i);
case '+':
c = fgetc(f);
if (c == 'F') {
- (void) getstring_noalloc(f);
- flag_read_all(f, "FLAG");
+ (void) getstring_noalloc(f);
+ flag_read_all(f, "FLAG");
} else if (c == 'P') {
- (void) getstring_noalloc(f);
- if(!(indb_flags & DBF_TYPE_GARBAGE))
- powers_read_all(f);
- else {
- if(ps_tab._Read_Powers_ == 0)
- init_powers();
- flag_read_all(f, NULL);
- }
+ (void) getstring_noalloc(f);
+ if(!(indb_flags & DBF_TYPE_GARBAGE))
+ powers_read_all(f);
+ else {
+ if(ps_tab._Read_Powers_ == 0)
+ init_powers();
+ flag_read_all(f, NULL);
+ }
} else {
- do_rawlog(LT_ERR, T("Unrecognized database format!"));
- return -1;
+ do_rawlog(LT_ERR, T("Unrecognized database format!"));
+ return -1;
}
break;
case '~':
case '!':
/* Read an object */
{
- char *label, *value;
- /* Thre should be an entry in the enum and following table and
- switch for each top-level label associated with an
- object. Not finding a label is not an error; the default
- set in new_object() is used. Finding a label not listed
- below is an error. */
- enum known_labels {
- LBL_NAME, LBL_LOCATION, LBL_CONTENTS, LBL_EXITS,
- LBL_NEXT, LBL_PARENT, LBL_LOCKS, LBL_OWNER, LBL_ZONE,
- LBL_PENNIES, LBL_TYPE, LBL_FLAGS, LBL_POWERGROUPS, LBL_POWERS, LBL_WARNINGS,
- LBL_CREATED, LBL_MODIFIED, LBL_ATTRS, LBL_ERROR, LBL_LEVEL,
- LBL_DIVOBJ, LBL_PWRLVL, LBL_LMOD
- };
- struct label_table {
- const char *label;
- enum known_labels tag;
- };
- struct label_table fields[] = {
- {"name", LBL_NAME},
- {"location", LBL_LOCATION},
- {"contents", LBL_CONTENTS},
- {"exits", LBL_EXITS},
- {"next", LBL_NEXT},
- {"parent", LBL_PARENT},
- {"lockcount", LBL_LOCKS},
- {"owner", LBL_OWNER},
- {"zone", LBL_ZONE},
- {"pennies", LBL_PENNIES},
- {"type", LBL_TYPE},
- {"flags", LBL_FLAGS},
- {"powers", LBL_POWERS},
- {"warnings", LBL_WARNINGS},
- {"created", LBL_CREATED},
- {"modified", LBL_MODIFIED},
- {"attrcount", LBL_ATTRS},
- {"division_object", LBL_DIVOBJ},
- {"level", LBL_LEVEL},
- {"powerlevel", LBL_PWRLVL},
- {"powergroup", LBL_POWERGROUPS},
- {"lastmod", LBL_LMOD},
- /* Add new label types here. */
- {NULL, LBL_ERROR}
- }, *entry;
- enum known_labels the_label;
-
- i = getref(f);
- db_grow(i + 1);
- o = db + i;
- while (1) {
- c = fgetc(f);
- ungetc(c, f);
- /* At the start of another object or the EOD marker */
- if (c == '!' || c == '*')
- break;
- db_read_labeled_string(f, &label, &value);
- the_label = LBL_ERROR;
- /* Look up the right enum value in the label table */
- for (entry = fields; entry->label; entry++) {
- if (strcmp(entry->label, label) == 0) {
- the_label = entry->tag;
- break;
- }
- }
- switch (the_label) {
- case LBL_NAME:
- set_name(i, value);
- break;
- case LBL_LOCATION:
- o->location = qparse_dbref(value);
- break;
- case LBL_CONTENTS:
- o->contents = qparse_dbref(value);
- break;
- case LBL_EXITS:
- o->exits = qparse_dbref(value);
- break;
- case LBL_NEXT:
- o->next = qparse_dbref(value);
- break;
- case LBL_PARENT:
- o->parent = qparse_dbref(value);
- break;
- case LBL_LOCKS:
- get_new_locks(i, f, parse_integer(value));
- break;
- case LBL_LEVEL:
- o->division.level = parse_integer(value);
- break;
- case LBL_PWRLVL:
- /* Do nothing with this value */
- break;
- case LBL_DIVOBJ:
- o->division.object = qparse_dbref(value);
- break;
- case LBL_OWNER:
- o->owner = qparse_dbref(value);
- break;
- case LBL_ZONE:
- o->zone = qparse_dbref(value);
- break;
- case LBL_PENNIES:
- s_Pennies(i, parse_integer(value));
- break;
- case LBL_TYPE:
- o->type = parse_integer(value);
- switch (Typeof(i)) {
- case TYPE_PLAYER:
- current_state.players++;
- current_state.garbage--;
- break;
- case TYPE_DIVISION:
- current_state.divisions++;
- current_state.garbage--;
- break;
- case TYPE_THING:
- current_state.things++;
- current_state.garbage--;
- break;
- case TYPE_EXIT:
- current_state.exits++;
- current_state.garbage--;
- break;
- case TYPE_ROOM:
- current_state.rooms++;
- current_state.garbage--;
- break;
- }
- break;
- case LBL_FLAGS:
- o->flags = string_to_bits("FLAG", value);
- /* Clear the GOING flags. If it was scheduled for destruction
- * when the db was saved, it gets a reprieve.
- */
- clear_flag_internal(i, "GOING");
- clear_flag_internal(i, "GOING_TWICE");
- break;
- case LBL_POWERS:
- div_powers = string_to_dpbits(value);
- if(power_is_zero(div_powers, DP_BYTES) == 0) {
- o->division.dp_bytes = NULL;
- mush_free(div_powers, "POWER_SPOT");
- } else o->division.dp_bytes = div_powers;
- break;
- case LBL_POWERGROUPS:
- powergroup_db_set(NOTHING, i, value, 0);
- break;
- case LBL_WARNINGS:
- o->warnings = parse_warnings(NOTHING, value);
- break;
- case LBL_CREATED:
- o->creation_time = (time_t) parse_integer(value);
- break;
- case LBL_MODIFIED:
- o->modification_time = (time_t) parse_integer(value);
- break;
- case LBL_LMOD:
- db[i].lastmod = NULL;
- set_lmod(i, value);
- break;
- case LBL_ATTRS:
- {
- int attrcount = parse_integer(value);
- db_read_attrs(f, i, attrcount);
- }
- break;
- case LBL_ERROR:
- default:
- do_rawlog(LT_ERR, T("Unrecognized field '%s' in object #%d"),
- label, i);
- return -1;
- }
- }
- if (IsPlayer(i) && (strlen(o->name) > (size_t) PLAYER_NAME_LIMIT)) {
- char buff[BUFFER_LEN + 1]; /* The name plus a NUL */
- strncpy(buff, o->name, PLAYER_NAME_LIMIT);
- buff[PLAYER_NAME_LIMIT] = '\0';
- set_name(i, buff);
- do_rawlog(LT_CHECK,
- T
- (" * Name of #%d is longer than the maximum, truncating.\n"),
- i);
- } else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) {
- char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */
- strncpy(buff, o->name, OBJECT_NAME_LIMIT);
- buff[OBJECT_NAME_LIMIT] = '\0';
- set_name(i, buff);
- do_rawlog(LT_CHECK,
- T
- (" * Name of #%d is longer than the maximum, truncating.\n"),
- i);
- }
- if (IsPlayer(i)) {
- add_player(i);
- clear_flag_internal(i, "CONNECTED");
- }
+ char *label, *value;
+ /* Thre should be an entry in the enum and following table and
+ switch for each top-level label associated with an
+ object. Not finding a label is not an error; the default
+ set in new_object() is used. Finding a label not listed
+ below is an error. */
+ enum known_labels {
+ LBL_NAME, LBL_LOCATION, LBL_CONTENTS, LBL_EXITS,
+ LBL_NEXT, LBL_PARENT, LBL_LOCKS, LBL_OWNER, LBL_ZONE,
+ LBL_PENNIES, LBL_TYPE, LBL_FLAGS, LBL_POWERGROUPS, LBL_POWERS, LBL_WARNINGS,
+ LBL_CREATED, LBL_MODIFIED, LBL_ATTRS, LBL_ERROR, LBL_LEVEL,
+ LBL_DIVOBJ, LBL_PWRLVL, LBL_LMOD
+ };
+ struct label_table {
+ const char *label;
+ enum known_labels tag;
+ };
+ struct label_table fields[] = {
+ {"name", LBL_NAME},
+ {"location", LBL_LOCATION},
+ {"contents", LBL_CONTENTS},
+ {"exits", LBL_EXITS},
+ {"next", LBL_NEXT},
+ {"parent", LBL_PARENT},
+ {"lockcount", LBL_LOCKS},
+ {"owner", LBL_OWNER},
+ {"zone", LBL_ZONE},
+ {"pennies", LBL_PENNIES},
+ {"type", LBL_TYPE},
+ {"flags", LBL_FLAGS},
+ {"powers", LBL_POWERS},
+ {"warnings", LBL_WARNINGS},
+ {"created", LBL_CREATED},
+ {"modified", LBL_MODIFIED},
+ {"attrcount", LBL_ATTRS},
+ {"division_object", LBL_DIVOBJ},
+ {"level", LBL_LEVEL},
+ {"powerlevel", LBL_PWRLVL},
+ {"powergroup", LBL_POWERGROUPS},
+ {"lastmod", LBL_LMOD},
+ /* Add new label types here. */
+ {NULL, LBL_ERROR}
+ }, *entry;
+ enum known_labels the_label;
+
+ i = getref(f);
+ db_grow(i + 1);
+ o = db + i;
+ while (1) {
+ c = fgetc(f);
+ ungetc(c, f);
+ /* At the start of another object or the EOD marker */
+ if (c == '!' || c == '*')
+ break;
+ db_read_labeled_string(f, &label, &value);
+ the_label = LBL_ERROR;
+ /* Look up the right enum value in the label table */
+ for (entry = fields; entry->label; entry++) {
+ if (strcmp(entry->label, label) == 0) {
+ the_label = entry->tag;
+ break;
+ }
+ }
+ switch (the_label) {
+ case LBL_NAME:
+ set_name(i, value);
+ break;
+ case LBL_LOCATION:
+ o->location = qparse_dbref(value);
+ break;
+ case LBL_CONTENTS:
+ o->contents = qparse_dbref(value);
+ break;
+ case LBL_EXITS:
+ o->exits = qparse_dbref(value);
+ break;
+ case LBL_NEXT:
+ o->next = qparse_dbref(value);
+ break;
+ case LBL_PARENT:
+ o->parent = qparse_dbref(value);
+ break;
+ case LBL_LOCKS:
+ get_new_locks(i, f, parse_integer(value));
+ break;
+ case LBL_LEVEL:
+ o->division.level = parse_integer(value);
+ break;
+ case LBL_PWRLVL:
+ /* Do nothing with this value */
+ break;
+ case LBL_DIVOBJ:
+ o->division.object = qparse_dbref(value);
+ break;
+ case LBL_OWNER:
+ o->owner = qparse_dbref(value);
+ break;
+ case LBL_ZONE:
+ o->zone = qparse_dbref(value);
+ break;
+ case LBL_PENNIES:
+ s_Pennies(i, parse_integer(value));
+ break;
+ case LBL_TYPE:
+ o->type = parse_integer(value);
+ switch (Typeof(i)) {
+ case TYPE_PLAYER:
+ current_state.players++;
+ current_state.garbage--;
+ break;
+ case TYPE_DIVISION:
+ current_state.divisions++;
+ current_state.garbage--;
+ break;
+ case TYPE_THING:
+ current_state.things++;
+ current_state.garbage--;
+ break;
+ case TYPE_EXIT:
+ current_state.exits++;
+ current_state.garbage--;
+ break;
+ case TYPE_ROOM:
+ current_state.rooms++;
+ current_state.garbage--;
+ break;
+ }
+ break;
+ case LBL_FLAGS:
+ o->flags = string_to_bits("FLAG", value);
+ /* Clear the GOING flags. If it was scheduled for destruction
+ * when the db was saved, it gets a reprieve.
+ */
+ clear_flag_internal(i, "GOING");
+ clear_flag_internal(i, "GOING_TWICE");
+ break;
+ case LBL_POWERS:
+ div_powers = string_to_dpbits(value);
+ if(power_is_zero(div_powers, DP_BYTES) == 0) {
+ o->division.dp_bytes = NULL;
+ mush_free(div_powers, "POWER_SPOT");
+ } else o->division.dp_bytes = div_powers;
+ break;
+ case LBL_POWERGROUPS:
+ powergroup_db_set(NOTHING, i, value, 0);
+ break;
+ case LBL_WARNINGS:
+ o->warnings = parse_warnings(NOTHING, value);
+ break;
+ case LBL_CREATED:
+ o->creation_time = (time_t) parse_integer(value);
+ break;
+ case LBL_MODIFIED:
+ o->modification_time = (time_t) parse_integer(value);
+ break;
+ case LBL_LMOD:
+ db[i].lastmod = NULL;
+ set_lmod(i, value);
+ break;
+ case LBL_ATTRS:
+ {
+ int attrcount = parse_integer(value);
+ db_read_attrs(f, i, attrcount);
+ }
+ break;
+ case LBL_ERROR:
+ default:
+ do_rawlog(LT_ERR, T("Unrecognized field '%s' in object #%d"),
+ label, i);
+ return -1;
+ }
+ }
+ if (IsPlayer(i) && (strlen(o->name) > (size_t) PLAYER_NAME_LIMIT)) {
+ char buff[BUFFER_LEN + 1]; /* The name plus a NUL */
+ strncpy(buff, o->name, PLAYER_NAME_LIMIT);
+ buff[PLAYER_NAME_LIMIT] = '\0';
+ set_name(i, buff);
+ do_rawlog(LT_CHECK,
+ T
+ (" * Name of #%d is longer than the maximum, truncating.\n"),
+ i);
+ } else if (!IsPlayer(i) && (strlen(o->name) > OBJECT_NAME_LIMIT)) {
+ char buff[OBJECT_NAME_LIMIT + 1]; /* The name plus a NUL */
+ strncpy(buff, o->name, OBJECT_NAME_LIMIT);
+ buff[OBJECT_NAME_LIMIT] = '\0';
+ set_name(i, buff);
+ do_rawlog(LT_CHECK,
+ T
+ (" * Name of #%d is longer than the maximum, truncating.\n"),
+ i);
+ }
+ if (IsPlayer(i)) {
+ add_player(i);
+ clear_flag_internal(i, "CONNECTED");
+ }
}
break;
case '*':
{
- char buff[80];
- ungetc('*', f);
- fgets(buff, sizeof buff, f);
- if (strcmp(buff, EOD) != 0) {
- do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1);
- return -1;
- } else {
- loading_db = 0;
- log_mem_check();
- fix_free_list();
- dbck();
- log_mem_check();
- do_rawlog(LT_ERR, "READING: done");
- return db_top;
- }
+ char buff[80];
+ ungetc('*', f);
+ fgets(buff, sizeof buff, f);
+ if (strcmp(buff, EOD) != 0) {
+ do_rawlog(LT_ERR, T("ERROR: No end of dump after object #%d"), i - 1);
+ return -1;
+ } else {
+ loading_db = 0;
+ log_mem_check();
+ fix_free_list();
+ dbck();
+ log_mem_check();
+ do_rawlog(LT_ERR, "READING: done");
+ return db_top;
+ }
}
default:
do_rawlog(LT_ERR, T("ERROR: failed object %d"), i);
void init_postconvert() {
dbref master_division, i;
- if((!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) && CreTime(0) != globals.first_start_time ) {
- do_rawlog(LT_ERR, "Beginning Pennmush to CobraMUSH database conversion process.");
- /* Final Step of DB Conversion
- * We're gonna first Create the Master Division
- * Second we're gonna loop through the database
- * set all players except unregistered players to the master division
- * and set all levels appropriate
- **/
- i = GOD;
- master_division = new_object();
- set_name(master_division, "Master Division");
- Type(master_division) = TYPE_DIVISION;
- PUSH(master_division, Contents(i));
- Owner(master_division) = i;
- CreTime(master_division) = ModTime(master_division) = mudtime;
- Location(master_division) = i;
- atr_new_add(master_division, "DESCRIBE",
- "This is the master division that comes before all divisions.", i,
- AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
- current_state.divisions++;
- SLEVEL(master_division) = LEVEL_DIRECTOR;
- SLEVEL(i) = LEVEL_GOD;
- /* Division & God Setup now run through the database & set everyitng else up */
- for(i = 0; i < db_top; i++)
- {
- if(IsGarbage(i))
- continue;
- if(has_flag_by_name(i, "UNREGISTERED", TYPE_PLAYER)){
- SLEVEL(i) = LEVEL_UNREGISTERED;
- clear_flag_internal(i, "UNREGISTERED");
- } else if(i != master_division) {
- SDIV(i).object = master_division;
- if(!has_flag_by_name(i, "WIZARD", NOTYPE) &&
- !has_flag_by_name(i, "ROYALTY", NOTYPE) && SLEVEL(i) != -500) {
- SLEVEL(i) = LEVEL_PLAYER;
- } else if(SLEVEL(i) == -500) {
- SLEVEL(i) = LEVEL_GUEST;
- } else if(has_flag_by_name(i, "WIZARD", NOTYPE)) { /* They look like wizard or royalty.. Set 'em up right */
- SLEVEL(i) = LEVEL_DIRECTOR;
- powergroup_db_set(GOD, i, "WIZARD", 1);
- } else if(has_flag_by_name(i, "ROYALTY", NOTYPE)) {
- SLEVEL(i) = LEVEL_ADMIN;
- powergroup_db_set(GOD, i, "ROYALTY", 1);
- }
- }
- }
- do_rawlog(LT_ERR, T("DB Conversion complete"));
- }
+ if((!(indb_flags & DBF_DIVISIONS) || (indb_flags & DBF_TYPE_GARBAGE)) && CreTime(0) != globals.first_start_time ) {
+ do_rawlog(LT_ERR, "Beginning Pennmush to CobraMUSH database conversion process.");
+ /* Final Step of DB Conversion
+ * We're gonna first Create the Master Division
+ * Second we're gonna loop through the database
+ * set all players except unregistered players to the master division
+ * and set all levels appropriate
+ **/
+ i = GOD;
+ master_division = new_object();
+ set_name(master_division, "Master Division");
+ Type(master_division) = TYPE_DIVISION;
+ PUSH(master_division, Contents(i));
+ Owner(master_division) = i;
+ CreTime(master_division) = ModTime(master_division) = mudtime;
+ Location(master_division) = i;
+ atr_new_add(master_division, "DESCRIBE",
+ "This is the master division that comes before all divisions.", i,
+ AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
+ current_state.divisions++;
+ SLEVEL(master_division) = LEVEL_DIRECTOR;
+ SLEVEL(i) = LEVEL_GOD;
+ /* Division & God Setup now run through the database & set everyitng else up */
+ for(i = 0; i < db_top; i++)
+ {
+ if(IsGarbage(i))
+ continue;
+ if(has_flag_by_name(i, "UNREGISTERED", TYPE_PLAYER)){
+ SLEVEL(i) = LEVEL_UNREGISTERED;
+ clear_flag_internal(i, "UNREGISTERED");
+ } else if(i != master_division) {
+ SDIV(i).object = master_division;
+ if(!has_flag_by_name(i, "WIZARD", NOTYPE) &&
+ !has_flag_by_name(i, "ROYALTY", NOTYPE) && SLEVEL(i) != -500) {
+ SLEVEL(i) = LEVEL_PLAYER;
+ } else if(SLEVEL(i) == -500) {
+ SLEVEL(i) = LEVEL_GUEST;
+ } else if(has_flag_by_name(i, "WIZARD", NOTYPE)) { /* They look like wizard or royalty.. Set 'em up right */
+ SLEVEL(i) = LEVEL_DIRECTOR;
+ powergroup_db_set(GOD, i, "WIZARD", 1);
+ } else if(has_flag_by_name(i, "ROYALTY", NOTYPE)) {
+ SLEVEL(i) = LEVEL_ADMIN;
+ powergroup_db_set(GOD, i, "ROYALTY", 1);
+ }
+ }
+ }
+ do_rawlog(LT_ERR, T("DB Conversion complete"));
+ }
}
int desc_flags = AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH;
- start_room = new_object(); /* #0 */
- god = new_object(); /* #1 */
- master_room = new_object(); /* #2 */
+ start_room = new_object(); /* #0 */
+ god = new_object(); /* #1 */
+ master_room = new_object(); /* #2 */
master_division = new_object(); /* #3 */
init_objdata_htab(DB_INITIAL_SIZE);
Type(start_room) = TYPE_ROOM;
Flags(start_room) = string_to_bits("FLAG", "LINK_OK");
atr_new_add(start_room, "DESCRIBE", "You are in Room Zero.", GOD, desc_flags,
- 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
+ 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
CreTime(start_room) = ModTime(start_room) = mudtime;
current_state.rooms++;
Owner(master_room) = god;
CreTime(master_room) = ModTime(master_room) = mudtime;
atr_new_add(master_room, "DESCRIBE",
- "This is the master room. Any exit in here is considered global. The same is true for objects with $-commands placed here.",
- god, desc_flags, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
+ "This is the master room. Any exit in here is considered global. The same is true for objects with $-commands placed here.",
+ god, desc_flags, 1, TRUE_BOOLEXP, TRUE_BOOLEXP, mudtime);
current_state.rooms++;
/* Master Division */
Location(master_division) = god;
*/
if (!controls(player, thing) &&
!(IsExit(thing) &&
- (controls(player, Destination(thing)) ||
- controls(player, Source(thing)))) &&
+ (controls(player, Destination(thing)) ||
+ controls(player, Source(thing)))) &&
!(DestOk(thing) && eval_lock(player, thing, Destroy_Lock))) {
notify(player, T("Permission denied."));
return NOTHING;
if (REALLY_SAFE) {
if (Safe(thing) && !DestOk(thing)) {
notify(player,
- T
- ("That object is set SAFE. You must set it !SAFE before destroying it."));
+ T
+ ("That object is set SAFE. You must set it !SAFE before destroying it."));
return NOTHING;
}
- } else { /* REALLY_SAFE */
+ } else { /* REALLY_SAFE */
if (Safe(thing) && !DestOk(thing) && !confirm) {
notify(player, T("That object is marked SAFE. Use @nuke to destroy it."));
return NOTHING;
/* check to make sure there's no accidental destruction */
if (!confirm && !Owns(player, thing) && !DestOk(thing)) {
notify(player,
- T("That object does not belong to you. Use @nuke to destroy it."));
+ T("That object does not belong to you. Use @nuke to destroy it."));
return NOTHING;
}
/* what kind of thing we are destroying? */
}
if (Connected(thing)) {
notify(player,
- T("How gruesome. You may not destroy players who are connected."));
+ T("How gruesome. You may not destroy players who are connected."));
return NOTHING;
}
if (!confirm) {
/* Present informative messages. */
if (!REALLY_SAFE && Safe(thing))
notify(player,
- T
- ("Warning: Target is set SAFE, but scheduling for destruction anyway."));
+ T
+ ("Warning: Target is set SAFE, but scheduling for destruction anyway."));
switch (Typeof(thing)) {
case TYPE_ROOM:
/* wait until dbck */
notify_except(Contents(thing), NOTHING,
- T("The room shakes and begins to crumble."), 0);
+ T("The room shakes and begins to crumble."), 0);
if (Owns(player, thing))
notify_format(player,
- T("You will be rewarded shortly for %s."),
- object_header(player, thing));
+ T("You will be rewarded shortly for %s."),
+ object_header(player, thing));
else {
notify_format(player,
- T
- ("The wrecking ball is on its way for %s's %s and its exits."),
- Name(Owner(thing)), object_header(player, thing));
+ T
+ ("The wrecking ball is on its way for %s's %s and its exits."),
+ Name(Owner(thing)), object_header(player, thing));
notify_format(Owner(thing),
- T("%s has scheduled your room %s to be destroyed."),
- Name(player), object_header(Owner(thing), thing));
+ T("%s has scheduled your room %s to be destroyed."),
+ Name(player), object_header(Owner(thing), thing));
}
break;
case TYPE_PLAYER:
/* wait until dbck */
notify_format(player,
- (DESTROY_POSSESSIONS ?
- (REALLY_SAFE ?
- T
- ("%s and all their (non-SAFE) objects are scheduled to be destroyed.")
- :
- T
- ("%s and all their objects are scheduled to be destroyed."))
- : T("%s is scheduled to be destroyed.")),
- object_header(player, thing));
+ (DESTROY_POSSESSIONS ?
+ (REALLY_SAFE ?
+ T
+ ("%s and all their (non-SAFE) objects are scheduled to be destroyed.")
+ :
+ T
+ ("%s and all their objects are scheduled to be destroyed."))
+ : T("%s is scheduled to be destroyed.")),
+ object_header(player, thing));
break;
case TYPE_DIVISION:
do_log(LT_WIZ, player, thing, "Division object scheduled for destruction.");
case TYPE_THING:
if (!Owns(player, thing)) {
notify_format(player, T("%s's %s is scheduled to be destroyed."),
- Name(Owner(thing)), object_header(player, thing));
+ Name(Owner(thing)), object_header(player, thing));
if (!DestOk(thing))
- notify_format(Owner(thing),
- T("%s has scheduled your %s for destruction."),
- Name(player), object_header(Owner(thing), thing));
+ notify_format(Owner(thing),
+ T("%s has scheduled your %s for destruction."),
+ Name(player), object_header(Owner(thing), thing));
} else {
notify_format(player, T("%s is scheduled to be destroyed."),
- object_header(player, thing));
+ object_header(player, thing));
}
break;
case TYPE_EXIT:
if (!Owns(player, thing)) {
notify_format(Owner(thing),
- T("%s has scheduled your %s for destruction."),
- Name(player), object_header(Owner(thing), thing));
+ T("%s has scheduled your %s for destruction."),
+ Name(player), object_header(Owner(thing), thing));
notify_format(player,
- T("%s's %s is scheduled to be destroyed."),
- Name(Owner(thing)), object_header(player, thing));
+ T("%s's %s is scheduled to be destroyed."),
+ Name(Owner(thing)), object_header(player, thing));
} else
notify_format(player,
- T("%s is scheduled to be destroyed."),
- object_header(player, thing));
+ T("%s is scheduled to be destroyed."),
+ object_header(player, thing));
break;
default:
do_log(LT_ERR, NOTHING, NOTHING, T("Surprising type in do_destroy."));
do_log(LT_WIZ, player, thing, "Division object destruction canceled.");
notify_format(Owner(thing),
- T("Your %s has been spared from destruction."),
- object_header(Owner(thing), thing));
+ T("Your %s has been spared from destruction."),
+ object_header(Owner(thing), thing));
if (player != Owner(thing)) {
notify_format(player,
- T("%s's %s has been spared from destruction."),
- Name(Owner(thing)), object_header(player, thing));
+ T("%s's %s has been spared from destruction."),
+ Name(Owner(thing)), object_header(player, thing));
}
} else {
- notify(player, T("That can't be undestroyed."));
+ notify(player, T("That can't be undestroyed."));
}
}
case TYPE_PLAYER:
if (DESTROY_POSSESSIONS) {
for (tmp = 0; tmp < db_top; tmp++) {
- if (Owner(tmp) == thing &&
- (tmp != thing) && (!REALLY_SAFE || !Safe(thing))) {
- pre_destroy(player, tmp);
- }
+ if (Owner(tmp) == thing &&
+ (tmp != thing) && (!REALLY_SAFE || !Safe(thing))) {
+ pre_destroy(player, tmp);
+ }
}
}
break;
* whose owner hasn't already been notified. */
if ((Owner(thing) != Owner(Source(thing))) && Going(Source(thing))) {
if (!Owns(player, thing)) {
- notify_format(Owner(thing),
- T("%s has scheduled your %s for destruction."),
- Name(player), object_header(Owner(thing), thing));
+ notify_format(Owner(thing),
+ T("%s has scheduled your %s for destruction."),
+ Name(player), object_header(Owner(thing), thing));
}
}
break;
if (Going(Owner(thing))) {
if (Owner(thing) != player) {
notify_format(player,
- T("%s has been spared from destruction."),
- object_header(player, Owner(thing)));
+ T("%s has been spared from destruction."),
+ object_header(player, Owner(thing)));
notify_format(Owner(thing),
- T("You have been spared from destruction by %s."),
- Name(player));
+ T("You have been spared from destruction by %s."),
+ Name(player));
} else {
notify(player, T("You have been spared from destruction."));
}
* be purged when the room is purged.
*/
for (tmp = 0; tmp < db_top; tmp++) {
- if (Owns(thing, tmp) &&
- (tmp != thing) &&
- !(IsExit(tmp) && !Owns(thing, Source(tmp)) && Going(Source(tmp)))) {
- (void) undestroy(player, tmp);
- }
+ if (Owns(thing, tmp) &&
+ (tmp != thing) &&
+ !(IsExit(tmp) && !Owns(thing, Source(tmp)) && Going(Source(tmp)))) {
+ (void) undestroy(player, tmp);
+ }
}
break;
case TYPE_DIVISION:
if (Going(Source(thing))) {
(void) undestroy(player, Source(thing));
notify_format(player,
- T("The room %s has been spared from destruction."),
- object_header(player, Source(thing)));
+ T("The room %s has been spared from destruction."),
+ object_header(player, Source(thing)));
if (Owner(Source(thing)) != player) {
- notify_format(Owner(Source(thing)),
- T("The room %s has been spared from destruction by %s."),
- object_header(Owner(Source(thing)), Source(thing)),
- Name(player));
+ notify_format(Owner(Source(thing)),
+ T("The room %s has been spared from destruction by %s."),
+ object_header(Owner(Source(thing)), Source(thing)),
+ Name(player));
}
}
break;
*/
DOLIST(tmp, Exits(thing)) {
if (DESTROY_POSSESSIONS ? (!Going(Owner(tmp)) || Safe(tmp)) : 1) {
- (void) undestroy(player, tmp);
+ (void) undestroy(player, tmp);
}
}
break;
break;
default:
do_log(LT_ERR, NOTHING, NOTHING, T("Unknown type on #%d in free_object."),
- thing);
+ thing);
return;
}
case TYPE_DIVISION:
case TYPE_PLAYER:
case TYPE_THING:
- Home(i) = DEFAULT_HOME;
- break;
+ Home(i) = DEFAULT_HOME;
+ break;
case TYPE_EXIT:
- /* Huh. An exit that claims to be from here, but wasn't linked
- * in properly. */
- do_rawlog(LT_ERR,
- T("ERROR: Exit %s leading from invalid room #%d destroyed."),
- unparse_object(GOD, i), thing);
- free_object(i);
- break;
+ /* Huh. An exit that claims to be from here, but wasn't linked
+ * in properly. */
+ do_rawlog(LT_ERR,
+ T("ERROR: Exit %s leading from invalid room #%d destroyed."),
+ unparse_object(GOD, i), thing);
+ free_object(i);
+ break;
case TYPE_ROOM:
- /* Hrm. It claims we're an exit from it, but we didn't agree.
- * Clean it up anyway. */
- do_log(LT_ERR, NOTHING, NOTHING,
- T("Found a destroyed exit #%d in room #%d"), thing, i);
- break;
+ /* Hrm. It claims we're an exit from it, but we didn't agree.
+ * Clean it up anyway. */
+ do_log(LT_ERR, NOTHING, NOTHING,
+ T("Found a destroyed exit #%d in room #%d"), thing, i);
+ break;
}
}
/* The location check MUST be done AFTER the home check. */
case TYPE_DIVISION:
case TYPE_PLAYER:
case TYPE_THING:
- /* Huh. It thought it was here, but we didn't agree. */
- enter_room(i, Home(i), 0);
- break;
+ /* Huh. It thought it was here, but we didn't agree. */
+ enter_room(i, Home(i), 0);
+ break;
case TYPE_EXIT:
- /* If our destination is destroyed, then we relink to the
- * source room (so that the exit can't be stolen). Yes, it's
- * inconsistent with the treatment of exits leading from
- * destroyed rooms, but it's a lot better than turning exits
- * into nasty limbo exits.
- */
- Destination(i) = Source(i);
- break;
+ /* If our destination is destroyed, then we relink to the
+ * source room (so that the exit can't be stolen). Yes, it's
+ * inconsistent with the treatment of exits leading from
+ * destroyed rooms, but it's a lot better than turning exits
+ * into nasty limbo exits.
+ */
+ Destination(i) = Source(i);
+ break;
case TYPE_ROOM:
- /* Just remove a dropto. */
- Location(i) = NOTHING;
- break;
+ /* Just remove a dropto. */
+ Location(i) = NOTHING;
+ break;
}
}
if (Next(i) == thing) {
else
current_state.players--;
break;
- case TYPE_EXIT: /* This probably won't be needed, but lets make sure */
+ case TYPE_EXIT: /* This probably won't be needed, but lets make sure */
loc = Source(thing);
if (GoodObject(loc))
Exits(loc) = remove_first(Exits(loc), thing);
set_name(thing, "Garbage");
Exits(thing) = NOTHING;
Home(thing) = NOTHING;
- CreTime(thing) = 0; /* Prevents it from matching objids */
+ CreTime(thing) = 0; /* Prevents it from matching objids */
set_lmod(thing, NULL);
clear_objdata(thing);
dbref rest;
dbref target;
notify_except(Contents(thing), NOTHING,
- T
- ("The floor disappears under your feet, you fall through NOTHINGness and then:"),
- 0);
+ T
+ ("The floor disappears under your feet, you fall through NOTHINGness and then:"),
+ 0);
first = Contents(thing);
Contents(thing) = NOTHING;
/* send all objects to nowhere */
rest = Next(first);
/* if home is in thing set it to limbo */
switch (Typeof(first)) {
- case TYPE_EXIT: /* if holding exits, destroy it */
+ case TYPE_EXIT: /* if holding exits, destroy it */
free_object(first);
break;
- case TYPE_THING: /* move to home */
+ case TYPE_THING: /* move to home */
case TYPE_PLAYER:
/* Make sure the home is a reasonable object. */
if (!GoodObject(Home(first)) || IsExit(Home(first)) ||
- Home(first) == thing)
- Home(first) = DEFAULT_HOME;
+ Home(first) == thing)
+ Home(first) = DEFAULT_HOME;
target = Home(first);
/* If home isn't a good place to send it, send it to DEFAULT_HOME. */
if (!GoodObject(target) || recursive_member(target, first, 0))
- target = DEFAULT_HOME;
+ target = DEFAULT_HOME;
if (target != NOTHING) {
- /* Use enter_room() on everything so that AENTER and such
- * are all triggered properly. */
- enter_room(first, target, 0);
+ /* Use enter_room() on everything so that AENTER and such
+ * are all triggered properly. */
+ enter_room(first, target, 0);
}
break;
}
clear_flag_internal(thing, "PUPPET");
if (!Quiet(thing) && !Quiet(Owner(thing)))
notify_format(Owner(thing),
- T("You get your %d %s deposit back for %s."),
- a, ((a == 1) ? MONEY : MONIES),
- object_header(Owner(thing), thing));
+ T("You get your %d %s deposit back for %s."),
+ a, ((a == 1) ? MONEY : MONIES),
+ object_header(Owner(thing), thing));
}
static void
for (i = 0; i < db_top; i++) {
if (Owner(i) == thing && i != thing) {
if (DESTROY_POSSESSIONS ? (REALLY_SAFE ? Safe(i) : 0) : 1) {
- chown_object(GOD, i, GOD, 0);
+ chown_object(GOD, i, GOD, 0);
} else {
- free_object(i);
+ free_object(i);
}
}
}
continue;
} else if (Going(thing)) {
if (Going_Twice(thing)) {
- free_object(thing);
+ free_object(thing);
} else {
- set_flag_internal(thing, "GOING_TWICE");
+ set_flag_internal(thing, "GOING_TWICE");
}
} else {
continue;
for(i = 0; i < db_top ; i++)
if(IsDivision(i)) {
/* first, let's do some smart division setting. if it's not set.
- * Just incase some weird corruption hits us
- */
+ * Just incase some weird corruption hits us
+ */
if(Division(i) == -1 && IsDivision(i) && IsDivision(Location(i))) {
- do_rawlog(LT_ERR, T("Auto-Divisioning #%d to #%d"), i, Location(i));
- Division(i) = Location(i);
- Parent(i) = Location(i);
+ do_rawlog(LT_ERR, T("Auto-Divisioning #%d to #%d"), i, Location(i));
+ Division(i) = Location(i);
+ Parent(i) = Location(i);
}
/* make sure their division is a valid object */
if((!GoodObject(Division(i)) && Division(i) != NOTHING)
- || (GoodObject(Division(i)) && IsGarbage(Division(i)))) {
- Division(i) = NOTHING;
- do_rawlog(LT_ERR, T("ERROR: Bad Division(#%d) set on object #%d"),
- Division(i), i);
+ || (GoodObject(Division(i)) && IsGarbage(Division(i)))) {
+ Division(i) = NOTHING;
+ do_rawlog(LT_ERR, T("ERROR: Bad Division(#%d) set on object #%d"),
+ Division(i), i);
}
/* check for division loops */
unsigned j;
for(tmp = Division(i), j = 0; GoodObject(tmp) && j < MAX_DIVISION_DEPTH;
- tmp = Division(tmp), j++) {
+ tmp = Division(tmp), j++) {
if(tmp == i) {
do_rawlog(LT_ERR, T("ERROR: Division loop detected at #%d"), i);
Division(i) = NOTHING;
/* now check parent tree */
if(Division(i) != -1)
- Parent(i) = Division(i);
+ Parent(i) = Division(i);
else
- for(n = 0, check = i; n < MAX_PARENTS && check != NOTHING; n++, check = Parent(check))
- if(IsDivision(Parent(check))) {
- do_rawlog(LT_ERR, T("ERROR: Bad Division Parent Structure."));
- Parent(check) = NOTHING;
- }
+ for(n = 0, check = i; n < MAX_PARENTS && check != NOTHING; n++, check = Parent(check))
+ if(IsDivision(Parent(check))) {
+ do_rawlog(LT_ERR, T("ERROR: Bad Division Parent Structure."));
+ Parent(check) = NOTHING;
+ }
}
}
dbref next;
next = Next(thing);
if ((!GoodObject(next) || !IsGarbage(next)) && (next != NOTHING)) {
- do_rawlog(LT_ERR, T("ERROR: Invalid next pointer #%d from object %s"),
- next, unparse_object(GOD, thing));
- Next(thing) = NOTHING;
- fix_free_list();
+ do_rawlog(LT_ERR, T("ERROR: Invalid next pointer #%d from object %s"),
+ next, unparse_object(GOD, thing));
+ Next(thing) = NOTHING;
+ fix_free_list();
}
continue;
} else {
dbref zone, loc, parent, home, owner, next;
zone = Zone(thing);
if (GoodObject(zone) && IsGarbage(zone))
- Zone(thing) = NOTHING;
+ Zone(thing) = NOTHING;
parent = Parent(thing);
if (GoodObject(parent) && IsGarbage(parent))
- Parent(thing) = NOTHING;
+ Parent(thing) = NOTHING;
owner = Owner(thing);
if (!GoodObject(owner) || IsGarbage(owner) || !IsPlayer(owner)) {
- do_rawlog(LT_ERR, T("ERROR: Invalid object owner on %s(%d)"),
- Name(thing), thing);
- report();
- Owner(thing) = GOD;
+ do_rawlog(LT_ERR, T("ERROR: Invalid object owner on %s(%d)"),
+ Name(thing), thing);
+ report();
+ Owner(thing) = GOD;
}
next = Next(thing);
if ((!GoodObject(next) || IsGarbage(next)) && (next != NOTHING)) {
- do_rawlog(LT_ERR, T("ERROR: Invalid next pointer #%d from object %s"),
- next, unparse_object(GOD, thing));
- Next(thing) = NOTHING;
+ do_rawlog(LT_ERR, T("ERROR: Invalid next pointer #%d from object %s"),
+ next, unparse_object(GOD, thing));
+ Next(thing) = NOTHING;
}
if((next == thing)) /* its saying itself is next? */
- Next(thing) = NOTHING;
+ Next(thing) = NOTHING;
/* This next bit has to be type-specific because of different uses
* of the home and location fields.
*/
case TYPE_DIVISION:
case TYPE_PLAYER:
case TYPE_THING:
- if (!GoodObject(home) || IsGarbage(home) || IsExit(home))
- Home(thing) = DEFAULT_HOME;
- if (!GoodObject(loc) || IsGarbage(loc) || IsExit(loc))
- enter_room(thing, Home(thing), 0);
- break;
+ if (!GoodObject(home) || IsGarbage(home) || IsExit(home))
+ Home(thing) = DEFAULT_HOME;
+ if (!GoodObject(loc) || IsGarbage(loc) || IsExit(loc))
+ enter_room(thing, Home(thing), 0);
+ break;
case TYPE_EXIT:
- if (Contents(thing) != NOTHING) {
- /* Eww.. Exits can't have contents. Bad news */
- Contents(thing) = NOTHING;
- do_rawlog(LT_ERR,
- T("ERROR: Exit %s has a contents list. Wiping it out."),
- unparse_object(GOD, thing));
- }
- if (!GoodObject(loc)
- && !((loc == NOTHING) || (loc == AMBIGUOUS) || (loc == HOME))) {
- /* Bad news. We're linked to a really impossible object.
- * Relink to our source
- */
- Destination(thing) = Source(thing);
- do_rawlog(LT_ERR,
- T
- ("ERROR: Exit %s leading to invalid room #%d relinked to its source room."),
- unparse_object(GOD, thing), home);
- } else if (GoodObject(loc) && IsGarbage(loc)) {
- /* If our destination is destroyed, then we relink to the
- * source room (so that the exit can't be stolen). Yes, it's
- * inconsistent with the treatment of exits leading from
- * destroyed rooms, but it's a lot better than turning exits
- * into nasty limbo exits.
- */
- Destination(thing) = Source(thing);
- do_rawlog(LT_ERR,
- T
- ("ERROR: Exit %s leading to garbage room #%d relinked to its source room."),
- unparse_object(GOD, thing), home);
- }
- /* This must come last */
- if (!GoodObject(home) || !IsRoom(home)) {
- /* If our source is destroyed, just destroy the exit. */
- do_rawlog(LT_ERR,
- T
- ("ERROR: Exit %s leading from invalid room #%d destroyed."),
- unparse_object(GOD, thing), home);
- free_object(thing);
- }
- break;
+ if (Contents(thing) != NOTHING) {
+ /* Eww.. Exits can't have contents. Bad news */
+ Contents(thing) = NOTHING;
+ do_rawlog(LT_ERR,
+ T("ERROR: Exit %s has a contents list. Wiping it out."),
+ unparse_object(GOD, thing));
+ }
+ if (!GoodObject(loc)
+ && !((loc == NOTHING) || (loc == AMBIGUOUS) || (loc == HOME))) {
+ /* Bad news. We're linked to a really impossible object.
+ * Relink to our source
+ */
+ Destination(thing) = Source(thing);
+ do_rawlog(LT_ERR,
+ T
+ ("ERROR: Exit %s leading to invalid room #%d relinked to its source room."),
+ unparse_object(GOD, thing), home);
+ } else if (GoodObject(loc) && IsGarbage(loc)) {
+ /* If our destination is destroyed, then we relink to the
+ * source room (so that the exit can't be stolen). Yes, it's
+ * inconsistent with the treatment of exits leading from
+ * destroyed rooms, but it's a lot better than turning exits
+ * into nasty limbo exits.
+ */
+ Destination(thing) = Source(thing);
+ do_rawlog(LT_ERR,
+ T
+ ("ERROR: Exit %s leading to garbage room #%d relinked to its source room."),
+ unparse_object(GOD, thing), home);
+ }
+ /* This must come last */
+ if (!GoodObject(home) || !IsRoom(home)) {
+ /* If our source is destroyed, just destroy the exit. */
+ do_rawlog(LT_ERR,
+ T
+ ("ERROR: Exit %s leading from invalid room #%d destroyed."),
+ unparse_object(GOD, thing), home);
+ free_object(thing);
+ }
+ break;
case TYPE_ROOM:
- if (GoodObject(home) && IsGarbage(home)) {
- /* Eww. Destroyed exit. This isn't supposed to happen. */
- do_log(LT_ERR, NOTHING, NOTHING,
- T("Found a destroyed exit #%d in room #%d"), home, thing);
- }
- if (GoodObject(loc) && (IsGarbage(loc) || IsExit(loc))) {
- /* Just remove a dropto. */
- Location(thing) = NOTHING;
- }
- break;
+ if (GoodObject(home) && IsGarbage(home)) {
+ /* Eww. Destroyed exit. This isn't supposed to happen. */
+ do_log(LT_ERR, NOTHING, NOTHING,
+ T("Found a destroyed exit #%d in room #%d"), home, thing);
+ }
+ if (GoodObject(loc) && (IsGarbage(loc) || IsExit(loc))) {
+ /* Just remove a dropto. */
+ Location(thing) = NOTHING;
+ }
+ break;
}
/* Check if this guy isn't in a division, if he's not.. Then we need fix their level & zap
* powers
*/
if(!IsDivision(thing) && !IsDivision(Division(thing))) {
- if(LEVEL(thing) > LEVEL_UNREGISTERED) {
- do_log(LT_ERR, NOTHING, NOTHING, T("Found' #%d' at Level '%d' without a valid division, setting to Unregistered level '%d'"),
- thing, LEVEL(thing), LEVEL_UNREGISTERED);
- SLEVEL(thing) = LEVEL_UNREGISTERED;
- }
- if(!!DPBITS(thing)) { /* Zap powers */
- do_log(LT_ERR, NOTHING, NOTHING, T("Found '#%d' with no division and powers set, removing."), thing);
- mush_free(DPBITS(thing), "POWER_SPOT");
- DPBITS(thing) = NULL;
- }
+ if(LEVEL(thing) > LEVEL_UNREGISTERED) {
+ do_log(LT_ERR, NOTHING, NOTHING, T("Found' #%d' at Level '%d' without a valid division, setting to Unregistered level '%d'"),
+ thing, LEVEL(thing), LEVEL_UNREGISTERED);
+ SLEVEL(thing) = LEVEL_UNREGISTERED;
+ }
+ if(!!DPBITS(thing)) { /* Zap powers */
+ do_log(LT_ERR, NOTHING, NOTHING, T("Found '#%d' with no division and powers set, removing."), thing);
+ mush_free(DPBITS(thing), "POWER_SPOT");
+ DPBITS(thing) = NULL;
+ }
}
/* Zap power allocation if they don't have any */
if(!!DPBITS(thing) && (power_is_zero(DPBITS(thing), DP_BYTES) == 0)) {
- mush_free(DPBITS(thing), "POWER_SPOT");
+ mush_free(DPBITS(thing), "POWER_SPOT");
DPBITS(thing) = NULL;
}
/* Check attribute ownership. If the attribute is owned by
* an invalid dbref, change its ownership to powerless.
*/
if (!IsGarbage(thing))
- atr_iter_get(options.powerless, thing, "**", 0, attribute_owner_helper, NULL);
+ atr_iter_get(options.powerless, thing, "**", 0, attribute_owner_helper, NULL);
}
}
}
static int
attribute_owner_helper(dbref player __attribute__ ((__unused__)),
- dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *atr, void *args
- __attribute__ ((__unused__)))
+ dbref thing __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *atr, void *args
+ __attribute__ ((__unused__)))
{
if (!GoodObject(AL_CREATOR(atr)))
AL_CREATOR(atr) = options.powerless; /* set to a powerless object so twinchecks don't backfire */
ClearMarked(loc);
else if (IsRoom(loc)) {
if (!Name(loc)) {
- do_log(LT_ERR, NOTHING, NOTHING, T("ERROR: no name for room #%d."),
- loc);
- set_name(loc, "XXXX");
+ do_log(LT_ERR, NOTHING, NOTHING, T("ERROR: no name for room #%d."),
+ loc);
+ set_name(loc, "XXXX");
}
if (!Going(loc) && !Floating(loc) && !NoWarnable(loc) &&
- (!EXITS_CONNECT_ROOMS || (Exits(loc) == NOTHING))) {
- notify_format(Owner(loc), T("You own a disconnected room, %s"),
- object_header(Owner(loc), loc));
+ (!EXITS_CONNECT_ROOMS || (Exits(loc) == NOTHING))) {
+ notify_format(Owner(loc), T("You own a disconnected room, %s"),
+ object_header(Owner(loc), loc));
}
}
}
continue;
if (ZONE_CONTROL_ZMP && !IsPlayer(zone))
continue;
- if (zone != n) /* Objects can be zoned to themselves */
+ if (zone != n) /* Objects can be zoned to themselves */
for (tmp = Zone(zone); GoodObject(tmp); tmp = Zone(tmp)) {
- if (tmp == n) {
- notify_format(Owner(n),
- T("You own an object in a circular zone chain: %s"),
- object_header(Owner(n), n));
- break;
- }
- if (tmp == Zone(tmp)) /* Object zoned to itself */
- break;
+ if (tmp == n) {
+ notify_format(Owner(n),
+ T("You own an object in a circular zone chain: %s"),
+ object_header(Owner(n), n));
+ break;
+ }
+ if (tmp == Zone(tmp)) /* Object zoned to itself */
+ break;
}
if (Marked(zone))
if (!IsGarbage(n) && Marked(n)) {
ClearMarked(n);
notify_format(Owner(n),
- T
- ("You own an object without a @lock/zone being used as a zone: %s"),
- object_header(Owner(n), n));
+ T
+ ("You own an object without a @lock/zone being used as a zone: %s"),
+ object_header(Owner(n), n));
}
}
}
break;
default:
do_rawlog(LT_ERR, T("Bad object type found for %s in mark_contents"),
- unparse_object(GOD, thing));
+ unparse_object(GOD, thing));
break;
}
}
for (thing = 0; thing < db_top; thing++) {
if (!IsRoom(thing) && !IsGarbage(thing) && !Marked(thing)) {
do_rawlog(LT_ERR, T("Object %s not pointed to by anything."),
- unparse_object(GOD, thing));
+ unparse_object(GOD, thing));
notify_format(Owner(thing),
- T("You own an object %s that was \'orphaned\'."),
- object_header(Owner(thing), thing));
+ T("You own an object %s that was \'orphaned\'."),
+ object_header(Owner(thing), thing));
/* We try to fix this by trying to send players and things to
* their current location, to their home, or to DEFAULT_HOME, in
* that order, and relinking exits to their source.
switch (Typeof(thing)) {
case TYPE_PLAYER:
case TYPE_THING:
- if (GoodObject(Location(thing)) &&
- !IsGarbage(Location(thing)) && Marked(Location(thing))) {
- PUSH(thing, Contents(Location(thing)));
- } else if (GoodObject(Home(thing)) &&
- !IsGarbage(Home(thing)) && Marked(Home(thing))) {
- Contents(Location(thing)) =
- remove_first(Contents(Location(thing)), thing);
- PUSH(thing, Contents(Home(thing)));
- Location(thing) = Home(thing);
- } else {
- Contents(Location(thing)) =
- remove_first(Contents(Location(thing)), thing);
- PUSH(thing, Contents(DEFAULT_HOME));
- Location(thing) = DEFAULT_HOME;
- }
- enter_room(thing, Location(thing), 0);
- /* If we've managed to reconnect it, then we've reconnected
- * its contents. */
- mark_contents(Contents(thing));
- notify_format(Owner(thing), T("It was moved to %s."),
- object_header(Owner(thing), Location(thing)));
- do_rawlog(LT_ERR, T("Moved to %s."),
- unparse_object(GOD, Location(thing)));
- break;
+ if (GoodObject(Location(thing)) &&
+ !IsGarbage(Location(thing)) && Marked(Location(thing))) {
+ PUSH(thing, Contents(Location(thing)));
+ } else if (GoodObject(Home(thing)) &&
+ !IsGarbage(Home(thing)) && Marked(Home(thing))) {
+ Contents(Location(thing)) =
+ remove_first(Contents(Location(thing)), thing);
+ PUSH(thing, Contents(Home(thing)));
+ Location(thing) = Home(thing);
+ } else {
+ Contents(Location(thing)) =
+ remove_first(Contents(Location(thing)), thing);
+ PUSH(thing, Contents(DEFAULT_HOME));
+ Location(thing) = DEFAULT_HOME;
+ }
+ enter_room(thing, Location(thing), 0);
+ /* If we've managed to reconnect it, then we've reconnected
+ * its contents. */
+ mark_contents(Contents(thing));
+ notify_format(Owner(thing), T("It was moved to %s."),
+ object_header(Owner(thing), Location(thing)));
+ do_rawlog(LT_ERR, T("Moved to %s."),
+ unparse_object(GOD, Location(thing)));
+ break;
case TYPE_EXIT:
- if (GoodObject(Source(thing)) && IsRoom(Source(thing))) {
- PUSH(thing, Exits(Source(thing)));
- notify_format(Owner(thing), T("It was moved to %s."),
- object_header(Owner(thing), Source(thing)));
- do_rawlog(LT_ERR, T("Moved to %s."),
- unparse_object(GOD, Source(thing)));
- } else {
- /* Just destroy the exit. */
- Source(thing) = NOTHING;
- notify(Owner(thing), T("It was destroyed."));
- do_rawlog(LT_ERR, T("Orphaned exit destroyed."));
- free_object(thing);
- }
- break;
+ if (GoodObject(Source(thing)) && IsRoom(Source(thing))) {
+ PUSH(thing, Exits(Source(thing)));
+ notify_format(Owner(thing), T("It was moved to %s."),
+ object_header(Owner(thing), Source(thing)));
+ do_rawlog(LT_ERR, T("Moved to %s."),
+ unparse_object(GOD, Source(thing)));
+ } else {
+ /* Just destroy the exit. */
+ Source(thing) = NOTHING;
+ notify(Owner(thing), T("It was destroyed."));
+ do_rawlog(LT_ERR, T("Orphaned exit destroyed."));
+ free_object(thing);
+ }
+ break;
case TYPE_ROOM:
- /* We should never get here. */
- do_log(LT_ERR, NOTHING, NOTHING, T("Disconnected room. So what?"));
- break;
+ /* We should never get here. */
+ do_log(LT_ERR, NOTHING, NOTHING, T("Disconnected room. So what?"));
+ break;
default:
- do_log(LT_ERR, NOTHING, NOTHING,
- T("Surprising type on #%d found in check_cycles."), thing);
- break;
+ do_log(LT_ERR, NOTHING, NOTHING,
+ T("Surprising type on #%d found in check_cycles."), thing);
+ break;
}
}
}
for (loc = 0; loc < db_top; loc++) {
if (!IsExit(loc)) {
for (thing = Contents(loc); thing != NOTHING; thing = Next(thing)) {
- if (!Mobile(thing)) {
- do_rawlog(LT_ERR,
- T
- ("ERROR: Contents of object %d corrupt at object %d cleared"),
- loc, thing);
- /* Remove this from the list and start over. */
- Contents(loc) = remove_first(Contents(loc), thing);
- thing = Contents(loc);
- continue;
- } else if (Location(thing) != loc) {
- /* Well, it would fit here, and it can't be elsewhere because
- * we've done a check_contents already, so let's just put it
- * here.
- */
- do_rawlog(LT_ERR,
- T("Incorrect location on object %s. Reset to #%d."),
- unparse_object(GOD, thing), loc);
- Location(thing) = loc;
- }
- SetMarked(thing);
+ if (!Mobile(thing)) {
+ do_rawlog(LT_ERR,
+ T
+ ("ERROR: Contents of object %d corrupt at object %d cleared"),
+ loc, thing);
+ /* Remove this from the list and start over. */
+ Contents(loc) = remove_first(Contents(loc), thing);
+ thing = Contents(loc);
+ continue;
+ } else if (Location(thing) != loc) {
+ /* Well, it would fit here, and it can't be elsewhere because
+ * we've done a check_contents already, so let's just put it
+ * here.
+ */
+ do_rawlog(LT_ERR,
+ T("Incorrect location on object %s. Reset to #%d."),
+ unparse_object(GOD, thing), loc);
+ Location(thing) = loc;
+ }
+ SetMarked(thing);
}
}
if (IsRoom(loc)) {
for (thing = Exits(loc); thing != NOTHING; thing = Next(thing)) {
- if (!IsExit(thing)) {
- do_rawlog(LT_ERR,
- T("ERROR: Exits of room %d corrupt at object %d cleared"),
- loc, thing);
- /* Remove this from the list and start over. */
- Exits(loc) = remove_first(Exits(loc), thing);
- thing = Exits(loc);
- continue;
- } else if (Source(thing) != loc) {
- do_rawlog(LT_ERR,
- T("Incorrect source on exit %s. Reset to #%d."),
- unparse_object(GOD, thing), loc);
- }
+ if (!IsExit(thing)) {
+ do_rawlog(LT_ERR,
+ T("ERROR: Exits of room %d corrupt at object %d cleared"),
+ loc, thing);
+ /* Remove this from the list and start over. */
+ Exits(loc) = remove_first(Exits(loc), thing);
+ thing = Exits(loc);
+ continue;
+ } else if (Source(thing) != loc) {
+ do_rawlog(LT_ERR,
+ T("Incorrect source on exit %s. Reset to #%d."),
+ unparse_object(GOD, thing), loc);
+ }
}
}
}
/* division.c - RLB 3/11/02
- * Part of the Division system for PennMUSH
- * 4/12/02 - RLB - Rewrite level set, much more readable now =)
- * 4/17/02 - RLB - Code StreamLining
- * 1/18/04 - RLB - began work on power conversion code
- * 1/23/04 - RLB - completed power conversion code
- * 3/26/04 - RLB - Added translation wrappers to messages.
- * 7/27/05 - RLB - DB Powers Completed
+ * Part of the Division system for PennMUSH
+ * 4/12/02 - RLB - Rewrite level set, much more readable now =)
+ * 4/17/02 - RLB - Code StreamLining
+ * 1/18/04 - RLB - began work on power conversion code
+ * 1/23/04 - RLB - completed power conversion code
+ * 3/26/04 - RLB - Added translation wrappers to messages.
+ * 7/27/05 - RLB - DB Powers Completed
*/
/* Required Includes {{{1 */
memset(tbuf, '\0', 128);
strncpy(tbuf, object_header(executor, player), 127);
notify_format(executor, "%s did not have powergroup %s.",
- tbuf, pgrp->name);
+ tbuf, pgrp->name);
continue;
}
/* Remove */
memset(tbuf, '\0', 128);
strncpy(tbuf, object_header(player, executor), 127);
notify_format(player, "%s removed powergroup %s from you.",
- tbuf, pgrp->name);
+ tbuf, pgrp->name);
} else {
if (powergroup_has(player, pgrp)) {
memset(tbuf, '\0', 128);
strncpy(tbuf, object_header(executor, player), 127);
notify_format(executor, "%s already has powergroup %s.",
- tbuf, pgrp->name);
+ tbuf, pgrp->name);
continue;
}
/* Add */
* @powergroup/auto <powergroup>=<power> - Assign a power as an autoset for the powergroup
* @powergroup/max <powergroup>=<power> - Assign a power to the maxset for the powergroup
* @powergroup/list - List all available powergroups
- * @powergroup/list <player> - List powergroups set on a object
+ * @powergroup/list <player> - List powergroups set on a object
* @powergroup/raw <user>=<powergroup> - Assign a powergroup to a user without assigning auto powers
*
*/
* pow_lev-> powerscope level
* Return Values: 1->Yes,
* No Vals: 0 -> Giver doesn't have it
- * -1 -> Giver power conflict in lowering pow_lev
- * -2 -> Receiver can't receive it due to powergroup conflict
+ * -1 -> Giver power conflict in lowering pow_lev
+ * -2 -> Receiver can't receive it due to powergroup conflict
*/
int
can_give_power(dbref giver, dbref receiver, POWER * power, int pow_lev)
static int yesno(const char *str);
static int canstilladd(dbref player);
static enum cmatch_type find_channel_partial_on(const char *name, CHAN **chan,
- dbref player);
+ dbref player);
static enum cmatch_type find_channel_partial_off(const char *name, CHAN **chan,
- dbref player);
+ dbref player);
static char *list_cuflags(CHANUSER *u, int verbose);
static void channel_join_self(dbref player, const char *name);
static void channel_leave_self(dbref player, const char *name);
void chat_player_announce(dbref player, char *msg, int ungag);
static int ok_channel_name(const char *n);
static void format_channel_broadcast(CHAN *chan, CHANUSER *u, dbref victim,
- int flags, const char *msg,
- const char *extra);
+ int flags, const char *msg,
+ const char *extra);
static void list_partial_matches(dbref player, const char *name,
- enum chan_match_type type);
+ enum chan_match_type type);
-const char *chan_speak_lock = "ChanSpeakLock"; /**< Name of speak lock */
-const char *chan_join_lock = "ChanJoinLock"; /**< Name of join lock */
-const char *chan_mod_lock = "ChanModLock"; /**< Name of modify lock */
-const char *chan_see_lock = "ChanSeeLock"; /**< Name of see lock */
-const char *chan_hide_lock = "ChanHideLock"; /**< Name of hide lock */
+const char *chan_speak_lock = "ChanSpeakLock"; /**< Name of speak lock */
+const char *chan_join_lock = "ChanJoinLock"; /**< Name of join lock */
+const char *chan_mod_lock = "ChanModLock"; /**< Name of modify lock */
+const char *chan_see_lock = "ChanSeeLock"; /**< Name of see lock */
+const char *chan_hide_lock = "ChanHideLock"; /**< Name of hide lock */
-#define CYES 1 /**< An affirmative. */
-#define CNO 0 /**< A negative. */
-#define ERR -1 /**< An error. Clever, eh? */
+#define CYES 1 /**< An affirmative. */
+#define CNO 0 /**< A negative. */
+#define ERR -1 /**< An error. Clever, eh? */
/** Wrapper for insert_user() that generates a new CHANUSER and inserts it */
#define insert_user_by_dbref(who,chan) \
int num_channels; /**< Number of channels defined */
-CHAN *channels; /**< Pointer to channel list */
+CHAN *channels; /**< Pointer to channel list */
static PRIV priv_table[] = {
{"Disabled", 'D', CHANNEL_DISABLED, CHANNEL_DISABLED},
if (strcmp(chat_timestamp, db_timestamp))
do_rawlog(LT_ERR,
- T
- ("CHAT: warning: chatdb and game db were saved at different times!"));
+ T
+ ("CHAT: warning: chatdb and game db were saved at different times!"));
/* How many channels? */
db_read_this_labeled_number(fp, "channels", &num_channels);
the_label = LBL_ERROR;
for(entry = field; entry->label; entry++)
if(!strcasecmp(entry->label, label)) {
- the_label = entry->tag;
- break;
+ the_label = entry->tag;
+ break;
}
switch(the_label) {
case LBL_NAME:
- strcpy(ChanName(ch), value);
- break;
+ strcpy(ChanName(ch), value);
+ break;
case LBL_DESC:
- strcpy(ChanTitle(ch), value);
- break;
+ strcpy(ChanTitle(ch), value);
+ break;
case LBL_CFLAGS:
- ChanType(ch) = parse_integer(value);
+ ChanType(ch) = parse_integer(value);
if (!iscobra)
for (i = 0; penn_conversion_table[i].oldchanflags; i++)
if ((ChanType(ch) & penn_conversion_table[i].oldchanflags)
- == penn_conversion_table[i].oldchanflags)
+ == penn_conversion_table[i].oldchanflags)
ChanType(ch) = (ChanType(ch)
- & ~penn_conversion_table[i].oldchanflags)
- | penn_conversion_table[i].newchanflags;
+ & ~penn_conversion_table[i].oldchanflags)
+ | penn_conversion_table[i].newchanflags;
for (i = 0; dbflag_conversion_table[i].dbflags; i++)
if (!(dbflags & dbflag_conversion_table[i].dbflags))
if ((ChanType(ch) & dbflag_conversion_table[i].oldchanflags)
- == dbflag_conversion_table[i].oldchanflags)
+ == dbflag_conversion_table[i].oldchanflags)
ChanType(ch) = (ChanType(ch)
- & ~dbflag_conversion_table[i].oldchanflags)
- | dbflag_conversion_table[i].newchanflags;
+ & ~dbflag_conversion_table[i].oldchanflags)
+ | dbflag_conversion_table[i].newchanflags;
- break;
+ break;
case LBL_CREATOR:
- ChanCreator(ch) = qparse_dbref(value);
- break;
+ ChanCreator(ch) = qparse_dbref(value);
+ break;
case LBL_COBJ:
- ChanObj(ch) = qparse_dbref(value);
- break;
+ ChanObj(ch) = qparse_dbref(value);
+ break;
case LBL_COST:
- ChanCost(ch) = parse_integer(value);
- break;
+ ChanCost(ch) = parse_integer(value);
+ break;
case LBL_LOCK:
- goto subfield_checks;
- break;
+ goto subfield_checks;
+ break;
case LBL_USERS:
- ChanMaxUsers(ch) = ChanNumUsers(ch) = parse_integer(value);
- ChanUsers(ch) = NULL;
- if(ChanNumUsers(ch) > 0)
- ChanNumUsers(ch) = load_labeled_chanusers(fp, ch);
- return 1;
- break;
+ ChanMaxUsers(ch) = ChanNumUsers(ch) = parse_integer(value);
+ ChanUsers(ch) = NULL;
+ if(ChanNumUsers(ch) > 0)
+ ChanNumUsers(ch) = load_labeled_chanusers(fp, ch);
+ return 1;
+ break;
case LBL_ERROR:
default:
- do_rawlog(LT_ERR, T("Unrecgonized field '%s' in chatdatabase"), label);
- return 0;
+ do_rawlog(LT_ERR, T("Unrecgonized field '%s' in chatdatabase"), label);
+ return 0;
};
continue;
subfield_checks:
for( sfptr = subfield; sfptr->subfield; sfptr++)
if((entry->tag == sfptr->tag) && !strcasecmp(sfptr->subfield, value) ) {
- the_subfield = sfptr->stag;
- break;
+ the_subfield = sfptr->stag;
+ break;
}
switch(the_subfield) {
case LBL_SPEAK:
- ChanSpeakLock(ch) = getboolexp(fp, chan_speak_lock);
- break;
+ ChanSpeakLock(ch) = getboolexp(fp, chan_speak_lock);
+ break;
case LBL_JOIN:
- ChanJoinLock(ch) = getboolexp(fp, chan_join_lock);
- break;
+ ChanJoinLock(ch) = getboolexp(fp, chan_join_lock);
+ break;
case LBL_MODIFY:
- ChanModLock(ch) = getboolexp(fp, chan_mod_lock);
- break;
+ ChanModLock(ch) = getboolexp(fp, chan_mod_lock);
+ break;
case LBL_SEE:
- ChanSeeLock(ch) = getboolexp(fp, chan_see_lock);
- break;
+ ChanSeeLock(ch) = getboolexp(fp, chan_see_lock);
+ break;
case LBL_HIDE:
- ChanHideLock(ch) = getboolexp(fp, chan_hide_lock);
- break;
+ ChanHideLock(ch) = getboolexp(fp, chan_hide_lock);
+ break;
case LBL_ERROR:
default:
- do_rawlog(LT_ERR, T("Unrecgonized lock subfield '%s' in chat database"), value);
- break;
+ do_rawlog(LT_ERR, T("Unrecgonized lock subfield '%s' in chat database"), value);
+ break;
};
}
return 1;
strcpy(CUtitle(user), getstring_noalloc(fp));
CUnext(user) = NULL;
if (insert_user(user, ch))
- num++;
+ num++;
} else {
/* But be sure to read (and discard) the player's info */
do_log(LT_ERR, 0, 0, T("Bad object #%d removed from channel %s"),
- player, ChanName(ch));
+ player, ChanName(ch));
(void) getref(fp);
(void) getstring_noalloc(fp);
}
strcpy(CUtitle(user), tmp);
CUnext(user) = NULL;
if (insert_user(user, ch))
- num++;
+ num++;
} else {
/* But be sure to read (and discard) the player's info */
do_log(LT_ERR, 0, 0, T("Bad object #%d removed from channel %s"),
- player, ChanName(ch));
+ player, ChanName(ch));
db_read_this_labeled_number(fp, "flags", &n);
db_read_this_labeled_string(fp, "title", &tmp);
}
} else {
/* Otherwise, find which channel this channel should be inserted after */
for (;
- p->next
- && (strcasecoll(ChanName(p->next->chan), ChanName(*ch)) < 0);
- p = p->next) ;
+ p->next
+ && (strcasecoll(ChanName(p->next->chan), ChanName(*ch)) < 0);
+ p = p->next) ;
if (p->next && !strcasecmp(ChanName(p->next->chan), ChanName(*ch))) {
/* Don't add the same channel twice! */
free_chanlist(tmp);
} else {
/* Otherwise, find which user this user should be inserted after */
for (;
- p->next
- && (strcasecoll(Name(CUdbref(p->next)), Name(CUdbref(user))) <= 0);
- p = p->next) ;
+ p->next
+ && (strcasecoll(Name(CUdbref(p->next)), Name(CUdbref(user))) <= 0);
+ p = p->next) ;
if (CUdbref(p) == CUdbref(user)) {
/* Don't add the same user twice! */
mush_free((Malloc_t) user, "CHANUSER");
if (!strcasecmp(cleanname, cleanp)) {
*chan = p;
if (Chan_Can_See(*chan, player) || OnChannel(player, *chan))
- return CMATCH_EXACT;
+ return CMATCH_EXACT;
else
- return CMATCH_NONE;
+ return CMATCH_NONE;
}
if (string_prefix(cleanp, name)) {
/* Keep the alphabetically first channel if we've got one */
if (Chan_Can_See(p, player) || OnChannel(player, p)) {
- if (!*chan)
- *chan = p;
- count++;
+ if (!*chan)
+ *chan = p;
+ count++;
}
}
}
* our best candidate so far.
*/
if (!*chan || (!OnChannel(player, *chan) && OnChannel(player, p)))
- *chan = p;
+ *chan = p;
count++;
}
}
if (!Chan_Can_See(p, player))
continue;
if ((type == PMATCH_ALL) || ((type == PMATCH_ON)
- ? (long) OnChannel(player, p)
- : !OnChannel(player, p))) {
+ ? (long) OnChannel(player, p)
+ : !OnChannel(player, p))) {
strcpy(cleanp, remove_markup(ChanName(p), NULL));
if (string_prefix(cleanp, cleanname)) {
- safe_chr(' ', buff, &bp);
- safe_str(ChanName(p), buff, &bp);
+ safe_chr(' ', buff, &bp);
+ safe_str(ChanName(p), buff, &bp);
}
}
}
if (OnChannel(player, p)) {
strcpy(cleanp, remove_markup(ChanName(p), NULL));
if (!strcasecmp(cleanname, cleanp)) {
- *chan = p;
- return CMATCH_EXACT;
+ *chan = p;
+ return CMATCH_EXACT;
}
if (string_prefix(cleanp, cleanname) && OnChannel(player, p)) {
- if (!*chan)
- *chan = p;
- count++;
+ if (!*chan)
+ *chan = p;
+ count++;
}
}
}
if (!OnChannel(player, p)) {
strcpy(cleanp, remove_markup(ChanName(p), NULL));
if (!strcasecmp(cleanname, cleanp)) {
- *chan = p;
- return CMATCH_EXACT;
+ *chan = p;
+ return CMATCH_EXACT;
}
if (string_prefix(cleanp, cleanname)) {
- if (!*chan)
- *chan = p;
- count++;
+ if (!*chan)
+ *chan = p;
+ count++;
}
}
}
if (!Chan_Can_See(chan, player)) {
if (OnChannel(player, chan))
notify_format(player,
- T("CHAT: You can't do that with channel <%s>."),
- ChanName(chan));
+ T("CHAT: You can't do that with channel <%s>."),
+ ChanName(chan));
else
notify(player, T("CHAT: I don't recognize that channel."));
return;
if (!strcasecmp("on", com) || !strcasecmp("join", com)) {
if (!Chan_Ok_Type(chan, victim)) {
notify_format(player,
- T("Sorry, wrong type of thing for channel <%s>."),
- ChanName(chan));
+ T("Sorry, wrong type of thing for channel <%s>."),
+ ChanName(chan));
return;
}
if (Guest(player)) {
/* Is victim already on the channel? */
if (OnChannel(victim, chan)) {
notify_format(player,
- T("%s is already on channel <%s>."), Name(victim),
- ChanName(chan));
+ T("%s is already on channel <%s>."), Name(victim),
+ ChanName(chan));
return;
}
/* Does victim pass the joinlock? */
if (!Chan_Can_Join(chan, victim)) {
if (Director(player)) {
- /* Directors can override join locks */
- notify(player,
- T
- ("CHAT: Warning: Target does not meet channel join permissions (joining anyway)"));
+ /* Directors can override join locks */
+ notify(player,
+ T
+ ("CHAT: Warning: Target does not meet channel join permissions (joining anyway)"));
} else {
- notify(player, T("Permission to join denied."));
- return;
+ notify(player, T("Permission to join denied."));
+ return;
}
}
if (insert_user_by_dbref(victim, chan)) {
notify_format(victim,
- T("CHAT: %s joins you to channel <%s>."), Name(player),
- ChanName(chan));
+ T("CHAT: %s joins you to channel <%s>."), Name(player),
+ ChanName(chan));
notify_format(player,
- T("CHAT: You join %s to channel <%s>."), Name(victim),
- ChanName(chan));
+ T("CHAT: You join %s to channel <%s>."), Name(victim),
+ ChanName(chan));
u = onchannel(victim, chan);
if (!Channel_Quiet(chan) && !DarkLegal(victim)) {
- format_channel_broadcast(chan, u, victim, CB_CHECKQUIET | CB_PRESENCE,
- T("%s %s has joined this channel."), NULL);
+ format_channel_broadcast(chan, u, victim, CB_CHECKQUIET | CB_PRESENCE,
+ T("%s %s has joined this channel."), NULL);
}
ChanNumUsers(chan)++;
} else {
notify_format(player,
- T("%s is already on channel <%s>."), Name(victim),
- ChanName(chan));
+ T("%s is already on channel <%s>."), Name(victim),
+ ChanName(chan));
}
return;
} else if (!strcasecmp("off", com) || !strcasecmp("leave", com)) {
strcpy(title, (u &&CUtitle(u)) ? CUtitle(u) : "");
if (remove_user(u, chan)) {
if (!Channel_Quiet(chan) && !DarkLegal(victim)) {
- format_channel_broadcast(chan, NULL, victim,
- CB_CHECKQUIET | CB_PRESENCE,
- T("%s %s has left this channel."), title);
+ format_channel_broadcast(chan, NULL, victim,
+ CB_CHECKQUIET | CB_PRESENCE,
+ T("%s %s has left this channel."), title);
}
notify_format(victim,
- T("CHAT: %s removes you from channel <%s>."),
- Name(player), ChanName(chan));
+ T("CHAT: %s removes you from channel <%s>."),
+ Name(player), ChanName(chan));
notify_format(player,
- T("CHAT: You remove %s from channel <%s>."),
- Name(victim), ChanName(chan));
+ T("CHAT: You remove %s from channel <%s>."),
+ Name(victim), ChanName(chan));
} else {
notify_format(player, T("%s is not on channel <%s>."), Name(victim),
- ChanName(chan));
+ ChanName(chan));
}
return;
} else {
case CMATCH_NONE:
if (find_channel_partial_on(name, &chan, player))
notify_format(player, T("CHAT: You are already on channel <%s>"),
- ChanName(chan));
+ ChanName(chan));
else
notify(player, T("CHAT: I don't recognize that channel."));
return;
}
if (!Chan_Ok_Type(chan, player)) {
notify_format(player,
- T("Sorry, wrong type of thing for channel <%s>."),
- ChanName(chan));
+ T("Sorry, wrong type of thing for channel <%s>."),
+ ChanName(chan));
return;
}
/* Does victim pass the joinlock? */
if (Director(player)) {
/* Directors can override join locks */
notify(player,
- T
- ("CHAT: Warning: You don't meet channel join permissions (joining anyway)"));
+ T
+ ("CHAT: Warning: You don't meet channel join permissions (joining anyway)"));
} else {
notify(player, T("Permission to join denied."));
return;
u = onchannel(player, chan);
if (!Channel_Quiet(chan) && !DarkLegal(player))
format_channel_broadcast(chan, u, player, CB_CHECKQUIET | CB_PRESENCE,
- T("%s %s has joined this channel."), NULL);
+ T("%s %s has joined this channel."), NULL);
ChanNumUsers(chan)++;
} else {
/* Should never happen */
notify_format(player,
- T("%s is already on channel <%s>."), Name(player),
- ChanName(chan));
+ T("%s is already on channel <%s>."), Name(player),
+ ChanName(chan));
}
}
switch (find_channel_partial_on(name, &chan, player)) {
case CMATCH_NONE:
if (find_channel_partial_off(name, &chan, player)
- && Chan_Can_See(chan, player))
+ && Chan_Can_See(chan, player))
notify_format(player, T("CHAT: You are not on channel <%s>"),
- ChanName(chan));
+ ChanName(chan));
else
notify(player, T("CHAT: I don't recognize that channel."));
return;
if (remove_user(u, chan)) {
if (!Channel_Quiet(chan) && !DarkLegal(player))
format_channel_broadcast(chan, NULL, player, CB_CHECKQUIET | CB_PRESENCE,
- T("%s %s has left this channel."), title);
+ T("%s %s has left this channel."), title);
notify_format(player, T("CHAT: You leave channel <%s>."), ChanName(chan));
} else {
/* Should never happen */
notify_format(player, T("%s is not on channel <%s>."), Name(player),
- ChanName(chan));
+ ChanName(chan));
}
}
case CMATCH_NONE:
if (find_channel(name, &c, player) == CMATCH_NONE) {
if (source)
- notify(player, T("CHAT: No such channel."));
+ notify(player, T("CHAT: No such channel."));
return 0;
}
}
if (!Chan_Ok_Type(chan, player)) {
notify_format(player,
- T
- ("Sorry, you're not the right type to be on channel <%s>."),
- ChanName(chan));
+ T
+ ("Sorry, you're not the right type to be on channel <%s>."),
+ ChanName(chan));
return;
}
if (!Chan_Can_Speak(chan, player)) {
if (Chan_Can_See(chan, player))
notify_format(player,
- T("Sorry, you're not allowed to speak on channel <%s>."),
- ChanName(chan));
+ T("Sorry, you're not allowed to speak on channel <%s>."),
+ ChanName(chan));
else
notify(player, T("No such channel."));
return;
return;
#ifdef RPMODE_SYS
} else if(RPMODE(player) && !Can_RPCHAT(player)) {
- notify(player, T("You can't do that in RPMODE."));
- return;
+ notify(player, T("You can't do that in RPMODE."));
+ return;
#endif /* RPMODE_SYS */
}
}
case POSE_TOKEN:
arg1 = arg1 + 1;
channel_broadcast(chan, player, 0, "%s %s%s%s%s%s%s", ChanObjName(chan),
- title ? title : "", title ? ANSI_NORMAL : "",
- (title && name) ? " " : "", name ? name : "", gap, arg1);
+ title ? title : "", title ? ANSI_NORMAL : "",
+ (title && name) ? " " : "", name ? name : "", gap, arg1);
if (!canhear)
notify_format(player, T("To channel %s: %s%s%s%s%s%s"), ChanName(chan),
- title ? title : "", title ? ANSI_NORMAL : "",
- (title && name) ? " " : "", name ? name : "", gap, arg1);
+ title ? title : "", title ? ANSI_NORMAL : "",
+ (title && name) ? " " : "", name ? name : "", gap, arg1);
break;
default:
if (CHAT_STRIP_QUOTE && (*arg1 == SAY_TOKEN))
arg1 = arg1 + 1;
channel_broadcast(chan, player, 0, T("%s %s%s%s%s says, \"%s\""),
- ChanObjName(chan), title ? title : "",
- title ? ANSI_NORMAL : "", (title && name) ? " " : "",
- name ? name : "", arg1);
+ ChanObjName(chan), title ? title : "",
+ title ? ANSI_NORMAL : "", (title && name) ? " " : "",
+ name ? name : "", arg1);
if (!canhear)
notify_format(player,
- T("To channel %s: %s%s%s%s says, \"%s\""),
- ChanName(chan), title ? title : "",
- title ? ANSI_NORMAL : "", (title && name) ? " " : "",
- name ? name : "", arg1);
+ T("To channel %s: %s%s%s%s says, \"%s\""),
+ ChanName(chan), title ? title : "",
+ title ? ANSI_NORMAL : "", (title && name) ? " " : "",
+ name ? name : "", arg1);
break;
}
}
if (!Chan_Ok_Type(chan, player)) {
notify_format(player,
- T
- ("Sorry, you're not the right type to be on channel <%s>."),
- ChanName(chan));
+ T
+ ("Sorry, you're not the right type to be on channel <%s>."),
+ ChanName(chan));
return;
}
if (!Chan_Can_Cemit(chan, player)) {
notify_format(player,
- T("Sorry, you're not allowed to @cemit on channel <%s>."),
- ChanName(chan));
+ T("Sorry, you're not allowed to @cemit on channel <%s>."),
+ ChanName(chan));
return;
}
u = onchannel(player, chan);
return;
#ifdef RPMODE_SYS
} else if(RPMODE(player) && !Can_RPCHAT(player)) {
- notify(player, T("You can't do that in RPMODE."));
- return;
+ notify(player, T("You can't do that in RPMODE."));
+ return;
#endif /* RPMODE_SYS */
}
}
}
if (!(flags & PEMIT_SILENT))
channel_broadcast(chan, player, (flags & PEMIT_SPOOF) ? 0 : CB_NOSPOOF,
- "%s %s", ChanObjName(chan), msg);
+ "%s %s", ChanObjName(chan), msg);
else
channel_broadcast(chan, player, (flags & PEMIT_SPOOF) ? 0 : CB_NOSPOOF,
- "%s", msg);
+ "%s", msg);
if (!canhear)
notify_format(player, T("Cemit to channel %s: %s"), ChanName(chan), msg);
ChanNumMsgs(chan)++;
/* Can the player afford it? There's a cost */
if (!payfor(Owner(player), CHANNEL_COST)) {
notify_format(player, T("You can't afford the %d %s."), CHANNEL_COST,
- MONIES);
+ MONIES);
return;
}
/* Ok, let's do it */
* itself
*/
if (temp != chan) {
- notify(player, T("The channel needs a more unique new name."));
- return;
+ notify(player, T("The channel needs a more unique new name."));
+ return;
}
}
if (strlen(perms) > CHAN_NAME_LEN - 1) {
strcpy(ChanName(chan), perms);
insert_channel(&chan);
channel_broadcast(chan, player, 0,
- "<%s> %s has renamed channel %s to %s.",
- ChanName(chan), Name(player), old, ChanName(chan));
+ "<%s> %s has renamed channel %s to %s.",
+ ChanName(chan), Name(player), old, ChanName(chan));
notify(player, T("Channel renamed."));
break;
case 3:
notify(player, T("Warning: channel will be disabled."));
if (type == ChanType(chan)) {
notify_format(player,
- T
- ("Invalid or same permissions on channel <%s>. No changes made."),
- ChanName(chan));
+ T
+ ("Invalid or same permissions on channel <%s>. No changes made."),
+ ChanName(chan));
} else {
ChanType(chan) = type;
notify_format(player,
- T("Permissions on channel <%s> changed."), ChanName(chan));
+ T("Permissions on channel <%s> changed."), ChanName(chan));
}
break;
}
*/
void
do_chan_user_flags(dbref player, char *name, const char *isyn, int flag,
- int silent)
+ int silent)
{
CHAN *c = NULL;
CHANUSER *u;
switch (flag) {
case 0:
notify(player, setting ? T("All channels have been muted.")
- : T("All channels have been unmuted."));
+ : T("All channels have been unmuted."));
break;
case 1:
notify(player, setting ? T("You hide on all the channels you can.")
- : T("You unhide on all channels."));
+ : T("You unhide on all channels."));
break;
case 2:
notify(player, setting ? T("All channels have been gagged.")
- : T("All channels have been ungagged."));
+ : T("All channels have been ungagged."));
break;
}
} else {
if (!u) {
/* This should only happen if they gave us a bad name */
if (!silent)
- notify_format(player, T("You are not on channel <%s>."), ChanName(c));
+ notify_format(player, T("You are not on channel <%s>."), ChanName(c));
return;
}
case 0:
/* Mute */
if (setting) {
- CUtype(u) |= CU_QUIET;
- if (!silent)
- notify_format(player,
- T
- ("You will no longer hear connection messages on channel <%s>."),
- ChanName(c));
+ CUtype(u) |= CU_QUIET;
+ if (!silent)
+ notify_format(player,
+ T
+ ("You will no longer hear connection messages on channel <%s>."),
+ ChanName(c));
} else {
- CUtype(u) &= ~CU_QUIET;
- if (!silent)
- notify_format(player,
- T
- ("You will now hear connection messages on channel <%s>."),
- ChanName(c));
+ CUtype(u) &= ~CU_QUIET;
+ if (!silent)
+ notify_format(player,
+ T
+ ("You will now hear connection messages on channel <%s>."),
+ ChanName(c));
}
break;
case 1:
/* Hide */
if (setting) {
- if (!Chan_Can_Hide(c, player) && !Director(player)) {
- if (!silent)
- notify_format(player,
- T("You are not permitted to hide on channel <%s>."),
- ChanName(c));
- } else {
- CUtype(u) |= CU_HIDE;
- if (!silent)
- notify_format(player,
- T
- ("You no longer appear on channel <%s>'s who list."),
- ChanName(c));
- }
+ if (!Chan_Can_Hide(c, player) && !Director(player)) {
+ if (!silent)
+ notify_format(player,
+ T("You are not permitted to hide on channel <%s>."),
+ ChanName(c));
+ } else {
+ CUtype(u) |= CU_HIDE;
+ if (!silent)
+ notify_format(player,
+ T
+ ("You no longer appear on channel <%s>'s who list."),
+ ChanName(c));
+ }
} else {
- CUtype(u) &= ~CU_HIDE;
- if (!silent)
- notify_format(player,
- T("You now appear on channel <%s>'s who list."),
- ChanName(c));
+ CUtype(u) &= ~CU_HIDE;
+ if (!silent)
+ notify_format(player,
+ T("You now appear on channel <%s>'s who list."),
+ ChanName(c));
}
break;
case 2:
/* Gag */
if (setting) {
- CUtype(u) |= CU_GAG;
- if (!silent)
- notify_format(player,
- T
- ("You will no longer hear messages on channel <%s>."),
- ChanName(c));
+ CUtype(u) |= CU_GAG;
+ if (!silent)
+ notify_format(player,
+ T
+ ("You will no longer hear messages on channel <%s>."),
+ ChanName(c));
} else {
- CUtype(u) &= ~CU_GAG;
- if (!silent)
- notify_format(player,
- T("You will now hear messages on channel <%s>."),
- ChanName(c));
+ CUtype(u) &= ~CU_GAG;
+ if (!silent)
+ notify_format(player,
+ T("You will now hear messages on channel <%s>."),
+ ChanName(c));
}
break;
}
/* Stomp newlines and other weird whitespace */
for (scan = title; *scan; scan++) {
if ((isspace((unsigned char) *scan) && (*scan != ' '))
- || (*scan == BEEP_CHAR)) {
+ || (*scan == BEEP_CHAR)) {
notify(player, T("Invalid character in title."));
return;
}
strcpy(CUtitle(u), title);
if (!Quiet(player))
notify_format(player, T("Title %s for %schannel %s."),
- *title ? T("set") : T("cleared"),
- Channel_NoTitles(c) ? "(NoTitles) " : "", ChanObjName(c));
+ *title ? T("set") : T("cleared"),
+ Channel_NoTitles(c) ? "(NoTitles) " : "", ChanObjName(c));
return;
}
if (SUPPORT_PUEBLO)
notify_noenter(player, tprintf("%cSAMP%c", TAG_START, TAG_END));
notify_format(player, "%-30s %-5s %8s %-16s %-8s %-3s",
- "Name", "Users", "Msgs", T("Chan Type"), "Status", "Buf");
+ "Name", "Users", "Msgs", T("Chan Type"), "Status", "Buf");
for (c = channels; c; c = c->next) {
strcpy(cleanname, remove_markup(ChanName(c), NULL));
if (Chan_Can_See(c, player) && string_prefix(cleanname, partname)) {
u = onchannel(player, c);
if (SUPPORT_PUEBLO)
- sprintf(numusers,
- "%cA XCH_CMD=\"@channel/who %s\" XCH_HINT=\"See who's on this channel now\"%c%5ld%c/A%c",
- TAG_START, cleanname, TAG_END, ChanNumUsers(c),
- TAG_START, TAG_END);
+ sprintf(numusers,
+ "%cA XCH_CMD=\"@channel/who %s\" XCH_HINT=\"See who's on this channel now\"%c%5ld%c/A%c",
+ TAG_START, cleanname, TAG_END, ChanNumUsers(c),
+ TAG_START, TAG_END);
else
- sprintf(numusers, "%5ld", ChanNumUsers(c));
+ sprintf(numusers, "%5ld", ChanNumUsers(c));
/* Display length is strlen(cleanname), but actual length is
* strlen(ChanName(c)). There are two different cases:
* 1. actual length <= 30. No problems.
len = strlen(ChanName(c));
numblanks = len - strlen(cleanname);
if (numblanks > 0 && numblanks < CHAN_NAME_LEN) {
- memset(blanks, ' ', CHAN_NAME_LEN - 1);
- if (len > 30)
- numblanks -= (len - 30);
- if (numblanks < 0)
- numblanks = 0;
- blanks[numblanks] = '\0';
+ memset(blanks, ' ', CHAN_NAME_LEN - 1);
+ if (len > 30)
+ numblanks -= (len - 30);
+ if (numblanks < 0)
+ numblanks = 0;
+ blanks[numblanks] = '\0';
} else {
- blanks[0] = '\0';
+ blanks[0] = '\0';
}
notify_format(player,
- "%-30s%s %s %8ld [%c%c%c%c%c%c%c%c %c%c%c%c%c%c] [%-3s %c%c] %3d",
- ChanName(c), blanks, numusers, ChanNumMsgs(c),
- Channel_Disabled(c) ? 'D' : '-',
- Channel_Player(c) ? 'P' : '-',
- Channel_Object(c) ? 'O' : '-',
- Channel_Admin(c) ? 'A' : (Channel_Director(c) ? 'W' : '-'),
- Channel_Quiet(c) ? 'Q' : '-',
- Channel_CanHide(c) ? 'H' : '-', Channel_Open(c) ? 'o' : '-',
- (ChanType(c) & CHANNEL_COBJ) ? 'Z' : '-',
- /* Locks */
- ChanJoinLock(c) != TRUE_BOOLEXP ? 'j' : '-',
- ChanSpeakLock(c) != TRUE_BOOLEXP ? 's' : '-',
- ChanModLock(c) != TRUE_BOOLEXP ? 'm' : '-',
- ChanSeeLock(c) != TRUE_BOOLEXP ? 'v' : '-',
- ChanHideLock(c) != TRUE_BOOLEXP ? 'h' : '-',
- /* Does the player own it? */
- ChanCreator(c) == player ? '*' : '-',
- /* User status */
- u ? (Chanuser_Gag(u) ? "Gag" : "On") : "Off",
- (u &&Chanuser_Quiet(u)) ? 'Q' : ' ',
- (u &&Chanuser_Hide(u)) ? 'H' : ' ',
- bufferq_lines(ChanBufferQ(c)));
+ "%-30s%s %s %8ld [%c%c%c%c%c%c%c%c %c%c%c%c%c%c] [%-3s %c%c] %3d",
+ ChanName(c), blanks, numusers, ChanNumMsgs(c),
+ Channel_Disabled(c) ? 'D' : '-',
+ Channel_Player(c) ? 'P' : '-',
+ Channel_Object(c) ? 'O' : '-',
+ Channel_Admin(c) ? 'A' : (Channel_Director(c) ? 'W' : '-'),
+ Channel_Quiet(c) ? 'Q' : '-',
+ Channel_CanHide(c) ? 'H' : '-', Channel_Open(c) ? 'o' : '-',
+ (ChanType(c) & CHANNEL_COBJ) ? 'Z' : '-',
+ /* Locks */
+ ChanJoinLock(c) != TRUE_BOOLEXP ? 'j' : '-',
+ ChanSpeakLock(c) != TRUE_BOOLEXP ? 's' : '-',
+ ChanModLock(c) != TRUE_BOOLEXP ? 'm' : '-',
+ ChanSeeLock(c) != TRUE_BOOLEXP ? 'v' : '-',
+ ChanHideLock(c) != TRUE_BOOLEXP ? 'h' : '-',
+ /* Does the player own it? */
+ ChanCreator(c) == player ? '*' : '-',
+ /* User status */
+ u ? (Chanuser_Gag(u) ? "Gag" : "On") : "Off",
+ (u &&Chanuser_Quiet(u)) ? 'Q' : ' ',
+ (u &&Chanuser_Hide(u)) ? 'H' : ' ',
+ bufferq_lines(ChanBufferQ(c)));
}
}
if (SUPPORT_PUEBLO)
}
if (nargs == 1) {
if (string_prefix(called_as, "CL"))
- safe_str(privs_to_string(priv_table, ChanType(c)), buff, bp);
+ safe_str(privs_to_string(priv_table, ChanType(c)), buff, bp);
else
- safe_str(privs_to_letters(priv_table, ChanType(c)), buff, bp);
+ safe_str(privs_to_letters(priv_table, ChanType(c)), buff, bp);
return;
}
thing = match_thing(executor, args[1]);
safe_str(ChanTitle(c), buff, bp);
else if (string_prefix(called_as, "CB")) {
if(ChanBufferQ(c) != NULL)
- safe_integer(BufferQSize(ChanBufferQ(c)), buff, bp);
+ safe_integer(BufferQSize(ChanBufferQ(c)), buff, bp);
else
- safe_chr('0', buff, bp);
+ safe_chr('0', buff, bp);
} else if (string_prefix(called_as, "CU"))
safe_integer(ChanNumUsers(c), buff, bp);
else if (string_prefix(called_as, "CM"))
u = onchannel(thing, c);
if (!u) {
if (can_ex || ok)
- safe_str(T("#-1 NOT ON CHANNEL"), buff, bp);
+ safe_str(T("#-1 NOT ON CHANNEL"), buff, bp);
else
- safe_str(T("#-1 PERMISSION DENIED"), buff, bp);
+ safe_str(T("#-1 PERMISSION DENIED"), buff, bp);
return;
}
ok &= !Chanuser_Hide(u);
}
/* They're on the channel, but maybe we can't see them? */
if (Chanuser_Hide(u) &&
- !(Priv_Who(executor) || Can_Examine(executor, thing))) {
+ !(Priv_Who(executor) || Can_Examine(executor, thing))) {
safe_str("Off", buff, bp);
return;
}
victim = CUdbref(u);
if (remove_user(u, chan))
notify_format(victim, T("CHAT: %s has removed all users from <%s>."),
- Name(player), ChanName(chan));
+ Name(player), ChanName(chan));
}
ChanNumUsers(chan) = 0;
return;
*/
chan_chown(c, victim);
notify_format(player,
- T("CHAT: Channel <%s> now owned by %s."), ChanName(c),
- Name(ChanCreator(c)));
+ T("CHAT: Channel <%s> now owned by %s."), ChanName(c),
+ Name(ChanCreator(c)));
return;
}
free_boolexp(ChanJoinLock(c));
ChanJoinLock(c) = key;
notify_format(player, (key == TRUE_BOOLEXP) ?
- T("CHAT: Joinlock on <%s> reset.") :
- T("CHAT: Joinlock on <%s> set."), ChanName(c));
+ T("CHAT: Joinlock on <%s> reset.") :
+ T("CHAT: Joinlock on <%s> set."), ChanName(c));
break;
case CL_SPEAK:
free_boolexp(ChanSpeakLock(c));
ChanSpeakLock(c) = key;
notify_format(player, (key == TRUE_BOOLEXP) ?
- T("CHAT: Speaklock on <%s> reset.") :
- T("CHAT: Speaklock on <%s> set."), ChanName(c));
+ T("CHAT: Speaklock on <%s> reset.") :
+ T("CHAT: Speaklock on <%s> set."), ChanName(c));
break;
case CL_SEE:
free_boolexp(ChanSeeLock(c));
ChanSeeLock(c) = key;
notify_format(player, (key == TRUE_BOOLEXP) ?
- T("CHAT: Seelock on <%s> reset.") :
- T("CHAT: Seelock on <%s> set."), ChanName(c));
+ T("CHAT: Seelock on <%s> reset.") :
+ T("CHAT: Seelock on <%s> set."), ChanName(c));
break;
case CL_HIDE:
free_boolexp(ChanHideLock(c));
ChanHideLock(c) = key;
notify_format(player, (key == TRUE_BOOLEXP) ?
- T("CHAT: Hidelock on <%s> reset.") :
- T("CHAT: Hidelock on <%s> set."), ChanName(c));
+ T("CHAT: Hidelock on <%s> reset.") :
+ T("CHAT: Hidelock on <%s> set."), ChanName(c));
break;
case CL_MOD:
free_boolexp(ChanModLock(c));
ChanModLock(c) = key;
notify_format(player, (key == TRUE_BOOLEXP) ?
- T("CHAT: Modlock on <%s> reset.") :
- T("CHAT: Modlock on <%s> set."), ChanName(c));
+ T("CHAT: Modlock on <%s> reset.") :
+ T("CHAT: Modlock on <%s> set."), ChanName(c));
break;
}
return;
notify_format(player, T("Description: %s"), ChanTitle(c));
notify_format(player, T("Owner: %s"), Name(ChanCreator(c)));
notify_format(player, T("Flags: %s"),
- privs_to_string(priv_table, ChanType(c)));
+ privs_to_string(priv_table, ChanType(c)));
if(ChanType(c) & CHANNEL_COBJ) {
- if(player == ChanCreator(c) || Director(player)
- || Visual(ChanObj(c))
- || controls(player, Owner(ChanCreator(c))))
+ if(player == ChanCreator(c) || Director(player)
+ || Visual(ChanObj(c))
+ || controls(player, Owner(ChanCreator(c))))
notify_format(player, "Channel object: %s",
- object_header(player, ChanObj(c)));
+ object_header(player, ChanObj(c)));
}
if (ChanBufferQ(c))
- notify_format(player,
- T("Recall buffer: %dk, can hold %d."),
- BufferQSize(ChanBufferQ(c)), bufferq_lines(ChanBufferQ(c)));
+ notify_format(player,
+ T("Recall buffer: %dk, can hold %d."),
+ BufferQSize(ChanBufferQ(c)), bufferq_lines(ChanBufferQ(c)));
found++;
}
}
if (string_prefix(cleanp, cleanname)) {
found++;
if (!(See_All(player) || Chan_Can_Modify(c, player)
- || (ChanCreator(c) == player))) {
- if (Chan_Can_See(c, player))
- notify_format(player, T("CHAT: No permission to decompile <%s>"),
- ChanName(c));
- continue;
+ || (ChanCreator(c) == player))) {
+ if (Chan_Can_See(c, player))
+ notify_format(player, T("CHAT: No permission to decompile <%s>"),
+ ChanName(c));
+ continue;
}
notify_format(player, "@channel/add %s = %s", ChanName(c),
- privs_to_string(priv_table, ChanType(c)));
+ privs_to_string(priv_table, ChanType(c)));
notify_format(player, "@channel/chown %s = %s", ChanName(c),
- Name(ChanCreator(c)));
+ Name(ChanCreator(c)));
if(ChanObj(c) != NOTHING)
- notify_format(player, "@cobj %s=%s", ChanName(c), unparse_dbref(ChanObj(c)));
+ notify_format(player, "@cobj %s=%s", ChanName(c), unparse_dbref(ChanObj(c)));
if (ChanModLock(c) != TRUE_BOOLEXP)
- notify_format(player, "@clock/mod %s = %s", ChanName(c),
- unparse_boolexp(player, ChanModLock(c), UB_MEREF));
+ notify_format(player, "@clock/mod %s = %s", ChanName(c),
+ unparse_boolexp(player, ChanModLock(c), UB_MEREF));
if (ChanHideLock(c) != TRUE_BOOLEXP)
- notify_format(player, "@clock/hide %s = %s", ChanName(c),
- unparse_boolexp(player, ChanHideLock(c), UB_MEREF));
+ notify_format(player, "@clock/hide %s = %s", ChanName(c),
+ unparse_boolexp(player, ChanHideLock(c), UB_MEREF));
if (ChanJoinLock(c) != TRUE_BOOLEXP)
- notify_format(player, "@clock/join %s = %s", ChanName(c),
- unparse_boolexp(player, ChanJoinLock(c), UB_MEREF));
+ notify_format(player, "@clock/join %s = %s", ChanName(c),
+ unparse_boolexp(player, ChanJoinLock(c), UB_MEREF));
if (ChanSpeakLock(c) != TRUE_BOOLEXP)
- notify_format(player, "@clock/speak %s = %s", ChanName(c),
- unparse_boolexp(player, ChanSpeakLock(c), UB_MEREF));
+ notify_format(player, "@clock/speak %s = %s", ChanName(c),
+ unparse_boolexp(player, ChanSpeakLock(c), UB_MEREF));
if (ChanSeeLock(c) != TRUE_BOOLEXP)
- notify_format(player, "@clock/see %s = %s", ChanName(c),
- unparse_boolexp(player, ChanSeeLock(c), UB_MEREF));
+ notify_format(player, "@clock/see %s = %s", ChanName(c),
+ unparse_boolexp(player, ChanSeeLock(c), UB_MEREF));
if (ChanTitle(c))
- notify_format(player, "@channel/desc %s = %s", ChanName(c),
- ChanTitle(c));
+ notify_format(player, "@channel/desc %s = %s", ChanName(c),
+ ChanTitle(c));
if (ChanBufferQ(c))
- notify_format(player, "@channel/buffer %s = %d", ChanName(c),
- bufferq_lines(ChanBufferQ(c)));
+ notify_format(player, "@channel/buffer %s = %d", ChanName(c),
+ bufferq_lines(ChanBufferQ(c)));
if (!brief) {
- for (u = ChanUsers(c); u; u = u->next) {
- if (!Chanuser_Hide(u) || Priv_Who(player))
+ for (u = ChanUsers(c); u; u = u->next) {
+ if (!Chanuser_Hide(u) || Priv_Who(player))
- notify_format(player, "@channel/on %s = %s", ChanName(c),
- Name(CUdbref(u)));
- }
+ notify_format(player, "@channel/on %s = %s", ChanName(c),
+ Name(CUdbref(u)));
+ }
}
}
}
for (u = ChanUsers(chan); u; u = u->next) {
who = CUdbref(u);
if ((IsThing(who) || Connected(who)) &&
- (!Chanuser_Hide(u) || Priv_Who(player))) {
+ (!Chanuser_Hide(u) || Priv_Who(player))) {
i++;
safe_itemizer(i, !(u->next), ",", T("and"), " ", tbuf1, &bp);
safe_str(Name(who), tbuf1, &bp);
if (IsThing(who))
- safe_format(tbuf1, &bp, "(#%d)", who);
+ safe_format(tbuf1, &bp, "(#%d)", who);
sf = 0;
if (Chanuser_Hide(u) || Chanuser_Gag(u)
#ifdef RPMODE_SYS
- || (RPMODE(u->who) && !Can_RPCHAT(u->who))
+ || (RPMODE(u->who) && !Can_RPCHAT(u->who))
#endif /* RPMODE_SYS */
- ) {
- safe_str(" (", tbuf1, &bp);
- sf++;
+ ) {
+ safe_str(" (", tbuf1, &bp);
+ sf++;
}
if (Chanuser_Hide(u)) {
- safe_str("hidden", tbuf1, &bp);
- sf++;
+ safe_str("hidden", tbuf1, &bp);
+ sf++;
}
if(Chanuser_Gag(u)) {
- if(sf > 1) safe_chr(',', tbuf1, &bp);
- safe_str("gagging", tbuf1, &bp);
- sf++;
+ if(sf > 1) safe_chr(',', tbuf1, &bp);
+ safe_str("gagging", tbuf1, &bp);
+ sf++;
}
#ifdef RPMODE_SYS
if(RPMODE(u->who) && !Can_RPCHAT(u->who)) {
- if(sf > 1) safe_chr(',', tbuf1, &bp);
- safe_str("rpgag", tbuf1, &bp);
- sf++;
+ if(sf > 1) safe_chr(',', tbuf1, &bp);
+ safe_str("rpgag", tbuf1, &bp);
+ sf++;
}
#endif /* RPMODE_SYS */
if(sf > 0)
- safe_chr(')', tbuf1, &bp);
+ safe_chr(')', tbuf1, &bp);
}
}
*bp = '\0';
for (u = ChanUsers(chan); u; u = u->next) {
who = CUdbref(u);
if ((IsThing(who) || Connected(who)) &&
- (!Chanuser_Hide(u) || Priv_Who(executor))) {
+ (!Chanuser_Hide(u) || Priv_Who(executor))) {
if (first)
- first = 0;
+ first = 0;
else
- safe_chr(' ', buff, bp);
+ safe_chr(' ', buff, bp);
safe_dbref(who, buff, bp);
}
}
if (!title || !*title) {
ChanTitle(c)[0] = '\0';
notify_format(player, T("CHAT: Channel <%s> description cleared."),
- ChanName(c));
+ ChanName(c));
} else {
strcpy(ChanTitle(c), title);
notify_format(player, T("CHAT: Channel <%s> description set."),
- ChanName(c));
+ ChanName(c));
}
}
u = onchannel(player, c);
if (u) {
if (!Channel_Quiet(c) && (Channel_Admin(c) || Channel_Director(c)
- || (!Chanuser_Hide(u) && !Dark(player)))) {
- bp = buff;
+ || (!Chanuser_Hide(u) && !Dark(player)))) {
+ bp = buff;
- safe_format(buff, &bp, "%s %s", "%s", msg);
- *bp = '\0';
- format_channel_broadcast(c, u, player, CB_CHECKQUIET | CB_PRESENCE,
- buff, NULL);
+ safe_format(buff, &bp, "%s %s", "%s", msg);
+ *bp = '\0';
+ format_channel_broadcast(c, u, player, CB_CHECKQUIET | CB_PRESENCE,
+ buff, NULL);
}
if (ungag)
- CUtype(u) &= ~CU_GAG;
+ CUtype(u) &= ~CU_GAG;
}
}
}
if (GoodObject(it)) {
int first = 1;
if (!delim_check(buff, bp, nargs, args, 2, &sep))
- return;
+ return;
can_ex = Can_Examine(executor, it);
for (cl = Chanlist(it); cl; cl = cl->next) {
- if (can_ex || ((u = onchannel(it, cl->chan)) &&!Chanuser_Hide(u)
- && onchannel(executor, cl->chan))) {
- if (!first)
- safe_chr(sep, buff, bp);
- safe_str(ChanName(cl->chan), buff, bp);
- first = 0;
- }
+ if (can_ex || ((u = onchannel(it, cl->chan)) &&!Chanuser_Hide(u)
+ && onchannel(executor, cl->chan))) {
+ if (!first)
+ safe_chr(sep, buff, bp);
+ safe_str(ChanName(cl->chan), buff, bp);
+ first = 0;
+ }
}
return;
} else {
/* args[0] didn't match. Maybe it's a delimiter? */
if (arglens[0] > 1) {
- if (it == NOTHING)
- notify(executor, T("I can't see that here."));
- else if (it == AMBIGUOUS)
- notify(executor, T("I don't know which thing you mean."));
- return;
+ if (it == NOTHING)
+ notify(executor, T("I can't see that here."));
+ else if (it == AMBIGUOUS)
+ notify(executor, T("I don't know which thing you mean."));
+ return;
} else if (!delim_check(buff, bp, nargs, args, 1, &sep))
- return;
+ return;
}
}
/* No arguments (except maybe delimiter) - return list of all channels */
for (c = channels; c; c = c->next) {
if (Chan_Can_See(c, executor)) {
if (c != channels)
- safe_chr(sep, buff, bp);
+ safe_chr(sep, buff, bp);
safe_str(ChanName(c), buff, bp);
}
}
if (nargs == 2) {
if (FUNCTION_SIDE_EFFECTS) {
if (!command_check_byname(executor, "@clock") || fun->flags & FN_NOSIDEFX) {
- safe_str(T(e_perm), buff, bp);
- return;
+ safe_str(T(e_perm), buff, bp);
+ return;
}
do_chan_lock(executor, args[0], args[1], which_lock);
return;
start--;
}
while ((buf = iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type,
- ×tamp)) && num_lines > 0) {
+ ×tamp)) && num_lines > 0) {
if (first)
first = 0;
else
safe_chr(sep, buff, bp);
if (Nospoof(executor) && GoodObject(speaker)) {
char *nsmsg = ns_esnotify(speaker, na_one, &executor,
- Paranoid(executor) ? 1 : 0);
+ Paranoid(executor) ? 1 : 0);
if (!showstamp)
- safe_format(buff, bp, T("%s %s"), nsmsg, buf);
+ safe_format(buff, bp, T("%s %s"), nsmsg, buf);
else {
- stamp = show_time(timestamp, 0);
- safe_format(buff, bp, T("[%s] %s %s"), stamp, nsmsg, buf);
+ stamp = show_time(timestamp, 0);
+ safe_format(buff, bp, T("[%s] %s %s"), stamp, nsmsg, buf);
}
mush_free(nsmsg, "string");
} else {
if (!showstamp)
- safe_str(buf, buff, bp);
+ safe_str(buf, buff, bp);
else {
- stamp = show_time(timestamp, 0);
- safe_format(buff, bp, T("[%s] %s"), stamp, buf);
+ stamp = show_time(timestamp, 0);
+ safe_format(buff, bp, T("[%s] %s"), stamp, buf);
}
}
num_lines--;
current = CUdbref(u);
nu = u->next;
cont = (!GoodObject(current) ||
- (nac->checkquiet && Chanuser_Quiet(u)) ||
- Chanuser_Gag(u)
+ (nac->checkquiet && Chanuser_Quiet(u)) ||
+ Chanuser_Gag(u)
#ifdef RPMODE_SYS
- || (RPMODE(current) && !Can_RPCHAT(current))
+ || (RPMODE(current) && !Can_RPCHAT(current))
#endif
- || (IsPlayer(current) && !Connected(current)));
+ || (IsPlayer(current) && !Connected(current)));
} while (cont);
nac->u = nu;
return current;
#ifdef HAS_VSNPRINTF
char tbuf1[BUFFER_LEN];
#else
- char tbuf1[BUFFER_LEN * 2]; /* Safety margin as per tprintf */
+ char tbuf1[BUFFER_LEN * 2]; /* Safety margin as per tprintf */
#endif
struct na_cpass nac;
int na_flags = NA_INTER_LOCK;
if (Channel_Interact(channel))
na_flags |= (flags & CB_PRESENCE) ? NA_INTER_PRESENCE : NA_INTER_HEAR;
notify_anything(player, na_channel, &nac, ns_esnotify,
- na_flags | ((flags & CB_NOSPOOF) ? 0 : NA_SPOOF), tbuf1);
+ na_flags | ((flags & CB_NOSPOOF) ? 0 : NA_SPOOF), tbuf1);
if (ChanBufferQ(channel))
add_to_bufferq(ChanBufferQ(channel), 0,
- (flags & CB_NOSPOOF) ? player : NOTHING, tbuf1);
+ (flags & CB_NOSPOOF) ? player : NOTHING, tbuf1);
}
CHANUSER *u;
const char *lines;
const char *startpos;
- int num_lines = 10; /* Default if none is given */
+ int num_lines = 10; /* Default if none is given */
int start = -1;
int all;
char *p = NULL, *buf;
if (is_integer(lines)) {
num_lines = parse_integer(lines);
if (num_lines == 0)
- num_lines = INT_MAX;
+ num_lines = INT_MAX;
} else {
notify(player, T("How many lines did you want to recall?"));
return;
if (!Chan_Can_See(chan, player)) {
if (OnChannel(player, chan))
notify_format(player,
- T("CHAT: You can't do that with channel <%s>."),
- ChanName(chan));
+ T("CHAT: You can't do that with channel <%s>."),
+ ChanName(chan));
else
notify(player, T("CHAT: I don't recognize that channel."));
return;
start--;
}
while ((buf = iter_bufferq(ChanBufferQ(chan), &p, &speaker, &type,
- ×tamp)) && num_lines > 0) {
+ ×tamp)) && num_lines > 0) {
if (Nospoof(player) && GoodObject(speaker)) {
char *nsmsg = ns_esnotify(speaker, na_one, &player,
- Paranoid(player) ? 1 : 0);
+ Paranoid(player) ? 1 : 0);
if (quiet)
- notify_format(player, T("%s %s"), nsmsg, buf);
+ notify_format(player, T("%s %s"), nsmsg, buf);
else {
- stamp = show_time(timestamp, 0);
- notify_format(player, T("[%s] %s %s"), stamp, nsmsg, buf);
+ stamp = show_time(timestamp, 0);
+ notify_format(player, T("[%s] %s %s"), stamp, nsmsg, buf);
}
mush_free(nsmsg, "string");
} else {
if (quiet)
- notify(player, buf);
+ notify(player, buf);
else {
- stamp = show_time(timestamp, 0);
- notify_format(player, T("[%s] %s"), stamp, buf);
+ stamp = show_time(timestamp, 0);
+ notify_format(player, T("[%s] %s"), stamp, buf);
}
}
num_lines--;
notify(player, T("CHAT: End recall"));
if (!all)
notify_format(player,
- T
- ("CHAT: To recall the entire buffer, use @chan/recall %s=0"),
- ChanName(chan));
+ T
+ ("CHAT: To recall the entire buffer, use @chan/recall %s=0"),
+ ChanName(chan));
}
/** Set the size of a channel's buffer in maximum lines.
free_bufferq(ChanBufferQ(chan));
ChanBufferQ(chan) = NULL;
notify_format(player,
- T("CHAT: Channel buffering disabled for channel <%s>."),
- ChanName(chan));
+ T("CHAT: Channel buffering disabled for channel <%s>."),
+ ChanName(chan));
} else {
notify_format(player,
- T
- ("CHAT: Channel buffering already disabled for channel <%s>."),
- ChanName(chan));
+ T
+ ("CHAT: Channel buffering already disabled for channel <%s>."),
+ ChanName(chan));
}
} else {
if (ChanBufferQ(chan)) {
/* Resize a buffer */
ChanBufferQ(chan) = reallocate_bufferq(ChanBufferQ(chan), size);
notify_format(player, T("CHAT: Resizing buffer of channel <%s>"),
- ChanName(chan));
+ ChanName(chan));
} else {
/* Start a new buffer */
ChanBufferQ(chan) = allocate_bufferq(size);
notify_format(player,
- T("CHAT: Buffering enabled on channel <%s>."),
- ChanName(chan));
+ T("CHAT: Buffering enabled on channel <%s>."),
+ ChanName(chan));
}
}
}
static void
format_channel_broadcast(CHAN *chan, CHANUSER *u, dbref victim, int flags,
- const char *msg, const char *extra)
+ const char *msg, const char *extra)
{
const char *title = NULL;
if (extra && *extra)
static void
do_set_cobj(player, name, obj)
dbref player;
- const char *name;
- const char *obj;
+ const char *name;
+ const char *obj;
{
CHAN *c;
dbref cobj;
if(!controls(player,cobj)) {
notify(player,"You must own that object first");
- return;
- }
+ return;
+ }
if(Typeof(cobj) != TYPE_THING) {
notify(player, "Must be an object");
ChanObj(c) = -1;
strcpy(buff,tprintf("<%s>", ChanName(c)));
return buff;
- }
+ }
nm = atr_get_noparent(ChanObj(c), "CHANNAME");
if(nm) {
strcpy(tbuf,atr_value(nm));
- strcpy(buff,(char *) nv_eval(ChanObj(c), tbuf));
- }
- else {
+ strcpy(buff,(char *) nv_eval(ChanObj(c), tbuf));
+ }
+ else {
strcpy(buff,tprintf("<%s>", ChanName(c)));
- }
+ }
}
else {
strcpy(buff,tprintf("<%s>", ChanName(c))); }
#ifdef USE_MAILER
-extern int do_convtime(const char *str, struct tm *ttm); /* funtime.c */
+extern int do_convtime(const char *str, struct tm *ttm); /* funtime.c */
static void do_mail_flags
(dbref player, const char *msglist, mail_flag flag, int negate);
static MAIL *real_mail_fetch(dbref player, int num, int folder);
static MAIL *mailfun_fetch(dbref player, int nargs, char *arg1, char *arg2);
static void count_mail(dbref player,
- int folder, int *rcount, int *ucount, int *ccount);
+ int folder, int *rcount, int *ucount, int *ccount);
static int real_send_mail(dbref player,
- dbref target, char *subject, char *message,
- mail_flag flags, int silent, int nosig);
+ dbref target, char *subject, char *message,
+ mail_flag flags, int silent, int nosig);
static void send_mail(dbref player,
- dbref target, char *subject, char *message,
- mail_flag flags, int silent, int nosig);
+ dbref target, char *subject, char *message,
+ mail_flag flags, int silent, int nosig);
static int send_mail_alias(dbref player,
- char *aname, char *subject,
- char *message, mail_flag flags, int silent,
- int nosig);
+ char *aname, char *subject,
+ char *message, mail_flag flags, int silent,
+ int nosig);
static void filter_mail(dbref from, dbref player, char *subject,
- char *message, int mailnumber, mail_flag flags);
+ char *message, int mailnumber, mail_flag flags);
static MAIL *find_insertion_point(dbref player);
static int get_folder_number(dbref player, char *name);
static char *get_folder_name(dbref player, int fld);
static char *get_sender(MAIL *mp, int full);
static int was_sender(dbref player, MAIL *mp);
-MAIL *maildb; /**< The head of the mail list */
-MAIL *tail_ptr; /**< The end of the mail list */
+MAIL *maildb; /**< The head of the mail list */
+MAIL *tail_ptr; /**< The end of the mail list */
-#define HEAD maildb /**< The head of the mail list */
-#define TAIL tail_ptr /**< The end of the mail list */
+#define HEAD maildb /**< The head of the mail list */
+#define TAIL tail_ptr /**< The end of the mail list */
/** A line of...dashes! */
#define DASH_LINE \
"-----------------------------------------------------------------------------"
-int mdb_top = 0; /**< total number of messages in mail db */
+int mdb_top = 0; /**< total number of messages in mail db */
/*-------------------------------------------------------------------------*
* User mail functions (these are called from game.c)
/* Stop at a return or a tab */
for (p = sbuf; *p; p++) {
if ((*p == '\r') || (*p == '\n') || (*p == '\t')) {
- *p = '\0';
- break;
+ *p = '\0';
+ break;
}
if (!isprint((unsigned char) *p)) {
- *p = ' ';
+ *p = ' ';
}
}
} else
safe_str(Name(mp->from), tbuf1, &bp);
else
safe_format(tbuf1, &bp, "%s (owner: %s)", Name(mp->from),
- Name(Owner(mp->from)));
+ Name(Owner(mp->from)));
*bp = '\0';
return tbuf1;
}
check_mail(player, pfld, 1);
pfld = player_folder(player);
notify_format(player,
- T("MAIL: Current folder is %d [%s]."), pfld,
- get_folder_name(player, pfld));
+ T("MAIL: Current folder is %d [%s]."), pfld,
+ get_folder_name(player, pfld));
return;
}
pfld = parse_folder(player, fld);
}
for (p = newname; p && *p; p++) {
if (!isdigit((unsigned char) *p) && !isalpha((unsigned char) *p)) {
- notify(player, T("MAIL: Illegal folder name"));
- return;
+ notify(player, T("MAIL: Illegal folder name"));
+ return;
}
}
add_folder_name(player, pfld, newname);
/* Set a new folder */
set_player_folder(player, pfld);
notify_format(player,
- T("MAIL: Current folder set to %d [%s]."), pfld,
- get_folder_name(player, pfld));
+ T("MAIL: Current folder set to %d [%s]."), pfld,
+ get_folder_name(player, pfld));
}
}
if ((mp->to == player) && (All(ms) || (Folder(mp) == folder))) {
i[Folder(mp)]++;
if (mail_match(player, mp, ms, i[Folder(mp)])) {
- j++;
- if (negate) {
- mp->read &= ~flag;
- } else {
- mp->read |= flag;
- }
- switch (flag) {
- case M_TAG:
- if (All(ms)) {
- if (!notified) {
- notify_format(player,
- T("MAIL: All messages in all folders %s."),
- negate ? "untagged" : "tagged");
- notified++;
- }
- } else
- notify_format(player,
- "MAIL: Msg #%d:%d %s.", Folder(mp),
- i[Folder(mp)], negate ? "untagged" : "tagged");
- break;
- case M_CLEARED:
- if (All(ms)) {
- if (!notified) {
- notify_format(player,
- T("MAIL: All messages in all folders %s."),
- negate ? "uncleared" : "cleared");
- notified++;
- }
- } else {
- if (Unread(mp) && !negate) {
- notify_format(player,
- T
- ("MAIL: Unread Msg #%d:%d cleared! Use @mail/unclear %d:%d to recover."),
- Folder(mp), i[Folder(mp)], Folder(mp),
- i[Folder(mp)]);
- } else {
- notify_format(player,
- (negate ? T("MAIL: Msg #%d:%d uncleared.") :
- T("MAIL: Msg #%d:%d cleared.")), Folder(mp),
- i[Folder(mp)]);
- }
- }
- break;
- }
+ j++;
+ if (negate) {
+ mp->read &= ~flag;
+ } else {
+ mp->read |= flag;
+ }
+ switch (flag) {
+ case M_TAG:
+ if (All(ms)) {
+ if (!notified) {
+ notify_format(player,
+ T("MAIL: All messages in all folders %s."),
+ negate ? "untagged" : "tagged");
+ notified++;
+ }
+ } else
+ notify_format(player,
+ "MAIL: Msg #%d:%d %s.", Folder(mp),
+ i[Folder(mp)], negate ? "untagged" : "tagged");
+ break;
+ case M_CLEARED:
+ if (All(ms)) {
+ if (!notified) {
+ notify_format(player,
+ T("MAIL: All messages in all folders %s."),
+ negate ? "uncleared" : "cleared");
+ notified++;
+ }
+ } else {
+ if (Unread(mp) && !negate) {
+ notify_format(player,
+ T
+ ("MAIL: Unread Msg #%d:%d cleared! Use @mail/unclear %d:%d to recover."),
+ Folder(mp), i[Folder(mp)], Folder(mp),
+ i[Folder(mp)]);
+ } else {
+ notify_format(player,
+ (negate ? T("MAIL: Msg #%d:%d uncleared.") :
+ T("MAIL: Msg #%d:%d cleared.")), Folder(mp),
+ i[Folder(mp)]);
+ }
+ }
+ break;
+ }
}
}
}
if ((mp->to == player) && (All(ms) || (Folder(mp) == origfold))) {
i[Folder(mp)]++;
if (mail_match(player, mp, ms, i[Folder(mp)])) {
- j++;
- mp->read &= M_FMASK; /* Clear the folder */
- mp->read &= ~M_CLEARED; /* Unclear it if it was marked cleared */
- mp->read |= FolderBit(foldernum);
- if (All(ms)) {
- if (!notified) {
- notify_format(player,
- T("MAIL: All messages filed in folder %d [%s]"),
- foldernum, get_folder_name(player, foldernum));
- notified++;
- }
- } else
- notify_format(player,
- T("MAIL: Msg %d:%d filed in folder %d [%s]"),
- origfold, i[origfold], foldernum,
- get_folder_name(player, foldernum));
+ j++;
+ mp->read &= M_FMASK; /* Clear the folder */
+ mp->read &= ~M_CLEARED; /* Unclear it if it was marked cleared */
+ mp->read |= FolderBit(foldernum);
+ if (All(ms)) {
+ if (!notified) {
+ notify_format(player,
+ T("MAIL: All messages filed in folder %d [%s]"),
+ foldernum, get_folder_name(player, foldernum));
+ notified++;
+ }
+ } else
+ notify_format(player,
+ T("MAIL: Msg %d:%d filed in folder %d [%s]"),
+ origfold, i[origfold], foldernum,
+ get_folder_name(player, foldernum));
}
}
}
if ((mp->to == player) && (All(ms) || Folder(mp) == folder)) {
i[Folder(mp)]++;
if (mail_match(player, mp, ms, i[Folder(mp)])) {
- /* Read it */
- j++;
- if (SUPPORT_PUEBLO) {
- notify_noenter(player, tprintf("%cSAMP%c", TAG_START, TAG_END));
- sprintf(folderheader,
- "%cA XCH_HINT=\"List messages in this folder\" XCH_CMD=\"@mail/list %d:1-\"%c%s%c/A%c",
- TAG_START, Folder(mp), TAG_END, T("Folder:"), TAG_START,
- TAG_END);
- } else
- strcpy(folderheader, T("Folder:"));
- notify(player, DASH_LINE);
- strcpy(tbuf1, get_sender(mp, 1));
- notify_format(player,
- T
- ("From: %-55s %s\nDate: %-25s %s %2d Message: %d\nStatus: %s"),
- tbuf1, ((*tbuf1 != '!') && IsPlayer(mp->from)
- && Connected(mp->from)
- && (!hidden(mp->from)
- || Priv_Who(player))) ? " (Conn)" : " ",
- show_time(mp->time, 0), folderheader, Folder(mp),
- i[Folder(mp)], status_string(mp));
- notify_format(player, T("Subject: %s"), get_subject(mp));
- notify(player, DASH_LINE);
- if (SUPPORT_PUEBLO)
- notify_noenter(player, tprintf("%c/SAMP%c", TAG_START, TAG_END));
- strcpy(tbuf1, get_message(mp));
- notify(player, tbuf1);
- if (SUPPORT_PUEBLO)
- notify_format(player, "%cSAMP%c%s%c/SAMP%c", TAG_START, TAG_END,
- DASH_LINE, TAG_START, TAG_END);
- else
- notify(player, DASH_LINE);
- if (Unread(mp))
- mp->read |= M_MSGREAD; /* mark message as read */
+ /* Read it */
+ j++;
+ if (SUPPORT_PUEBLO) {
+ notify_noenter(player, tprintf("%cSAMP%c", TAG_START, TAG_END));
+ sprintf(folderheader,
+ "%cA XCH_HINT=\"List messages in this folder\" XCH_CMD=\"@mail/list %d:1-\"%c%s%c/A%c",
+ TAG_START, Folder(mp), TAG_END, T("Folder:"), TAG_START,
+ TAG_END);
+ } else
+ strcpy(folderheader, T("Folder:"));
+ notify(player, DASH_LINE);
+ strcpy(tbuf1, get_sender(mp, 1));
+ notify_format(player,
+ T
+ ("From: %-55s %s\nDate: %-25s %s %2d Message: %d\nStatus: %s"),
+ tbuf1, ((*tbuf1 != '!') && IsPlayer(mp->from)
+ && Connected(mp->from)
+ && (!hidden(mp->from)
+ || Priv_Who(player))) ? " (Conn)" : " ",
+ show_time(mp->time, 0), folderheader, Folder(mp),
+ i[Folder(mp)], status_string(mp));
+ notify_format(player, T("Subject: %s"), get_subject(mp));
+ notify(player, DASH_LINE);
+ if (SUPPORT_PUEBLO)
+ notify_noenter(player, tprintf("%c/SAMP%c", TAG_START, TAG_END));
+ strcpy(tbuf1, get_message(mp));
+ notify(player, tbuf1);
+ if (SUPPORT_PUEBLO)
+ notify_format(player, "%cSAMP%c%s%c/SAMP%c", TAG_START, TAG_END,
+ DASH_LINE, TAG_START, TAG_END);
+ else
+ notify(player, DASH_LINE);
+ if (Unread(mp))
+ mp->read |= M_MSGREAD; /* mark message as read */
}
}
}
if (SUPPORT_PUEBLO)
notify_noenter(player, tprintf("%cSAMP%c", TAG_START, TAG_END));
notify_format(player,
- T
- ("--------------------------- MAIL (folder %2d) ------------------------------"),
- folder);
+ T
+ ("--------------------------- MAIL (folder %2d) ------------------------------"),
+ folder);
for (mp = find_exact_starting_point(player); mp && (mp->to == player);
mp = mp->next) {
if ((mp->to == player) && (All(ms) || Folder(mp) == folder)) {
i[Folder(mp)]++;
if (mail_match(player, mp, ms, i[Folder(mp)])) {
- /* list it */
- if (SUPPORT_PUEBLO)
- notify_noenter(player,
- tprintf
- ("%cA XCH_CMD=\"@mail/read %d:%d\" XCH_HINT=\"Read message %d in folder %d\"%c",
- TAG_START, Folder(mp), i[Folder(mp)],
- i[Folder(mp)], Folder(mp), TAG_END));
- strcpy(subj, chopstr(get_subject(mp), 28));
- strcpy(sender, chopstr(get_sender(mp, 0), 12));
- notify_format(player, "[%s] %2d:%-3d %c%-12s %-*s %s",
- status_chars(mp), Folder(mp), i[Folder(mp)],
- ((*sender != '!') && (Connected(mp->from) &&
- (!hidden(mp->from)
- || Priv_Who(player)))
- ? '*' : ' '), sender, 30, subj,
- mail_list_time(show_time(mp->time, 0), 1));
- if (SUPPORT_PUEBLO)
- notify_noenter(player, tprintf("%c/A%c", TAG_START, TAG_END));
+ /* list it */
+ if (SUPPORT_PUEBLO)
+ notify_noenter(player,
+ tprintf
+ ("%cA XCH_CMD=\"@mail/read %d:%d\" XCH_HINT=\"Read message %d in folder %d\"%c",
+ TAG_START, Folder(mp), i[Folder(mp)],
+ i[Folder(mp)], Folder(mp), TAG_END));
+ strcpy(subj, chopstr(get_subject(mp), 28));
+ strcpy(sender, chopstr(get_sender(mp, 0), 12));
+ notify_format(player, "[%s] %2d:%-3d %c%-12s %-*s %s",
+ status_chars(mp), Folder(mp), i[Folder(mp)],
+ ((*sender != '!') && (Connected(mp->from) &&
+ (!hidden(mp->from)
+ || Priv_Who(player)))
+ ? '*' : ' '), sender, 30, subj,
+ mail_list_time(show_time(mp->time, 0), 1));
+ if (SUPPORT_PUEBLO)
+ notify_noenter(player, tprintf("%c/A%c", TAG_START, TAG_END));
}
}
}
if (!flag) {
for (i = 0; i < 3; i++) {
if (*p)
- p++;
+ p++;
}
for (i = 0; i < 5; i++) {
if (*p)
- *q++ = *p++;
+ *q++ = *p++;
}
}
*q = '\0';
/* Delete this one */
/* head and tail of the list are special */
if (mp == HEAD)
- HEAD = mp->next;
+ HEAD = mp->next;
else if (mp == TAIL)
- TAIL = mp->prev;
+ TAIL = mp->prev;
/* relink the list */
if (mp->prev != NULL)
- mp->prev->next = mp->next;
+ mp->prev->next = mp->next;
if (mp->next != NULL)
- mp->next->prev = mp->prev;
+ mp->next->prev = mp->prev;
/* save the pointer */
nextp = mp->next;
/* then wipe */
if ((mp->to == player) && (All(ms) || (Folder(mp) == folder))) {
i[Folder(mp)]++;
if (mail_match(player, mp, ms, i[Folder(mp)])) {
- /* forward it to all players listed */
- head = tolist;
- while (head && *head) {
- current = next_in_list(start);
- /* Now locate a target */
- num = atoi(current);
- if (num) {
- /* reply to a mail message */
- temp = mail_fetch(player, num);
- if (!temp) {
- notify(player, T("MAIL: You can't reply to nonexistant mail."));
- } else {
- char tbuf1[BUFFER_LEN];
- unsigned char tbuf2[BUFFER_LEN];
- strcpy(tbuf1, uncompress(mp->subject));
- u_strcpy(tbuf2, get_compressed_message(mp));
- send_mail(player, temp->from, tbuf1, (char *) tbuf2,
- M_FORWARD | M_REPLY, 1, 0);
- num_recpts++;
- }
- } else {
- /* forwarding to a player */
- target =
- match_result(player, current, TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
- if (!GoodObject(target))
- target = lookup_player(current);
- if (!GoodObject(target))
- target = short_page(current);
- if (!GoodObject(target) || !IsPlayer(target)) {
- notify_format(player, T("No such unique player: %s."), current);
- } else {
- char tbuf1[BUFFER_LEN];
- unsigned char tbuf2[BUFFER_LEN];
- strcpy(tbuf1, uncompress(mp->subject));
- u_strcpy(tbuf2, get_compressed_message(mp));
- send_mail(player, target, tbuf1, (char *) tbuf2, M_FORWARD, 1, 0);
- num_recpts++;
- }
- }
- }
+ /* forward it to all players listed */
+ head = tolist;
+ while (head && *head) {
+ current = next_in_list(start);
+ /* Now locate a target */
+ num = atoi(current);
+ if (num) {
+ /* reply to a mail message */
+ temp = mail_fetch(player, num);
+ if (!temp) {
+ notify(player, T("MAIL: You can't reply to nonexistant mail."));
+ } else {
+ char tbuf1[BUFFER_LEN];
+ unsigned char tbuf2[BUFFER_LEN];
+ strcpy(tbuf1, uncompress(mp->subject));
+ u_strcpy(tbuf2, get_compressed_message(mp));
+ send_mail(player, temp->from, tbuf1, (char *) tbuf2,
+ M_FORWARD | M_REPLY, 1, 0);
+ num_recpts++;
+ }
+ } else {
+ /* forwarding to a player */
+ target =
+ match_result(player, current, TYPE_PLAYER,
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
+ if (!GoodObject(target))
+ target = lookup_player(current);
+ if (!GoodObject(target))
+ target = short_page(current);
+ if (!GoodObject(target) || !IsPlayer(target)) {
+ notify_format(player, T("No such unique player: %s."), current);
+ } else {
+ char tbuf1[BUFFER_LEN];
+ unsigned char tbuf2[BUFFER_LEN];
+ strcpy(tbuf1, uncompress(mp->subject));
+ u_strcpy(tbuf2, get_compressed_message(mp));
+ send_mail(player, target, tbuf1, (char *) tbuf2, M_FORWARD, 1, 0);
+ num_recpts++;
+ }
+ }
+ }
}
}
mp = mp->next;
*/
void
do_mail_send(dbref player, char *tolist, char *message, mail_flag flags,
- int silent, int nosig)
+ int silent, int nosig)
{
const char *head;
int num;
return;
}
sb = sbuf;
- mb = message; /* Save the message pointer */
+ mb = message; /* Save the message pointer */
while (*message && (i < SUBJECT_LEN) && *message != SUBJECT_COOKIE) {
*sb++ = *message++;
i++;
message++;
subject_given = 1;
} else
- message = mb; /* Rewind the pointer to the beginning */
+ message = mb; /* Rewind the pointer to the beginning */
#ifdef ALLOW_NOSUBJECT
if (!subject_given)
strcpy(sbuf, T("(no subject)"));
temp = mail_fetch(player, num);
if (!temp) {
- notify(player, T("MAIL: You can't reply to nonexistent mail."));
- return;
+ notify(player, T("MAIL: You can't reply to nonexistent mail."));
+ return;
}
if (subject_given)
- send_mail(player, temp->from, sbuf, message, mail_flags, silent, nosig);
+ send_mail(player, temp->from, sbuf, message, mail_flags, silent, nosig);
else
- send_mail(player, temp->from, uncompress(temp->subject), message,
- mail_flags | M_REPLY, silent, nosig);
+ send_mail(player, temp->from, uncompress(temp->subject), message,
+ mail_flags | M_REPLY, silent, nosig);
} else {
/* send a new mail message */
target =
- match_result(player, current, TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
+ match_result(player, current, TYPE_PLAYER,
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
if (!GoodObject(target))
- target = lookup_player(current);
+ target = lookup_player(current);
if (!GoodObject(target))
- target = short_page(current);
+ target = short_page(current);
if (!GoodObject(target) || !IsPlayer(target)) {
- if (!send_mail_alias
- (player, current, sbuf, message, mail_flags, silent, nosig))
- notify_format(player, T("No such unique player: %s."), current);
+ if (!send_mail_alias
+ (player, current, sbuf, message, mail_flags, silent, nosig))
+ notify_format(player, T("No such unique player: %s."), current);
} else
- send_mail(player, target, sbuf, message, mail_flags, silent, nosig);
+ send_mail(player, target, sbuf, message, mail_flags, silent, nosig);
}
}
}
mp && (mp->to == player); mp = mp->next) {
if ((mp->to == player) && ((folder == -1) || (Folder(mp) == folder))) {
if (Cleared(mp))
- cc++;
+ cc++;
else if (Read(mp))
- rc++;
+ rc++;
else
- uc++;
+ uc++;
}
}
*rcount = rc;
static void
send_mail(dbref player, dbref target, char *subject, char *message,
- mail_flag flags, int silent, int nosig)
+ mail_flag flags, int silent, int nosig)
{
/* send a message to a target, consulting the target's mailforward.
* If mailforward isn't set, just deliver to targt.
fwdstr = trim_space_sep(orig, ' ');
while ((curr = split_token(&fwdstr, ' ')) != NULL) {
if (is_objid(curr)) {
- fwd = parse_objid(curr);
- if (GoodObject(fwd) && Can_MailForward(target, fwd)) {
- good +=
- real_send_mail(player, fwd, subject, message, flags, 1, nosig);
- } else
- notify_format(target, T("Failed attempt to forward @mail to #%d"),
- fwd);
+ fwd = parse_objid(curr);
+ if (GoodObject(fwd) && Can_MailForward(target, fwd)) {
+ good +=
+ real_send_mail(player, fwd, subject, message, flags, 1, nosig);
+ } else
+ notify_format(target, T("Failed attempt to forward @mail to #%d"),
+ fwd);
}
}
free((Malloc_t) orig);
if (!silent) {
if (good)
notify_format(player,
- T("MAIL: You sent your message to %s."), Name(target));
+ T("MAIL: You sent your message to %s."), Name(target));
else
notify_format(player,
- T
- ("MAIL: Your message was not sent to %s due to a mail forwarding problem."),
- Name(target));
+ T
+ ("MAIL: Your message was not sent to %s due to a mail forwarding problem."),
+ Name(target));
}
}
}
if (!strcasecmp(message, "clear")) {
notify(player,
- T("MAIL: You probably don't wanna send mail saying 'clear'."));
+ T("MAIL: You probably don't wanna send mail saying 'clear'."));
return 0;
}
if (!(Admin(player) || eval_lock(player, target, Mail_Lock))) {
notify_format(player,
- T("MAIL: %s is not accepting mail from you right now."),
- Name(target));
+ T("MAIL: %s is not accepting mail from you right now."),
+ Name(target));
return 0;
}
count_mail(target, 0, &rc, &uc, &cc);
if ((rc + uc + cc) >= MAIL_LIMIT) {
notify_format(player, T("MAIL: %s's mailbox is full. Can't send."),
- Name(target));
+ Name(target));
return 0;
}
/* Append the MAILSIGNATURE to the mail - Cordin@Dune's idea */
buff = (char *) mush_malloc(BUFFER_LEN, "string");
if (!buff)
- mush_panic(T("Failed to allocate string in send_mail"));
+ mush_panic(T("Failed to allocate string in send_mail"));
ms = mailsig = safe_atr_value(a);
bp = buff;
process_expression(buff, &bp, &ms, player, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free(mailsig);
safe_str(buff, newmsg, &nm);
}
newp->time = mudtime;
- newp->read = flags & M_FMASK; /* Send to folder 0 */
+ newp->read = flags & M_FMASK; /* Send to folder 0 */
/* Where do we insert it? After mp, wherever that is.
* This can return NULL if there are no messages or
/* notify people */
if (!silent)
notify_format(player,
- T("MAIL: You sent your message to %s."), Name(target));
+ T("MAIL: You sent your message to %s."), Name(target));
notify_format(target,
- T("MAIL: You have a new message (%d) from %s."),
- rc + uc + cc + 1, Name(player));
+ T("MAIL: You have a new message (%d) from %s."),
+ rc + uc + cc + 1, Name(player));
/* Check @mailfilter */
filter_mail(player, target, subject, message, rc + uc + cc + 1, flags);
desc_mail_clear();
do_log(LT_ERR, 0, 0, T("** MAIL PURGE ** done by %s(#%d)."),
- Name(player), player);
+ Name(player), player);
notify(player, T("You annihilate the post office. All messages cleared."));
}
} else if (string_prefix("sanity", action)) {
for (i = 0, mp = HEAD; mp != NULL; i++, mp = mp->next) {
if (!GoodObject(mp->to))
- notify_format(player, T("Bad object #%d has mail."), mp->to);
+ notify_format(player, T("Bad object #%d has mail."), mp->to);
else if (!IsPlayer(mp->to))
- notify_format(player, T("%s(#%d) has mail but is not a player."),
- Name(mp->to), mp->to);
+ notify_format(player, T("%s(#%d) has mail but is not a player."),
+ Name(mp->to), mp->to);
}
if (i != mdb_top) {
notify_format(player,
- T
- ("Mail database top is %d, actual message count is %d. Fixing."),
- mdb_top, i);
+ T
+ ("Mail database top is %d, actual message count is %d. Fixing."),
+ mdb_top, i);
mdb_top = i;
}
notify(player, T("Mail sanity check completed."));
} else if (string_prefix("fix", action)) {
for (i = 0, mp = HEAD; mp != NULL; i++, mp = nextp) {
if (!GoodObject(mp->to) || !IsPlayer(mp->to)) {
- notify_format(player, T("Fixing mail for #%d."), mp->to);
- /* Delete this one */
- /* head and tail of the list are special */
- if (mp == HEAD)
- HEAD = mp->next;
- else if (mp == TAIL)
- TAIL = mp->prev;
- /* relink the list */
- if (mp->prev != NULL)
- mp->prev->next = mp->next;
- if (mp->next != NULL)
- mp->next->prev = mp->prev;
- /* save the pointer */
- nextp = mp->next;
- /* then wipe */
- mdb_top--;
- if (mp->subject)
- free(mp->subject);
- chunk_delete(mp->msgid);
- mush_free((Malloc_t) mp, "mail");
+ notify_format(player, T("Fixing mail for #%d."), mp->to);
+ /* Delete this one */
+ /* head and tail of the list are special */
+ if (mp == HEAD)
+ HEAD = mp->next;
+ else if (mp == TAIL)
+ TAIL = mp->prev;
+ /* relink the list */
+ if (mp->prev != NULL)
+ mp->prev->next = mp->next;
+ if (mp->next != NULL)
+ mp->next->prev = mp->prev;
+ /* save the pointer */
+ nextp = mp->next;
+ /* then wipe */
+ mdb_top--;
+ if (mp->subject)
+ free(mp->subject);
+ chunk_delete(mp->msgid);
+ mush_free((Malloc_t) mp, "mail");
} else if (!GoodObject(mp->from)) {
- /* Oops, it's from a player whose dbref is out of range!
- * We'll make it appear to be from #0 instead because there's
- * no really good choice
- */
- mp->from = 0;
- nextp = mp->next;
+ /* Oops, it's from a player whose dbref is out of range!
+ * We'll make it appear to be from #0 instead because there's
+ * no really good choice
+ */
+ mp->from = 0;
+ nextp = mp->next;
} else {
- nextp = mp->next;
+ nextp = mp->next;
}
}
notify(player, T("Mail sanity fix completed."));
if (!payfor(player, FIND_COST)) {
notify_format(player, T("Finding mail stats costs %d %s."), FIND_COST,
- (FIND_COST == 1) ? MONEY : MONIES);
+ (FIND_COST == 1) ? MONEY : MONIES);
return;
}
- if (target == AMBIGUOUS) { /* stats for all */
+ if (target == AMBIGUOUS) { /* stats for all */
if (full == MSTATS_COUNT) {
notify_format(player,
- T("There are %d messages in the mail spool."), mdb_top);
+ T("There are %d messages in the mail spool."), mdb_top);
return;
} else if (full == MSTATS_READ) {
for (mp = HEAD; mp != NULL; mp = mp->next) {
- if (Cleared(mp))
- fc++;
- else if (Read(mp))
- fr++;
- else
- fu++;
+ if (Cleared(mp))
+ fc++;
+ else if (Read(mp))
+ fr++;
+ else
+ fu++;
}
notify_format(player,
- T
- ("MAIL: There are %d msgs in the mail spool, %d unread, %d cleared."),
- fc + fr + fu, fu, fc);
+ T
+ ("MAIL: There are %d msgs in the mail spool, %d unread, %d cleared."),
+ fc + fr + fu, fu, fc);
return;
} else {
for (mp = HEAD; mp != NULL; mp = mp->next) {
- if (Cleared(mp)) {
- fc++;
- cchars += strlen(get_message(mp));
- } else if (Read(mp)) {
- fr++;
- fchars += strlen(get_message(mp));
- } else {
- fu++;
- tchars += strlen(get_message(mp));
- }
+ if (Cleared(mp)) {
+ fc++;
+ cchars += strlen(get_message(mp));
+ } else if (Read(mp)) {
+ fr++;
+ fchars += strlen(get_message(mp));
+ } else {
+ fu++;
+ tchars += strlen(get_message(mp));
+ }
}
notify_format(player,
- T
- ("MAIL: There are %d old msgs in the mail spool, totalling %d characters."),
- fr, fchars);
+ T
+ ("MAIL: There are %d old msgs in the mail spool, totalling %d characters."),
+ fr, fchars);
notify_format(player,
- T
- ("MAIL: There are %d new msgs in the mail spool, totalling %d characters."),
- fu, tchars);
+ T
+ ("MAIL: There are %d new msgs in the mail spool, totalling %d characters."),
+ fu, tchars);
notify_format(player,
- ("MAIL: There are %d cleared msgs in the mail spool, totalling %d characters."),
- fc, cchars);
+ ("MAIL: There are %d cleared msgs in the mail spool, totalling %d characters."),
+ fc, cchars);
return;
}
}
/* just count number of messages */
for (mp = HEAD; mp != NULL; mp = mp->next) {
if (was_sender(target, mp))
- fr++;
+ fr++;
if (mp->to == target)
- tr++;
+ tr++;
}
notify_format(player, T("%s sent %d messages."), Name(target), fr);
notify_format(player, T("%s has %d messages."), Name(target), tr);
for (mp = HEAD; mp != NULL; mp = mp->next) {
if (was_sender(target, mp)) {
if (Cleared(mp))
- fc++;
+ fc++;
else if (Read(mp))
- fr++;
+ fr++;
else
- fu++;
+ fu++;
if (full == MSTATS_SIZE)
- fchars += strlen(get_message(mp));
+ fchars += strlen(get_message(mp));
}
if (mp->to == target) {
if (!tr && !tu)
- strcpy(last, show_time(mp->time, 0));
+ strcpy(last, show_time(mp->time, 0));
if (Cleared(mp))
- tc++;
+ tc++;
else if (Read(mp))
- tr++;
+ tr++;
else
- tu++;
+ tu++;
if (full == MSTATS_SIZE)
- tchars += strlen(get_message(mp));
+ tchars += strlen(get_message(mp));
}
}
if (full == MSTATS_READ) {
notify_format(player, T("%d messages sent, %d unread, %d cleared."),
- fc + fr + fu, fu, fc);
+ fc + fr + fu, fu, fc);
notify_format(player, T("%d messages received, %d unread, %d cleared."),
- tc + tr + tu, tu, tc);
+ tc + tr + tu, tu, tc);
} else {
notify_format(player,
- T
- ("%d messages sent, %d unread, %d cleared, totalling %d characters."),
- fc + fr + fu, fu, fc, fchars);
+ T
+ ("%d messages sent, %d unread, %d cleared, totalling %d characters."),
+ fc + fr + fu, fu, fc, fchars);
notify_format(player,
- T
- ("%d messages received, %d unread, %d cleared, totalling %d characters."),
- tc + tr + tu, tu, tc, tchars);
+ T
+ ("%d messages received, %d unread, %d cleared, totalling %d characters."),
+ tc + tr + tu, tu, tc, tchars);
}
if (tc + tr + tu > 0)
} else {
/* Must be reading or listing mail - no arg2 */
if (((p = strchr(arg1, ':')) && (*(p + 1) == '\0'))
- || !(isdigit((unsigned char) *arg1) && !strchr(arg1, '-')))
+ || !(isdigit((unsigned char) *arg1) && !strchr(arg1, '-')))
do_mail_list(player, arg1);
else
do_mail_read(player, arg1);
if (!is_integer(args[0])) {
/* handle the case of wanting to count the number of messages */
if ((player =
- noisy_match_result(executor, args[0], TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
- safe_str(T("#-1 NO SUCH PLAYER"), buff, bp);
- return;
+ noisy_match_result(executor, args[0], TYPE_PLAYER,
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
+ safe_str(T("#-1 NO SUCH PLAYER"), buff, bp);
+ return;
} else if ((executor != player) && !MailAdmin(executor, player)) {
- safe_str(T(e_perm), buff, bp);
- return;
+ safe_str(T(e_perm), buff, bp);
+ return;
} else {
- count_mail(player, player_folder(player), &rc, &uc, &cc);
+ count_mail(player, player_folder(player), &rc, &uc, &cc);
}
} else {
count_mail(executor, parse_integer(args[0]), &rc, &uc, &cc);
break;
case 2:
if ((player =
- noisy_match_result(executor, args[0], TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
+ noisy_match_result(executor, args[0], TYPE_PLAYER,
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
safe_str(T("#-1 NO SUCH PLAYER"), buff, bp);
return;
} else if ((executor != player) && !MailAdmin(executor, player)) {
if (nargs == 1) {
player =
match_result(executor, args[0], TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER);
if (GoodObject(player)) {
if ((executor != player) && !MailAdmin(executor, player)) {
- safe_str(T(e_perm), buff, bp);
+ safe_str(T(e_perm), buff, bp);
} else {
- count_mail(player, -1, &rc, &uc, &cc);
- safe_integer(rc, buff, bp);
- safe_chr(' ', buff, bp);
- safe_integer(uc, buff, bp);
- safe_chr(' ', buff, bp);
- safe_integer(cc, buff, bp);
+ count_mail(player, -1, &rc, &uc, &cc);
+ safe_integer(rc, buff, bp);
+ safe_chr(' ', buff, bp);
+ safe_integer(uc, buff, bp);
+ safe_chr(' ', buff, bp);
+ safe_integer(cc, buff, bp);
}
return;
}
} else {
/* Both a target and a message */
if ((target =
- noisy_match_result(player, arg1, TYPE_PLAYER,
- MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
+ noisy_match_result(player, arg1, TYPE_PLAYER,
+ MAT_ME | MAT_ABSOLUTE | MAT_PLAYER)) == NOTHING) {
return NULL;
} else if ((player != target) && !MailAdmin(player, target)) {
notify(player, T("Permission denied"));
if (!payfor(executor, FIND_COST)) {
notify_format(executor, T("Finding mail stats costs %d %s."), FIND_COST,
- (FIND_COST == 1) ? MONEY : MONIES);
+ (FIND_COST == 1) ? MONEY : MONIES);
return;
}
- if (target == AMBIGUOUS) { /* stats for all */
+ if (target == AMBIGUOUS) { /* stats for all */
if (full == 0) {
/* FORMAT
* total mail
return;
} else if (full == 1) {
for (mp = HEAD; mp != NULL; mp = mp->next) {
- if (Cleared(mp))
- fc++;
- else if (Read(mp))
- fr++;
- else
- fu++;
+ if (Cleared(mp))
+ fc++;
+ else if (Read(mp))
+ fr++;
+ else
+ fu++;
}
/* FORMAT
* sent, sent_unread, sent_cleared
safe_format(buff, bp, "%d %d %d", fc + fr + fu, fu, fc);
} else {
for (mp = HEAD; mp != NULL; mp = mp->next) {
- if (Cleared(mp)) {
- fc++;
- cchars += strlen(get_message(mp));
- } else if (Read(mp)) {
- fr++;
- fchars += strlen(get_message(mp));
- } else {
- fu++;
- tchars += strlen(get_message(mp));
- }
+ if (Cleared(mp)) {
+ fc++;
+ cchars += strlen(get_message(mp));
+ } else if (Read(mp)) {
+ fr++;
+ fchars += strlen(get_message(mp));
+ } else {
+ fu++;
+ tchars += strlen(get_message(mp));
+ }
}
/* FORMAT
* sent_read, sent_read_characters,
* sent_clear, sent_clear_characters
*/
safe_format(buff, bp, "%d %d %d %d %d %d",
- fr, fchars, fu, tchars, fc, cchars);
+ fr, fchars, fu, tchars, fc, cchars);
return;
}
}
/* just count number of messages */
for (mp = HEAD; mp != NULL; mp = mp->next) {
if (was_sender(target, mp))
- fr++;
+ fr++;
if (mp->to == target)
- tr++;
+ tr++;
}
/* FORMAT
* sent, received
for (mp = HEAD; mp != NULL; mp = mp->next) {
if (was_sender(target, mp)) {
if (Cleared(mp))
- fc++;
+ fc++;
else if (Read(mp))
- fr++;
+ fr++;
else
- fu++;
+ fu++;
if (full == 2)
- fchars += strlen(get_message(mp));
+ fchars += strlen(get_message(mp));
}
if (mp->to == target) {
if (!tr && !tu)
- strcpy(last, show_time(mp->time, 0));
+ strcpy(last, show_time(mp->time, 0));
if (Cleared(mp))
- tc++;
+ tc++;
else if (Read(mp))
- tr++;
+ tr++;
else
- tu++;
+ tu++;
if (full == 2)
- tchars += strlen(get_message(mp));
+ tchars += strlen(get_message(mp));
}
}
* received, rec_unread, rec_cleared
*/
safe_format(buff, bp, "%d %d %d %d %d %d",
- fc + fr + fu, fu, fc, tc + tr + tu, tu, tc);
+ fc + fr + fu, fu, fc, tc + tr + tu, tu, tc);
} else {
/* FORMAT
* sent, sent_unread, sent_cleared, sent_bytes
* received, rec_unread, rec_cleared, rec_bytes
*/
safe_format(buff, bp, "%d %d %d %d %d %d %d %d",
- fc + fr + fu, fu, fc, fchars, tc + tr + tu, tu, tc, tchars);
+ fc + fr + fu, fu, fc, fchars, tc + tr + tu, tu, tc, tchars);
}
}
if (count != mdb_top) {
do_log(LT_ERR, 0, 0, T("MAIL: Count of messages is %d, mdb_top is %d."),
- count, mdb_top);
- mdb_top = count; /* Doesn't help if we forked, but oh well */
+ count, mdb_top);
+ mdb_top = count; /* Doesn't help if we forked, but oh well */
}
return (count);
}
* has mail - we have to scan the maildb.
*/
if (HEAD->to > player)
- return NULL; /* No mail chain */
+ return NULL; /* No mail chain */
for (mp = HEAD; mp && (mp->to < player); mp = mp->next) ;
} else {
while (mp && (mp->to >= player))
* has mail - we have to scan the maildb.
*/
if (HEAD->to > player)
- return NULL; /* No mail chain */
+ return NULL; /* No mail chain */
for (mp = TAIL; mp && (mp->to > player); mp = mp->prev) ;
} else {
while (mp && (mp->to <= player))
char buff[20];
fgets(buff, sizeof buff, fp);
if (!*buff)
- do_rawlog(LT_ERR,
- T("MAIL: Missing end-of-dump marker in mail database."));
+ do_rawlog(LT_ERR,
+ T("MAIL: Missing end-of-dump marker in mail database."));
else if (strcmp(buff, (mail_flags & MDBF_NEW_EOD)
- ? "***END OF DUMP***\n" : "*** END OF DUMP ***\n") == 0)
- return 1;
+ ? "***END OF DUMP***\n" : "*** END OF DUMP ***\n") == 0)
+ return 1;
else
- do_rawlog(LT_ERR, T("MAIL: Trailing garbage in the mail database."));
+ do_rawlog(LT_ERR, T("MAIL: Trailing garbage in the mail database."));
}
return 0;
}
if (mail_flags & MDBF_SENDERCTIME)
mp->from_ctime = getref(fp);
else
- mp->from_ctime = 0; /* No one will have this creation time */
+ mp->from_ctime = 0; /* No one will have this creation time */
if (do_convtime(getstring_noalloc(fp), &ttm))
mp->time = mktime(&ttm);
if (mail_flags & MDBF_SENDERCTIME)
mp->from_ctime = getref(fp);
else
- mp->from_ctime = 0; /* No one will have this creation time */
+ mp->from_ctime = 0; /* No one will have this creation time */
if (do_convtime(getstring_noalloc(fp), &ttm))
mp->time = mktime(&ttm);
else /* do_convtime failed. Odd. */
/* Search for where to put it */
mp->prev = NULL;
for (done = 0, tmpmp = HEAD; tmpmp && !done; tmpmp = tmpmp->next) {
- if (tmpmp->to > mp->to) {
- /* Insert before tmpmp */
- mp->next = tmpmp;
- mp->prev = tmpmp->prev;
- if (tmpmp->prev) {
- /* tmpmp isn't HEAD */
- tmpmp->prev->next = mp;
- } else {
- /* tmpmp is HEAD */
- HEAD = mp;
- }
- tmpmp->prev = mp;
- done = 1;
- }
+ if (tmpmp->to > mp->to) {
+ /* Insert before tmpmp */
+ mp->next = tmpmp;
+ mp->prev = tmpmp->prev;
+ if (tmpmp->prev) {
+ /* tmpmp isn't HEAD */
+ tmpmp->prev->next = mp;
+ } else {
+ /* tmpmp is HEAD */
+ HEAD = mp;
+ }
+ tmpmp->prev = mp;
+ done = 1;
+ }
}
if (!done) {
- /* This is bad */
- do_rawlog(LT_ERR, T("MAIL: bad code."));
+ /* This is bad */
+ do_rawlog(LT_ERR, T("MAIL: bad code."));
}
}
}
if (i != mail_top) {
do_rawlog(LT_ERR, T("MAIL: mail_top is %d, only read in %d messages."),
- mail_top, i);
+ mail_top, i);
}
{
char buff[20];
fgets(buff, sizeof buff, fp);
if (!*buff)
do_rawlog(LT_ERR,
- T("MAIL: Missing end-of-dump marker in mail database."));
+ T("MAIL: Missing end-of-dump marker in mail database."));
else if (strcmp(buff, (mail_flags & MDBF_NEW_EOD)
- ? EOD : "*** END OF DUMP ***\n") != 0)
+ ? EOD : "*** END OF DUMP ***\n") != 0)
/* There's still stuff. Icky. */
do_rawlog(LT_ERR, T("MAIL: Trailing garbage in the mail database."));
}
while (!isspace((unsigned char) *r))
r++;
*r = '\0';
- res = replace_string(old, new, tbuf); /* mallocs mem! */
+ res = replace_string(old, new, tbuf); /* mallocs mem! */
} else {
r = res = (char *) mush_malloc(BUFFER_LEN + 1, "replace_string.buff");
if (a)
}
/* put the attrib back */
(void) atr_add(player, "MAILFOLDERS", res, GOD,
- AF_NOPROG | AF_LOCKED);
+ AF_NOPROG | AF_LOCKED);
mush_free((Malloc_t) res, "replace_string.buff");
mush_free((Malloc_t) new, "string");
mush_free((Malloc_t) pat, "string");
a = (ATTR *) atr_match("MAILCURF");
if (a)
(void) atr_add(player, a->name, tbuf1, GOD, a->flags);
- else /* Shouldn't happen, but... */
+ else /* Shouldn't happen, but... */
(void) atr_add(player, "MAILCURF", tbuf1, GOD,
- AF_NOPROG | AF_LOCKED);
+ AF_NOPROG | AF_LOCKED);
}
static int
p++;
if (!p || !*p) {
ms->flags |= M_FOLDER;
- return 1; /* all messages in current folder */
+ return 1; /* all messages in current folder */
}
if (isdigit((unsigned char) *p) || *p == '-') {
if (!parse_message_spec(player, p, &ms->low, &ms->high, &folder)) {
void
check_mail(dbref player, int folder, int silent)
{
- int rc; /* read messages */
- int uc; /* unread messages */
- int cc; /* cleared messages */
+ int rc; /* read messages */
+ int uc; /* unread messages */
+ int cc; /* cleared messages */
int total;
/* just count messages */
total = rc + uc + cc;
if (total > 0)
notify_format(player,
- T
- ("MAIL: %d messages in folder %d [%s] (%d unread, %d cleared)."),
- total, folder, get_folder_name(player, folder), uc, cc);
+ T
+ ("MAIL: %d messages in folder %d [%s] (%d unread, %d cleared)."),
+ total, folder, get_folder_name(player, folder), uc, cc);
else if (!silent)
notify(player, T("\nMAIL: You have no mail.\n"));
if ((folder == 0) && (total + 5 > MAIL_LIMIT))
notify_format(player, T("MAIL: Warning! Limit on inbox messages is %d!"),
- MAIL_LIMIT);
+ MAIL_LIMIT);
return;
}
*/
static int
parse_message_spec(dbref player, const char *s, int *msglow, int *msghigh,
- int *folder)
+ int *folder)
{
char buf[BUFFER_LEN];
char *p, *q;
/* f:low-high */
*q++ = '\0';
if (!*p)
- *msglow = 0;
+ *msglow = 0;
else if (!is_integer(p))
- return 0;
+ return 0;
else {
- *msglow = parse_integer(p);
- if (*msglow == 0)
- *msglow = -1;
+ *msglow = parse_integer(p);
+ if (*msglow == 0)
+ *msglow = -1;
}
if (!*q)
- *msghigh = 0;
+ *msghigh = 0;
else if (!is_integer(q))
- return 0;
+ return 0;
else {
- *msghigh = parse_integer(q);
- if (*msghigh == 0)
- *msghigh = -1;
+ *msghigh = parse_integer(q);
+ if (*msghigh == 0)
+ *msghigh = -1;
}
} else {
/* f:m */
if (!*p) {
- /* f: */
- *msglow = 0;
- if (msghigh)
- *msghigh = HUGE_INT;
+ /* f: */
+ *msglow = 0;
+ if (msghigh)
+ *msghigh = HUGE_INT;
} else {
- if (!is_integer(p))
- return 0;
- *msglow = parse_integer(p);
- if (*msglow == 0)
- *msglow = -1;
- if (msghigh)
- *msghigh = *msglow;
+ if (!is_integer(p))
+ return 0;
+ *msglow = parse_integer(p);
+ if (*msglow == 0)
+ *msglow = -1;
+ if (msghigh)
+ *msghigh = *msglow;
}
}
if (*msglow < 0 || (msghigh && *msghigh < 0) || *folder < 0
- || *folder > MAX_FOLDERS)
+ || *folder > MAX_FOLDERS)
return 0;
} else {
/* No folder spec */
/* low-high */
*q++ = '\0';
if (!*buf)
- *msglow = 0;
+ *msglow = 0;
else if (!is_integer(buf))
- return 0;
+ return 0;
else {
- *msglow = parse_integer(buf);
- if (*msglow == 0)
- *msglow = -1;
+ *msglow = parse_integer(buf);
+ if (*msglow == 0)
+ *msglow = -1;
}
if (!*q)
- *msghigh = 0;
+ *msghigh = 0;
else if (!is_integer(q))
- return 0;
+ return 0;
else {
- *msghigh = parse_integer(q);
- if (*msghigh == 0)
- *msghigh = -1;
+ *msghigh = parse_integer(q);
+ if (*msghigh == 0)
+ *msghigh = -1;
}
} else {
/* m */
if (!is_integer(buf))
- return 0;
+ return 0;
*msglow = parse_integer(buf);
if (*msglow == 0)
- *msglow = -1;
+ *msglow = -1;
if (msghigh)
- *msghigh = *msglow;
+ *msghigh = *msglow;
}
if (*msglow < 0 || (msghigh && *msghigh < 0))
return 0;
static int
send_mail_alias(dbref player, char *aname, char *subject, char *message,
- mail_flag flags, int silent, int nosig)
+ mail_flag flags, int silent, int nosig)
{
struct mail_alias *m;
int i;
return 0;
/* Is it an alias they can use? */
if (!((m->owner == player) || (m->nflags == 0) ||
- (Admin(player)) ||
- ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))))
+ (Admin(player)) ||
+ ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))))
return 0;
/* If they are not allowed to see the people on the alias, then
* we must treat this as a case of silent mailing.
*/
if (!((m->owner == player) || (m->mflags == 0) ||
- (Admin(player)) ||
- ((m->mflags & ALIAS_MEMBERS) && ismember(m, player)))) {
+ (Admin(player)) ||
+ ((m->mflags & ALIAS_MEMBERS) && ismember(m, player)))) {
silent = 1;
notify_format(player,
- T("You sent your message to the '%s' alias"), m->name);
+ T("You sent your message to the '%s' alias"), m->name);
}
for (i = 0; i < m->size; i++) {
send_mail(player, m->members[i], subject, message, flags, silent, nosig);
}
- return 1; /* Success */
+ return 1; /* Success */
}
/** Event for @mailfilter.
*/
void
filter_mail(dbref from, dbref player, char *subject,
- char *message, int mailnumber, mail_flag flags)
+ char *message, int mailnumber, mail_flag flags)
{
ATTR *f;
char buff[BUFFER_LEN], *bp, *asave;
restore_global_regs("filter_mail", rsave);
}
-#endif /* USE_MAILER */
+#endif /* USE_MAILER */
#include "log.h"
#include "confmagic.h"
-extern char confname[BUFFER_LEN]; /* From bsd.c */
+extern char confname[BUFFER_LEN]; /* From bsd.c */
/* This is bad, but only for WIN32, which is bad anyway... */
#define EMBEDDED_MKINDX
do {
if (!(fildata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
do_rawlog(LT_ERR, "%s: %s, %ld %s", T(" Copying file"),
- fildata.cFileName, fildata.nFileSizeLow,
- fildata.nFileSizeLow == 1 ? T("byte") : T("bytes"));
+ fildata.cFileName, fildata.nFileSizeLow,
+ fildata.nFileSizeLow == 1 ? T("byte") : T("bytes"));
strcpy(fullname, directory);
strcat(fullname, fildata.cFileName);
/* Open the input file */
- f = fopen(fullname, "rb");
+ f = fopen(fullname, "rb");
if (!f)
- do_rawlog(LT_ERR, T(" ** Unable to open file: %s"), fullname);
+ do_rawlog(LT_ERR, T(" ** Unable to open file: %s"), fullname);
else {
- total_files++;
+ total_files++;
- /* do the copy loop */
- while (!feof(f)) {
- bytes_in = fread(buff, 1, sizeof(buff), f);
- if (bytes_in <= 0)
- break;
- bytes_out = fwrite(buff, 1, bytes_in, fo);
- total_bytes += bytes_out;
- if (bytes_in != bytes_out) {
- do_rawlog(LT_ERR, T("Unable to write to file: %s"), outputfile);
- fclose(f);
- break;
- }
- } /* end of copy loop */
- fclose(f);
- } /* end of being able to open file */
+ /* do the copy loop */
+ while (!feof(f)) {
+ bytes_in = fread(buff, 1, sizeof(buff), f);
+ if (bytes_in <= 0)
+ break;
+ bytes_out = fwrite(buff, 1, bytes_in, fo);
+ total_bytes += bytes_out;
+ if (bytes_in != bytes_out) {
+ do_rawlog(LT_ERR, T("Unable to write to file: %s"), outputfile);
+ fclose(f);
+ break;
+ }
+ } /* end of copy loop */
+ fclose(f);
+ } /* end of being able to open file */
}
/* end of not being a directory */
FindClose(filscan);
fclose(fo);
do_rawlog(LT_ERR, T("Copied %i %s, %ld %s"), total_files,
- total_files == 1 ? T("file") : T("files"), total_bytes,
- total_bytes == 1 ? T("byte") : T("bytes"));
+ total_files == 1 ? T("file") : T("files"), total_bytes,
+ total_bytes == 1 ? T("byte") : T("bytes"));
if (status == ERROR_NO_MORE_FILES)
return TRUE;
if (st.wMonth < 1 || st.wMonth > 12)
st.wMonth = 0;
do_rawlog(LT_ERR, T
- ("File \"%s\" found, size %ld %s, modified on %02d %s %04d %02d:%02d:%02d"),
- path, fildata.nFileSizeLow,
- fildata.nFileSizeLow == 1 ? T("byte") : T("bytes"), st.wDay,
- months[st.wMonth], st.wYear, st.wHour, st.wMinute, st.wSecond);
+ ("File \"%s\" found, size %ld %s, modified on %02d %s %04d %02d:%02d:%02d"),
+ path, fildata.nFileSizeLow,
+ fildata.nFileSizeLow == 1 ? T("byte") : T("bytes"), st.wDay,
+ months[st.wMonth], st.wYear, st.wHour, st.wMinute, st.wSecond);
if (fildata.nFileSizeHigh == 0 && fildata.nFileSizeLow < 80) {
do_rawlog(LT_ERR, T("File is too small to be a MUSH database."));
return FALSE;
return FALSE;
}
return TRUE;
-} /* end of CheckDatabase */
+} /* end of CheckDatabase */
void
Win32MUSH_setup(void)
{
if (GetModuleFileName(NULL, FileName, 256) != 0) {
if (!strcasecmp(rindex(FileName, '\\') + 1, "cobramush.exe")) {
if (CopyFile("cobramush.exe", "cobramush_run.exe", FALSE)) {
- do_rawlog(LT_ERR, "Successfully copied executable, starting copy.");
+ do_rawlog(LT_ERR, "Successfully copied executable, starting copy.");
#ifdef WIN32SERVICES
- execl("cobramush_run.exe", "cobramush_run.exe", "/run", NULL);
+ execl("cobramush_run.exe", "cobramush_run.exe", "/run", NULL);
#else
- execl("cobramush_run.exe", "cobramush_run.exe", confname, NULL);
+ execl("cobramush_run.exe", "cobramush_run.exe", confname, NULL);
#endif
}
}
}
-#endif /* */
+#endif /* */
ConcatenateFiles("txt\\hlp\\*.hlp", "txt\\help.txt");
ConcatenateFiles("txt\\nws\\*.nws", "txt\\news.txt");
ConcatenateFiles("txt\\evt\\*.evt", "txt\\events.txt");
indb_OK = CheckDatabase(options.input_db, &indb_time, &indb_size);
outdb_OK = CheckDatabase(options.output_db, &outdb_time, &outdb_size);
panicdb_OK = CheckDatabase(options.crash_db, &panicdb_time, &panicdb_size);
- if (indb_OK) { /* Look at outdb */
- if (outdb_OK) { /* Look at panicdb */
- if (panicdb_OK) { /* outdb or panicdb or indb */
- if (CompareFileTime(&panicdb_time, &outdb_time) > 0) { /* panicdb or indb */
- if (CompareFileTime(&panicdb_time, &indb_time) > 0) { /* panicdb */
- ConcatenateFiles(options.crash_db, options.input_db);
- } else { /* indb */
- }
- } else { /* outdb or indb */
- if (CompareFileTime(&outdb_time, &indb_time) > 0) { /* outdb */
- ConcatenateFiles(options.output_db, options.input_db);
- } else { /* indb */
- }
- }
- } else { /* outdb or indb */
- if (CompareFileTime(&outdb_time, &indb_time) > 0) { /* outdb */
- ConcatenateFiles(options.output_db, options.input_db);
- } else { /* indb */
- }
+ if (indb_OK) { /* Look at outdb */
+ if (outdb_OK) { /* Look at panicdb */
+ if (panicdb_OK) { /* outdb or panicdb or indb */
+ if (CompareFileTime(&panicdb_time, &outdb_time) > 0) { /* panicdb or indb */
+ if (CompareFileTime(&panicdb_time, &indb_time) > 0) { /* panicdb */
+ ConcatenateFiles(options.crash_db, options.input_db);
+ } else { /* indb */
+ }
+ } else { /* outdb or indb */
+ if (CompareFileTime(&outdb_time, &indb_time) > 0) { /* outdb */
+ ConcatenateFiles(options.output_db, options.input_db);
+ } else { /* indb */
+ }
+ }
+ } else { /* outdb or indb */
+ if (CompareFileTime(&outdb_time, &indb_time) > 0) { /* outdb */
+ ConcatenateFiles(options.output_db, options.input_db);
+ } else { /* indb */
+ }
}
- } else { /* outdb not OK */
- if (panicdb_OK) { /* panicdb or indb */
- if (CompareFileTime(&panicdb_time, &indb_time) > 0) { /* panicdb */
- ConcatenateFiles(options.crash_db, options.input_db);
- } else { /* indb */
- }
- } else { /* indb */
+ } else { /* outdb not OK */
+ if (panicdb_OK) { /* panicdb or indb */
+ if (CompareFileTime(&panicdb_time, &indb_time) > 0) { /* panicdb */
+ ConcatenateFiles(options.crash_db, options.input_db);
+ } else { /* indb */
+ }
+ } else { /* indb */
}
}
- } else { /* indb not OK */
- if (outdb_OK) { /* look at panicdb */
- if (panicdb_OK) { /* out or panic */
- if (CompareFileTime(&panicdb_time, &outdb_time) > 0) { /* panicdb */
- ConcatenateFiles(options.crash_db, options.input_db);
- } else { /* outdb */
- ConcatenateFiles(options.output_db, options.input_db);
- }
- } else { /* outdb */
- ConcatenateFiles(options.output_db, options.input_db);
+ } else { /* indb not OK */
+ if (outdb_OK) { /* look at panicdb */
+ if (panicdb_OK) { /* out or panic */
+ if (CompareFileTime(&panicdb_time, &outdb_time) > 0) { /* panicdb */
+ ConcatenateFiles(options.crash_db, options.input_db);
+ } else { /* outdb */
+ ConcatenateFiles(options.output_db, options.input_db);
+ }
+ } else { /* outdb */
+ ConcatenateFiles(options.output_db, options.input_db);
}
- } else { /* outdb not OK */
- if (panicdb_OK) { /* panicdb */
- ConcatenateFiles(options.crash_db, options.input_db);
- } else { /* NOTHING */
- return;
+ } else { /* outdb not OK */
+ if (panicdb_OK) { /* panicdb */
+ ConcatenateFiles(options.crash_db, options.input_db);
+ } else { /* NOTHING */
+ return;
}
}
}
}
-#endif /* WIN32 */
+#endif /* WIN32 */
static FLAG *match_flag_ns(FLAGSPACE * n, const char *name);
static void flag_fake_read(FILE *);
-PTAB ptab_flag; /**< Table of flags by name, inc. aliases */
-HASHTAB htab_flagspaces; /**< Hash of flagspaces */
+PTAB ptab_flag; /**< Table of flags by name, inc. aliases */
+HASHTAB htab_flagspaces; /**< Hash of flagspaces */
-extern PTAB ptab_command; /* Uses flag bitmasks */
+extern PTAB ptab_command; /* Uses flag bitmasks */
extern long flagdb_flags;
/** Attempt to find a flagspace from its name */
if (n->flag_table == flag_table) {
for (f = type_table; f->name != NULL; f++)
if (string_prefix(name, f->name))
- return f;
+ return f;
}
return NULL;
if (f->bitpos >= n->flagbits) {
/* Oops, we need a bigger array */
if (n->flagbits == 0)
- n->flags = (FLAG **) malloc(sizeof(FLAG *));
+ n->flags = (FLAG **) malloc(sizeof(FLAG *));
else {
- n->flags =
- (FLAG **) realloc(n->flags, (f->bitpos + 1) * sizeof(FLAG *));
- if (!n->flags)
- mush_panic("Unable to reallocate flags array!\n");
+ n->flags =
+ (FLAG **) realloc(n->flags, (f->bitpos + 1) * sizeof(FLAG *));
+ if (!n->flags)
+ mush_panic("Unable to reallocate flags array!\n");
}
/* Make sure the new space is full of NULLs */
for (i = n->flagbits; i <= f->bitpos; i++)
- n->flags[i] = NULL;
+ n->flags[i] = NULL;
}
/* Put the canonical flag in the flags array */
n->flags[f->bitpos] = f;
c = mush_strdup(getstring_noalloc(in), "flag name");
if (!strcmp(c, "FLAG ALIASES")) {
mush_free(c, "flag name");
- return NULL; /* We're done */
+ return NULL; /* We're done */
}
f = new_flag();
f->name = c;
c = mush_strdup(getstring_noalloc(in), "flag alias");
if (!strcmp(c, "END OF FLAGS")) {
mush_free(c, "flag alias");
- return NULL; /* We're done */
+ return NULL; /* We're done */
}
f = match_flag(c);
if (!f) {
/* Corrupt db. Recover as well as we can. */
do_rawlog(LT_ERR,
- T
- ("FLAG READ: flag alias %s matches no known flag. Skipping aliases."),
- c);
+ T
+ ("FLAG READ: flag alias %s matches no known flag. Skipping aliases."),
+ c);
mush_free(c, "flag alias");
do {
c = (char *) getstring_noalloc(in);
if (!f) {
/* Corrupt db. Recover as well as we can. */
do_rawlog(LT_ERR,
- T
- ("FLAG READ: flag alias %s matches no known flag. Skipping this alias."),
- c);
+ T
+ ("FLAG READ: flag alias %s matches no known flag. Skipping this alias."),
+ c);
mush_free(c, "flag alias");
(void) getstring_noalloc(in);
return NULL;
flag_add(n, a->alias, f);
else
do_rawlog(LT_ERR,
- T("FLAG INIT: flag alias %s matches no known flag."), a->alias);
+ T("FLAG INIT: flag alias %s matches no known flag."), a->alias);
}
flag_add_additional();
add_flag("EMPIRE", 'E', TYPE_DIVISION, F_PRIVILEGE, F_PRIVILEGE);
add_flag("INHERIT", 'I', TYPE_THING | TYPE_EXIT | TYPE_ROOM, F_PRIVILEGE, F_PRIVILEGE);
add_flag("INHERITABLE", 'I', TYPE_PLAYER, F_PRIVILEGE | F_SELF,
- F_PRIVILEGE | F_SELF);
+ F_PRIVILEGE | F_SELF);
add_flag("ZCLONE_OK", '\0', TYPE_THING, F_PRIVILEGE, F_PRIVILEGE);
add_flag("WEIRDSITE", '\0', TYPE_PLAYER, F_GOD | F_DARK, F_GOD | F_DARK);
add_flag("MISTRUST", 'm', TYPE_THING | TYPE_EXIT | TYPE_ROOM, F_PRIVILEGE,
- F_PRIVILEGE);
+ F_PRIVILEGE);
add_flag("ORPHAN", 'i', NOTYPE, F_ANY, F_ANY);
add_flag("TRACK_MONEY", '\0', TYPE_PLAYER, F_ANY, F_ANY);
add_flag("LOUD", '\0', NOTYPE, F_PRIVILEGE, F_ANY);
for (f = flag_table; f->name; f++) {
if (f->type == NOTYPE) {
if (f->bitpos & old_flags) {
- newf = match_flag(f->name);
- set_flag_bitmask(bitmask, newf->bitpos);
+ newf = match_flag(f->name);
+ set_flag_bitmask(bitmask, newf->bitpos);
}
} else if (f->type & type) {
if (f->bitpos & old_toggles) {
- newf = match_flag(f->name);
- set_flag_bitmask(bitmask, newf->bitpos);
+ newf = match_flag(f->name);
+ set_flag_bitmask(bitmask, newf->bitpos);
}
}
}
* it's more useful to check 'C' as COLOR. Argle.
*/
if (!(is_flag(f, "CHOWN_OK") && (type == TYPE_PLAYER)) &&
- ((f->letter == c) && (f->type & type)))
- return f;
+ ((f->letter == c) && (f->type & type)))
+ return f;
}
/* Do we need to do this? */
return NULL;
*/
const char *
bits_to_string(const char *ns, object_flag_type bitmask, dbref privs,
- dbref thing)
+ dbref thing)
{
FLAG *f;
FLAGSPACE *n;
for (i = 0; i < n->flagbits; i++) {
if ((f = n->flags[i])) {
if (has_bit(bitmask, f->bitpos) &&
- (!GoodObject(thing) || Can_See_Flag(privs, thing, f))) {
- if (!first)
- safe_chr(' ', buf, &bp);
- safe_str(f->name, buf, &bp);
- first = 0;
+ (!GoodObject(thing) || Can_See_Flag(privs, thing, f))) {
+ if (!first)
+ safe_chr(' ', buf, &bp);
+ safe_str(f->name, buf, &bp);
+ first = 0;
}
}
}
return bitmask;
}
if (!str)
- return bitmask; /* We're done, then */
+ return bitmask; /* We're done, then */
copy = mush_strdup(str, "flagstring");
s = trim_space_sep(copy, ' ');
while (s) {
if ((myperms & F_GOD) && !God(player))
return 0;
if (Director(thing) && is_flag(flagp, "GAGGED"))
- return 0; /* can't gag directors/God */
+ return 0; /* can't gag directors/God */
/* Check if its wiz or roy flag.. Make sure they're in a division before they can do 'em */
if ((is_flag(flagp, "WIZARD") || is_flag(flagp, "ROYALTY"))
&& (SDIV(thing).object == NOTHING))
return 0;
- if (God(player)) /* God can do (almost) anything) */
+ if (God(player)) /* God can do (almost) anything) */
return 1;
/* Make sure we don't accidentally permission-check toggles when
* checking priv bits.
for (i = 0; i < n->flagbits; i++) {
if ((f = n->flags[i])) {
if (has_flag(thing, f) && Can_See_Flag(player, thing, f))
- *p++ = f->letter;
+ *p++ = f->letter;
}
}
*p = '\0';
for (i = 0; i < n->flagbits; i++)
if ((f = n->flags[i])) {
if (has_flag(thing, f) && Can_See_Flag(player, thing, f))
- notify_format(player, "@set %s = %s", name, f->name);
+ notify_format(player, "@set %s = %s", name, f->name);
}
}
*/
void
set_flag(dbref player, dbref thing, const char *flag, int negate,
- int hear, int listener)
+ int hear, int listener)
{
FLAG *f;
char tbuf1[BUFFER_LEN];
}
if(is_flag(f, "BUILDER") && !OOREF(player,div_powover(player,player, "BCreate"),
- div_powover(ooref, ooref, "BCreate"))) {
+ div_powover(ooref, ooref, "BCreate"))) {
notify(player, T("Permission denied."));
return;
}
}
if(is_flag(f, "RPMODE")) {
if(atr_get(thing, "RPLOCK") != NULL) {
- notify_format(player, "That player is currently locked %s RPMode.", RPMODE(thing) ? "into" : "out of");
- return;
+ notify_format(player, "That player is currently locked %s RPMode.", RPMODE(thing) ? "into" : "out of");
+ return;
}
- if(negate) {
- if(!RPMODE(thing)) {
- notify(player, "That player isn't currently in RPMODE.");
- return;
- }
- icloc = GoodObject((absroom = absolute_room(thing))) ? absroom : thing;
- if(GoodObject(icloc) && has_flag_by_name(icloc, "ICFUNCS" , NOTYPE)
- && !Going(icloc)) {
- (void) atr_add(thing, "INF_RPLOC", unparse_dbref(Location(thing)), GOD, NOTHING);
- icloc = Home(thing);
- } else {
- notify(player, "That player is not an IC Location, therefore can't go OOC.");
- return;
- }
- } else {
- if(RPMODE(thing)) {
- notify(player, "That player is already in RPMODE.");
- return;
- }
- if(InProg(thing)) {
- notify(player, "Permission denied. Can not go RPMODE while in a @PROGRAM.");
- return;
- }
- /* First make sure there truerace is valid */
- icloc_ptr = atr_get(thing, "TRUERACE");
- if(icloc_ptr)
- strncpy(icloc_buf, atr_value(icloc_ptr), BUFFER_LEN-1);
- if(!*icloc_buf) {
- if(player != thing)
- notify(player, "That player does not have a valid TRUERACE set.");
- notify(thing, "You do not have a valid TRUERACE set. Contact an administrator.");
- return;
- } else if(parse_dbref(icloc_buf) == NOTHING) {
- if(player != thing)
- notify(player, "That player has an invalid TRUERACE.");
- notify(thing, "You have an invalid TRUERACE. Contact an administrator.");
- return;
- }
- icloc_ptr = atr_get(thing, "INF_RPLOC");
- memset(icloc_buf, '\0', BUFFER_LEN);
- if(icloc_ptr)
- strncpy(icloc_buf, atr_value(icloc_ptr), BUFFER_LEN-1);
- if(!*icloc_buf) {
- if(player != thing)
- notify(player, "That player has an invalid RP location set.");
- notify(thing, "You have an invalid RP location set. Contact an administrator.");
- return;
- }
-
- icloc = parse_dbref(icloc_buf);
- icloc = GoodObject((absroom = absolute_room(icloc))) ? absroom : icloc;
-
- if(!GoodObject(icloc) || !has_flag_by_name(icloc, "ICFUNCS", NOTYPE) || Going(icloc)) {
- if(player != thing)
- notify(player, "That player has an invalid RP location set.");
- notify(thing, "You have an invalid RP location set. Contact an administrator.");
- return;
- }
- /* Ok.. everythings good, move 'em to the IC world */
- }
+ if(negate) {
+ if(!RPMODE(thing)) {
+ notify(player, "That player isn't currently in RPMODE.");
+ return;
+ }
+ icloc = GoodObject((absroom = absolute_room(thing))) ? absroom : thing;
+ if(GoodObject(icloc) && has_flag_by_name(icloc, "ICFUNCS" , NOTYPE)
+ && !Going(icloc)) {
+ (void) atr_add(thing, "INF_RPLOC", unparse_dbref(Location(thing)), GOD, NOTHING);
+ icloc = Home(thing);
+ } else {
+ notify(player, "That player is not an IC Location, therefore can't go OOC.");
+ return;
+ }
+ } else {
+ if(RPMODE(thing)) {
+ notify(player, "That player is already in RPMODE.");
+ return;
+ }
+ if(InProg(thing)) {
+ notify(player, "Permission denied. Can not go RPMODE while in a @PROGRAM.");
+ return;
+ }
+ /* First make sure there truerace is valid */
+ icloc_ptr = atr_get(thing, "TRUERACE");
+ if(icloc_ptr)
+ strncpy(icloc_buf, atr_value(icloc_ptr), BUFFER_LEN-1);
+ if(!*icloc_buf) {
+ if(player != thing)
+ notify(player, "That player does not have a valid TRUERACE set.");
+ notify(thing, "You do not have a valid TRUERACE set. Contact an administrator.");
+ return;
+ } else if(parse_dbref(icloc_buf) == NOTHING) {
+ if(player != thing)
+ notify(player, "That player has an invalid TRUERACE.");
+ notify(thing, "You have an invalid TRUERACE. Contact an administrator.");
+ return;
+ }
+ icloc_ptr = atr_get(thing, "INF_RPLOC");
+ memset(icloc_buf, '\0', BUFFER_LEN);
+ if(icloc_ptr)
+ strncpy(icloc_buf, atr_value(icloc_ptr), BUFFER_LEN-1);
+ if(!*icloc_buf) {
+ if(player != thing)
+ notify(player, "That player has an invalid RP location set.");
+ notify(thing, "You have an invalid RP location set. Contact an administrator.");
+ return;
+ }
+
+ icloc = parse_dbref(icloc_buf);
+ icloc = GoodObject((absroom = absolute_room(icloc))) ? absroom : icloc;
+
+ if(!GoodObject(icloc) || !has_flag_by_name(icloc, "ICFUNCS", NOTYPE) || Going(icloc)) {
+ if(player != thing)
+ notify(player, "That player has an invalid RP location set.");
+ notify(thing, "You have an invalid RP location set. Contact an administrator.");
+ return;
+ }
+ /* Ok.. everythings good, move 'em to the IC world */
+ }
}
#endif /* RPMODE_SYS */
#ifdef RPMODE_SYS
if(is_flag(f, "RPMODE")) {
- dbref oldloc;
- oldloc = Location(thing);
- enter_room(thing, icloc, 1);
- if(!negate) {
- a = atr_get( ANCESTOR_PLAYER, "AIC");
- if(a) {
- strncpy(tbuf1, atr_value(a), BUFFER_LEN-1);
- tbuf1[strlen(tbuf1)+1] = '\0';
- tp = mush_strdup(unparse_dbref(thing), "rpsys.thing");
- tp2 = mush_strdup(unparse_dbref(oldloc), "rpsys.oldloc");
- tp3 = mush_strdup(unparse_dbref(icloc), "rpsys.icloc");
- global_eval_context.wnxt[0] = tp;
- global_eval_context.wnxt[1] = tp2;
- global_eval_context.wnxt[2] = tp3;
- global_eval_context.wnxt[3] = NULL;
- parse_que(ANCESTOR_PLAYER, tbuf1, player);
- if(tp)
- mush_free(tp, "rpsys.thing");
- if(tp2)
- mush_free(tp2, "rpsys.oldloc");
- if(tp3)
- mush_free(tp3, "rpsys.icloc");
- }
- notify_format(thing, "You wake up from a deep sleep.");
- if(oldloc != icloc)
- notify_except(Contents(oldloc), NOTHING, tprintf("%s%sGAME%s%s:%s%s %s has entered RPMODE%s.",
- ANSI_HILITE, ANSI_CYAN, ANSI_NORMAL, ANSI_RED, ANSI_HILITE, ANSI_YELLOW,
- Name(thing), ANSI_NORMAL), 0);
- if(Connected(thing))
- notify_except(Contents(icloc), thing, tprintf("%s wakes up from a deep sleep.",
- spname(thing)), NA_INTER_HEAR);
- } else {
+ dbref oldloc;
+ oldloc = Location(thing);
+ enter_room(thing, icloc, 1);
+ if(!negate) {
+ a = atr_get( ANCESTOR_PLAYER, "AIC");
+ if(a) {
+ strncpy(tbuf1, atr_value(a), BUFFER_LEN-1);
+ tbuf1[strlen(tbuf1)+1] = '\0';
+ tp = mush_strdup(unparse_dbref(thing), "rpsys.thing");
+ tp2 = mush_strdup(unparse_dbref(oldloc), "rpsys.oldloc");
+ tp3 = mush_strdup(unparse_dbref(icloc), "rpsys.icloc");
+ global_eval_context.wnxt[0] = tp;
+ global_eval_context.wnxt[1] = tp2;
+ global_eval_context.wnxt[2] = tp3;
+ global_eval_context.wnxt[3] = NULL;
+ parse_que(ANCESTOR_PLAYER, tbuf1, player);
+ if(tp)
+ mush_free(tp, "rpsys.thing");
+ if(tp2)
+ mush_free(tp2, "rpsys.oldloc");
+ if(tp3)
+ mush_free(tp3, "rpsys.icloc");
+ }
+ notify_format(thing, "You wake up from a deep sleep.");
+ if(oldloc != icloc)
+ notify_except(Contents(oldloc), NOTHING, tprintf("%s%sGAME%s%s:%s%s %s has entered RPMODE%s.",
+ ANSI_HILITE, ANSI_CYAN, ANSI_NORMAL, ANSI_RED, ANSI_HILITE, ANSI_YELLOW,
+ Name(thing), ANSI_NORMAL), 0);
+ if(Connected(thing))
+ notify_except(Contents(icloc), thing, tprintf("%s wakes up from a deep sleep.",
+ spname(thing)), NA_INTER_HEAR);
+ } else {
a = atr_get( ANCESTOR_PLAYER, "AOOC");
if(a) {
strncpy(tbuf1, atr_value(a), BUFFER_LEN-1);
notify_format(thing, "You fall into a deep sleep.");
- notify_except(Contents(icloc), thing, tprintf("%s%sGAME%s%s:%s%s %s has arrived from leaving RPMODE%s.", ANSI_HILITE, ANSI_CYAN, ANSI_NORMAL, ANSI_RED, ANSI_HILITE, ANSI_YELLOW,
+ notify_except(Contents(icloc), thing, tprintf("%s%sGAME%s%s:%s%s %s has arrived from leaving RPMODE%s.", ANSI_HILITE, ANSI_CYAN, ANSI_NORMAL, ANSI_RED, ANSI_HILITE, ANSI_YELLOW,
Name(thing), ANSI_NORMAL), 0);
- if(Connected(thing))
- notify_anything(orator, na_loc, &Contents(oldloc), NULL, NA_INTER_HEAR,
- tprintf("%s falls into a deep sleep.", spname(thing)));
- }
+ if(Connected(thing))
+ notify_anything(orator, na_loc, &Contents(oldloc), NULL, NA_INTER_HEAR,
+ tprintf("%s falls into a deep sleep.", spname(thing)));
+ }
}
#endif /* RPMODE_SYS */
if (negate) {
/* Perform Marker Resets & Check if Royalty flag is on them for special conditions */
powergroup_db_set(player, thing, "!WIZARD", 1);
if(has_flag_by_name(thing, "ROYALTY", NOTYPE))
- SLEVEL(thing) = 28;
+ SLEVEL(thing) = 28;
else
- SLEVEL(thing) = 3;
+ SLEVEL(thing) = 3;
} else if (is_flag(f, "ROYALTY")) {
do_log(LT_WIZ, player, thing, "ROYAL FLAG RESET");
/* Perform Marker Resets */
powergroup_db_set(player, thing, "!ROYALTY", 1);
if(!has_flag_by_name(thing, "WIZARD", NOTYPE))
- SLEVEL(thing) = 3;
+ SLEVEL(thing) = 3;
}
if (is_flag(f, "SUSPECT"))
do_log(LT_WIZ, player, thing, "SUSPECT FLAG RESET");
/* notify the area if something stops listening, but only if it
wasn't listening before */
if (!IsPlayer(thing) && (hear || listener) &&
- !Hearer(thing) && !Listener(thing)) {
+ !Hearer(thing) && !Listener(thing)) {
tp = tbuf1;
safe_format(tbuf1, &tp, T("%s is no longer listening."), Name(thing));
*tp = '\0';
if (GoodObject(Location(thing)))
- notify_except(Contents(Location(thing)), NOTHING, tbuf1,
- NA_INTER_PRESENCE);
+ notify_except(Contents(Location(thing)), NOTHING, tbuf1,
+ NA_INTER_PRESENCE);
notify_except(Contents(thing), NOTHING, tbuf1, 0);
}
if (IsRoom(thing) && is_flag(f, "MONITOR") && !hear && !Listener(thing)) {
if (is_flag(f, "AUDIBLE")) {
switch (Typeof(thing)) {
case TYPE_EXIT:
- if (Audible(Source(thing))) {
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("Exit %s is no longer broadcasting."),
- Name(thing));
- *tp = '\0';
- notify_except(Contents(Source(thing)), NOTHING, tbuf1, 0);
- }
- break;
+ if (Audible(Source(thing))) {
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("Exit %s is no longer broadcasting."),
+ Name(thing));
+ *tp = '\0';
+ notify_except(Contents(Source(thing)), NOTHING, tbuf1, 0);
+ }
+ break;
case TYPE_ROOM:
- notify_except(Contents(thing), NOTHING,
- T("Audible exits in this room have been deactivated."),
- 0);
- break;
+ notify_except(Contents(thing), NOTHING,
+ T("Audible exits in this room have been deactivated."),
+ 0);
+ break;
case TYPE_THING:
case TYPE_PLAYER:
- notify_except(Contents(thing), thing,
- T("This room is no longer broadcasting."), 0);
- notify(thing, T("Your contents can no longer be heard from outside."));
- break;
+ notify_except(Contents(thing), thing,
+ T("This room is no longer broadcasting."), 0);
+ notify(thing, T("Your contents can no longer be heard from outside."));
+ break;
}
}
if (is_flag(f, "QUIET") || (!AreQuiet(player, thing))) {
/* marker powers */
powergroup_db_set(player, thing, "ROYALTY", 1);
if(!has_flag_by_name(thing, "WIZARD", NOTYPE))
- SLEVEL(thing) = 28;
+ SLEVEL(thing) = 28;
}
if (is_flag(f, "SUSPECT"))
do_log(LT_WIZ, player, thing, "SUSPECT FLAG SET");
if (is_flag(f, "SHARED"))
- check_zone_lock(player, thing, 1);
+ check_zone_lock(player, thing, 1);
/* DARK players should be treated as logged out */
if (is_flag(f, "DARK") && IsPlayer(thing))
hide_player(thing, 1);
/* notify area if something starts listening */
if (!IsPlayer(thing) &&
- (is_flag(f, "PUPPET") || is_flag(f, "MONITOR")) && !hear && !listener) {
+ (is_flag(f, "PUPPET") || is_flag(f, "MONITOR")) && !hear && !listener) {
tp = tbuf1;
safe_format(tbuf1, &tp, T("%s is now listening."), Name(thing));
*tp = '\0';
if (GoodObject(Location(thing)))
- notify_except(Contents(Location(thing)), NOTHING, tbuf1,
- NA_INTER_PRESENCE);
+ notify_except(Contents(Location(thing)), NOTHING, tbuf1,
+ NA_INTER_PRESENCE);
notify_except(Contents(thing), NOTHING, tbuf1, 0);
}
if (IsRoom(thing) && is_flag(f, "MONITOR") && !hear && !listener) {
if (is_flag(f, "AUDIBLE")) {
switch (Typeof(thing)) {
case TYPE_EXIT:
- if (Audible(Source(thing))) {
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("Exit %s is now broadcasting."),
- Name(thing));
- *tp = '\0';
- notify_except(Contents(Source(thing)), NOTHING, tbuf1, 0);
- }
- break;
+ if (Audible(Source(thing))) {
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("Exit %s is now broadcasting."),
+ Name(thing));
+ *tp = '\0';
+ notify_except(Contents(Source(thing)), NOTHING, tbuf1, 0);
+ }
+ break;
case TYPE_ROOM:
- notify_except(Contents(thing), NOTHING,
- T("Audible exits in this room have been activated."), 0);
- break;
+ notify_except(Contents(thing), NOTHING,
+ T("Audible exits in this room have been activated."), 0);
+ break;
case TYPE_PLAYER:
case TYPE_THING:
- notify_except(Contents(thing), thing,
- T("This room is now broadcasting."), 0);
- notify(thing, T("Your contents can now be heard from outside."));
- break;
+ notify_except(Contents(thing), thing,
+ T("This room is now broadcasting."), 0);
+ notify(thing, T("Your contents can now be heard from outside."));
+ break;
}
}
if (is_flag(f, "QUIET") || (!AreQuiet(player, thing))) {
*/
int
flaglist_check(const char *ns, dbref player, dbref it, const char *fstr,
- int type)
+ int type)
{
char *s;
FLAG *fp;
negate = 1;
s++;
} else {
- negate = 0; /* It's important to clear this at appropriate times;
- * else !Dc means (!D && !c), instead of (!D && c). */
+ negate = 0; /* It's important to clear this at appropriate times;
+ * else !Dc means (!D && !c), instead of (!D && c). */
}
if (!*s)
/* We got a '!' that wasn't followed by a letter.
* flags, but we grandfather them in to preserve old code
*/
if ((*s == 'T') || (*s == 'R') || (*s == 'E') || (*s == 'P')) {
- temp = (*s == 'T') ? (Typeof(it) == TYPE_THING) :
- ((*s == 'R') ? (Typeof(it) == TYPE_ROOM) :
- ((*s == 'E') ? (Typeof(it) == TYPE_EXIT) :
- (Typeof(it) == TYPE_PLAYER)));
- if ((type == 1) && ((negate && temp) || (!negate && !temp)))
- return 0;
- else if ((type == 0) && ((!negate && temp) || (negate && !temp)))
- ret |= 1;
+ temp = (*s == 'T') ? (Typeof(it) == TYPE_THING) :
+ ((*s == 'R') ? (Typeof(it) == TYPE_ROOM) :
+ ((*s == 'E') ? (Typeof(it) == TYPE_EXIT) :
+ (Typeof(it) == TYPE_PLAYER)));
+ if ((type == 1) && ((negate && temp) || (!negate && !temp)))
+ return 0;
+ else if ((type == 0) && ((!negate && temp) || (negate && !temp)))
+ ret |= 1;
} else {
- /* Either we got a '!' that wasn't followed by a letter, or
- * we couldn't find that flag. For AND, since we've failed
- * a check, we can return false. Otherwise we just go on.
- */
- if (type == 1)
- return 0;
- else
- continue;
+ /* Either we got a '!' that wasn't followed by a letter, or
+ * we couldn't find that flag. For AND, since we've failed
+ * a check, we can return false. Otherwise we just go on.
+ */
+ if (type == 1)
+ return 0;
+ else
+ continue;
}
} else {
/* does the object have this flag? */
temp = (has_flag(it, fp) && Can_See_Flag(player, it, fp));
if ((type == 1) && ((negate && temp) || (!negate && !temp))) {
- /* Too bad there's no NXOR function...
- * At this point we've either got a flag and we don't want
- * it, or we don't have a flag and we want it. Since it's
- * AND, we return false.
- */
- return 0;
+ /* Too bad there's no NXOR function...
+ * At this point we've either got a flag and we don't want
+ * it, or we don't have a flag and we want it. Since it's
+ * AND, we return false.
+ */
+ return 0;
} else if ((type == 0) && ((!negate && temp) || (negate && !temp))) {
- /* We've found something we want, in an OR. We OR a
- * true with the current value.
- */
- ret |= 1;
+ /* We've found something we want, in an OR. We OR a
+ * true with the current value.
+ */
+ ret |= 1;
}
/* Otherwise, we don't need to do anything. */
}
*/
int
flaglist_check_long(const char *ns, dbref player, dbref it, const char *fstr,
- int type)
+ int type)
{
char *s, *copy, *sp;
FLAG *fp;
negate = 1;
s++;
} else {
- negate = 0; /* It's important to clear this at appropriate times;
- * else !D c means (!D && !c), instead of (!D && c). */
+ negate = 0; /* It's important to clear this at appropriate times;
+ * else !D c means (!D && !c), instead of (!D && c). */
}
if (!*s) {
/* We got a '!' that wasn't followed by a string.
* Fail the check. */
if (type == 1)
- ret = 0;
+ ret = 0;
break;
}
/* Find the flag. */
* a check, we can return false. Otherwise we just go on.
*/
if (type == 1) {
- ret = 0;
- break;
+ ret = 0;
+ break;
} else
- continue;
+ continue;
} else {
/* does the object have this flag? There's a special case
* here, as we want (for consistency with flaglist_check)
* to allow types to match as well
*/
if (!strcmp(fp->name, "PLAYER"))
- temp = IsPlayer(it);
+ temp = IsPlayer(it);
else if (!strcmp(fp->name, "THING"))
- temp = IsThing(it);
+ temp = IsThing(it);
else if (!strcmp(fp->name, "ROOM"))
- temp = IsRoom(it);
+ temp = IsRoom(it);
else if (!strcmp(fp->name, "EXIT"))
- temp = IsExit(it);
+ temp = IsExit(it);
else
- temp = (has_flag(it, fp) && Can_See_Flag(player, it, fp));
+ temp = (has_flag(it, fp) && Can_See_Flag(player, it, fp));
if ((type == 1) && ((negate && temp) || (!negate && !temp))) {
- /* Too bad there's no NXOR function...
- * At this point we've either got a flag and we don't want
- * it, or we don't have a flag and we want it. Since it's
- * AND, we return false.
- */
- ret = 0;
- break;
+ /* Too bad there's no NXOR function...
+ * At this point we've either got a flag and we don't want
+ * it, or we don't have a flag and we want it. Since it's
+ * AND, we return false.
+ */
+ ret = 0;
+ break;
} else if ((type == 0) && ((!negate && temp) || (negate && !temp))) {
- /* We've found something we want, in an OR. We OR a
- * true with the current value.
- */
- ret |= 1;
+ /* We've found something we want, in an OR. We OR a
+ * true with the current value.
+ */
+ ret |= 1;
}
/* Otherwise, we don't need to do anything. */
}
*/
FLAG *
add_flag(const char *name, const char letter, int type,
- int perms, int negate_perms)
+ int perms, int negate_perms)
{
FLAG *f;
FLAGSPACE *n;
notify_format(player, " Type(s): %s", f->type == ALLTYPES ? "ANY" : privs_to_string(type_privs, f->type));
notify_format(player, " Perms: %s", privs_to_string(flag_privs, f->perms));
notify_format(player, "ResetPrms: %s",
- privs_to_string(flag_privs, f->negate_perms));
+ privs_to_string(flag_privs, f->negate_perms));
}
/** Change the permissions on a flag.
} else {
negate_perms = string_to_privs(flag_privs, args_right[2], 0);
if ((!negate_perms) || (negate_perms & (F_INTERNAL | F_DISABLED))) {
- notify(player, T("I don't understand those permissions."));
- return;
+ notify(player, T("I don't understand those permissions."));
+ return;
}
}
} else {
}
if (!type_string || !*type_string) {
notify_format(player, T("What type do you want to make that %s?"),
- strlower(ns));
+ strlower(ns));
return;
}
if (!strcasecmp(type_string, "any")) {
/* Do we have a type? */
if (args_right[2]) {
if (*args_right[2] && strcasecmp(args_right[2], "any"))
- type = string_to_privs(type_privs, args_right[2], 0);
+ type = string_to_privs(type_privs, args_right[2], 0);
if (!type) {
- notify(player, T("I don't understand the list of types."));
- return;
+ notify(player, T("I don't understand the list of types."));
+ return;
}
}
/* Is this letter already in use for this type? */
if (*args_right[1]) {
if ((f = letter_to_flagptr(n, *args_right[1], type))) {
- notify_format(player, T("Letter conflicts with the %s flag."), f->name);
- return;
+ notify_format(player, T("Letter conflicts with the %s flag."), f->name);
+ return;
}
}
/* Do we have perms? */
if (args_right[3] && *args_right[3]) {
if (!strcasecmp(args_right[3], "any")) {
- perms = F_ANY;
+ perms = F_ANY;
} else {
- perms = string_to_privs(flag_privs, args_right[3], 0);
- if ((!perms) || (perms & (F_INTERNAL | F_DISABLED))) {
- notify(player, T("I don't understand those permissions."));
- return;
- }
+ perms = string_to_privs(flag_privs, args_right[3], 0);
+ if ((!perms) || (perms & (F_INTERNAL | F_DISABLED))) {
+ notify(player, T("I don't understand those permissions."));
+ return;
+ }
}
}
if (args_right[4] && *args_right[4]) {
if (!strcasecmp(args_right[4], "any")) {
- negate_perms = F_ANY;
+ negate_perms = F_ANY;
} else {
- negate_perms = string_to_privs(flag_privs, args_right[4], 0);
- if ((!negate_perms) || (negate_perms & (F_INTERNAL | F_DISABLED))) {
- notify(player, T("I don't understand those permissions."));
- return;
- }
+ negate_perms = string_to_privs(flag_privs, args_right[4], 0);
+ if ((!negate_perms) || (negate_perms & (F_INTERNAL | F_DISABLED))) {
+ notify(player, T("I don't understand those permissions."));
+ return;
+ }
}
} else
negate_perms = perms;
af = match_flag_ns(n, alias);
if (!delete && af) {
notify_format(player, T("That alias already matches the %s flag."),
- af->name);
+ af->name);
return;
}
f = match_flag_ns(n, name);
}
if (delete && !af) {
notify_format(player, T("That isn't an alias of the %s flag."),
- f->name);
+ f->name);
return;
}
if (delete) {
}
ptab_delete(n->tab, alias);
if ((af = match_flag_ns(n, alias)))
- notify(player, T("Unknown failure deleting alias."));
+ notify(player, T("Unknown failure deleting alias."));
else
do_flag_info("FLAG", player, f->name);
} else {
if ((other = letter_to_flagptr(n, *letter, NOTYPE))) {
notify_format(player, T("Letter conflicts with the %s flag."),
- other->name);
+ other->name);
return;
}
f->letter = *letter;
notify_format(player, T("Letter for flag %s set to '%c'."),
- f->name, *letter);
- } else { /* Clear a flag */
+ f->name, *letter);
+ } else { /* Clear a flag */
f->letter = '\0';
notify_format(player, T("Letter for flag %s cleared."), f->name);
}
tmpf = ptab_firstentry_new(n->tab, flagname);
while (tmpf) {
if (!strcmp(tmpf->name, f->name) &&
- strcmp(n->flags[f->bitpos]->name, flagname)) {
- ptab_delete(n->tab, flagname);
- got_one = 1;
- break;
+ strcmp(n->flags[f->bitpos]->name, flagname)) {
+ ptab_delete(n->tab, flagname);
+ got_one = 1;
+ break;
}
tmpf = ptab_nextentry_new(n->tab, flagname);
}
f = ptab_firstentry_new(n->tab, flagname);
while (f) {
if (!strcmp(given->name, f->name) &&
- strcmp(n->flags[f->bitpos]->name, flagname)) {
+ strcmp(n->flags[f->bitpos]->name, flagname)) {
/* This is an alias! */
if (!first)
- safe_chr(' ', buf, &bp);
+ safe_chr(' ', buf, &bp);
first = 0;
safe_str(flagname, buf, &bp);
}
for (i = 0; i < n->flagbits; i++) {
if ((f = n->flags[i]) && !(f->perms & disallowed)) {
if (!name || !*name || quick_wild(name, f->name))
- ptrs[numptrs++] = (char *) f->name;
+ ptrs[numptrs++] = (char *) f->name;
}
}
do_gensort(privs, ptrs, NULL, numptrs, ALPHANUM_LIST);
switch (which) {
case 0x3:
if (i)
- safe_strl(", ", 2, buf, &bp);
+ safe_strl(", ", 2, buf, &bp);
safe_str(ptrs[i], buf, &bp);
f = match_flag_ns(n, ptrs[i]);
if (!f)
- break;
+ break;
if (f->letter != '\0')
- safe_format(buf, &bp, " (%c)", f->letter);
+ safe_format(buf, &bp, " (%c)", f->letter);
if (f->perms & F_DISABLED)
- safe_str(T(" (disabled)"), buf, &bp);
+ safe_str(T(" (disabled)"), buf, &bp);
break;
case 0x2:
if (i)
- safe_chr(' ', buf, &bp);
+ safe_chr(' ', buf, &bp);
safe_str(ptrs[i], buf, &bp);
break;
case 0x1:
f = match_flag_ns(n, ptrs[i]);
if (f && (f->letter != '\0'))
- safe_chr(f->letter, buf, &bp);
+ safe_chr(f->letter, buf, &bp);
break;
}
}
while (*in) {
while (*in == ESC_CHAR) {
while (*in && *in != 'm')
- in++;
- in++; /* skip 'm' */
+ in++;
+ in++; /* skip 'm' */
}
if ((*in >= 32) && (*in <= 126)) {
*out++ = *in;
shsUpdate(&shsInfo, (const BYTE *) args[0], arglens[0]);
shsFinal(&shsInfo);
safe_format(buff, bp, "%0x%0x%0x%0x%0x", shsInfo.digest[0],
- shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3],
- shsInfo.digest[4]);
+ shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3],
+ shsInfo.digest[4]);
#endif
}
shsUpdate(&shsInfo, (const BYTE *) args[0], arglens[0]);
shsFinal(&shsInfo);
safe_format(buff, bp, "%0x%0x%0x%0x%0x", shsInfo.digest[0],
- shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3],
- shsInfo.digest[4]);
+ shsInfo.digest[1], shsInfo.digest[2], shsInfo.digest[3],
+ shsInfo.digest[4]);
} else {
safe_str(T("#-1 UNSUPPORTED DIGEST TYPE"), buff, bp);
}
static int apply_restrictions(unsigned int result, const char *restriction);
USERFN_ENTRY *userfn_tab; /**< Table of user-defined functions */
-HASHTAB htab_function; /**< Function hash table */
+HASHTAB htab_function; /**< Function hash table */
HASHTAB htab_user_function; /**< User-defined function hash table */
/* -------------------------------------------------------------------------*
*/
void
save_global_env(const char *funcname __attribute__ ((__unused__)),
- char *preserve[])
+ char *preserve[])
{
int i;
for (i = 0; i < 10; i++)
*/
void
restore_global_env(const char *funcname __attribute__ ((__unused__)),
- char *preserve[])
+ char *preserve[])
{
int i;
for (i = 0; i < 10; i++)
*/
void
save_global_nxt(const char *funcname, char *preservew[], char *preserver[],
- char *valw[], char *valr[])
+ char *valw[], char *valr[])
{
int i;
for (i = 0; i < NUMQ; i++) {
*/
int
delim_check(char *buff, char **bp, int nfargs, char *fargs[], int sep_arg,
- char *sep)
+ char *sep)
{
/* Find a delimiter. */
* This structure represents a function's entry in the function table.
*/
typedef struct fun_tab {
- const char *name; /**< Name of the function, uppercase. */
- function_func fun; /**< Pointer to code to call for this function. */
- int minargs; /**< Minimum args required. */
- int maxargs; /**< Maximum args, or INT_MAX. If <0, last arg may have commas */
- int flags; /**< Flags to control how the function is parsed. */
+ const char *name; /**< Name of the function, uppercase. */
+ function_func fun; /**< Pointer to code to call for this function. */
+ int minargs; /**< Minimum args required. */
+ int maxargs; /**< Maximum args, or INT_MAX. If <0, last arg may have commas */
+ int flags; /**< Flags to control how the function is parsed. */
} FUNTAB;
{
userfn_tab =
(USERFN_ENTRY *) mush_malloc(MAX_GLOBAL_FNS * sizeof(USERFN_ENTRY),
- "userfn_tab");
+ "userfn_tab");
}
/** Check permissions to run a function.
return 0;
function_add(strdup(strupper(alias)), fp->where.fun,
- fp->minargs, fp->maxargs, fp->flags);
+ fp->minargs, fp->maxargs, fp->flags);
return 1;
}
*/
void
function_add(const char *name, function_func fun, int minargs, int maxargs,
- int ftype)
+ int ftype)
{
FUN *fp;
fp = (FUN *) mush_malloc(sizeof(FUN), "function");
buff = (char *) mush_malloc(BUFFER_LEN, "strip_braces.buff");
bufc = buff;
- while (isspace((unsigned char) *str)) /* eat spaces at the beginning */
+ while (isspace((unsigned char) *str)) /* eat spaces at the beginning */
str++;
switch (*str) {
process_expression(buff, &bufc, &str, 0, 0, 0, PE_NOTHING, PT_BRACE, NULL);
*bufc = '\0';
return buff;
- break; /* NOT REACHED */
+ break; /* NOT REACHED */
default:
strcpy(buff, str);
return buff;
} else if (string_prefix(restriction, "nofix")) {
flag = FN_NOFIXED;
} else if (string_prefix(restriction, "norp")) {
- flag = FN_NORP;
+ flag = FN_NORP;
} else if (!strcasecmp(restriction, "noguest")) {
flag = FN_NOGUEST;
} else if (!strcasecmp(restriction, "admin")) {
*/
notify(player, T("Function Name Dbref # Attrib"));
for (fp = (FUN *) hash_firstentry(&htab_user_function);
- fp; fp = (FUN *) hash_nextentry(&htab_user_function)) {
- notify_format(player,
- "%-32s %6d %s", fp->name,
- userfn_tab[fp->where.offset].thing,
- userfn_tab[fp->where.offset].name);
+ fp; fp = (FUN *) hash_nextentry(&htab_user_function)) {
+ notify_format(player,
+ "%-32s %6d %s", fp->name,
+ userfn_tab[fp->where.offset].thing,
+ userfn_tab[fp->where.offset].name);
}
} else {
/* just print out the list of available functions */
safe_str(T("User functions:"), tbuf1, &bp);
for (fp = (FUN *) hash_firstentry(&htab_user_function);
- fp; fp = (FUN *) hash_nextentry(&htab_user_function)) {
- safe_chr(' ', tbuf1, &bp);
- safe_str(fp->name, tbuf1, &bp);
+ fp; fp = (FUN *) hash_nextentry(&htab_user_function)) {
+ safe_chr(' ', tbuf1, &bp);
+ safe_str(fp->name, tbuf1, &bp);
}
*bp = '\0';
notify(player, tbuf1);
if (argv[3] && *argv[3]) {
fp->minargs = parse_integer(argv[3]);
if (fp->minargs < 0)
- fp->minargs = 0;
+ fp->minargs = 0;
else if (fp->minargs > 10)
- fp->minargs = 10;
+ fp->minargs = 10;
} else
fp->minargs = 0;
if (argv[4] && *argv[4]) {
fp->maxargs = parse_integer(argv[4]);
if (fp->maxargs < -10)
- fp->maxargs = -10;
+ fp->maxargs = -10;
else if (fp->maxargs > 10)
- fp->maxargs = 10;
+ fp->maxargs = 10;
} else
fp->maxargs = 10;
if (argv[5] && *argv[5])
notify(player, T("You cannot change that built-in function."));
return;
}
- if (fp->flags & FN_BUILTIN) { /* Overriding a built in function */
+ if (fp->flags & FN_BUILTIN) { /* Overriding a built in function */
if (userfn_count >= (Size_t) MAX_GLOBAL_FNS) {
- notify(player, T("Function table full."));
- return;
+ notify(player, T("Function table full."));
+ return;
}
fp = (FUN *) mush_malloc(sizeof(FUN), "func_hash.FUN");
fp->name = mush_strdup(name, "func_hash.name");
userfn_tab[fp->where.offset].thing = thing;
if (userfn_tab[fp->where.offset].name)
mush_free((Malloc_t) userfn_tab[fp->where.offset].name,
- "userfn_tab.name");
+ "userfn_tab.name");
userfn_tab[fp->where.offset].name =
mush_strdup(upcasestr(argv[2]), "userfn_tab.name");
if (argv[3] && *argv[3]) {
fp->minargs = parse_integer(argv[3]);
if (fp->minargs < 0)
- fp->minargs = 0;
+ fp->minargs = 0;
else if (fp->minargs > 10)
- fp->minargs = 10;
+ fp->minargs = 10;
} else
fp->minargs = 0;
if (argv[4] && *argv[4]) {
fp->maxargs = parse_integer(argv[4]);
if (fp->maxargs < -10)
- fp->maxargs = -10;
+ fp->maxargs = -10;
else if (fp->maxargs > 10)
- fp->maxargs = 10;
+ fp->maxargs = 10;
} else
fp->maxargs = 10;
}
if(fp->flags & FN_NORP) {
- if(first == 0)
- safe_strl(", ", 2, tbuf, &tp);
- safe_str("NoRPMODE", tbuf, &tp);
- first =0;
+ if(first == 0)
+ safe_strl(", ", 2, tbuf, &tp);
+ safe_str("NoRPMODE", tbuf, &tp);
+ first =0;
}
if (fp->flags & FN_DIRECTOR) {
if (!(fp->flags & FN_BUILTIN) && Global_Funcs(player)) {
notify_format(player, T("Location : #%d/%s"),
- userfn_tab[fp->where.offset].thing,
- userfn_tab[fp->where.offset].name);
+ userfn_tab[fp->where.offset].thing,
+ userfn_tab[fp->where.offset].name);
}
maxargs = abs(fp->maxargs);
notify_format(player, T("Arguments : At least %d %s"), fp->minargs, tbuf);
else
notify_format(player,
- T("Arguments : %d to %d %s"), fp->minargs, maxargs, tbuf);
+ T("Arguments : %d to %d %s"), fp->minargs, maxargs, tbuf);
}
#include "confmagic.h"
#ifdef WIN32
-#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
extern PRIV attr_privs_view[];
static lock_type get_locktype(char *str);
extern struct db_stat_info *get_stats(dbref owner);
static int lattr_helper(dbref player, dbref thing, dbref parent, char const *pattern,
- ATTR *atr, void *args);
+ ATTR *atr, void *args);
static dbref
dbwalk(char *buff, char **bp, dbref executor, dbref enactor,
int type, dbref loc, dbref after, int skipdark,
- int start, int count, int *retcount);
+ int start, int count, int *retcount);
const char *
if (a) {
if (Can_Read_Attr(executor, thing, a)) {
if (strlen(value = atr_value(a)) < BUFFER_LEN)
- return value;
+ return value;
else
- return T("#-1 ATTRIBUTE LENGTH TOO LONG");
+ return T("#-1 ATTRIBUTE LENGTH TOO LONG");
}
return T(e_atrperm);
}
/** Structure containing arguments for lattr_helper */
struct lh_args {
- int first; /**< Is this is the first attribute, or later? */
- char *buff; /**< Buffer to store output */
- char **bp; /**< Pointer to address of insertion point in buff */
+ int first; /**< Is this is the first attribute, or later? */
+ char *buff; /**< Buffer to store output */
+ char **bp; /**< Pointer to address of insertion point in buff */
};
/* this function produces a space-separated list of attributes that are
/* ARGSUSED */
static int
lattr_helper(dbref player __attribute__ ((__unused__)),
- dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *pattern __attribute__ ((__unused__)),
- ATTR *atr, void *args)
+ dbref thing __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern __attribute__ ((__unused__)),
+ ATTR *atr, void *args)
{
struct lh_args *lh = args;
if (lh->first)
FUNCTION(fun_ooref) {
- safe_dbref(ooref, buff, bp);
+ safe_dbref(ooref, buff, bp);
}
/* ARGSUSED */
FUNCTION(fun_lattr)
if (pattern)
*pattern++ = '\0';
else
- pattern = (char *) "*"; /* match anything */
+ pattern = (char *) "*"; /* match anything */
thing = match_thing(executor, args[0]);
if (!GoodObject(thing)) {
dp = mstr;
sp = args[i - 1];
process_expression(mstr, &dp, &sp, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
*dp = '\0';
parse_attrib(executor, mstr, &thing, &attrib);
if (GoodObject(thing) && attrib && Can_Read_Attr(executor, thing, attrib)) {
/* We couldn't get it. Evaluate the last arg and return it */
sp = args[nargs - 1];
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
return;
}
tp = tbuf = safe_atr_value(a);
add_check("fun_eval.attr_value");
process_expression(buff, bp, &tp, thing, executor, executor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) tbuf, "fun_eval.attr_value");
return;
} else if (a || !Can_Examine(executor, thing)) {
tp = tbuf = safe_atr_value(a);
add_check("fun_eval.attr_value");
process_expression(buff, bp, &tp, thing, executor, executor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) tbuf, "fun_eval.attr_value");
return;
} else if (a || !Can_Examine(executor, thing)) {
dp = mstr;
sp = args[0];
process_expression(mstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
parse_attrib(executor, mstr, &thing, &attrib);
if (GoodObject(thing) && attrib && Can_Read_Attr(executor, thing, attrib)) {
sp = sbuf = safe_atr_value(attrib);
add_check("fun_edefault.attr_value");
process_expression(buff, bp, &sp, thing, executor, executor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) sbuf, "fun_edefault.attr_value");
return;
}
/* We couldn't get it. Evaluate args[1] and return it */
sp = args[1];
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
return;
}
case '8':
case '9':
if (global_eval_context.wenv[c - '0'])
- safe_str(global_eval_context.wenv[c - '0'], buff, bp);
+ safe_str(global_eval_context.wenv[c - '0'], buff, bp);
return;
case '#':
/* enactor dbref */
}
#ifdef WIN32
-#pragma warning( default : 4761) /* Re-enable conversion warning */
+#pragma warning( default : 4761) /* Re-enable conversion warning */
#endif
/* ARGSUSED */
* use type == TYPE_PLAYER for this check. :-/.
*/
if (!(Typeof(thing) & type) ||
- !can_interact(thing, executor, INTERACT_SEE) ||
- (skipdark && Dark(thing) && !Light(thing) && !Light(loc)) ||
- ((type == TYPE_PLAYER) && skipdark && !Connected(thing)))
- continue;
+ !can_interact(thing, executor, INTERACT_SEE) ||
+ (skipdark && Dark(thing) && !Light(thing) && !Light(loc)) ||
+ ((type == TYPE_PLAYER) && skipdark && !Connected(thing)))
+ continue;
nthing += 1;
if (count < 1 || (nthing >= start && nthing < start + count)) {
- if (buff) {
- if (first)
- first = 0;
- else
- safe_chr(' ', buff, bp);
- safe_dbref(thing, buff, bp);
- }
+ if (buff) {
+ if (first)
+ first = 0;
+ else
+ safe_chr(' ', buff, bp);
+ safe_dbref(thing, buff, bp);
+ }
}
if (result == NOTHING) {
- if (after == NOTHING)
- result = thing;
- if (after == thing)
- after = NOTHING;
+ if (after == NOTHING)
+ result = thing;
+ if (after == thing)
+ after = NOTHING;
}
if (retcount)
- *retcount = nthing;
+ *retcount = nthing;
}
} else if (buff)
safe_str("#-1", buff, bp);
case 'D':
type = TYPE_DIVISION; /* divisions */
break;
- case 'C': /* con */
+ case 'C': /* con */
type = TYPE_THING | TYPE_PLAYER;
break;
- case 'T': /* things */
+ case 'T': /* things */
type = TYPE_THING;
break;
- case 'P': /* players */
+ case 'P': /* players */
type = TYPE_PLAYER;
break;
- case 'E': /* exits */
+ case 'E': /* exits */
type = TYPE_EXIT;
break;
default:
}
dbwalk(buffptr, bptr, executor, enactor, type, loc, NOTHING,
- vis, start, count, &result);
+ vis, start, count, &result);
if (!buffptr) {
safe_integer(result, buff, bp);
{
dbref loc = match_thing(executor, args[0]);
safe_dbref(dbwalk (NULL, NULL, executor, enactor, TYPE_THING | TYPE_PLAYER, loc,
- NOTHING, 0, 0, 0, NULL), buff, bp);
+ NOTHING, 0, 0, 0, NULL), buff, bp);
}
{
dbref loc = match_thing(executor, args[0]);
safe_dbref(dbwalk (NULL, NULL, executor, enactor, TYPE_EXIT, loc, NOTHING, 0, 0, 0,
- NULL), buff, bp);
+ NULL), buff, bp);
}
dbref counter;
dbref entrance;
int found;
- int exd, td, pd, rd; /* what we're looking for */
+ int exd, td, pd, rd; /* what we're looking for */
char *p;
if (!command_check_byname(executor, "@entrances")) {
switch (*p) {
case 'a':
case 'A':
- exd = td = pd = rd = 1;
- break;
+ exd = td = pd = rd = 1;
+ break;
case 'e':
case 'E':
- exd = 1;
- break;
+ exd = 1;
+ break;
case 't':
case 'T':
- td = 1;
- break;
+ td = 1;
+ break;
case 'p':
case 'P':
- pd = 1;
- break;
+ pd = 1;
+ break;
case 'r':
case 'R':
- rd = 1;
- break;
+ rd = 1;
+ break;
default:
- safe_str(T("#-1 INVALID SECOND ARGUMENT"), buff, bp);
- return;
+ safe_str(T("#-1 INVALID SECOND ARGUMENT"), buff, bp);
+ return;
}
p++;
}
}
if (!payfor(executor, FIND_COST)) {
notify_format(executor, T("You don't have %d %s to do that."),
- FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES));
+ FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES));
safe_str("#-1", buff, bp);
return;
}
for (counter = low; counter <= high; counter++) {
if (controls(executor, where) || controls(executor, counter)) {
if ((exd && IsExit(counter)) ||
- (td && IsThing(counter)) ||
- (pd && IsPlayer(counter)) || (rd && IsRoom(counter))) {
- if (Mobile(counter))
- entrance = Home(counter);
- else
- entrance = Location(counter);
- if (entrance == where) {
- if (!found)
- found = 1;
- else
- safe_chr(' ', buff, bp);
- safe_dbref(counter, buff, bp);
- }
+ (td && IsThing(counter)) ||
+ (pd && IsPlayer(counter)) || (rd && IsRoom(counter))) {
+ if (Mobile(counter))
+ entrance = Home(counter);
+ else
+ entrance = Location(counter);
+ if (entrance == where) {
+ if (!found)
+ found = 1;
+ else
+ safe_chr(' ', buff, bp);
+ safe_dbref(counter, buff, bp);
+ }
}
}
}
else if (!GoodObject(thing))
safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp);
else if (!(controls(executor, it) || controls(executor, thing)
- || CanSee(executor, it) || CanSee(executor, thing)))
+ || CanSee(executor, it) || CanSee(executor, thing)))
safe_str(T(e_perm), buff, bp);
else
safe_chr(controls(it, thing) ? '1' : '0', buff, bp);
default:
safe_str("WEIRD OBJECT", buff, bp);
do_rawlog(LT_ERR, T("WARNING: Weird object #%d (type %d)\n"), it,
- Typeof(it));
+ Typeof(it));
}
}
dbref it = match_thing(executor, args[0]);
if (!strcmp(called_as, "ORLPOWERS"))
safe_boolean(flaglist_check_long("POWER", executor, it, args[1], 0), buff,
- bp);
+ bp);
else
safe_boolean(flaglist_check_long("FLAG", executor, it, args[1], 0), buff,
- bp);
+ bp);
}
/* ARGSUSED */
dbref it = match_thing(executor, args[0]);
if (!strcmp(called_as, "ANDLPOWERS"))
safe_boolean(flaglist_check_long("POWER", executor, it, args[1], 1), buff,
- bp);
+ bp);
else
safe_boolean(flaglist_check_long("FLAG", executor, it, args[1], 1), buff,
- bp);
+ bp);
}
static lock_type
if (GoodObject(it) && (real_ltype != NULL)
&& Can_Read_Lock(executor, it, real_ltype)) {
safe_str(unparse_boolexp(executor, getlock(it, real_ltype), UB_DBREF),
- buff, bp);
+ buff, bp);
return;
}
safe_str("#-1", buff, bp);
else if (!GoodObject(victim))
safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp);
else if (!CanSee(executor, obj) && !controls(executor, obj) &&
- !controls(executor, victim))
+ !controls(executor, victim))
safe_str(T(e_perm), buff, bp);
else
safe_boolean(Can_Locate(obj, victim), buff, bp);
if (GoodObject(it) && Can_Locate(executor, it)) {
for(loc = it; GoodObject(Location(loc)) ; loc = Location(loc)) {
- if(loc != it)
- safe_chr(' ', buff, bp);
- safe_dbref(Location(loc), buff, bp);
- }
+ if(loc != it)
+ safe_chr(' ', buff, bp);
+ safe_dbref(Location(loc), buff, bp);
+ }
}
else safe_str("#-1", buff, bp);
-
+
}
/* ARGSUSED */
else {
for (i = 0; i < deep; i++) {
if (!GoodObject(it) || IsRoom(it))
- break;
+ break;
it = Location(it);
}
safe_dbref(it, buff, bp);
if (is_integer(args[0])) {
int a = parse_integer(args[0]);
if (abs(a) == 1)
- safe_str(MONEY, buff, bp);
+ safe_str(MONEY, buff, bp);
else
- safe_str(MONIES, buff, bp);
+ safe_str(MONIES, buff, bp);
} else {
/* Guess we're just making a typo or something. */
safe_str("#-1", buff, bp);
if (strchr(args[0], '/')) {
parse_attrib(executor, args[0], &thing, &attrib);
if (!GoodObject(thing) || !attrib
- || !Can_Read_Attr(executor, thing, attrib))
+ || !Can_Read_Attr(executor, thing, attrib))
safe_str("#-1", buff, bp);
else
safe_dbref(attrib->creator, buff, bp);
/* Support changing alias via function if side-effects are enabled */
if (nargs == 2) {
if (!command_check_byname(executor, "ATTRIB_SET")
- || fun->flags & FN_NOSIDEFX) {
+ || fun->flags & FN_NOSIDEFX) {
safe_str(T(e_perm), buff, bp);
return;
}
}
it = match_thing(executor, args[0]);
if (GoodObject(it))
- /* Quick Fix for most code dealing with know system */
- /* All code.. when the enactor is IC & so is the person they're
- * trying to gt the name of, they will get their 'know name' variant.
- * Only exceptions are A) Code called from the master room
- * B) Code called from a division object
- * C) The enactor has see_all over the other player & are over the empire levels
- **/
+ /* Quick Fix for most code dealing with know system */
+ /* All code.. when the enactor is IC & so is the person they're
+ * trying to gt the name of, they will get their 'know name' variant.
+ * Only exceptions are A) Code called from the master room
+ * B) Code called from a division object
+ * C) The enactor has see_all over the other player & are over the empire levels
+ **/
safe_str(
- shortname(it)
- , buff, bp);
+ shortname(it)
+ , buff, bp);
else
safe_str(T(e_notvis), buff, bp);
}
#ifdef KNOW_SYS
FUNCTION(fun_checkknow) {
- dbref who;
- dbref what;
+ dbref who;
+ dbref what;
- who = match_thing(executor, args[0]);
- what = match_thing(executor, args[1]);
+ who = match_thing(executor, args[0]);
+ what = match_thing(executor, args[1]);
- if(!IsPlayer(who) || !IsPlayer(what)) {
- safe_str((e_notvis), buff, bp);
- return;
- }
+ if(!IsPlayer(who) || !IsPlayer(what)) {
+ safe_str((e_notvis), buff, bp);
+ return;
+ }
- safe_chr(check_know(who,what) ? '1' : '0' , buff, bp);
+ safe_chr(check_know(who,what) ? '1' : '0' , buff, bp);
}
#endif
if (GoodObject(it)) {
/* You must either be see_all, control it, or be inside it */
if (!(controls(executor, it) || CanSee(executor, it) ||
- (Location(executor) == it))) {
+ (Location(executor) == it))) {
safe_str(T(e_perm), buff, bp);
return;
}
if (nameformat(executor, it, tbuf1,
- IsExit(it) ? shortname(it) : (char *) accented_name(it)))
+ IsExit(it) ? shortname(it) : (char *) accented_name(it)))
safe_str(tbuf1, buff, bp);
else if (IsExit(it))
safe_str(shortname(it), buff, bp);
match_flags |= MAT_ENGLISH;
break;
case 'X':
- ambig_ok = 1; /* okay to pick last match */
+ ambig_ok = 1; /* okay to pick last match */
break;
default:
notify_format(executor, T("I don't understand switch '%c'."), *p);
if (Can_Examine(executor, loc))
safe_dbref(item, buff, bp);
else if (can_interact(item, executor, INTERACT_SEE)
- && (!DarkLegal(item) || Light(loc) || Light(item)))
+ && (!DarkLegal(item) || Light(loc) || Light(item)))
safe_dbref(item, buff, bp);
else
safe_dbref(NOTHING, buff, bp);
} else {
if (can_interact(item, executor, INTERACT_SEE)
- && (See_All(executor) || !DarkLegal(item) || Light(item)))
+ && (See_All(executor) || !DarkLegal(item) || Light(item)))
safe_dbref(item, buff, bp);
else
safe_dbref(NOTHING, buff, bp);
si = get_stats(who);
if (who != ANY_OWNER) {
safe_format(buff, bp, "%d %d %d %d %d %d", si->total - si->garbage, si->rooms,
- si->exits, si->things, si->players, si->divisions);
+ si->exits, si->things, si->players, si->divisions);
} else {
safe_format(buff, bp, "%d %d %d %d %d %d %d", si->total, si->rooms, si->exits,
- si->things, si->players, si->divisions, si->garbage);
+ si->things, si->players, si->divisions, si->garbage);
}
}
if (status == 1) {
if (FUNCTION_SIDE_EFFECTS) {
if (!command_check_byname(executor, "@atrlock")
- || fun->flags & FN_NOSIDEFX) {
- safe_str(T(e_perm), buff, bp);
- return;
+ || fun->flags & FN_NOSIDEFX) {
+ safe_str(T(e_perm), buff, bp);
+ return;
}
do_atrlock(executor, args[0], args[1], 0);
return;
if ((thing =
noisy_match_result(executor, args[0], NOTYPE,
- MAT_EVERYTHING)) == NOTHING) {
+ MAT_EVERYTHING)) == NOTHING) {
safe_str(T(e_notvis), buff, bp);
return;
}
if ((thing =
noisy_match_result(executor, args[0], NOTYPE,
- MAT_EVERYTHING)) == NOTHING) {
+ MAT_EVERYTHING)) == NOTHING) {
safe_str(T(e_notvis), buff, bp);
return;
}
static char *next_token(char *str, char sep);
static char *autodetect_list(char **ptrs, int nptrs);
static char *get_list_type(char **args, int nargs,
- int type_pos, char **ptrs, int nptrs);
+ int type_pos, char **ptrs, int nptrs);
static char *get_list_type_noauto(char **args, int nargs, int type_pos);
static int i_comp(const void *s1, const void *s2);
static int f_comp(const void *s1, const void *s2);
static int u_comp(const void *s1, const void *s2);
static int regrep_helper(dbref who, dbref what, dbref parent,
- char const *name, ATTR *atr, void *args);
+ char const *name, ATTR *atr, void *args);
/** Type definition for a qsort comparison function */
typedef int (*comp_func) (const void *, const void *);
static void sane_qsort(void **array, int left, int right, comp_func compare);
static void do_itemfuns(char *buff, char **bp, char *str, char *num,
- char *word, char *sep, int flag);
+ char *word, char *sep, int flag);
char *iter_rep[MAX_ITERS]; /**< itext values */
int iter_place[MAX_ITERS]; /**< inum numbers */
-int inum = 0; /**< iter depth */
-int inum_limit = 0; /**< limit of iter depth */
+int inum = 0; /**< iter depth */
+int inum_limit = 0; /**< limit of iter depth */
int iter_break = 0; /**< iter break */
extern const unsigned char *tables;
if(*p == sep) {
*p = '\0';
if(lp != NULL) {
- safe_str(lp, cbufp, &bp);
+ safe_str(lp, cbufp, &bp);
*bp++ = '\0';
- r[i++] = cbufp;
- cbufp = bp;
+ r[i++] = cbufp;
+ cbufp = bp;
} else r[i++] = NULL;
lp = ++p;
continue;
uargs[0] = lp;
uargs[1] = isep;
do_userfn(rlist, &rp, thing, attrib, 2, uargs,
- executor, caller, enactor, pe_info);
+ executor, caller, enactor, pe_info);
*rp = '\0';
/* Now that we have our result, put it back into array form. Search
for (i = 0; i < nresults; i++) {
for (j = 0; j < nptrs1; j++) {
if (ptrs2[j] && !strcmp(results[i], ptrs1[j])) {
- if (first)
- first = 0;
- else
- safe_str(osep, buff, bp);
- safe_str(ptrs2[j], buff, bp);
- ptrs2[j] = NULL;
- break;
+ if (first)
+ first = 0;
+ else
+ safe_str(osep, buff, bp);
+ safe_str(ptrs2[j], buff, bp);
+ ptrs2[j] = NULL;
+ break;
}
}
}
r = split_token(&s, sep);
if (quick_wild(args[1], r)) {
if (*bp != b)
- safe_str(osep, buff, bp);
+ safe_str(osep, buff, bp);
safe_integer(wcount, buff, bp);
}
wcount++;
r = split_token(&s, sep);
if (quick_wild(args[1], r)) {
if (*bp != b)
- safe_str(osep, buff, bp);
+ safe_str(osep, buff, bp);
safe_str(r, buff, bp);
}
} while (s);
wenv[1] = split_token(&cp, sep);
per = call_ufun(&ufun, wenv, 2, result, executor, enactor, pe_info);
if (per || (pe_info->fun_invocations >= FUNCTION_LIMIT &&
- pe_info->fun_invocations == funccount && !strcmp(base, result)))
+ pe_info->fun_invocations == funccount && !strcmp(base, result)))
break;
funccount = pe_info->fun_invocations;
strcpy(base, result);
if (call_ufun(&ufun, wenv, 1, result, executor, enactor, pe_info))
break;
if ((check_bool == 0)
- ? (*result == '1' && *(result + 1) == '\0')
- : parse_boolean(result)) {
+ ? (*result == '1' && *(result + 1) == '\0')
+ : parse_boolean(result)) {
if (first)
- first = 0;
+ first = 0;
else
- safe_str(osep, buff, bp);
+ safe_str(osep, buff, bp);
safe_str(wenv[0], buff, bp);
}
/* Can't do *bp == oldbp like in all the others, because bp might not
switch (lt) {
case L_NUMERIC:
if (!is_strict_integer(ptrs[i])) {
- /* If it's not an integer, see if it's a floating-point number */
- if (is_strict_number(ptrs[i])) {
- lt = L_FLOAT;
- sort_type = FLOAT_LIST;
- } else if (i == 0) {
-
- /* If we get something non-numeric, switch to an
- * alphanumeric guess, unless this is the first
- * element and we have a dbref.
- */
- if (is_objid(ptrs[i])) {
- lt = L_DBREF;
- sort_type = DBREF_LIST;
- } else
- return ALPHANUM_LIST;
- }
+ /* If it's not an integer, see if it's a floating-point number */
+ if (is_strict_number(ptrs[i])) {
+ lt = L_FLOAT;
+ sort_type = FLOAT_LIST;
+ } else if (i == 0) {
+
+ /* If we get something non-numeric, switch to an
+ * alphanumeric guess, unless this is the first
+ * element and we have a dbref.
+ */
+ if (is_objid(ptrs[i])) {
+ lt = L_DBREF;
+ sort_type = DBREF_LIST;
+ } else
+ return ALPHANUM_LIST;
+ }
}
break;
case L_FLOAT:
if (!is_strict_number(ptrs[i]))
- return ALPHANUM_LIST;
+ return ALPHANUM_LIST;
break;
case L_DBREF:
if (!is_objid(ptrs[i]))
- return ALPHANUM_LIST;
+ return ALPHANUM_LIST;
break;
default:
return ALPHANUM_LIST;
* its 'key' to sort by. Sort of a hardcode munge.
*/
struct sort_record {
- char *ptr; /**< NULL except for sortkey */
- char *val; /**< The string this is */
- dbref db; /**< dbref (default 0, bad is -1) */
- char *str; /**< string comparisons */
- int num; /**< integer comparisons */
- NVAL numval; /**< float comparisons */
- int freestr; /**< free str on completion */
+ char *ptr; /**< NULL except for sortkey */
+ char *val; /**< The string this is */
+ dbref db; /**< dbref (default 0, bad is -1) */
+ char *str; /**< string comparisons */
+ int num; /**< integer comparisons */
+ NVAL numval; /**< float comparisons */
+ int freestr; /**< free str on completion */
};
/* Compare(r,x,y) {
strcpy(stype, str);
str = strchr(stype, ':');
if (str)
- *(str++) = '\0';
+ *(str++) = '\0';
for (i = 0; ltypelist[i].name && strcasecmp(ltypelist[i].name, stype);
- i++) ;
+ i++) ;
/* return ltypelist[i].name; */
if (ltypelist[i].name) {
- return args[type_pos - 1];
+ return args[type_pos - 1];
}
}
}
strcpy(stype, str);
str = strchr(stype, ':');
if (str)
- *(str++) = '\0';
+ *(str++) = '\0';
for (i = 0; ltypelist[i].name && strcasecmp(ltypelist[i].name, stype);
- i++) ;
+ i++) ;
/* return ltypelist[i].name; */
return args[type_pos - 1];
}
tbuf = ucomp_buff;
rp = result;
if (process_expression(result, &rp, &tbuf,
- ucomp_executor, ucomp_caller, ucomp_enactor,
- PE_DEFAULT, PT_DEFAULT, ucomp_pe_info))
+ ucomp_executor, ucomp_caller, ucomp_enactor,
+ PE_DEFAULT, PT_DEFAULT, ucomp_pe_info))
return 0;
n = parse_integer(result);
if (!*ptr)
ptr = NULL;
for (i = 0;
- ltypelist[i].name && strncasecmp(ltypelist[i].name, sort_type, len);
- i++) ;
+ ltypelist[i].name && strncasecmp(ltypelist[i].name, sort_type, len);
+ i++) ;
} else {
for (i = 0; ltypelist[i].name && strcasecmp(ltypelist[i].name, sort_type);
- i++) ;
+ i++) ;
}
s1.freestr = s2.freestr = 0;
if (ltypelist[i].isdbs) {
if (!*ptr)
ptr = NULL;
for (sorti = 0;
- ltypelist[sorti].name && strcasecmp(ltypelist[sorti].name, stype);
- sorti++) ;
+ ltypelist[sorti].name && strcasecmp(ltypelist[sorti].name, stype);
+ sorti++) ;
} else {
for (sorti = 0;
- ltypelist[sorti].name && strcasecmp(ltypelist[sorti].name, sort_type);
- sorti++) ;
+ ltypelist[sorti].name && strcasecmp(ltypelist[sorti].name, sort_type);
+ sorti++) ;
}
sp = (s_rec *) mush_malloc(n * sizeof(s_rec), "do_gensort");
for (i = 0; i < n; i++) {
if (ltypelist[sorti].isdbs) {
sp[i].db = parse_objid(keys[i]);
if (!RealGoodObject(sp[i].db))
- sp[i].db = NOTHING;
+ sp[i].db = NOTHING;
}
ltypelist[sorti].make_record(&(sp[i]), player, ptr);
}
if (compare(array[i], array[left]) < 0) {
last++;
if (last == i)
- continue;
+ continue;
tmp = array[last];
array[last] = array[i];
rp = result;
cp = tbuff;
process_expression(result, &rp, &cp,
- thing, executor, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ thing, executor, enactor,
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*rp = '\0';
keys[i] = mush_strdup(result, "sortkey");
}
/* Split up the list, sort it, reconstruct it. */
nptrs = list2arr(ptrs, MAX_SORTSIZE, args[1], sep);
- if (nptrs > 1) /* pointless to sort less than 2 elements */
+ if (nptrs > 1) /* pointless to sort less than 2 elements */
sane_qsort((void *) ptrs, 0, nptrs - 1, u_comp);
arr2list(ptrs, nptrs, buff, bp, osep);
osepd[0] = sep;
osep = osepd;
if (sep)
- osepl = 1;
+ osepl = 1;
}
} else if (nargs == 5) {
sort_type = get_list_type(args, nargs, 4, a1, n1);
if (val < 0) {
x1++;
if (x1 >= n1) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
}
} else {
x2++;
if (x2 >= n2) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
}
}
}
while ((x1 < n1) && (x2 < n2)) {
while ((val = gencomp(executor, a1[x1], a2[x2], sort_type))) {
if (val < 0) {
- x1++;
- if (x1 >= n1) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
- }
+ x1++;
+ if (x1 >= n1) {
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
+ }
} else {
- x2++;
- if (x2 >= n2) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
- }
+ x2++;
+ if (x2 >= n2) {
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
+ }
}
}
safe_strl(osep, osepl, buff, bp);
while (!gencomp(executor, a1[x1], a2[x2], sort_type)) {
x1++;
if (x1 >= n1) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
}
}
}
osepd[0] = sep;
osep = osepd;
if (sep)
- osepl = 1;
+ osepl = 1;
}
} else if (nargs == 5) {
sort_type = get_list_type(args, nargs, 4, a1, n1);
if (x1 < n1 && lastx1 >= 0) {
val = gencomp(executor, a1[lastx1], a1[x1], sort_type);
if (val == 0) {
- x1++;
- continue;
+ x1++;
+ continue;
}
}
if (x1 < n1 && lastx2 >= 0) {
val = gencomp(executor, a2[lastx2], a1[x1], sort_type);
if (val == 0) {
- x1++;
- continue;
+ x1++;
+ continue;
}
}
if (x2 < n2 && lastx1 >= 0) {
val = gencomp(executor, a1[lastx1], a2[x2], sort_type);
if (val == 0) {
- x2++;
- continue;
+ x2++;
+ continue;
}
}
if (x2 < n2 && lastx2 >= 0) {
val = gencomp(executor, a2[lastx2], a2[x2], sort_type);
if (val == 0) {
- x2++;
- continue;
+ x2++;
+ continue;
}
}
if (x1 >= n1) {
/* Just copy off the rest of a2 */
if (x2 < n2) {
- if (found)
- safe_strl(osep, osepl, buff, bp);
- safe_str(a2[x2], buff, bp);
- lastx2 = x2;
- x2++;
- found = 1;
+ if (found)
+ safe_strl(osep, osepl, buff, bp);
+ safe_str(a2[x2], buff, bp);
+ lastx2 = x2;
+ x2++;
+ found = 1;
}
} else if (x2 >= n2) {
/* Just copy off the rest of a1 */
if (x1 < n1) {
- if (found)
- safe_strl(osep, osepl, buff, bp);
- safe_str(a1[x1], buff, bp);
- lastx1 = x1;
- x1++;
- found = 1;
+ if (found)
+ safe_strl(osep, osepl, buff, bp);
+ safe_str(a1[x1], buff, bp);
+ lastx1 = x1;
+ x1++;
+ found = 1;
}
} else {
/* At this point, we're merging. Take the lower of the two. */
val = gencomp(executor, a1[x1], a2[x2], sort_type);
if (val <= 0) {
- if (found)
- safe_strl(osep, osepl, buff, bp);
- safe_str(a1[x1], buff, bp);
- lastx1 = x1;
- x1++;
- found = 1;
+ if (found)
+ safe_strl(osep, osepl, buff, bp);
+ safe_str(a1[x1], buff, bp);
+ lastx1 = x1;
+ x1++;
+ found = 1;
} else {
- if (found)
- safe_strl(osep, osepl, buff, bp);
- safe_str(a2[x2], buff, bp);
- lastx2 = x2;
- x2++;
- found = 1;
+ if (found)
+ safe_strl(osep, osepl, buff, bp);
+ safe_str(a2[x2], buff, bp);
+ lastx2 = x2;
+ x2++;
+ found = 1;
}
}
}
osepd[0] = sep;
osep = osepd;
if (sep)
- osepl = 1;
+ osepl = 1;
}
} else if (nargs == 5) {
sort_type = get_list_type(args, nargs, 4, a1, n1);
if (val > 0) {
x2++;
if (x2 >= n2)
- break;
+ break;
}
if (!val) {
x1++;
if (x1 >= n1) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
}
}
}
}
if (val <= 0) {
do {
- x1++;
- if (x1 >= n1) {
- mush_free((Malloc_t) a1, "ptrarray");
- mush_free((Malloc_t) a2, "ptrarray");
- return;
- }
+ x1++;
+ if (x1 >= n1) {
+ mush_free((Malloc_t) a1, "ptrarray");
+ mush_free((Malloc_t) a2, "ptrarray");
+ return;
+ }
} while (!gencomp(executor, a1[x1], a1[x1 - 1], sort_type));
}
if (val >= 0)
start = end;
end = parse_number(args[1]);
if ((start == 0) && (end == 0)) {
- safe_str("0", buff, bp); /* Special case - lnum(0,0) -> 0 */
+ safe_str("0", buff, bp); /* Special case - lnum(0,0) -> 0 */
return;
}
} else {
if (end == 0)
- return; /* Special case - lnum(0) -> blank string */
+ return; /* Special case - lnum(0) -> blank string */
else if (end == 1) {
- safe_str("0", buff, bp); /* Special case - lnum(1) -> 0 */
+ safe_str("0", buff, bp); /* Special case - lnum(1) -> 0 */
return;
}
end--;
safe_integer(istart, cresult[cpos], &cp);
if (istart <= iend) {
for (k = istart + 1; k <= iend; k++) {
- safe_str(osep, cresult[cpos], &cp);
- if (safe_integer(k, cresult[cpos], &cp))
- break;
+ safe_str(osep, cresult[cpos], &cp);
+ if (safe_integer(k, cresult[cpos], &cp))
+ break;
}
} else {
for (k = istart - 1; k >= iend; k--) {
- safe_str(osep, cresult[cpos], &cp);
- if (safe_integer(k, cresult[cpos], &cp))
- break;
+ safe_str(osep, cresult[cpos], &cp);
+ if (safe_integer(k, cresult[cpos], &cp))
+ break;
}
}
} else {
safe_number(start, cresult[cpos], &cp);
if (start <= end) {
for (j = start + 1; j <= end; j++) {
- safe_str(osep, cresult[cpos], &cp);
- if (safe_number(j, cresult[cpos], &cp))
- break;
+ safe_str(osep, cresult[cpos], &cp);
+ if (safe_number(j, cresult[cpos], &cp))
+ break;
}
} else {
for (j = start - 1; j >= end; j--) {
- safe_str(osep, cresult[cpos], &cp);
- if (safe_number(j, cresult[cpos], &cp))
- break;
+ safe_str(osep, cresult[cpos], &cp);
+ if (safe_number(j, cresult[cpos], &cp))
+ break;
}
}
}
word_index--;
}
- if (!s || !*s) /* ran off the end of the string */
+ if (!s || !*s) /* ran off the end of the string */
return;
/* Chop off the end, and copy. No length checking needed. */
r = split_token(&s, sep);
victim = parse_dbref(r);
if (!RealGoodObject(victim))
- continue; /* Don't bother with garbage */
+ continue; /* Don't bother with garbage */
if (!(string_match(Name(victim), args[1]) || (absolute == victim)))
- continue;
+ continue;
if (!can_interact(victim, executor, INTERACT_MATCH))
- continue;
+ continue;
/* It matches, and is interact-able */
if (!first)
- safe_chr(sep, buff, bp);
+ safe_chr(sep, buff, bp);
safe_str(r, buff, bp);
first = 0;
} while (s);
r = split_token(&s, sep);
victim = parse_dbref(r);
if (!RealGoodObject(victim))
- continue; /* Don't bother with garbage */
+ continue; /* Don't bother with garbage */
if (!can_interact(victim, executor, INTERACT_MATCH))
- continue;
+ continue;
/* It's real, and is interact-able */
if (!first)
- safe_chr(sep, buff, bp);
+ safe_chr(sep, buff, bp);
safe_str(r, buff, bp);
first = 0;
} while (s);
start--;
}
- if (!s || !*s) /* ran off the end of the string */
+ if (!s || !*s) /* ran off the end of the string */
return;
/* Find the end of the string that we want. */
el++;
} while (*s);
- safe_chr('0', buff, bp); /* no match */
+ safe_chr('0', buff, bp); /* no match */
}
/* ARGSUSED */
*/
static void
do_itemfuns(char *buff, char **bp, char *str, char *num, char *word,
- char *sep, int flag)
+ char *sep, int flag)
{
char c;
int el, count, len = -1;
count = 1;
/* go to the correct item in the string */
- if (el < 0) { /* if using insert() with a negative insertion param */
+ if (el < 0) { /* if using insert() with a negative insertion param */
/* count keeps track of the number of words from the right
* of the string. When count equals the correct position, then
* sptr will point to the count'th word from the right, or
* eptr is just a helper. */
for (len = strlen(str); len >= 0 && count < abs(el); len--, eptr--) {
if (*eptr == c)
- count++;
+ count++;
if (count == abs(el)) {
- sptr = eptr + 1;
- break;
+ sptr = eptr + 1;
+ break;
}
}
} else {
switch (flag) {
case 0:
/* deletion */
- if (!eptr) { /* last element in the string */
+ if (!eptr) { /* last element in the string */
if (el != 1)
- safe_str(str, buff, bp);
- } else if (sptr == str) { /* first element in the string */
- eptr++; /* chop leading separator */
+ safe_str(str, buff, bp);
+ } else if (sptr == str) { /* first element in the string */
+ eptr++; /* chop leading separator */
safe_str(eptr, buff, bp);
} else {
safe_str(str, buff, bp);
break;
case 1:
/* replacing */
- if (!eptr) { /* last element in string */
+ if (!eptr) { /* last element in string */
if (el != 1) {
- safe_str(str, buff, bp);
- safe_chr(c, buff, bp);
+ safe_str(str, buff, bp);
+ safe_chr(c, buff, bp);
}
safe_str(word, buff, bp);
- } else if (sptr == str) { /* first element in string */
+ } else if (sptr == str) { /* first element in string */
safe_str(word, buff, bp);
safe_str(eptr, buff, bp);
} else {
break;
case 2:
/* insertion */
- if (sptr == str) { /* first element in string */
+ if (sptr == str) { /* first element in string */
safe_str(word, buff, bp);
safe_chr(c, buff, bp);
safe_str(str, buff, bp);
el++;
} while (s);
- safe_chr('0', buff, bp); /* not found */
+ safe_chr('0', buff, bp); /* not found */
}
/* ARGSUSED */
int i;
if(!args[0] || !*args[0])
- i = 0;
+ i = 0;
if(i != 0 && !is_strict_integer(args[0])) {
- safe_str(T(e_int), buff, bp);
- return;
+ safe_str(T(e_int), buff, bp);
+ return;
}
if(i != 0) i = parse_integer(args[0]);
if(i < 0 || i >= inum || (inum - i) <= inum_limit) {
- safe_str(T("#-1 ARGUMENT OUT OF RANGE"), buff, bp);
- return;
+ safe_str(T("#-1 ARGUMENT OUT OF RANGE"), buff, bp);
+ return;
}
iter_break = i+1;
char *isep = insep;
const char *arg3 = args[2];
process_expression(insep, &isep, &arg3, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*isep = '\0';
strcpy(args[2], insep);
}
const char *arg4 = args[3];
char *osep = outsep;
process_expression(outsep, &osep, &arg4, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*osep = '\0';
}
lp = list;
sp = args[0];
process_expression(list, &lp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*lp = '\0';
lp = trim_space_sep(list, sep);
if (!*lp) {
tbuf2 = replace_string2(standard_tokens, replace, args[1]);
sp = tbuf2;
if (process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info))
+ PE_DEFAULT, PT_DEFAULT, pe_info))
break;
if (*bp == (buff + BUFFER_LEN - 1) && pe_info->fun_invocations == funccount)
break;
ap = asave;
process_expression(buff, bp, &ap, thing, executor, enactor,
- pe_flags, PT_DEFAULT, pe_info);
+ pe_flags, PT_DEFAULT, pe_info);
oldbp = *bp;
funccount = pe_info->fun_invocations;
while (lp) {
for (n = 0; n < step; n++) {
global_eval_context.wenv[n] = split_token(&lp, sep);
if (!lp) {
- n++;
- break;
+ n++;
+ break;
}
}
for (; n < 10; n++)
global_eval_context.wenv[n] = NULL;
ap = asave;
if (process_expression(buff, bp, &ap, thing, executor, enactor,
- pe_flags, PT_DEFAULT, pe_info))
+ pe_flags, PT_DEFAULT, pe_info))
break;
if (*bp == (buff + BUFFER_LEN - 1) && pe_info->fun_invocations == funccount)
break;
int lists, words;
int first = 1;
- if (nargs > 3) { /* Last arg must be the delimiter */
+ if (nargs > 3) { /* Last arg must be the delimiter */
n = nargs;
lists = nargs - 2;
} else {
words = 0;
for (n = 0; n < lists; n++) {
if (lp[n] && *lp[n]) {
- list[n] = split_token(&lp[n], sep);
- if (list[n])
- words++;
+ list[n] = split_token(&lp[n], sep);
+ if (list[n])
+ words++;
} else {
- list[n] = NULL;
+ list[n] = NULL;
}
}
if (!words)
col += field_width + !!osep;
if (col > line_length) {
if (NEWLINE_ONE_CHAR)
- safe_str("\n", buff, bp);
+ safe_str("\n", buff, bp);
else
- safe_str("\r\n", buff, bp);
+ safe_str("\r\n", buff, bp);
col = field_width + !!osep;
} else {
if (osep)
- safe_chr(osep, buff, bp);
+ safe_chr(osep, buff, bp);
}
t = split_token(&cp, sep);
if (!t)
abp = abuf;
r = args[0];
process_expression(abuf, &abp, &r, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
*abp = '\0';
postp = postbuf;
tbp = tbuf;
r = args[i];
process_expression(tbuf, &tbp, &r, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
*tbp = '\0';
if ((re = pcre_compile(tbuf, flags, &errptr, &erroffset, tables)) == NULL) {
if (all) {
study = pcre_study(re, 0, &errptr);
if (errptr != NULL) {
- mush_free((Malloc_t) re, "pcre");
- safe_str(T("#-1 REGEXP ERROR: "), buff, bp);
- safe_str(errptr, buff, bp);
- return;
+ mush_free((Malloc_t) re, "pcre");
+ safe_str(T("#-1 REGEXP ERROR: "), buff, bp);
+ safe_str(errptr, buff, bp);
+ return;
}
if (study != NULL)
- add_check("pcre.extra");
+ add_check("pcre.extra");
}
len = strlen(prebuf);
start = prebuf;
safe_str(prebuf, postbuf, &postp);
mush_free((Malloc_t) re, "pcre");
if (study)
- mush_free((Malloc_t) study, "pcre.extra");
+ mush_free((Malloc_t) study, "pcre.extra");
continue;
}
global_eval_context.re_offsets = offsets;
global_eval_context.re_subpatterns = subpatterns;
process_expression(postbuf, &postp, &obp, executor, caller, enactor,
- PE_DEFAULT | PE_DOLLAR, PT_DEFAULT, pe_info);
+ PE_DEFAULT | PE_DOLLAR, PT_DEFAULT, pe_info);
if ((*bp == (buff + BUFFER_LEN - 1))
- && (pe_info->fun_invocations == funccount))
- break;
+ && (pe_info->fun_invocations == funccount))
+ break;
oldbp = postp;
funccount = pe_info->fun_invocations;
match_offset = offsets[1];
/* Make sure we advance at least 1 char */
if (offsets[0] == match_offset)
- match_offset++;
+ match_offset++;
} while (all && match_offset < len && (subpatterns =
- pcre_exec(re, study, prebuf, len,
- match_offset, 0, offsets,
- 99)) >= 0);
+ pcre_exec(re, study, prebuf, len,
+ match_offset, 0, offsets,
+ 99)) >= 0);
/* Now copy everything after the matched bit */
if (strcmp(called_as, "REGMATCHI") == 0)
flags = PCRE_CASELESS;
- if (nargs == 2) { /* Don't care about saving sub expressions */
+ if (nargs == 2) { /* Don't care about saving sub expressions */
safe_boolean(quick_regexp_match(args[1], args[0], flags ? 0 : 1), buff, bp);
return;
}
/* subexpr:register */
*regname++ = '\0';
if (is_strict_integer(qregs[i]))
- subpattern = parse_integer(qregs[i]);
+ subpattern = parse_integer(qregs[i]);
else
- named_subpattern = qregs[i];
+ named_subpattern = qregs[i];
} else {
/* Get subexpr by position in list */
subpattern = i;
}
if (regname && regname[0] && !regname[1] &&
- ((qindex = qreg_indexes[(unsigned char) regname[0]]) != -1))
+ ((qindex = qreg_indexes[(unsigned char) regname[0]]) != -1))
curq = qindex;
else
curq = -1;
global_eval_context.renv[curq][0] = '\0';
else if (named_subpattern)
pcre_copy_named_substring(re, args[0], offsets, subpatterns,
- named_subpattern,
- global_eval_context.renv[curq], BUFFER_LEN);
+ named_subpattern,
+ global_eval_context.renv[curq], BUFFER_LEN);
else
pcre_copy_substring(args[0], offsets, subpatterns, subpattern,
- global_eval_context.renv[curq], BUFFER_LEN);
+ global_eval_context.renv[curq], BUFFER_LEN);
}
mush_free((Malloc_t) re, "pcre");
}
/** Structure to hold data for regrep */
struct regrep_data {
- pcre *re; /**< Pointer to compiled regular expression */
- pcre_extra *study; /**< Pointer to studied data about re */
- char *buff; /**< Buffer to store regrep results */
- char **bp; /**< Pointer to address of insertion point in buff */
- int first; /**< Is this the first match or a later match? */
+ pcre *re; /**< Pointer to compiled regular expression */
+ pcre_extra *study; /**< Pointer to studied data about re */
+ char *buff; /**< Buffer to store regrep results */
+ char **bp; /**< Pointer to address of insertion point in buff */
+ int first; /**< Is this the first match or a later match? */
};
/* Like grep(), but using a regexp pattern. This same function handles
flags = PCRE_CASELESS;
if ((reharg.re = pcre_compile(args[2], flags,
- &errptr, &erroffset, tables)) == NULL) {
+ &errptr, &erroffset, tables)) == NULL) {
/* Matching error. */
safe_str(T("#-1 REGEXP ERROR: "), buff, bp);
safe_str(errptr, buff, bp);
static int
regrep_helper(dbref who __attribute__ ((__unused__)),
- dbref what __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *name __attribute__ ((__unused__)),
- ATTR *atr, void *args)
+ dbref what __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ char const *name __attribute__ ((__unused__)),
+ ATTR *atr, void *args)
{
struct regrep_data *reharg = args;
char const *str;
r = split_token(&s, sep);
if (pcre_exec(re, study, r, strlen(r), 0, 0, offsets, 99) >= 0) {
if (all && *bp != b)
- safe_str(osep, buff, bp);
+ safe_str(osep, buff, bp);
safe_str(r, buff, bp);
if (!all)
- break;
+ break;
}
} while (s);
static NVAL angle_to_rad(NVAL angle, const char *from);
static NVAL rad_to_angle(NVAL angle, const char *to);
static double frac(double v, double *RESTRICT n, double *RESTRICT d,
- double error);
+ double error);
void init_math_hashtab(void);
extern int format_long(long n, char *buff, char **bp, int maxlen,
if ((p >= *buff) && !strncasecmp(p, singles[i], len)) {
**bp = p;
safe_str(singleths[i], *buff, *bp);
- return; /* done */
+ return; /* done */
}
}
/* The string didn't end with a single. How about a y? */
if (*pnumber == '.') {
if (ordinal_mode) {
- /* Only integers may be ordinalized */
- safe_str(T(e_int), buff, bp);
- return;
+ /* Only integers may be ordinalized */
+ safe_str(T(e_int), buff, bp);
+ return;
}
if (dot) {
safe_str(T(e_num), buff, bp);
#include "confmagic.h"
#ifdef WIN32
-#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
extern FUN flist[];
if ((nargs % 2) != 0) {
safe_format(buff, bp,
- T("#-1 FUNCTION (%s) EXPECTS AN EVEN NUMBER OF ARGUMENTS"),
- called_as);
+ T("#-1 FUNCTION (%s) EXPECTS AN EVEN NUMBER OF ARGUMENTS"),
+ called_as);
return;
}
for (n = 0; n < nargs; n += 2) {
if (*args[n] && (*(args[n] + 1) == '\0') &&
- ((qindex = qreg_indexes[(unsigned char) args[n][0]]) != -1)
- && global_eval_context.renv[qindex]) {
+ ((qindex = qreg_indexes[(unsigned char) args[n][0]]) != -1)
+ && global_eval_context.renv[qindex]) {
strcpy(global_eval_context.renv[qindex], args[n + 1]);
if (n == 0 && !strcmp(called_as, "SETR"))
- safe_strl(args[n + 1], arglens[n + 1], buff, bp);
+ safe_strl(args[n + 1], arglens[n + 1], buff, bp);
} else {
if (*args[n] && !strpbrk(args[n], "|<>% \n\r\t")) {
set_namedreg(&global_eval_context.namedregs, args[n], args[n+1]);
if (show_all) {
for (count = 0; count < n; count++) {
if (first)
- first = 0;
+ first = 0;
else
- safe_chr(' ', buff, bp);
+ safe_chr(' ', buff, bp);
safe_uinteger(get_random_long(1, die), buff, bp);
}
} else {
dp = mstr;
sp = args[0];
process_expression(mstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
/* try matching, return match immediately when found */
dp = pstr;
sp = args[j];
process_expression(pstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
if ((!exact)
- ? local_wild_match(pstr, mstr)
- : (strcmp(pstr, mstr) == 0)) {
+ ? local_wild_match(pstr, mstr)
+ : (strcmp(pstr, mstr) == 0)) {
/* If there's a #$ in a switch's action-part, replace it with
* the value of the conditional (mstr) before evaluating it.
*/
if (!exact)
- tbuf1 = replace_string("#$", mstr, args[j + 1]);
+ tbuf1 = replace_string("#$", mstr, args[j + 1]);
else
- tbuf1 = args[j + 1];
+ tbuf1 = args[j + 1];
sp = tbuf1;
per = process_expression(buff, bp, &sp,
- executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ executor, caller, enactor,
+ PE_DEFAULT, PT_DEFAULT, pe_info);
if (!exact)
- mush_free((Malloc_t) tbuf1, "replace_string.buff");
+ mush_free((Malloc_t) tbuf1, "replace_string.buff");
found = 1;
if (per || first)
- return;
+ return;
}
}
tbuf1 = replace_string("#$", mstr, args[nargs - 1]);
sp = tbuf1;
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) tbuf1, "replace_string.buff");
}
}
dp = mstr;
sp = args[0];
process_expression(mstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
/* try matching, return match immediately when found */
dp = pstr;
sp = args[j];
process_expression(pstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
if (quick_regexp_match(pstr, mstr, cs)) {
sp = tbuf1;
per = process_expression(buff, bp, &sp,
- executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ executor, caller, enactor,
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) tbuf1, "replace_string.buff");
found = 1;
if (per || first)
- return;
+ return;
}
}
tbuf1 = replace_string("#$", mstr, args[nargs - 1]);
sp = tbuf1;
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) tbuf1, "replace_string.buff");
}
}
tp = tbuf;
sp = args[0];
process_expression(tbuf, &tp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*tp = '\0';
if (parse_boolean(tbuf)) {
sp = args[1];
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
} else if (nargs > 2) {
sp = args[2];
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
}
}
if (!args[0] || !*args[0] || !isalpha((unsigned char) *args[0])
|| strchr(args[0], ' ')) {
safe_str(T("#-1 FUNCTION (SOUNDEX) REQUIRES A SINGLE WORD ARGUMENT"), buff,
- bp);
+ bp);
return;
}
safe_str(soundex(args[0]), buff, bp);
|| !isalpha((unsigned char) *args[1]) || strchr(args[0], ' ')
|| strchr(args[1], ' ')) {
safe_str(T("#-1 FUNCTION (SOUNDLIKE) REQUIRES TWO ONE-WORD ARGUMENTS"),
- buff, bp);
+ buff, bp);
return;
}
/* soundex uses a static buffer, so we need to save it */
enum whichof_t { DO_FIRSTOF, DO_ALLOF };
static void
do_whichof(char *args[], int nargs, enum whichof_t flag, char *buff, char **bp,
- dbref executor, dbref caller, dbref enactor, PE_Info * pe_info)
+ dbref executor, dbref caller, dbref enactor, PE_Info * pe_info)
{
int j;
char tbuf[BUFFER_LEN], *tp;
char *isep = insep;
const char *arglast = args[nargs - 1];
process_expression(insep, &isep, &arglast, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*isep = '\0';
strcpy(args[nargs - 1], insep);
tp = tbuf;
sp = args[j];
process_expression(tbuf, &tp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*tp = '\0';
if (parse_boolean(tbuf)) {
if (!first) {
- safe_chr(sep, buff, bp);
+ safe_chr(sep, buff, bp);
} else
- first = 0;
+ first = 0;
safe_str(tbuf, buff, bp);
if (flag == DO_FIRSTOF)
- return;
+ return;
}
}
if (flag == DO_FIRSTOF)
FUNCTION(fun_firstof)
{
do_whichof(args, nargs, DO_FIRSTOF, buff, bp, executor,
- caller, enactor, pe_info);
+ caller, enactor, pe_info);
}
FUNCTION(fun_allof)
{
do_whichof(args, nargs, DO_ALLOF, buff, bp, executor,
- caller, enactor, pe_info);
+ caller, enactor, pe_info);
}
/* Signal Shit */
FUNCTION(fun_signal) {
- enum qid_flags qsig = QID_FALSE;
- int signal_r;
-
- if(!*args[0] || !*args[1])
- return;
- /* find out which signal we're using */
- if(string_prefix("kill", args[1]))
- qsig = QID_KILL;
- else if(string_prefix("freeze", args[1]))
- qsig = QID_FREEZE;
- else if(string_prefix("continue", args[1]))
- qsig = QID_CONT;
- else if(string_prefix("time", args[1]))
- qsig = QID_TIME;
- else if(string_prefix("query_t", args[1]))
- qsig = QID_QUERY_T;
- if(qsig == QID_FALSE) {
- safe_str("#-1 INVALID SIGNAL", buff, bp);
- return;
- } else if(qsig == QID_TIME && (!*args[2] || atoi(args[2]) < 0)) {
- safe_str("#-1 INVALID TIME ARGUMENT", buff, bp);
- return;
- }
-
- switch((signal_r = do_signal_qid(executor, atoi(args[0]), qsig, qsig == QID_TIME ? atoi(args[2]) : -1))) {
- case 0:
- safe_str("#-1 INVALID TIME ARGUMENT", buff, bp);
- break;
- case -1:
- safe_str("#-1 INVALID QID", buff, bp);
- break;
- case -2: /* we shouldn't be getting this */
- safe_str("#-1 INVALID SIGNAL", buff, bp);
- break;
- case -3:
- safe_str("#-1 PERMISSION DENIED", buff, bp);
- default:
- safe_integer(signal_r > -1 ? signal_r : 0, buff, bp);
- break;
- }
-
+ enum qid_flags qsig = QID_FALSE;
+ int signal_r;
+
+ if(!*args[0] || !*args[1])
+ return;
+ /* find out which signal we're using */
+ if(string_prefix("kill", args[1]))
+ qsig = QID_KILL;
+ else if(string_prefix("freeze", args[1]))
+ qsig = QID_FREEZE;
+ else if(string_prefix("continue", args[1]))
+ qsig = QID_CONT;
+ else if(string_prefix("time", args[1]))
+ qsig = QID_TIME;
+ else if(string_prefix("query_t", args[1]))
+ qsig = QID_QUERY_T;
+ if(qsig == QID_FALSE) {
+ safe_str("#-1 INVALID SIGNAL", buff, bp);
+ return;
+ } else if(qsig == QID_TIME && (!*args[2] || atoi(args[2]) < 0)) {
+ safe_str("#-1 INVALID TIME ARGUMENT", buff, bp);
+ return;
+ }
+
+ switch((signal_r = do_signal_qid(executor, atoi(args[0]), qsig, qsig == QID_TIME ? atoi(args[2]) : -1))) {
+ case 0:
+ safe_str("#-1 INVALID TIME ARGUMENT", buff, bp);
+ break;
+ case -1:
+ safe_str("#-1 INVALID QID", buff, bp);
+ break;
+ case -2: /* we shouldn't be getting this */
+ safe_str("#-1 INVALID SIGNAL", buff, bp);
+ break;
+ case -3:
+ safe_str("#-1 PERMISSION DENIED", buff, bp);
+ default:
+ safe_integer(signal_r > -1 ? signal_r : 0, buff, bp);
+ break;
+ }
+
}
FUNCTION(fun_trigger) {
- if(!args[0] || !*args[0]) {
- safe_str("#-1 INVALID ARGUMENTS", buff, bp);
- return;
- }
- if(!command_check_byname(executor, "@trigger")){
- safe_str("#-1 PERMISSION DENIED", buff, bp);
- return;
- }
+ if(!args[0] || !*args[0]) {
+ safe_str("#-1 INVALID ARGUMENTS", buff, bp);
+ return;
+ }
+ if(!command_check_byname(executor, "@trigger")){
+ safe_str("#-1 PERMISSION DENIED", buff, bp);
+ return;
+ }
- do_trigger(executor, args[0], args);
+ do_trigger(executor, args[0], args);
}
#ifdef WIN32
#define LC_MESSAGES 6
-#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
#ifdef __APPLE__
#define MAX_COLS 32 /**< Maximum number of columns for align() */
static int wraplen(char *str, int maxlen);
static int align_one_line(char *buff, char **bp, int ncols,
- int cols[MAX_COLS], int calign[MAX_COLS],
- char *ptrs[MAX_COLS], ansi_string *as[MAX_COLS],
- int linenum, char *fieldsep, int fslen, char *linesep,
- int lslen, char filler);
+ int cols[MAX_COLS], int calign[MAX_COLS],
+ char *ptrs[MAX_COLS], ansi_string *as[MAX_COLS],
+ int linenum, char *fieldsep, int fslen, char *linesep,
+ int lslen, char filler);
static int comp_gencomp(dbref exceutor, char *left, char *right, char *type);
void init_tag_hashtab(void);
void init_pronouns(void);
}
}
-char *subj[4]; /**< Subjective pronouns */
-char *poss[4]; /**< Possessive pronouns */
-char *obj[4]; /**< Objective pronouns */
-char *absp[4]; /**< Absolute possessive pronouns */
+char *subj[4]; /**< Subjective pronouns */
+char *poss[4]; /**< Possessive pronouns */
+char *obj[4]; /**< Objective pronouns */
+char *absp[4]; /**< Absolute possessive pronouns */
/** Macro to set a pronoun entry based on whether we're translating or not */
#define SET_PRONOUN(p,v,u) p = strdup((translate) ? (v) : (u))
}
switch (type) {
- case 'A': /* Case-sensitive lexicographic */
+ case 'A': /* Case-sensitive lexicographic */
{
char left[BUFFER_LEN], right[BUFFER_LEN], *l, *r;
size_t llen, rlen;
r = remove_markup(args[1], &rlen);
memcpy(right, r, rlen);
safe_integer(comp_gencomp(executor, left, right, ALPHANUM_LIST), buff,
- bp);
+ bp);
return;
}
- case 'I': /* Case-insensitive lexicographic */
+ case 'I': /* Case-insensitive lexicographic */
{
char left[BUFFER_LEN], right[BUFFER_LEN], *l, *r;
size_t llen, rlen;
r = remove_markup(args[1], &rlen);
memcpy(right, r, rlen);
safe_integer(comp_gencomp(executor, left, right, INSENS_ALPHANUM_LIST),
- buff, bp);
+ buff, bp);
return;
}
- case 'N': /* Integers */
+ case 'N': /* Integers */
if (!is_strict_integer(args[0]) || !is_strict_integer(args[1])) {
safe_str(T(e_ints), buff, bp);
return;
}
safe_integer(comp_gencomp(executor, args[0], args[1], NUMERIC_LIST), buff,
- bp);
+ bp);
return;
case 'F':
if (!is_strict_number(args[0]) || !is_strict_number(args[1])) {
return;
}
safe_integer(comp_gencomp(executor, args[0], args[1], FLOAT_LIST), buff,
- bp);
+ bp);
return;
case 'D':
{
a = parse_objid(args[0]);
b = parse_objid(args[1]);
if (a == NOTHING || b == NOTHING) {
- safe_str(T("#-1 INVALID DBREF"), buff, bp);
- return;
+ safe_str(T("#-1 INVALID DBREF"), buff, bp);
+ return;
}
safe_integer(comp_gencomp(executor, args[0], args[1], DBREF_LIST), buff,
- bp);
+ bp);
return;
}
default:
for (n = 0; n < len; n++)
if (pos[n] == c) {
if (first)
- first = 0;
+ first = 0;
else
- safe_chr(' ', buff, bp);
+ safe_chr(' ', buff, bp);
safe_integer(n, buff, bp);
}
}
int dir, sentinel, cur;
if (rawstr[i] < rawstr[i + 2])
- dir = 1;
+ dir = 1;
else
- dir = -1;
+ dir = -1;
sentinel = rawstr[i + 2] + dir;
cur = rawstr[i] + dir;
while (cur != sentinel) {
- safe_chr((char) cur, instr, &ip);
- cur += dir;
+ safe_chr((char) cur, instr, &ip);
+ cur += dir;
}
i += 2;
}
int dir, sentinel, cur;
if (rawstr[i] < rawstr[i + 2])
- dir = 1;
+ dir = 1;
else
- dir = -1;
+ dir = -1;
sentinel = rawstr[i + 2] + dir;
cur = rawstr[i] + dir;
while (cur != sentinel) {
- safe_chr((char) cur, outstr, &op);
- cur += dir;
+ safe_chr((char) cur, outstr, &op);
+ cur += dir;
}
i += 2;
}
while (times) {
if (times & 1) {
if (safe_strl(args[0], arglens[0], buff, bp) != 0)
- break;
+ break;
}
safe_str(args[0], args[0], &ap);
*ap = '\0';
if (args[3] && *args[3]) {
filllen = ansi_strlen(args[3]);
if (!filllen) {
- safe_str(T("#-1 FILL ARGUMENT MAY NOT BE ZERO-LENGTH"), buff, bp);
- return;
+ safe_str(T("#-1 FILL ARGUMENT MAY NOT BE ZERO-LENGTH"), buff, bp);
+ return;
}
as = parse_ansi_string(args[3]);
fillq = rsp / filllen;
*cbuf = *lp++;
ap = asave;
if (process_expression(buff, bp, &ap, thing, executor, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info))
+ PE_DEFAULT, PT_DEFAULT, pe_info))
break;
if (*bp == oldbp && pe_info->fun_invocations == funccount)
break;
safe_chr('\\', buff, bp);
for (s = (unsigned char *) args[0]; *s; s++) {
if ((s != (unsigned char *) args[0]) && escaped_chars[*s])
- safe_chr('\\', buff, bp);
+ safe_chr('\\', buff, bp);
safe_chr(*s, buff, bp);
}
}
tp--;
tp[1] = '\0';
- for (tp = args[0]; *tp == sep; tp++) /* skip leading spaces */
+ for (tp = args[0]; *tp == sep; tp++) /* skip leading spaces */
;
while (*tp) {
safe_chr(*tp, buff, bp);
if (*tp == sep)
while (*tp == sep)
- tp++;
+ tp++;
else
tp++;
}
}
m = remove_markup(args[0], &len);
- if (len != 2) /* len includes trailing nul */
+ if (len != 2) /* len includes trailing nul */
safe_str(T("#-1 FUNCTION EXPECTS ONE CHARACTER"), buff, bp);
else if (isprint((unsigned char) *m))
safe_integer((unsigned char) *m, buff, bp);
safe_strl(args[0], arglens[0], buff, bp);
for (i = 1; i < nargs; i++) {
if (ok_tag_attribute(executor, args[i])) {
- safe_chr(' ', buff, bp);
- safe_strl(args[i], arglens[i], buff, bp);
+ safe_chr(' ', buff, bp);
+ safe_strl(args[i], arglens[i], buff, bp);
}
}
safe_chr(TAG_END, buff, bp);
}
}
-#define COL_FLASH (1) /**< ANSI flash attribute bit */
-#define COL_HILITE (2) /**< ANSI hilite attribute bit */
-#define COL_INVERT (4) /**< ANSI inverse attribute bit */
-#define COL_UNDERSCORE (8) /**< ANSI underscore attribute bit */
-
-#define VAL_FLASH (5) /**< ANSI flag attribute value */
-#define VAL_HILITE (1) /**< ANSI hilite attribute value */
-#define VAL_INVERT (7) /**< ANSI inverse attribute value */
-#define VAL_UNDERSCORE (4) /**< ANSI underscore attribute value */
-
-#define COL_BLACK (30) /**< ANSI color black */
-#define COL_RED (31) /**< ANSI color red */
-#define COL_GREEN (32) /**< ANSI color green */
-#define COL_YELLOW (33) /**< ANSI color yellow */
-#define COL_BLUE (34) /**< ANSI color blue */
-#define COL_MAGENTA (35) /**< ANSI color magenta */
-#define COL_CYAN (36) /**< ANSI color cyan */
-#define COL_WHITE (37) /**< ANSI color white */
+#define COL_FLASH (1) /**< ANSI flash attribute bit */
+#define COL_HILITE (2) /**< ANSI hilite attribute bit */
+#define COL_INVERT (4) /**< ANSI inverse attribute bit */
+#define COL_UNDERSCORE (8) /**< ANSI underscore attribute bit */
+
+#define VAL_FLASH (5) /**< ANSI flag attribute value */
+#define VAL_HILITE (1) /**< ANSI hilite attribute value */
+#define VAL_INVERT (7) /**< ANSI inverse attribute value */
+#define VAL_UNDERSCORE (4) /**< ANSI underscore attribute value */
+
+#define COL_BLACK (30) /**< ANSI color black */
+#define COL_RED (31) /**< ANSI color red */
+#define COL_GREEN (32) /**< ANSI color green */
+#define COL_YELLOW (33) /**< ANSI color yellow */
+#define COL_BLUE (34) /**< ANSI color blue */
+#define COL_MAGENTA (35) /**< ANSI color magenta */
+#define COL_CYAN (36) /**< ANSI color cyan */
+#define COL_WHITE (37) /**< ANSI color white */
/** The ansi attributes associated with a character. */
typedef struct {
- char flags; /**< Ansi text attributes */
- char fore; /**< Ansi foreground color */
- char back; /**< Ansi background color */
+ char flags; /**< Ansi text attributes */
+ char fore; /**< Ansi foreground color */
+ char back; /**< Ansi background color */
} ansi_data;
static void dump_ansi_codes(ansi_data * ad, char *buff, char **bp);
tbp = tbuff;
arg0 = args[0];
process_expression(tbuff, &tbp, &arg0, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*tbp = '\0';
sp[1] = sp[0];
for (tbp = tbuff; *tbp; tbp++) {
switch (*tbp) {
- case 'n': /* normal */
+ case 'n': /* normal */
sp->flags = 0;
sp->fore = 0;
sp->back = 0;
break;
- case 'f': /* flash */
+ case 'f': /* flash */
sp->flags |= COL_FLASH;
break;
- case 'h': /* hilite */
+ case 'h': /* hilite */
sp->flags |= COL_HILITE;
break;
- case 'i': /* inverse */
+ case 'i': /* inverse */
sp->flags |= COL_INVERT;
break;
- case 'u': /* underscore */
+ case 'u': /* underscore */
sp->flags |= COL_UNDERSCORE;
break;
- case 'F': /* flash */
+ case 'F': /* flash */
sp->flags &= ~COL_FLASH;
break;
- case 'H': /* hilite */
+ case 'H': /* hilite */
sp->flags &= ~COL_HILITE;
break;
- case 'I': /* inverse */
+ case 'I': /* inverse */
sp->flags &= ~COL_INVERT;
break;
- case 'U': /* underscore */
+ case 'U': /* underscore */
sp->flags &= ~COL_UNDERSCORE;
break;
- case 'b': /* blue fg */
+ case 'b': /* blue fg */
sp->fore = COL_BLUE;
break;
- case 'c': /* cyan fg */
+ case 'c': /* cyan fg */
sp->fore = COL_CYAN;
break;
- case 'g': /* green fg */
+ case 'g': /* green fg */
sp->fore = COL_GREEN;
break;
- case 'm': /* magenta fg */
+ case 'm': /* magenta fg */
sp->fore = COL_MAGENTA;
break;
- case 'r': /* red fg */
+ case 'r': /* red fg */
sp->fore = COL_RED;
break;
- case 'w': /* white fg */
+ case 'w': /* white fg */
sp->fore = COL_WHITE;
break;
- case 'x': /* black fg */
+ case 'x': /* black fg */
sp->fore = COL_BLACK;
break;
- case 'y': /* yellow fg */
+ case 'y': /* yellow fg */
sp->fore = COL_YELLOW;
break;
- case 'B': /* blue bg */
+ case 'B': /* blue bg */
sp->back = COL_BLUE;
break;
- case 'C': /* cyan bg */
+ case 'C': /* cyan bg */
sp->back = COL_CYAN;
break;
- case 'G': /* green bg */
+ case 'G': /* green bg */
sp->back = COL_GREEN;
break;
- case 'M': /* magenta bg */
+ case 'M': /* magenta bg */
sp->back = COL_MAGENTA;
break;
- case 'R': /* red bg */
+ case 'R': /* red bg */
sp->back = COL_RED;
break;
- case 'W': /* white bg */
+ case 'W': /* white bg */
sp->back = COL_WHITE;
break;
- case 'X': /* black bg */
+ case 'X': /* black bg */
sp->back = COL_BLACK;
break;
- case 'Y': /* yellow bg */
+ case 'Y': /* yellow bg */
sp->back = COL_YELLOW;
break;
}
arg1 = args[1];
process_expression(buff, bp, &arg1, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
dump_ansi_codes(--sp, buff, bp);
for (i = 1; i < nargs - 1; i += 2) {
postp = postbuf;
- f = args[i]; /* find this */
- r = args[i + 1]; /* replace it with this */
+ f = args[i]; /* find this */
+ r = args[i + 1]; /* replace it with this */
flen = arglens[i];
rlen = arglens[i + 1];
size_t last;
safe_strl(r, rlen, postbuf, &postp);
for (last = 0; last < prebuf->len; last++) {
- safe_ansi_string(prebuf, last, 1, postbuf, &postp);
- safe_strl(r, rlen, postbuf, &postp);
+ safe_ansi_string(prebuf, last, 1, postbuf, &postp);
+ safe_strl(r, rlen, postbuf, &postp);
}
} else {
char *p;
size_t last = 0;
while (last < prebuf->len && (p = strstr(prebuf->text + last, f)) != NULL) {
- safe_ansi_string(prebuf, last, p - (prebuf->text + last),
- postbuf, &postp);
- safe_strl(r, rlen, postbuf, &postp);
- last = p - prebuf->text + flen;
+ safe_ansi_string(prebuf, last, p - (prebuf->text + last),
+ postbuf, &postp);
+ safe_strl(r, rlen, postbuf, &postp);
+ last = p - prebuf->text + flen;
}
if (last < prebuf->len)
- safe_ansi_string(prebuf, last, prebuf->len, postbuf, &postp);
+ safe_ansi_string(prebuf, last, prebuf->len, postbuf, &postp);
}
*postp = '\0';
free_ansi_string(prebuf);
int rbrack, lbrack, rbrace, lbrace, lcurl, rcurl;
lcurl = rcurl = rbrack = lbrack = rbrace = lbrace = 0;
- str = args[0]; /* The string to count the brackets in */
+ str = args[0]; /* The string to count the brackets in */
while (*str) {
switch (*str) {
case '[':
str++;
}
safe_format(buff, bp, "%d %d %d %d %d %d", lbrack, rbrack,
- lbrace, rbrace, lcurl, rcurl);
+ lbrace, rbrace, lcurl, rcurl);
}
*/
while (i < length) {
if ((str[i] == '\n') || (str[i] == '\r'))
- return i;
+ return i;
i++;
}
return length;
* args[3] = output delimiter (btwn lines)
*/
- char *pstr; /* start of string */
+ char *pstr; /* start of string */
ansi_string *as;
- const char *pend; /* end of string */
+ const char *pend; /* end of string */
int linewidth, width1st, width;
int linenr = 0;
const char *linesep;
/* word doesn't fit on one line, so cut it */
safe_ansi_string2(as, pstr - as->text, ansiwidth - 1, buff, bp);
safe_chr('-', buff, bp);
- pstr += ansiwidth - 1; /* move to start of next line */
+ pstr += ansiwidth - 1; /* move to start of next line */
} else {
/* normal line */
safe_ansi_string2(as, pstr - as->text, ansilen, buff, bp);
if (pstr[ansilen] == '\r')
- ++ansilen;
- pstr += ansilen + 1; /* move to start of next line */
+ ++ansilen;
+ pstr += ansilen + 1; /* move to start of next line */
}
}
free_ansi_string(as);
static int
align_one_line(char *buff, char **bp, int ncols,
- int cols[MAX_COLS], int calign[MAX_COLS], char *ptrs[MAX_COLS],
- ansi_string *as[MAX_COLS],
- int linenum, char *fieldsep, int fslen,
- char *linesep, int lslen, char filler)
+ int cols[MAX_COLS], int calign[MAX_COLS], char *ptrs[MAX_COLS],
+ ansi_string *as[MAX_COLS],
+ int linenum, char *fieldsep, int fslen,
+ char *linesep, int lslen, char filler)
{
static char line[BUFFER_LEN];
static char segment[BUFFER_LEN];
for (i = 0; i < ncols; i++) {
if (!ptrs[i] || !*ptrs[i]) {
if (calign[i] & AL_REPEAT) {
- ptrs[i] = as[i]->text;
+ ptrs[i] = as[i]->text;
} else {
- lp += cols[i];
- if (i < (ncols - 1) && fslen)
- safe_str(fieldsep, line, &lp);
- cols_done++;
- continue;
+ lp += cols[i];
+ if (i < (ncols - 1) && fslen)
+ safe_str(fieldsep, line, &lp);
+ cols_done++;
+ continue;
}
}
if (calign[i] & AL_REPEAT) {
}
for (len = 0, ptr = ptrs[i], lastspace = NULL; len < cols[i]; ptr++, len++) {
if ((!*ptr) || (*ptr == '\n'))
- break;
+ break;
if (isspace((unsigned char) *ptr)) {
- lastspace = ptr;
+ lastspace = ptr;
}
}
skipspace = 0;
sp = segment;
if (!*ptr) {
if (len > 0) {
- safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
+ safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
}
ptrs[i] = ptr;
} else if (*ptr == '\n') {
for (tptr = ptr;
- *tptr && tptr >= ptrs[i] && isspace((unsigned char) *tptr); tptr--) ;
+ *tptr && tptr >= ptrs[i] && isspace((unsigned char) *tptr); tptr--) ;
len = (tptr - ptrs[i]) + 1;
if (len > 0) {
- safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
+ safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
}
ptrs[i] = ptr + 1;
ptr = tptr;
ptr = lastspace;
skipspace = 1;
for (tptr = ptr;
- *tptr && tptr >= ptrs[i] && isspace((unsigned char) *tptr); tptr--) ;
+ *tptr && tptr >= ptrs[i] && isspace((unsigned char) *tptr); tptr--) ;
len = (tptr - ptrs[i]) + 1;
if (len > 0) {
- safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
+ safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
}
ptrs[i] = lastspace;
} else {
if (len > 0) {
- safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
+ safe_ansi_string2(as[i], ptrs[i] - (as[i]->text), len, segment, &sp);
}
ptrs[i] = ptr;
}
safe_str(fieldsep, line, &lp);
if (skipspace)
for (;
- *ptrs[i] && (*ptrs[i] != '\n') && isspace((unsigned char) *ptrs[i]);
- ptrs[i]++) ;
+ *ptrs[i] && (*ptrs[i] != '\n') && isspace((unsigned char) *ptrs[i]);
+ ptrs[i]++) ;
}
if (cols_done == ncols)
return 0;
nline = 0;
while (1) {
if (!align_one_line(buff, bp, ncols, cols, calign, ptrs,
- as, nline++, fieldsep, fslen, linesep, lslen, filler))
+ as, nline++, fieldsep, fslen, linesep, lslen, filler))
break;
}
**bp = '\0';
/* we have a transform attr */
transform = 1;
if (!fetch_ufun_attrib(args[3], executor, &transufun, 1)) {
- safe_str(T(e_atrperm), buff, bp);
+ safe_str(T(e_atrperm), buff, bp);
LEAVE_OOREF;
- return;
+ return;
}
if (nargs > 4) {
- if (args[4] != '\0') {
- /* we have an attr to use when transform returns an empty string */
- null = 1;
- if (!fetch_ufun_attrib(args[4], executor, &nullufun, 1)) {
- safe_str(T(e_atrperm), buff, bp);
+ if (args[4] != '\0') {
+ /* we have an attr to use when transform returns an empty string */
+ null = 1;
+ if (!fetch_ufun_attrib(args[4], executor, &nullufun, 1)) {
+ safe_str(T(e_atrperm), buff, bp);
LEAVE_OOREF;
- return;
- }
- }
+ return;
+ }
+ }
}
}
}
if (*string == ' ') {
/* semipose it instead */
while (*string == ' ')
- string++;
+ string++;
} else
safe_chr(' ', buff, bp);
break;
/* pose it instead */
safe_chr(' ', buff, bp);
while (*string == ' ')
- string++;
+ string++;
}
break;
case '|':
wenv[1] = unparse_integer(fragment);
if (call_ufun(&nullufun, wenv, 2, rbuff, executor, enactor, pe_info)) {
LEAVE_OOREF;
- return;
+ return;
}
safe_str(rbuff, buff, bp);
LEAVE_OOREF;
}
funccount = pe_info->fun_invocations;
while (!finished && ((say && fragment == 0 && (speech = string))
- || (speech = strstr(string, open)))) {
+ || (speech = strstr(string, open)))) {
fragment++;
indx = string - speech;
if (indx < 0)
- indx *= -1;
+ indx *= -1;
if (string != NULL && strlen(string) > 0 && indx > 0)
- safe_strl(string, indx, buff, bp);
+ safe_strl(string, indx, buff, bp);
if (!say || fragment > 1)
- speech = speech + strlen(open); /* move past open char */
+ speech = speech + strlen(open); /* move past open char */
/* find close-char */
string = strstr(speech, close);
if (!string || !(string = string + strlen(close))) {
- /* no close char, or nothing after it; we're at the end! */
- finished = 1;
+ /* no close char, or nothing after it; we're at the end! */
+ finished = 1;
}
delete = (string == NULL ? strlen(speech) : strlen(speech) -
- (strlen(string) + strlen(close)));
+ (strlen(string) + strlen(close)));
speech = chopstr(speech, delete);
wenv[0] = speech;
wenv[1] = speaker_str;
wenv[2] = unparse_integer(fragment);
if (call_ufun(&transufun, wenv, 3, rbuff, executor, enactor, pe_info))
- break;
+ break;
if (*bp == (buff + BUFFER_LEN - 1) &&
- pe_info->fun_invocations == funccount)
- break;
+ pe_info->fun_invocations == funccount)
+ break;
funccount = pe_info->fun_invocations;
if ((null == 1) && (strlen(rbuff) == 0)) {
- wenv[0] = speaker_str;
- wenv[1] = unparse_integer(fragment);
- if (call_ufun(&nullufun, wenv, 2, rbuff, executor, enactor, pe_info))
- break;
+ wenv[0] = speaker_str;
+ wenv[1] = unparse_integer(fragment);
+ if (call_ufun(&nullufun, wenv, 2, rbuff, executor, enactor, pe_info))
+ break;
}
if (strlen(rbuff) > 0) {
- safe_str(rbuff, buff, bp);
+ safe_str(rbuff, buff, bp);
}
if (*bp == (buff + BUFFER_LEN - 1) &&
- pe_info->fun_invocations == funccount)
- break;
+ pe_info->fun_invocations == funccount)
+ break;
}
if (string != NULL && strlen(string) > 0) {
- safe_str(string, buff, bp); /* remaining string (not speech, so not t) */
+ safe_str(string, buff, bp); /* remaining string (not speech, so not t) */
}
}
int do_convtime(const char *str, struct tm *ttm);
void do_timestring(char *buff, char **bp, const char *format,
- unsigned long secs);
+ unsigned long secs);
extern char valid_timefmt_codes[256];
int len, n;
if (!args[0] || !*args[0])
- return; /* No field? Bad user. */
+ return; /* No field? Bad user. */
if (nargs == 2) {
/* This is silly, but time_t is signed on several platforms,
args[0][n] = '%';
n++;
if (args[0][n] == '$')
- args[0][n] = '%';
+ args[0][n] = '%';
else if (!valid_timefmt_codes[(unsigned char) args[0][n]]) {
- safe_format(buff, bp, T("#-1 INVALID ESCAPE CODE '$%c'"),
- args[0][n] ? args[0][n] : ' ');
- return;
+ safe_format(buff, bp, T("#-1 INVALID ESCAPE CODE '$%c'"),
+ args[0][n] ? args[0][n] : ' ');
+ return;
}
}
}
char *ptr;
thing = match_result(executor, args[0], NOTYPE, MAT_EVERYTHING);
if (!GoodObject(thing)) {
- /* Assume this is a manul timezone set */
- if(is_strict_number(args[0])) {
- utc = 1;
- tz = strtod(args[0], NULL);
- if (tz < -24.0 || tz > 24.0) {
- safe_str("#-1 INVALID TIME ZONE", buff, bp);
- return;
- }
- mytime += (int) (tz * 3600);
- } else setenv("TZ", args[0], 1);
+ /* Assume this is a manul timezone set */
+ if(is_strict_number(args[0])) {
+ utc = 1;
+ tz = strtod(args[0], NULL);
+ if (tz < -24.0 || tz > 24.0) {
+ safe_str("#-1 INVALID TIME ZONE", buff, bp);
+ return;
+ }
+ mytime += (int) (tz * 3600);
+ } else setenv("TZ", args[0], 1);
} else {
/* Always make time(player) return a time,
* even if player's TZ is unset or wonky */
- a = atr_get(thing, "TZ");
- if (a) {
- ptr = atr_value(a);
- if(is_strict_number(ptr)) {
- utc = 1;
- tz = strtod(ptr, NULL);
- if (tz >= -24.0 || tz <= 24.0) {
- mytime += (int) (tz * 3600);
- }
- } else setenv("TZ", ptr, 1);
- }
+ a = atr_get(thing, "TZ");
+ if (a) {
+ ptr = atr_value(a);
+ if(is_strict_number(ptr)) {
+ utc = 1;
+ tz = strtod(ptr, NULL);
+ if (tz >= -24.0 || tz <= 24.0) {
+ mytime += (int) (tz * 3600);
+ }
+ } else setenv("TZ", ptr, 1);
+ }
}
}
} else if (!strcmp("UTCTIME", called_as)) {
i++;
}
if (i == 0) {
- return 0; /* No numbers given */
+ return 0; /* No numbers given */
}
str2[i] = '\0';
if (!*str1) {
- *secs += parse_integer(str2); /* no more chars, just add seconds and stop */
+ *secs += parse_integer(str2); /* no more chars, just add seconds and stop */
break;
}
switch (*str1) {
case 'd':
case 'D':
- *secs += (parse_integer(str2) * 86400); /* days */
+ *secs += (parse_integer(str2) * 86400); /* days */
break;
case 'h':
case 'H':
- *secs += (parse_integer(str2) * 3600); /* hours */
+ *secs += (parse_integer(str2) * 3600); /* hours */
break;
case 'm':
case 'M':
- *secs += (parse_integer(str2) * 60); /* minutes */
+ *secs += (parse_integer(str2) * 60); /* minutes */
break;
case 's':
case 'S':
case ' ':
- *secs += parse_integer(str2); /* seconds */
+ *secs += parse_integer(str2); /* seconds */
break;
default:
return 0;
}
- str1++; /* move past the time char */
+ str1++; /* move past the time char */
}
return 1;
}
#ifdef NEVER
if (getdate_err <= 7)
do_rawlog(LT_ERR, "getdate returned error code %d for %s", getdate_err,
- str);
+ str);
#endif
return 0;
}
if (strlen(p) != 3)
return 0;
for (i = 0; (i < 12) && strcmp(month_table[i], p); i++) ;
- if (i == 12) /* not found */
+ if (i == 12) /* not found */
return 0;
else
ttm->tm_mon = i;
/* get the day of month */
p = q;
- while (isspace((unsigned char) *p)) /* skip leading space */
+ while (isspace((unsigned char) *p)) /* skip leading space */
p++;
if (!(q = strchr(p, ' ')))
return 0;
safe_uinteger(timelocal(&ttm), buff, bp);
#else
safe_uinteger(mktime(&ttm), buff, bp);
-#endif /* SUN_OS */
+#endif /* SUN_OS */
} else {
safe_str("-1", buff, bp);
}
}
#ifdef WIN32
-#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
/* ARGSUSED */
FUNCTION(fun_isdaylight)
c++;
width = strtol(c, &w, 10);
if (c == w)
- pad = 0;
+ pad = 0;
else
- pad = 1;
+ pad = 1;
if (width < 0)
- width = 0;
+ width = 0;
else if (width >= BUFFER_LEN)
- width = BUFFER_LEN - 1;
+ width = BUFFER_LEN - 1;
even_if_0 = in_format_flags = 1;
include_suffix = 0;
while (in_format_flags) {
- switch (*w) {
- case 'x':
- case 'X':
- include_suffix = 1;
- w++;
- break;
- case 'z':
- case 'Z':
- even_if_0 = 0;
- w++;
- break;
- case '$':
- in_format_flags = 0;
- if (pad)
- safe_format(buff, bp, "%*c", width, '$');
- else
- safe_chr('$', buff, bp);
- break;
- case 's':
- in_format_flags = 0;
- if (secs || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%*lu", width, secs);
- else
- safe_uinteger(secs, buff, bp);
- if (include_suffix)
- safe_chr('s', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'S':
- in_format_flags = 0;
- if (secs || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%0*lu", width, secs);
- else
- safe_format(buff, bp, "%0lu", secs);
- if (include_suffix)
- safe_chr('s', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'm':
- in_format_flags = 0;
- if (mins || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%*d", width, mins);
- else
- safe_integer(mins, buff, bp);
- if (include_suffix)
- safe_chr('m', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'M':
- in_format_flags = 0;
- if (mins || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%0*d", width, mins);
- else
- safe_format(buff, bp, "%0d", mins);
- if (include_suffix)
- safe_chr('m', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'h':
- in_format_flags = 0;
- if (hours || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%*d", width, hours);
- else
- safe_integer(hours, buff, bp);
- if (include_suffix)
- safe_chr('h', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'H':
- in_format_flags = 0;
- if (hours || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%0*d", width, hours);
- else
- safe_format(buff, bp, "%0d", hours);
- if (include_suffix)
- safe_chr('h', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'd':
- in_format_flags = 0;
- if (days || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%*d", width, days);
- else
- safe_integer(days, buff, bp);
- if (include_suffix)
- safe_chr('d', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- case 'D':
- in_format_flags = 0;
- if (days || even_if_0) {
- if (pad)
- safe_format(buff, bp, "%0*d", width, days);
- else
- safe_format(buff, bp, "%0d", days);
- if (include_suffix)
- safe_chr('d', buff, bp);
- } else if (pad)
- safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
- break;
- default:
- in_format_flags = 0;
- safe_chr('$', buff, bp);
- for (; c != w; c++)
- safe_chr(*c, buff, bp);
- safe_chr(*c, buff, bp);
- }
+ switch (*w) {
+ case 'x':
+ case 'X':
+ include_suffix = 1;
+ w++;
+ break;
+ case 'z':
+ case 'Z':
+ even_if_0 = 0;
+ w++;
+ break;
+ case '$':
+ in_format_flags = 0;
+ if (pad)
+ safe_format(buff, bp, "%*c", width, '$');
+ else
+ safe_chr('$', buff, bp);
+ break;
+ case 's':
+ in_format_flags = 0;
+ if (secs || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%*lu", width, secs);
+ else
+ safe_uinteger(secs, buff, bp);
+ if (include_suffix)
+ safe_chr('s', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'S':
+ in_format_flags = 0;
+ if (secs || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%0*lu", width, secs);
+ else
+ safe_format(buff, bp, "%0lu", secs);
+ if (include_suffix)
+ safe_chr('s', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'm':
+ in_format_flags = 0;
+ if (mins || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%*d", width, mins);
+ else
+ safe_integer(mins, buff, bp);
+ if (include_suffix)
+ safe_chr('m', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'M':
+ in_format_flags = 0;
+ if (mins || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%0*d", width, mins);
+ else
+ safe_format(buff, bp, "%0d", mins);
+ if (include_suffix)
+ safe_chr('m', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'h':
+ in_format_flags = 0;
+ if (hours || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%*d", width, hours);
+ else
+ safe_integer(hours, buff, bp);
+ if (include_suffix)
+ safe_chr('h', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'H':
+ in_format_flags = 0;
+ if (hours || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%0*d", width, hours);
+ else
+ safe_format(buff, bp, "%0d", hours);
+ if (include_suffix)
+ safe_chr('h', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'd':
+ in_format_flags = 0;
+ if (days || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%*d", width, days);
+ else
+ safe_integer(days, buff, bp);
+ if (include_suffix)
+ safe_chr('d', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ case 'D':
+ in_format_flags = 0;
+ if (days || even_if_0) {
+ if (pad)
+ safe_format(buff, bp, "%0*d", width, days);
+ else
+ safe_format(buff, bp, "%0d", days);
+ if (include_suffix)
+ safe_chr('d', buff, bp);
+ } else if (pad)
+ safe_fill(' ', width + (include_suffix ? 1 : 0), buff, bp);
+ break;
+ default:
+ in_format_flags = 0;
+ safe_chr('$', buff, bp);
+ for (; c != w; c++)
+ safe_chr(*c, buff, bp);
+ safe_chr(*c, buff, bp);
+ }
}
c = w;
} else
}
#ifdef WIN32
-#pragma warning( default : 4761) /* NJG: enable warning re conversion */
+#pragma warning( default : 4761) /* NJG: enable warning re conversion */
#endif
#include "confmagic.h"
void do_userfn(char *buff, char **bp, dbref obj, ATTR *attrib, int nargs,
- char **args, dbref executor, dbref caller, dbref enactor,
- PE_Info * pe_info);
+ char **args, dbref executor, dbref caller, dbref enactor,
+ PE_Info * pe_info);
/* ARGSUSED */
FUNCTION(fun_s)
char const *p;
p = args[0];
process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
}
/* ARGSUSED */
p = args[0];
process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
restore_global_regs("localize", saver);
}
s = name;
p = args[0];
process_expression(name, &s, &p, executor, caller, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
*s = '\0';
if (FUNCTION_SIDE_EFFECTS) {
p = args[1];
process_expression(buff, bp, &p, obj, executor, enactor, PE_DEFAULT,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
LEAVE_OOREF;
}
*/
void
do_userfn(char *buff, char **bp, dbref obj, ATTR *attrib, int nargs,
- char **args, dbref executor, dbref caller
- __attribute__ ((__unused__)), dbref enactor, PE_Info * pe_info)
+ char **args, dbref executor, dbref caller
+ __attribute__ ((__unused__)), dbref enactor, PE_Info * pe_info)
{
int j;
char *tptr[10];
/* copy the appropriate args into the stack */
if (nargs > 10)
- nargs = 10; /* maximum ten args */
+ nargs = 10; /* maximum ten args */
for (j = 0; j < nargs; j++)
global_eval_context.wenv[j] = args[j];
for (; j < 10; j++)
if (attrib->flags & AF_DEBUG)
pe_flags |= PE_DEBUG;
process_expression(buff, bp, &tp, obj, executor, enactor, pe_flags,
- PT_DEFAULT, pe_info);
+ PT_DEFAULT, pe_info);
free(tbuf);
/* restore the stack */
dp = mstr;
sp = args[0];
process_expression(mstr, &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
*dp = '\0';
parse_attrib(executor, mstr, &thing, &attrib);
if (GoodObject(thing) && attrib && CanEvalAttr(executor, thing, attrib)
xargs = NULL;
if (nargs > 2) {
xargs =
- (char **) mush_malloc((nargs - 2) * sizeof(char *), "udefault.xargs");
+ (char **) mush_malloc((nargs - 2) * sizeof(char *), "udefault.xargs");
for (i = 0; i < nargs - 2; i++) {
- xargs[i] = (char *) mush_malloc(BUFFER_LEN, "udefault");
- dp = xargs[i];
- sp = args[i + 2];
- process_expression(xargs[i], &dp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
- *dp = '\0';
+ xargs[i] = (char *) mush_malloc(BUFFER_LEN, "udefault");
+ dp = xargs[i];
+ sp = args[i + 2];
+ process_expression(xargs[i], &dp, &sp, executor, caller, enactor,
+ PE_DEFAULT, PT_DEFAULT, pe_info);
+ *dp = '\0';
}
}
if (called_as[1] == 'L')
save_global_regs("uldefault.save", preserve);
do_userfn(buff, bp, thing, attrib, nargs - 2, xargs,
- executor, caller, enactor, pe_info);
+ executor, caller, enactor, pe_info);
if (called_as[1] == 'L')
restore_global_regs("uldefault.save", preserve);
/* Free the xargs */
if (nargs > 2) {
for (i = 0; i < nargs - 2; i++)
- mush_free(xargs[i], "udefault");
+ mush_free(xargs[i], "udefault");
mush_free(xargs, "udefault.xargs");
}
LEAVE_OOREF;
if (called_as[1] == 'L')
save_global_regs("uldefault.save", preserve);
process_expression(buff, bp, &sp, executor, caller, enactor,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
if (called_as[1] == 'L')
restore_global_regs("uldefault.save", preserve);
return;
}
do_userfn(buff, bp, zone, attrib, nargs - 1, args + 1, executor, caller,
- enactor, pe_info);
+ enactor, pe_info);
LEAVE_OOREF;
return;
} else if (attrib || !Can_Examine(executor, zone)) {
#ifdef WIN32
#include <process.h>
#include <windows.h>
-#undef OPAQUE /* Clashes with flags.h */
+#undef OPAQUE /* Clashes with flags.h */
void Win32MUSH_setup(void);
#endif
#ifdef I_SYS_TYPES
#ifdef hpux
#include <sys/syscall.h>
#define getrusage(x,p) syscall(SYS_GETRUSAGE,x,p)
-#endif /* fix to HP-UX getrusage() braindamage */
+#endif /* fix to HP-UX getrusage() braindamage */
#include "confmagic.h"
#ifdef HAS_WAITPID
/* declarations */
GLOBALTAB globals = { 0, "", 0, 0, 0, 0, 0, 0, 0, 0 };
static int epoch = 0;
-static int reserved; /**< Reserved file descriptor */
-int depth = 0; /**< excessive recursion prevention */
-static dbref *errdblist = NULL; /**< List of dbrefs to return errors from */
-static dbref *errdbtail; /**< Pointer to end of errdblist */
-static int errdbsize = 4; /**< Current size of errdblist array */
+static int reserved; /**< Reserved file descriptor */
+int depth = 0; /**< excessive recursion prevention */
+static dbref *errdblist = NULL; /**< List of dbrefs to return errors from */
+static dbref *errdbtail; /**< Pointer to end of errdblist */
+static int errdbsize = 4; /**< Current size of errdblist array */
extern int use_flagfile;
static void errdb_grow(void);
void do_readcache(dbref player);
int check_alias(const char *command, const char *list);
int list_check(dbref thing, dbref player, char type,
- char end, char *str, int just_match);
+ char end, char *str, int just_match);
int alias_list_check(dbref thing, const char *command, const char *type);
int loc_alias_check(dbref loc, const char *command, const char *type);
void do_poor(dbref player, char *arg1);
void do_writelog(dbref player, char *str, int ltype);
void bind_and_queue(dbref player, dbref cause, char *action, const char *arg,
- const char *placestr);
+ const char *placestr);
void do_scan(dbref player, char *command, int flag);
void do_list(dbref player, char *arg, int lc);
void do_dolist(dbref player, char *list, char *command,
- dbref cause, unsigned int flags);
+ dbref cause, unsigned int flags);
void do_uptime(dbref player, int mortal);
static char *make_new_epoch_file(const char *basename, int the_epoch);
#ifdef HAS_GETRUSAGE
void st_stats_header(dbref player);
void st_stats(dbref player, StrTree *root, const char *name);
void do_timestring(char *buff, char **bp, const char *format,
- unsigned long secs);
+ unsigned long secs);
-extern void create_minimal_db(void); /* From db.c */
+extern void create_minimal_db(void); /* From db.c */
-dbref orator = NOTHING; /**< Last dbref to issue a speech command */
+dbref orator = NOTHING; /**< Last dbref to issue a speech command */
dbref ooref = NOTHING; /**< Origin Reference Object(used for twin checks) */
dbref tooref = NOTHING; /**< temp store ooref variable */
#ifdef COMP_STATS
extern void compress_stats(long *entries,
- long *mem_used,
- long *total_uncompressed, long *total_compressed);
+ long *mem_used,
+ long *total_uncompressed, long *total_compressed);
#endif
#ifdef MUSHCRON
/* want to do a scan before dumping each object */
globals.paranoid_dump = 1;
if (num && *num) {
- /* checkpoint interval given */
- globals.paranoid_checkpt = atoi(num);
- if ((globals.paranoid_checkpt < 1)
- || (globals.paranoid_checkpt >= db_top)) {
- notify(player, T("Permission denied. Invalid checkpoint interval."));
- globals.paranoid_dump = 0;
- return;
- }
+ /* checkpoint interval given */
+ globals.paranoid_checkpt = atoi(num);
+ if ((globals.paranoid_checkpt < 1)
+ || (globals.paranoid_checkpt >= db_top)) {
+ notify(player, T("Permission denied. Invalid checkpoint interval."));
+ globals.paranoid_dump = 0;
+ return;
+ }
} else {
- /* use a default interval */
- globals.paranoid_checkpt = db_top / 5;
- if (globals.paranoid_checkpt < 1)
- globals.paranoid_checkpt = 1;
+ /* use a default interval */
+ globals.paranoid_checkpt = db_top / 5;
+ if (globals.paranoid_checkpt < 1)
+ globals.paranoid_checkpt = 1;
}
if (flag == DUMP_PARANOID) {
- notify_format(player, T("Paranoid dumping, checkpoint interval %d."),
- globals.paranoid_checkpt);
- do_rawlog(LT_CHECK,
- "*** PARANOID DUMP *** done by %s(#%d),\n",
- Name(player), player);
+ notify_format(player, T("Paranoid dumping, checkpoint interval %d."),
+ globals.paranoid_checkpt);
+ do_rawlog(LT_CHECK,
+ "*** PARANOID DUMP *** done by %s(#%d),\n",
+ Name(player), player);
} else {
- notify_format(player, T("Debug dumping, checkpoint interval %d."),
- globals.paranoid_checkpt);
- do_rawlog(LT_CHECK,
- "*** DEBUG DUMP *** done by %s(#%d),\n",
- Name(player), player);
+ notify_format(player, T("Debug dumping, checkpoint interval %d."),
+ globals.paranoid_checkpt);
+ do_rawlog(LT_CHECK,
+ "*** DEBUG DUMP *** done by %s(#%d),\n",
+ Name(player), player);
}
do_rawlog(LT_CHECK, T("\tcheckpoint interval %d, at %s"),
- globals.paranoid_checkpt, show_time(mudtime, 0));
+ globals.paranoid_checkpt, show_time(mudtime, 0));
} else {
/* normal dump */
- globals.paranoid_dump = 0; /* just to be safe */
+ globals.paranoid_dump = 0; /* just to be safe */
notify(player, "Dumping...");
do_rawlog(LT_CHECK, "** DUMP ** done by %s(#%d) at %s",
- Name(player), player, show_time(mudtime, 0));
+ Name(player), player, show_time(mudtime, 0));
}
fork_and_dump(1);
globals.paranoid_dump = 0;
{
if (GoodObject(global_eval_context.cplr))
do_rawlog(LT_TRACE, T("TRACE: Cmd:%s\tdepth:%d\tby #%d at #%d"), global_eval_context.ccom,
- depth, global_eval_context.cplr, Location(global_eval_context.cplr));
+ depth, global_eval_context.cplr, Location(global_eval_context.cplr));
else
do_rawlog(LT_TRACE, "TRACE: Cmd:%s\tdepth:%d\tby #%d", global_eval_context.ccom, depth, global_eval_context.cplr);
notify_activity(NOTHING, 0, 1);
do_rawlog(LT_ERR, T("Process statistics:"));
do_rawlog(LT_ERR, T("Time used: %10ld user %10ld sys"),
- usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
+ usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
do_rawlog(LT_ERR, "Max res mem: %10ld pages %10ld bytes",
- usage.ru_maxrss, (usage.ru_maxrss * psize));
+ usage.ru_maxrss, (usage.ru_maxrss * psize));
do_rawlog(LT_ERR, "Integral mem:%10ld shared %10ld private %10ld stack",
- usage.ru_ixrss, usage.ru_idrss, usage.ru_isrss);
+ usage.ru_ixrss, usage.ru_idrss, usage.ru_isrss);
do_rawlog(LT_ERR,
- T("Page faults: %10ld hard %10ld soft %10ld swapouts"),
- usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
+ T("Page faults: %10ld hard %10ld soft %10ld swapouts"),
+ usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
do_rawlog(LT_ERR, T("Disk I/O: %10ld reads %10ld writes"),
- usage.ru_inblock, usage.ru_oublock);
+ usage.ru_inblock, usage.ru_oublock);
do_rawlog(LT_ERR, T("Network I/O: %10ld in %10ld out"), usage.ru_msgrcv,
- usage.ru_msgsnd);
+ usage.ru_msgsnd);
do_rawlog(LT_ERR, T("Context swi: %10ld vol %10ld forced"),
- usage.ru_nvcsw, usage.ru_nivcsw);
+ usage.ru_nvcsw, usage.ru_nivcsw);
do_rawlog(LT_ERR, "Signals: %10ld", usage.ru_nsignals);
}
-#endif /* HAS_GETRUSAGE */
+#endif /* HAS_GETRUSAGE */
/** User interface to shut down the MUSH.
* \verbatim
{
flag_broadcast(0, 0, T("GAME: Shutdown by %s"), Name(player));
do_log(LT_ERR, player, NOTHING, T("SHUTDOWN by %s(%s)\n"),
- Name(player), unparse_dbref(player));
+ Name(player), unparse_dbref(player));
/* This will create a file used to check if a restart should occur */
#ifdef AUTORESTART
mush_panic("@shutdown/panic");
} else {
if (flag == SHUT_PARANOID) {
- globals.paranoid_checkpt = db_top / 5;
- if (globals.paranoid_checkpt < 1)
- globals.paranoid_checkpt = 1;
- globals.paranoid_dump = 1;
+ globals.paranoid_checkpt = db_top / 5;
+ if (globals.paranoid_checkpt < 1)
+ globals.paranoid_checkpt = 1;
+ globals.paranoid_dump = 1;
}
shutdown_flag = 1;
}
strcpy(tmpfl, make_new_epoch_file(options.flagdb, epoch));
sprintf(realtmpfl, "%s%s", tmpfl, options.compresssuff);
if((f = db_open_write(tmpfl)) != NULL) {
- use_flagfile = 1;
- db_write_flag_db(f);
- db_close(f);
+ use_flagfile = 1;
+ db_write_flag_db(f);
+ db_close(f);
#ifdef WIN32
- unlink(realdumpfile);
+ unlink(realdumpfile);
#endif
- if(rename(realtmpfl, realdumpfile) < 0) {
- perror(realtmpfl);
- longjmp(db_err, 1);
- }
+ if(rename(realtmpfl, realdumpfile) < 0) {
+ perror(realtmpfl);
+ longjmp(db_err, 1);
+ }
} else {
- perror(realtmpfl);
- longjmp(db_err, 1);
+ perror(realtmpfl);
+ longjmp(db_err, 1);
}
}
switch (globals.paranoid_dump) {
case 0:
#ifdef ALWAYS_PARANOID
- db_paranoid_write(f, 0);
+ db_paranoid_write(f, 0);
#else
- db_write(f, 0);
+ db_write(f, 0);
#endif
- break;
+ break;
case 1:
- db_paranoid_write(f, 0);
- break;
+ db_paranoid_write(f, 0);
+ break;
case 2:
- db_paranoid_write(f, 1);
- break;
+ db_paranoid_write(f, 1);
+ break;
}
db_close(f);
#ifdef WIN32
unlink(realdumpfile);
#endif
if (rename(realtmpfl, realdumpfile) < 0) {
- perror(realtmpfl);
- longjmp(db_err, 1);
+ perror(realtmpfl);
+ longjmp(db_err, 1);
}
} else {
perror(realtmpfl);
sprintf(realtmpfl, "%s%s", tmpfl, options.compresssuff);
if (mdb_top >= 0) {
if ((f = db_open_write(tmpfl)) != NULL) {
- dump_mail(f);
- db_close(f);
+ dump_mail(f);
+ db_close(f);
#ifdef WIN32
- unlink(realdumpfile);
+ unlink(realdumpfile);
#endif
- if (rename(realtmpfl, realdumpfile) < 0) {
- perror(realtmpfl);
- longjmp(db_err, 1);
- }
+ if (rename(realtmpfl, realdumpfile) < 0) {
+ perror(realtmpfl);
+ longjmp(db_err, 1);
+ }
} else {
- perror(realtmpfl);
- longjmp(db_err, 1);
+ perror(realtmpfl);
+ longjmp(db_err, 1);
}
}
#endif
unlink(realdumpfile);
#endif
if (rename(realtmpfl, realdumpfile) < 0) {
- perror(realtmpfl);
- longjmp(db_err, 1);
+ perror(realtmpfl);
+ longjmp(db_err, 1);
}
} else {
perror(realtmpfl);
if (already_panicking) {
do_rawlog(LT_ERR,
- T
- ("PANIC: Attempted to panic because of '%s' while already panicking. Run in circles, scream and shout!"),
- message);
+ T
+ ("PANIC: Attempted to panic because of '%s' while already panicking. Run in circles, scream and shout!"),
+ message);
_exit(133);
}
_exit(134);
} else {
if ((f = fopen(panicfile, FOPEN_WRITE)) == NULL) {
- do_rawlog(LT_ERR, T("CANNOT OPEN PANIC FILE, YOU LOSE"));
- _exit(135);
+ do_rawlog(LT_ERR, T("CANNOT OPEN PANIC FILE, YOU LOSE"));
+ _exit(135);
} else {
- do_rawlog(LT_ERR, T("DUMPING: %s"), panicfile);
- db_write(f, DBF_PANIC);
+ do_rawlog(LT_ERR, T("DUMPING: %s"), panicfile);
+ db_write(f, DBF_PANIC);
#ifdef USE_MAILER
- dump_mail(f);
+ dump_mail(f);
#endif
#ifdef CHAT_SYSTEM
- save_chatdb(f);
+ save_chatdb(f);
#endif /* CHAT_SYSTEM */
- fclose(f);
- do_rawlog(LT_ERR, T("DUMPING: %s (done)"), panicfile);
+ fclose(f);
+ do_rawlog(LT_ERR, T("DUMPING: %s (done)"), panicfile);
}
}
} else {
va_end(args);
mush_panic(c);
- _exit(136); /* Not reached but kills warnings */
+ _exit(136); /* Not reached but kills warnings */
}
/** Dump the database.
if (NO_FORK)
nofork = 1;
else
- nofork = !forking || (globals.paranoid_dump == 2); /* Don't fork for dump/debug */
+ nofork = !forking || (globals.paranoid_dump == 2); /* Don't fork for dump/debug */
#ifdef WIN32
nofork = 1;
#endif
if (child < 0) {
/* Oops, fork failed. Let's do a nofork dump */
do_log(LT_ERR, 0, 0,
- "fork_and_dump: fork() failed! Dumping nofork instead.");
+ "fork_and_dump: fork() failed! Dumping nofork instead.");
if (DUMP_NOFORK_MESSAGE && *DUMP_NOFORK_MESSAGE)
- flag_broadcast(0, 0, "%s", DUMP_NOFORK_MESSAGE);
+ flag_broadcast(0, 0, "%s", DUMP_NOFORK_MESSAGE);
child = 0;
nofork = 1;
if (split) {
- split = 0;
- chunk_fork_done();
+ split = 0;
+ chunk_fork_done();
}
} else if (child > 0) {
forked_dump_pid = child;
/* Lower the priority of the child to make parent more responsive */
#ifdef HAS_GETPRIORITY
setpriority(PRIO_PROCESS, child, getpriority(PRIO_PROCESS, child) + 4);
-#else /* HAS_GETPRIORITY */
+#else /* HAS_GETPRIORITY */
setpriority(PRIO_PROCESS, child, 8);
-#endif /* HAS_GETPRIORITY */
-#endif /* HAS_SETPRIORITY */
+#endif /* HAS_GETPRIORITY */
+#endif /* HAS_SETPRIORITY */
}
-#endif /* WIN32 */
+#endif /* WIN32 */
} else {
if (DUMP_NOFORK_MESSAGE && *DUMP_NOFORK_MESSAGE)
flag_broadcast(0, 0, "%s", DUMP_NOFORK_MESSAGE);
chunk_fork_done();
#endif
if (!nofork) {
- _exit(status); /* !!! */
+ _exit(status); /* !!! */
} else {
reserve_fd();
if (DUMP_NOFORK_COMPLETE && *DUMP_NOFORK_COMPLETE)
- flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
+ flag_broadcast(0, 0, "%s", DUMP_NOFORK_COMPLETE);
}
}
#ifdef LOG_CHUNK_STATS
for (thing = 0; thing < db_top; thing++) {
if (IsPlayer(thing)) {
if ((s = atr_get_noparent(thing, "ALIAS")) != NULL) {
- bp = buf;
- safe_str(atr_value(s), buf, &bp);
- *bp = '\0';
- add_player_alias(thing, buf);
+ bp = buf;
+ safe_str(atr_value(s), buf, &bp);
+ *bp = '\0';
+ add_player_alias(thing, buf);
}
}
}
for (thing = 0; thing < db_top; thing++) {
if (Name(thing) == NULL) {
if (IsGarbage(thing))
- set_name(thing, "Garbage");
+ set_name(thing, "Garbage");
else {
- do_log(LT_ERR, NOTHING, NOTHING, T("Null name on object #%d"), thing);
- set_name(thing, "XXXX");
+ do_log(LT_ERR, NOTHING, NOTHING, T("Null name on object #%d"), thing);
+ set_name(thing, "XXXX");
}
}
if (STARTUPS && !IsGarbage(thing) && !(Halted(thing))) {
do_rawlog(LT_ERR, "CobraMUSH v%s [%s]", VERSION, VBRANCH);
do_rawlog(LT_ERR, T("MUSH restarted, PID %d, at %s"),
- (int) getpid(), show_time(globals.start_time, 0));
+ (int) getpid(), show_time(globals.start_time, 0));
}
/** Post-db-load configuration.
/* Set up ssl */
if (!ssl_init()) {
fprintf(stderr, "SSL initialization failure\n");
- options.ssl_port = 0; /* Disable ssl */
+ options.ssl_port = 0; /* Disable ssl */
}
#endif
#if (defined(HAS_MYSQL) && defined(_SWMP_))
int panicdb;
#ifdef WIN32
- Win32MUSH_setup(); /* create index files, copy databases etc. */
+ Win32MUSH_setup(); /* create index files, copy databases etc. */
#endif
infile = restarting ? options.output_db : options.input_db;
use_flagfile = 1;
do_rawlog(LT_ERR, "LOADING: %s", flag_file);
if(load_flag_db(f) != 0)
- use_flagfile = 0;
+ use_flagfile = 0;
do_rawlog(LT_ERR, "LOADING: %s(done)", flag_file);
db_close(f);
}
/* complain about bad config options */
if (!GoodObject(PLAYER_START) || (!IsRoom(PLAYER_START)))
do_rawlog(LT_ERR, T("WARNING: Player_start (#%d) is NOT a room."),
- PLAYER_START);
+ PLAYER_START);
if (!GoodObject(MASTER_ROOM) || (!IsRoom(MASTER_ROOM)))
do_rawlog(LT_ERR, T("WARNING: Master room (#%d) is NOT a room."),
- MASTER_ROOM);
+ MASTER_ROOM);
if (!GoodObject(BASE_ROOM) || (!IsRoom(BASE_ROOM)))
do_rawlog(LT_ERR, T("WARNING: Base room (#%d) is NOT a room."),
- BASE_ROOM);
+ BASE_ROOM);
if (!GoodObject(DEFAULT_HOME) || (!IsRoom(DEFAULT_HOME)))
do_rawlog(LT_ERR, T("WARNING: Default home (#%d) is NOT a room."),
- DEFAULT_HOME);
+ DEFAULT_HOME);
if (!GoodObject(GOD) || (!IsPlayer(GOD)))
do_rawlog(LT_ERR, T("WARNING: God (#%d) is NOT a player."), GOD);
if (!panicdb) {
f = db_open(options.chatdb);
if (f) {
- do_rawlog(LT_ERR, "LOADING: %s", options.chatdb);
- dbline = 0;
- if (load_chatdb(f)) {
- do_rawlog(LT_ERR, "LOADING: %s (done)", options.chatdb);
- } else {
- do_rawlog(LT_ERR, "ERROR LOADING %s", options.chatdb);
- return -1;
- }
- db_close(f);
+ do_rawlog(LT_ERR, "LOADING: %s", options.chatdb);
+ dbline = 0;
+ if (load_chatdb(f)) {
+ do_rawlog(LT_ERR, "LOADING: %s (done)", options.chatdb);
+ } else {
+ do_rawlog(LT_ERR, "ERROR LOADING %s", options.chatdb);
+ return -1;
+ }
+ db_close(f);
}
}
#endif /* CHAT_SYSTEM */
int eo;
pass_ptn = pcre_compile("^(@pass.*?)\\s([^=]*)=(.*)",
- PCRE_CASELESS, &errptr, &eo, tables);
+ PCRE_CASELESS, &errptr, &eo, tables);
if (!pass_ptn)
do_log(LT_ERR, GOD, GOD, "pcre_compile: %s", errptr);
newpass_ptn = pcre_compile("^(@(?:newp|pcreate)[^=]*)=(.*)",
- PCRE_CASELESS, &errptr, &eo, tables);
+ PCRE_CASELESS, &errptr, &eo, tables);
if (!newpass_ptn)
do_log(LT_ERR, GOD, GOD, "pcre_compile: %s", errptr);
initialized = 1;
safe_chr('=', buff, &bp);
safe_fill('*', ovec[7] - ovec[6], buff, &bp);
} else if ((matched = pcre_exec(newpass_ptn, NULL, cmd, cmdlen, 0, 0,
- ovec, 20)) > 0) {
+ ovec, 20)) > 0) {
pcre_copy_substring(cmd, ovec, matched, 1, buff, BUFFER_LEN);
bp = buff + strlen(buff);
safe_chr('=', buff, &bp);
process_command(dbref player, char *command, dbref cause, dbref realcause, int from_port)
{
int a;
- char *p; /* utility */
+ char *p; /* utility */
- char unp[BUFFER_LEN]; /* unparsed command */
+ char unp[BUFFER_LEN]; /* unparsed command */
/* general form command arg0=arg1,arg2...arg10 */
- char temp[BUFFER_LEN]; /* utility */
- int i; /* utility */
+ char temp[BUFFER_LEN]; /* utility */
+ int i; /* utility */
char *cptr;
dbref errdb;
dbref check_loc;
/* robustify player */
if (!GoodObject(player)) {
do_log(LT_ERR, NOTHING, NOTHING, T("process_command bad player #%d"),
- player);
+ player);
return;
}
/* And neither can halted players if the command isn't from_port */
if (Halted(player) && (!IsPlayer(player) || !from_port)) {
notify_format(Owner(player),
- T("Attempt to execute command by halted object #%d"), player);
+ T("Attempt to execute command by halted object #%d"), player);
return;
}
/* Players, things, and exits should not have invalid locations. This check
* must be done _after_ the destroyed-object check.
*/
check_loc = IsExit(player) ? Source(player) : (IsRoom(player) ? player :
- Location(player));
+ Location(player));
if (!GoodObject(check_loc) || IsGarbage(check_loc)) {
notify_format(Owner(player),
- T("Invalid location on command execution: %s(#%d)"),
- Name(player), player);
+ T("Invalid location on command execution: %s(#%d)"),
+ Name(player), player);
do_log(LT_ERR, NOTHING, NOTHING,
- T("Command attempted by %s(#%d) in invalid location #%d."),
- Name(player), player, Location(player));
+ T("Command attempted by %s(#%d) in invalid location #%d."),
+ Name(player), player, Location(player));
if (Mobile(player))
- moveto(player, PLAYER_START); /* move it someplace valid */
+ moveto(player, PLAYER_START); /* move it someplace valid */
}
orator = player;
a = 0;
if (!Gagged(player)) {
if (Mobile(player)) {
- /* if the "player" is an exit or room, no need to do these checks */
- /* try matching enter aliases */
- if (check_loc != NOTHING &&
- (i = alias_list_check(Contents(check_loc), cptr, "EALIAS")) != -1) {
-
- sprintf(temp, "#%d", i);
- do_enter(player, temp);
- goto done;
- }
- /* if that didn't work, try matching leave aliases */
- if (!IsRoom(check_loc) && (loc_alias_check(check_loc, cptr, "LALIAS"))) {
- do_leave(player);
- goto done;
- }
+ /* if the "player" is an exit or room, no need to do these checks */
+ /* try matching enter aliases */
+ if (check_loc != NOTHING &&
+ (i = alias_list_check(Contents(check_loc), cptr, "EALIAS")) != -1) {
+
+ sprintf(temp, "#%d", i);
+ do_enter(player, temp);
+ goto done;
+ }
+ /* if that didn't work, try matching leave aliases */
+ if (!IsRoom(check_loc) && (loc_alias_check(check_loc, cptr, "LALIAS"))) {
+ do_leave(player);
+ goto done;
+ }
}
/* try matching user defined functions before chopping */
* and objects in the player's inventory.
*/
if (GoodObject(check_loc)) {
- a += list_match(Contents(check_loc));
- if (check_loc != player) {
- a += cmd_match(check_loc);
- MAYBE_ADD_ERRDB(errdb);
- }
+ a += list_match(Contents(check_loc));
+ if (check_loc != player) {
+ a += cmd_match(check_loc);
+ MAYBE_ADD_ERRDB(errdb);
+ }
}
if (check_loc != player)
- a += list_match(Contents(player));
+ a += list_match(Contents(player));
/* now do check on zones */
if ((!a) && (Zone(check_loc) != NOTHING)) {
- if (IsRoom(Zone(check_loc))) {
- /* zone of player's location is a zone master room,
- * so we check for exits and commands
- */
- /* check zone master room exits */
- if (remote_exit(player, cptr)) {
- if (!Mobile(player))
- goto done;
- else {
- do_move(player, cptr, 2);
- goto done;
- }
- } else
- a += list_match(Contents(Zone(Location(player))));
- } else {
- a += cmd_match(Zone(Location(player)));
- MAYBE_ADD_ERRDB(errdb);
- }
+ if (IsRoom(Zone(check_loc))) {
+ /* zone of player's location is a zone master room,
+ * so we check for exits and commands
+ */
+ /* check zone master room exits */
+ if (remote_exit(player, cptr)) {
+ if (!Mobile(player))
+ goto done;
+ else {
+ do_move(player, cptr, 2);
+ goto done;
+ }
+ } else
+ a += list_match(Contents(Zone(Location(player))));
+ } else {
+ a += cmd_match(Zone(Location(player)));
+ MAYBE_ADD_ERRDB(errdb);
+ }
}
/* if nothing matched with zone master room/zone object, try
* matching zone commands on the player's personal zone
*/
if ((!a) && (Zone(player) != NOTHING) && GoodObject(Location(check_loc))
- && (Zone(Location(check_loc)) != Zone(player))) {
- if (IsRoom(Zone(player)))
- /* Player's personal zone is a zone master room, so we
- * also check commands on objects in that room
- */
- a += list_match(Contents(Zone(check_loc)));
- else {
- a += cmd_match(Zone(player));
- MAYBE_ADD_ERRDB(errdb);
- }
+ && (Zone(Location(check_loc)) != Zone(player))) {
+ if (IsRoom(Zone(player)))
+ /* Player's personal zone is a zone master room, so we
+ * also check commands on objects in that room
+ */
+ a += list_match(Contents(Zone(check_loc)));
+ else {
+ a += cmd_match(Zone(player));
+ MAYBE_ADD_ERRDB(errdb);
+ }
}
/* end of zone stuff */
/* check division object */
/* check global exits only if no other commands are matched */
if ((!a) && (check_loc != MASTER_ROOM)) {
- if (global_exit(player, cptr)) {
- if (!Mobile(player))
- goto done;
- else {
- do_move(player, cptr, 1);
- goto done;
- }
- } else
- /* global user-defined commands checked if all else fails.
- * May match more than one command in the master room.
- */
- a += list_match(Contents(MASTER_ROOM));
+ if (global_exit(player, cptr)) {
+ if (!Mobile(player))
+ goto done;
+ else {
+ do_move(player, cptr, 1);
+ goto done;
+ }
+ } else
+ /* global user-defined commands checked if all else fails.
+ * May match more than one command in the master room.
+ */
+ a += list_match(Contents(MASTER_ROOM));
}
/* end of master room check */
- } /* end of special checks */
+ } /* end of special checks */
if (!a) {
/* Do we have any error dbs queued up, and if so, do any
* have associated failure messages?
*/
if ((errdblist == errdbtail) || (!fail_commands(player)))
- generic_command_failure(player, cause, unp, from_port);
+ generic_command_failure(player, cause, unp, from_port);
}
}
const char *p;
while (*list) {
for (p = command; (*p && DOWNCASE(*p) == DOWNCASE(*list)
- && *list != EXIT_DELIMITER); p++, list++) ;
+ && *list != EXIT_DELIMITER); p++, list++) ;
if (*p == '\0') {
while (isspace((unsigned char) *list))
- list++;
+ list++;
if (*list == '\0' || *list == EXIT_DELIMITER)
- return 1; /* word matched */
+ return 1; /* word matched */
}
/* didn't match. check next word in list */
while (*list && *list++ != EXIT_DELIMITER) ;
*/
int
list_check(dbref thing, dbref player, char type, char end, char *str,
- int just_match)
+ int just_match)
{
int match = 0;
dbref errdb = NOTHING;
while (thing != NOTHING) {
if (atr_comm_match
- (thing, player, type, end, str, just_match, NULL, NULL, &errdb))
+ (thing, player, type, end, str, just_match, NULL, NULL, &errdb))
match = 1;
else {
MAYBE_ADD_ERRDB(errdb);
if (a) {
strcpy(alias, atr_value(a));
if (check_alias(command, alias) != 0)
- return thing; /* matched an alias */
+ return thing; /* matched an alias */
}
thing = Next(thing);
}
ALIST *ptr;
if(Halted(thing)||NoCommand(thing))
- return 0;
+ return 0;
for (ptr = List(thing); ptr; ptr = AL_NEXT(ptr)) {
if (AF_Command(ptr) && !AF_Noprog(ptr))
return (1);
if (IsPlayer(a))
s_Pennies(a, amt);
notify_format(player,
- T
- ("The money supply of all players has been reset to %d %s."),
- amt, MONIES);
+ T
+ ("The money supply of all players has been reset to %d %s."),
+ amt, MONIES);
do_log(LT_WIZ, player, NOTHING,
- T("** POOR done ** Money supply reset to %d %s."), amt, MONIES);
+ T("** POOR done ** Money supply reset to %d %s."), amt, MONIES);
}
do_writelog(dbref player, char *str, int ltype)
{
do_rawlog(ltype, "LOG: %s(#%d%s): %s", Name(player), player,
- unparse_flags(player, GOD), str);
+ unparse_flags(player, GOD), str);
notify(player, "Logged.");
}
*/
void
bind_and_queue(dbref player, dbref cause, char *action,
- const char *arg, const char *placestr)
+ const char *arg, const char *placestr)
{
char *repl, *command;
const char *replace[2];
if (IsRoom(Zone(Location(player)))) {
/* zone of player's location is a zone master room */
if (Location(player) != Zone(player)) {
- DOLIST(thing, Contents(Zone(Location(player)))) {
- if (ScanFind(player, thing)) {
- *ptr = '\0';
- safe_str(atrname, tbuf, &tp);
- ptr = atrname;
- }
- }
+ DOLIST(thing, Contents(Zone(Location(player)))) {
+ if (ScanFind(player, thing)) {
+ *ptr = '\0';
+ safe_str(atrname, tbuf, &tp);
+ ptr = atrname;
+ }
+ }
}
} else {
/* regular zone object */
if (ScanFind(player, Zone(Location(player)))) {
- *ptr = '\0';
- safe_str(atrname, tbuf, &tp);
+ *ptr = '\0';
+ safe_str(atrname, tbuf, &tp);
}
}
}
/* check the player's personal zone */
if (IsRoom(Zone(player))) {
if (Location(player) != Zone(player)) {
- DOLIST(thing, Contents(Zone(player))) {
- if (ScanFind(player, thing)) {
- *ptr = '\0';
- safe_str(atrname, tbuf, &tp);
- ptr = atrname;
- }
- }
+ DOLIST(thing, Contents(Zone(player))) {
+ if (ScanFind(player, thing)) {
+ *ptr = '\0';
+ safe_str(atrname, tbuf, &tp);
+ ptr = atrname;
+ }
+ }
}
} else if (ScanFind(player, Zone(player))) {
*ptr = '\0';
/* try Master Room stuff */
DOLIST(thing, Contents(MASTER_ROOM)) {
if (ScanFind(player, thing)) {
- *ptr = '\0';
- safe_str(atrname, tbuf, &tp);
- ptr = atrname;
+ *ptr = '\0';
+ safe_str(atrname, tbuf, &tp);
+ ptr = atrname;
}
}
}
*tp = '\0';
if (*tbuf && *tbuf == ' ')
- return tbuf + 1; /* atrname comes with leading spaces */
+ return tbuf + 1; /* atrname comes with leading spaces */
return tbuf;
}
notify(player, T("Matches on contents of this room:"));
DOLIST(thing, Contents(Location(player))) {
if (ScanFind(player, thing)) {
- *ptr = '\0';
- notify_format(player,
- "%s [%d:%s]", unparse_object(player, thing),
- num, atrname);
- ptr = atrname;
+ *ptr = '\0';
+ notify_format(player,
+ "%s [%d:%s]", unparse_object(player, thing),
+ num, atrname);
+ ptr = atrname;
}
}
}
if (ScanFind(player, Location(player))) {
*ptr = '\0';
notify_format(player, T("Matched here: %s [%d:%s]"),
- unparse_object(player, Location(player)), num, atrname);
+ unparse_object(player, Location(player)), num, atrname);
}
}
ptr = atrname;
notify(player, T("Matches on carried objects:"));
DOLIST(thing, Contents(player)) {
if (ScanFind(player, thing)) {
- *ptr = '\0';
- notify_format(player, "%s [%d:%s]",
- unparse_object(player, thing), num, atrname);
- ptr = atrname;
+ *ptr = '\0';
+ notify_format(player, "%s [%d:%s]",
+ unparse_object(player, thing), num, atrname);
+ ptr = atrname;
}
}
}
if (ScanFind(player, player)) {
*ptr = '\0';
notify_format(player, T("Matched self: %s [%d:%s]"),
- unparse_object(player, player), num, atrname);
+ unparse_object(player, player), num, atrname);
}
}
ptr = atrname;
/* zone checks */
if (Zone(Location(player)) != NOTHING) {
if (IsRoom(Zone(Location(player)))) {
- /* zone of player's location is a zone master room */
- if (Location(player) != Zone(player)) {
- notify(player, T("Matches on zone master room of location:"));
- DOLIST(thing, Contents(Zone(Location(player)))) {
- if (ScanFind(player, thing)) {
- *ptr = '\0';
- notify_format(player, "%s [%d:%s]",
- unparse_object(player, thing), num, atrname);
- ptr = atrname;
- }
- }
- }
+ /* zone of player's location is a zone master room */
+ if (Location(player) != Zone(player)) {
+ notify(player, T("Matches on zone master room of location:"));
+ DOLIST(thing, Contents(Zone(Location(player)))) {
+ if (ScanFind(player, thing)) {
+ *ptr = '\0';
+ notify_format(player, "%s [%d:%s]",
+ unparse_object(player, thing), num, atrname);
+ ptr = atrname;
+ }
+ }
+ }
} else {
- /* regular zone object */
- if (ScanFind(player, Zone(Location(player)))) {
- *ptr = '\0';
- notify_format(player,
- T("Matched zone of location: %s [%d:%s]"),
- unparse_object(player,
- Zone(Location(player))), num, atrname);
- }
+ /* regular zone object */
+ if (ScanFind(player, Zone(Location(player)))) {
+ *ptr = '\0';
+ notify_format(player,
+ T("Matched zone of location: %s [%d:%s]"),
+ unparse_object(player,
+ Zone(Location(player))), num, atrname);
+ }
}
}
ptr = atrname;
if ((Zone(player) != NOTHING)
- && (Zone(player) != Zone(Location(player)))) {
+ && (Zone(player) != Zone(Location(player)))) {
/* check the player's personal zone */
if (IsRoom(Zone(player))) {
- if (Location(player) != Zone(player)) {
- notify(player, T("Matches on personal zone master room:"));
- DOLIST(thing, Contents(Zone(player))) {
- if (ScanFind(player, thing)) {
- *ptr = '\0';
- notify_format(player, "%s [%d:%s]",
- unparse_object(player, thing), num, atrname);
- ptr = atrname;
- }
- }
- }
+ if (Location(player) != Zone(player)) {
+ notify(player, T("Matches on personal zone master room:"));
+ DOLIST(thing, Contents(Zone(player))) {
+ if (ScanFind(player, thing)) {
+ *ptr = '\0';
+ notify_format(player, "%s [%d:%s]",
+ unparse_object(player, thing), num, atrname);
+ ptr = atrname;
+ }
+ }
+ }
} else if (ScanFind(player, Zone(player))) {
- *ptr = '\0';
- notify_format(player, T("Matched personal zone: %s [%d:%s]"),
- unparse_object(player, Zone(player)), num, atrname);
+ *ptr = '\0';
+ notify_format(player, T("Matched personal zone: %s [%d:%s]"),
+ unparse_object(player, Zone(player)), num, atrname);
}
}
}
notify(player, T("Matches on objects in the Master Room:"));
DOLIST(thing, Contents(MASTER_ROOM)) {
if (ScanFind(player, thing)) {
- *ptr = '\0';
- notify_format(player, "%s [%d:%s]",
- unparse_object(player, thing), num, atrname);
- ptr = atrname;
+ *ptr = '\0';
+ notify_format(player, "%s [%d:%s]",
+ unparse_object(player, thing), num, atrname);
+ ptr = atrname;
}
}
}
*/
void
do_dolist(dbref player, char *list, char *command, dbref cause,
- unsigned int flags)
+ unsigned int flags)
{
char *curr, *objstring;
char outbuf[BUFFER_LEN];
if (list[1] != ' ') {
notify(player, T("Separator must be one character."));
if (flags & DOL_NOTIFY)
- parse_que(player, "@notify me", cause);
+ parse_que(player, "@notify me", cause);
return;
}
delim = list[0];
char *ebuf, *ebufptr;
/* it's @map, add to the output list */
if (bp != outbuf)
- safe_chr(delim, outbuf, &bp);
+ safe_chr(delim, outbuf, &bp);
replace[0] = curr;
replace[1] = placestr;
ebufptr = ebuf = replace_string2(standard_tokens, replace, command);
process_expression(outbuf, &bp, (char const **) &ebuf, player,
- cause, cause, PE_DEFAULT, PT_DEFAULT, NULL);
+ cause, cause, PE_DEFAULT, PT_DEFAULT, NULL);
mush_free(ebufptr, "replace_string.buff");
}
}
/* Use /proc files instead of calling the external uptime program on linux */
char tbuf1[BUFFER_LEN];
FILE *fp;
- char line[128]; /* Overkill */
+ char line[128]; /* Overkill */
char *nl;
Pid_t pid;
int psize;
only care about seconds. */
uptime = strtol(line, NULL, 10);
if (uptime > 86400)
- fmt = "up $d days, $2h:$2M,";
+ fmt = "up $d days, $2h:$2M,";
else
- fmt = "up $2h:$2M,";
+ fmt = "up $2h:$2M,";
do_timestring(tbuf1, &nl, fmt, uptime);
} else {
safe_str("Unknown uptime,", tbuf1, &nl);
l = x;
load[2] = strtod(l, NULL);
safe_format(tbuf1, &nl, " load average: %.2f, %.2f, %.2f",
- load[0], load[1], load[2]);
+ load[0], load[1], load[2]);
} else {
safe_str("Unknown load", tbuf1, &nl);
}
pid = getpid();
psize = getpagesize();
notify_format(player,
- T("\nWorking directory: %s\nProcess ID: %10u %10d bytes per page"),
- tbuf1, pid, psize);
+ T("\nWorking directory: %s\nProcess ID: %10u %10d bytes per page"),
+ tbuf1, pid, psize);
/* Linux's getrusage() is mostly unimplemented. Just has times, page faults
and swapouts. We use /proc/self/status */
#ifdef HAS_GETRUSAGE
getrusage(RUSAGE_SELF, &usage);
notify_format(player, T("Time used: %10ld user %10ld sys"),
- usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
+ usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
notify_format(player,
- T
- ("Page faults: %10ld hard %10ld soft %10ld swapouts"),
- usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
+ T
+ ("Page faults: %10ld hard %10ld soft %10ld swapouts"),
+ usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
#endif
fp = fopen("/proc/self/status", "r");
if (!fp)
for (n = 0; fields[n]; n++) {
size_t len = strlen(fields[n]);
if (strncmp(line, fields[n], len) == 0) {
- if ((nl = strchr(line, '\n')) != NULL)
- *nl = '\0';
- notify(player, line);
+ if ((nl = strchr(line, '\n')) != NULL)
+ *nl = '\0';
+ notify(player, line);
}
}
}
static void
win32_uptime(dbref player __attribute__ ((__unused__)))
-{ /* written by NJG */
+{ /* written by NJG */
#ifdef WIN32
MEMORYSTATUS memstat;
double mem;
pclose(fp);
notify(player, tbuf1);
-#endif /* HAS_UPTIME */
+#endif /* HAS_UPTIME */
/* do process stats */
(void) getcwd(tbuf1, BUFFER_LEN);
pid = getpid();
psize = getpagesize();
notify_format(player,
- T("\nWorking directory: %s\nProcess ID: %10u %10d bytes per page"),
- tbuf1, pid, psize);
+ T("\nWorking directory: %s\nProcess ID: %10u %10d bytes per page"),
+ tbuf1, pid, psize);
#ifdef HAS_GETRUSAGE
getrusage(RUSAGE_SELF, &usage);
notify_format(player, T("Time used: %10ld user %10ld sys"),
- usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
+ usage.ru_utime.tv_sec, usage.ru_stime.tv_sec);
notify_format(player, "Max res mem: %10ld pages %10ld bytes",
- usage.ru_maxrss, (usage.ru_maxrss * psize));
+ usage.ru_maxrss, (usage.ru_maxrss * psize));
notify_format(player,
- "Integral mem:%10ld shared %10ld private %10ld stack",
- usage.ru_ixrss, usage.ru_idrss, usage.ru_isrss);
+ "Integral mem:%10ld shared %10ld private %10ld stack",
+ usage.ru_ixrss, usage.ru_idrss, usage.ru_isrss);
notify_format(player,
- T
- ("Page faults: %10ld hard %10ld soft %10ld swapouts"),
- usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
+ T
+ ("Page faults: %10ld hard %10ld soft %10ld swapouts"),
+ usage.ru_majflt, usage.ru_minflt, usage.ru_nswap);
notify_format(player, T("Disk I/O: %10ld reads %10ld writes"),
- usage.ru_inblock, usage.ru_oublock);
+ usage.ru_inblock, usage.ru_oublock);
notify_format(player, T("Network I/O: %10ld in %10ld out"),
- usage.ru_msgrcv, usage.ru_msgsnd);
+ usage.ru_msgrcv, usage.ru_msgsnd);
notify_format(player, T("Context swi: %10ld vol %10ld forced"),
- usage.ru_nvcsw, usage.ru_nivcsw);
+ usage.ru_nvcsw, usage.ru_nivcsw);
notify_format(player, "Signals: %10ld", usage.ru_nsignals);
-#endif /* HAS_GETRUSAGE */
+#endif /* HAS_GETRUSAGE */
}
#endif
if (globals.last_dump_time > 0) {
when = localtime(&globals.last_dump_time);
strftime(tbuf1, sizeof tbuf1,
- T(" Time of last database save: %a %b %d %X %Z %Y"), when);
+ T(" Time of last database save: %a %b %d %X %Z %Y"), when);
notify(player, tbuf1);
}
when = localtime(&options.dump_counter);
strftime(tbuf1, sizeof tbuf1, "%X", when);
notify_format(player,
- T
- ("Time until next database save: %ld minutes %ld seconds, at %s"),
- (options.dump_counter - mudtime) / 60,
- (options.dump_counter - mudtime) % 60, tbuf1);
+ T
+ ("Time until next database save: %ld minutes %ld seconds, at %s"),
+ (options.dump_counter - mudtime) / 60,
+ (options.dump_counter - mudtime) % 60, tbuf1);
when = localtime(&options.dbck_counter);
strftime(tbuf1, sizeof tbuf1, "%X", when);
notify_format(player,
- T
- (" Time until next dbck check: %ld minutes %ld seconds, at %s."),
- (options.dbck_counter - mudtime) / 60,
- (options.dbck_counter - mudtime) % 60, tbuf1);
+ T
+ (" Time until next dbck check: %ld minutes %ld seconds, at %s."),
+ (options.dbck_counter - mudtime) / 60,
+ (options.dbck_counter - mudtime) % 60, tbuf1);
when = localtime(&options.purge_counter);
strftime(tbuf1, sizeof tbuf1, "%X", when);
notify_format(player,
- T
- (" Time until next purge: %ld minutes %ld seconds, at %s."),
- (options.purge_counter - mudtime) / 60,
- (options.purge_counter - mudtime) % 60, tbuf1);
+ T
+ (" Time until next purge: %ld minutes %ld seconds, at %s."),
+ (options.purge_counter - mudtime) / 60,
+ (options.purge_counter - mudtime) % 60, tbuf1);
if (options.warn_interval) {
when = localtime(&options.warn_counter);
strftime(tbuf1, sizeof tbuf1, "%X", when);
notify_format(player,
- T
- (" Time until next @warnings: %ld minutes %ld seconds, at %s."),
- (options.warn_counter - mudtime) / 60,
- (options.warn_counter - mudtime) % 60, tbuf1);
+ T
+ (" Time until next @warnings: %ld minutes %ld seconds, at %s."),
+ (options.warn_counter - mudtime) / 60,
+ (options.warn_counter - mudtime) % 60, tbuf1);
}
/* Mortals, go no further! */
fclose(f);
f =
#ifdef __LCC__
- (FILE *)
+ (FILE *)
#endif
- popen(tprintf
- ("%s < %s%s", options.uncompressprog, filename,
- options.compresssuff), "r");
+ popen(tprintf
+ ("%s < %s%s", options.uncompressprog, filename,
+ options.compresssuff), "r");
/* Force the pipe to be fully buffered */
if (f)
- setvbuf(f, NULL, _IOFBF, BUFSIZ);
+ setvbuf(f, NULL, _IOFBF, BUFSIZ);
}
} else
-#endif /* WIN32 */
+#endif /* WIN32 */
{
f = fopen(filename, FOPEN_READ);
}
if (chdir(workdir) < 0)
#endif
fprintf(stderr,
- "chdir to %s failed in db_open_write, errno %d (%s)\n",
- workdir, errno, strerror(errno));
+ "chdir to %s failed in db_open_write, errno %d (%s)\n",
+ workdir, errno, strerror(errno));
} else {
/* If this fails, we probably can't write to a log, either, though */
fprintf(stderr,
- "getcwd failed during db_open_write, errno %d (%s)\n",
- errno, strerror(errno));
+ "getcwd failed during db_open_write, errno %d (%s)\n",
+ errno, strerror(errno));
}
#ifndef WIN32
if (options.compressprog && *options.compressprog) {
(FILE *)
#endif
popen(tprintf
- ("%s >%s%s", options.compressprog, filename,
- options.compresssuff), "w");
+ ("%s >%s%s", options.compressprog, filename,
+ options.compresssuff), "w");
/* Force the pipe to be fully buffered */
if (f)
setvbuf(f, NULL, _IOFBF, BUFSIZ);
} else
-#endif /* WIN32 */
+#endif /* WIN32 */
{
f = fopen(filename, FOPEN_WRITE);
}
if (options.compressprog && *options.compressprog) {
pclose(f);
} else
-#endif /* WIN32 */
+#endif /* WIN32 */
{
fclose(f);
}
compress_stats(&items, &used, &total_uncomp, &total_comp);
notify(player, "---------- Internal attribute compression ----------");
notify_format(player,
- "%10ld compression table items used, "
- "taking %ld bytes.", items, used);
+ "%10ld compression table items used, "
+ "taking %ld bytes.", items, used);
notify_format(player, "%10ld bytes in text before compression. ",
- total_uncomp);
+ total_uncomp);
notify_format(player, "%10ld bytes in text AFTER compression. ",
- total_comp);
+ total_comp);
percent = ((float) (total_comp)) / ((float) total_uncomp) * 100.0;
notify_format(player,
- "%10.0f %% text compression ratio (lower is better). ",
- percent);
+ "%10.0f %% text compression ratio (lower is better). ",
+ percent);
percent =
((float) (total_comp + used + (32768L * sizeof(char *)))) /
((float) total_uncomp) * 100.0;
notify_format(player,
- "%10.0f %% OVERALL compression ratio (lower is better). ",
- percent);
+ "%10.0f %% OVERALL compression ratio (lower is better). ",
+ percent);
notify_format(player,
- T
- (" (Includes table items, and table of words pointers of %ld bytes)"),
- 32768L * sizeof(char *));
+ T
+ (" (Includes table items, and table of words pointers of %ld bytes)"),
+ 32768L * sizeof(char *));
if (percent >= 100.0)
notify(player,
- " " "(Compression ratio improves with larger database)");
+ " " "(Compression ratio improves with larger database)");
}
#endif
static char *
make_new_epoch_file(const char *basename, int the_epoch)
{
- static char result[BUFFER_LEN]; /* STATIC! */
+ static char result[BUFFER_LEN]; /* STATIC! */
/* Unlink the last the_epoch and create a new one */
sprintf(result, "%s.#%d#", basename, the_epoch - 1);
unlink(result);
errdb_grow(void)
{
if (errdbsize >= 50)
- return; /* That's it, no more, forget it */
+ return; /* That's it, no more, forget it */
errdbsize++;
errdblist = realloc(errdblist, errdbsize * sizeof(dbref));
errdbtail = errdblist + errdbsize - 1;
#include <unistd.h>
#endif
-#endif /* _MALLOC_INTERNAL. */
+#endif /* _MALLOC_INTERNAL. */
#ifdef __cplusplus
extern "C" {
#define __P(args) args
#undef __ptr_t
#define __ptr_t void *
-#else /* Not C++ or ANSI C. */
+#else /* Not C++ or ANSI C. */
#undef __P
#define __P(args) ()
#undef const
#define const
#undef __ptr_t
#define __ptr_t char *
-#endif /* C++ or ANSI C. */
+#endif /* C++ or ANSI C. */
#if defined (__STDC__) && __STDC__
#include <stddef.h>
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
extern __ptr_t memalign __P((__malloc_size_t __alignment,
- __malloc_size_t __size));
+ __malloc_size_t __size));
/* Allocate SIZE bytes on a page boundary. */
extern __ptr_t valloc __P((__malloc_size_t __size));
logarithm to the base two of the fragment size. */
int type;
union {
- struct {
- __malloc_size_t nfree; /* Free frags in a fragmented block. */
- __malloc_size_t first; /* First free fragment of the block. */
- } frag;
- /* For a large object, in its first block, this has the number
- of blocks in the object. In the other blocks, this has a
- negative number which says how far back the first block is. */
- __malloc_ptrdiff_t size;
+ struct {
+ __malloc_size_t nfree; /* Free frags in a fragmented block. */
+ __malloc_size_t first; /* First free fragment of the block. */
+ } frag;
+ /* For a large object, in its first block, this has the number
+ of blocks in the object. In the other blocks, this has a
+ negative number which says how far back the first block is. */
+ __malloc_ptrdiff_t size;
} info;
} busy;
/* Heap information for a free block
(that may be the first of a free cluster). */
struct {
- __malloc_size_t size; /* Size (in blocks) of a free cluster. */
- __malloc_size_t next; /* Index of next free cluster. */
- __malloc_size_t prev; /* Index of previous free cluster. */
+ __malloc_size_t size; /* Size (in blocks) of a free cluster. */
+ __malloc_size_t next; /* Index of next free cluster. */
+ __malloc_size_t prev; /* Index of previous free cluster. */
} free;
} malloc_info;
/* List of blocks allocated with `memalign' (or `valloc'). */
struct alignlist {
struct alignlist *next;
- __ptr_t aligned; /* The address that memaligned returned. */
- __ptr_t exact; /* The address that malloc returned. */
+ __ptr_t aligned; /* The address that memaligned returned. */
+ __ptr_t exact; /* The address that malloc returned. */
};
extern struct alignlist *_aligned_blocks;
/* Internal version of `free' used in `morecore' (malloc.c). */
extern void _free_internal __P((__ptr_t __ptr));
-#endif /* _MALLOC_INTERNAL. */
+#endif /* _MALLOC_INTERNAL. */
/* Given an address in the middle of a malloc'd object,
return the address of the beginning of the object. */
/* Return values for `mprobe': these are the kinds of inconsistencies that
`mcheck' enables detection of. */
enum mcheck_status {
- MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
- MCHECK_OK, /* Block is fine. */
- MCHECK_FREE, /* Block freed twice. */
- MCHECK_HEAD, /* Memory before the block was clobbered. */
- MCHECK_TAIL /* Memory after the block was clobbered. */
+ MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
+ MCHECK_OK, /* Block is fine. */
+ MCHECK_FREE, /* Block freed twice. */
+ MCHECK_HEAD, /* Memory before the block was clobbered. */
+ MCHECK_TAIL /* Memory after the block was clobbered. */
};
/* Activate a standard collection of debugging hooks. This must be called
/* Statistics available to the user. */
struct mstats {
- __malloc_size_t bytes_total; /* Total size of the heap. */
- __malloc_size_t chunks_used; /* Chunks allocated by the user. */
- __malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */
- __malloc_size_t chunks_free; /* Chunks in the free list. */
- __malloc_size_t bytes_free; /* Byte total of chunks in the free list. */
+ __malloc_size_t bytes_total; /* Total size of the heap. */
+ __malloc_size_t chunks_used; /* Chunks allocated by the user. */
+ __malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */
+ __malloc_size_t chunks_free; /* Chunks in the free list. */
+ __malloc_size_t bytes_free; /* Byte total of chunks in the free list. */
};
/* Pick up the current statistics. */
/* Call WARNFUN with a warning message when memory usage is high. */
extern void memory_warnings __P((__ptr_t __start,
- void (*__warnfun) __P((const char *))));
+ void (*__warnfun) __P((const char *))));
/* Relocating allocator. */
#ifdef __cplusplus
}
#endif
-#endif /* malloc.h */ /* Allocate memory on a page boundary.
- Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; see the file COPYING.LIB. If
- not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- The author may be reached (Email) at the address mike@ai.mit.edu,
- or (US mail) as Mike Haertel c/o Free Software Foundation. */
+#endif /* malloc.h */ /* Allocate memory on a page boundary.
+ Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; see the file COPYING.LIB. If
+ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+ Cambridge, MA 02139, USA.
+
+ The author may be reached (Email) at the address mike@ai.mit.edu,
+ or (US mail) as Mike Haertel c/o Free Software Foundation. */
#if defined (__GNU_LIBRARY__) || defined (_LIBC)
#include <stddef.h>
#include <sys/cdefs.h>
result = (*__morecore) (size);
adj = (unsigned long int) ((unsigned long int) ((char *) result -
- (char *) NULL)) % BLOCKSIZE;
+ (char *) NULL)) % BLOCKSIZE;
if (adj != 0) {
adj = BLOCKSIZE - adj;
(void) (*__morecore) (adj);
result = (__ptr_t) next;
next->prev->next = next->next;
if (next->next != NULL)
- next->next->prev = next->prev;
+ next->next->prev = next->prev;
block = BLOCK(result);
if (--_heapinfo[block].busy.info.frag.nfree != 0)
- _heapinfo[block].busy.info.frag.first = (unsigned long int)
- ((unsigned long int) ((char *) next->next - (char *) NULL)
- % BLOCKSIZE) >> log;
+ _heapinfo[block].busy.info.frag.first = (unsigned long int)
+ ((unsigned long int) ((char *) next->next - (char *) NULL)
+ % BLOCKSIZE) >> log;
/* Update the statistics. */
++_chunks_used;
and break it into fragments, returning the first. */
result = malloc(BLOCKSIZE);
if (result == NULL)
- return NULL;
+ return NULL;
/* Link all fragments but the first into the free list. */
for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> log); ++i) {
- next = (struct list *) ((char *) result + (i << log));
- next->next = _fraghead[log].next;
- next->prev = &_fraghead[log];
- next->prev->next = next;
- if (next->next != NULL)
- next->next->prev = next;
+ next = (struct list *) ((char *) result + (i << log));
+ next->next = _fraghead[log].next;
+ next->prev = &_fraghead[log];
+ next->prev->next = next;
+ if (next->next != NULL)
+ next->next->prev = next;
}
/* Initialize the nfree and first counters for this block. */
while (_heapinfo[block].free.size < blocks) {
block = _heapinfo[block].free.next;
if (block == start) {
- /* Need to get more from the system. Check to see if
- the new core will be contiguous with the final free
- block; if so we don't need to get as much. */
- block = _heapinfo[0].free.prev;
- lastblocks = _heapinfo[block].free.size;
- if (_heaplimit != 0 && block + lastblocks == _heaplimit &&
- (*__morecore) (0) == ADDRESS(block + lastblocks) &&
- (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) {
- /* Which block we are extending (the `final free
- block' referred to above) might have changed, if
- it got combined with a freed info table. */
- block = _heapinfo[0].free.prev;
- _heapinfo[block].free.size += (blocks - lastblocks);
- _bytes_free += (blocks - lastblocks) * BLOCKSIZE;
- continue;
- }
- result = morecore(blocks * BLOCKSIZE);
- if (result == NULL)
- return NULL;
- block = BLOCK(result);
- _heapinfo[block].busy.type = 0;
- _heapinfo[block].busy.info.size = blocks;
- ++_chunks_used;
- _bytes_used += blocks * BLOCKSIZE;
- return result;
+ /* Need to get more from the system. Check to see if
+ the new core will be contiguous with the final free
+ block; if so we don't need to get as much. */
+ block = _heapinfo[0].free.prev;
+ lastblocks = _heapinfo[block].free.size;
+ if (_heaplimit != 0 && block + lastblocks == _heaplimit &&
+ (*__morecore) (0) == ADDRESS(block + lastblocks) &&
+ (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) {
+ /* Which block we are extending (the `final free
+ block' referred to above) might have changed, if
+ it got combined with a freed info table. */
+ block = _heapinfo[0].free.prev;
+ _heapinfo[block].free.size += (blocks - lastblocks);
+ _bytes_free += (blocks - lastblocks) * BLOCKSIZE;
+ continue;
+ }
+ result = morecore(blocks * BLOCKSIZE);
+ if (result == NULL)
+ return NULL;
+ block = BLOCK(result);
+ _heapinfo[block].busy.type = 0;
+ _heapinfo[block].busy.info.size = blocks;
+ ++_chunks_used;
+ _bytes_used += blocks * BLOCKSIZE;
+ return result;
}
}
_heapinfo[block + blocks].free.next = _heapinfo[block].free.next;
_heapinfo[block + blocks].free.prev = _heapinfo[block].free.prev;
_heapinfo[_heapinfo[block].free.prev].free.next
- = _heapinfo[_heapinfo[block].free.next].free.prev
- = _heapindex = block + blocks;
+ = _heapinfo[_heapinfo[block].free.next].free.prev
+ = _heapindex = block + blocks;
} else {
/* The block exactly matches our requirements,
so just remove it from the list. */
_heapinfo[_heapinfo[block].free.next].free.prev
- = _heapinfo[block].free.prev;
+ = _heapinfo[block].free.prev;
_heapinfo[_heapinfo[block].free.prev].free.next
- = _heapindex = _heapinfo[block].free.next;
+ = _heapindex = _heapinfo[block].free.next;
--_chunks_free;
}
i = _heapindex;
if (i > block)
while (i > block)
- i = _heapinfo[i].free.prev;
+ i = _heapinfo[i].free.prev;
else {
do
- i = _heapinfo[i].free.next;
+ i = _heapinfo[i].free.next;
while (i > 0 && i < block);
i = _heapinfo[i].free.prev;
}
and adding in its size). */
if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) {
_heapinfo[block].free.size
- += _heapinfo[_heapinfo[block].free.next].free.size;
+ += _heapinfo[_heapinfo[block].free.next].free.size;
_heapinfo[block].free.next
- = _heapinfo[_heapinfo[block].free.next].free.next;
+ = _heapinfo[_heapinfo[block].free.next].free.next;
_heapinfo[_heapinfo[block].free.next].free.prev = block;
--_chunks_free;
}
/* Now see if we can return stuff to the system. */
blocks = _heapinfo[block].free.size;
if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit
- && (*__morecore) (0) == ADDRESS(block + blocks)) {
+ && (*__morecore) (0) == ADDRESS(block + blocks)) {
register __malloc_size_t bytes = blocks * BLOCKSIZE;
_heaplimit -= blocks;
(*__morecore) (-bytes);
_heapinfo[_heapinfo[block].free.prev].free.next
- = _heapinfo[block].free.next;
+ = _heapinfo[block].free.next;
_heapinfo[_heapinfo[block].free.next].free.prev
- = _heapinfo[block].free.prev;
+ = _heapinfo[block].free.prev;
block = _heapinfo[block].free.prev;
--_chunks_free;
_bytes_free -= bytes;
/* Get the address of the first free fragment in this block. */
prev = (struct list *) ((char *) ADDRESS(block) +
- (_heapinfo[block].busy.info.frag.first << type));
+ (_heapinfo[block].busy.info.frag.first << type));
if (_heapinfo[block].busy.info.frag.nfree ==
- (__malloc_size_t) (BLOCKSIZE >> type) - 1) {
+ (__malloc_size_t) (BLOCKSIZE >> type) - 1) {
/* If all fragments of this block are free, remove them
from the fragment list and free the whole block. */
next = prev;
for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> type); ++i)
- next = next->next;
+ next = next->next;
prev->prev->next = next;
if (next != NULL)
- next->prev = prev->prev;
+ next->prev = prev->prev;
_heapinfo[block].busy.type = 0;
_heapinfo[block].busy.info.size = 1;
next->prev = prev;
prev->next = next;
if (next->next != NULL)
- next->next->prev = next;
+ next->next->prev = next;
++_heapinfo[block].busy.info.frag.nfree;
} else {
/* No fragments of this block are free, so link this
prev = (struct list *) ptr;
_heapinfo[block].busy.info.frag.nfree = 1;
_heapinfo[block].busy.info.frag.first = (unsigned long int)
- ((unsigned long int) ((char *) ptr - (char *) NULL)
- % BLOCKSIZE >> type);
+ ((unsigned long int) ((char *) ptr - (char *) NULL)
+ % BLOCKSIZE >> type);
prev->next = _fraghead[type].next;
prev->prev = &_fraghead[type];
prev->prev->next = prev;
if (prev->next != NULL)
- prev->next->prev = prev;
+ prev->next->prev = prev;
}
break;
}
for (l = _aligned_blocks; l != NULL; l = l->next)
if (l->aligned == ptr) {
- l->aligned = NULL; /* Mark the slot in the list as free. */
+ l->aligned = NULL; /* Mark the slot in the list as free. */
ptr = l->exact;
break;
}
bad, I'm trying to err in its favor. */
if (to - from < 64) {
do
- *--endt = *--endf;
+ *--endt = *--endf;
while (endf != from);
} else {
for (;;) {
- endt -= (to - from);
- endf -= (to - from);
+ endt -= (to - from);
+ endf -= (to - from);
- if (endt < to)
- break;
+ if (endt < to)
+ break;
- bcopy(endf, endt, to - from);
+ bcopy(endf, endt, to - from);
}
/* If SIZE wasn't a multiple of TO - FROM, there will be a
}
}
}
-#endif /* Not emacs. */
+#endif /* Not emacs. */
#define memmove(to, from, size) safe_bcopy ((from), (to), (size))
if (size <= BLOCKSIZE / 2) {
result = malloc(size);
if (result != NULL) {
- memcpy(result, ptr, size);
- _free_internal(ptr);
- return result;
+ memcpy(result, ptr, size);
+ _free_internal(ptr);
+ return result;
}
}
/* The new size is a large allocation as well;
excess memory to the free list. */
_heapinfo[block + blocks].busy.type = 0;
_heapinfo[block + blocks].busy.info.size
- = _heapinfo[block].busy.info.size - blocks;
+ = _heapinfo[block].busy.info.size - blocks;
_heapinfo[block].busy.info.size = blocks;
/* We have just created a new chunk by splitting a chunk in two.
Now we will free this chunk; increment the statistics counter
_heaplimit = oldlimit;
result = malloc(size);
if (result == NULL) {
- /* Now we're really in trouble. We have to unfree
- the thing we just freed. Unfortunately it might
- have been coalesced with its neighbors. */
- if (_heapindex == block)
- (void) malloc(blocks * BLOCKSIZE);
- else {
- __ptr_t previous = malloc((block - _heapindex) * BLOCKSIZE);
- (void) malloc(blocks * BLOCKSIZE);
- _free_internal(previous);
- }
- return NULL;
+ /* Now we're really in trouble. We have to unfree
+ the thing we just freed. Unfortunately it might
+ have been coalesced with its neighbors. */
+ if (_heapindex == block)
+ (void) malloc(blocks * BLOCKSIZE);
+ else {
+ __ptr_t previous = malloc((block - _heapindex) * BLOCKSIZE);
+ (void) malloc(blocks * BLOCKSIZE);
+ _free_internal(previous);
+ }
+ return NULL;
}
if (ptr != result)
- memmove(result, ptr, blocks * BLOCKSIZE);
+ memmove(result, ptr, blocks * BLOCKSIZE);
}
break;
/* Old size is a fragment; type is logarithm
to base two of the fragment size. */
if (size > (__malloc_size_t) (1 << (type - 1)) &&
- size <= (__malloc_size_t) (1 << type))
+ size <= (__malloc_size_t) (1 << type))
/* The new size is the same kind of fragment. */
result = ptr;
else {
and copy the lesser of the new size and the old. */
result = malloc(size);
if (result == NULL)
- return NULL;
+ return NULL;
memcpy(result, ptr, min(size, (__malloc_size_t) 1 << type));
free(ptr);
}
if (result == NULL)
return NULL;
adj = (unsigned long int) ((unsigned long int) ((char *) result -
- (char *) NULL)) % alignment;
+ (char *) NULL)) % alignment;
if (adj != 0) {
struct alignlist *l;
for (l = _aligned_blocks; l != NULL; l = l->next)
if (l->aligned == NULL)
- /* This slot is free. Use it. */
- break;
+ /* This slot is free. Use it. */
+ break;
if (l == NULL) {
l = (struct alignlist *) malloc(sizeof(struct alignlist));
if (l == NULL) {
- free(result);
- return NULL;
+ free(result);
+ return NULL;
}
l->next = _aligned_blocks;
_aligned_blocks = l;
static const char *string_spitfile(help_file *help_dat, char *arg1);
static help_indx *help_find_entry(help_file *help_dat, const char *the_topic);
static char *list_matching_entries(char *pattern, help_file *help_dat,
- const char *sep);
+ const char *sep);
static const char *normalize_entry(help_file *help_dat, char *arg1);
static void help_build_index(help_file *h, int restricted);
/** Linked list of help topic names. */
typedef struct TLIST {
- char topic[TOPIC_NAME_LEN + 1]; /**< Name of topic */
- struct TLIST *next; /**< Pointer to next list entry */
+ char topic[TOPIC_NAME_LEN + 1]; /**< Name of topic */
+ struct TLIST *next; /**< Pointer to next list entry */
} tlist;
tlist *top = NULL; /**< Pointer to top of linked list of topic names */
static void write_topic(long int p);
-#define TRUE 1 /**< A true value */
-#define FALSE 0 /**< A false value */
+#define TRUE 1 /**< A true value */
+#define FALSE 0 /**< A false value */
COMMAND (cmd_helpcmd) {
help_file *h;
if (wildcard(arg_left))
notify_format(player, T("Here are the entries which match '%s':\n%s"),
- arg_left, list_matching_entries(arg_left, h, ", "));
+ arg_left, list_matching_entries(arg_left, h, ", "));
else
do_new_spitfile(player, arg_left, h);
}
if (player != NOTHING) {
notify(player, T("Help files reindexed."));
do_rawlog(LT_WIZ, T("Help files reindexed by %s(#%d)"), Name(player),
- player);
+ player);
} else
do_rawlog(LT_WIZ, T("Help files reindexed."));
}
if ((fp = fopen(help_dat->file, FOPEN_READ)) == NULL) {
notify(player, T("Sorry, that function is temporarily unavailable."));
do_log(LT_ERR, 0, 0, T("Can't open text file %s for reading"),
- help_dat->file);
+ help_dat->file);
return;
}
if (fseek(fp, entry->pos, 0) < 0L) {
notify(player, " ");
} else {
for (p = line; *p != '\0'; p++)
- if (*p == '\n')
- *p = '\0';
+ if (*p == '\n')
+ *p = '\0';
notify(player, line);
}
}
size_t n;
help_indx *entry = NULL;
- if (help_dat->entries < 10) { /* Just do a linear search for small files */
+ if (help_dat->entries < 10) { /* Just do a linear search for small files */
for (n = 0; n < help_dat->entries; n++) {
if (string_prefix(help_dat->indx[n].topic, the_topic)) {
- entry = &help_dat->indx[n];
- break;
+ entry = &help_dat->indx[n];
+ break;
}
}
- } else { /* Binary search of the index */
+ } else { /* Binary search of the index */
int left = 0;
int cmp;
int right = help_dat->entries - 1;
n = (left + right) / 2;
if (left > right)
- break;
+ break;
cmp = strcasecmp(the_topic, help_dat->indx[n].topic);
if (cmp == 0) {
- entry = &help_dat->indx[n];
- break;
+ entry = &help_dat->indx[n];
+ break;
} else if (cmp < 0) {
- /* We need to catch the first prefix */
- if (string_prefix(help_dat->indx[n].topic, the_topic)) {
- int m;
- for (m = n - 1; m >= 0; m--) {
- if (!string_prefix(help_dat->indx[m].topic, the_topic))
- break;
- }
- entry = &help_dat->indx[m + 1];
- break;
- }
- if (left == right)
- break;
- right = n - 1;
- } else { /* cmp > 0 */
- if (left == right)
- break;
- left = n + 1;
+ /* We need to catch the first prefix */
+ if (string_prefix(help_dat->indx[n].topic, the_topic)) {
+ int m;
+ for (m = n - 1; m >= 0; m--) {
+ if (!string_prefix(help_dat->indx[m].topic, the_topic))
+ break;
+ }
+ entry = &help_dat->indx[m + 1];
+ break;
+ }
+ if (left == right)
+ break;
+ right = n - 1;
+ } else { /* cmp > 0 */
+ if (left == right)
+ break;
+ left = n + 1;
}
}
}
if (num_topics >= top_topics) {
top_topics += top_topics / 2 + 20;
if (topics)
- topics = (help_indx *) realloc(topics, top_topics * sizeof(help_indx));
+ topics = (help_indx *) realloc(topics, top_topics * sizeof(help_indx));
else
- topics = (help_indx *) malloc(top_topics * sizeof(help_indx));
+ topics = (help_indx *) malloc(top_topics * sizeof(help_indx));
if (!topics) {
- mush_panic(T("Out of memory"));
+ mush_panic(T("Out of memory"));
}
}
temp = &topics[num_topics++];
if (ntopics == 0) {
/* Looking for the first topic, but we'll ignore blank lines */
if (!line[0]) {
- /* Someone's feeding us /dev/null? */
- do_rawlog(LT_ERR, T("Malformed help file %s doesn't start with &"),
- h->file);
- fclose(rfp);
- return;
+ /* Someone's feeding us /dev/null? */
+ do_rawlog(LT_ERR, T("Malformed help file %s doesn't start with &"),
+ h->file);
+ fclose(rfp);
+ return;
}
if (isspace((unsigned char) line[0]))
- continue;
+ continue;
if (line[0] != '&') {
- do_rawlog(LT_ERR, T("Malformed help file %s doesn't start with &"),
- h->file);
- fclose(rfp);
- return;
+ do_rawlog(LT_ERR, T("Malformed help file %s doesn't start with &"),
+ h->file);
+ fclose(rfp);
+ return;
}
}
n = strlen(line);
if (line[0] == '&') {
++ntopics;
if (!in_topic) {
- /* Finish up last entry */
- if (ntopics > 1) {
- write_topic(pos);
- }
- in_topic = TRUE;
+ /* Finish up last entry */
+ if (ntopics > 1) {
+ write_topic(pos);
+ }
+ in_topic = TRUE;
}
/* parse out the topic */
/* Get the beginning of the topic string */
for (topic = &line[1];
- (*topic == ' ' || *topic == '\t') && *topic != '\0'; topic++) ;
+ (*topic == ' ' || *topic == '\t') && *topic != '\0'; topic++) ;
/* Get the topic */
strcpy(the_topic, "");
for (i = -1, s = topic; *s != '\n' && *s != '\0'; s++) {
- if (i >= TOPIC_NAME_LEN - 1)
- break;
- if (*s != ' ' || the_topic[i] != ' ')
- the_topic[++i] = *s;
+ if (i >= TOPIC_NAME_LEN - 1)
+ break;
+ if (*s != ' ' || the_topic[i] != ' ')
+ the_topic[++i] = *s;
}
if ((restricted && the_topic[0] == '&')
- || (!restricted && the_topic[0] != '&')) {
- the_topic[++i] = '\0';
- cur = (tlist *) malloc(sizeof(tlist));
- strcpy(cur->topic, the_topic);
- cur->next = top;
- top = cur;
+ || (!restricted && the_topic[0] != '&')) {
+ the_topic[++i] = '\0';
+ cur = (tlist *) malloc(sizeof(tlist));
+ strcpy(cur->topic, the_topic);
+ cur->next = top;
+ top = cur;
}
} else {
if (in_topic) {
- pos = bigpos;
+ pos = bigpos;
}
in_topic = FALSE;
}
bp = buff;
if (help_dat->admin)
- offset = 1; /* To skip the leading & */
+ offset = 1; /* To skip the leading & */
else
offset = 0;
if (quick_wild(pattern, help_dat->indx[n].topic + offset)) {
safe_str(help_dat->indx[n].topic + offset, buff, &bp);
if (sep)
- safe_strl(sep, len, buff, &bp);
+ safe_strl(sep, len, buff, &bp);
}
if (bp > buff)
/* This hash function adapted from http://burtleburtle.net/bob/hash/evahash.html */
-typedef unsigned long int u4; /**< unsigned 4-byte type */
-typedef unsigned char u1; /**< unsigned 1-byte type */
+typedef unsigned long int u4; /**< unsigned 4-byte type */
+typedef unsigned char u1; /**< unsigned 1-byte type */
/* The mixing step */
#define mix(a,b,c) \
static int
hash_val(register const char *k, int mask)
{
- register u4 a, b, c; /* the internal state */
- u4 len, length; /* how many key bytes still need mixing */
- static u4 initval = 5432; /* the previous hash, or an arbitrary value */
+ register u4 a, b, c; /* the internal state */
+ u4 len, length; /* how many key bytes still need mixing */
+ static u4 initval = 5432; /* the previous hash, or an arbitrary value */
/* Set up the internal state */
length = len = strlen(k);
- a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
- c = initval; /* variable initialization of internal state */
+ a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
+ c = initval; /* variable initialization of internal state */
/*---------------------------------------- handle most of the key */
while (len >= 12) {
/*------------------------------------- handle the last 11 bytes */
c = c + length;
- switch (len) { /* all the case statements fall through */
+ switch (len) { /* all the case statements fall through */
case 11:
c = c + ((u4) k[10] << 24);
case 10:
}
-#else /* NEW_HASH_FUN */
+#else /* NEW_HASH_FUN */
/** Compute a hash value for mask-style hashing.
* Given a null key, return 0. Otherwise, add up the numeric value
* of all the characters and return the sum modulo the size of the
hash = (hash << 5) + hash + *sp;
return (hash & hashmask);
}
-#endif /* NEW_HASH_FUN */
+#endif /* NEW_HASH_FUN */
/* ----------------------------------------------------------------------
* hash_getmask: Get hash mask for mask-style hashing.
nent = hent->next;
hval = hash_val(hent->key, mask);
for (curr = newarr[hval], old = NULL; curr; old = curr, curr = curr->next) {
- if (strcmp(curr->key, hent->key) > 0)
- break;
+ if (strcmp(curr->key, hent->key) > 0)
+ break;
}
if (old) {
- old->next = hent;
- hent->next = curr;
+ old->next = hent;
+ hent->next = curr;
} else {
- hent->next = newarr[hval];
- newarr[hval] = hent;
+ hent->next = newarr[hval];
+ newarr[hval] = hent;
}
hent = nent;
}
for (curr = old->next; curr; old = curr, curr = curr->next) {
/* Comparison will never be 0 because hash_add checks to see
if the entry is already present. */
- if (strcmp(key, curr->key) < 0) { /* Insert before curr */
+ if (strcmp(key, curr->key) < 0) { /* Insert before curr */
old->next = hptr;
hptr->next = curr;
return hptr;
*/
int
hash_add(HASHTAB *htab, const char *key, void *hashdata,
- int extra_size __attribute__ ((__unused__)))
+ int extra_size __attribute__ ((__unused__)))
{
HASHENT *hptr;
for (hptr = htab->buckets[hval]; hptr; last = hptr, hptr = hptr->next) {
if (entry == hptr) {
if (last == NULL)
- htab->buckets[hval] = hptr->next;
+ htab->buckets[hval] = hptr->next;
else
- last->next = hptr->next;
+ last->next = hptr->next;
mush_free(hptr, "hash_entry");
htab->entries--;
return;
for (i = 0; i < htab->hashsize; i++) {
hent = htab->buckets[i];
while (hent != NULL) {
- thent = hent;
- hent = hent->next;
- mush_free(thent, "hash_entry");
+ thent = hent;
+ hent = hent->next;
+ mush_free(thent, "hash_entry");
}
htab->buckets[i] = NULL;
}
hash_stats_header(dbref player)
{
notify_format(player,
- "Table Buckets Entries LChain ECh 1Ch 2Ch 3Ch 4+Ch AvgCh ~Memory");
+ "Table Buckets Entries LChain ECh 1Ch 2Ch 3Ch 4+Ch AvgCh ~Memory");
}
/** Display stats on a hashtable.
int chain = 0;
HASHENT *b;
if (htab->buckets[n]) {
- for (b = htab->buckets[n]; b; b = b->next) {
- chain++;
- bytes += strlen(b->key) + 1 /* + b->extra_size */ ;
- }
- if (chain > longest)
- longest = chain;
+ for (b = htab->buckets[n]; b; b = b->next) {
+ chain++;
+ bytes += strlen(b->key) + 1 /* + b->extra_size */ ;
+ }
+ if (chain > longest)
+ longest = chain;
}
lengths[(chain > 4) ? 4 : chain]++;
chainlens += chain;
totchains += lengths[n];
notify_format(player,
- "%-10s %7d %7d %6d %4d %4d %4d %4d %4d %6.3f %7u", hname,
- htab->hashsize, htab->entries, longest, lengths[0], lengths[1],
- lengths[2], lengths[3], lengths[4],
- totchains > 0 ? chainlens / totchains : 0.0, bytes);
+ "%-10s %7d %7d %6d %4d %4d %4d %4d %4d %6.3f %7u", hname,
+ htab->hashsize, htab->entries, longest, lengths[0], lengths[1],
+ lengths[2], lengths[3], lengths[4],
+ totchains > 0 ? chainlens / totchains : 0.0, bytes);
}
#include <arpa/inet.h>
#endif
#include <netdb.h>
-#endif /* WIN32 */
+#endif /* WIN32 */
#ifdef I_UNISTD
#include <unistd.h>
/** Structure to track an ident connection. */
typedef struct {
- int fd; /**< file descriptor to read from. */
- char buf[IDBUFSIZE]; /**< buffer to hold ident data. */
+ int fd; /**< file descriptor to read from. */
+ char buf[IDBUFSIZE]; /**< buffer to hold ident data. */
} ident_t;
static ident_t *id_open(struct sockaddr *faddr,
- socklen_t flen,
- struct sockaddr *laddr, socklen_t llen, int *timeout);
+ socklen_t flen,
+ struct sockaddr *laddr, socklen_t llen, int *timeout);
static int id_query(ident_t * id,
- struct sockaddr *laddr,
- socklen_t llen,
- struct sockaddr *faddr, socklen_t flen, int *timeout);
+ struct sockaddr *laddr,
+ socklen_t llen,
+ struct sockaddr *faddr, socklen_t flen, int *timeout);
static int id_close(ident_t * id);
*/
IDENT *
ident_query(struct sockaddr *laddr, socklen_t llen,
- struct sockaddr *raddr, socklen_t rlen, int *timeout)
+ struct sockaddr *raddr, socklen_t rlen, int *timeout)
{
int res;
ident_t *id;
}
id_close(id);
- return ident; /* At last! */
+ return ident; /* At last! */
}
/** Perform an ident lookup and return the remote identifier as a
static ident_t *
id_open(struct sockaddr *faddr, socklen_t flen,
- struct sockaddr *laddr, socklen_t llen, int *timeout)
+ struct sockaddr *laddr, socklen_t llen, int *timeout)
{
ident_t *id;
char host[NI_MAXHOST];
memset(id, 0, sizeof(ident_t));
if (getnameinfo(faddr, flen, host, sizeof(host), NULL, 0,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
free(id);
return 0;
}
memcpy(&myinterface, laddr, llen);
if (myinterface.addr.sa_family == AF_INET)
((struct sockaddr_in *) &myinterface.addr)->sin_port = 0;
-#ifdef HAS_IPV6 /* Bleah, I wanted to avoid stuff like this */
+#ifdef HAS_IPV6 /* Bleah, I wanted to avoid stuff like this */
else if (myinterface.addr.sa_family == AF_INET6)
((struct sockaddr_in6 *) &myinterface.addr)->sin6_port = 0;
#endif
id->fd = make_socket_conn(host, &myinterface.addr, llen, IDPORT, timeout);
- if (id->fd < 0) /* Couldn't connect to an ident server */
+ if (id->fd < 0) /* Couldn't connect to an ident server */
goto ERROR_BRANCH;
if (timeout) {
ERROR_BRANCH:
#ifndef WIN32
- tmperrno = errno; /* Save, so close() won't erase it */
+ tmperrno = errno; /* Save, so close() won't erase it */
#endif
closesocket(id->fd);
free(id);
static int
id_query(ident_t * id, struct sockaddr *laddr, socklen_t llen,
- struct sockaddr *faddr, socklen_t flen, int *timeout)
+ struct sockaddr *faddr, socklen_t flen, int *timeout)
{
int res;
char buf[80];
struct timeval to;
getnameinfo(laddr, llen, NULL, 0, port, sizeof(port),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ NI_NUMERICHOST | NI_NUMERICSERV);
sprintf(buf, "%s , ", port);
getnameinfo(faddr, flen, NULL, 0, port, sizeof(port),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ NI_NUMERICHOST | NI_NUMERICSERV);
strncat(buf, port, sizeof(buf));
strncat(buf, "\r\n", sizeof(buf));
}
}
while (pos < sizeof(id->buf) &&
- (res = recv(id->fd, id->buf + pos, 1, 0)) == 1 && id->buf[pos] != '\n')
+ (res = recv(id->fd, id->buf + pos, 1, 0)) == 1 && id->buf[pos] != '\n')
pos++;
if (res < 0)
return -1;
if (c == ',') {
cp = xstrtok(NULL, ":", &c);
if (!cp)
- return -2;
+ return -2;
tmp_charset = cp;
/* We have even more subfields - ignore them */
if (c == ',')
- xstrtok(NULL, ":", &c);
+ xstrtok(NULL, ":", &c);
}
if (tmp_charset && strcmp(tmp_charset, "OCTET") == 0)
cp = xstrtok(NULL, NULL, &c);
int port;
int fd;
union sockaddr_u local, remote;
- static char buf[BUFFER_LEN]; /* overkill */
+ static char buf[BUFFER_LEN]; /* overkill */
char *bp;
int len, size;
IDENT *ident_result;
use_dns = 1;
#ifdef HAS_SOCKETPAIR
- mush = port; /* We inherit open file descriptions and sockets from parent */
+ mush = port; /* We inherit open file descriptions and sockets from parent */
#else
mush = make_socket_conn("127.0.0.1", NULL, 0, port, NULL);
- if (mush == -1) { /* Couldn't connect */
+ if (mush == -1) { /* Couldn't connect */
fprintf(stderr, "Couldn't connect to mush!\n");
return EXIT_FAILURE;
}
bp = buf;
if (getnameinfo(&remote.addr, rlen, host, sizeof host, NULL, 0,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0)
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0)
safe_str("An error occured", buf, &bp);
else
safe_str(host, buf, &bp);
safe_chr('^', buf, &bp);
if (getnameinfo(&local.addr, llen, NULL, 0, lport, sizeof lport,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0)
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0)
safe_str("An error occured", buf, &bp);
else
safe_str(lport, buf, &bp);
if (use_ident > 0) {
timeout = use_ident;
ident_result =
- ident_query(&local.addr, llen, &remote.addr, rlen, &timeout);
+ ident_query(&local.addr, llen, &remote.addr, rlen, &timeout);
if (ident_result && ident_result->identifier) {
- safe_str(ident_result->identifier, buf, &bp);
- safe_chr('@', buf, &bp);
+ safe_str(ident_result->identifier, buf, &bp);
+ safe_chr('@', buf, &bp);
}
if (ident_result)
- ident_free(ident_result);
+ ident_free(ident_result);
}
if (use_dns) {
if (getnameinfo(&remote.addr, rlen, host, sizeof host, NULL, 0,
- NI_NUMERICSERV) != 0) {
- safe_str("An error occured", buf, &bp);
+ NI_NUMERICSERV) != 0) {
+ safe_str("An error occured", buf, &bp);
} else {
- safe_str(host, buf, &bp);
+ safe_str(host, buf, &bp);
}
} else
safe_str(host, buf, &bp);
* but just config_string for strings.
*/
add_config("use_example", cf_bool, &config_example, sizeof config_example,
- "cosmetic");
+ "cosmetic");
add_config("some_string", cf_str, config_string, sizeof config_string,
- "cosmetic");
+ "cosmetic");
#endif
}
*/
void
local_connect(dbref player __attribute__ ((__unused__)),
- int isnew __attribute__ ((__unused__)),
- int num __attribute__ ((__unused__)))
+ int isnew __attribute__ ((__unused__)),
+ int num __attribute__ ((__unused__)))
{
}
*/
void
local_disconnect(dbref player __attribute__ ((__unused__)),
- int num __attribute__ ((__unused__)))
+ int num __attribute__ ((__unused__)))
{
}
void
local_data_clone(dbref clone __attribute__ ((__unused__)),
- dbref source __attribute__ ((__unused__)))
+ dbref source __attribute__ ((__unused__)))
{
}
*/
int
local_can_interact_first(dbref from __attribute__ ((__unused__)),
- dbref to __attribute__ ((__unused__)), int type
- __attribute__ ((__unused__)))
+ dbref to __attribute__ ((__unused__)), int type
+ __attribute__ ((__unused__)))
{
return NOTHING;
/* This one is called *after* most standard interaction checks. */
int
local_can_interact_last(dbref from __attribute__ ((__unused__)),
- dbref to __attribute__ ((__unused__)), int type
- __attribute__ ((__unused__)))
+ dbref to __attribute__ ((__unused__)), int type
+ __attribute__ ((__unused__)))
{
/* from is where the message is coming from, in theory. It makes sense
* for sound, but think of it as light rays for visiblity or matching.
/* Splits the universe in half, half FOO and half not. */
return (has_flag_by_name(to, "FOO", NOTYPE) ==
- has_flag_by_name(from, "FOO", NOTYPE));
+ has_flag_by_name(from, "FOO", NOTYPE));
-#endif /* NEVER */
+#endif /* NEVER */
/* You want to return NOTHING if you haven't made up your mind */
return NOTHING;
/* If any lock_type ever contains the character '|', reading in locks
* from the db will break.
*/
-const lock_type Basic_Lock = "Basic"; /**< Name of basic lock */
-const lock_type Enter_Lock = "Enter"; /**< Name of enter lock */
-const lock_type Use_Lock = "Use"; /**< Name of use lock */
-const lock_type Zone_Lock = "Zone"; /**< Name of zone lock */
-const lock_type Page_Lock = "Page"; /**< Name of page lock */
+const lock_type Basic_Lock = "Basic"; /**< Name of basic lock */
+const lock_type Enter_Lock = "Enter"; /**< Name of enter lock */
+const lock_type Use_Lock = "Use"; /**< Name of use lock */
+const lock_type Zone_Lock = "Zone"; /**< Name of zone lock */
+const lock_type Page_Lock = "Page"; /**< Name of page lock */
const lock_type Tport_Lock = "Teleport"; /**< Name of teleport lock */
-const lock_type Speech_Lock = "Speech"; /**< Name of speech lock */
-const lock_type Listen_Lock = "Listen"; /**< Name of listen lock */
+const lock_type Speech_Lock = "Speech"; /**< Name of speech lock */
+const lock_type Listen_Lock = "Listen"; /**< Name of listen lock */
const lock_type Command_Lock = "Command"; /**< Name of command lock */
-const lock_type Parent_Lock = "Parent"; /**< Name of parent lock */
-const lock_type Link_Lock = "Link"; /**< Name of link lock */
-const lock_type Leave_Lock = "Leave"; /**< Name of leave lock */
-const lock_type Drop_Lock = "Drop"; /**< Name of drop lock */
-const lock_type Give_Lock = "Give"; /**< Name of give lock */
-const lock_type Mail_Lock = "Mail"; /**< Name of mail lock */
-const lock_type Follow_Lock = "Follow"; /**< Name of follow lock */
+const lock_type Parent_Lock = "Parent"; /**< Name of parent lock */
+const lock_type Link_Lock = "Link"; /**< Name of link lock */
+const lock_type Leave_Lock = "Leave"; /**< Name of leave lock */
+const lock_type Drop_Lock = "Drop"; /**< Name of drop lock */
+const lock_type Give_Lock = "Give"; /**< Name of give lock */
+const lock_type Mail_Lock = "Mail"; /**< Name of mail lock */
+const lock_type Follow_Lock = "Follow"; /**< Name of follow lock */
const lock_type Examine_Lock = "Examine"; /**< Name of examine lock */
-const lock_type Chzone_Lock = "Chzone"; /**< Name of chzone lock */
+const lock_type Chzone_Lock = "Chzone"; /**< Name of chzone lock */
const lock_type Forward_Lock = "Forward"; /**< Name of forward lock */
const lock_type Control_Lock = "Control"; /**< Name of control lock */
-const lock_type Dropto_Lock = "Dropto"; /**< Name of dropto lock */
+const lock_type Dropto_Lock = "Dropto"; /**< Name of dropto lock */
const lock_type Destroy_Lock = "Destroy"; /**< Name of destroy lock */
const lock_type Interact_Lock = "Interact"; /**< Name of interaction lock */
const lock_type Take_Lock = "Take"; /**< Name of take lock */
if (God(thing))
return 0;
if ((L_FLAGS(lock) & LF_PRIVILEGE)
- && !Prived(player))
+ && !Prived(player))
return 0;
if (L_FLAGS(lock) & LF_OWNER)
return player == Owner(thing);
do {
for (; GoodObject(p); p = Parent(p)) {
if (count++ > 100)
- return NULL;
+ return NULL;
if (p == ancestor)
- ancestor_in_chain = 1;
+ ancestor_in_chain = 1;
ll = Locks(p);
while (ll && L_TYPE(ll)) {
- cmp = strcasecmp(L_TYPE(ll), type);
- if (cmp == 0)
- return (p != thing && (ll->flags & LF_PRIVATE)) ? NULL : ll;
- else if (cmp > 0)
- break;
- ll = ll->next;
+ cmp = strcasecmp(L_TYPE(ll), type);
+ if (cmp == 0)
+ return (p != thing && (ll->flags & LF_PRIVATE)) ? NULL : ll;
+ else if (cmp > 0)
+ break;
+ ll = ll->next;
}
}
p = ancestor;
ll->key = key;
ll->creator = player;
if (flags == -1) {
- const lock_list *l2 = get_lockproto(real_type);
- if (l2)
- ll->flags = l2->flags;
- else
- ll->flags = 0;
+ const lock_list *l2 = get_lockproto(real_type);
+ if (l2)
+ ll->flags = l2->flags;
+ else
+ ll->flags = 0;
} else {
- ll->flags = flags;
+ ll->flags = flags;
}
if (!can_write_lock(player, thing, ll)) {
- st_delete(real_type, &lock_names);
- free_boolexp(key);
- return 0;
+ st_delete(real_type, &lock_names);
+ free_boolexp(key);
+ return 0;
}
t = &Locks(thing);
while (*t && strcasecmp(L_TYPE(*t), L_TYPE(ll)) < 0)
if (flags == -1) {
const lock_list *l2 = get_lockproto(real_type);
if (l2)
- ll->flags = l2->flags;
+ ll->flags = l2->flags;
else
- ll->flags = 0;
+ ll->flags = 0;
} else {
ll->flags = flags;
}
if ((thing = match_controlled(player, name)) != NOTHING) {
if ((real_type = check_lock_type(player, thing, type)) != NULL) {
if (getlock(thing, real_type) == TRUE_BOOLEXP) {
- if (!AreQuiet(player, thing))
- notify_format(player, T("%s(%s) - %s (already) unlocked."),
- Name(thing), unparse_dbref(thing), real_type);
+ if (!AreQuiet(player, thing))
+ notify_format(player, T("%s(%s) - %s (already) unlocked."),
+ Name(thing), unparse_dbref(thing), real_type);
} else if (delete_lock(player, thing, real_type)) {
- if (!AreQuiet(player, thing))
- notify_format(player, T("%s(%s) - %s unlocked."), Name(thing),
- unparse_dbref(thing), real_type);
- if (!IsPlayer(thing)) {
+ if (!AreQuiet(player, thing))
+ notify_format(player, T("%s(%s) - %s unlocked."), Name(thing),
+ unparse_dbref(thing), real_type);
+ if (!IsPlayer(thing)) {
char lmbuf[1024];
ModTime(thing) = mudtime;
snprintf(lmbuf, 1023, "%s lock[#%d]", real_type, player);
lmbuf[strlen(lmbuf)+1] = '\0';
set_lmod(thing, lmbuf);
- }
+ }
} else
- notify(player, T("Permission denied."));
+ notify(player, T("Permission denied."));
}
}
}
if ((real_type = check_lock_type(player, thing, type)) != NULL) {
/* everything ok, do it */
if (add_lock(player, thing, real_type, key, -1)) {
- if (!AreQuiet(player, thing))
- notify_format(player, T("%s(%s) - %s locked."), Name(thing),
- unparse_dbref(thing), real_type);
- if (!IsPlayer(thing)) {
+ if (!AreQuiet(player, thing))
+ notify_format(player, T("%s(%s) - %s locked."), Name(thing),
+ unparse_dbref(thing), real_type);
+ if (!IsPlayer(thing)) {
char lmbuf[1024];
ModTime(thing) = mudtime;
snprintf(lmbuf, 1023, "%s lock[#%d]", real_type, player);
lmbuf[strlen(lmbuf)+1] = '\0';
set_lmod(thing, lmbuf);
- }
+ }
} else {
- notify(player, T("Permission denied."));
- free_boolexp(key);
+ notify(player, T("Permission denied."));
+ free_boolexp(key);
}
} else
free_boolexp(key);
*/
int
fail_lock(dbref player, dbref thing, lock_type ltype, const char *def,
- dbref loc)
+ dbref loc)
{
const LOCKMSGINFO *lm;
char atr[BUFFER_LEN];
if (!Quiet(player) && !(Quiet(thing) && (Owner(thing) == player)))
notify_format(player, "%s/%s - %s.", Name(thing), L_TYPE(l),
- unset ? T("lock flags unset") : T("lock flags set"));
+ unset ? T("lock flags unset") : T("lock flags set"));
if (!IsPlayer(thing)) {
char lmbuf[1024];
ModTime(thing) = mudtime;
add_lock(GOD, zone, Zone_Lock, parse_boolexp(zone, "=me", Zone_Lock), -1);
if (noisy)
notify_format(player,
- T
- ("Unlocked zone %s - automatically zone-locking to itself"),
- unparse_object(player, zone));
+ T
+ ("Unlocked zone %s - automatically zone-locking to itself"),
+ unparse_object(player, zone));
} else if (eval_lock(Location(player), zone, Zone_Lock)) {
/* Does #0 and #2 pass it? If so, probably trivial elock */
if (eval_lock(PLAYER_START, zone, Zone_Lock) &&
- eval_lock(MASTER_ROOM, zone, Zone_Lock)) {
+ eval_lock(MASTER_ROOM, zone, Zone_Lock)) {
if (noisy)
- notify_format(player,
- T("Zone %s really should have a more secure zone-lock."),
- unparse_object(player, zone));
- } else /* Probably inexact zone lock */
+ notify_format(player,
+ T("Zone %s really should have a more secure zone-lock."),
+ unparse_object(player, zone));
+ } else /* Probably inexact zone lock */
notify_format(player,
- T
- ("Warning: Zone %s may have loose zone lock. Lock zones to =player, not player"),
- unparse_object(player, zone));
+ T
+ ("Warning: Zone %s may have loose zone lock. Lock zones to =player, not player"),
+ unparse_object(player, zone));
}
}
BUFFERQ *activity_bq = NULL;
-HASHTAB htab_logfiles; /**< Hash table of logfile names and descriptors */
+HASHTAB htab_logfiles; /**< Hash table of logfile names and descriptors */
/* log file pointers */
FILE *connlog_fp; /**< Connect log */
default:
bp = buff;
safe_format(buff, &bp, "%s(#%d%s)",
- Name(object), object, unparse_flags(object, GOD));
+ Name(object), object, unparse_flags(object, GOD));
*bp = '\0';
}
*fp = fopen(newfilename, "a");
if (*fp == NULL) {
- fprintf(stderr, T("WARNING: cannot open log %s\n"), newfilename);
- *fp = stderr;
+ fprintf(stderr, T("WARNING: cannot open log %s\n"), newfilename);
+ *fp = stderr;
} else {
- hashadd(strupper(filename), (void *) *fp, &htab_logfiles);
- fprintf(*fp, "START OF LOG.\n");
- fflush(*fp);
+ hashadd(strupper(filename), (void *) *fp, &htab_logfiles);
+ fprintf(*fp, "START OF LOG.\n");
+ fflush(*fp);
}
}
}
if (GoodObject(object)) {
strcpy(unp2, quick_unparse(object));
do_rawlog(logtype, T("CMD: %s %s / %s: %s"),
- (Suspect(player) ? "SUSPECT" : ""), unp1, unp2, tbuf1);
+ (Suspect(player) ? "SUSPECT" : ""), unp1, unp2, tbuf1);
} else {
strcpy(unp2, quick_unparse(Location(player)));
do_rawlog(logtype, T("CMD: %s %s in %s: %s"),
- (Suspect(player) ? "SUSPECT" : ""), unp1, unp2, tbuf1);
+ (Suspect(player) ? "SUSPECT" : ""), unp1, unp2, tbuf1);
}
break;
case LT_WIZ:
strcpy(unp1, quick_unparse(player));
strcpy(unp2, quick_unparse(Location(player)));
do_rawlog(logtype, T("HUH: %s in %s [%s]: %s"),
- unp1, unp2,
- (GoodObject(Location(player))) ?
- Name(Owner(Location(player))) : T("bad object"), tbuf1);
+ unp1, unp2,
+ (GoodObject(Location(player))) ?
+ Name(Owner(Location(player))) : T("bad object"), tbuf1);
}
break;
default:
}
notify(player, T("Wrong password."));
do_log(LT_WIZ, player, NOTHING,
- T("Invalid attempt to wipe the %s log, password %s"), lname, str);
+ T("Invalid attempt to wipe the %s log, password %s"), lname, str);
return;
}
switch (logtype) {
buf = iter_bufferq(activity_bq, &p, &plr, &type, ×tamp);
if (skip <= 0) {
if (buf) {
- stamp = show_time(timestamp, 0);
- switch (type) {
- case LA_CMD:
- typestr = "CMD";
- break;
- case LA_PE:
- typestr = "EXP";
- break;
- case LA_LOCK:
- typestr = "LCK";
- break;
- default:
- typestr = "???";
- break;
- }
-
- if (dump)
- do_rawlog(LT_ERR, "[%s/#%d/%s] %s", stamp, plr, typestr, buf);
- else
- notify_format(player, "[%s/#%d/%s] %s", stamp, plr, typestr, buf);
+ stamp = show_time(timestamp, 0);
+ switch (type) {
+ case LA_CMD:
+ typestr = "CMD";
+ break;
+ case LA_PE:
+ typestr = "EXP";
+ break;
+ case LA_LOCK:
+ typestr = "LCK";
+ break;
+ default:
+ typestr = "???";
+ break;
+ }
+
+ if (dump)
+ do_rawlog(LT_ERR, "[%s/#%d/%s] %s", stamp, plr, typestr, buf);
+ else
+ notify_format(player, "[%s/#%d/%s] %s", stamp, plr, typestr, buf);
}
}
skip--;
static void look_contents(dbref player, dbref loc, const char *contents_name);
static void look_atrs(dbref player, dbref thing, const char *mstr, int all);
static void mortal_look_atrs(dbref player, dbref thing, const char *mstr,
- int all);
+ int all);
static void look_simple(dbref player, dbref thing);
static void look_description(dbref player, dbref thing, const char *def,
- const char *descname, const char *descformatname);
+ const char *descname, const char *descformatname);
static int decompile_helper
(dbref player, dbref thing, dbref parent, char const *pattern, ATTR *atr, void *args);
static int look_helper
static int look_helper_veiled
(dbref player, dbref thing, dbref target, char const *pattern, ATTR *atr, void *args);
void decompile_atrs(dbref player, dbref thing, const char *name,
- const char *pattern, const char *prefix, int skipdef);
+ const char *pattern, const char *prefix, int skipdef);
void decompile_locks(dbref player, dbref thing, const char *name, int skipdef);
extern PRIV attr_privs_view[];
bp = arg;
DOLIST(thing, Exits(loc)) {
if (((Light(loc) || Light(thing)) || !(Dark(loc) || Dark(thing)))
- && can_interact(thing, player, INTERACT_SEE)) {
- if (bp != arg)
- safe_chr(' ', arg, &bp);
- safe_dbref(thing, arg, &bp);
+ && can_interact(thing, player, INTERACT_SEE)) {
+ if (bp != arg)
+ safe_chr(' ', arg, &bp);
+ safe_dbref(thing, arg, &bp);
}
}
*bp = '\0';
exec_target = loc;
process_expression(buff, &bp, &sp, exec_target, ((AL_FLAGS(a) & AF_POWINHERIT ) ? loc : player), player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free((Malloc_t) save);
notify_by(loc, player, buff);
for (thing = Exits(loc); thing != NOTHING; thing = Next(thing)) {
total_count++;
if (!Transparented(loc) || Opaque(thing))
- exit_count++;
+ exit_count++;
}
} else if (Dark(loc)) {
for (thing = Exits(loc); thing != NOTHING; thing = Next(thing)) {
if (Light(thing) && can_interact(thing, player, INTERACT_SEE)) {
- total_count++;
- if (!Transparented(loc) || Opaque(thing))
- exit_count++;
+ total_count++;
+ if (!Transparented(loc) || Opaque(thing))
+ exit_count++;
}
}
} else {
for (thing = Exits(loc); thing != NOTHING; thing = Next(thing)) {
if ((Light(thing) || !DarkLegal(thing)) &&
- can_interact(thing, player, INTERACT_SEE)) {
- total_count++;
- if (!Transparented(loc) || Opaque(thing))
- exit_count++;
+ can_interact(thing, player, INTERACT_SEE)) {
+ total_count++;
+ if (!Transparented(loc) || Opaque(thing))
+ exit_count++;
}
}
}
for (thing = Exits(loc); thing != NOTHING; thing = Next(thing)) {
if ((Light(loc) || Light(thing) || !(DarkLegal(thing) && !Dark(loc)))
- && can_interact(thing, player, INTERACT_SEE)) {
+ && can_interact(thing, player, INTERACT_SEE)) {
strcpy(pbuff, Name(thing));
if ((p = strchr(pbuff, ';')))
- *p = '\0';
+ *p = '\0';
p = nbuf;
safe_tag_wrap("A", tprintf("XCH_CMD=\"go #%d\"", thing), pbuff, nbuf, &p,
- NOTHING);
+ NOTHING);
*p = '\0';
if (Transparented(loc) && !(Opaque(thing))) {
- if (SUPPORT_PUEBLO && !texits) {
- texits = 1;
- notify_noenter_by(loc, player, tprintf("%cUL%c", TAG_START, TAG_END));
- }
- s1 = tbuf1;
- safe_tag("LI", tbuf1, &s1);
- safe_chr(' ', tbuf1, &s1);
- if (Location(thing) == NOTHING)
- safe_format(tbuf1, &s1, T("%s leads nowhere."), nbuf);
- else if (Location(thing) == HOME)
- safe_format(tbuf1, &s1, T("%s leads home."), nbuf);
- else if (Location(thing) == AMBIGUOUS)
- safe_format(tbuf1, &s1, T("%s leads to a variable location."), nbuf);
- else if (!GoodObject(thing))
- safe_format(tbuf1, &s1, T("%s is corrupt!"), nbuf);
- else {
- safe_format(tbuf1, &s1, T("%s leads to %s."), nbuf,
- Name(Location(thing)));
- }
- *s1 = '\0';
- notify_nopenter_by(loc, player, tbuf1);
+ if (SUPPORT_PUEBLO && !texits) {
+ texits = 1;
+ notify_noenter_by(loc, player, tprintf("%cUL%c", TAG_START, TAG_END));
+ }
+ s1 = tbuf1;
+ safe_tag("LI", tbuf1, &s1);
+ safe_chr(' ', tbuf1, &s1);
+ if (Location(thing) == NOTHING)
+ safe_format(tbuf1, &s1, T("%s leads nowhere."), nbuf);
+ else if (Location(thing) == HOME)
+ safe_format(tbuf1, &s1, T("%s leads home."), nbuf);
+ else if (Location(thing) == AMBIGUOUS)
+ safe_format(tbuf1, &s1, T("%s leads to a variable location."), nbuf);
+ else if (!GoodObject(thing))
+ safe_format(tbuf1, &s1, T("%s is corrupt!"), nbuf);
+ else {
+ safe_format(tbuf1, &s1, T("%s leads to %s."), nbuf,
+ Name(Location(thing)));
+ }
+ *s1 = '\0';
+ notify_nopenter_by(loc, player, tbuf1);
} else {
- if (COMMA_EXIT_LIST) {
- safe_itemizer(this_exit, (this_exit == exit_count),
- ",", T("and"), " ", tbuf2, &s2);
- safe_str(nbuf, tbuf2, &s2);
- this_exit++;
- } else {
- safe_str(nbuf, tbuf2, &s2);
- safe_str(" ", tbuf2, &s2);
- }
+ if (COMMA_EXIT_LIST) {
+ safe_itemizer(this_exit, (this_exit == exit_count),
+ ",", T("and"), " ", tbuf2, &s2);
+ safe_str(nbuf, tbuf2, &s2);
+ this_exit++;
+ } else {
+ safe_str(nbuf, tbuf2, &s2);
+ safe_str(" ", tbuf2, &s2);
+ }
}
}
}
bp2 = arg2;
DOLIST(thing, Contents(loc)) {
if (can_see(player, thing, can_see_loc)) {
- if (bp != arg)
- safe_chr(' ', arg, &bp);
- safe_dbref(thing, arg, &bp);
+ if (bp != arg)
+ safe_chr(' ', arg, &bp);
+ safe_dbref(thing, arg, &bp);
if (bp2 != arg2)
safe_chr('|', arg2, &bp2);
safe_str(unparse_object_myopic(player, thing), arg2, &bp2);
sp = save = safe_atr_value(a);
bp = buff;
if(AL_FLAGS(a) & AF_POWINHERIT)
- exec_target = atr_on_obj;
+ exec_target = atr_on_obj;
else
- exec_target = loc;
+ exec_target = loc;
process_expression(buff, &bp, &sp, exec_target, ((AL_FLAGS(a) & AF_POWINHERIT ) ? loc : player), player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free((Malloc_t) save);
notify_by(loc, player, buff);
PEND;
notify_nopenter_by(loc, player, pbuff);
DOLIST(thing, Contents(loc)) {
- if (can_see(player, thing, can_see_loc)) {
- PUSE;
- tag("LI");
- tag_wrap("A", tprintf("XCH_CMD=\"look #%d\"", thing),
- unparse_object_myopic(player, thing));
- PEND;
- notify_by(loc, player, pbuff);
- }
+ if (can_see(player, thing, can_see_loc)) {
+ PUSE;
+ tag("LI");
+ tag_wrap("A", tprintf("XCH_CMD=\"look #%d\"", thing),
+ unparse_object_myopic(player, thing));
+ PEND;
+ notify_by(loc, player, pbuff);
+ }
}
PUSE;
tag_cancel("UL");
PEND;
notify_noenter_by(loc, player, pbuff);
- break; /* we're done */
+ break; /* we're done */
}
}
}
static int
look_helper_veiled(dbref player, dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *pattern, ATTR *atr, void *args
- __attribute__ ((__unused__)))
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern, ATTR *atr, void *args
+ __attribute__ ((__unused__)))
{
char fbuf[BUFFER_LEN];
char const *r;
if (AF_Veiled(atr)) {
if (ShowAnsi(player))
notify_format(player,
- "%s%s [#%d%s]%s is veiled", ANSI_HILITE, AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL);
+ "%s%s [#%d%s]%s is veiled", ANSI_HILITE, AL_NAME(atr),
+ Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL);
else
notify_format(player,
- "%s [#%d%s] is veiled", AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf);
+ "%s [#%d%s] is veiled", AL_NAME(atr),
+ Owner(AL_CREATOR(atr)), fbuf);
} else {
r = safe_atr_value(atr);
if (ShowAnsi(player))
notify_format(player,
- "%s%s [#%d%s]:%s %s", ANSI_HILITE, AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL, r);
+ "%s%s [#%d%s]:%s %s", ANSI_HILITE, AL_NAME(atr),
+ Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL, r);
else
notify_format(player, "%s [#%d%s]: %s", AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf, r);
+ Owner(AL_CREATOR(atr)), fbuf, r);
/* Show the Lock if it has one */
if(!(AL_RLock(atr) == TRUE_BOOLEXP))
notify_format(player, "Readlock: %s", unparse_boolexp(player, AL_RLock(atr), UB_ALL ));
static int
look_helper(dbref player, dbref thing __attribute__ ((__unused__)),
dbref parent __attribute__ ((__unused__)),
- char const *pattern, ATTR *atr, void *args
- __attribute__ ((__unused__)))
+ char const *pattern, ATTR *atr, void *args
+ __attribute__ ((__unused__)))
{
char fbuf[BUFFER_LEN];
char const *r;
r = safe_atr_value(atr);
if (ShowAnsi(player))
notify_format(player,
- "%s%s [#%d%s]:%s %s", ANSI_HILITE, AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL, r);
+ "%s%s [#%d%s]:%s %s", ANSI_HILITE, AL_NAME(atr),
+ Owner(AL_CREATOR(atr)), fbuf, ANSI_NORMAL, r);
else
notify_format(player, "%s [#%d%s]: %s", AL_NAME(atr),
- Owner(AL_CREATOR(atr)), fbuf, r);
+ Owner(AL_CREATOR(atr)), fbuf, r);
free((Malloc_t) r);
return 1;
}
notify(player, T("No matching attributes."));
} else {
if (!atr_iter_get(player, thing, mstr, 1, look_helper_veiled, NULL)
- && mstr)
+ && mstr)
notify(player, T("No matching attributes."));
}
}
PEND;
notify(player, pbuff);
look_description(player, thing, T("You see nothing special."), "DESCRIBE",
- "DESCFORMAT");
+ "DESCFORMAT");
did_it(player, thing, NULL, NULL, "ODESCRIBE", NULL, "ADESCRIBE", NOTHING);
if (IsExit(thing) && Transparented(thing)) {
if (Cloudy(thing))
if (SUPPORT_PUEBLO && style == LOOK_AUTO) {
a = atr_get(loc, "VRML_URL");
if (a) {
- tag(tprintf("IMG XCH_GRAPH=LOAD HREF=\"%s\"", atr_value(a)));
+ tag(tprintf("IMG XCH_GRAPH=LOAD HREF=\"%s\"", atr_value(a)));
} else {
- tag("IMG XCH_GRAPH=HIDE");
+ tag("IMG XCH_GRAPH=HIDE");
}
}
tag("HR");
if (!IsRoom(loc)) {
if (style != LOOK_AUTO || !Terse(player)) {
if (atr_get(loc, "IDESCRIBE")) {
- look_description(player, loc, NULL, "IDESCRIBE", "IDESCFORMAT");
- did_it(player, loc, NULL, NULL, "OIDESCRIBE", NULL,
- "AIDESCRIBE", NOTHING);
+ look_description(player, loc, NULL, "IDESCRIBE", "IDESCFORMAT");
+ did_it(player, loc, NULL, NULL, "OIDESCRIBE", NULL,
+ "AIDESCRIBE", NOTHING);
} else if (atr_get(loc, "IDESCFORMAT")) {
- look_description(player, loc, NULL, "DESCRIBE", "IDESCFORMAT");
+ look_description(player, loc, NULL, "DESCRIBE", "IDESCFORMAT");
} else
- look_description(player, loc, NULL, "DESCRIBE", "DESCFORMAT");
+ look_description(player, loc, NULL, "DESCRIBE", "DESCFORMAT");
}
}
/* tell him the description */
else {
if (style == LOOK_NORMAL || style == LOOK_AUTO) {
if (style == LOOK_NORMAL || !Terse(player)) {
- look_description(player, loc, NULL, "DESCRIBE", "DESCFORMAT");
- did_it(player, loc, NULL, NULL, "ODESCRIBE", NULL,
- "ADESCRIBE", NOTHING);
+ look_description(player, loc, NULL, "DESCRIBE", "DESCFORMAT");
+ did_it(player, loc, NULL, NULL, "ODESCRIBE", NULL,
+ "ADESCRIBE", NOTHING);
} else
- did_it(player, loc, NULL, NULL, "ODESCRIBE", NULL, "ADESCRIBE",
- NOTHING);
+ did_it(player, loc, NULL, NULL, "ODESCRIBE", NULL, "ADESCRIBE",
+ NOTHING);
} else if (style != LOOK_CLOUDY)
look_description(player, loc, NULL, "DESCRIBE", "DESCFORMAT");
}
if (IsRoom(loc) && (style == LOOK_NORMAL || style == LOOK_AUTO)) {
if (style == LOOK_AUTO && Terse(player)) {
if (could_doit(player, loc))
- did_it(player, loc, NULL, NULL, "OSUCCESS", NULL, "ASUCCESS", NOTHING);
+ did_it(player, loc, NULL, NULL, "OSUCCESS", NULL, "ASUCCESS", NOTHING);
else
- did_it(player, loc, NULL, NULL, "OFAILURE", NULL, "AFAILURE", NOTHING);
+ did_it(player, loc, NULL, NULL, "OFAILURE", NULL, "AFAILURE", NOTHING);
} else if (could_doit(player, loc))
did_it(player, loc, "SUCCESS", NULL, "OSUCCESS", NULL, "ASUCCESS",
- NOTHING);
+ NOTHING);
else
fail_lock(player, loc, Basic_Lock, NULL, NOTHING);
}
static void
look_description(dbref player, dbref thing, const char *def,
- const char *descname, const char *descformatname)
+ const char *descname, const char *descformatname)
{
/* Show thing's description to player, obeying DESCFORMAT if set */
ATTR *a, *f;
ap = asave;
bp = buff;
process_expression(buff, &bp, &ap, thing, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free((Malloc_t) asave);
}
ap = asave;
fbp = fbuff;
process_expression(fbuff, &fbp, &ap, thing, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*fbp = '\0';
free((Malloc_t) asave);
notify_by(thing, player, fbuff);
dbref loc;
if ((loc = Location(player)) == NOTHING)
return;
- look_room(player, loc, LOOK_AUTO); /* auto-look. Obey TERSE. */
+ look_room(player, loc, LOOK_AUTO); /* auto-look. Obey TERSE. */
}
/** Look at something.
if (!GoodObject(Location(player)))
return;
- if (key) { /* look outside */
+ if (key) { /* look outside */
/* can't see through opaque objects */
if (IsRoom(Location(player)) || Opaque(Location(player))) {
notify(player, T("You can't see through that."));
}
thing =
match_result(loc, name, NOTYPE,
- MAT_PLAYER | MAT_REMOTE_CONTENTS | MAT_EXIT | MAT_REMOTES);
+ MAT_PLAYER | MAT_REMOTE_CONTENTS | MAT_EXIT | MAT_REMOTES);
if (thing == NOTHING) {
notify(player, T("I don't see that here."));
return;
notify(player, T("I don't know which one you mean."));
return;
}
- } else { /* regular look */
+ } else { /* regular look */
if (*name == '\0') {
look_room(player, Location(player), LOOK_NORMAL);
return;
const char *boxname = name;
box = parse_match_possessor(player, &name);
if (box == NOTHING) {
- notify(player, T("I don't see that here."));
- return;
+ notify(player, T("I don't see that here."));
+ return;
} else if (box == AMBIGUOUS) {
- notify_format(player, T("I can't tell which %s."), boxname);
- return;
+ notify_format(player, T("I can't tell which %s."), boxname);
+ return;
}
thing = match_result(box, name, NOTYPE, MAT_POSSESSION);
if (thing == NOTHING) {
- notify(player, T("I don't see that here."));
- return;
+ notify(player, T("I don't see that here."));
+ return;
} else if (thing == AMBIGUOUS) {
- notify_format(player, T("I can't tell which %s."), name);
- return;
+ notify_format(player, T("I can't tell which %s."), name);
+ return;
}
if (Opaque(Location(thing)) &&
- (!CanSee(player, Location(thing)) &&
- !controls(player, thing) && !controls(player, Location(thing)))) {
- notify(player, T("You can't look at that from here."));
- return;
+ (!CanSee(player, Location(thing)) &&
+ !controls(player, thing) && !controls(player, Location(thing)))) {
+ notify(player, T("You can't look at that from here."));
+ return;
}
} else if (thing == AMBIGUOUS) {
notify(player, T("I can't tell which one you mean."));
case TYPE_PLAYER:
#ifdef RPMODE_SYS
if(Blind(player) && RPMODE(player) && ICRoom(Location(player))
- && ((IsPlayer(thing) && RPMODE(thing))
- || (IsThing(thing) && RPAPPROVED(thing)))) {
+ && ((IsPlayer(thing) && RPMODE(thing))
+ || (IsThing(thing) && RPAPPROVED(thing)))) {
notify(player, "You are temporarily blind.");
break;
}
/* look it up */
if ((thing =
- noisy_match_result(player, real_name, NOTYPE,
- MAT_EVERYTHING)) == NOTHING)
+ noisy_match_result(player, real_name, NOTYPE,
+ MAT_EVERYTHING)) == NOTHING)
return;
}
}
if (ok) {
notify_format(player,
- T("Owner: %s Zone: %s %s: %d"),
- Name(Owner(thing)),
- object_header(player, Zone(thing)), MONIES, Pennies(thing));
+ T("Owner: %s Zone: %s %s: %d"),
+ Name(Owner(thing)),
+ object_header(player, Zone(thing)), MONIES, Pennies(thing));
notify_format(player, T("Division: %s Level: %d"),
- object_header(player, SDIV(thing).object),
- LEVEL(thing));
+ object_header(player, SDIV(thing).object),
+ LEVEL(thing));
notify_format(player,
- T("Parent: %s"), object_header(player, Parent(thing)));
+ T("Parent: %s"), object_header(player, Parent(thing)));
{
struct lock_list *ll;
for (ll = Locks(thing); ll; ll = ll->next) {
- notify_format(player, T("%s Lock [#%d%s]: %s"),
- L_TYPE(ll), L_CREATOR(ll), lock_flags(ll),
- unparse_boolexp(player, L_KEY(ll), UB_ALL));
+ notify_format(player, T("%s Lock [#%d%s]: %s"),
+ L_TYPE(ll), L_CREATOR(ll), lock_flags(ll),
+ unparse_boolexp(player, L_KEY(ll), UB_ALL));
}
}
notify_format(player, T("Powergroups: %s"), powergroups_list_on(thing, 0));
#endif /* CHAT_SYSTEM */
notify_format(player, T("Warnings checked: %s"),
- unparse_warnings(Warnings(thing)));
+ unparse_warnings(Warnings(thing)));
notify_format(player, T("Created: %s"), show_time(CreTime(thing), 0));
if (!IsPlayer(thing)) {
notify_format(player, T("Last Modification: %s"),
- show_time(ModTime(thing), 0));
+ show_time(ModTime(thing), 0));
if(((Owner(thing) == Owner(player)) || Director(player))
- && LastMod(thing))
+ && LastMod(thing))
notify_format(player, T("Modified: %s"), LastMod(thing));
}
}
/* show attributes */
switch (flag) {
- case EXAM_NORMAL: /* Standard */
+ case EXAM_NORMAL: /* Standard */
if (EX_PUBLIC_ATTRIBS || ok)
look_atrs(player, thing, NULL, all);
break;
- case EXAM_BRIEF: /* Brief */
+ case EXAM_BRIEF: /* Brief */
break;
- case EXAM_MORTAL: /* Mortal */
+ case EXAM_MORTAL: /* Mortal */
if (EX_PUBLIC_ATTRIBS)
mortal_look_atrs(player, thing, NULL, all);
break;
non_div = NOTHING;
DOLIST_VISIBLE(content, Contents(thing), (ok) ? GOD : player) {
if(IsDivision(content)) {
- if(!listed) {
- listed = 1;
- notify(player, T("Sub-Divisions:"));
- }
- notify(player, object_header(player, content));
+ if(!listed) {
+ listed = 1;
+ notify(player, T("Sub-Divisions:"));
+ }
+ notify(player, object_header(player, content));
} else non_div = content;
}
listed = 0;
listed = 0;
DOLIST_VISIBLE(content, Contents(thing), (ok) ? GOD : player) {
if(IsDivision(content) && IsDivision(thing))
- continue;
+ continue;
if (!listed) {
- listed = 1;
- if (IsPlayer(thing))
- notify(player, T("Carrying:"));
- else
- notify(player, T("Contents:"));
+ listed = 1;
+ if (IsPlayer(thing))
+ notify(player, T("Carrying:"));
+ else
+ notify(player, T("Contents:"));
}
notify(player, object_header(player, content));
}
if (Exits(thing) != NOTHING) {
notify(player, T("Exits:"));
DOLIST(exit_dbref, Exits(thing))
- notify(player, object_header(player, exit_dbref));
+ notify(player, object_header(player, exit_dbref));
} else
notify(player, T("No exits."));
/* print dropto if present */
if (Location(thing) != NOTHING) {
notify_format(player,
- T("Dropped objects go to: %s"),
- object_header(player, Location(thing)));
+ T("Dropped objects go to: %s"),
+ object_header(player, Location(thing)));
}
break;
case TYPE_DIVISION:
case TYPE_THING:
case TYPE_PLAYER:
/* print home */
- notify_format(player, T("Home: %s"), object_header(player, Home(thing))); /* home */
+ notify_format(player, T("Home: %s"), object_header(player, Home(thing))); /* home */
/* print location if player can link to it */
if (Location(thing) != NOTHING)
notify_format(player,
- T("Location: %s"), object_header(player, Location(thing)));
+ T("Location: %s"), object_header(player, Location(thing)));
break;
case TYPE_EXIT:
/* print source */
switch (Source(thing)) {
case NOTHING:
do_rawlog(LT_ERR,
- T
- ("*** BLEAH *** Weird exit %s(#%d) in #%d with source NOTHING."),
- Name(thing), thing, Destination(thing));
+ T
+ ("*** BLEAH *** Weird exit %s(#%d) in #%d with source NOTHING."),
+ Name(thing), thing, Destination(thing));
break;
case AMBIGUOUS:
do_rawlog(LT_ERR,
- T("*** BLEAH *** Weird exit %s(#%d) in #%d with source AMBIG."),
- Name(thing), thing, Destination(thing));
+ T("*** BLEAH *** Weird exit %s(#%d) in #%d with source AMBIG."),
+ Name(thing), thing, Destination(thing));
break;
case HOME:
do_rawlog(LT_ERR,
- T("*** BLEAH *** Weird exit %s(#%d) in #%d with source HOME."),
- Name(thing), thing, Destination(thing));
+ T("*** BLEAH *** Weird exit %s(#%d) in #%d with source HOME."),
+ Name(thing), thing, Destination(thing));
break;
default:
notify_format(player,
- T("Source: %s"), object_header(player, Source(thing)));
+ T("Source: %s"), object_header(player, Source(thing)));
break;
}
/* print destination */
break;
default:
notify_format(player,
- T("Destination: %s"),
- object_header(player, Destination(thing)));
+ T("Destination: %s"),
+ object_header(player, Destination(thing)));
break;
}
break;
{
notify_format(player,
- T("You have %d %s."),
- Pennies(player), Pennies(player) == 1 ? MONEY : MONIES);
+ T("You have %d %s."),
+ Pennies(player), Pennies(player) == 1 ? MONEY : MONIES);
}
/** The inventory command.
bp2 = arg2;
DOLIST(thing, Contents(player)) {
if (bp != arg)
- safe_chr(' ', arg, &bp);
+ safe_chr(' ', arg, &bp);
safe_dbref(thing, arg, &bp);
if (bp2 != arg2)
- safe_chr('|', arg2, &bp2);
+ safe_chr('|', arg2, &bp2);
safe_str(unparse_object_myopic(player, thing), arg2, &bp2);
}
*bp = '\0';
if (!payfor(player, FIND_COST)) {
notify_format(player, T("Finds cost %d %s."), FIND_COST,
- ((FIND_COST == 1) ? MONEY : MONIES));
+ ((FIND_COST == 1) ? MONEY : MONIES));
return;
}
/* determinte range */
for (i = bot; i < top; i++) {
if (!IsGarbage(i) && !IsExit(i) && controls(player, i) &&
- (!*name || string_match(Name(i), name))) {
+ (!*name || string_match(Name(i), name))) {
notify(player, object_header(player, i));
count++;
}
if (connect_flag) {
/* only worry about puppet and players who's owner's are connected */
if (Connected(here) || (Puppet(here) && Connected(Owner(here)))) {
- if (IsPlayer(here)) {
- notify_format(player, T("%s is listening."), Name(here));
- } else {
- notify_format(player, T("%s [owner: %s] is listening."),
- Name(here), Name(Owner(here)));
- }
+ if (IsPlayer(here)) {
+ notify_format(player, T("%s is listening."), Name(here));
+ } else {
+ notify_format(player, T("%s [owner: %s] is listening."),
+ Name(here), Name(Owner(here)));
+ }
}
} else {
if (Hearer(here) || Listener(here)) {
- if (Connected(here))
- notify_format(player, T("%s (this room) [speech]. (connected)"),
- Name(here));
- else
- notify_format(player, T("%s (this room) [speech]."), Name(here));
+ if (Connected(here))
+ notify_format(player, T("%s (this room) [speech]. (connected)"),
+ Name(here));
+ else
+ notify_format(player, T("%s (this room) [speech]."), Name(here));
}
if (Commer(here))
- notify_format(player, T("%s (this room) [commands]."), Name(here));
+ notify_format(player, T("%s (this room) [commands]."), Name(here));
if (Audible(here))
- notify_format(player, T("%s (this room) [broadcasting]."), Name(here));
+ notify_format(player, T("%s (this room) [broadcasting]."), Name(here));
}
for (here = Contents(here); here != NOTHING; here = Next(here)) {
if (connect_flag) {
- /* only worry about puppet and players who's owner's are connected */
- if (Connected(here) || (Puppet(here) && Connected(Owner(here)))) {
- if (IsPlayer(here)) {
- notify_format(player, T("%s is listening."), Name(here));
- } else {
- notify_format(player, T("%s [owner: %s] is listening."),
- Name(here), Name(Owner(here)));
- }
- }
+ /* only worry about puppet and players who's owner's are connected */
+ if (Connected(here) || (Puppet(here) && Connected(Owner(here)))) {
+ if (IsPlayer(here)) {
+ notify_format(player, T("%s is listening."), Name(here));
+ } else {
+ notify_format(player, T("%s [owner: %s] is listening."),
+ Name(here), Name(Owner(here)));
+ }
+ }
} else {
- if (Hearer(here) || Listener(here)) {
- if (Connected(here))
- notify_format(player, "%s [speech]. (connected)", Name(here));
- else
- notify_format(player, "%s [speech].", Name(here));
- }
- if (Commer(here))
- notify_format(player, "%s [commands].", Name(here));
+ if (Hearer(here) || Listener(here)) {
+ if (Connected(here))
+ notify_format(player, "%s [speech]. (connected)", Name(here));
+ else
+ notify_format(player, "%s [speech].", Name(here));
+ }
+ if (Commer(here))
+ notify_format(player, "%s [commands].", Name(here));
}
}
}
if (Audible(Location(player))) {
/* listening exits only work if the room is AUDIBLE */
for (here = Exits(Location(player)); here != NOTHING; here = Next(here)) {
- if (Audible(here)) {
- strcpy(tbuf1, Name(here));
- for (p = tbuf1; *p && (*p != ';'); p++) ;
- *p = '\0';
- notify_format(player, "%s [broadcasting].", tbuf1);
- }
+ if (Audible(here)) {
+ strcpy(tbuf1, Name(here));
+ for (p = tbuf1; *p && (*p != ';'); p++) ;
+ *p = '\0';
+ notify_format(player, "%s [broadcasting].", tbuf1);
+ }
}
}
}
for (here = Contents(player); here != NOTHING; here = Next(here)) {
if (connect_flag) {
- /* only worry about puppet and players who's owner's are connected */
- if (Connected(here) || (Puppet(here) && Connected(Owner(here)))) {
- if (IsPlayer(here)) {
- notify_format(player, T("%s is listening."), Name(here));
- } else {
- notify_format(player, T("%s [owner: %s] is listening."),
- Name(here), Name(Owner(here)));
- }
- }
+ /* only worry about puppet and players who's owner's are connected */
+ if (Connected(here) || (Puppet(here) && Connected(Owner(here)))) {
+ if (IsPlayer(here)) {
+ notify_format(player, T("%s is listening."), Name(here));
+ } else {
+ notify_format(player, T("%s [owner: %s] is listening."),
+ Name(here), Name(Owner(here)));
+ }
+ }
} else {
- if (Hearer(here) || Listener(here)) {
- if (Connected(here))
- notify_format(player, "%s [speech]. (connected)", Name(here));
- else
- notify_format(player, "%s [speech].", Name(here));
- }
- if (Commer(here))
- notify_format(player, "%s [commands].", Name(here));
+ if (Hearer(here) || Listener(here)) {
+ if (Connected(here))
+ notify_format(player, "%s [speech]. (connected)", Name(here));
+ else
+ notify_format(player, "%s [speech].", Name(here));
+ }
+ if (Commer(here))
+ notify_format(player, "%s [commands].", Name(here));
}
}
}
return;
}
notify_format(player,
- T("%s is at: %s."), Name(thing),
- unparse_object(player, Location(thing)));
+ T("%s is at: %s."), Name(thing),
+ unparse_object(player, Location(thing)));
if (!CanSee(player, thing))
notify_format(thing, T("%s has just located your position."), Name(player));
return;
{
dbref place;
dbref counter;
- int exc, tc, pc, rc; /* how many we've found */
- int exd, td, pd, rd; /* what we're looking for */
+ int exc, tc, pc, rc; /* how many we've found */
+ int exd, td, pd, rd; /* what we're looking for */
int bot = 0;
int top = db_top;
return;
} else {
if ((place = noisy_match_result(player, where, NOTYPE, MAT_EVERYTHING))
- == NOTHING)
+ == NOTHING)
return;
}
}
if (!payfor(player, FIND_COST)) {
notify_format(player, T("You don't have enough %d %s to do that."),
- FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES));
+ FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES));
return;
}
/* figure out what we're looking for */
if (controls(player, place) || controls(player, counter)) {
switch (Typeof(counter)) {
case TYPE_EXIT:
- if (exd) {
- if (Location(counter) == place) {
- notify_format(player,
- "%s(#%d) [from: %s(#%d)]", Name(counter),
- counter, Name(Source(counter)), Source(counter));
- exc++;
- }
- }
- break;
+ if (exd) {
+ if (Location(counter) == place) {
+ notify_format(player,
+ "%s(#%d) [from: %s(#%d)]", Name(counter),
+ counter, Name(Source(counter)), Source(counter));
+ exc++;
+ }
+ }
+ break;
case TYPE_ROOM:
- if (rd) {
- if (Location(counter) == place) {
- notify_format(player, "%s(#%d) [dropto]", Name(counter), counter);
- rc++;
- }
- }
- break;
+ if (rd) {
+ if (Location(counter) == place) {
+ notify_format(player, "%s(#%d) [dropto]", Name(counter), counter);
+ rc++;
+ }
+ }
+ break;
case TYPE_THING:
- if (td) {
- if (Home(counter) == place) {
- notify_format(player, "%s(#%d) [home]", Name(counter), counter);
- tc++;
- }
- }
- break;
+ if (td) {
+ if (Home(counter) == place) {
+ notify_format(player, "%s(#%d) [home]", Name(counter), counter);
+ tc++;
+ }
+ }
+ break;
case TYPE_PLAYER:
- if (pd) {
- if (Home(counter) == place) {
- notify_format(player, "%s(#%d) [home]", Name(counter), counter);
- pc++;
- }
- }
- break;
+ if (pd) {
+ if (Home(counter) == place) {
+ notify_format(player, "%s(#%d) [home]", Name(counter), counter);
+ pc++;
+ }
+ }
+ break;
}
}
}
} else {
notify(player, T("---------- Entrances Done ----------"));
notify_format(player,
- "Totals: Rooms...%d Exits...%d Objects...%d Players...%d",
- rc, exc, tc, pc);
+ "Totals: Rooms...%d Exits...%d Objects...%d Players...%d",
+ rc, exc, tc, pc);
return;
}
}
/** Store arguments for decompile_helper() */
struct dh_args {
- char const *prefix; /**< Decompile/tf prefix */
- char const *name; /**< Decompile object name */
- int skipdef; /**< Skip default flags on attributes if true */
+ char const *prefix; /**< Decompile/tf prefix */
+ char const *name; /**< Decompile object name */
+ int skipdef; /**< Skip default flags on attributes if true */
};
extern char escaped_chars[UCHAR_MAX + 1];
case ESC_CHAR:
ptr++;
if (!*ptr) {
- ptr--;
- break;
+ ptr--;
+ break;
}
/* Check if this is any sort of useful code. */
if (*ptr == '[' && *(ptr + 1) && *(ptr + 2)) {
- codestart = ptr; /* Save the address of the escape code. */
- ptr++;
- digits = 0; /* Digit count is zero. */
- /* The following code works in this way:
- * 1) If a character is a ;, we are allowed to count 2 more digits
- * 2) If the digits count is 3, break out of the "ansi" code.
- * 3) If the character is not a number or ;, break out.
- * 4) If an 'm' is encountered, the for-loop exits.
- * The only non-breaking exit occurs when the code ends with "m".
- * Otherwise, we break out with the ptr pointing to the end of
- * the invalid code, causing decompose() to ignore it entirely.
- */
- for (; *ptr && (*ptr != 'm'); ptr++) {
- if (*ptr == ';') {
- if (digits == 0) { /* No double-;s are allowed. */
- digits = 3;
- break;
- }
- digits = 0;
- } else if (digits >= 2) {
- digits = 3; /* If we encounter a 3-number code, break out. */
- break;
- } else if (isdigit(*ptr)) {
- digits++; /* Count the numbers we encounter. */
- } else {
- digits = 3;
- break;
- }
- }
-
- /* 3 is the break-code. 0 means there's no ANSI at all! */
- if (!*ptr || digits == 3 || digits == 0) {
- break;
- }
-
- /* It IS an ansi code! It ends in "m" anyway.
- * Set ptr to point to the first digit in the code. We are
- * promised at this point that ptr+1 is not NUL.
- */
- ptr = codestart + 1;
-
- /* Check if the first part of the code is two-digit (color) */
- if (*(ptr + 1) >= '0' && *(ptr + 1) <= '7') {
- if (flag_depth < ansi_depth) {
- safe_str(")]", value, &s);
- ansi_depth--;
- }
- } else { /* ansi "flag", inverse, flash, underline, hilight */
- flag_depth = ansi_depth + 1;
- }
- /* Check to see if this is an 'ansi-reset' code. */
- if (*ptr == '0' && *(ptr + 1) == 'm') {
- for (; ansi_depth > 0; ansi_depth--) {
- safe_str(")]", value, &s);
- }
- flag_depth = 0;
- ptr++;
- break;
- }
-
- ansi_depth++;
- safe_str("[ansi(", value, &s);
- dospace = 1;
-
- /* code for decompiling ansi */
- for (; isdigit(*ptr) || *ptr == ';'; ptr++) {
- if (*ptr == ';') /* Yes, it is necessary to do it this way. */
- ptr++;
- /* Break if there is an 'm' here. */
- if (!*ptr || !isdigit(*ptr))
- break;
- /* Check to see if the code is one character long. */
- if (*(ptr + 1) == ';' || *(ptr + 1) == 'm') {
- /* ANSI flag */
- switch (*ptr) {
- case '1':
- safe_chr('h', value, &s);
- break;
- case '4':
- safe_chr('u', value, &s);
- break;
- case '5':
- safe_chr('f', value, &s);
- break;
- case '7':
- safe_chr('i', value, &s);
- break;
- default: /* Not a valid code. */
- break;
- }
- } else {
- if (!*(ptr + 1))
- break; /* Sudden string end or lack of real color code. */
- ptr++;
-
- /* Check if this could be a real color (starts with 3 or 4) */
- if (*(ptr - 1) == '3' || *(ptr - 1) == '4') {
- switch (*ptr) {
- case '0':
- ansi_letter = 'x';
- break;
- case '1':
- ansi_letter = 'r';
- break;
- case '2':
- ansi_letter = 'g';
- break;
- case '3':
- ansi_letter = 'y';
- break;
- case '4':
- ansi_letter = 'b';
- break;
- case '5':
- ansi_letter = 'm';
- break;
- case '6':
- ansi_letter = 'c';
- break;
- case '7':
- ansi_letter = 'w';
- break;
- default:
- break; /* Not a valid color. */
- }
- /* If background color, change the letter to a capital. */
- if (*(ptr - 1) == '4')
- ansi_letter = toupper(ansi_letter);
- safe_chr(ansi_letter, value, &s);
- }
- /* No "else" here: If a two-digit code
- * doesn't start with 3 or 4, is isn't ANSI. */
- }
- }
- safe_chr(',', value, &s);
+ codestart = ptr; /* Save the address of the escape code. */
+ ptr++;
+ digits = 0; /* Digit count is zero. */
+ /* The following code works in this way:
+ * 1) If a character is a ;, we are allowed to count 2 more digits
+ * 2) If the digits count is 3, break out of the "ansi" code.
+ * 3) If the character is not a number or ;, break out.
+ * 4) If an 'm' is encountered, the for-loop exits.
+ * The only non-breaking exit occurs when the code ends with "m".
+ * Otherwise, we break out with the ptr pointing to the end of
+ * the invalid code, causing decompose() to ignore it entirely.
+ */
+ for (; *ptr && (*ptr != 'm'); ptr++) {
+ if (*ptr == ';') {
+ if (digits == 0) { /* No double-;s are allowed. */
+ digits = 3;
+ break;
+ }
+ digits = 0;
+ } else if (digits >= 2) {
+ digits = 3; /* If we encounter a 3-number code, break out. */
+ break;
+ } else if (isdigit(*ptr)) {
+ digits++; /* Count the numbers we encounter. */
+ } else {
+ digits = 3;
+ break;
+ }
+ }
+
+ /* 3 is the break-code. 0 means there's no ANSI at all! */
+ if (!*ptr || digits == 3 || digits == 0) {
+ break;
+ }
+
+ /* It IS an ansi code! It ends in "m" anyway.
+ * Set ptr to point to the first digit in the code. We are
+ * promised at this point that ptr+1 is not NUL.
+ */
+ ptr = codestart + 1;
+
+ /* Check if the first part of the code is two-digit (color) */
+ if (*(ptr + 1) >= '0' && *(ptr + 1) <= '7') {
+ if (flag_depth < ansi_depth) {
+ safe_str(")]", value, &s);
+ ansi_depth--;
+ }
+ } else { /* ansi "flag", inverse, flash, underline, hilight */
+ flag_depth = ansi_depth + 1;
+ }
+ /* Check to see if this is an 'ansi-reset' code. */
+ if (*ptr == '0' && *(ptr + 1) == 'm') {
+ for (; ansi_depth > 0; ansi_depth--) {
+ safe_str(")]", value, &s);
+ }
+ flag_depth = 0;
+ ptr++;
+ break;
+ }
+
+ ansi_depth++;
+ safe_str("[ansi(", value, &s);
+ dospace = 1;
+
+ /* code for decompiling ansi */
+ for (; isdigit(*ptr) || *ptr == ';'; ptr++) {
+ if (*ptr == ';') /* Yes, it is necessary to do it this way. */
+ ptr++;
+ /* Break if there is an 'm' here. */
+ if (!*ptr || !isdigit(*ptr))
+ break;
+ /* Check to see if the code is one character long. */
+ if (*(ptr + 1) == ';' || *(ptr + 1) == 'm') {
+ /* ANSI flag */
+ switch (*ptr) {
+ case '1':
+ safe_chr('h', value, &s);
+ break;
+ case '4':
+ safe_chr('u', value, &s);
+ break;
+ case '5':
+ safe_chr('f', value, &s);
+ break;
+ case '7':
+ safe_chr('i', value, &s);
+ break;
+ default: /* Not a valid code. */
+ break;
+ }
+ } else {
+ if (!*(ptr + 1))
+ break; /* Sudden string end or lack of real color code. */
+ ptr++;
+
+ /* Check if this could be a real color (starts with 3 or 4) */
+ if (*(ptr - 1) == '3' || *(ptr - 1) == '4') {
+ switch (*ptr) {
+ case '0':
+ ansi_letter = 'x';
+ break;
+ case '1':
+ ansi_letter = 'r';
+ break;
+ case '2':
+ ansi_letter = 'g';
+ break;
+ case '3':
+ ansi_letter = 'y';
+ break;
+ case '4':
+ ansi_letter = 'b';
+ break;
+ case '5':
+ ansi_letter = 'm';
+ break;
+ case '6':
+ ansi_letter = 'c';
+ break;
+ case '7':
+ ansi_letter = 'w';
+ break;
+ default:
+ break; /* Not a valid color. */
+ }
+ /* If background color, change the letter to a capital. */
+ if (*(ptr - 1) == '4')
+ ansi_letter = toupper(ansi_letter);
+ safe_chr(ansi_letter, value, &s);
+ }
+ /* No "else" here: If a two-digit code
+ * doesn't start with 3 or 4, is isn't ANSI. */
+ }
+ }
+ safe_chr(',', value, &s);
} else {
- ptr--;
- /* This shouldn't happen if we only have ansi codes
- * So if more dirty things must be added later... */
+ ptr--;
+ /* This shouldn't happen if we only have ansi codes
+ * So if more dirty things must be added later... */
}
break;
default:
}
static int
-decompile_helper(dbref player, dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- const char *pattern __attribute__ ((__unused__)),
- ATTR *atr, void *args)
+decompile_helper(dbref player, dbref thing __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ const char *pattern __attribute__ ((__unused__)),
+ ATTR *atr, void *args)
{
struct dh_args *dh = args;
ATTR *ptr;
if (ptr && !strcmp(AL_NAME(atr), AL_NAME(ptr)))
safe_chr('@', msg, &bp);
else {
- ptr = NULL; /* To speed later checks */
+ ptr = NULL; /* To speed later checks */
safe_chr('&', msg, &bp);
}
safe_str(AL_NAME(atr), msg, &bp);
/* Are we different? If so, do as usual */
int npmflags = AL_FLAGS(ptr) & (~AF_PREFIXMATCH);
if (AL_FLAGS(atr) != AL_FLAGS(ptr) && AL_FLAGS(atr) != npmflags)
- privs = privs_to_string(attr_privs_view, AL_FLAGS(atr));
+ privs = privs_to_string(attr_privs_view, AL_FLAGS(atr));
} else {
privs = privs_to_string(attr_privs_view, AL_FLAGS(atr));
}
*/
void
decompile_atrs(dbref player, dbref thing, const char *name, const char *pattern,
- const char *prefix, int skipdef)
+ const char *prefix, int skipdef)
{
struct dh_args dh;
dh.prefix = prefix;
const lock_list *p = get_lockproto(L_TYPE(ll));
if (p) {
notify_format(player, "@lock/%s %s=%s",
- L_TYPE(ll), name, unparse_boolexp(player, L_KEY(ll),
- UB_MEREF));
+ L_TYPE(ll), name, unparse_boolexp(player, L_KEY(ll),
+ UB_MEREF));
if (skipdef) {
- if (p && L_FLAGS(ll) == L_FLAGS(p))
- continue;
+ if (p && L_FLAGS(ll) == L_FLAGS(p))
+ continue;
}
if (L_FLAGS(ll))
- notify_format(player,
- "@lset %s/%s=%s", name, L_TYPE(ll), lock_flags_long(ll));
+ notify_format(player,
+ "@lset %s/%s=%s", name, L_TYPE(ll), lock_flags_long(ll));
if ((L_FLAGS(p) & LF_PRIVATE) && !(L_FLAGS(ll) & LF_PRIVATE))
- notify_format(player, "@lset %s/%s=!no_inherit", name, L_TYPE(ll));
+ notify_format(player, "@lset %s/%s=!no_inherit", name, L_TYPE(ll));
} else {
notify_format(player, "@lock/user:%s %s=%s",
- ll->type, name, unparse_boolexp(player, ll->key, UB_MEREF));
+ ll->type, name, unparse_boolexp(player, ll->key, UB_MEREF));
if (L_FLAGS(ll))
- notify_format(player,
- "@lset %s/%s=%s", name, L_TYPE(ll), lock_flags_long(ll));
+ notify_format(player,
+ "@lset %s/%s=%s", name, L_TYPE(ll), lock_flags_long(ll));
}
}
}
*/
void
do_decompile(dbref player, const char *name, const char *prefix,
- enum dec_type dbflag, int skipdef)
+ enum dec_type dbflag, int skipdef)
{
dbref thing;
const char *object = NULL;
break;
default:
if (IsRoom(thing))
- decompile_atrs(player, thing, "here", attrib, prefix, skipdef);
+ decompile_atrs(player, thing, "here", attrib, prefix, skipdef);
else
- decompile_atrs(player, thing, Name(thing), attrib, prefix, skipdef);
+ decompile_atrs(player, thing, Name(thing), attrib, prefix, skipdef);
break;
}
return;
} else {
object = shortname(thing);
if (dbflag != DEC_ATTR)
- notify_format(player, "%s@open %s", prefix, Name(thing));
+ notify_format(player, "%s@open %s", prefix, Name(thing));
}
break;
case TYPE_DIVISION:
if (dbflag != DEC_ATTR) {
if (Mobile(thing)) {
if (GoodObject(Home(thing)))
- notify_format(player, "%s@link %s = #%d", prefix, object, Home(thing));
+ notify_format(player, "%s@link %s = #%d", prefix, object, Home(thing));
else if (Home(thing) == HOME)
- notify_format(player, "%s@link %s = HOME", prefix, object);
+ notify_format(player, "%s@link %s = HOME", prefix, object);
} else {
if (GoodObject(Destination(thing)))
- notify_format(player, "%s@link %s = #%d", prefix, object,
- Destination(thing));
+ notify_format(player, "%s@link %s = #%d", prefix, object,
+ Destination(thing));
else if (Destination(thing) == AMBIGUOUS)
- notify_format(player, "%s@link %s = VARIABLE", prefix, object);
+ notify_format(player, "%s@link %s = VARIABLE", prefix, object);
else if (Destination(thing) == HOME)
- notify_format(player, "%s@link %s = HOME", prefix, object);
+ notify_format(player, "%s@link %s = HOME", prefix, object);
}
if (GoodObject(Zone(thing)))
notify_format(player, "%s@parent %s=#%d", prefix, object, Parent(thing));
if (GoodObject(SDIV(thing).object) && IsDivision(SDIV(thing).object))
notify_format(player, "%s@division %s = #%d", prefix, object,
- SDIV(thing).object);
+ SDIV(thing).object);
decompile_locks(player, thing, object, skipdef);
decompile_flags(player, thing, object);
* \endverbatim
*/
-#define MA_INC 3 /**< How many maliases we malloc at a time */
+#define MA_INC 3 /**< How many maliases we malloc at a time */
#include "config.h"
#include "copyrite.h"
int ma_size = 0; /**< Number of maliases */
-int ma_top = 0; /**< Top of alias array */
+int ma_top = 0; /**< Top of alias array */
struct mail_alias *malias; /**< Pointer to linked list of aliases */
/** Privilege table for maliases. */
}
if (*alias != MALIAS_TOKEN) {
notify_format(player,
- T("MAIL: All Mail aliases must begin with '%c'."),
- MALIAS_TOKEN);
+ T("MAIL: All Mail aliases must begin with '%c'."),
+ MALIAS_TOKEN);
return;
}
good = "`$_-.'";
return;
}
}
- m = get_malias(GOD, alias); /* GOD can see all aliases */
- if (m) { /* Ensures no duplicates! */
+ m = get_malias(GOD, alias); /* GOD can see all aliases */
+ if (m) { /* Ensures no duplicates! */
notify_format(player, T("MAIL: Mail Alias '%s' already exists."), alias);
return;
}
ma_size = MA_INC;
malias =
(struct mail_alias *) mush_malloc(sizeof(struct mail_alias) *
- ma_size, "malias_list");
+ ma_size, "malias_list");
} else if (ma_top >= ma_size) {
ma_size += MA_INC;
m =
(struct mail_alias *) mush_malloc(sizeof(struct mail_alias) *
- (ma_size), "malias_list");
+ (ma_size), "malias_list");
memcpy(m, malias, sizeof(struct mail_alias) * ma_top);
mush_free((Malloc_t) malias, "malias_list");
malias = m;
tail = head;
while (*tail && (*tail != ' ')) {
if (*tail == '"') {
- head++;
- tail++;
- while (*tail && (*tail != '"'))
- tail++;
+ head++;
+ tail++;
+ while (*tail && (*tail != '"'))
+ tail++;
}
if (*tail)
- tail++;
+ tail++;
}
tail--;
if (*tail != '"')
for (i = 0; i < ma_top; i++) {
m = &malias[i];
if ((m->owner == player) || (m->nflags == 0) ||
- ((m->nflags & ALIAS_ADMIN) && Admin(player)) ||
- ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) {
+ ((m->nflags & ALIAS_ADMIN) && Admin(player)) ||
+ ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) {
if (!notified) {
- notify_format(player, "%-13s %-35s %s %-15s",
- T("Name"), T("Alias Description"), T("Use See"),
- T("Owner"));
- notified++;
+ notify_format(player, "%-13s %-35s %s %-15s",
+ T("Name"), T("Alias Description"), T("Use See"),
+ T("Owner"));
+ notified++;
}
notify_format(player,
- "%c%-12.12s %-35.35s %s %-15.15s", MALIAS_TOKEN, m->name,
- uncompress((unsigned char *) (m->desc)), get_shortprivs(m),
- Name(m->owner));
+ "%c%-12.12s %-35.35s %s %-15.15s", MALIAS_TOKEN, m->name,
+ uncompress((unsigned char *) (m->desc)), get_shortprivs(m),
+ Name(m->owner));
}
}
return;
} else if (MailAdmin(player, m->owner) || (player == m->owner)) {
if (m->desc)
- free(m->desc); /* No need to update MEM_CHECK records here */
+ free(m->desc); /* No need to update MEM_CHECK records here */
m->desc = compress(desc);
notify(player, T("MAIL: Description changed."));
} else
return;
} else {
if ((no = lookup_player(owner)) == NOTHING) {
- notify(player, T("MAIL: I cannot find that player."));
- return;
+ notify(player, T("MAIL: I cannot find that player."));
+ return;
}
m->owner = no;
notify(player, T("MAIL: Owner changed for alias."));
}
if (*newname != MALIAS_TOKEN) {
notify_format(player,
- T("MAIL: Bad alias. Aliases must start with '%c'."),
- MALIAS_TOKEN);
+ T("MAIL: Bad alias. Aliases must start with '%c'."),
+ MALIAS_TOKEN);
return;
}
if (get_malias(GOD, newname) != NULL) {
return;
}
- free(m->name); /* No need to update MEM_CHECK records here. */
+ free(m->name); /* No need to update MEM_CHECK records here. */
m->name = strdup(newname + 1);
notify(player, T("MAIL: Mail Alias renamed."));
m = get_malias(player, alias);
if (!m) {
notify(player,
- T
- ("MAIL: Not a valid alias. Remember to prefix the alias name with *."));
+ T
+ ("MAIL: Not a valid alias. Remember to prefix the alias name with *."));
return;
}
if (MailAdmin(player, m->owner) || (m->owner == player)) {
m = get_malias(player, alias);
if (!m) {
notify_format(player,
- T
- ("MAIL: Not a valid alias. Remember to prefix the alias name with %c."),
- MALIAS_TOKEN);
+ T
+ ("MAIL: Not a valid alias. Remember to prefix the alias name with %c."),
+ MALIAS_TOKEN);
return;
}
if (!tolist || !*tolist) {
tail = head;
while (*tail && (*tail != ' ')) {
if (*tail == '"') {
- head++;
- tail++;
- while (*tail && (*tail != '"'))
- tail++;
+ head++;
+ tail++;
+ while (*tail && (*tail != '"'))
+ tail++;
}
if (*tail)
- tail++;
+ tail++;
}
tail--;
if (*tail != '"')
return;
}
notify(player,
- "Num Name Description Owner Count");
+ "Num Name Description Owner Count");
for (i = 0; i < ma_top; i++) {
m = &malias[i];
notify_format(player, "#%-4d %c%-10.10s %-40.40s %-11.11s (%3d)",
- i, MALIAS_TOKEN, m->name,
- uncompress((unsigned char *) m->desc),
- Name(m->owner), m->size);
+ i, MALIAS_TOKEN, m->name,
+ uncompress((unsigned char *) m->desc),
+ Name(m->owner), m->size);
}
notify(player, T("***** End of Mail Aliases *****"));
notify(player, T("MAIL: Permission denied."));
else {
notify_format(player,
- T("MAIL: Number of mail aliases defined: %d"), ma_top);
+ T("MAIL: Number of mail aliases defined: %d"), ma_top);
notify_format(player, T("MAIL: Allocated slots %d"), ma_size);
}
}
notify(player, T("MAIL: Only god can do that!"));
return;
}
- if (ma_size) { /* aliases defined ? */
+ if (ma_size) { /* aliases defined ? */
for (i = 0; i < ma_top; i++) {
m = &malias[i];
if (m->name)
- mush_free(m->name, "malias_name");
+ mush_free(m->name, "malias_name");
if (m->desc)
- mush_free(m->desc, "malias_desc");
+ mush_free(m->desc, "malias_desc");
if (m->members)
- mush_free((Malloc_t) m->members, "malias_members");
+ mush_free((Malloc_t) m->members, "malias_members");
}
mush_free((Malloc_t) malias, "malias_list");
}
p = type ? &m->mflags : &m->nflags;
*p = string_to_privs(malias_priv_table, privs, 0);
notify_format(player,
- T("MAIL: Permission to see/use alias '%s' changed to %s"),
- alias, privs_to_string(malias_priv_table, *p));
+ T("MAIL: Permission to see/use alias '%s' changed to %s"),
+ alias, privs_to_string(malias_priv_table, *p));
}
tail = head;
while (*tail && (*tail != ' ')) {
if (*tail == '"') {
- head++;
- tail++;
- while (*tail && (*tail != '"'))
- tail++;
+ head++;
+ tail++;
+ while (*tail && (*tail != '"'))
+ tail++;
}
if (*tail)
- tail++;
+ tail++;
}
tail--;
if (*tail != '"')
notify_format(player, T("MAIL: No such player '%s'."), head);
} else {
if (ismember(m, target)) {
- notify_format(player,
- T("MAIL: player '%s' exists already in alias %s."),
- head, alias);
+ notify_format(player,
+ T("MAIL: player '%s' exists already in alias %s."),
+ head, alias);
} else {
- buff = unparse_object(player, target);
- notify_format(player, T("MAIL: %s added to alias %s"), buff, alias);
- alist[i] = target;
- i++;
+ buff = unparse_object(player, target);
+ notify_format(player, T("MAIL: %s added to alias %s"), buff, alias);
+ alist[i] = target;
+ i++;
}
}
/*
tail = head;
while (*tail && (*tail != ' ')) {
if (*tail == '"') {
- head++;
- tail++;
- while (*tail && (*tail != '"'))
- tail++;
+ head++;
+ tail++;
+ while (*tail && (*tail != '"'))
+ tail++;
}
if (*tail)
- tail++;
+ tail++;
}
tail--;
if (*tail != '"')
notify_format(player, T("MAIL: No such player '%s'."), head);
} else {
if (!(i = ismember(m, target))) {
- notify_format(player, T("MAIL: player '%s' is not in alias %s."),
- head, alias);
+ notify_format(player, T("MAIL: player '%s' is not in alias %s."),
+ head, alias);
} else {
- buff = unparse_object(player, target);
- m->members[i - 1] = m->members[--m->size];
- notify_format(player, T("MAIL: %s removed from alias %s"), buff, alias);
+ buff = unparse_object(player, target);
+ m->members[i - 1] = m->members[--m->size];
+ notify_format(player, T("MAIL: %s removed from alias %s"), buff, alias);
}
}
/*
int i;
for (i = 0; i < m->size; i++) {
if (player == m->members[i])
- return (i + 1); /* To avoid entry "0" */
+ return (i + 1); /* To avoid entry "0" */
}
return 0;
}
for (i = 0; i < ma_top; i++) {
m = &malias[i];
if ((m->owner == player) || (m->nflags == 0) ||
- /* ((m->nflags & ALIAS_ADMIN) && Admin(player)) || */
- Admin(player) ||
- ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) {
+ /* ((m->nflags & ALIAS_ADMIN) && Admin(player)) || */
+ Admin(player) ||
+ ((m->nflags & ALIAS_MEMBERS) && ismember(m, player))) {
if (!strcasecmp(mal, m->name))
- return m;
+ return m;
}
}
return NULL;
if (ma_top > 0)
malias =
(struct mail_alias *) mush_malloc(sizeof(struct mail_alias) *
- ma_size, "malias_list");
+ ma_size, "malias_list");
else
malias = NULL;
if (m->size > 0) {
m->members =
- (dbref *) mush_malloc(m->size * sizeof(dbref), "malias_members");
+ (dbref *) mush_malloc(m->size * sizeof(dbref), "malias_members");
for (j = 0; j < m->size; j++) {
- m->members[j] = getref(fp);
+ m->members[j] = getref(fp);
}
} else {
m->members = NULL;
#define match_absolute(name) parse_objid(name)
static dbref match_player(const dbref matcher, const char *match_name);
static dbref choose_thing(const dbref match_who, const int preferred_type,
- long int flags, dbref thing1, dbref thing2);
-extern int check_alias(const char *command, const char *list); /* game.c */
+ long int flags, dbref thing1, dbref thing2);
+extern int check_alias(const char *command, const char *list); /* game.c */
/** A wrapper for returning a match, AMBIGUOUS, or NOTHING.
*/
dbref
match_result(const dbref who, const char *name, const int type,
- const long flags)
+ const long flags)
{
return match_result_internal(who, name, type, flags);
}
*/
dbref
noisy_match_result(const dbref who, const char *name, const int type,
- const long flags)
+ const long flags)
{
return match_result_internal(who, name, type, flags | MAT_NOISY);
}
*/
dbref
last_match_result(const dbref who, const char *name, const int type,
- const long flags)
+ const long flags)
{
return match_result_internal(who, name, type, flags | MAT_LAST);
}
* e. If we got no matches, complain
*/
-#define MATCH_NONE 0x0 /**< No matches were found */
-#define MATCH_EXACT 0x1 /**< At least one exact match found */
-#define MATCH_PARTIAL 0x2 /**< At least one partial match found, no exact */
+#define MATCH_NONE 0x0 /**< No matches were found */
+#define MATCH_EXACT 0x1 /**< At least one exact match found */
+#define MATCH_PARTIAL 0x2 /**< At least one partial match found, no exact */
/** Prototype for matching functions */
#define MATCH_FUNC_PROTO(fun_name) \
/* ARGSUSED */ /* try to keep lint happy */ \
if (!exact_matches_to_go)
match = exact_match;
else if (GoodObject(last_match))
- match = last_match; /* nth exact-or-partial match, or nothing? */
+ match = last_match; /* nth exact-or-partial match, or nothing? */
/* This shouldn't happen, but just in case we have a valid match,
* and an invalid last_match in the matchnum case, fall through and
* use the match.
} else if (GoodObject(exact_match)) {
/* How many exact matches? */
if (exact_matches_to_go == -1)
- match = exact_match; /* Good */
+ match = exact_match; /* Good */
else if (flags & MAT_LAST)
- match = exact_match; /* Good enough */
+ match = exact_match; /* Good enough */
else
match = AMBIGUOUS;
} else {
if (!matches_to_go)
- match = NOTHING; /* No matches */
+ match = NOTHING; /* No matches */
else if (matches_to_go == -1)
- match = last_match; /* Good */
+ match = last_match; /* Good */
else if (flags & MAT_LAST)
- match = last_match; /* Good enough */
+ match = last_match; /* Good enough */
else
match = AMBIGUOUS;
}
if (GoodObject(match) && (flags & MAT_NEAR) && !CanRemote(who, match))
goto mat_near;
if (GoodObject(match)) {
- if (flags & MAT_CONTROL) {
- /* Check for control */
- if (controls(who, match) || nearby(who, match))
- return match;
- } else {
- return match;
- }
+ if (flags & MAT_CONTROL) {
+ /* Check for control */
+ if (controls(who, match) || nearby(who, match))
+ return match;
+ } else {
+ return match;
+ }
}
}
if (flags & MAT_PLAYER) {
match = match_player(who, name);
if (GoodObject(match))
- return match;
+ return match;
}
} else {
/* We're doing a nearby match and the player doesn't have
*name += 10;
*flags &= ~(MAT_POSSESSION | MAT_EXIT);
} else if (!strncasecmp(*name, "here ", 5)
- || !strncasecmp(*name, "this ", 5)) {
+ || !strncasecmp(*name, "this ", 5)) {
*name += 5;
*flags &=
- ~(MAT_POSSESSION | MAT_EXIT | MAT_REMOTE_CONTENTS | MAT_CONTAINER);
+ ~(MAT_POSSESSION | MAT_EXIT | MAT_REMOTE_CONTENTS | MAT_CONTAINER);
}
}
if ((*flags & MAT_POSSESSION) && (!strncasecmp(*name, "my ", 3)
- || !strncasecmp(*name, "me ", 3))) {
+ || !strncasecmp(*name, "me ", 3))) {
*name += 3;
*flags &= ~(MAT_NEIGHBOR | MAT_EXIT | MAT_CONTAINER | MAT_REMOTE_CONTENTS);
}
count = -1;
} else if ((count > 10) && (count < 14)) {
if (strcasecmp(e, "th"))
- count = -1;
+ count = -1;
} else if ((count % 10) == 1) {
if (strcasecmp(e, "st"))
- count = -1;
+ count = -1;
} else if ((count % 10) == 2) {
if (strcasecmp(e, "nd"))
- count = -1;
+ count = -1;
} else if ((count % 10) == 3) {
if (strcasecmp(e, "rd"))
- count = -1;
+ count = -1;
} else if (strcasecmp(e, "th")) {
count = -1;
}
(*matches_to_go)--;
return MATCH_EXACT;
} else if( can_interact(first, who, INTERACT_MATCH) && (!strcasecmp(Name(first), name) ||
- (GoodObject(alias_match) && (alias_match == first)))) {
+ (GoodObject(alias_match) && (alias_match == first)))) {
/* An exact match, but there may be others */
(*exact_matches_to_go)--;
(*matches_to_go)--;
if (nth_match) {
- if (!(*exact_matches_to_go)) {
- /* We're done */
- *match = first;
- return MATCH_EXACT;
- }
+ if (!(*exact_matches_to_go)) {
+ /* We're done */
+ *match = first;
+ return MATCH_EXACT;
+ }
} else {
- if (match_type == MATCH_EXACT)
- *match = choose_thing(who, type, flags, *match, first);
- else
- *match = first;
- match_type = MATCH_EXACT;
+ if (match_type == MATCH_EXACT)
+ *match = choose_thing(who, type, flags, *match, first);
+ else
+ *match = first;
+ match_type = MATCH_EXACT;
}
} else if ((match_type != MATCH_EXACT)
- && string_match(Name(first), name)
- && can_interact(first, who, INTERACT_MATCH)) {
+ && string_match(Name(first), name)
+ && can_interact(first, who, INTERACT_MATCH)) {
/* A partial match, and we haven't done an exact match yet */
(*matches_to_go)--;
if (nth_match) {
- if (!(*matches_to_go))
- *match = first;
+ if (!(*matches_to_go))
+ *match = first;
} else if (match_type == MATCH_PARTIAL)
- *match = choose_thing(who, type, flags, *match, first);
+ *match = choose_thing(who, type, flags, *match, first);
else
- *match = first;
+ *match = first;
match_type = MATCH_PARTIAL;
}
}
if (flags & MAT_REMOTES) {
if (GoodObject(loc))
return match_exit_internal(who, name, type, flags, Zone(loc),
- match, exact_matches_to_go, matches_to_go);
+ match, exact_matches_to_go, matches_to_go);
else
return NOTHING;
} else if (flags & MAT_GLOBAL)
return match_exit_internal(who, name, type, flags, MASTER_ROOM,
- match, exact_matches_to_go, matches_to_go);
+ match, exact_matches_to_go, matches_to_go);
/* Recursively search upwards in locations parent tree */
while(GoodObject(loc) && !IsGarbage(loc) && mret != MATCH_EXACT ) {
mret = match_exit_internal(who, name, type, flags, loc,
- match, exact_matches_to_go, matches_to_go);
+ match, exact_matches_to_go, matches_to_go);
loc = Parent(loc);
}
return mret;
(*matches_to_go)--;
return MATCH_EXACT;
} else if (check_alias(name, Name(exit_tmp))
- && (can_interact(exit_tmp, who, INTERACT_MATCH))) {
+ && (can_interact(exit_tmp, who, INTERACT_MATCH))) {
/* Matched an exit alias, but there may be more */
(*exact_matches_to_go)--;
(*matches_to_go)--;
if (nth_match) {
- if (!(*exact_matches_to_go)) {
- /* We're done */
- *match = exit_tmp;
- return MATCH_EXACT;
- }
+ if (!(*exact_matches_to_go)) {
+ /* We're done */
+ *match = exit_tmp;
+ return MATCH_EXACT;
+ }
} else {
- if (match_type == MATCH_EXACT)
- *match = choose_thing(who, type, flags, *match, exit_tmp);
- else
- *match = exit_tmp;
- match_type = MATCH_EXACT;
+ if (match_type == MATCH_EXACT)
+ *match = choose_thing(who, type, flags, *match, exit_tmp);
+ else
+ *match = exit_tmp;
+ match_type = MATCH_EXACT;
}
}
}
if (!GoodObject(who))
return NOTHING;
return match_list(who, name, type, flags, Contents(who), match,
- exact_matches_to_go, matches_to_go);
+ exact_matches_to_go, matches_to_go);
}
MATCH_FUNC(match_container)
if (!GoodObject(who))
return NOTHING;
return match_list(who, name, type, flags, Location(who), match,
- exact_matches_to_go, matches_to_go);
+ exact_matches_to_go, matches_to_go);
}
MATCH_FUNC(match_neighbor)
if (!GoodObject(loc))
return NOTHING;
return match_list(who, name, type, flags, Contents(loc), match,
- exact_matches_to_go, matches_to_go);
+ exact_matches_to_go, matches_to_go);
}
static dbref
choose_thing(const dbref match_who, const int preferred_type, long flags,
- dbref thing1, dbref thing2)
+ dbref thing1, dbref thing2)
{
int has1;
int has2;
if (preferred_type != NOTYPE) {
if (Typeof(thing1) == preferred_type) {
if (Typeof(thing2) != preferred_type)
- return thing1;
+ return thing1;
} else if (Typeof(thing2) == preferred_type)
return thing2;
}
/** A linked list for storing memory allocation counts */
struct mem_check {
- int ref_count; /**< Number of allocations of this type. */
- MEM *next; /**< Pointer to next in linked list. */
- char ref_name[BUFFER_LEN]; /**< Name of this allocation type. */
+ int ref_count; /**< Number of allocations of this type. */
+ MEM *next; /**< Pointer to next in linked list. */
+ char ref_name[BUFFER_LEN]; /**< Name of this allocation type. */
};
static MEM *my_check = NULL;
if (cmp == 0) {
loop->ref_count--;
if (!loop->ref_count) {
- if (!prev)
- my_check = loop->next;
- else
- prev->next = loop->next;
- free(loop);
+ if (!prev)
+ my_check = loop->next;
+ else
+ prev->next = loop->next;
+ free(loop);
}
return;
} else if (cmp < 0)
prev = loop;
}
do_rawlog(LT_CHECK,
- T("ERROR: Tried deleting a check that was never added! :%s\n"),
- ref);
+ T("ERROR: Tried deleting a check that was never added! :%s\n"),
+ ref);
}
/** List allocations.
switch (where) {
case NOTHING:
Location(what) = NOTHING;
- return; /* NOTHING doesn't have contents */
+ return; /* NOTHING doesn't have contents */
case HOME:
- where = Home(what); /* home */
+ where = Home(what); /* home */
safe_tel(what, where, nomovemsgs);
return;
/*NOTREACHED */
if ((where != NOTHING) && (old != where)) {
did_it(what, what, NULL, NULL, "OXMOVE", NULL, NULL, old);
if (Hearer(what) && !nomovemsgs) {
- did_it_interact(what, old, "LEAVE", NULL, "OLEAVE", T("has left."),
- "ALEAVE", old, NA_INTER_PRESENCE);
- /* If the player is leaving a zone, do zone messages */
- /* The tricky bit here is that we only care about the zone of
- * the outermost contents */
- if (GoodObject(absold) && GoodObject(Zone(absold))
- && (Zone(absloc) != Zone(absold)))
- did_it_interact(what, Zone(absold), "ZLEAVE", NULL, "OZLEAVE", NULL,
- "AZLEAVE", old, NA_INTER_SEE);
- if (GoodObject(old) && !IsRoom(old))
- did_it_interact(what, old, NULL, NULL, "OXLEAVE", NULL, NULL, where,
- NA_INTER_SEE);
- if (!IsRoom(where))
- did_it_interact(what, where, NULL, NULL, "OXENTER", NULL, NULL, old,
- NA_INTER_SEE);
- /* If the player is entering a new zone, do zone messages */
- if (!GoodObject(absold)
- || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold))))
- did_it_interact(what, Zone(absloc), "ZENTER", NULL, "OZENTER", NULL,
- "AZENTER", where, NA_INTER_SEE);
- did_it_interact(what, where, "ENTER", NULL, "OENTER", T("has arrived."),
- "AENTER", where, NA_INTER_PRESENCE);
+ did_it_interact(what, old, "LEAVE", NULL, "OLEAVE", T("has left."),
+ "ALEAVE", old, NA_INTER_PRESENCE);
+ /* If the player is leaving a zone, do zone messages */
+ /* The tricky bit here is that we only care about the zone of
+ * the outermost contents */
+ if (GoodObject(absold) && GoodObject(Zone(absold))
+ && (Zone(absloc) != Zone(absold)))
+ did_it_interact(what, Zone(absold), "ZLEAVE", NULL, "OZLEAVE", NULL,
+ "AZLEAVE", old, NA_INTER_SEE);
+ if (GoodObject(old) && !IsRoom(old))
+ did_it_interact(what, old, NULL, NULL, "OXLEAVE", NULL, NULL, where,
+ NA_INTER_SEE);
+ if (!IsRoom(where))
+ did_it_interact(what, where, NULL, NULL, "OXENTER", NULL, NULL, old,
+ NA_INTER_SEE);
+ /* If the player is entering a new zone, do zone messages */
+ if (!GoodObject(absold)
+ || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold))))
+ did_it_interact(what, Zone(absloc), "ZENTER", NULL, "OZENTER", NULL,
+ "AZENTER", where, NA_INTER_SEE);
+ did_it_interact(what, where, "ENTER", NULL, "OENTER", T("has arrived."),
+ "AENTER", where, NA_INTER_PRESENCE);
} else {
- /* non-listeners only trigger the actions not the messages */
- did_it(what, old, NULL, NULL, NULL, NULL, "ALEAVE", old);
- if (GoodObject(absold) && GoodObject(Zone(absold))
- && (Zone(absloc) != Zone(absold)))
- did_it(what, Zone(absold), NULL, NULL, NULL, NULL, "AZLEAVE", old);
- if (!GoodObject(absold)
- || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold))))
- did_it(what, Zone(absloc), NULL, NULL, NULL, NULL, "AZENTER", where);
- did_it(what, where, NULL, NULL, NULL, NULL, "AENTER", where);
+ /* non-listeners only trigger the actions not the messages */
+ did_it(what, old, NULL, NULL, NULL, NULL, "ALEAVE", old);
+ if (GoodObject(absold) && GoodObject(Zone(absold))
+ && (Zone(absloc) != Zone(absold)))
+ did_it(what, Zone(absold), NULL, NULL, NULL, NULL, "AZLEAVE", old);
+ if (!GoodObject(absold)
+ || (GoodObject(Zone(absloc)) && (Zone(absloc) != Zone(absold))))
+ did_it(what, Zone(absloc), NULL, NULL, NULL, NULL, "AZENTER", where);
+ did_it(what, where, NULL, NULL, NULL, NULL, "AENTER", where);
}
}
if (!nomovemsgs)
did_it_interact(what, what, "MOVE", NULL, "OMOVE", NULL, "AMOVE", where,
- NA_INTER_SEE);
+ NA_INTER_SEE);
}
/** A dropper is an object that can hear and has a connected owner */
{
dbref thing;
if (loc == dropto)
- return; /* bizarre special case */
+ return; /* bizarre special case */
if (!IsRoom(loc))
return;
/* check for players */
}
if (loc == player) {
do_rawlog(LT_ERR, T("ERROR: Attempt to move player %d into itself\n"),
- player);
+ player);
deep--;
return;
}
if (recursive_member(loc, player, 0)) {
do_rawlog(LT_ERR,
- T("ERROR: Attempt to move player %d into carried object %d\n"),
- player, loc);
+ T("ERROR: Attempt to move player %d into carried object %d\n"),
+ player, loc);
deep--;
return;
}
* the player.
*/
if (!controls(player, first)
- && (Sticky(first)
- && (Home(first) != player)))
+ && (Sticky(first)
+ && (Home(first) != player)))
enter_room(first, HOME, nomovemsgs);
else {
PUSH(first, Contents(player));
} else {
/* otherwise match on exits - don't use GoodObject here! */
ok = (match_result(player, direction, TYPE_EXIT, MAT_ENGLISH | MAT_EXIT) !=
- NOTHING);
+ NOTHING);
}
return ok;
}
ap = abuf;
bp = buff;
process_expression(buff, &bp, &ap, exit_obj, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
dest_room = parse_objid(buff);
free((Malloc_t) abuf);
/* send him home */
/* but steal all his possessions */
if (!Mobile(player) || !GoodObject(Home(player)) ||
- recursive_member(Home(player), player, 0)
- || (player == Home(player))) {
+ recursive_member(Home(player), player, 0)
+ || (player == Home(player))) {
notify(player, T("Bad destination."));
return;
}
if ((loc = Location(player)) != NOTHING && !Dark(player) && !Dark(loc)) {
/* tell everybody else */
notify_except(Contents(loc), player,
- tprintf(T("%s goes home."), Name(player)), NA_INTER_SEE);
+ tprintf(T("%s goes home."), Name(player)), NA_INTER_SEE);
}
/* give the player the messages */
notify(player, T("There's no place like home..."));
/* find the exit */
if (type == MOVE_GLOBAL)
exit_m =
- match_result(player, direction, TYPE_EXIT,
- MAT_ENGLISH | MAT_EXIT | MAT_GLOBAL | MAT_CHECK_KEYS);
+ match_result(player, direction, TYPE_EXIT,
+ MAT_ENGLISH | MAT_EXIT | MAT_GLOBAL | MAT_CHECK_KEYS);
else if (type == MOVE_ZONE)
exit_m =
- match_result(player, direction, TYPE_EXIT,
- MAT_ENGLISH | MAT_EXIT | MAT_REMOTES | MAT_CHECK_KEYS);
+ match_result(player, direction, TYPE_EXIT,
+ MAT_ENGLISH | MAT_EXIT | MAT_REMOTES | MAT_CHECK_KEYS);
else
exit_m =
- match_result(player, direction, TYPE_EXIT,
- MAT_ENGLISH | MAT_EXIT | MAT_CHECK_KEYS);
+ match_result(player, direction, TYPE_EXIT,
+ MAT_ENGLISH | MAT_EXIT | MAT_CHECK_KEYS);
switch (exit_m) {
case NOTHING:
/* try to force the object */
/* we got one */
/* check to see if we're allowed to pass */
if (!eval_lock(player, Location(player), Leave_Lock)) {
- fail_lock(player, Location(player), Leave_Lock,
- T("You can't go that way."), NOTHING);
- return;
+ fail_lock(player, Location(player), Leave_Lock,
+ T("You can't go that way."), NOTHING);
+ return;
}
if (could_doit(player, exit_m)) {
- switch (Location(exit_m)) {
- case HOME:
- var_dest = Home(player);
- break;
- case AMBIGUOUS:
- var_dest = find_var_dest(player, exit_m);
- /* Only allowed if the owner of the exit could link to var_dest */
- if (!GoodObject(var_dest) || !can_link_to(exit_m, var_dest)) {
- notify_format(player,
- T
- ("Variable exit destination #%d is invalid or not permitted."),
- var_dest);
-
- return;
- }
- break;
- default:
- var_dest = Location(exit_m);
- }
-
- if (!GoodObject(var_dest)) {
- do_rawlog(LT_ERR,
- T("Exit #%d destination became %d during move.\n"),
- exit_m, var_dest);
- notify(player, T("Exit destination is invalid."));
- return;
- }
- if (recursive_member(var_dest, player, 0)) {
- notify(player, T("Exit destination is invalid."));
- return;
- }
- did_it(player, exit_m, "SUCCESS", NULL, "OSUCCESS", NULL,
- "ASUCCESS", NOTHING);
- did_it(player, exit_m, "DROP", NULL, "ODROP", NULL, "ADROP", var_dest);
- switch (Typeof(var_dest)) {
- case TYPE_ROOM:
- /* Remember the current room */
- loc = Location(player);
- /* Move the leader */
- enter_room(player, var_dest, 0);
- /* Move the followers if the leader is elsewhere */
- if (Location(player) != loc)
- follower_command(player, loc, tprintf("%s #%d", "move", exit_m));
- break;
+ switch (Location(exit_m)) {
+ case HOME:
+ var_dest = Home(player);
+ break;
+ case AMBIGUOUS:
+ var_dest = find_var_dest(player, exit_m);
+ /* Only allowed if the owner of the exit could link to var_dest */
+ if (!GoodObject(var_dest) || !can_link_to(exit_m, var_dest)) {
+ notify_format(player,
+ T
+ ("Variable exit destination #%d is invalid or not permitted."),
+ var_dest);
+
+ return;
+ }
+ break;
+ default:
+ var_dest = Location(exit_m);
+ }
+
+ if (!GoodObject(var_dest)) {
+ do_rawlog(LT_ERR,
+ T("Exit #%d destination became %d during move.\n"),
+ exit_m, var_dest);
+ notify(player, T("Exit destination is invalid."));
+ return;
+ }
+ if (recursive_member(var_dest, player, 0)) {
+ notify(player, T("Exit destination is invalid."));
+ return;
+ }
+ did_it(player, exit_m, "SUCCESS", NULL, "OSUCCESS", NULL,
+ "ASUCCESS", NOTHING);
+ did_it(player, exit_m, "DROP", NULL, "ODROP", NULL, "ADROP", var_dest);
+ switch (Typeof(var_dest)) {
+ case TYPE_ROOM:
+ /* Remember the current room */
+ loc = Location(player);
+ /* Move the leader */
+ enter_room(player, var_dest, 0);
+ /* Move the followers if the leader is elsewhere */
+ if (Location(player) != loc)
+ follower_command(player, loc, tprintf("%s #%d", "move", exit_m));
+ break;
case TYPE_DIVISION:
- case TYPE_PLAYER:
- case TYPE_THING:
- if (IsGarbage(var_dest)) {
- notify(player, T("You can't go that way."));
- return;
- }
- if (Location(var_dest) == NOTHING)
- return;
- /* Remember the current room */
- loc = Location(player);
- /* Move the leader */
- safe_tel(player, var_dest, 0);
- /* Move the followers if the leader is elsewhere */
- if (Location(player) != loc)
- follower_command(player, loc, tprintf("%s #%d", "move", exit_m));
- break;
- case TYPE_EXIT:
- notify(player, T("This feature coming soon."));
- break;
- }
+ case TYPE_PLAYER:
+ case TYPE_THING:
+ if (IsGarbage(var_dest)) {
+ notify(player, T("You can't go that way."));
+ return;
+ }
+ if (Location(var_dest) == NOTHING)
+ return;
+ /* Remember the current room */
+ loc = Location(player);
+ /* Move the leader */
+ safe_tel(player, var_dest, 0);
+ /* Move the followers if the leader is elsewhere */
+ if (Location(player) != loc)
+ follower_command(player, loc, tprintf("%s #%d", "move", exit_m));
+ break;
+ case TYPE_EXIT:
+ notify(player, T("This feature coming soon."));
+ break;
+ }
} else
- fail_lock(player, exit_m, Basic_Lock, T("You can't go that way."),
- NOTHING);
+ fail_lock(player, exit_m, Basic_Lock, T("You can't go that way."),
+ NOTHING);
break;
}
}
dbref loc;
if ((thing =
noisy_match_result(player, what, TYPE_EXIT,
- MAT_ENGLISH | MAT_EXIT)) == NOTHING)
+ MAT_ENGLISH | MAT_EXIT)) == NOTHING)
return;
loc = Home(thing);
if (!controls(player, loc)) {
/* take care of possessive get (stealing) */
box = parse_match_possessor(player, &what);
if (box == NOTHING) {
- notify(player, T("I don't see that here."));
- return;
+ notify(player, T("I don't see that here."));
+ return;
} else if (box == AMBIGUOUS) {
- notify_format(player, T("I can't tell which %s."), boxname);
- return;
+ notify_format(player, T("I can't tell which %s."), boxname);
+ return;
}
thing = match_result(box, what, NOTYPE, MAT_POSSESSION);
if (thing == NOTHING) {
- notify(player, T("I don't see that here."));
- return;
+ notify(player, T("I don't see that here."));
+ return;
} else if (thing == AMBIGUOUS) {
- notify_format(player, T("I can't tell which %s."), what);
- return;
+ notify_format(player, T("I can't tell which %s."), what);
+ return;
}
/* to steal something, you have to be able to get it, and the
* object must be ENTER_OK and not take-locked against you.
(POSSGET_ON_DISCONNECTED ||
(!IsPlayer(Location(thing)) ||
Connected(Location(thing)))) &&
- (controls(player, thing) ||
- (EnterOk(Location(thing)) &&
- eval_lock(player, Location(thing), Take_Lock)))) {
- notify_format(Location(thing),
- T("%s was taken from you."), Name(thing));
- notify_format(thing, T("%s took you."), Name(player));
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("You take %s from %s."), Name(thing),
- Name(Location(thing)));
- *tp = '\0';
- tp = tbuf2;
- safe_format(tbuf2, &tp, T("takes %s from %s."), Name(thing),
- Name(Location(thing)));
- *tp = '\0';
- moveto(thing, player);
- did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS",
- NOTHING);
- did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
- "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR);
+ (controls(player, thing) ||
+ (EnterOk(Location(thing)) &&
+ eval_lock(player, Location(thing), Take_Lock)))) {
+ notify_format(Location(thing),
+ T("%s was taken from you."), Name(thing));
+ notify_format(thing, T("%s took you."), Name(player));
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("You take %s from %s."), Name(thing),
+ Name(Location(thing)));
+ *tp = '\0';
+ tp = tbuf2;
+ safe_format(tbuf2, &tp, T("takes %s from %s."), Name(thing),
+ Name(Location(thing)));
+ *tp = '\0';
+ moveto(thing, player);
+ did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS",
+ NOTHING);
+ did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
+ "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR);
} else
- fail_lock(player, thing, Basic_Lock,
- T("You can't take that from there."), NOTHING);
+ fail_lock(player, thing, Basic_Lock,
+ T("You can't take that from there."), NOTHING);
} else {
- notify(player, T("I don't see that here."));
+ notify(player, T("I don't see that here."));
}
return;
} else {
if ((thing = noisy_match_result(player, what, TYPE_THING, match_flags))
- != NOTHING) {
+ != NOTHING) {
if (Location(thing) == player) {
- notify(player, T("You already have that!"));
- return;
+ notify(player, T("You already have that!"));
+ return;
}
if (Location(player) == thing) {
- notify(player, T("It's all around you!"));
- return;
+ notify(player, T("It's all around you!"));
+ return;
}
if (recursive_member(player, thing, 0)) {
- notify(player, T("Bad destination."));
- return;
+ notify(player, T("Bad destination."));
+ return;
}
switch (Typeof(thing)) {
case TYPE_DIVISION:
case TYPE_PLAYER:
case TYPE_THING:
- if (thing == player) {
- notify(player, T("You cannot get yourself!"));
- return;
- }
- if (!eval_lock(player, Location(thing), Take_Lock)) {
- fail_lock(player, Location(thing), Take_Lock,
- T("You can't take that from there."), NOTHING);
- return;
- }
- if (could_doit(player, thing)) {
- moveto(thing, player);
- notify_format(thing, T("%s took you."), Name(player));
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("You take %s."), Name(thing));
- *tp = '\0';
- tp = tbuf2;
- safe_format(tbuf2, &tp, T("takes %s."), Name(thing));
- *tp = '\0';
- did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2,
- "ASUCCESS", NOTHING);
- did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
- "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR);
- } else
- fail_lock(player, thing, Basic_Lock, T("You can't pick that up."),
- NOTHING);
- break;
+ if (thing == player) {
+ notify(player, T("You cannot get yourself!"));
+ return;
+ }
+ if (!eval_lock(player, Location(thing), Take_Lock)) {
+ fail_lock(player, Location(thing), Take_Lock,
+ T("You can't take that from there."), NOTHING);
+ return;
+ }
+ if (could_doit(player, thing)) {
+ moveto(thing, player);
+ notify_format(thing, T("%s took you."), Name(player));
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("You take %s."), Name(thing));
+ *tp = '\0';
+ tp = tbuf2;
+ safe_format(tbuf2, &tp, T("takes %s."), Name(thing));
+ *tp = '\0';
+ did_it(player, thing, "SUCCESS", tbuf1, "OSUCCESS", tbuf2,
+ "ASUCCESS", NOTHING);
+ did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
+ "ARECEIVE", NOTHING, thing, NOTHING, NA_INTER_HEAR);
+ } else
+ fail_lock(player, thing, Basic_Lock, T("You can't pick that up."),
+ NOTHING);
+ break;
case TYPE_EXIT:
- notify(player, T("You can't pick up exits."));
- return;
+ notify(player, T("You can't pick up exits."));
+ return;
default:
- notify(player, T("You can't take that!"));
- break;
+ notify(player, T("You can't take that!"));
+ break;
}
}
}
if ((loc = Location(player)) == NOTHING)
return;
switch (thing =
- match_result(player, name, TYPE_THING,
- MAT_POSSESSION | MAT_ABSOLUTE | MAT_CONTROL |
- MAT_ENGLISH)) {
+ match_result(player, name, TYPE_THING,
+ MAT_POSSESSION | MAT_ABSOLUTE | MAT_CONTROL |
+ MAT_ENGLISH)) {
case NOTHING:
notify(player, T("You don't have that!"));
return;
notify(thing, T("Dropped."));
safe_tel(thing, HOME, 0);
} else if ((Location(loc) != NOTHING) && IsRoom(loc) && !Sticky(loc)
- && eval_lock(thing, loc, Dropto_Lock)) {
+ && eval_lock(thing, loc, Dropto_Lock)) {
/* location has immediate dropto */
notify_format(thing, T("%s drops you."), Name(player));
moveto(thing, Location(loc));
return;
thing =
noisy_match_result(player, what, TYPE_THING | TYPE_PLAYER,
- MAT_NEAR_THINGS | MAT_ENGLISH);
+ MAT_NEAR_THINGS | MAT_ENGLISH);
if (!GoodObject(thing))
return;
thing_loc = Location(thing);
item = first_visible(player, next)) {
next = Next(item);
if (IsExit(item))
- continue; /* No dropping exits */
+ continue; /* No dropping exits */
empty_ok = 0;
if (player == thing) {
/* empty me: You don't need to get what's in your inventory already */
if (eval_lock(player, item, Drop_Lock) &&
- (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock)))
- empty_ok = 1;
+ (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock)))
+ empty_ok = 1;
}
/* Check that player can get stuff from thing */
else if (controls(player, thing) ||
- (EnterOk(thing) && eval_lock(player, thing, Enter_Lock))) {
+ (EnterOk(thing) && eval_lock(player, thing, Enter_Lock))) {
/* Check that player can get item */
if (!could_doit(player, item)) {
- /* Send failure message if set, otherwise be quiet */
- fail_lock(player, thing, Basic_Lock, NULL, NOTHING);
- continue;
+ /* Send failure message if set, otherwise be quiet */
+ fail_lock(player, thing, Basic_Lock, NULL, NOTHING);
+ continue;
}
/* Now check for dropping in the destination */
/* Thing is in player's inventory - sufficient */
if (thing_loc == player)
- empty_ok = 1;
+ empty_ok = 1;
/* Thing is in player's location - player must also be able to drop */
else if (eval_lock(player, item, Drop_Lock) &&
- (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock)))
- empty_ok = 1;
+ (!IsRoom(thing_loc) || eval_lock(player, thing_loc, Drop_Lock)))
+ empty_ok = 1;
}
/* Now do the work, if we should. That includes triggering messages */
if (empty_ok) {
count++;
/* Get messages */
if (thing != player) {
- notify_format(thing, T("%s was taken from you."), Name(item));
- notify_format(item, T("%s took you."), Name(player));
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("You take %s from %s."), Name(item),
- Name(thing));
- *tp = '\0';
- tp = tbuf2;
- safe_format(tbuf2, &tp, T("takes %s from %s."), Name(item),
- Name(thing));
- *tp = '\0';
- moveto(item, player);
- did_it(player, item, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS",
- NOTHING);
- did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
- "ARECEIVE", NOTHING, item, NOTHING, NA_INTER_HEAR);
+ notify_format(thing, T("%s was taken from you."), Name(item));
+ notify_format(item, T("%s took you."), Name(player));
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("You take %s from %s."), Name(item),
+ Name(thing));
+ *tp = '\0';
+ tp = tbuf2;
+ safe_format(tbuf2, &tp, T("takes %s from %s."), Name(item),
+ Name(thing));
+ *tp = '\0';
+ moveto(item, player);
+ did_it(player, item, "SUCCESS", tbuf1, "OSUCCESS", tbuf2, "ASUCCESS",
+ NOTHING);
+ did_it_with(player, player, "RECEIVE", NULL, "ORECEIVE", NULL,
+ "ARECEIVE", NOTHING, item, NOTHING, NA_INTER_HEAR);
}
/* Drop messages */
if (thing_loc != player) {
- if (Sticky(item) && !Fixed(item)) {
- safe_tel(thing, HOME, 0);
- } else if ((Location(thing_loc) != NOTHING) && IsRoom(thing_loc)
- && !Sticky(thing_loc)
- && eval_lock(item, thing_loc, Dropto_Lock)) {
- /* location has immediate dropto */
- notify_format(item, T("%s drops you."), Name(player));
- moveto(item, Location(thing_loc));
- } else {
- notify_format(item, T("%s drops you."), Name(player));
- moveto(item, thing_loc);
- }
- tp = tbuf1;
- safe_format(tbuf1, &tp, T("You drop %s."), Name(item));
- *tp = '\0';
- tp = tbuf2;
- safe_format(tbuf2, &tp, T("drops %s."), Name(item));
- *tp = '\0';
- did_it(player, item, "DROP", tbuf1, "ODROP", tbuf2, "ADROP", NOTHING);
+ if (Sticky(item) && !Fixed(item)) {
+ safe_tel(thing, HOME, 0);
+ } else if ((Location(thing_loc) != NOTHING) && IsRoom(thing_loc)
+ && !Sticky(thing_loc)
+ && eval_lock(item, thing_loc, Dropto_Lock)) {
+ /* location has immediate dropto */
+ notify_format(item, T("%s drops you."), Name(player));
+ moveto(item, Location(thing_loc));
+ } else {
+ notify_format(item, T("%s drops you."), Name(player));
+ moveto(item, thing_loc);
+ }
+ tp = tbuf1;
+ safe_format(tbuf1, &tp, T("You drop %s."), Name(item));
+ *tp = '\0';
+ tp = tbuf2;
+ safe_format(tbuf2, &tp, T("drops %s."), Name(item));
+ *tp = '\0';
+ did_it(player, item, "DROP", tbuf1, "ODROP", tbuf2, "ADROP", NOTHING);
}
}
}
notify_format(player, T("You remove %d object%s from %s."),
- count, (count == 1) ? "" : "s", Name(thing));
+ count, (count == 1) ? "" : "s", Name(thing));
return;
}
/* the object must pass the lock. Also, the thing being entered */
/* has to be controlled, or must be enter_ok */
if (!((EnterOk(thing) || controls(player, thing)) &&
- (eval_lock(player, thing, Enter_Lock))
- )) {
+ (eval_lock(player, thing, Enter_Lock))
+ )) {
fail_lock(player, thing, Enter_Lock, T("Permission denied."), NOTHING);
return;
}
global_exit(dbref player, const char *direction)
{
return (GoodObject
- (match_result(player, direction, TYPE_EXIT, MAT_GLOBAL | MAT_EXIT)));
+ (match_result(player, direction, TYPE_EXIT, MAT_GLOBAL | MAT_EXIT)));
}
/** Is direction a remote exit?
remote_exit(dbref player, const char *direction)
{
return (GoodObject
- (match_result(player, direction, TYPE_EXIT, MAT_REMOTES | MAT_EXIT)));
+ (match_result(player, direction, TYPE_EXIT, MAT_REMOTES | MAT_EXIT)));
}
/** Wrapper for exit movement.
else if ((Zone(Location(player)) != NOTHING) && remote_exit(player, command))
do_move(player, command, 2);
else if ((Location(player) != MASTER_ROOM)
- && global_exit(player, command))
+ && global_exit(player, command))
do_move(player, command, 1);
else
do_move(player, command, 0);
return;
}
if (!GoodObject(leader) || !GoodObject(Location(player))
- || (IsPlayer(leader) && !Connected(leader))
- || ((DarkLegal(leader)
- || (Dark(Location(player)) && !Light(leader)))
- && !CanSee(player, leader))) {
+ || (IsPlayer(leader) && !Connected(leader))
+ || ((DarkLegal(leader)
+ || (Dark(Location(player)) && !Light(leader)))
+ && !CanSee(player, leader))) {
notify(player, T("You don't see that here."));
return;
}
/* Ok, are we allowed to follow them? */
if (!eval_lock(player, leader, Follow_Lock)) {
fail_lock(player, leader, Follow_Lock,
- T("You're not alllowed to follow."), Location(player));
+ T("You're not alllowed to follow."), Location(player));
return;
}
/* Ok, looks good */
}
/* Are we following or leading them? */
if (!is_following(who, player)
- && !is_following(player, who)) {
+ && !is_following(player, who)) {
notify_format(player,
- T("%s isn't following you, nor vice versa."), Name(who));
+ T("%s isn't following you, nor vice versa."), Name(who));
return;
}
/* Ok, looks good */
strcpy(msg, tprintf(T("You begin following %s."), Name(leader)));
notify_format(leader, T("%s begins following you."), Name(follower));
did_it(follower, leader, "FOLLOW", msg, "OFOLLOW", NULL,
- "AFOLLOW", NOTHING);
+ "AFOLLOW", NOTHING);
}
}
char flwr[BUFFER_LEN];
a = atr_get_noparent(leader, "FOLLOWERS");
if (!a)
- return; /* No followers, so no deletion */
+ return; /* No followers, so no deletion */
/* Let's take it apart and put it back together w/o follower */
strcpy(flwr, unparse_dbref(follower));
strcpy(tbuf1, atr_value(a));
(void) atr_add(leader, "FOLLOWERS",
- remove_word(tbuf1, flwr, ' '), GOD, NOTHING);
+ remove_word(tbuf1, flwr, ' '), GOD, NOTHING);
}
/* Delete someone from a player's FOLLOWING attribute */
char ldr[BUFFER_LEN];
a = atr_get_noparent(follower, "FOLLOWING");
if (!a)
- return; /* Not following, so no deletion */
+ return; /* Not following, so no deletion */
/* Let's take it apart and put it back together w/o leader */
strcpy(ldr, unparse_dbref(leader));
strcpy(tbuf1, atr_value(a));
(void) atr_add(follower, "FOLLOWING",
- remove_word(tbuf1, ldr, ' '), GOD, NOTHING);
+ remove_word(tbuf1, ldr, ' '), GOD, NOTHING);
}
static void
strcpy(msg, tprintf(T("You stop following %s."), Name(leader)));
notify_format(leader, T("%s stops following you."), Name(follower));
did_it(follower, leader, "UNFOLLOW", msg, "OUNFOLLOW",
- NULL, "AUNFOLLOW", NOTHING);
+ NULL, "AUNFOLLOW", NOTHING);
}
}
who = parse_dbref(sp);
if (GoodObject(who)) {
if (!first)
- safe_str(", ", buff, &bp);
+ safe_str(", ", buff, &bp);
safe_str(Name(who), buff, &bp);
first = 0;
}
who = parse_dbref(sp);
if (GoodObject(who)) {
if (!first)
- safe_str(", ", buff, &bp);
+ safe_str(", ", buff, &bp);
safe_str(Name(who), buff, &bp);
first = 0;
}
*/
a = atr_get_noparent(follower, "FOLLOWING");
if (!a)
- return 0; /* Following no one */
+ return 0; /* Following no one */
strcpy(tbuf1, atr_value(a));
s = trim_space_sep(tbuf1, ' ');
while (s) {
dbref flwr;
a = atr_get_noparent(leader, "FOLLOWERS");
if (!a)
- return; /* No one's following me */
+ return; /* No one's following me */
strcpy(tbuf1, atr_value(a));
s = trim_space_sep(tbuf1, ' ');
while (s) {
if (GoodObject(flwr)) {
del_following(flwr, leader);
if (noisy)
- notify_format(flwr, T("You stop following %s."), Name(leader));
+ notify_format(flwr, T("You stop following %s."), Name(leader));
}
}
(void) atr_clr(leader, "FOLLOWERS", GOD);
dbref ldr;
a = atr_get_noparent(follower, "FOLLOWING");
if (!a)
- return; /* I'm not following anyone */
+ return; /* I'm not following anyone */
strcpy(tbuf1, atr_value(a));
s = trim_space_sep(tbuf1, ' ');
while (s) {
if (GoodObject(ldr)) {
del_follower(ldr, follower);
if (noisy)
- notify_format(ldr, T("%s stops following you."), Name(follower));
+ notify_format(ldr, T("%s stops following you."), Name(follower));
}
}
(void) atr_clr(follower, "FOLLOWING", GOD);
sp = split_token(&s, ' ');
cur_obj = parse_dbref(sp);
if(GoodObject(cur_obj) && Location(cur_obj) == loc && Leave_Behind(cur_obj)) {
- /* K.. we found someone we suppose to be following.. Trigger unfollow on them */
- do_unfollow(leader, unparse_dbref(cur_obj));
+ /* K.. we found someone we suppose to be following.. Trigger unfollow on them */
+ do_unfollow(leader, unparse_dbref(cur_obj));
}
}
return;
sp = split_token(&s, ' ');
cur_obj = parse_dbref(sp);
if (GoodObject(cur_obj) && (Location(cur_obj) == loc)
- && (Connected(cur_obj) || IsThing(cur_obj))
- && (!(DarkLegal(leader)
- || (Dark(Location(cur_obj)) && !Light(leader)))
- || CanSee(cur_obj, leader))) {
+ && (Connected(cur_obj) || IsThing(cur_obj))
+ && (!(DarkLegal(leader)
+ || (Dark(Location(cur_obj)) && !Light(leader)))
+ || CanSee(cur_obj, leader))) {
/* This is a follower who was in the room with the leader. Follow. */
notify_format(cur_obj, T("You follow %s."), Name(leader));
process_command(cur_obj, combuf, cur_obj, cur_obj, 0);
// success code
if (SWIG_IsNewObj(res) {
...
- delete *ptr;
+ delete *ptr;
} else {
...
}
also requires SWIG_ConvertPtr to return new result values, such as
int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
+ if (<obj is ok>) {
+ if (<need new object>) {
*ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = <ptr to old object>;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
}
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
/* Structure to store information on one type */
typedef struct swig_type_info {
- const char *name; /* mangled name of this type */
- const char *str; /* human readable name of this type */
- swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
- struct swig_cast_info *cast; /* linked list of types that can cast into this type */
- void *clientdata; /* language specific type data */
- int owndata; /* flag if the structure owns the clientdata */
+ const char *name; /* mangled name of this type */
+ const char *str; /* human readable name of this type */
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
+ void *clientdata; /* language specific type data */
+ int owndata; /* flag if the structure owns the clientdata */
} swig_type_info;
/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
- swig_type_info *type; /* pointer to type that is equivalent to this type */
- swig_converter_func converter; /* function to cast the void pointers */
- struct swig_cast_info *next; /* pointer to next cast in linked list */
- struct swig_cast_info *prev; /* pointer to the previous cast */
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
+ swig_converter_func converter; /* function to cast the void pointers */
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
+ struct swig_cast_info *prev; /* pointer to the previous cast */
} swig_cast_info;
/* Structure used to store module information
* Each module generates one structure like this, and the runtime collects
* all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
- swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
- size_t size; /* Number of types in this module */
- struct swig_module_info *next; /* Pointer to next element in circularly linked list */
- swig_type_info **type_initial; /* Array of initially generated type structures */
- swig_cast_info **cast_initial; /* Array of initially generated casting structures */
- void *clientdata; /* Language specific module data */
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
+ size_t size; /* Number of types in this module */
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
+ swig_type_info **type_initial; /* Array of initially generated type structures */
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
+ void *clientdata; /* Language specific module data */
} swig_module_info;
/*
*/
SWIGRUNTIME int
SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
+ const char *f2, const char *l2) {
for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
while ((*f1 == ' ') && (f1 != l1)) ++f1;
while ((*f2 == ' ') && (f2 != l2)) ++f2;
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
- SWIG_TypeClientData(tc, clientdata);
+ SWIG_TypeClientData(tc, clientdata);
}
}
cast = cast->next;
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
- const char *name) {
+ const char *name) {
swig_module_info *iter = start;
do {
if (iter->size) {
register size_t l = 0;
register size_t r = iter->size - 1;
do {
- /* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
- const char *iname = iter->types[i]->name;
- if (iname) {
- register int compare = strcmp(name, iname);
- if (compare == 0) {
- return iter->types[i];
- } else if (compare < 0) {
- if (i) {
- r = i - 1;
- } else {
- break;
- }
- } else if (compare > 0) {
- l = i + 1;
- }
- } else {
- break; /* should never happen */
- }
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ register size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ register int compare = strcmp(name, iname);
+ if (compare == 0) {
+ return iter->types[i];
+ } else if (compare < 0) {
+ if (i) {
+ r = i - 1;
+ } else {
+ break;
+ }
+ } else if (compare > 0) {
+ l = i + 1;
+ }
+ } else {
+ break; /* should never happen */
+ }
} while (l <= r);
}
iter = iter->next;
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
- const char *name) {
+ const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
if (ret) {
do {
register size_t i = 0;
for (; i < iter->size; ++i) {
- if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
- return iter->types[i];
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+ return iter->types[i];
}
iter = iter->next;
} while (iter != end);
swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
}
- }
+ }
}
/* performs the entire class registration process */
if (str==0 || str[0]==0) return 0; /* nothing to do */
top=lua_gettop(L); /* save stack */
#if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
- ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */
+ ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */
#else
- ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */
+ ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */
#endif
if (ok!=0) {
SWIG_DOSTRING_FAIL(lua_tostring(L,-1));
printf("SWIG_InitializeModule: found type %s\n", type->name);
#endif
if (swig_module.type_initial[i]->clientdata) {
- type->clientdata = swig_module.type_initial[i]->clientdata;
+ type->clientdata = swig_module.type_initial[i]->clientdata;
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
#endif
if (swig_module.next != &swig_module) {
ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
#ifdef SWIGRUNTIME_DEBUG
- if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
#endif
}
if (ret) {
- if (type == swig_module.type_initial[i]) {
+ if (type == swig_module.type_initial[i]) {
#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
#endif
- cast->type = ret;
- ret = 0;
- } else {
- /* Check for casting already in the list */
- swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+ cast->type = ret;
+ ret = 0;
+ } else {
+ /* Check for casting already in the list */
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
#ifdef SWIGRUNTIME_DEBUG
- if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
#endif
- if (!ocast) ret = 0;
- }
+ if (!ocast) ret = 0;
+ }
}
if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
#endif
if (type->cast) {
type->cast->prev = cast;
static char port[NI_MAXSERV];
if (getnameinfo(host, len, hostname, sizeof hostname, port, sizeof port,
- (USE_DNS ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV) != 0) {
+ (USE_DNS ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV) != 0) {
return NULL;
}
hi.hostname = hostname;
static char port[NI_MAXSERV];
if (getnameinfo(host, len, hostname, sizeof hostname, port, sizeof port,
- NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
return NULL;
}
hi.hostname = hostname;
hi.port = port;
return &hi;
}
-#endif /* INFOSLAVE */
+#endif /* INFOSLAVE */
/** Open a tcp connection to a given host and port. Basically
* tcp_connect from UNPv1
*/
int
make_socket_conn(const char *host, struct sockaddr *myiterface,
- socklen_t myilen, Port_t port, int *timeout)
+ socklen_t myilen, Port_t port, int *timeout)
{
struct addrinfo hints, *server, *save;
char cport[NI_MAXSERV];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
- hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */
+ hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */
hints.ai_socktype = SOCK_STREAM;
sprintf(cport, "%hu", port);
if (myiterface && myilen > 0) {
/* Bind to a specific interface. Needed for ident lookups */
if (bind(s, myiterface, myilen) < 0)
- perror("bind failed (Possibly harmless)");
+ perror("bind failed (Possibly harmless)");
}
if ((err = connect_nonb(s, server->ai_addr, server->ai_addrlen, timeout)) ==
- 0)
+ 0)
break;
#ifdef DEBUG
*/
int
make_socket(Port_t port, union sockaddr_u *addr, socklen_t *len,
- const char *host)
+ const char *host)
{
int s, opt, ipv = 4;
/* Use getaddrinfo() to fill in the sockaddr fields. This
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
#ifdef FORCE_IPV4
- hints.ai_family = AF_INET; /* OpenBSD apparently doesn't properly
- map IPv4 connections to IPv6 servers. */
+ hints.ai_family = AF_INET; /* OpenBSD apparently doesn't properly
+ map IPv4 connections to IPv6 servers. */
#else
- hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */
+ hints.ai_family = AF_UNSPEC; /* Try to use IPv6 if available */
#endif
hints.ai_socktype = SOCK_STREAM;
}
if (bind(s, server->ai_addr, server->ai_addrlen) == 0)
- break; /* Success */
+ break; /* Success */
perror("binding stream socket (Possibly ignorable)");
closesocket(s);
}
if (fcntl(s, F_SETFL, flags | O_NDELAY) == -1) {
-#endif /* WIN32 */
+#endif /* WIN32 */
perror("make_nonblocking: fcntl");
#ifndef INFOSLAVE
mush_panic("O_NDELAY fcntl failed");
/* enable TCP keepalive */
if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
- (void *) &keepalive, sizeof(keepalive)) == -1)
+ (void *) &keepalive, sizeof(keepalive)) == -1)
fprintf(stderr, "[%d] could not set SO_KEEPALIVE: errno %d", s, errno);
/* And set the ping time to something reasonable instead of the
this. OS X and possibly others use TCP_KEEPALIVE. */
#if defined(TCP_KEEPIDLE)
if (setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE,
- (void *) &keepidle, sizeof(keepidle)) == -1)
+ (void *) &keepidle, sizeof(keepidle)) == -1)
fprintf(stderr, "[%d] could not set TCP_KEEPIDLE: errno %d", s, errno);
#elif defined(TCP_KEEPALIVE)
if (setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE,
- (void *) &keepidle, sizeof(keepidle)) == -1)
+ (void *) &keepidle, sizeof(keepidle)) == -1)
fprintf(stderr, "[%d] could not set TCP_KEEPALIVE: errno %d", s, errno);
#endif
#endif
*/
int
connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen,
- int *timeout)
+ int *timeout)
{
int n, error;
time_t start, end;
time(&start);
if ((n = select(sockfd + 1, &rset, &wset, NULL, &tval)) == 0) {
- closesocket(sockfd); /* timeout */
+ closesocket(sockfd); /* timeout */
errno = ETIMEDOUT;
return -1;
}
if (FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) {
len = sizeof(error);
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (__ptr_t) &error, &len) < 0)
- return -1; /* Solaris pending error */
+ return -1; /* Solaris pending error */
} else
return -1;
done:
if (error) {
- closesocket(sockfd); /* just in case */
+ closesocket(sockfd); /* just in case */
errno = error;
return -1;
}
#define INT16SZ 2
#ifndef AF_INET6
-#define AF_INET6 AF_MAX+1 /* just to let this compile */
+#define AF_INET6 AF_MAX+1 /* just to let this compile */
#endif
/*
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
- cur.base = i, cur.len = 1;
+ cur.base = i, cur.len = 1;
else
- cur.len++;
+ cur.len++;
} else {
if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
}
}
}
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
if (i == best.base)
- *tp++ = ':';
+ *tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
+ return (NULL);
tp += strlen(tp);
break;
}
unsigned int new = *tp * 10 + (pch - digits);
if (new > 255)
- return (0);
+ return (0);
*tp = new;
if (!saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
+ if (++octets > 4)
+ return (0);
+ saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
- return (0);
+ return (0);
*++tp = 0;
saw_digit = 0;
} else
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
- return (0);
+ return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
}
if (tp + INT16SZ > endp)
- return (0);
+ return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
saw_xdigit = 0;
if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) {
tp += INADDRSZ;
saw_xdigit = 0;
- break; /* '\0' was seen by inet_pton4(). */
+ break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
#ifndef HAS_GETNAMEINFO
static int gn_ipv46(char *, size_t, char *, size_t, void *, size_t,
- int, int, int);
+ int, int, int);
/*
* Handle either an IPv4 or an IPv6 address and port.
/* include gn_ipv46 */
static int
gn_ipv46(char *host, size_t hostlen, char *serv, size_t servlen,
- void *aptr, size_t alen, int family, int port, int flags)
+ void *aptr, size_t alen, int family, int port, int flags)
{
char *ptr;
struct hostent *hptr;
if (hostlen > 0) {
if (flags & NI_NUMERICHOST) {
if (inet_ntop(family, aptr, host, hostlen) == NULL)
- return (1);
+ return (1);
} else {
hptr = gethostbyaddr(aptr, alen, family);
if (hptr != NULL && hptr->h_name != NULL) {
- if (flags & NI_NOFQDN) {
- if ((ptr = strchr(hptr->h_name, '.')) != NULL)
- *ptr = 0; /* overwrite first dot */
- }
+ if (flags & NI_NOFQDN) {
+ if ((ptr = strchr(hptr->h_name, '.')) != NULL)
+ *ptr = 0; /* overwrite first dot */
+ }
#ifdef HAS_SNPRINTF
- snprintf(host, hostlen, "%s", hptr->h_name);
+ snprintf(host, hostlen, "%s", hptr->h_name);
#else
- strncpy(host, hptr->h_name, hostlen);
- host[hostlen - 1] = '\0';
+ strncpy(host, hptr->h_name, hostlen);
+ host[hostlen - 1] = '\0';
#endif
} else {
- if (flags & NI_NAMEREQD)
- return (1);
- if (inet_ntop(family, aptr, host, hostlen) == NULL)
- return (1);
+ if (flags & NI_NAMEREQD)
+ return (1);
+ if (inet_ntop(family, aptr, host, hostlen) == NULL)
+ return (1);
}
}
}
/* include getnameinfo */
int
getnameinfo(const struct sockaddr *sa, socklen_t salen,
- char *host, size_t hostlen, char *serv, size_t servlen, int flags)
+ char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
switch (sa->sa_family) {
struct sockaddr_in *sain = (struct sockaddr_in *) sa;
return (gn_ipv46(host, hostlen, serv, servlen,
- &sain->sin_addr, sizeof(struct in_addr),
- AF_INET, sain->sin_port, flags));
+ &sain->sin_addr, sizeof(struct in_addr),
+ AF_INET, sain->sin_port, flags));
}
#endif
struct sockaddr_in6 *sain = (struct sockaddr_in6 *) sa;
return (gn_ipv46(host, hostlen, serv, servlen,
- &sain->sin6_addr, sizeof(struct in6_addr),
- AF_INET6, sain->sin6_port, flags));
+ &sain->sin6_addr, sizeof(struct in6_addr),
+ AF_INET6, sain->sin6_port, flags));
}
#endif
/* include ga1 */
struct search {
- const char *host; /* hostname or address string */
- int family; /* AF_xxx */
+ const char *host; /* hostname or address string */
+ int family; /* AF_xxx */
};
static int ga_aistruct(struct addrinfo ***, const struct addrinfo *,
- const void *, int);
+ const void *, int);
static struct addrinfo *ga_clone(struct addrinfo *);
static int ga_echeck(const char *, const char *, int, int, int, int);
static int ga_nsearch(const char *, const struct addrinfo *, struct search *);
int
getaddrinfo(const char *hostname, const char *servname,
- const struct addrinfo *hintsp, struct addrinfo **result)
+ const struct addrinfo *hintsp, struct addrinfo **result)
{
int rc, error, nsearch;
char **ap, *canon;
*/
#define error(e) { error = (e); goto bad; }
- aihead = NULL; /* initialize automatic variables */
+ aihead = NULL; /* initialize automatic variables */
aipnext = &aihead;
canon = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
} else
- hints = *hintsp; /* struct copy */
+ hints = *hintsp; /* struct copy */
/* 4first some basic error checking */
if ((rc = ga_echeck(hostname, servname, hints.ai_flags, hints.ai_family,
- hints.ai_socktype, hints.ai_protocol)) != 0)
+ hints.ai_socktype, hints.ai_protocol)) != 0)
error(rc);
/* end ga1 */
struct in_addr inaddr;
if (inet_pton(AF_INET, sptr->host, &inaddr) == 1) {
- if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET)
- error(EAI_ADDRFAMILY);
- if (sptr->family != AF_INET)
- continue; /* ignore */
- rc = ga_aistruct(&aipnext, &hints, &inaddr, AF_INET);
- if (rc != 0)
- error(rc);
- continue;
+ if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET)
+ error(EAI_ADDRFAMILY);
+ if (sptr->family != AF_INET)
+ continue; /* ignore */
+ rc = ga_aistruct(&aipnext, &hints, &inaddr, AF_INET);
+ if (rc != 0)
+ error(rc);
+ continue;
}
}
#endif
#ifdef HAS_IPV6
/* 4check for an IPv6 hex string */
if ((isxdigit((unsigned char) sptr->host[0]) || sptr->host[0] == ':') &&
- (strchr(sptr->host, ':') != NULL)) {
+ (strchr(sptr->host, ':') != NULL)) {
struct in6_addr in6addr;
if (inet_pton(AF_INET6, sptr->host, &in6addr) == 1) {
- if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6)
- error(EAI_ADDRFAMILY);
- if (sptr->family != AF_INET6)
- continue; /* ignore */
- rc = ga_aistruct(&aipnext, &hints, &in6addr, AF_INET6);
- if (rc != 0)
- error(rc);
- continue;
+ if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6)
+ error(EAI_ADDRFAMILY);
+ if (sptr->family != AF_INET6)
+ continue; /* ignore */
+ rc = ga_aistruct(&aipnext, &hints, &in6addr, AF_INET6);
+ if (rc != 0)
+ error(rc);
+ continue;
}
}
#endif
/* 4remainder of for() to look up hostname */
#ifdef HAS_IPV6
if ((_res.options & RES_INIT) == 0)
- res_init(); /* need this to set _res.options */
+ res_init(); /* need this to set _res.options */
#endif
if (nsearch == 2) {
} else {
#ifdef HAS_IPV6
if (sptr->family == AF_INET6)
- _res.options |= RES_USE_INET6;
+ _res.options |= RES_USE_INET6;
else
- _res.options &= ~RES_USE_INET6;
+ _res.options &= ~RES_USE_INET6;
#endif
hptr = gethostbyname(sptr->host);
}
if (hptr == NULL) {
if (nsearch == 2)
- continue; /* failure OK if multiple searches */
+ continue; /* failure OK if multiple searches */
switch (h_errno) {
case HOST_NOT_FOUND:
- error(EAI_NONAME);
+ error(EAI_NONAME);
case TRY_AGAIN:
- error(EAI_AGAIN);
+ error(EAI_AGAIN);
case NO_RECOVERY:
- error(EAI_FAIL);
+ error(EAI_FAIL);
case NO_DATA:
- error(EAI_NODATA);
+ error(EAI_NODATA);
default:
- error(EAI_NONAME);
+ error(EAI_NONAME);
}
}
/* 4save canonical name first time */
if (hostname != NULL && hostname[0] != '\0' &&
- (hints.ai_flags & AI_CANONNAME) && canon == NULL) {
+ (hints.ai_flags & AI_CANONNAME) && canon == NULL) {
if ((canon = strdup(hptr->h_name)) == NULL)
- error(EAI_MEMORY);
+ error(EAI_MEMORY);
}
/* 4create one addrinfo{} for each returned address */
for (ap = hptr->h_addr_list; *ap != NULL; ap++) {
rc = ga_aistruct(&aipnext, &hints, *ap, hptr->h_addrtype);
if (rc != 0)
- error(rc);
+ error(rc);
}
}
if (aihead == NULL)
- error(EAI_NONAME); /* nothing found */
+ error(EAI_NONAME); /* nothing found */
/* end ga4 */
/* include ga5 */
/* 4return canonical name */
if (hostname != NULL && hostname[0] != '\0' && hints.ai_flags & AI_CANONNAME) {
if (canon != NULL)
- aihead->ai_canonname = canon; /* strdup'ed earlier */
+ aihead->ai_canonname = canon; /* strdup'ed earlier */
else {
if ((aihead->ai_canonname = strdup(search[0].host)) == NULL)
- error(EAI_MEMORY);
+ error(EAI_MEMORY);
}
}
error(rc);
}
- *result = aihead; /* pointer to first structure in linked list */
+ *result = aihead; /* pointer to first structure in linked list */
return (0);
bad:
- freeaddrinfo(aihead); /* free any alloc'ed memory */
+ freeaddrinfo(aihead); /* free any alloc'ed memory */
return (error);
}
/* include ga_echeck */
static int
ga_echeck(const char *hostname, const char *servname,
- int flags, int family, int socktype, int protocol)
+ int flags, int family, int socktype, int protocol)
{
if (flags & ~(AI_PASSIVE | AI_CANONNAME))
- return (EAI_BADFLAGS); /* unknown flag bits */
+ return (EAI_BADFLAGS); /* unknown flag bits */
if (hostname == NULL || hostname[0] == '\0') {
if (servname == NULL || servname[0] == '\0')
- return (EAI_NONAME); /* host or service must be specified */
+ return (EAI_NONAME); /* host or service must be specified */
}
switch (family) {
#ifdef IPv4
case AF_INET:
if (socktype != 0 &&
- (socktype != SOCK_STREAM &&
- socktype != SOCK_DGRAM && socktype != SOCK_RAW))
- return (EAI_SOCKTYPE); /* invalid socket type */
+ (socktype != SOCK_STREAM &&
+ socktype != SOCK_DGRAM && socktype != SOCK_RAW))
+ return (EAI_SOCKTYPE); /* invalid socket type */
break;
#endif
#ifdef HAS_IPV6
case AF_INET6:
if (socktype != 0 &&
- (socktype != SOCK_STREAM &&
- socktype != SOCK_DGRAM && socktype != SOCK_RAW))
- return (EAI_SOCKTYPE); /* invalid socket type */
+ (socktype != SOCK_STREAM &&
+ socktype != SOCK_DGRAM && socktype != SOCK_RAW))
+ return (EAI_SOCKTYPE); /* invalid socket type */
break;
#endif
default:
- return (EAI_FAMILY); /* unknown protocol family */
+ return (EAI_FAMILY); /* unknown protocol family */
}
return (0);
}
/* include ga_nsearch1 */
static int
ga_nsearch(const char *hostname, const struct addrinfo *hintsp,
- struct search *search)
+ struct search *search)
{
int nsearch = 0;
switch (hintsp->ai_family) {
#ifdef IPv4
case AF_INET:
- search[nsearch].host = "0.0.0.0";
- search[nsearch].family = AF_INET;
- nsearch++;
- break;
+ search[nsearch].host = "0.0.0.0";
+ search[nsearch].family = AF_INET;
+ nsearch++;
+ break;
#endif
#ifdef HAS_IPV6
case AF_INET6:
- search[nsearch].host = "0::0";
- search[nsearch].family = AF_INET6;
- nsearch++;
- break;
+ search[nsearch].host = "0::0";
+ search[nsearch].family = AF_INET6;
+ nsearch++;
+ break;
#endif
case AF_UNSPEC:
#ifdef HAS_IPV6
- search[nsearch].host = "0::0"; /* IPv6 first, then IPv4 */
- search[nsearch].family = AF_INET6;
- nsearch++;
+ search[nsearch].host = "0::0"; /* IPv6 first, then IPv4 */
+ search[nsearch].family = AF_INET6;
+ nsearch++;
#endif
#ifdef IPv4
- search[nsearch].host = "0.0.0.0";
- search[nsearch].family = AF_INET;
- nsearch++;
+ search[nsearch].host = "0.0.0.0";
+ search[nsearch].family = AF_INET;
+ nsearch++;
#endif
- break;
+ break;
}
/* end ga_nsearch1 */
/* include ga_nsearch2 */
switch (hintsp->ai_family) {
#ifdef IPv4
case AF_INET:
- search[nsearch].host = "localhost"; /* 127.0.0.1 */
- search[nsearch].family = AF_INET;
- nsearch++;
- break;
+ search[nsearch].host = "localhost"; /* 127.0.0.1 */
+ search[nsearch].family = AF_INET;
+ nsearch++;
+ break;
#endif
#ifdef HAS_IPV6
case AF_INET6:
- search[nsearch].host = "0::1";
- search[nsearch].family = AF_INET6;
- nsearch++;
- break;
+ search[nsearch].host = "0::1";
+ search[nsearch].family = AF_INET6;
+ nsearch++;
+ break;
#endif
case AF_UNSPEC:
#ifdef HAS_IPV6
- search[nsearch].host = "0::1"; /* IPv6 first, then IPv4 */
- search[nsearch].family = AF_INET6;
- nsearch++;
+ search[nsearch].host = "0::1"; /* IPv6 first, then IPv4 */
+ search[nsearch].family = AF_INET6;
+ nsearch++;
#endif
#ifdef IPv4
- search[nsearch].host = "localhost";
- search[nsearch].family = AF_INET;
- nsearch++;
+ search[nsearch].host = "localhost";
+ search[nsearch].family = AF_INET;
+ nsearch++;
#endif
- break;
+ break;
}
}
/* end ga_nsearch2 */
/* include ga_nsearch3 */
- } else { /* host is specified */
+ } else { /* host is specified */
switch (hintsp->ai_family) {
#ifdef IPv4
case AF_INET:
case AF_UNSPEC:
#ifdef HAS_IPV6
search[nsearch].host = hostname;
- search[nsearch].family = AF_INET6; /* IPv6 first */
+ search[nsearch].family = AF_INET6; /* IPv6 first */
nsearch++;
#endif
#ifdef IPv4
search[nsearch].host = hostname;
- search[nsearch].family = AF_INET; /* then IPv4 */
+ search[nsearch].family = AF_INET; /* then IPv4 */
nsearch++;
#endif
break;
/* include ga_aistruct1 */
int
ga_aistruct(struct addrinfo ***paipnext, const struct addrinfo *hintsp,
- const void *addr, int family)
+ const void *addr, int family)
{
struct addrinfo *ai;
/* 4allocate sockaddr_in{} and fill in all but port */
if ((sinptr = calloc(1, sizeof(struct sockaddr_in))) == NULL)
- return (EAI_MEMORY);
+ return (EAI_MEMORY);
#ifdef HAVE_SOCKADDR_SA_LEN
sinptr->sin_len = sizeof(struct sockaddr_in);
#endif
ai->ai_addrlen = sizeof(struct sockaddr_in);
break;
}
-#endif /* IPV4 */
+#endif /* IPV4 */
#ifdef HAS_IPV6
case AF_INET6:{
struct sockaddr_in6 *sin6ptr;
/* 4allocate sockaddr_in6{} and fill in all but port */
if ((sin6ptr = calloc(1, sizeof(struct sockaddr_in6))) == NULL)
- return (EAI_MEMORY);
+ return (EAI_MEMORY);
#ifdef HAVE_SOCKADDR_SA_LEN
sin6ptr->sin6_len = sizeof(struct sockaddr_in6);
#endif
ai->ai_addrlen = sizeof(struct sockaddr_in6);
break;
}
-#endif /* IPV6 */
+#endif /* IPV6 */
}
return (0);
/* include ga_serv */
int
ga_serv(struct addrinfo *aihead, const struct addrinfo *hintsp,
- const char *serv)
+ const char *serv)
{
int port, rc, nfound;
nfound = 0;
- if (isdigit((unsigned char) serv[0])) { /* check for port number string first */
+ if (isdigit((unsigned char) serv[0])) { /* check for port number string first */
port = (int) htons((unsigned short) atoi(serv));
if (hintsp->ai_socktype) {
/* 4caller specifies socket type */
if ((rc = ga_port(aihead, port, hintsp->ai_socktype)) < 0)
- return (EAI_MEMORY);
+ return (EAI_MEMORY);
nfound += rc;
} else {
/* 4caller does not specify socket type */
if ((rc = ga_port(aihead, port, SOCK_STREAM)) < 0)
- return (EAI_MEMORY);
+ return (EAI_MEMORY);
nfound += rc;
if ((rc = ga_port(aihead, port, SOCK_DGRAM)) < 0)
- return (EAI_MEMORY);
+ return (EAI_MEMORY);
nfound += rc;
}
}
if (nfound == 0) {
if (hintsp->ai_socktype == 0)
- return (EAI_NONAME); /* all calls to getservbyname() failed */
+ return (EAI_NONAME); /* all calls to getservbyname() failed */
else
- return (EAI_SERVICE); /* service not supported for socket type */
+ return (EAI_SERVICE); /* service not supported for socket type */
}
return (0);
}
/* include ga_port */
int
ga_port(struct addrinfo *aihead, int port, int socktype)
- /* port must be in network byte order */
+ /* port must be in network byte order */
{
int nfound = 0;
struct addrinfo *ai;
for (ai = aihead; ai != NULL; ai = ai->ai_next) {
if (ai->ai_flags & AI_CLONE) {
if (ai->ai_socktype != 0) {
- if ((ai = ga_clone(ai)) == NULL)
- return (-1); /* memory allocation error */
- /* ai points to newly cloned entry, which is what we want */
+ if ((ai = ga_clone(ai)) == NULL)
+ return (-1); /* memory allocation error */
+ /* ai points to newly cloned entry, which is what we want */
}
} else if (ai->ai_socktype != socktype)
- continue; /* ignore if mismatch on socket type */
+ continue; /* ignore if mismatch on socket type */
ai->ai_socktype = socktype;
new->ai_next = ai->ai_next;
ai->ai_next = new;
- new->ai_flags = 0; /* make sure AI_CLONE is off */
+ new->ai_flags = 0; /* make sure AI_CLONE is off */
new->ai_family = ai->ai_family;
new->ai_socktype = ai->ai_socktype;
new->ai_protocol = ai->ai_protocol;
}
/* end ga_clone */
-#endif /* HAS_GETADDRINFO */
+#endif /* HAS_GETADDRINFO */
/*
* Return a string containing some additional information after an
return ("unknown getaddrinfo() error");
}
}
-#endif /* HAS_GAI_STRERROR */
+#endif /* HAS_GAI_STRERROR */
#ifndef HAS_GETADDRINFO
for (ai = aihead; ai != NULL; ai = ainext) {
if (ai->ai_addr != NULL)
- free(ai->ai_addr); /* socket address structure */
+ free(ai->ai_addr); /* socket address structure */
if (ai->ai_canonname != NULL)
free(ai->ai_canonname);
- ainext = ai->ai_next; /* can't fetch ai_next after free() */
- free(ai); /* the addrinfo{} itself */
+ ainext = ai->ai_next; /* can't fetch ai_next after free() */
+ free(ai); /* the addrinfo{} itself */
}
}
/* end freeaddrinfo */
-#endif /* HAS_GETADDRINFO */
+#endif /* HAS_GETADDRINFO */
#define MAXHOSTNAMELEN 32
#define LC_MESSAGES 6
void shutdown_checkpoint(void);
-#else /* !WIN32 */
+#else /* !WIN32 */
#ifdef I_SYS_FILE
#include <sys/file.h>
#endif
#ifdef I_SYS_STAT
#include <sys/stat.h>
#endif
-#endif /* !WIN32 */
+#endif /* !WIN32 */
#include <time.h>
#ifdef I_SYS_WAIT
#include <sys/wait.h>
#include "parse.h"
#include "confmagic.h"
-#define MYSSL_RB 0x1 /**< Read blocked (on read) */
-#define MYSSL_WB 0x2 /**< Write blocked (on write) */
-#define MYSSL_RBOW 0x4 /**< Read blocked (on write) */
-#define MYSSL_WBOR 0x8 /**< Write blocked (on read) */
-#define MYSSL_ACCEPT 0x10 /**< We need to call SSL_accept (again) */
-#define MYSSL_VERIFIED 0x20 /**< This is an authenticated connection */
-#define MYSSL_HANDSHAKE 0x40 /**< We need to call SSL_do_handshake */
+#define MYSSL_RB 0x1 /**< Read blocked (on read) */
+#define MYSSL_WB 0x2 /**< Write blocked (on write) */
+#define MYSSL_RBOW 0x4 /**< Read blocked (on write) */
+#define MYSSL_WBOR 0x8 /**< Write blocked (on read) */
+#define MYSSL_ACCEPT 0x10 /**< We need to call SSL_accept (again) */
+#define MYSSL_VERIFIED 0x20 /**< This is an authenticated connection */
+#define MYSSL_HANDSHAKE 0x40 /**< We need to call SSL_do_handshake */
#undef MYSSL_DEBUG
#ifdef MYSSL_DEBUG
if (*options.ssl_private_key_file) {
if (!SSL_CTX_use_certificate_chain_file(ctx, options.ssl_private_key_file)) {
ssl_errordump
- ("Unable to load server certificate - only anonymous ciphers supported.");
+ ("Unable to load server certificate - only anonymous ciphers supported.");
}
if (!SSL_CTX_use_PrivateKey_file
- (ctx, options.ssl_private_key_file, SSL_FILETYPE_PEM)) {
+ (ctx, options.ssl_private_key_file, SSL_FILETYPE_PEM)) {
ssl_errordump
- ("Unable to load private key - only anonymous ciphers supported.");
+ ("Unable to load private key - only anonymous ciphers supported.");
}
}
ssl_errordump("Unable to load CA certificates");
} else {
if (options.ssl_require_client_cert)
- SSL_CTX_set_verify(ctx,
- SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
- client_verify_callback);
+ SSL_CTX_set_verify(ctx,
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
+ client_verify_callback);
else
- SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, client_verify_callback);
+ SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, client_verify_callback);
#if (OPENSSL_VERSION_NUMBER < 0x0090600fL)
SSL_CTX_set_verify_depth(ctx, 1);
#endif
SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE | SSL_OP_ALL);
SSL_CTX_set_mode(ctx,
- SSL_MODE_ENABLE_PARTIAL_WRITE |
- SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+ SSL_MODE_ENABLE_PARTIAL_WRITE |
+ SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
/* Set up DH callback */
SSL_CTX_set_tmp_dh(ctx, get_dh1024());
X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
if (!preverify_ok) {
do_log(LT_ERR, 0, 0, "verify error:num=%d:%s:depth=%d:%s\n", err,
- X509_verify_cert_error_string(err), depth, buf);
+ X509_verify_cert_error_string(err), depth, buf);
if (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT) {
X509_NAME_oneline(X509_get_issuer_name(x509_ctx->current_cert), buf, 256);
do_log(LT_ERR, 0, 0, "issuer= %s\n", buf);
/* Successful accept - report it */
if ((peer = SSL_get_peer_certificate(ssl))) {
if (SSL_get_verify_result(ssl) == X509_V_OK) {
- /* The client sent a certificate which verified OK */
- X509_NAME_oneline(X509_get_subject_name(peer), buf, 256);
- do_log(LT_CONN, 0, 0, "SSL client certificate accepted: %s", buf);
- state |= MYSSL_VERIFIED;
+ /* The client sent a certificate which verified OK */
+ X509_NAME_oneline(X509_get_subject_name(peer), buf, 256);
+ do_log(LT_CONN, 0, 0, "SSL client certificate accepted: %s", buf);
+ state |= MYSSL_VERIFIED;
}
}
}
*/
int
ssl_read(SSL * ssl, int state, int net_read_ready, int net_write_ready,
- char *buf, int bufsize, int *bytes_read)
+ char *buf, int bufsize, int *bytes_read)
{
if ((net_read_ready && !(state & MYSSL_WBOR)) ||
(net_write_ready && (state & MYSSL_RBOW))) {
*bytes_read = SSL_read(ssl, buf, bufsize);
switch (SSL_get_error(ssl, *bytes_read)) {
case SSL_ERROR_NONE:
- /* Yay */
- return state;
+ /* Yay */
+ return state;
case SSL_ERROR_ZERO_RETURN:
- /* End of data on this socket */
- return -1;
+ /* End of data on this socket */
+ return -1;
case SSL_ERROR_WANT_READ:
- /* More needs to be read from the underlying socket */
- ssl_debugdump("SSL_read wants read");
- state |= MYSSL_RB;
- break;
+ /* More needs to be read from the underlying socket */
+ ssl_debugdump("SSL_read wants read");
+ state |= MYSSL_RB;
+ break;
case SSL_ERROR_WANT_WRITE:
- /* More needs to be written to the underlying socket.
- * This can happen during a rehandshake.
- */
- ssl_debugdump("SSL_read wants write");
- state |= MYSSL_RBOW;
- break;
+ /* More needs to be written to the underlying socket.
+ * This can happen during a rehandshake.
+ */
+ ssl_debugdump("SSL_read wants write");
+ state |= MYSSL_RBOW;
+ break;
default:
- /* Should never happen */
- ssl_errordump("Unknown ssl_read failure!");
- return -1;
+ /* Should never happen */
+ ssl_errordump("Unknown ssl_read failure!");
+ return -1;
}
} while (SSL_pending(ssl) && !(state & MYSSL_RB));
}
*/
int
ssl_write(SSL * ssl, int state, int net_read_ready, int net_write_ready,
- unsigned char *buf, int bufsize, int *offset)
+ unsigned char *buf, int bufsize, int *offset)
{
int r;
if ((net_write_ready && bufsize) || (net_read_ready && !(state & MYSSL_WBOR))) {
SSL_set_bio(ssl, bio, bio);
return ssl;
}
-#endif /* BROKEN */
+#endif /* BROKEN */
-#endif /* HAS_OPENSSL */
+#endif /* HAS_OPENSSL */
#include <windows.h>
#include <winsock.h>
#include <io.h>
-#else /* !WIN32 */
+#else /* !WIN32 */
#ifdef I_SYS_FILE
#include <sys/file.h>
#endif
#ifdef I_SYS_STAT
#include <sys/stat.h>
#endif
-#endif /* !WIN32 */
+#endif /* !WIN32 */
#include <time.h>
#include <fcntl.h>
#include <ctype.h>
*/
/* Telnet codes */
-#define IAC 255 /**< telnet: interpret as command */
+#define IAC 255 /**< telnet: interpret as command */
/** Iterate through a list of descriptors, and do something with those
* that are connected.
/** Types of text renderings we can do in notify_anything(). */
enum na_type {
- NA_ASCII = 0, /**< Plain old ascii. */
- NA_ANSI, /**< ANSI flag */
- NA_COLOR, /**< ANSI and COLOR flags */
- NA_PUEBLO, /**< html */
- NA_PASCII, /**< Player without any of the above */
- NA_TANSI, /**< Like above with telnet-aware client */
- NA_TCOLOR, /**< Like above with telnet-aware client */
- NA_TPASCII, /**< Like above with telnet-aware client */
- NA_NANSI, /**< ANSI and NOACCENTS */
- NA_NCOLOR, /**< ANSI, COLOR, NOACCENTS */
- NA_NPUEBLO, /**< html & NOACCENTS */
- NA_NPASCII /**< NOACCENTS */
+ NA_ASCII = 0, /**< Plain old ascii. */
+ NA_ANSI, /**< ANSI flag */
+ NA_COLOR, /**< ANSI and COLOR flags */
+ NA_PUEBLO, /**< html */
+ NA_PASCII, /**< Player without any of the above */
+ NA_TANSI, /**< Like above with telnet-aware client */
+ NA_TCOLOR, /**< Like above with telnet-aware client */
+ NA_TPASCII, /**< Like above with telnet-aware client */
+ NA_NANSI, /**< ANSI and NOACCENTS */
+ NA_NCOLOR, /**< ANSI, COLOR, NOACCENTS */
+ NA_NPUEBLO, /**< html & NOACCENTS */
+ NA_NPASCII /**< NOACCENTS */
};
/** Number of possible message text renderings */
#define MESSAGE_TYPES 12
-#define TA_BGC 0 /**< Text attribute background color */
-#define TA_FGC 1 /**< Text attribute foreground color */
-#define TA_BOLD 2 /**< Text attribute bold/hilite */
-#define TA_REV 3 /**< Text attribute reverse/inverse */
-#define TA_BLINK 4 /**< Text attribute blinking/flashing */
-#define TA_ULINE 5 /**< Text attribute underline */
+#define TA_BGC 0 /**< Text attribute background color */
+#define TA_FGC 1 /**< Text attribute foreground color */
+#define TA_BOLD 2 /**< Text attribute bold/hilite */
+#define TA_REV 3 /**< Text attribute reverse/inverse */
+#define TA_BLINK 4 /**< Text attribute blinking/flashing */
+#define TA_ULINE 5 /**< Text attribute underline */
static int na_depth = 0;
/** A place to store a rendered message. */
struct notify_strings {
- unsigned char *message; /**< The message text. */
- size_t len; /**< Length of message. */
- int made; /**< True if message has been rendered. */
+ unsigned char *message; /**< The message text. */
+ size_t len; /**< Length of message. */
+ int made; /**< True if message has been rendered. */
};
static void fillstate(int state[], const unsigned char **f);
static void ansi_change_state(char *t, char **o, int color, int *state,
- int *newstate);
+ int *newstate);
static enum na_type notify_type(DESC *d);
static void free_strings(struct notify_strings messages[]);
static void zero_strings(struct notify_strings messages[]);
static unsigned char *notify_makestring(const char *message,
- struct notify_strings messages[],
- enum na_type type);
+ struct notify_strings messages[],
+ enum na_type type);
static void
p++;
while (*p && *p != 'm') {
if ((*p > '9') || (*p < '0')) {
- /* Nada */
+ /* Nada */
} else if (!(*(p + 1)) || (*(p + 1) == 'm') || (*(p + 1) == ';')) {
- /* ShortCode */ ;
- switch (*p) {
- case '0':
- for (i = 0; i < 6; i++)
- state[i] = 0;
- break;
- case '1':
- state[TA_BOLD] = 1;
- break;
- case '7':
- state[TA_REV] = 1;
- break;
- case '5':
- state[TA_BLINK] = 1;
- break;
- case '4':
- state[TA_ULINE] = 1;
- break;
- }
+ /* ShortCode */ ;
+ switch (*p) {
+ case '0':
+ for (i = 0; i < 6; i++)
+ state[i] = 0;
+ break;
+ case '1':
+ state[TA_BOLD] = 1;
+ break;
+ case '7':
+ state[TA_REV] = 1;
+ break;
+ case '5':
+ state[TA_BLINK] = 1;
+ break;
+ case '4':
+ state[TA_ULINE] = 1;
+ break;
+ }
} else {
- n = (*p - '0') * 10;
- p++;
- n += (*p - '0');
- if ((n >= 30) && (n <= 37))
- state[TA_FGC] = n - 29;
- else if ((n >= 40) && (n <= 47))
- state[TA_BGC] = n - 39;
+ n = (*p - '0') * 10;
+ p++;
+ n += (*p - '0');
+ if ((n >= 30) && (n <= 37))
+ state[TA_FGC] = n - 29;
+ else if ((n >= 40) && (n <= 47))
+ state[TA_BGC] = n - 39;
}
p++;
}
static unsigned char *
notify_makestring(const char *message, struct notify_strings messages[],
- enum na_type type)
+ enum na_type type)
{
char *o;
const unsigned char *p;
while (*p) {
switch (*p) {
case TAG_START:
- while (*p && *p != TAG_END)
- p++;
- break;
+ while (*p && *p != TAG_END)
+ p++;
+ break;
case '\r':
case BEEP_CHAR:
- break;
+ break;
case ESC_CHAR:
- while (*p && *p != 'm')
- p++;
- break;
+ while (*p && *p != 'm')
+ p++;
+ break;
default:
- safe_chr(*p, t, &o);
+ safe_chr(*p, t, &o);
}
p++;
}
while (*p) {
switch (*p) {
case IAC:
- if (type == NA_TPASCII)
- safe_str("\xFF\xFF", t, &o);
- else if (strip)
- safe_str(accent_table[IAC].base, t, &o);
- else
- safe_chr((char) IAC, t, &o);
- break;
+ if (type == NA_TPASCII)
+ safe_str("\xFF\xFF", t, &o);
+ else if (strip)
+ safe_str(accent_table[IAC].base, t, &o);
+ else
+ safe_chr((char) IAC, t, &o);
+ break;
case TAG_START:
- while (*p && *p != TAG_END)
- p++;
- break;
+ while (*p && *p != TAG_END)
+ p++;
+ break;
case ESC_CHAR:
- while (*p && *p != 'm')
- p++;
- break;
+ while (*p && *p != 'm')
+ p++;
+ break;
case '\r':
- break;
+ break;
case '\n':
- safe_str("\r\n", t, &o);
- break;
+ safe_str("\r\n", t, &o);
+ break;
default:
- if (strip && accent_table[(unsigned char) *p].base)
- safe_str(accent_table[(unsigned char) *p].base, t, &o);
- else
- safe_chr(*p, t, &o);
+ if (strip && accent_table[(unsigned char) *p].base)
+ safe_str(accent_table[(unsigned char) *p].base, t, &o);
+ else
+ safe_chr(*p, t, &o);
}
p++;
}
while (*p) {
switch ((unsigned char) *p) {
case IAC:
- if (changed) {
- changed = 0;
- ansi_change_state(t, &o, color, state, newstate);
- }
- if (type == NA_TANSI || type == NA_TCOLOR)
- safe_str("\xFF\xFF", t, &o);
- else if (strip && accent_table[IAC].base)
- safe_str(accent_table[IAC].base, t, &o);
- else
- safe_chr((char) IAC, t, &o);
- break;
+ if (changed) {
+ changed = 0;
+ ansi_change_state(t, &o, color, state, newstate);
+ }
+ if (type == NA_TANSI || type == NA_TCOLOR)
+ safe_str("\xFF\xFF", t, &o);
+ else if (strip && accent_table[IAC].base)
+ safe_str(accent_table[IAC].base, t, &o);
+ else
+ safe_chr((char) IAC, t, &o);
+ break;
case TAG_START:
- if (pueblo) {
- safe_chr('<', t, &o);
- p++;
- while ((*p) && (*p != TAG_END)) {
- safe_chr(*p, t, &o);
- p++;
- }
- safe_chr('>', t, &o);
- } else {
- /* Non-pueblo */
- while (*p && *p != TAG_END)
- p++;
- }
- break;
+ if (pueblo) {
+ safe_chr('<', t, &o);
+ p++;
+ while ((*p) && (*p != TAG_END)) {
+ safe_chr(*p, t, &o);
+ p++;
+ }
+ safe_chr('>', t, &o);
+ } else {
+ /* Non-pueblo */
+ while (*p && *p != TAG_END)
+ p++;
+ }
+ break;
case TAG_END:
- /* Should never be seen alone */
- break;
+ /* Should never be seen alone */
+ break;
case '\r':
- break;
+ break;
case ESC_CHAR:
- fillstate(newstate, &p);
- changed = 1;
- break;
+ fillstate(newstate, &p);
+ changed = 1;
+ break;
default:
- if (changed) {
- changed = 0;
- ansi_change_state(t, &o, color, state, newstate);
- }
- if (pueblo) {
- if (strip) {
- /* Even if we're NOACCENTS, we must still translate a few things */
- switch ((unsigned char) *p) {
- case '\n':
- case '&':
- case '<':
- case '>':
- case '"':
- safe_str(accent_table[(unsigned char) *p].entity, t, &o);
- break;
- default:
- if (accent_table[(unsigned char) *p].base)
- safe_str(accent_table[(unsigned char) *p].base, t, &o);
- else
- safe_chr(*p, t, &o);
- break;
- }
- } else if (accent_table[(unsigned char) *p].entity)
- safe_str(accent_table[(unsigned char) *p].entity, t, &o);
- else
- safe_chr(*p, t, &o);
- } else {
- /* Non-pueblo */
- if ((unsigned char) *p == '\n')
- safe_str("\r\n", t, &o);
- else if (strip && accent_table[(unsigned char) *p].base)
- safe_str(accent_table[(unsigned char) *p].base, t, &o);
- else
- safe_chr(*p, t, &o);
- }
+ if (changed) {
+ changed = 0;
+ ansi_change_state(t, &o, color, state, newstate);
+ }
+ if (pueblo) {
+ if (strip) {
+ /* Even if we're NOACCENTS, we must still translate a few things */
+ switch ((unsigned char) *p) {
+ case '\n':
+ case '&':
+ case '<':
+ case '>':
+ case '"':
+ safe_str(accent_table[(unsigned char) *p].entity, t, &o);
+ break;
+ default:
+ if (accent_table[(unsigned char) *p].base)
+ safe_str(accent_table[(unsigned char) *p].base, t, &o);
+ else
+ safe_chr(*p, t, &o);
+ break;
+ }
+ } else if (accent_table[(unsigned char) *p].entity)
+ safe_str(accent_table[(unsigned char) *p].entity, t, &o);
+ else
+ safe_chr(*p, t, &o);
+ } else {
+ /* Non-pueblo */
+ if ((unsigned char) *p == '\n')
+ safe_str("\r\n", t, &o);
+ else if (strip && accent_table[(unsigned char) *p].base)
+ safe_str(accent_table[(unsigned char) *p].base, t, &o);
+ else
+ safe_chr(*p, t, &o);
+ }
}
p++;
}
if (state[TA_BOLD] || state[TA_REV] ||
- state[TA_BLINK] || state[TA_ULINE] ||
- (color && (state[TA_FGC] || state[TA_BGC])))
+ state[TA_BLINK] || state[TA_ULINE] ||
+ (color && (state[TA_FGC] || state[TA_BGC])))
safe_str(ANSI_NORMAL, t, &o);
break;
}
dbref na_jloc(dbref current, void *data) {
- dbref player = *((dbref *) data);
- if(current == NOTHING)
- return player;
- if(current == player)
- return Location(player);
- else
- return NOTHING;
+ dbref player = *((dbref *) data);
+ if(current == NOTHING)
+ return player;
+ if(current == player)
+ return Location(player);
+ else
+ return NOTHING;
}
/** notify_anthing() iterator for following a contents/exit chain.
check = 0;
for (i = 2; i < dbrefs[0] + 2; i++)
if (current == dbrefs[i])
- check = 1;
+ check = 1;
} while (check);
return current;
}
} else if (ShowAnsi(d->player)) {
if (ShowAnsiColor(d->player)) {
if (strip)
- poutput = NA_NCOLOR;
+ poutput = NA_NCOLOR;
else
- poutput = (d->conn_flags & CONN_TELNET) ? NA_TCOLOR : NA_COLOR;
+ poutput = (d->conn_flags & CONN_TELNET) ? NA_TCOLOR : NA_COLOR;
} else {
if (strip)
- poutput = NA_NANSI;
+ poutput = NA_NANSI;
else
- poutput = (d->conn_flags & CONN_TELNET) ? NA_TANSI : NA_ANSI;
+ poutput = (d->conn_flags & CONN_TELNET) ? NA_TANSI : NA_ANSI;
}
} else {
if (strip)
*/
void
notify_anything_loc(dbref speaker, na_lookup func,
- void *fdata, char *(*nsfunc) (dbref, na_lookup func, void *,
- int), int flags,
- const char *message, dbref loc)
+ void *fdata, char *(*nsfunc) (dbref, na_lookup func, void *,
+ int), int flags,
+ const char *message, dbref loc)
{
dbref target;
dbref passalong[3];
if (IsPlayer(target)) {
if (!Connected(target) && options.login_allow && under_limit)
- continue;
+ continue;
if (flags & NA_INTERACTION) {
- int pass_interact = 1;
- if ((flags & NA_INTER_SEE) &&
- !can_interact(speaker, target, INTERACT_SEE))
- pass_interact = 0;
- if (pass_interact && (flags & NA_INTER_PRESENCE) &&
- !can_interact(speaker, target, INTERACT_PRESENCE))
- pass_interact = 0;
- if (pass_interact && (flags & NA_INTER_HEAR) &&
- !can_interact(speaker, target, INTERACT_HEAR))
- pass_interact = 0;
- if (pass_interact && (flags & NA_INTER_LOCK) &&
- !Pass_Interact_Lock(speaker, target))
- pass_interact = 0;
- if (!pass_interact)
- continue;
+ int pass_interact = 1;
+ if ((flags & NA_INTER_SEE) &&
+ !can_interact(speaker, target, INTERACT_SEE))
+ pass_interact = 0;
+ if (pass_interact && (flags & NA_INTER_PRESENCE) &&
+ !can_interact(speaker, target, INTERACT_PRESENCE))
+ pass_interact = 0;
+ if (pass_interact && (flags & NA_INTER_HEAR) &&
+ !can_interact(speaker, target, INTERACT_HEAR))
+ pass_interact = 0;
+ if (pass_interact && (flags & NA_INTER_LOCK) &&
+ !Pass_Interact_Lock(speaker, target))
+ pass_interact = 0;
+ if (!pass_interact)
+ continue;
}
/* Evaluate the On Contact Message */
if(flags & NA_EVALONCONTACT) {
- const char *tmpbuf = msgbuf;
- for (j = 0; j < 10; j++)
- wsave[j] = global_eval_context.wenv[j];
- global_eval_context.wenv[0] = msgbuf;
- for (j = 1; j < 10; j++)
- global_eval_context.wenv[j] = NULL;
- bp = eocm;
- process_expression(eocm, &bp, &tmpbuf, target, speaker, speaker,
- PE_DEFAULT, PT_DEFAULT, NULL);
- *bp = 0;
- for (j = 0; j < 10; j++)
- global_eval_context.wenv[j] = wsave[j];
+ const char *tmpbuf = msgbuf;
+ for (j = 0; j < 10; j++)
+ wsave[j] = global_eval_context.wenv[j];
+ global_eval_context.wenv[0] = msgbuf;
+ for (j = 1; j < 10; j++)
+ global_eval_context.wenv[j] = NULL;
+ bp = eocm;
+ process_expression(eocm, &bp, &tmpbuf, target, speaker, speaker,
+ PE_DEFAULT, PT_DEFAULT, NULL);
+ *bp = 0;
+ for (j = 0; j < 10; j++)
+ global_eval_context.wenv[j] = wsave[j];
}
for (d = descriptor_list; d; d = d->next) {
- if (d->connected && d->player == target) {
- poutput = notify_type(d);
-
- if ((flags & NA_PONLY) && (poutput != NA_PUEBLO))
- continue;
-
- if (!(flags & NA_SPOOF)
- && (nsfunc && ((Nospoof(target) && (target != speaker))
- || (flags & NA_NOSPOOF)))) {
- if (Paranoid(target) || (flags & NA_PARANOID)) {
- if (!havepara) {
- paranoid = nsfunc(speaker, func, fdata, 1);
- havepara = 1;
- }
- pstring = notify_makestring(paranoid, paranoids, poutput);
- plen = paranoids[poutput].len;
- } else {
- if (!havespoof) {
- nospoof = nsfunc(speaker, func, fdata, 0);
- havespoof = 1;
- }
- pstring = notify_makestring(nospoof, nospoofs, poutput);
- plen = nospoofs[poutput].len;
- }
- queue_newwrite(d, pstring, plen);
- }
-
- pstring = notify_makestring((flags & NA_EVALONCONTACT) ? eocm : msgbuf, messages, poutput);
- plen = messages[poutput].len;
- if (pstring && *pstring)
- queue_newwrite(d, pstring, plen);
-
- if (!(flags & NA_NOENTER)) {
- if ((poutput == NA_PUEBLO) || (poutput == NA_NPUEBLO)) {
- if (flags & NA_NOPENTER)
- queue_newwrite(d, (unsigned char *) "\n", 1);
- else
- queue_newwrite(d, (unsigned char *) "<BR>\n", 5);
- } else {
- queue_newwrite(d, (unsigned char *) "\r\n", 2);
- }
- }
- }
+ if (d->connected && d->player == target) {
+ poutput = notify_type(d);
+
+ if ((flags & NA_PONLY) && (poutput != NA_PUEBLO))
+ continue;
+
+ if (!(flags & NA_SPOOF)
+ && (nsfunc && ((Nospoof(target) && (target != speaker))
+ || (flags & NA_NOSPOOF)))) {
+ if (Paranoid(target) || (flags & NA_PARANOID)) {
+ if (!havepara) {
+ paranoid = nsfunc(speaker, func, fdata, 1);
+ havepara = 1;
+ }
+ pstring = notify_makestring(paranoid, paranoids, poutput);
+ plen = paranoids[poutput].len;
+ } else {
+ if (!havespoof) {
+ nospoof = nsfunc(speaker, func, fdata, 0);
+ havespoof = 1;
+ }
+ pstring = notify_makestring(nospoof, nospoofs, poutput);
+ plen = nospoofs[poutput].len;
+ }
+ queue_newwrite(d, pstring, plen);
+ }
+
+ pstring = notify_makestring((flags & NA_EVALONCONTACT) ? eocm : msgbuf, messages, poutput);
+ plen = messages[poutput].len;
+ if (pstring && *pstring)
+ queue_newwrite(d, pstring, plen);
+
+ if (!(flags & NA_NOENTER)) {
+ if ((poutput == NA_PUEBLO) || (poutput == NA_NPUEBLO)) {
+ if (flags & NA_NOPENTER)
+ queue_newwrite(d, (unsigned char *) "\n", 1);
+ else
+ queue_newwrite(d, (unsigned char *) "<BR>\n", 5);
+ } else {
+ queue_newwrite(d, (unsigned char *) "\r\n", 2);
+ }
+ }
+ }
}
} else if (Puppet(target) &&
- ((Location(target) != Location(Owner(target))) ||
- Verbose(target) ||
- (flags & NA_MUST_PUPPET)) &&
- ((flags & NA_PUPPET) || !(flags & NA_NORELAY))) {
+ ((Location(target) != Location(Owner(target))) ||
+ Verbose(target) ||
+ (flags & NA_MUST_PUPPET)) &&
+ ((flags & NA_PUPPET) || !(flags & NA_NORELAY))) {
dbref last = puppet;
if (flags & NA_INTERACTION) {
- int pass_interact = 1;
- if ((flags & NA_INTER_SEE) &&
- !can_interact(speaker, target, INTERACT_SEE))
- pass_interact = 0;
- if (pass_interact && (flags & NA_INTER_PRESENCE) &&
- !can_interact(speaker, target, INTERACT_PRESENCE))
- pass_interact = 0;
- if (pass_interact && (flags & NA_INTER_HEAR) &&
- !can_interact(speaker, target, INTERACT_HEAR))
- pass_interact = 0;
- if (!pass_interact)
- continue;
+ int pass_interact = 1;
+ if ((flags & NA_INTER_SEE) &&
+ !can_interact(speaker, target, INTERACT_SEE))
+ pass_interact = 0;
+ if (pass_interact && (flags & NA_INTER_PRESENCE) &&
+ !can_interact(speaker, target, INTERACT_PRESENCE))
+ pass_interact = 0;
+ if (pass_interact && (flags & NA_INTER_HEAR) &&
+ !can_interact(speaker, target, INTERACT_HEAR))
+ pass_interact = 0;
+ if (!pass_interact)
+ continue;
}
puppet = target;
if (!tbuf1)
- tbuf1 = (char *) mush_malloc(BUFFER_LEN, "string");
+ tbuf1 = (char *) mush_malloc(BUFFER_LEN, "string");
bp = tbuf1;
safe_str(Name(target), tbuf1, &bp);
safe_str("> ", tbuf1, &bp);
*bp = '\0';
notify_anything(GOD, na_one, &Owner(target), NULL,
- NA_NOENTER | NA_PUPPET2 | NA_NORELAY | flags, tbuf1);
+ NA_NOENTER | NA_PUPPET2 | NA_NORELAY | flags, tbuf1);
nsflags = 0;
if (!(flags & NA_SPOOF)) {
- if (Nospoof(target))
- nsflags |= NA_NOSPOOF;
- if (Paranoid(target))
- nsflags |= NA_PARANOID;
+ if (Nospoof(target))
+ nsflags |= NA_NOSPOOF;
+ if (Paranoid(target))
+ nsflags |= NA_PARANOID;
}
notify_anything(speaker, na_one, &Owner(target), ns_esnotify,
- flags | nsflags | NA_NORELAY | NA_PUPPET2, msgbuf);
+ flags | nsflags | NA_NORELAY | NA_PUPPET2, msgbuf);
puppet = last;
}
if ((flags & NA_NOLISTEN)
- || (!PLAYER_LISTEN && IsPlayer(target))
- || IsExit(target))
+ || (!PLAYER_LISTEN && IsPlayer(target))
+ || IsExit(target))
continue;
#ifdef RPMODE_SYS
a = atr_get_noparent(target, "LISTEN");
if (a) {
if (!tbuf1)
- tbuf1 = (char *) mush_malloc(BUFFER_LEN, "string");
+ tbuf1 = (char *) mush_malloc(BUFFER_LEN, "string");
strcpy(tbuf1, atr_value(a));
if (AF_Regexp(a)
- ? regexp_match_case(tbuf1,
- (char *) notify_makestring(msgbuf, messages,
- NA_ASCII), AF_Case(a))
- : wild_match_case(tbuf1,
- (char *) notify_makestring(msgbuf, messages,
- NA_ASCII), AF_Case(a))) {
- if (eval_lock(speaker, target, Listen_Lock))
- if (PLAYER_AHEAR || (!IsPlayer(target))) {
- if (speaker != target)
- charge_action(speaker, target, "AHEAR");
- else
- charge_action(speaker, target, "AMHEAR");
- charge_action(speaker, target, "AAHEAR");
- }
- if (!(flags & NA_NORELAY) && (loc != target) &&
- !filter_found(target,
- (char *) notify_makestring(msgbuf, messages,
- NA_ASCII), 1)) {
- passalong[0] = target;
- passalong[1] = target;
- passalong[2] = Owner(target);
- a = atr_get(target, "INPREFIX");
- if (a) {
- for (j = 0; j < 10; j++)
- wsave[j] = global_eval_context.wenv[j];
- global_eval_context.wenv[0] = (char *) msgbuf;
- for (j = 1; j < 10; j++)
- global_eval_context.wenv[j] = NULL;
- save_global_regs("inprefix_save", preserve);
- asave = safe_atr_value(a);
- ap = asave;
- bp = tbuf1;
- process_expression(tbuf1, &bp, &ap, target, speaker, speaker,
- PE_DEFAULT, PT_DEFAULT, NULL);
- if (bp != tbuf1)
- safe_chr(' ', tbuf1, &bp);
- safe_str(msgbuf, tbuf1, &bp);
- *bp = 0;
- free(asave);
- restore_global_regs("inprefix_save", preserve);
- for (j = 0; j < 10; j++)
- global_eval_context.wenv[j] = wsave[j];
- }
- notify_anything(speaker, Puppet(target) ? na_except2 : na_except,
- passalong, NULL, flags | NA_NORELAY | NA_PUPPET,
- (a) ? tbuf1 : msgbuf);
- }
+ ? regexp_match_case(tbuf1,
+ (char *) notify_makestring(msgbuf, messages,
+ NA_ASCII), AF_Case(a))
+ : wild_match_case(tbuf1,
+ (char *) notify_makestring(msgbuf, messages,
+ NA_ASCII), AF_Case(a))) {
+ if (eval_lock(speaker, target, Listen_Lock))
+ if (PLAYER_AHEAR || (!IsPlayer(target))) {
+ if (speaker != target)
+ charge_action(speaker, target, "AHEAR");
+ else
+ charge_action(speaker, target, "AMHEAR");
+ charge_action(speaker, target, "AAHEAR");
+ }
+ if (!(flags & NA_NORELAY) && (loc != target) &&
+ !filter_found(target,
+ (char *) notify_makestring(msgbuf, messages,
+ NA_ASCII), 1)) {
+ passalong[0] = target;
+ passalong[1] = target;
+ passalong[2] = Owner(target);
+ a = atr_get(target, "INPREFIX");
+ if (a) {
+ for (j = 0; j < 10; j++)
+ wsave[j] = global_eval_context.wenv[j];
+ global_eval_context.wenv[0] = (char *) msgbuf;
+ for (j = 1; j < 10; j++)
+ global_eval_context.wenv[j] = NULL;
+ save_global_regs("inprefix_save", preserve);
+ asave = safe_atr_value(a);
+ ap = asave;
+ bp = tbuf1;
+ process_expression(tbuf1, &bp, &ap, target, speaker, speaker,
+ PE_DEFAULT, PT_DEFAULT, NULL);
+ if (bp != tbuf1)
+ safe_chr(' ', tbuf1, &bp);
+ safe_str(msgbuf, tbuf1, &bp);
+ *bp = 0;
+ free(asave);
+ restore_global_regs("inprefix_save", preserve);
+ for (j = 0; j < 10; j++)
+ global_eval_context.wenv[j] = wsave[j];
+ }
+ notify_anything(speaker, Puppet(target) ? na_except2 : na_except,
+ passalong, NULL, flags | NA_NORELAY | NA_PUPPET,
+ (a) ? tbuf1 : msgbuf);
+ }
}
}
/* if object is flagged LISTENER, check for ^ listen patterns
* */
if ((speaker != target) && (ThingListen(target) || RoomListen(target))
- && eval_lock(speaker, target, Listen_Lock)
+ && eval_lock(speaker, target, Listen_Lock)
)
atr_comm_match(target, speaker, '^', ':',
- (char *) notify_makestring(msgbuf, messages, NA_ASCII), 0,
- NULL, NULL, NULL);
+ (char *) notify_makestring(msgbuf, messages, NA_ASCII), 0,
+ NULL, NULL, NULL);
/* If object is flagged AUDIBLE and has a @FORWARDLIST, send
* stuff on */
if ((!(flags & NA_NORELAY) || (flags & NA_PUPPET)) && Audible(target)
- && ((a = atr_get_noparent(target, "FORWARDLIST")) != NULL)
- && !filter_found(target, msgbuf, 0)) {
+ && ((a = atr_get_noparent(target, "FORWARDLIST")) != NULL)
+ && !filter_found(target, msgbuf, 0)) {
notify_list(speaker, target, "FORWARDLIST", msgbuf, flags);
}
*/
void
notify_anything(dbref speaker, na_lookup func,
- void *fdata, char *(*nsfunc) (dbref, na_lookup func, void *,
- int), int flags,
- const char *message)
+ void *fdata, char *(*nsfunc) (dbref, na_lookup func, void *,
+ int), int flags,
+ const char *message)
{
dbref loc;
*/
void WIN32_CDECL
notify_anything_format(dbref speaker, na_lookup func,
- void *fdata, char *(*nsfunc) (dbref, na_lookup func,
- void *, int), int flags,
- const char *fmt, ...)
+ void *fdata, char *(*nsfunc) (dbref, na_lookup func,
+ void *, int), int flags,
+ const char *fmt, ...)
{
#ifdef HAS_VSNPRINTF
char buff[BUFFER_LEN];
*/
void
notify_list(dbref speaker, dbref thing, const char *atr, const char *msg,
- int flags)
+ int flags)
{
char *fwdstr, *orig, *curr;
char tbuf1[BUFFER_LEN], *bp;
make_prefixstr(thing, msg, tbuf1);
if (!(flags & NA_SPOOF)) {
if (Nospoof(thing))
- nsflags |= NA_NOSPOOF;
+ nsflags |= NA_NOSPOOF;
if (Paranoid(thing))
- nsflags |= NA_PARANOID;
+ nsflags |= NA_PARANOID;
}
} else {
safe_str(msg, tbuf1, &bp);
if (is_objid(curr)) {
fwd = parse_objid(curr);
if (GoodObject(fwd) && !IsGarbage(fwd) && (thing != fwd)
- && (Can_Forward(thing, fwd) || Can_Forward(AL_CREATOR(a),fwd))) {
- if (IsRoom(fwd)) {
- notify_anything(speaker, na_loc, &fwd, ns_esnotify,
- flags | nsflags | NA_NORELAY, tbuf1);
- } else {
- notify_anything(speaker, na_one, &fwd, ns_esnotify,
- flags | nsflags | NA_NORELAY, tbuf1);
- }
+ && (Can_Forward(thing, fwd) || Can_Forward(AL_CREATOR(a),fwd))) {
+ if (IsRoom(fwd)) {
+ notify_anything(speaker, na_loc, &fwd, ns_esnotify,
+ flags | nsflags | NA_NORELAY, tbuf1);
+ } else {
+ notify_anything(speaker, na_one, &fwd, ns_esnotify,
+ flags | nsflags | NA_NORELAY, tbuf1);
+ }
}
}
}
*/
int
safe_tag_wrap(char const *a_tag, char const *params, char const *data,
- char *buf, char **bp, dbref player)
+ char *buf, char **bp, dbref player)
{
int result = 0;
char *save = buf;
q->head = p->nxt;
#ifdef DEBUG
do_rawlog(LT_ERR, "free_text_block(0x%x) at 1.", p);
-#endif /* DEBUG */
+#endif /* DEBUG */
free_text_block(p);
}
p =
q->head->nxt = p->nxt;
#ifdef DEBUG
do_rawlog(LT_ERR, "free_text_block(0x%x) at 1.", p);
-#endif /* DEBUG */
+#endif /* DEBUG */
free_text_block(p);
}
}
if (space < 0) {
#ifdef HAS_OPENSSL
if (d->ssl) {
- /* Now we have a problem, as SSL works in blocks and you can't
- * just partially flush stuff.
- */
- d->output_size = ssl_flush_queue(&d->output);
+ /* Now we have a problem, as SSL works in blocks and you can't
+ * just partially flush stuff.
+ */
+ d->output_size = ssl_flush_queue(&d->output);
} else
#endif
- d->output_size -= flush_queue(&d->output, -space);
+ d->output_size -= flush_queue(&d->output, -space);
}
}
add_to_queue(&d->output, b, n);
next = cur->nxt;
#ifdef DEBUG
do_rawlog(LT_ERR, "free_text_block(0x%x) at 3.", cur);
-#endif /* DEBUG */
+#endif /* DEBUG */
free_text_block(cur);
cur = next;
}
next = cur->nxt;
#ifdef DEBUG
do_rawlog(LT_ERR, "free_text_block(0x%x) at 4.", cur);
-#endif /* DEBUG */
+#endif /* DEBUG */
free_text_block(cur);
cur = next;
}
* */
char *
ns_esnotify(dbref speaker, na_lookup func __attribute__ ((__unused__)),
- void *fdata __attribute__ ((__unused__)), int para)
+ void *fdata __attribute__ ((__unused__)), int para)
{
char *dest, *bp;
bp = dest = mush_malloc(BUFFER_LEN, "string");
safe_format(dest, &bp, "[%s(#%d)] ", Name(speaker), speaker);
else
safe_format(dest, &bp, "[%s(#%d)'s %s(#%d)] ", Name(Owner(speaker)),
- Owner(speaker), Name(speaker), speaker);
+ Owner(speaker), Name(speaker), speaker);
} else
safe_format(dest, &bp, "[%s:] ", spname(speaker));
*bp = '\0';
#include "mymalloc.h"
#include "confmagic.h"
-extern char *absp[], *obj[], *poss[], *subj[]; /* fundb.c */
+extern char *absp[], *obj[], *poss[], *subj[]; /* fundb.c */
extern int inum, inum_limit;
extern char *iter_rep[];
int global_fun_invocations;
/** Structure for storing DEBUG output in a linked list */
struct debug_info {
- char *string; /**< A DEBUG string */
- Debug_Info *prev; /**< Previous node in the linked list */
- Debug_Info *next; /**< Next node in the linked list */
+ char *string; /**< A DEBUG string */
+ Debug_Info *prev; /**< Previous node in the linked list */
+ Debug_Info *next; /**< Next node in the linked list */
};
FUNCTION_PROTO(fun_gfun);
time_t matchtime;
p++;
if (!is_strict_integer(p))
- return NOTHING;
+ return NOTHING;
matchtime = parse_integer(p);
return (CreTime(it) == matchtime) ? it : NOTHING;
} else
return 0;
/* Non-zero numbers are true, zero is false */
if (is_strict_number(str))
- return parse_number(str) != 0; /* avoid rounding problems */
+ return parse_number(str) != 0; /* avoid rounding problems */
/* Skip blanks */
while (*str == ' ')
str++;
/* If there's any non-blanks left, it's true */
- return *str != '\0'; /* force to 1 or 0 */
+ return *str != '\0'; /* force to 1 or 0 */
}
}
extern signed char qreg_indexes[UCHAR_MAX + 1];
#ifdef WIN32
-#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
+#pragma warning( disable : 4761) /* NJG: disable warning re conversion */
#endif
*/
int
process_expression(char *buff, char **bp, char const **str,
- dbref executor, dbref caller, dbref enactor,
- int eflags, int tflags, PE_Info * pe_info)
+ dbref executor, dbref caller, dbref enactor,
+ int eflags, int tflags, PE_Info * pe_info)
{
int debugging = 0, made_info = 0;
char *debugstr = NULL, *sourcestr = NULL;
* it might never get displayed.
*/
if (!Quiet(enactor))
- notify(enactor, T("CPU usage exceeded."));
+ notify(enactor, T("CPU usage exceeded."));
do_rawlog(LT_TRACE,
- T
- ("CPU time limit exceeded. enactor=#%d executor=#%d caller=#%d code=%s"),
- enactor, executor, caller, *str);
+ T
+ ("CPU time limit exceeded. enactor=#%d executor=#%d caller=#%d code=%s"),
+ enactor, executor, caller, *str);
}
return 1;
}
inum_limit = inum;
made_info = 1;
pe_info = (PE_Info *) mush_malloc(sizeof(PE_Info),
- "process_expression.pe_info");
+ "process_expression.pe_info");
pe_info->fun_invocations = 0;
pe_info->fun_depth = 0;
pe_info->nest_depth = 0;
realbuff = buff;
realbp = *bp;
buff = (char *) mush_malloc(BUFFER_LEN,
- "process_expression.buffer_extension");
+ "process_expression.buffer_extension");
*bp = buff;
startpos = buff;
}
Debug_Info *node;
debugstr = (char *) mush_malloc(BUFFER_LEN,
- "process_expression.debug_source");
+ "process_expression.debug_source");
debugp = debugstr;
safe_dbref(executor, debugstr, &debugp);
safe_chr('!', debugstr, &debugp);
for (j = 0; j <= pe_info->nest_depth; j++)
- safe_chr(' ', debugstr, &debugp);
+ safe_chr(' ', debugstr, &debugp);
sourcestr = debugp;
mark = *str;
process_expression(debugstr, &debugp, str,
- executor, caller, enactor,
- PE_NOTHING, tflags, pe_info);
+ executor, caller, enactor,
+ PE_NOTHING, tflags, pe_info);
*str = mark;
if (eflags & PE_COMPRESS_SPACES)
- while ((debugp > sourcestr) && (debugp[-1] == ' '))
- debugp--;
+ while ((debugp > sourcestr) && (debugp[-1] == ' '))
+ debugp--;
*debugp = '\0';
node = (Debug_Info *) mush_malloc(sizeof(Debug_Info),
- "process_expression.debug_node");
+ "process_expression.debug_node");
node->string = debugstr;
node->prev = pe_info->debug_strings;
node->next = NULL;
if (node->prev)
- node->prev->next = node;
+ node->prev->next = node;
pe_info->debug_strings = node;
pe_info->nest_depth++;
}
for (;;) {
if(iter_break > 0) {
- while(*str && **str)
- (*str)++;
- goto exit_sequence;
+ while(*str && **str)
+ (*str)++;
+ goto exit_sequence;
}
/* Find the first "interesting" character */
{
/* Inlined strcspn() equivalent, to save on overhead and portability */
pos = *str;
while (!active_table[*(unsigned char const *) *str])
- (*str)++;
+ (*str)++;
/* Inlined safe_str(), since the source string
* may not be null terminated */
len = *str - pos;
len2 = BUFFER_LEN - 1 - (*bp - buff);
if (len > len2)
- len = len2;
+ len = len2;
if (len >= 0) {
- memcpy(*bp, pos, len);
- *bp += len;
+ memcpy(*bp, pos, len);
+ *bp += len;
}
}
/* Possible terminators */
case '}':
if (tflags & PT_BRACE)
- goto exit_sequence;
+ goto exit_sequence;
break;
case ']':
if (tflags & PT_BRACKET)
- goto exit_sequence;
+ goto exit_sequence;
break;
case ')':
if (tflags & PT_PAREN)
- goto exit_sequence;
+ goto exit_sequence;
break;
case ',':
if (tflags & PT_COMMA)
- goto exit_sequence;
+ goto exit_sequence;
break;
case ';':
if (tflags & PT_SEMI)
- goto exit_sequence;
+ goto exit_sequence;
break;
case '=':
if (tflags & PT_EQUALS)
- goto exit_sequence;
+ goto exit_sequence;
break;
case ' ':
if (tflags & PT_SPACE)
- goto exit_sequence;
+ goto exit_sequence;
break;
case '\0':
goto exit_sequence;
switch (**str) {
- case 0x1B: /* ANSI escapes. */
+ case 0x1B: /* ANSI escapes. */
/* Skip over until the 'm' that matches the end. */
for (; *str && **str && **str != 'm'; (*str)++)
- safe_chr(**str, buff, bp);
+ safe_chr(**str, buff, bp);
if (*str && **str) {
- safe_chr(**str, buff, bp);
- (*str)++;
+ safe_chr(**str, buff, bp);
+ (*str)++;
}
break;
- case '$': /* Dollar subs for regedit() */
+ case '$': /* Dollar subs for regedit() */
if ((eflags & (PE_DOLLAR | PE_EVALUATE)) == (PE_DOLLAR | PE_EVALUATE) &&
- global_eval_context.re_subpatterns >= 0) {
- char obuf[BUFFER_LEN];
- int p = 0;
+ global_eval_context.re_subpatterns >= 0) {
+ char obuf[BUFFER_LEN];
+ int p = 0;
char subspace[BUFFER_LEN];
char *named_substring = NULL;
obuf[0] = '\0';
- (*str)++;
- /* Check the first two characters after the $ for a number */
- if (isdigit((unsigned char) **str)) {
- p = **str - '0';
- (*str)++;
- if (isdigit((unsigned char) **str)) {
- p *= 10;
- p += **str - '0';
- (*str)++;
- if (isdigit((unsigned char) **str)) {
- /* More than 100. Treat this as literal. */
- safe_chr('$', buff, bp);
- safe_number(p, buff, bp);
- }
- }
- /* Look for a named subexpression */
- } else if (**str == '<') {
- char *nbuf = subspace;
- (*str)++;
- for (; *str && **str != '>'; (*str)++)
- safe_chr(**str, subspace, &nbuf);
- *nbuf = '\0';
- if (*str)
- (*str)++;
- if (is_strict_integer(subspace))
- p = abs(parse_integer(subspace));
- else
- named_substring = subspace;
- } else {
- safe_chr('$', buff, bp);
- break;
- }
+ (*str)++;
+ /* Check the first two characters after the $ for a number */
+ if (isdigit((unsigned char) **str)) {
+ p = **str - '0';
+ (*str)++;
+ if (isdigit((unsigned char) **str)) {
+ p *= 10;
+ p += **str - '0';
+ (*str)++;
+ if (isdigit((unsigned char) **str)) {
+ /* More than 100. Treat this as literal. */
+ safe_chr('$', buff, bp);
+ safe_number(p, buff, bp);
+ }
+ }
+ /* Look for a named subexpression */
+ } else if (**str == '<') {
+ char *nbuf = subspace;
+ (*str)++;
+ for (; *str && **str != '>'; (*str)++)
+ safe_chr(**str, subspace, &nbuf);
+ *nbuf = '\0';
+ if (*str)
+ (*str)++;
+ if (is_strict_integer(subspace))
+ p = abs(parse_integer(subspace));
+ else
+ named_substring = subspace;
+ } else {
+ safe_chr('$', buff, bp);
+ break;
+ }
- if ((!named_substring && p >= global_eval_context.re_subpatterns) ||
- global_eval_context.re_offsets == NULL ||
- global_eval_context.re_from == NULL) {
- /* It's out of bounds, return */
- safe_chr('$', buff, bp);
- if (named_substring)
- safe_format(buff, bp, "<%s>", named_substring);
- else
- safe_integer(p, buff, bp);
- break;
- }
+ if ((!named_substring && p >= global_eval_context.re_subpatterns) ||
+ global_eval_context.re_offsets == NULL ||
+ global_eval_context.re_from == NULL) {
+ /* It's out of bounds, return */
+ safe_chr('$', buff, bp);
+ if (named_substring)
+ safe_format(buff, bp, "<%s>", named_substring);
+ else
+ safe_integer(p, buff, bp);
+ break;
+ }
- if (named_substring) {
- pcre_copy_named_substring(global_eval_context.re_code,
- global_eval_context.re_from,
- global_eval_context.re_offsets,
- global_eval_context.re_subpatterns,
- named_substring, obuf, BUFFER_LEN);
- } else {
- pcre_copy_substring(global_eval_context.re_from,
- global_eval_context.re_offsets,
- global_eval_context.re_subpatterns,
- p, obuf, BUFFER_LEN);
- }
- safe_str(obuf, buff, bp);
+ if (named_substring) {
+ pcre_copy_named_substring(global_eval_context.re_code,
+ global_eval_context.re_from,
+ global_eval_context.re_offsets,
+ global_eval_context.re_subpatterns,
+ named_substring, obuf, BUFFER_LEN);
+ } else {
+ pcre_copy_substring(global_eval_context.re_from,
+ global_eval_context.re_offsets,
+ global_eval_context.re_subpatterns,
+ p, obuf, BUFFER_LEN);
+ }
+ safe_str(obuf, buff, bp);
} else {
- safe_chr('$', buff, bp);
- (*str)++;
+ safe_chr('$', buff, bp);
+ (*str)++;
}
break;
- case '%': /* Percent substitutions */
+ case '%': /* Percent substitutions */
if (!(eflags & PE_EVALUATE) || (*bp - buff >= BUFFER_LEN - 1)) {
- /* peak -- % escapes (at least) one character */
- char savec;
+ /* peak -- % escapes (at least) one character */
+ char savec;
- safe_chr('%', buff, bp);
- (*str)++;
- savec = **str;
- if (!savec)
- goto exit_sequence;
- safe_chr(savec, buff, bp);
- (*str)++;
- switch (savec) {
+ safe_chr('%', buff, bp);
+ (*str)++;
+ savec = **str;
+ if (!savec)
+ goto exit_sequence;
+ safe_chr(savec, buff, bp);
+ (*str)++;
+ switch (savec) {
case '<':
savec = **str;
if (!savec)
safe_chr(savec, buff, bp);
(*str)++;
break;
- case 'Q':
- case 'q':
+ case 'Q':
+ case 'q':
savec = **str;
if (!savec)
goto exit_sequence;
(*str)++;
}
break;
- case 'V':
- case 'v':
- case 'W':
- case 'w':
- case 'X':
- case 'x':
- /* These sequences escape two characters */
- savec = **str;
- if (!savec)
- goto exit_sequence;
- safe_chr(savec, buff, bp);
- (*str)++;
- }
- break;
+ case 'V':
+ case 'v':
+ case 'W':
+ case 'w':
+ case 'X':
+ case 'x':
+ /* These sequences escape two characters */
+ savec = **str;
+ if (!savec)
+ goto exit_sequence;
+ safe_chr(savec, buff, bp);
+ (*str)++;
+ }
+ break;
} else {
- char savec, nextc;
- char *savepos;
- ATTR *attrib;
+ char savec, nextc;
+ char *savepos;
+ ATTR *attrib;
- (*str)++;
- savec = **str;
- if (!savec) {
- /* Line ended in %, so treat it as a literal */
- safe_chr('%', buff, bp);
- goto exit_sequence;
- }
- savepos = *bp;
- (*str)++;
+ (*str)++;
+ savec = **str;
+ if (!savec) {
+ /* Line ended in %, so treat it as a literal */
+ safe_chr('%', buff, bp);
+ goto exit_sequence;
+ }
+ savepos = *bp;
+ (*str)++;
- switch (savec) {
- case '%': /* %% - a real % */
- safe_chr('%', buff, bp);
- break;
- case ' ': /* "% " for more natural typing */
- safe_str("% ", buff, bp);
- break;
- case '!': /* executor dbref */
- safe_dbref(executor, buff, bp);
- break;
- case '@': /* caller dbref */
- safe_dbref(caller, buff, bp);
- break;
- case '#': /* enactor dbref */
- safe_dbref(enactor, buff, bp);
- break;
- case ':': /* enactor unique id */
- safe_dbref(enactor, buff, bp);
- safe_chr(':', buff, bp);
- safe_integer(CreTime(enactor), buff, bp);
- break;
- case '?': /* function limits */
- if (pe_info) {
- safe_integer(pe_info->fun_invocations, buff, bp);
- safe_chr(' ', buff, bp);
- safe_integer(pe_info->fun_depth, buff, bp);
- } else {
- safe_str("0 0", buff, bp);
- }
- break;
- case '~': /* enactor accented name */
- safe_str(accented_name(enactor), buff, bp);
- break;
- case '+': /* argument count */
- if (pe_info)
- safe_integer(pe_info->arg_count, buff, bp);
- else
- safe_integer(0, buff, bp);
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': /* positional argument */
- if (global_eval_context.wenv[savec - '0'])
- safe_str(global_eval_context.wenv[savec - '0'], buff, bp);
- break;
- case 'A':
- case 'a': /* enactor absolute possessive pronoun */
- if (gender < 0)
- gender = get_gender(enactor);
- safe_str(absp[gender], buff, bp);
- break;
- case 'B':
- case 'b': /* blank space */
- safe_chr(' ', buff, bp);
- break;
- case 'C':
- case 'c': /* command line */
- safe_str(global_eval_context.ccom, buff, bp);
- break;
- case 'I':
- case 'i':
- nextc = **str;
- if (!nextc)
- goto exit_sequence;
- (*str)++;
- if (!isdigit(nextc)) {
- safe_str(T(e_int), buff, bp);
- break;
- }
- inum_this = nextc - '0';
- if (inum_this < 0 || inum_this >= inum
- || (inum - inum_this) <= inum_limit) {
- safe_str(T("#-1 ARGUMENT OUT OF RANGE"), buff, bp);
- } else {
- safe_str(iter_rep[inum - inum_this], buff, bp);
- }
- break;
- case 'U':
- case 'u':
- safe_str(global_eval_context.ucom, buff, bp);
- break;
- case 'L':
- case 'l': /* enactor location dbref */
- /* The security implications of this have
- * already been talked to death. Deal. */
- safe_dbref(Location(enactor), buff, bp);
- break;
- case 'N':
- case 'n': /* enactor name */
- safe_str(Name(enactor), buff, bp);
- break;
- case 'O':
- case 'o': /* enactor objective pronoun */
- if (gender < 0)
- gender = get_gender(enactor);
- safe_str(obj[gender], buff, bp);
- break;
- case 'P':
- case 'p': /* enactor possessive pronoun */
- if (gender < 0)
- gender = get_gender(enactor);
- safe_str(poss[gender], buff, bp);
- break;
+ switch (savec) {
+ case '%': /* %% - a real % */
+ safe_chr('%', buff, bp);
+ break;
+ case ' ': /* "% " for more natural typing */
+ safe_str("% ", buff, bp);
+ break;
+ case '!': /* executor dbref */
+ safe_dbref(executor, buff, bp);
+ break;
+ case '@': /* caller dbref */
+ safe_dbref(caller, buff, bp);
+ break;
+ case '#': /* enactor dbref */
+ safe_dbref(enactor, buff, bp);
+ break;
+ case ':': /* enactor unique id */
+ safe_dbref(enactor, buff, bp);
+ safe_chr(':', buff, bp);
+ safe_integer(CreTime(enactor), buff, bp);
+ break;
+ case '?': /* function limits */
+ if (pe_info) {
+ safe_integer(pe_info->fun_invocations, buff, bp);
+ safe_chr(' ', buff, bp);
+ safe_integer(pe_info->fun_depth, buff, bp);
+ } else {
+ safe_str("0 0", buff, bp);
+ }
+ break;
+ case '~': /* enactor accented name */
+ safe_str(accented_name(enactor), buff, bp);
+ break;
+ case '+': /* argument count */
+ if (pe_info)
+ safe_integer(pe_info->arg_count, buff, bp);
+ else
+ safe_integer(0, buff, bp);
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': /* positional argument */
+ if (global_eval_context.wenv[savec - '0'])
+ safe_str(global_eval_context.wenv[savec - '0'], buff, bp);
+ break;
+ case 'A':
+ case 'a': /* enactor absolute possessive pronoun */
+ if (gender < 0)
+ gender = get_gender(enactor);
+ safe_str(absp[gender], buff, bp);
+ break;
+ case 'B':
+ case 'b': /* blank space */
+ safe_chr(' ', buff, bp);
+ break;
+ case 'C':
+ case 'c': /* command line */
+ safe_str(global_eval_context.ccom, buff, bp);
+ break;
+ case 'I':
+ case 'i':
+ nextc = **str;
+ if (!nextc)
+ goto exit_sequence;
+ (*str)++;
+ if (!isdigit(nextc)) {
+ safe_str(T(e_int), buff, bp);
+ break;
+ }
+ inum_this = nextc - '0';
+ if (inum_this < 0 || inum_this >= inum
+ || (inum - inum_this) <= inum_limit) {
+ safe_str(T("#-1 ARGUMENT OUT OF RANGE"), buff, bp);
+ } else {
+ safe_str(iter_rep[inum - inum_this], buff, bp);
+ }
+ break;
+ case 'U':
+ case 'u':
+ safe_str(global_eval_context.ucom, buff, bp);
+ break;
+ case 'L':
+ case 'l': /* enactor location dbref */
+ /* The security implications of this have
+ * already been talked to death. Deal. */
+ safe_dbref(Location(enactor), buff, bp);
+ break;
+ case 'N':
+ case 'n': /* enactor name */
+ safe_str(Name(enactor), buff, bp);
+ break;
+ case 'O':
+ case 'o': /* enactor objective pronoun */
+ if (gender < 0)
+ gender = get_gender(enactor);
+ safe_str(obj[gender], buff, bp);
+ break;
+ case 'P':
+ case 'p': /* enactor possessive pronoun */
+ if (gender < 0)
+ gender = get_gender(enactor);
+ safe_str(poss[gender], buff, bp);
+ break;
case '<':
- if (!**str)
- goto exit_sequence;
+ if (!**str)
+ goto exit_sequence;
{
const char *tmp;
char atrname[BUFFER_LEN];
*str = tmp + 1;
}
break;
- case 'Q':
- case 'q': /* temporary storage */
- nextc = **str;
- if (!nextc)
- goto exit_sequence;
- (*str)++;
+ case 'Q':
+ case 'q': /* temporary storage */
+ nextc = **str;
+ if (!nextc)
+ goto exit_sequence;
+ (*str)++;
if (nextc == '<') {
const char *tmp;
char regname[BUFFER_LEN];
safe_str(get_namedreg(&global_eval_context.namedregs, regname), buff, bp);
*str = tmp + 1;
} else {
- if ((qindex = qreg_indexes[(unsigned char) nextc]) == -1)
- break;
- if (global_eval_context.renv[qindex])
- safe_str(global_eval_context.renv[qindex], buff, bp);
+ if ((qindex = qreg_indexes[(unsigned char) nextc]) == -1)
+ break;
+ if (global_eval_context.renv[qindex])
+ safe_str(global_eval_context.renv[qindex], buff, bp);
}
- break;
- case 'R':
- case 'r': /* newline */
- if (NEWLINE_ONE_CHAR)
- safe_chr('\n', buff, bp);
- else
- safe_str("\r\n", buff, bp);
- break;
- case 'S':
- case 's': /* enactor subjective pronoun */
- if (gender < 0)
- gender = get_gender(enactor);
- safe_str(subj[gender], buff, bp);
- break;
- case 'T':
- case 't': /* tab */
- safe_chr('\t', buff, bp);
- break;
- case 'V':
- case 'v':
- case 'W':
- case 'w':
- case 'X':
- case 'x': /* attribute substitution */
- nextc = **str;
- if (!nextc)
- goto exit_sequence;
- (*str)++;
- temp[0] = UPCASE(savec);
- temp[1] = UPCASE(nextc);
- temp[2] = '\0';
- attrib = atr_get(executor, temp);
- if (attrib)
- safe_str(atr_value(attrib), buff, bp);
- break;
+ break;
+ case 'R':
+ case 'r': /* newline */
+ if (NEWLINE_ONE_CHAR)
+ safe_chr('\n', buff, bp);
+ else
+ safe_str("\r\n", buff, bp);
+ break;
+ case 'S':
+ case 's': /* enactor subjective pronoun */
+ if (gender < 0)
+ gender = get_gender(enactor);
+ safe_str(subj[gender], buff, bp);
+ break;
+ case 'T':
+ case 't': /* tab */
+ safe_chr('\t', buff, bp);
+ break;
+ case 'V':
+ case 'v':
+ case 'W':
+ case 'w':
+ case 'X':
+ case 'x': /* attribute substitution */
+ nextc = **str;
+ if (!nextc)
+ goto exit_sequence;
+ (*str)++;
+ temp[0] = UPCASE(savec);
+ temp[1] = UPCASE(nextc);
+ temp[2] = '\0';
+ attrib = atr_get(executor, temp);
+ if (attrib)
+ safe_str(atr_value(attrib), buff, bp);
+ break;
case 'z':
case 'Z':
nextc = **str;
}
break;
}
- default: /* just copy */
- safe_chr(savec, buff, bp);
- }
+ default: /* just copy */
+ safe_chr(savec, buff, bp);
+ }
- if (isupper((unsigned char) savec))
- *savepos = UPCASE(*savepos);
+ if (isupper((unsigned char) savec))
+ *savepos = UPCASE(*savepos);
}
break;
- case '{': /* "{}" parse group; recurse with no function check */
+ case '{': /* "{}" parse group; recurse with no function check */
if (CALL_LIMIT && (pe_info->call_depth > CALL_LIMIT)) {
- (*str)++;
- break;
+ (*str)++;
+ break;
}
if (eflags & PE_LITERAL) {
- safe_chr('{', buff, bp);
- (*str)++;
- break;
+ safe_chr('{', buff, bp);
+ (*str)++;
+ break;
}
if (!(eflags & (PE_STRIP_BRACES | PE_COMMAND_BRACES)))
- safe_chr('{', buff, bp);
+ safe_chr('{', buff, bp);
(*str)++;
if (process_expression(buff, bp, str,
- executor, caller, enactor,
- eflags & PE_COMMAND_BRACES
- ? (eflags & ~PE_COMMAND_BRACES)
- : (eflags &
- ~(PE_STRIP_BRACES | PE_FUNCTION_CHECK)),
- PT_BRACE, pe_info)) {
- retval = 1;
- break;
+ executor, caller, enactor,
+ eflags & PE_COMMAND_BRACES
+ ? (eflags & ~PE_COMMAND_BRACES)
+ : (eflags &
+ ~(PE_STRIP_BRACES | PE_FUNCTION_CHECK)),
+ PT_BRACE, pe_info)) {
+ retval = 1;
+ break;
}
if (**str == '}') {
- if (!(eflags & (PE_STRIP_BRACES | PE_COMMAND_BRACES)))
- safe_chr('}', buff, bp);
- (*str)++;
+ if (!(eflags & (PE_STRIP_BRACES | PE_COMMAND_BRACES)))
+ safe_chr('}', buff, bp);
+ (*str)++;
}
/* Only strip one set of braces for commands */
eflags &= ~PE_COMMAND_BRACES;
break;
- case '[': /* "[]" parse group; recurse with mandatory function check */
+ case '[': /* "[]" parse group; recurse with mandatory function check */
if (CALL_LIMIT && (pe_info->call_depth > CALL_LIMIT)) {
- (*str)++;
- break;
+ (*str)++;
+ break;
}
if (eflags & PE_LITERAL) {
- safe_chr('[', buff, bp);
- (*str)++;
- break;
+ safe_chr('[', buff, bp);
+ (*str)++;
+ break;
}
if (!(eflags & PE_EVALUATE)) {
- safe_chr('[', buff, bp);
- temp_eflags = eflags & ~PE_STRIP_BRACES;
+ safe_chr('[', buff, bp);
+ temp_eflags = eflags & ~PE_STRIP_BRACES;
} else
- temp_eflags = eflags | PE_FUNCTION_CHECK | PE_FUNCTION_MANDATORY;
+ temp_eflags = eflags | PE_FUNCTION_CHECK | PE_FUNCTION_MANDATORY;
(*str)++;
if (process_expression(buff, bp, str,
- executor, caller, enactor,
- temp_eflags, PT_BRACKET, pe_info)) {
- retval = 1;
- break;
+ executor, caller, enactor,
+ temp_eflags, PT_BRACKET, pe_info)) {
+ retval = 1;
+ break;
}
if (**str == ']') {
- if (!(eflags & PE_EVALUATE))
- safe_chr(']', buff, bp);
- (*str)++;
+ if (!(eflags & PE_EVALUATE))
+ safe_chr(']', buff, bp);
+ (*str)++;
}
break;
- case '(': /* Function call */
+ case '(': /* Function call */
if (CALL_LIMIT && (pe_info->call_depth > CALL_LIMIT)) {
- (*str)++;
- break;
+ (*str)++;
+ break;
}
(*str)++;
if (!(eflags & PE_EVALUATE) || !(eflags & PE_FUNCTION_CHECK)) {
- safe_chr('(', buff, bp);
- if (**str == ' ') {
- safe_chr(**str, buff, bp);
- (*str)++;
- }
- if (process_expression(buff, bp, str,
- executor, caller, enactor,
- eflags & ~PE_STRIP_BRACES, PT_PAREN, pe_info))
- retval = 1;
- if (**str == ')') {
- if (eflags & PE_COMPRESS_SPACES && (*str)[-1] == ' ')
- safe_chr(' ', buff, bp);
- safe_chr(')', buff, bp);
- (*str)++;
- }
- break;
+ safe_chr('(', buff, bp);
+ if (**str == ' ') {
+ safe_chr(**str, buff, bp);
+ (*str)++;
+ }
+ if (process_expression(buff, bp, str,
+ executor, caller, enactor,
+ eflags & ~PE_STRIP_BRACES, PT_PAREN, pe_info))
+ retval = 1;
+ if (**str == ')') {
+ if (eflags & PE_COMPRESS_SPACES && (*str)[-1] == ' ')
+ safe_chr(' ', buff, bp);
+ safe_chr(')', buff, bp);
+ (*str)++;
+ }
+ break;
} else {
- char *sargs[10];
- char **fargs;
- int sarglens[10];
- int *arglens;
- int args_alloced;
- int nfargs;
- int j;
- static char name[BUFFER_LEN];
- char *sp, *tp;
- FUN *fp;
- int temp_tflags;
- int denied;
+ char *sargs[10];
+ char **fargs;
+ int sarglens[10];
+ int *arglens;
+ int args_alloced;
+ int nfargs;
+ int j;
+ static char name[BUFFER_LEN];
+ char *sp, *tp;
+ FUN *fp;
+ int temp_tflags;
+ int denied;
- fargs = sargs;
- arglens = sarglens;
- for (j = 0; j < 10; j++) {
- fargs[j] = NULL;
- arglens[j] = 0;
- }
- args_alloced = 10;
- eflags &= ~PE_FUNCTION_CHECK;
- /* Get the function name */
- for (sp = startpos, tp = name; sp < *bp; sp++)
- safe_chr(UPCASE(*sp), name, &tp);
- *tp = '\0';
- fp = func_hash_lookup(name);
- if (!fp) {
- if (eflags & PE_FUNCTION_MANDATORY) {
- *bp = startpos;
- safe_str(T("#-1 FUNCTION ("), buff, bp);
- safe_str(name, buff, bp);
- safe_str(") NOT FOUND", buff, bp);
- if (process_expression(name, &tp, str,
- executor, caller, enactor,
- PE_NOTHING, PT_PAREN, pe_info))
- retval = 1;
- if (**str == ')')
- (*str)++;
- break;
- }
- safe_chr('(', buff, bp);
- if (**str == ' ') {
- safe_chr(**str, buff, bp);
- (*str)++;
- }
- if (process_expression(buff, bp, str, executor, caller, enactor,
- eflags, PT_PAREN, pe_info)) {
- retval = 1;
- break;
- }
- if (**str == ')') {
- if (eflags & PE_COMPRESS_SPACES && (*str)[-1] == ' ')
- safe_chr(' ', buff, bp);
- safe_chr(')', buff, bp);
- (*str)++;
- }
- break;
- }
- *bp = startpos;
+ fargs = sargs;
+ arglens = sarglens;
+ for (j = 0; j < 10; j++) {
+ fargs[j] = NULL;
+ arglens[j] = 0;
+ }
+ args_alloced = 10;
+ eflags &= ~PE_FUNCTION_CHECK;
+ /* Get the function name */
+ for (sp = startpos, tp = name; sp < *bp; sp++)
+ safe_chr(UPCASE(*sp), name, &tp);
+ *tp = '\0';
+ fp = func_hash_lookup(name);
+ if (!fp) {
+ if (eflags & PE_FUNCTION_MANDATORY) {
+ *bp = startpos;
+ safe_str(T("#-1 FUNCTION ("), buff, bp);
+ safe_str(name, buff, bp);
+ safe_str(") NOT FOUND", buff, bp);
+ if (process_expression(name, &tp, str,
+ executor, caller, enactor,
+ PE_NOTHING, PT_PAREN, pe_info))
+ retval = 1;
+ if (**str == ')')
+ (*str)++;
+ break;
+ }
+ safe_chr('(', buff, bp);
+ if (**str == ' ') {
+ safe_chr(**str, buff, bp);
+ (*str)++;
+ }
+ if (process_expression(buff, bp, str, executor, caller, enactor,
+ eflags, PT_PAREN, pe_info)) {
+ retval = 1;
+ break;
+ }
+ if (**str == ')') {
+ if (eflags & PE_COMPRESS_SPACES && (*str)[-1] == ' ')
+ safe_chr(' ', buff, bp);
+ safe_chr(')', buff, bp);
+ (*str)++;
+ }
+ break;
+ }
+ *bp = startpos;
- /* Check for the invocation limit */
- if ((pe_info->fun_invocations >= FUNCTION_LIMIT) ||
- (global_fun_invocations >= FUNCTION_LIMIT * 5)) {
- e_msg = T(e_invoke);
- e_len = strlen(e_msg);
- if ((buff + e_len > *bp) || strcmp(e_msg, *bp - e_len))
- safe_str(e_msg, buff, bp);
- if (process_expression(name, &tp, str,
- executor, caller, enactor,
- PE_NOTHING, PT_PAREN, pe_info))
- retval = 1;
- if (**str == ')')
- (*str)++;
- break;
- }
- /* Check for the recursion limit */
- if ((pe_info->fun_depth + 1 >= RECURSION_LIMIT) ||
- (global_fun_recursions + 1 >= RECURSION_LIMIT * 5)) {
- safe_str(T("#-1 FUNCTION RECURSION LIMIT EXCEEDED"), buff, bp);
- if (process_expression(name, &tp, str,
- executor, caller, enactor,
- PE_NOTHING, PT_PAREN, pe_info))
- retval = 1;
- if (**str == ')')
- (*str)++;
- break;
- }
- /* Get the arguments */
- temp_eflags = (eflags & ~PE_FUNCTION_MANDATORY)
- | PE_COMPRESS_SPACES | PE_EVALUATE | PE_FUNCTION_CHECK;
- switch (fp->flags & FN_ARG_MASK) {
- case FN_LITERAL:
- temp_eflags |= PE_LITERAL;
- /* FALL THROUGH */
- case FN_NOPARSE:
- temp_eflags &= ~(PE_COMPRESS_SPACES | PE_EVALUATE |
- PE_FUNCTION_CHECK);
- break;
- }
- denied = !check_func(executor, fp);
- if (denied)
- temp_eflags &=
- ~(PE_COMPRESS_SPACES | PE_EVALUATE | PE_FUNCTION_CHECK);
- temp_tflags = PT_COMMA | PT_PAREN;
- nfargs = 0;
- do {
- char *argp;
- if ((fp->maxargs < 0) && ((nfargs + 1) >= -fp->maxargs))
- temp_tflags = PT_PAREN;
- if (nfargs >= args_alloced) {
- char **nargs;
- int *narglens;
- nargs = (char **) mush_malloc((nfargs + 10) * sizeof(char *),
- "process_expression.function_arglist");
- narglens = (int *) mush_malloc((nfargs + 10) * sizeof(int),
- "process_expression.function_arglens");
- for (j = 0; j < nfargs; j++) {
- nargs[j] = fargs[j];
- narglens[j] = arglens[j];
- }
- if (fargs != sargs)
- mush_free((Malloc_t) fargs,
- "process_expression.function_arglist");
- if (arglens != sarglens)
- mush_free((Malloc_t) arglens,
- "process_expression.function_arglens");
- fargs = nargs;
- arglens = narglens;
- args_alloced += 10;
- }
- fargs[nfargs] = (char *) mush_malloc(BUFFER_LEN,
- "process_expression.function_argument");
- argp = fargs[nfargs];
- if (process_expression(fargs[nfargs], &argp, str,
- executor, caller, enactor,
- temp_eflags, temp_tflags, pe_info)) {
- retval = 1;
- nfargs++;
- goto free_func_args;
- }
- *argp = '\0';
- arglens[nfargs] = argp - fargs[nfargs];
- (*str)++;
- nfargs++;
- } while ((*str)[-1] == ',');
- if ((*str)[-1] != ')')
- (*str)--;
- /* See if this function is enabled */
- /* Can't do this check earlier, because of possible side effects
- * from the functions. Bah. */
- if (denied) {
- if (fp->flags & FN_DISABLED)
- safe_str(T(e_disabled), buff, bp);
- else
- safe_str(T(e_perm), buff, bp);
- goto free_func_args;
- } else {
- /* If we have the right number of args, eval the function.
- * Otherwise, return an error message.
- * Special case: zero args is recognized as one null arg.
- */
- if ((fp->minargs == 0 || (fp->minargs == 1 && (fp->flags & FN_ONEARG))) && (nfargs == 1) && (!*fargs[0] || arglens[0]== 0)) {
- mush_free((Malloc_t) fargs[0],
- "process_expression.function_argument");
- fargs[0] = NULL;
- arglens[0] = 0;
- nfargs = 0;
- }
- if ((nfargs < fp->minargs) || (nfargs > abs(fp->maxargs))) {
- safe_str(T("#-1 FUNCTION ("), buff, bp);
- safe_str(fp->name, buff, bp);
- safe_str(") EXPECTS ", buff, bp);
- if (fp->minargs == abs(fp->maxargs)) {
- safe_integer(fp->minargs, buff, bp);
- } else if ((fp->minargs + 1) == abs(fp->maxargs)) {
- safe_integer(fp->minargs, buff, bp);
- safe_str(" OR ", buff, bp);
- safe_integer(abs(fp->maxargs), buff, bp);
- } else if (fp->maxargs == INT_MAX) {
- safe_str("AT LEAST ", buff, bp);
- safe_integer(fp->minargs, buff, bp);
- } else {
- safe_str("BETWEEN ", buff, bp);
- safe_integer(fp->minargs, buff, bp);
- safe_str(" AND ", buff, bp);
- safe_integer(abs(fp->maxargs), buff, bp);
- }
- safe_str(" ARGUMENTS BUT GOT ", buff, bp);
- safe_integer(nfargs, buff, bp);
- } else {
- global_fun_recursions++;
- pe_info->fun_depth++;
- if (fp->flags & FN_BUILTIN) {
- global_fun_invocations++;
- pe_info->fun_invocations++;
- fp->where.fun(fp, buff, bp, nfargs, fargs, arglens, executor,
- caller, enactor, fp->name, pe_info);
- if (fp->flags & FN_LOGARGS) {
- char logstr[BUFFER_LEN];
- char *logp;
- int logi;
- logp = logstr;
- safe_str(fp->name, logstr, &logp);
- safe_chr('(', logstr, &logp);
- for (logi = 0; logi < nfargs; logi++) {
- safe_str(fargs[logi], logstr, &logp);
- if (logi + 1 < nfargs)
- safe_chr(',', logstr, &logp);
- }
- safe_chr(')', logstr, &logp);
- *logp = '\0';
- do_log(LT_CMD, executor, caller, "%s", logstr);
- } else if (fp->flags & FN_LOGNAME)
- do_log(LT_CMD, executor, caller, "%s()", fp->name);
- } else {
- dbref thing;
- ATTR *attrib;
- global_fun_invocations++;
- pe_info->fun_invocations++;
- thing = userfn_tab[fp->where.offset].thing;
- attrib = atr_get(thing, userfn_tab[fp->where.offset].name);
- if (!attrib) {
- do_rawlog(LT_ERR,
- T("ERROR: @function (%s) without attribute (#%d/%s)"),
- fp->name, thing, userfn_tab[fp->where.offset].name);
- safe_str("#-1 @FUNCTION (", buff, bp);
- safe_str(fp->name, buff, bp);
- safe_str(") MISSING ATTRIBUTE (", buff, bp);
- safe_dbref(thing, buff, bp);
- safe_chr('/', buff, bp);
- safe_str(userfn_tab[fp->where.offset].name, buff, bp);
- safe_chr(')', buff, bp);
- } else {
- char *preserve[NUMQ];
- dbref local_ooref;
- if (fp->flags & FN_LOCALIZE)
- save_global_regs("@function.save", preserve);
- /* Temporarily change ooref */
- local_ooref = ooref;
- ooref = attrib->creator;
- do_userfn(buff, bp, thing, attrib, nfargs, fargs,
- executor, caller, enactor, pe_info);
- ooref = local_ooref;
- if (fp->flags & FN_LOCALIZE)
- restore_global_regs("@function.save", preserve);
- }
- }
- pe_info->fun_depth--;
- global_fun_recursions--;
- }
- }
- /* Free up the space allocated for the args */
+ /* Check for the invocation limit */
+ if ((pe_info->fun_invocations >= FUNCTION_LIMIT) ||
+ (global_fun_invocations >= FUNCTION_LIMIT * 5)) {
+ e_msg = T(e_invoke);
+ e_len = strlen(e_msg);
+ if ((buff + e_len > *bp) || strcmp(e_msg, *bp - e_len))
+ safe_str(e_msg, buff, bp);
+ if (process_expression(name, &tp, str,
+ executor, caller, enactor,
+ PE_NOTHING, PT_PAREN, pe_info))
+ retval = 1;
+ if (**str == ')')
+ (*str)++;
+ break;
+ }
+ /* Check for the recursion limit */
+ if ((pe_info->fun_depth + 1 >= RECURSION_LIMIT) ||
+ (global_fun_recursions + 1 >= RECURSION_LIMIT * 5)) {
+ safe_str(T("#-1 FUNCTION RECURSION LIMIT EXCEEDED"), buff, bp);
+ if (process_expression(name, &tp, str,
+ executor, caller, enactor,
+ PE_NOTHING, PT_PAREN, pe_info))
+ retval = 1;
+ if (**str == ')')
+ (*str)++;
+ break;
+ }
+ /* Get the arguments */
+ temp_eflags = (eflags & ~PE_FUNCTION_MANDATORY)
+ | PE_COMPRESS_SPACES | PE_EVALUATE | PE_FUNCTION_CHECK;
+ switch (fp->flags & FN_ARG_MASK) {
+ case FN_LITERAL:
+ temp_eflags |= PE_LITERAL;
+ /* FALL THROUGH */
+ case FN_NOPARSE:
+ temp_eflags &= ~(PE_COMPRESS_SPACES | PE_EVALUATE |
+ PE_FUNCTION_CHECK);
+ break;
+ }
+ denied = !check_func(executor, fp);
+ if (denied)
+ temp_eflags &=
+ ~(PE_COMPRESS_SPACES | PE_EVALUATE | PE_FUNCTION_CHECK);
+ temp_tflags = PT_COMMA | PT_PAREN;
+ nfargs = 0;
+ do {
+ char *argp;
+ if ((fp->maxargs < 0) && ((nfargs + 1) >= -fp->maxargs))
+ temp_tflags = PT_PAREN;
+ if (nfargs >= args_alloced) {
+ char **nargs;
+ int *narglens;
+ nargs = (char **) mush_malloc((nfargs + 10) * sizeof(char *),
+ "process_expression.function_arglist");
+ narglens = (int *) mush_malloc((nfargs + 10) * sizeof(int),
+ "process_expression.function_arglens");
+ for (j = 0; j < nfargs; j++) {
+ nargs[j] = fargs[j];
+ narglens[j] = arglens[j];
+ }
+ if (fargs != sargs)
+ mush_free((Malloc_t) fargs,
+ "process_expression.function_arglist");
+ if (arglens != sarglens)
+ mush_free((Malloc_t) arglens,
+ "process_expression.function_arglens");
+ fargs = nargs;
+ arglens = narglens;
+ args_alloced += 10;
+ }
+ fargs[nfargs] = (char *) mush_malloc(BUFFER_LEN,
+ "process_expression.function_argument");
+ argp = fargs[nfargs];
+ if (process_expression(fargs[nfargs], &argp, str,
+ executor, caller, enactor,
+ temp_eflags, temp_tflags, pe_info)) {
+ retval = 1;
+ nfargs++;
+ goto free_func_args;
+ }
+ *argp = '\0';
+ arglens[nfargs] = argp - fargs[nfargs];
+ (*str)++;
+ nfargs++;
+ } while ((*str)[-1] == ',');
+ if ((*str)[-1] != ')')
+ (*str)--;
+ /* See if this function is enabled */
+ /* Can't do this check earlier, because of possible side effects
+ * from the functions. Bah. */
+ if (denied) {
+ if (fp->flags & FN_DISABLED)
+ safe_str(T(e_disabled), buff, bp);
+ else
+ safe_str(T(e_perm), buff, bp);
+ goto free_func_args;
+ } else {
+ /* If we have the right number of args, eval the function.
+ * Otherwise, return an error message.
+ * Special case: zero args is recognized as one null arg.
+ */
+ if ((fp->minargs == 0 || (fp->minargs == 1 && (fp->flags & FN_ONEARG))) && (nfargs == 1) && (!*fargs[0] || arglens[0]== 0)) {
+ mush_free((Malloc_t) fargs[0],
+ "process_expression.function_argument");
+ fargs[0] = NULL;
+ arglens[0] = 0;
+ nfargs = 0;
+ }
+ if ((nfargs < fp->minargs) || (nfargs > abs(fp->maxargs))) {
+ safe_str(T("#-1 FUNCTION ("), buff, bp);
+ safe_str(fp->name, buff, bp);
+ safe_str(") EXPECTS ", buff, bp);
+ if (fp->minargs == abs(fp->maxargs)) {
+ safe_integer(fp->minargs, buff, bp);
+ } else if ((fp->minargs + 1) == abs(fp->maxargs)) {
+ safe_integer(fp->minargs, buff, bp);
+ safe_str(" OR ", buff, bp);
+ safe_integer(abs(fp->maxargs), buff, bp);
+ } else if (fp->maxargs == INT_MAX) {
+ safe_str("AT LEAST ", buff, bp);
+ safe_integer(fp->minargs, buff, bp);
+ } else {
+ safe_str("BETWEEN ", buff, bp);
+ safe_integer(fp->minargs, buff, bp);
+ safe_str(" AND ", buff, bp);
+ safe_integer(abs(fp->maxargs), buff, bp);
+ }
+ safe_str(" ARGUMENTS BUT GOT ", buff, bp);
+ safe_integer(nfargs, buff, bp);
+ } else {
+ global_fun_recursions++;
+ pe_info->fun_depth++;
+ if (fp->flags & FN_BUILTIN) {
+ global_fun_invocations++;
+ pe_info->fun_invocations++;
+ fp->where.fun(fp, buff, bp, nfargs, fargs, arglens, executor,
+ caller, enactor, fp->name, pe_info);
+ if (fp->flags & FN_LOGARGS) {
+ char logstr[BUFFER_LEN];
+ char *logp;
+ int logi;
+ logp = logstr;
+ safe_str(fp->name, logstr, &logp);
+ safe_chr('(', logstr, &logp);
+ for (logi = 0; logi < nfargs; logi++) {
+ safe_str(fargs[logi], logstr, &logp);
+ if (logi + 1 < nfargs)
+ safe_chr(',', logstr, &logp);
+ }
+ safe_chr(')', logstr, &logp);
+ *logp = '\0';
+ do_log(LT_CMD, executor, caller, "%s", logstr);
+ } else if (fp->flags & FN_LOGNAME)
+ do_log(LT_CMD, executor, caller, "%s()", fp->name);
+ } else {
+ dbref thing;
+ ATTR *attrib;
+ global_fun_invocations++;
+ pe_info->fun_invocations++;
+ thing = userfn_tab[fp->where.offset].thing;
+ attrib = atr_get(thing, userfn_tab[fp->where.offset].name);
+ if (!attrib) {
+ do_rawlog(LT_ERR,
+ T("ERROR: @function (%s) without attribute (#%d/%s)"),
+ fp->name, thing, userfn_tab[fp->where.offset].name);
+ safe_str("#-1 @FUNCTION (", buff, bp);
+ safe_str(fp->name, buff, bp);
+ safe_str(") MISSING ATTRIBUTE (", buff, bp);
+ safe_dbref(thing, buff, bp);
+ safe_chr('/', buff, bp);
+ safe_str(userfn_tab[fp->where.offset].name, buff, bp);
+ safe_chr(')', buff, bp);
+ } else {
+ char *preserve[NUMQ];
+ dbref local_ooref;
+ if (fp->flags & FN_LOCALIZE)
+ save_global_regs("@function.save", preserve);
+ /* Temporarily change ooref */
+ local_ooref = ooref;
+ ooref = attrib->creator;
+ do_userfn(buff, bp, thing, attrib, nfargs, fargs,
+ executor, caller, enactor, pe_info);
+ ooref = local_ooref;
+ if (fp->flags & FN_LOCALIZE)
+ restore_global_regs("@function.save", preserve);
+ }
+ }
+ pe_info->fun_depth--;
+ global_fun_recursions--;
+ }
+ }
+ /* Free up the space allocated for the args */
free_func_args:
- for (j = 0; j < nfargs; j++)
- if (fargs[j])
- mush_free((Malloc_t) fargs[j],
- "process_expression.function_argument");
- if (fargs != sargs)
- mush_free((Malloc_t) fargs, "process_expression.function_arglist");
- if (arglens != sarglens)
- mush_free((Malloc_t) arglens, "process_expression.function_arglens");
+ for (j = 0; j < nfargs; j++)
+ if (fargs[j])
+ mush_free((Malloc_t) fargs[j],
+ "process_expression.function_argument");
+ if (fargs != sargs)
+ mush_free((Malloc_t) fargs, "process_expression.function_arglist");
+ if (arglens != sarglens)
+ mush_free((Malloc_t) arglens, "process_expression.function_arglens");
}
break;
/* Space compression */
safe_chr(' ', buff, bp);
(*str)++;
if (eflags & PE_COMPRESS_SPACES) {
- while (**str == ' ')
- (*str)++;
+ while (**str == ' ')
+ (*str)++;
} else
- while (**str == ' ') {
- safe_chr(' ', buff, bp);
- (*str)++;
- }
+ while (**str == ' ') {
+ safe_chr(' ', buff, bp);
+ (*str)++;
+ }
break;
/* Escape charater */
case '\\':
if (!(eflags & PE_EVALUATE))
- safe_chr('\\', buff, bp);
+ safe_chr('\\', buff, bp);
(*str)++;
if (!**str)
- goto exit_sequence;
+ goto exit_sequence;
/* FALL THROUGH */
/* Basic character */
default:
exit_sequence:
if (eflags != PE_NOTHING) {
if ((eflags & PE_COMPRESS_SPACES) && had_space &&
- ((*str)[-1] == ' ') && ((*bp)[-1] == ' '))
+ ((*str)[-1] == ' ') && ((*bp)[-1] == ' '))
(*bp)--;
if (debugging) {
pe_info->nest_depth--;
**bp = '\0';
if (strcmp(sourcestr, startpos)) {
- static char dbuf[BUFFER_LEN];
- char *dbp;
- if (pe_info->debug_strings) {
- while (pe_info->debug_strings->prev)
- pe_info->debug_strings = pe_info->debug_strings->prev;
- while (pe_info->debug_strings->next) {
- dbp = dbuf;
- dbuf[0] = '\0';
- safe_format(dbuf, &dbp, "%s :", pe_info->debug_strings->string);
- *dbp = '\0';
- if (Connected(Owner(executor)))
- raw_notify(Owner(executor), dbuf);
- notify_list(executor, executor, "DEBUGFORWARDLIST", dbuf,
- NA_NOLISTEN | NA_NOPREFIX);
- pe_info->debug_strings = pe_info->debug_strings->next;
- mush_free((Malloc_t) pe_info->debug_strings->prev,
- "process_expression.debug_node");
- }
- mush_free((Malloc_t) pe_info->debug_strings,
- "process_expression.debug_node");
- pe_info->debug_strings = NULL;
- }
- dbp = dbuf;
- dbuf[0] = '\0';
- safe_format(dbuf, &dbp, "%s => %s", debugstr, startpos);
- *dbp = '\0';
- if (Connected(Owner(executor)))
- raw_notify(Owner(executor), dbuf);
- notify_list(executor, executor, "DEBUGFORWARDLIST", dbuf,
- NA_NOLISTEN | NA_NOPREFIX);
+ static char dbuf[BUFFER_LEN];
+ char *dbp;
+ if (pe_info->debug_strings) {
+ while (pe_info->debug_strings->prev)
+ pe_info->debug_strings = pe_info->debug_strings->prev;
+ while (pe_info->debug_strings->next) {
+ dbp = dbuf;
+ dbuf[0] = '\0';
+ safe_format(dbuf, &dbp, "%s :", pe_info->debug_strings->string);
+ *dbp = '\0';
+ if (Connected(Owner(executor)))
+ raw_notify(Owner(executor), dbuf);
+ notify_list(executor, executor, "DEBUGFORWARDLIST", dbuf,
+ NA_NOLISTEN | NA_NOPREFIX);
+ pe_info->debug_strings = pe_info->debug_strings->next;
+ mush_free((Malloc_t) pe_info->debug_strings->prev,
+ "process_expression.debug_node");
+ }
+ mush_free((Malloc_t) pe_info->debug_strings,
+ "process_expression.debug_node");
+ pe_info->debug_strings = NULL;
+ }
+ dbp = dbuf;
+ dbuf[0] = '\0';
+ safe_format(dbuf, &dbp, "%s => %s", debugstr, startpos);
+ *dbp = '\0';
+ if (Connected(Owner(executor)))
+ raw_notify(Owner(executor), dbuf);
+ notify_list(executor, executor, "DEBUGFORWARDLIST", dbuf,
+ NA_NOLISTEN | NA_NOPREFIX);
} else {
- Debug_Info *node;
- node = pe_info->debug_strings;
- if (node) {
- pe_info->debug_strings = node->prev;
- if (node->prev)
- node->prev->next = NULL;
- mush_free((Malloc_t) node, "process_expression.debug_node");
- }
+ Debug_Info *node;
+ node = pe_info->debug_strings;
+ if (node) {
+ pe_info->debug_strings = node->prev;
+ if (node->prev)
+ node->prev->next = NULL;
+ mush_free((Malloc_t) node, "process_expression.debug_node");
+ }
}
mush_free((Malloc_t) debugstr, "process_expression.debug_source");
}
}
#ifdef WIN32
-#pragma warning( default : 4761) /* NJG: enable warning re conversion */
+#pragma warning( default : 4761) /* NJG: enable warning re conversion */
#endif
-#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
+#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
typedef unsigned char uschar;
with negative values. The public options defined in pcre.h start at the least
significant end. Make sure they don't overlap! */
-#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
-#define PCRE_REQCHSET 0x20000000 /* req_byte is set */
-#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
-#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
-#define PCRE_NOPARTIAL 0x04000000 /* can't use partial with this regex */
+#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
+#define PCRE_REQCHSET 0x20000000 /* req_byte is set */
+#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
+#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
+#define PCRE_NOPARTIAL 0x04000000 /* can't use partial with this regex */
/* Options for the "extra" block produced by pcre_study(). */
-#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
+#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
/* Masks for identifying the public options that are permitted at compile
time, run time, or study time, respectively. */
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART)
-#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
+#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
/* Magic number to provide a small check against being handed junk. Also used
to detect whether a pattern was compiled on a host of different endianness. */
-#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
+#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
/* Negative values for the firstchar and reqchar variables */
/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
variable-length repeat, or a anything other than literal characters. */
-#define REQ_CASELESS 0x0100 /* indicates caselessness */
-#define REQ_VARY 0x0200 /* reqbyte followed non-literal item */
+#define REQ_CASELESS 0x0100 /* indicates caselessness */
+#define REQ_VARY 0x0200 /* reqbyte followed non-literal item */
/* Miscellaneous definitions */
/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain UTF-8 characters with values greater than 255. */
-#define XCL_NOT 0x01 /* Flag: this is a negative class */
-#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
+#define XCL_NOT 0x01 /* Flag: this is a negative class */
+#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
-#define XCL_END 0 /* Marks end of individual items */
-#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
-#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
-#define XCL_PROP 3 /* Unicode property (one property code) follows */
-#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
+#define XCL_END 0 /* Marks end of individual items */
+#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
+#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
+#define XCL_PROP 3 /* Unicode property (one property code) follows */
+#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
must also be updated to match. */
enum {
- OP_END, /* 0 End of pattern */
+ OP_END, /* 0 End of pattern */
/* Values corresponding to backslashed metacharacters */
- OP_SOD, /* 1 Start of data: \A */
- OP_SOM, /* 2 Start of match (subject + offset): \G */
- OP_NOT_WORD_BOUNDARY, /* 3 \B */
- OP_WORD_BOUNDARY, /* 4 \b */
- OP_NOT_DIGIT, /* 5 \D */
- OP_DIGIT, /* 6 \d */
- OP_NOT_WHITESPACE, /* 7 \S */
- OP_WHITESPACE, /* 8 \s */
- OP_NOT_WORDCHAR, /* 9 \W */
- OP_WORDCHAR, /* 10 \w */
- OP_ANY, /* 11 Match any character */
- OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
- OP_NOTPROP, /* 13 \P (not Unicode property) */
- OP_PROP, /* 14 \p (Unicode property) */
- OP_EXTUNI, /* 15 \X (extended Unicode sequence */
- OP_EODN, /* 16 End of data or \n at end of data: \Z. */
- OP_EOD, /* 17 End of data: \z */
-
- OP_OPT, /* 18 Set runtime options */
- OP_CIRC, /* 19 Start of line - varies with multiline switch */
- OP_DOLL, /* 20 End of line - varies with multiline switch */
- OP_CHAR, /* 21 Match one character, casefully */
- OP_CHARNC, /* 22 Match one character, caselessly */
- OP_NOT, /* 23 Match anything but the following char */
-
- OP_STAR, /* 24 The maximizing and minimizing versions of */
- OP_MINSTAR, /* 25 all these opcodes must come in pairs, with */
- OP_PLUS, /* 26 the minimizing one second. */
- OP_MINPLUS, /* 27 This first set applies to single characters */
- OP_QUERY, /* 28 */
- OP_MINQUERY, /* 29 */
- OP_UPTO, /* 30 From 0 to n matches */
- OP_MINUPTO, /* 31 */
- OP_EXACT, /* 32 Exactly n matches */
-
- OP_NOTSTAR, /* 33 The maximizing and minimizing versions of */
- OP_NOTMINSTAR, /* 34 all these opcodes must come in pairs, with */
- OP_NOTPLUS, /* 35 the minimizing one second. */
- OP_NOTMINPLUS, /* 36 This set applies to "not" single characters */
- OP_NOTQUERY, /* 37 */
- OP_NOTMINQUERY, /* 38 */
- OP_NOTUPTO, /* 39 From 0 to n matches */
- OP_NOTMINUPTO, /* 40 */
- OP_NOTEXACT, /* 41 Exactly n matches */
-
- OP_TYPESTAR, /* 42 The maximizing and minimizing versions of */
- OP_TYPEMINSTAR, /* 43 all these opcodes must come in pairs, with */
- OP_TYPEPLUS, /* 44 the minimizing one second. These codes must */
- OP_TYPEMINPLUS, /* 45 be in exactly the same order as those above. */
- OP_TYPEQUERY, /* 46 This set applies to character types such as \d */
- OP_TYPEMINQUERY, /* 47 */
- OP_TYPEUPTO, /* 48 From 0 to n matches */
- OP_TYPEMINUPTO, /* 49 */
- OP_TYPEEXACT, /* 50 Exactly n matches */
-
- OP_CRSTAR, /* 51 The maximizing and minimizing versions of */
- OP_CRMINSTAR, /* 52 all these opcodes must come in pairs, with */
- OP_CRPLUS, /* 53 the minimizing one second. These codes must */
- OP_CRMINPLUS, /* 54 be in exactly the same order as those above. */
- OP_CRQUERY, /* 55 These are for character classes and back refs */
- OP_CRMINQUERY, /* 56 */
- OP_CRRANGE, /* 57 These are different to the three sets above. */
- OP_CRMINRANGE, /* 58 */
-
- OP_CLASS, /* 59 Match a character class, chars < 256 only */
- OP_NCLASS, /* 60 Same, but the bitmap was created from a negative
- class - the difference is relevant only when a UTF-8
- character > 255 is encountered. */
-
- OP_XCLASS, /* 61 Extended class for handling UTF-8 chars within the
- class. This does both positive and negative. */
-
- OP_REF, /* 62 Match a back reference */
- OP_RECURSE, /* 63 Match a numbered subpattern (possibly recursive) */
- OP_CALLOUT, /* 64 Call out to external function if provided */
-
- OP_ALT, /* 65 Start of alternation */
- OP_KET, /* 66 End of group that doesn't have an unbounded repeat */
- OP_KETRMAX, /* 67 These two must remain together and in this */
- OP_KETRMIN, /* 68 order. They are for groups the repeat for ever. */
+ OP_SOD, /* 1 Start of data: \A */
+ OP_SOM, /* 2 Start of match (subject + offset): \G */
+ OP_NOT_WORD_BOUNDARY, /* 3 \B */
+ OP_WORD_BOUNDARY, /* 4 \b */
+ OP_NOT_DIGIT, /* 5 \D */
+ OP_DIGIT, /* 6 \d */
+ OP_NOT_WHITESPACE, /* 7 \S */
+ OP_WHITESPACE, /* 8 \s */
+ OP_NOT_WORDCHAR, /* 9 \W */
+ OP_WORDCHAR, /* 10 \w */
+ OP_ANY, /* 11 Match any character */
+ OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
+ OP_NOTPROP, /* 13 \P (not Unicode property) */
+ OP_PROP, /* 14 \p (Unicode property) */
+ OP_EXTUNI, /* 15 \X (extended Unicode sequence */
+ OP_EODN, /* 16 End of data or \n at end of data: \Z. */
+ OP_EOD, /* 17 End of data: \z */
+
+ OP_OPT, /* 18 Set runtime options */
+ OP_CIRC, /* 19 Start of line - varies with multiline switch */
+ OP_DOLL, /* 20 End of line - varies with multiline switch */
+ OP_CHAR, /* 21 Match one character, casefully */
+ OP_CHARNC, /* 22 Match one character, caselessly */
+ OP_NOT, /* 23 Match anything but the following char */
+
+ OP_STAR, /* 24 The maximizing and minimizing versions of */
+ OP_MINSTAR, /* 25 all these opcodes must come in pairs, with */
+ OP_PLUS, /* 26 the minimizing one second. */
+ OP_MINPLUS, /* 27 This first set applies to single characters */
+ OP_QUERY, /* 28 */
+ OP_MINQUERY, /* 29 */
+ OP_UPTO, /* 30 From 0 to n matches */
+ OP_MINUPTO, /* 31 */
+ OP_EXACT, /* 32 Exactly n matches */
+
+ OP_NOTSTAR, /* 33 The maximizing and minimizing versions of */
+ OP_NOTMINSTAR, /* 34 all these opcodes must come in pairs, with */
+ OP_NOTPLUS, /* 35 the minimizing one second. */
+ OP_NOTMINPLUS, /* 36 This set applies to "not" single characters */
+ OP_NOTQUERY, /* 37 */
+ OP_NOTMINQUERY, /* 38 */
+ OP_NOTUPTO, /* 39 From 0 to n matches */
+ OP_NOTMINUPTO, /* 40 */
+ OP_NOTEXACT, /* 41 Exactly n matches */
+
+ OP_TYPESTAR, /* 42 The maximizing and minimizing versions of */
+ OP_TYPEMINSTAR, /* 43 all these opcodes must come in pairs, with */
+ OP_TYPEPLUS, /* 44 the minimizing one second. These codes must */
+ OP_TYPEMINPLUS, /* 45 be in exactly the same order as those above. */
+ OP_TYPEQUERY, /* 46 This set applies to character types such as \d */
+ OP_TYPEMINQUERY, /* 47 */
+ OP_TYPEUPTO, /* 48 From 0 to n matches */
+ OP_TYPEMINUPTO, /* 49 */
+ OP_TYPEEXACT, /* 50 Exactly n matches */
+
+ OP_CRSTAR, /* 51 The maximizing and minimizing versions of */
+ OP_CRMINSTAR, /* 52 all these opcodes must come in pairs, with */
+ OP_CRPLUS, /* 53 the minimizing one second. These codes must */
+ OP_CRMINPLUS, /* 54 be in exactly the same order as those above. */
+ OP_CRQUERY, /* 55 These are for character classes and back refs */
+ OP_CRMINQUERY, /* 56 */
+ OP_CRRANGE, /* 57 These are different to the three sets above. */
+ OP_CRMINRANGE, /* 58 */
+
+ OP_CLASS, /* 59 Match a character class, chars < 256 only */
+ OP_NCLASS, /* 60 Same, but the bitmap was created from a negative
+ class - the difference is relevant only when a UTF-8
+ character > 255 is encountered. */
+
+ OP_XCLASS, /* 61 Extended class for handling UTF-8 chars within the
+ class. This does both positive and negative. */
+
+ OP_REF, /* 62 Match a back reference */
+ OP_RECURSE, /* 63 Match a numbered subpattern (possibly recursive) */
+ OP_CALLOUT, /* 64 Call out to external function if provided */
+
+ OP_ALT, /* 65 Start of alternation */
+ OP_KET, /* 66 End of group that doesn't have an unbounded repeat */
+ OP_KETRMAX, /* 67 These two must remain together and in this */
+ OP_KETRMIN, /* 68 order. They are for groups the repeat for ever. */
/* The assertions must come before ONCE and COND */
- OP_ASSERT, /* 69 Positive lookahead */
- OP_ASSERT_NOT, /* 70 Negative lookahead */
- OP_ASSERTBACK, /* 71 Positive lookbehind */
- OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */
- OP_REVERSE, /* 73 Move pointer back - used in lookbehind assertions */
+ OP_ASSERT, /* 69 Positive lookahead */
+ OP_ASSERT_NOT, /* 70 Negative lookahead */
+ OP_ASSERTBACK, /* 71 Positive lookbehind */
+ OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */
+ OP_REVERSE, /* 73 Move pointer back - used in lookbehind assertions */
/* ONCE and COND must come after the assertions, with ONCE first, as there's
a test for >= ONCE for a subpattern that isn't an assertion. */
- OP_ONCE, /* 74 Once matched, don't back up into the subpattern */
- OP_COND, /* 75 Conditional group */
- OP_CREF, /* 76 Used to hold an extraction string number (cond ref) */
+ OP_ONCE, /* 74 Once matched, don't back up into the subpattern */
+ OP_COND, /* 75 Conditional group */
+ OP_CREF, /* 76 Used to hold an extraction string number (cond ref) */
- OP_BRAZERO, /* 77 These two must remain together and in this */
- OP_BRAMINZERO, /* 78 order. */
+ OP_BRAZERO, /* 77 These two must remain together and in this */
+ OP_BRAMINZERO, /* 78 order. */
- OP_BRANUMBER, /* 79 Used for extracting brackets whose number is greater
- than can fit into an opcode. */
+ OP_BRANUMBER, /* 79 Used for extracting brackets whose number is greater
+ than can fit into an opcode. */
- OP_BRA /* 80 This and greater values are used for brackets that
- extract substrings up to EXTRACT_BASIC_MAX. After
- that, use is made of OP_BRANUMBER. */
+ OP_BRA /* 80 This and greater values are used for brackets that
+ extract substrings up to EXTRACT_BASIC_MAX. After
+ that, use is made of OP_BRANUMBER. */
};
/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and
typedef struct real_pcre {
pcre_uint32 magic_number;
- pcre_uint32 size; /* Total that was malloced */
+ pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
- pcre_uint32 dummy1; /* For future use, maybe */
+ pcre_uint32 dummy1; /* For future use, maybe */
pcre_uint16 top_bracket;
pcre_uint16 top_backref;
pcre_uint16 first_byte;
pcre_uint16 req_byte;
- pcre_uint16 name_table_offset; /* Offset to name table that follows */
- pcre_uint16 name_entry_size; /* Size of any name items */
- pcre_uint16 name_count; /* Number of name items */
- pcre_uint16 ref_count; /* Reference count */
+ pcre_uint16 name_table_offset; /* Offset to name table that follows */
+ pcre_uint16 name_entry_size; /* Size of any name items */
+ pcre_uint16 name_count; /* Number of name items */
+ pcre_uint16 ref_count; /* Reference count */
- const unsigned char *tables; /* Pointer to tables or NULL for std */
- const unsigned char *nullpad; /* NULL padding */
+ const unsigned char *tables; /* Pointer to tables or NULL for std */
+ const unsigned char *nullpad; /* NULL padding */
} real_pcre;
/* The format of the block used to store data from pcre_study(). The same
remark (see NOTE above) about extending this structure applies. */
typedef struct pcre_study_data {
- pcre_uint32 size; /* Total that was malloced */
+ pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
uschar start_bits[32];
} pcre_study_data;
doing the compiling, so that they are thread-safe. */
typedef struct compile_data {
- const uschar *lcc; /* Points to lower casing table */
- const uschar *fcc; /* Points to case-flipping table */
- const uschar *cbits; /* Points to character type table */
- const uschar *ctypes; /* Points to table of type maps */
- const uschar *start_code; /* The start of the compiled code */
- const uschar *start_pattern; /* The start of the pattern */
- uschar *name_table; /* The name/number table */
- int names_found; /* Number of entries so far */
- int name_entry_size; /* Size of each entry */
- int top_backref; /* Maximum back reference */
- unsigned int backref_map; /* Bitmap of low back refs */
- int req_varyopt; /* "After variable item" flag for reqbyte */
- BOOL nopartial; /* Set TRUE if partial won't work */
+ const uschar *lcc; /* Points to lower casing table */
+ const uschar *fcc; /* Points to case-flipping table */
+ const uschar *cbits; /* Points to character type table */
+ const uschar *ctypes; /* Points to table of type maps */
+ const uschar *start_code; /* The start of the compiled code */
+ const uschar *start_pattern; /* The start of the pattern */
+ uschar *name_table; /* The name/number table */
+ int names_found; /* Number of entries so far */
+ int name_entry_size; /* Size of each entry */
+ int top_backref; /* Maximum back reference */
+ unsigned int backref_map; /* Bitmap of low back refs */
+ int req_varyopt; /* "After variable item" flag for reqbyte */
+ BOOL nopartial; /* Set TRUE if partial won't work */
} compile_data;
/* Structure for maintaining a chain of pointers to the currently incomplete
call within the pattern. */
typedef struct recursion_info {
- struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
- int group_num; /* Number of group that was called */
- const uschar *after_call; /* "Return value": points after the call in the expr */
- const uschar *save_start; /* Old value of md->start_match */
- int *offset_save; /* Pointer to start of saved offsets */
- int saved_max; /* Number of saved offsets */
+ struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
+ int group_num; /* Number of group that was called */
+ const uschar *after_call; /* "Return value": points after the call in the expr */
+ const uschar *save_start; /* Old value of md->start_match */
+ int *offset_save; /* Pointer to start of saved offsets */
+ int saved_max; /* Number of saved offsets */
} recursion_info;
/* When compiling in a mode that doesn't use recursive calls to match(),
doing traditional NFA matching, so that they are thread-safe. */
typedef struct match_data {
- unsigned long int match_call_count; /* As it says */
- unsigned long int match_limit; /* As it says */
- int *offset_vector; /* Offset vector */
- int offset_end; /* One past the end */
- int offset_max; /* The maximum usable for return data */
- const uschar *lcc; /* Points to lower casing table */
- const uschar *ctypes; /* Points to table of type maps */
- BOOL offset_overflow; /* Set if too many extractions */
- BOOL notbol; /* NOTBOL flag */
- BOOL noteol; /* NOTEOL flag */
- BOOL utf8; /* UTF8 flag */
- BOOL endonly; /* Dollar not before final \n */
- BOOL notempty; /* Empty string match not wanted */
- BOOL partial; /* PARTIAL flag */
- BOOL hitend; /* Hit the end of the subject at some point */
- const uschar *start_code; /* For use when recursing */
- const uschar *start_subject; /* Start of the subject string */
- const uschar *end_subject; /* End of the subject string */
- const uschar *start_match; /* Start of this match attempt */
- const uschar *end_match_ptr; /* Subject position at end match */
- int end_offset_top; /* Highwater mark at end of match */
- int capture_last; /* Most recent capture number */
- int start_offset; /* The start offset value */
- recursion_info *recursive; /* Linked list of recursion data */
- void *callout_data; /* To pass back to callouts */
- struct heapframe *thisframe; /* Used only when compiling for no recursion */
+ unsigned long int match_call_count; /* As it says */
+ unsigned long int match_limit; /* As it says */
+ int *offset_vector; /* Offset vector */
+ int offset_end; /* One past the end */
+ int offset_max; /* The maximum usable for return data */
+ const uschar *lcc; /* Points to lower casing table */
+ const uschar *ctypes; /* Points to table of type maps */
+ BOOL offset_overflow; /* Set if too many extractions */
+ BOOL notbol; /* NOTBOL flag */
+ BOOL noteol; /* NOTEOL flag */
+ BOOL utf8; /* UTF8 flag */
+ BOOL endonly; /* Dollar not before final \n */
+ BOOL notempty; /* Empty string match not wanted */
+ BOOL partial; /* PARTIAL flag */
+ BOOL hitend; /* Hit the end of the subject at some point */
+ const uschar *start_code; /* For use when recursing */
+ const uschar *start_subject; /* Start of the subject string */
+ const uschar *end_subject; /* End of the subject string */
+ const uschar *start_match; /* Start of this match attempt */
+ const uschar *end_match_ptr; /* Subject position at end match */
+ int end_offset_top; /* Highwater mark at end of match */
+ int capture_last; /* Most recent capture number */
+ int start_offset; /* The start offset value */
+ recursion_info *recursive; /* Linked list of recursion data */
+ void *callout_data; /* To pass back to callouts */
+ struct heapframe *thisframe; /* Used only when compiling for no recursion */
} match_data;
/* A similar structure is used for the same purpose by the DFA matching
functions. */
typedef struct dfa_match_data {
- const uschar *start_code; /* Start of the compiled pattern */
- const uschar *start_subject; /* Start of the subject string */
- const uschar *end_subject; /* End of subject string */
- const uschar *tables; /* Character tables */
- int moptions; /* Match options */
- int poptions; /* Pattern options */
- void *callout_data; /* To pass back to callouts */
+ const uschar *start_code; /* Start of the compiled pattern */
+ const uschar *start_subject; /* Start of the subject string */
+ const uschar *end_subject; /* End of subject string */
+ const uschar *tables; /* Character tables */
+ int moptions; /* Match options */
+ int poptions; /* Pattern options */
+ void *callout_data; /* To pass back to callouts */
} dfa_match_data;
/* Bit definitions for entries in the pcre_ctypes table. */
#define ctype_letter 0x02
#define ctype_digit 0x04
#define ctype_xdigit 0x08
-#define ctype_word 0x10 /* alphameric or '_' */
-#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
+#define ctype_word 0x10 /* alphameric or '_' */
+#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
of bits for a class map. Some classes are built by combining these tables. */
-#define cbit_space 0 /* [:space:] or \s */
-#define cbit_xdigit 32 /* [:xdigit:] */
-#define cbit_digit 64 /* [:digit:] or \d */
-#define cbit_upper 96 /* [:upper:] */
-#define cbit_lower 128 /* [:lower:] */
-#define cbit_word 160 /* [:word:] or \w */
-#define cbit_graph 192 /* [:graph:] */
-#define cbit_print 224 /* [:print:] */
-#define cbit_punct 256 /* [:punct:] */
-#define cbit_cntrl 288 /* [:cntrl:] */
-#define cbit_length 320 /* Length of the cbits table */
+#define cbit_space 0 /* [:space:] or \s */
+#define cbit_xdigit 32 /* [:xdigit:] */
+#define cbit_digit 64 /* [:digit:] or \d */
+#define cbit_upper 96 /* [:upper:] */
+#define cbit_lower 128 /* [:lower:] */
+#define cbit_word 160 /* [:word:] or \w */
+#define cbit_graph 192 /* [:graph:] */
+#define cbit_print 224 /* [:print:] */
+#define cbit_punct 256 /* [:punct:] */
+#define cbit_cntrl 288 /* [:cntrl:] */
+#define cbit_length 320 /* Length of the cbits table */
/* Offsets of the various tables from the base tables pointer, and
total length. */
0x80 regular expression metacharacter or binary zero
*/
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
- 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
- 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, /* - ' */
- 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, /* ( - / */
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, /* 0 - 7 */
- 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 8 - ? */
- 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* @ - G */
- 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* H - O */
- 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* P - W */
- 0x12, 0x12, 0x12, 0x80, 0x00, 0x00, 0x80, 0x10, /* X - _ */
- 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* ` - g */
- 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* h - o */
- 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* p - w */
- 0x12, 0x12, 0x12, 0x80, 0x80, 0x00, 0x00, 0x00, /* x -127 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 136-143 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144-151 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 152-159 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160-167 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 168-175 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 176-183 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 192-199 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200-207 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 208-215 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 216-223 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 224-231 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 232-239 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240-247 */
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
+ 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
+ 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, /* - ' */
+ 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, /* ( - / */
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, /* 0 - 7 */
+ 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 8 - ? */
+ 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* @ - G */
+ 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* H - O */
+ 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* P - W */
+ 0x12, 0x12, 0x12, 0x80, 0x00, 0x00, 0x80, 0x10, /* X - _ */
+ 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* ` - g */
+ 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* h - o */
+ 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* p - w */
+ 0x12, 0x12, 0x12, 0x80, 0x80, 0x00, 0x00, 0x00, /* x -127 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 136-143 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144-151 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 152-159 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160-167 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 168-175 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 176-183 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 192-199 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200-207 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 208-215 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 216-223 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 224-231 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 232-239 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240-247 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-}; /* 248-255 */
+}; /* 248-255 */
/* End of chartables.c */
*/
real_pcre *_pcre_try_flipped(const real_pcre * re, real_pcre * internal_re,
- const pcre_study_data * study,
- pcre_study_data * internal_study);
+ const pcre_study_data * study,
+ pcre_study_data * internal_study);
real_pcre *
_pcre_try_flipped(const real_pcre * re, real_pcre * internal_re,
- const pcre_study_data * study,
- pcre_study_data * internal_study)
+ const pcre_study_data * study,
+ pcre_study_data * internal_study)
{
if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
return NULL;
- *internal_re = *re; /* To copy other fields */
+ *internal_re = *re; /* To copy other fields */
internal_re->size = byteflip(re->size, sizeof(re->size));
internal_re->options = byteflip(re->options, sizeof(re->options));
internal_re->top_bracket =
(pcre_uint16) byteflip(re->req_byte, sizeof(re->req_byte));
internal_re->name_table_offset =
(pcre_uint16) byteflip(re->name_table_offset,
- sizeof(re->name_table_offset));
+ sizeof(re->name_table_offset));
internal_re->name_entry_size =
(pcre_uint16) byteflip(re->name_entry_size, sizeof(re->name_entry_size));
internal_re->name_count =
(pcre_uint16) byteflip(re->name_count, sizeof(re->name_count));
if (study != NULL) {
- *internal_study = *study; /* To copy other fields */
+ *internal_study = *study; /* To copy other fields */
internal_study->size = byteflip(study->size, sizeof(study->size));
internal_study->options = byteflip(study->options, sizeof(study->options));
}
int
pcre_fullinfo(const pcre * argument_re, const pcre_extra * extra_data, int what,
- void *where)
+ void *where)
{
real_pcre internal_re;
pcre_study_data internal_study;
int
pcre_copy_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, char *buffer, int size)
+ int stringnumber, char *buffer, int size)
{
int yield;
if (stringnumber < 0 || stringnumber >= stringcount)
int
pcre_copy_named_substring(const pcre * code, const char *subject, int *ovector,
- int stringcount, const char *stringname, char *buffer,
- int size)
+ int stringcount, const char *stringname, char *buffer,
+ int size)
{
int n = pcre_get_stringnumber(code, stringname);
if (n <= 0)
int
pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
- const char ***listptr);
+ const char ***listptr);
int
pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
- const char ***listptr)
+ const char ***listptr)
{
int i;
int size = sizeof(char *);
int
pcre_get_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, const char **stringptr);
+ int stringnumber, const char **stringptr);
int
pcre_get_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, const char **stringptr)
+ int stringnumber, const char **stringptr)
{
int yield;
char *substring;
int
pcre_get_named_substring(const pcre * code, const char *subject, int *ovector,
- int stringcount, const char *stringname,
- const char **stringptr);
+ int stringcount, const char *stringname,
+ const char **stringptr);
int
pcre_get_named_substring(const pcre * code, const char *subject, int *ovector,
- int stringcount, const char *stringname,
- const char **stringptr)
+ int stringcount, const char *stringname,
+ const char **stringptr)
{
int n = pcre_get_stringnumber(code, stringname);
if (n <= 0)
static BOOL
set_start_bits(const uschar * code, uschar * start_bits, BOOL caseless,
- BOOL utf8, compile_data * cd)
+ BOOL utf8, compile_data * cd)
{
register int c;
recurse to set bits from within them. That's all for this branch. */
if ((int) *tcode >= OP_BRA || *tcode == OP_ASSERT) {
- if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))
- return FALSE;
- try_next = FALSE;
+ if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))
+ return FALSE;
+ try_next = FALSE;
}
else
- switch (*tcode) {
- default:
- return FALSE;
-
- /* Skip over callout */
-
- case OP_CALLOUT:
- tcode += 2 + 2 * LINK_SIZE;
- break;
-
- /* Skip over extended extraction bracket number */
-
- case OP_BRANUMBER:
- tcode += 3;
- break;
-
- /* Skip over lookbehind and negative lookahead assertions */
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do
- tcode += GET(tcode, 1);
- while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- break;
-
- /* Skip over an option setting, changing the caseless flag */
-
- case OP_OPT:
- caseless = (tcode[1] & PCRE_CASELESS) != 0;
- tcode += 2;
- break;
-
- /* BRAZERO does the bracket, but carries on. */
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))
- return FALSE;
- dummy = 1;
- do
- tcode += GET(tcode, 1);
- while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- break;
-
- /* Single-char * or ? sets the bit and tries the next item */
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_QUERY:
- case OP_MINQUERY:
- set_bit(start_bits, tcode[1], caseless, cd);
- tcode += 2;
- break;
-
- /* Single-char upto sets the bit and tries the next */
-
- case OP_UPTO:
- case OP_MINUPTO:
- set_bit(start_bits, tcode[3], caseless, cd);
- tcode += 4;
- break;
-
- /* At least one single char sets the bit and stops */
-
- case OP_EXACT: /* Fall through */
- tcode += 2;
-
- case OP_CHAR:
- case OP_CHARNC:
- case OP_PLUS:
- case OP_MINPLUS:
- set_bit(start_bits, tcode[1], caseless, cd);
- try_next = FALSE;
- break;
-
- /* Single character type sets the bits and stops */
-
- case OP_NOT_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_digit];
- try_next = FALSE;
- break;
-
- case OP_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_digit];
- try_next = FALSE;
- break;
-
- case OP_NOT_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_space];
- try_next = FALSE;
- break;
-
- case OP_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_space];
- try_next = FALSE;
- break;
-
- case OP_NOT_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_word];
- try_next = FALSE;
- break;
-
- case OP_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_word];
- try_next = FALSE;
- break;
-
- /* One or more character type fudges the pointer and restarts, knowing
- it will hit a single character type and stop there. */
-
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- tcode++;
- break;
-
- case OP_TYPEEXACT:
- tcode += 3;
- break;
-
- /* Zero or more repeats of character types set the bits and then
- try again. */
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- tcode += 2; /* Fall through */
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- switch (tcode[1]) {
- case OP_ANY:
- return FALSE;
-
- case OP_NOT_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_digit];
- break;
-
- case OP_DIGIT:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_digit];
- break;
-
- case OP_NOT_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_space];
- break;
-
- case OP_WHITESPACE:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_space];
- break;
-
- case OP_NOT_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= ~cd->cbits[c + cbit_word];
- break;
-
- case OP_WORDCHAR:
- for (c = 0; c < 32; c++)
- start_bits[c] |= cd->cbits[c + cbit_word];
- break;
- }
-
- tcode += 2;
- break;
-
- /* Character class where all the information is in a bit map: set the
- bits and either carry on or not, according to the repeat count. If it was
- a negative class, and we are operating with UTF-8 characters, any byte
- with a value >= 0xc4 is a potentially valid starter because it starts a
- character with a value > 255. */
-
- case OP_NCLASS:
- if (utf8) {
- start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
- memset(start_bits + 25, 0xff, 7); /* Bits for 0xc9 - 0xff */
- }
- /* Fall through */
-
- case OP_CLASS:
- {
- tcode++;
-
- /* In UTF-8 mode, the bits in a bit map correspond to character
- values, not to byte values. However, the bit map we are constructing is
- for byte values. So we have to do a conversion for characters whose
- value is > 127. In fact, there are only two possible starting bytes for
- characters in the range 128 - 255. */
-
- if (utf8) {
- for (c = 0; c < 16; c++)
- start_bits[c] |= tcode[c];
- for (c = 128; c < 256; c++) {
- if ((tcode[c / 8] && (1 << (c & 7))) != 0) {
- int d = (c >> 6) | 0xc0; /* Set bit for this starter */
- start_bits[d / 8] |= (1 << (d & 7)); /* and then skip on to the */
- c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */
- }
- }
- }
-
- /* In non-UTF-8 mode, the two bit maps are completely compatible. */
-
- else {
- for (c = 0; c < 32; c++)
- start_bits[c] |= tcode[c];
- }
-
- /* Advance past the bit map, and act on what follows */
-
- tcode += 32;
- switch (*tcode) {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- tcode++;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- if (((tcode[1] << 8) + tcode[2]) == 0)
- tcode += 5;
- else
- try_next = FALSE;
- break;
-
- default:
- try_next = FALSE;
- break;
- }
- }
- break; /* End of bitmap class handling */
-
- } /* End of switch */
- } /* End of try_next loop */
-
- code += GET(code, 1); /* Advance to next branch */
+ switch (*tcode) {
+ default:
+ return FALSE;
+
+ /* Skip over callout */
+
+ case OP_CALLOUT:
+ tcode += 2 + 2 * LINK_SIZE;
+ break;
+
+ /* Skip over extended extraction bracket number */
+
+ case OP_BRANUMBER:
+ tcode += 3;
+ break;
+
+ /* Skip over lookbehind and negative lookahead assertions */
+
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ tcode += GET(tcode, 1);
+ while (*tcode == OP_ALT);
+ tcode += 1 + LINK_SIZE;
+ break;
+
+ /* Skip over an option setting, changing the caseless flag */
+
+ case OP_OPT:
+ caseless = (tcode[1] & PCRE_CASELESS) != 0;
+ tcode += 2;
+ break;
+
+ /* BRAZERO does the bracket, but carries on. */
+
+ case OP_BRAZERO:
+ case OP_BRAMINZERO:
+ if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))
+ return FALSE;
+ dummy = 1;
+ do
+ tcode += GET(tcode, 1);
+ while (*tcode == OP_ALT);
+ tcode += 1 + LINK_SIZE;
+ break;
+
+ /* Single-char * or ? sets the bit and tries the next item */
+
+ case OP_STAR:
+ case OP_MINSTAR:
+ case OP_QUERY:
+ case OP_MINQUERY:
+ set_bit(start_bits, tcode[1], caseless, cd);
+ tcode += 2;
+ break;
+
+ /* Single-char upto sets the bit and tries the next */
+
+ case OP_UPTO:
+ case OP_MINUPTO:
+ set_bit(start_bits, tcode[3], caseless, cd);
+ tcode += 4;
+ break;
+
+ /* At least one single char sets the bit and stops */
+
+ case OP_EXACT: /* Fall through */
+ tcode += 2;
+
+ case OP_CHAR:
+ case OP_CHARNC:
+ case OP_PLUS:
+ case OP_MINPLUS:
+ set_bit(start_bits, tcode[1], caseless, cd);
+ try_next = FALSE;
+ break;
+
+ /* Single character type sets the bits and stops */
+
+ case OP_NOT_DIGIT:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_digit];
+ try_next = FALSE;
+ break;
+
+ case OP_DIGIT:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_digit];
+ try_next = FALSE;
+ break;
+
+ case OP_NOT_WHITESPACE:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_space];
+ try_next = FALSE;
+ break;
+
+ case OP_WHITESPACE:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_space];
+ try_next = FALSE;
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_word];
+ try_next = FALSE;
+ break;
+
+ case OP_WORDCHAR:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_word];
+ try_next = FALSE;
+ break;
+
+ /* One or more character type fudges the pointer and restarts, knowing
+ it will hit a single character type and stop there. */
+
+ case OP_TYPEPLUS:
+ case OP_TYPEMINPLUS:
+ tcode++;
+ break;
+
+ case OP_TYPEEXACT:
+ tcode += 3;
+ break;
+
+ /* Zero or more repeats of character types set the bits and then
+ try again. */
+
+ case OP_TYPEUPTO:
+ case OP_TYPEMINUPTO:
+ tcode += 2; /* Fall through */
+
+ case OP_TYPESTAR:
+ case OP_TYPEMINSTAR:
+ case OP_TYPEQUERY:
+ case OP_TYPEMINQUERY:
+ switch (tcode[1]) {
+ case OP_ANY:
+ return FALSE;
+
+ case OP_NOT_DIGIT:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_digit];
+ break;
+
+ case OP_DIGIT:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_digit];
+ break;
+
+ case OP_NOT_WHITESPACE:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_space];
+ break;
+
+ case OP_WHITESPACE:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_space];
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + cbit_word];
+ break;
+
+ case OP_WORDCHAR:
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + cbit_word];
+ break;
+ }
+
+ tcode += 2;
+ break;
+
+ /* Character class where all the information is in a bit map: set the
+ bits and either carry on or not, according to the repeat count. If it was
+ a negative class, and we are operating with UTF-8 characters, any byte
+ with a value >= 0xc4 is a potentially valid starter because it starts a
+ character with a value > 255. */
+
+ case OP_NCLASS:
+ if (utf8) {
+ start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
+ memset(start_bits + 25, 0xff, 7); /* Bits for 0xc9 - 0xff */
+ }
+ /* Fall through */
+
+ case OP_CLASS:
+ {
+ tcode++;
+
+ /* In UTF-8 mode, the bits in a bit map correspond to character
+ values, not to byte values. However, the bit map we are constructing is
+ for byte values. So we have to do a conversion for characters whose
+ value is > 127. In fact, there are only two possible starting bytes for
+ characters in the range 128 - 255. */
+
+ if (utf8) {
+ for (c = 0; c < 16; c++)
+ start_bits[c] |= tcode[c];
+ for (c = 128; c < 256; c++) {
+ if ((tcode[c / 8] && (1 << (c & 7))) != 0) {
+ int d = (c >> 6) | 0xc0; /* Set bit for this starter */
+ start_bits[d / 8] |= (1 << (d & 7)); /* and then skip on to the */
+ c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */
+ }
+ }
+ }
+
+ /* In non-UTF-8 mode, the two bit maps are completely compatible. */
+
+ else {
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= tcode[c];
+ }
+
+ /* Advance past the bit map, and act on what follows */
+
+ tcode += 32;
+ switch (*tcode) {
+ case OP_CRSTAR:
+ case OP_CRMINSTAR:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ tcode++;
+ break;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ if (((tcode[1] << 8) + tcode[2]) == 0)
+ tcode += 5;
+ else
+ try_next = FALSE;
+ break;
+
+ default:
+ try_next = FALSE;
+ break;
+ }
+ }
+ break; /* End of bitmap class handling */
+
+ } /* End of switch */
+ } /* End of try_next loop */
+
+ code += GET(code, 1); /* Advance to next branch */
}
while (*code == OP_ALT);
return TRUE;
tables = re->tables;
if (tables == NULL)
(void) pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
- (void *) (&tables));
+ (void *) (&tables));
compile_block.lcc = tables + lcc_offset;
compile_block.fcc = tables + fcc_offset;
memset(start_bits, 0, 32 * sizeof(uschar));
if (!set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,
- (re->options & PCRE_UTF8) != 0, &compile_block))
+ (re->options & PCRE_UTF8) != 0, &compile_block))
return NULL;
/* Get a pcre_extra block and a pcre_study_data block. The study data is put in
on. Zero means further processing is needed (for things like \x), or the escape
is invalid. */
-#if !EBCDIC /* This is the "normal" table for ASCII systems */
+#if !EBCDIC /* This is the "normal" table for ASCII systems */
static const short int escapes[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
- 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
- '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G, /* @ - G */
- 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
- -ESC_P, -ESC_Q, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
- -ESC_X, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
- '`', 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0, /* ` - g */
- 0, 0, 0, 0, 0, 0, ESC_n, 0, /* h - o */
- -ESC_p, 0, ESC_r, -ESC_s, ESC_tee, 0, 0, -ESC_w, /* p - w */
- 0, 0, -ESC_z /* x - z */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
+ 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
+ '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G, /* @ - G */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
+ -ESC_P, -ESC_Q, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
+ -ESC_X, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
+ '`', 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0, /* ` - g */
+ 0, 0, 0, 0, 0, 0, ESC_n, 0, /* h - o */
+ -ESC_p, 0, ESC_r, -ESC_s, ESC_tee, 0, 0, -ESC_w, /* p - w */
+ 0, 0, -ESC_z /* x - z */
};
-#else /* This is the "abnormal" table for EBCDIC systems */
+#else /* This is the "abnormal" table for EBCDIC systems */
static const short int escapes[] = {
/* 48 */ 0, 0, 0, '.', '<', '(', '+', '|',
/* 50 */ '&', 0, 0, 0, 0, 0, 0, 0,
the vertical space characters. */
static const int posix_class_maps[] = {
- cbit_lower, cbit_upper, -1, /* alpha */
- cbit_lower, -1, -1, /* lower */
- cbit_upper, -1, -1, /* upper */
- cbit_digit, cbit_lower, cbit_upper, /* alnum */
- cbit_print, cbit_cntrl, -1, /* ascii */
- cbit_space, -1, -1, /* blank - a GNU extension */
- cbit_cntrl, -1, -1, /* cntrl */
- cbit_digit, -1, -1, /* digit */
- cbit_graph, -1, -1, /* graph */
- cbit_print, -1, -1, /* print */
- cbit_punct, -1, -1, /* punct */
- cbit_space, -1, -1, /* space */
- cbit_word, -1, -1, /* word - a Perl extension */
- cbit_xdigit, -1, -1 /* xdigit */
+ cbit_lower, cbit_upper, -1, /* alpha */
+ cbit_lower, -1, -1, /* lower */
+ cbit_upper, -1, -1, /* upper */
+ cbit_digit, cbit_lower, cbit_upper, /* alnum */
+ cbit_print, cbit_cntrl, -1, /* ascii */
+ cbit_space, -1, -1, /* blank - a GNU extension */
+ cbit_cntrl, -1, -1, /* cntrl */
+ cbit_digit, -1, -1, /* digit */
+ cbit_graph, -1, -1, /* graph */
+ cbit_print, -1, -1, /* print */
+ cbit_punct, -1, -1, /* punct */
+ cbit_space, -1, -1, /* space */
+ cbit_word, -1, -1, /* word - a Perl extension */
+ cbit_xdigit, -1, -1 /* xdigit */
};
Then we can use ctype_digit and ctype_xdigit in the code. */
-#if !EBCDIC /* This is the "normal" case, for ASCII systems */
+#if !EBCDIC /* This is the "normal" case, for ASCII systems */
static const unsigned char digitab[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8- 15 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - ' */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ( - / */
- 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 0 - 7 */
- 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 - ? */
- 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* @ - G */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H - O */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* P - W */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* X - _ */
- 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* ` - g */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h - o */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p - w */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x -127 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 136-143 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144-151 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 152-159 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160-167 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 168-175 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 176-183 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 192-199 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200-207 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 208-215 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 216-223 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 224-231 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 232-239 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240-247 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8- 15 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - ' */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ( - / */
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 0 - 7 */
+ 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 - ? */
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* @ - G */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H - O */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* P - W */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* X - _ */
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* ` - g */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h - o */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p - w */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x -127 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 136-143 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144-151 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 152-159 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160-167 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 168-175 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 176-183 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 192-199 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200-207 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 208-215 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 216-223 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 224-231 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 232-239 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240-247 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-}; /* 248-255 */
+}; /* 248-255 */
-#else /* This is the "abnormal" case, for EBCDIC systems */
+#else /* This is the "abnormal" case, for EBCDIC systems */
static const unsigned char digitab[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8- 15 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 10 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 32- 39 20 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 40- 47 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48- 55 30 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56- 63 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - 71 40 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 72- | */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* & - 87 50 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 88- ¬ */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - -103 60 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 104- ? */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 112-119 70 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 120- " */
- 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* 128- g 80 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h -143 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144- p 90 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* q -159 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160- x A0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y -175 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^ -183 B0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
- 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* { - G C0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H -207 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* } - P D0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Q -223 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* \ - X E0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Y -239 */
- 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 0 - 7 F0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0- 7 0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8- 15 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16- 23 10 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 32- 39 20 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 40- 47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48- 55 30 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56- 63 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - 71 40 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 72- | */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* & - 87 50 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 88- ¬ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - -103 60 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 104- ? */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 112-119 70 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 120- " */
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* 128- g 80 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h -143 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 144- p 90 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* q -159 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160- x A0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y -175 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^ -183 B0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /* { - G C0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H -207 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* } - P D0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Q -223 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* \ - X E0 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Y -239 */
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 0 - 7 F0 */
0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-}; /* 8 -255 */
-
-static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 0- 7 */
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 16- 23 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 32- 39 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 40- 47 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48- 55 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56- 63 */
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - 71 */
- 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, /* 72- | */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* & - 87 */
- 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, /* 88- ¬ */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - -103 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, /* 104- ? */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 112-119 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 120- " */
- 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* 128- g */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h -143 */
- 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* 144- p */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* q -159 */
- 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* 160- x */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y -175 */
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^ -183 */
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
- 0x80, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* { - G */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H -207 */
- 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* } - P */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Q -223 */
- 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* \ - X */
- 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Y -239 */
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, /* 0 - 7 */
+}; /* 8 -255 */
+
+static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 0- 7 */
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, /* 8- 15 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 16- 23 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24- 31 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* 32- 39 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 40- 47 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48- 55 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56- 63 */
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - 71 */
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, /* 72- | */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* & - 87 */
+ 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, /* 88- ¬ */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - -103 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, /* 104- ? */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 112-119 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 120- " */
+ 0x00, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* 128- g */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h -143 */
+ 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* 144- p */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* q -159 */
+ 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* 160- x */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y -175 */
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^ -183 */
+ 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 184-191 */
+ 0x80, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x12, /* { - G */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H -207 */
+ 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* } - P */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Q -223 */
+ 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, /* \ - X */
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Y -239 */
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, /* 0 - 7 */
0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-}; /* 8 -255 */
+}; /* 8 -255 */
#endif
static BOOL
compile_regex(int, int, int *, uschar **, const uschar **, int *, BOOL, int,
- int *, int *, branch_chain *, compile_data *);
+ int *, int *, branch_chain *, compile_data *);
static int
check_escape(const uschar ** ptrptr, int *errorcodeptr, int bracount,
- int options, BOOL isclass)
+ int options, BOOL isclass)
{
const uschar *ptr = *ptrptr;
int c, i;
a table. A non-zero result is something that can be returned immediately.
Otherwise further processing may be required. */
-#if !EBCDIC /* ASCII coding */
+#if !EBCDIC /* ASCII coding */
else if (c < '0' || c > 'z') {
} /* Not alphameric */
else if ((i = escapes[c - '0']) != 0)
c = i;
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {
} /* Not alphameric */
else if ((i = escapes[c - 0x48]) != 0)
case '9':
if (!isclass) {
- oldptr = ptr;
- c -= '0';
- while ((digitab[ptr[1]] & ctype_digit) != 0)
- c = c * 10 + *(++ptr) - '0';
- if (c < 10 || c <= bracount) {
- c = -(ESC_REF + c);
- break;
- }
- ptr = oldptr; /* Put the pointer back and fall through */
+ oldptr = ptr;
+ c -= '0';
+ while ((digitab[ptr[1]] & ctype_digit) != 0)
+ c = c * 10 + *(++ptr) - '0';
+ if (c < 10 || c <= bracount) {
+ c = -(ESC_REF + c);
+ break;
+ }
+ ptr = oldptr; /* Put the pointer back and fall through */
}
/* Handle an octal number following \. If the first digit is 8 or 9, Perl
Thus we have to pull back the pointer by one. */
if ((c = *ptr) >= '8') {
- ptr--;
- c = 0;
- break;
+ ptr--;
+ c = 0;
+ break;
}
/* \0 always starts an octal number, but we may drop through to here with a
case '0':
c -= '0';
while (i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7')
- c = c * 8 + *(++ptr) - '0';
- c &= 255; /* Take least significant 8 bits */
+ c = c * 8 + *(++ptr) - '0';
+ c &= 255; /* Take least significant 8 bits */
break;
/* \x is complicated when UTF-8 is enabled. \x{ddd} is a character number
c = 0;
while (i++ < 2 && (digitab[ptr[1]] & ctype_xdigit) != 0) {
- int cc; /* Some compilers don't like ++ */
- cc = *(++ptr); /* in initializers */
-#if !EBCDIC /* ASCII coding */
- if (cc >= 'a')
- cc -= 32; /* Convert to upper case */
- c = c * 16 + cc - ((cc < 'A') ? '0' : ('A' - 10));
-#else /* EBCDIC coding */
- if (cc <= 'z')
- cc += 64; /* Convert to upper case */
- c = c * 16 + cc - ((cc >= '0') ? '0' : ('A' - 10));
+ int cc; /* Some compilers don't like ++ */
+ cc = *(++ptr); /* in initializers */
+#if !EBCDIC /* ASCII coding */
+ if (cc >= 'a')
+ cc -= 32; /* Convert to upper case */
+ c = c * 16 + cc - ((cc < 'A') ? '0' : ('A' - 10));
+#else /* EBCDIC coding */
+ if (cc <= 'z')
+ cc += 64; /* Convert to upper case */
+ c = c * 16 + cc - ((cc >= '0') ? '0' : ('A' - 10));
#endif
}
break;
case 'c':
c = *(++ptr);
if (c == 0) {
- *errorcodeptr = ERR2;
- return 0;
+ *errorcodeptr = ERR2;
+ return 0;
}
/* A letter is upper-cased; then the 0x40 bit is flipped. This coding
is ASCII-specific, but then the whole concept of \cx is ASCII-specific.
(However, an EBCDIC equivalent has now been added.) */
-#if !EBCDIC /* ASCII coding */
+#if !EBCDIC /* ASCII coding */
if (c >= 'a' && c <= 'z')
- c -= 32;
+ c -= 32;
c ^= 0x40;
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
if (c >= 'a' && c <= 'z')
- c += 64;
+ c += 64;
c ^= 0xC0;
#endif
break;
default:
if ((options & PCRE_EXTRA) != 0)
- switch (c) {
- default:
- *errorcodeptr = ERR3;
- break;
- }
+ switch (c) {
+ default:
+ *errorcodeptr = ERR3;
+ break;
+ }
break;
}
}
for (i = 0; i <= 2; i++) {
c = *(++ptr);
if (c == 0)
- goto ERROR_RETURN;
+ goto ERROR_RETURN;
if (c == '}')
- break;
+ break;
name[i] = c;
}
- if (c != '}') { /* Try to distinguish error cases */
+ if (c != '}') { /* Try to distinguish error cases */
while (*(++ptr) != 0 && *ptr != '}') ;
if (*ptr == '}')
- goto UNKNOWN_RETURN;
+ goto UNKNOWN_RETURN;
else
- goto ERROR_RETURN;
+ goto ERROR_RETURN;
}
name[i] = 0;
}
if (*(++p) != '}') {
max = 0;
while ((digitab[*p] & ctype_digit) != 0)
- max = max * 10 + *p++ - '0';
+ max = max * 10 + *p++ - '0';
if (max < 0 || max > 65535) {
- *errorcodeptr = ERR5;
- return p;
+ *errorcodeptr = ERR5;
+ return p;
}
if (max < min) {
- *errorcodeptr = ERR4;
- return p;
+ *errorcodeptr = ERR4;
+ return p;
}
}
}
static const uschar *
first_significant_code(const uschar * code, int *options, int optbit,
- BOOL skipassert)
+ BOOL skipassert)
{
for (;;) {
switch ((int) *code) {
case OP_OPT:
if (optbit > 0 && ((int) code[1] & optbit) != (*options & optbit))
- *options = (int) code[1];
+ *options = (int) code[1];
code += 2;
break;
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
if (!skipassert)
- return code;
+ return code;
do
- code += GET(code, 1);
+ code += GET(code, 1);
while (*code == OP_ALT);
code += _pcre_OP_lengths[*code];
break;
case OP_WORD_BOUNDARY:
case OP_NOT_WORD_BOUNDARY:
if (!skipassert)
- return code;
+ return code;
/* Fall through */
case OP_CALLOUT:
case OP_COND:
d = find_fixedlength(cc, options);
if (d < 0)
- return d;
+ return d;
branchlength += d;
do
- cc += GET(cc, 1);
+ cc += GET(cc, 1);
while (*cc == OP_ALT);
cc += 1 + LINK_SIZE;
break;
case OP_KETRMIN:
case OP_END:
if (length < 0)
- length = branchlength;
+ length = branchlength;
else if (length != branchlength)
- return -1;
+ return -1;
if (*cc != OP_ALT)
- return length;
+ return length;
cc += 1 + LINK_SIZE;
branchlength = 0;
break;
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
do
- cc += GET(cc, 1);
+ cc += GET(cc, 1);
while (*cc == OP_ALT);
/* Fall through */
case OP_CRMINSTAR:
case OP_CRQUERY:
case OP_CRMINQUERY:
- return -1;
+ return -1;
case OP_CRRANGE:
case OP_CRMINRANGE:
- if (GET2(cc, 1) != GET2(cc, 3))
- return -1;
- branchlength += GET2(cc, 1);
- cc += 5;
- break;
+ if (GET2(cc, 1) != GET2(cc, 3))
+ return -1;
+ branchlength += GET2(cc, 1);
+ cc += 5;
+ break;
default:
- branchlength++;
+ branchlength++;
}
break;
static const uschar *
find_bracket(const uschar * code, BOOL utf8, int number)
{
- utf8 = utf8; /* Stop pedantic compilers complaining */
+ utf8 = utf8; /* Stop pedantic compilers complaining */
for (;;) {
register int c = *code;
else if (c > OP_BRA) {
int n = c - OP_BRA;
if (n > EXTRACT_BASIC_MAX)
- n = GET2(code, 2 + LINK_SIZE);
+ n = GET2(code, 2 + LINK_SIZE);
if (n == number)
- return (uschar *) code;
+ return (uschar *) code;
code += _pcre_OP_lengths[OP_BRA];
} else {
code += _pcre_OP_lengths[c];
static const uschar *
find_recurse(const uschar * code, BOOL utf8)
{
- utf8 = utf8; /* Stop pedantic compilers complaining */
+ utf8 = utf8; /* Stop pedantic compilers complaining */
for (;;) {
register int c = *code;
if (c >= OP_BRA) {
BOOL empty_branch;
if (GET(code, 1) == 0)
- return TRUE; /* Hit unclosed bracket */
+ return TRUE; /* Hit unclosed bracket */
/* Scan a closed bracket */
empty_branch = FALSE;
do {
- if (!empty_branch && could_be_empty_branch(code, endcode, utf8))
- empty_branch = TRUE;
- code += GET(code, 1);
+ if (!empty_branch && could_be_empty_branch(code, endcode, utf8))
+ empty_branch = TRUE;
+ code += GET(code, 1);
}
while (*code == OP_ALT);
if (!empty_branch)
- return FALSE; /* All branches are non-empty */
+ return FALSE; /* All branches are non-empty */
code += 1 + LINK_SIZE;
c = *code;
}
else
switch (c) {
- /* Check for quantifiers after a class */
+ /* Check for quantifiers after a class */
case OP_CLASS:
case OP_NCLASS:
- ccode = code + 33;
+ ccode = code + 33;
- switch (*ccode) {
- case OP_CRSTAR: /* These could be empty; continue */
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- break;
+ switch (*ccode) {
+ case OP_CRSTAR: /* These could be empty; continue */
+ case OP_CRMINSTAR:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ break;
- default: /* Non-repeat => class must match */
- case OP_CRPLUS: /* These repeats aren't empty */
- case OP_CRMINPLUS:
- return FALSE;
+ default: /* Non-repeat => class must match */
+ case OP_CRPLUS: /* These repeats aren't empty */
+ case OP_CRMINPLUS:
+ return FALSE;
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- if (GET2(ccode, 1) > 0)
- return FALSE; /* Minimum > 0 */
- break;
- }
- break;
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ if (GET2(ccode, 1) > 0)
+ return FALSE; /* Minimum > 0 */
+ break;
+ }
+ break;
- /* Opcodes that must match a character */
+ /* Opcodes that must match a character */
case OP_PROP:
case OP_NOTPROP:
case OP_TYPEPLUS:
case OP_TYPEMINPLUS:
case OP_TYPEEXACT:
- return FALSE;
+ return FALSE;
- /* End of branch */
+ /* End of branch */
case OP_KET:
case OP_KETRMAX:
case OP_KETRMIN:
case OP_ALT:
- return TRUE;
+ return TRUE;
- /* In UTF-8 mode, STAR, MINSTAR, QUERY, MINQUERY, UPTO, and MINUPTO may be
- followed by a multibyte character */
+ /* In UTF-8 mode, STAR, MINSTAR, QUERY, MINQUERY, UPTO, and MINUPTO may be
+ followed by a multibyte character */
}
}
static BOOL
could_be_empty(const uschar * code, const uschar * endcode,
- branch_chain * bcptr, BOOL utf8)
+ branch_chain * bcptr, BOOL utf8)
{
while (bcptr != NULL && bcptr->current >= code) {
if (!could_be_empty_branch(bcptr->current, endcode, utf8))
static BOOL
check_posix_syntax(const uschar * ptr, const uschar ** endptr,
- compile_data * cd)
+ compile_data * cd)
{
- int terminator; /* Don't combine these lines; the Solaris cc */
- terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
+ int terminator; /* Don't combine these lines; the Solaris cc */
+ terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
if (*(++ptr) == '^')
ptr++;
while ((cd->ctypes[*ptr] & ctype_letter) != 0)
register int yield = 0;
while (posix_name_lengths[yield] != 0) {
if (len == posix_name_lengths[yield] &&
- strncmp((const char *) ptr, posix_names[yield], len) == 0)
+ strncmp((const char *) ptr, posix_names[yield], len) == 0)
return yield;
yield++;
}
{
*code++ = OP_CALLOUT;
*code++ = 255;
- PUT(code, 0, ptr - cd->start_pattern); /* Pattern offset */
- PUT(code, LINK_SIZE, 0); /* Default length */
+ PUT(code, 0, ptr - cd->start_pattern); /* Pattern offset */
+ PUT(code, LINK_SIZE, 0); /* Default length */
return code + 2 * LINK_SIZE;
}
static void
complete_callout(uschar * previous_callout, const uschar * ptr,
- compile_data * cd)
+ compile_data * cd)
{
int length = ptr - cd->start_pattern - GET(previous_callout, 2);
PUT(previous_callout, 2 + LINK_SIZE, length);
for (++c; c <= d; c++) {
if (_pcre_ucp_findchar(c, &chartype, &othercase) != ucp_L ||
- othercase != next)
+ othercase != next)
break;
next++;
}
return TRUE;
}
-#endif /* SUPPORT_UCP */
+#endif /* SUPPORT_UCP */
/*************************************************
static BOOL
compile_branch(int *optionsptr, int *brackets, uschar ** codeptr,
- const uschar ** ptrptr, int *errorcodeptr, int *firstbyteptr,
- int *reqbyteptr, branch_chain * bcptr, compile_data * cd)
+ const uschar ** ptrptr, int *errorcodeptr, int *firstbyteptr,
+ int *reqbyteptr, branch_chain * bcptr, compile_data * cd)
{
int repeat_type, op_type;
- int repeat_min = 0, repeat_max = 0; /* To please picky compilers */
+ int repeat_min = 0, repeat_max = 0; /* To please picky compilers */
int bravalue = 0;
int greedy_default, greedy_non_default;
int firstbyte, reqbyte;
if (inescq && c != 0) {
if (c == '\\' && ptr[1] == 'E') {
- inescq = FALSE;
- ptr++;
- continue;
+ inescq = FALSE;
+ ptr++;
+ continue;
} else {
- if (previous_callout != NULL) {
- complete_callout(previous_callout, ptr, cd);
- previous_callout = NULL;
- }
- if ((options & PCRE_AUTO_CALLOUT) != 0) {
- previous_callout = code;
- code = auto_callout(code, ptr, cd);
- }
- goto NORMAL_CHAR;
+ if (previous_callout != NULL) {
+ complete_callout(previous_callout, ptr, cd);
+ previous_callout = NULL;
+ }
+ if ((options & PCRE_AUTO_CALLOUT) != 0) {
+ previous_callout = code;
+ code = auto_callout(code, ptr, cd);
+ }
+ goto NORMAL_CHAR;
}
}
(c == '{' && is_counted_repeat(ptr + 1));
if (!is_quantifier && previous_callout != NULL &&
- after_manual_callout-- <= 0) {
+ after_manual_callout-- <= 0) {
complete_callout(previous_callout, ptr, cd);
previous_callout = NULL;
}
if ((options & PCRE_EXTENDED) != 0) {
if ((cd->ctypes[c] & ctype_space) != 0)
- continue;
+ continue;
if (c == '#') {
- /* The space before the ; is to avoid a warning on a silly compiler
- on the Macintosh. */
- while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
- if (c != 0)
- continue; /* Else fall through to handle end of string */
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
+ if (c != 0)
+ continue; /* Else fall through to handle end of string */
}
}
case '^':
if ((options & PCRE_MULTILINE) != 0) {
- if (firstbyte == REQ_UNSET)
- firstbyte = REQ_NONE;
+ if (firstbyte == REQ_UNSET)
+ firstbyte = REQ_NONE;
}
previous = NULL;
*code++ = OP_CIRC;
case '.':
if (firstbyte == REQ_UNSET)
- firstbyte = REQ_NONE;
+ firstbyte = REQ_NONE;
zerofirstbyte = firstbyte;
zeroreqbyte = reqbyte;
previous = code;
they are encountered at the top level, so we'll do that too. */
if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
- check_posix_syntax(ptr, &tempptr, cd)) {
- *errorcodeptr = (ptr[1] == ':') ? ERR13 : ERR31;
- goto FAILED;
+ check_posix_syntax(ptr, &tempptr, cd)) {
+ *errorcodeptr = (ptr[1] == ':') ? ERR13 : ERR31;
+ goto FAILED;
}
/* If the first character is '^', set the negation flag and skip it. */
if ((c = *(++ptr)) == '^') {
- negate_class = TRUE;
- c = *(++ptr);
+ negate_class = TRUE;
+ c = *(++ptr);
} else {
- negate_class = FALSE;
+ negate_class = FALSE;
}
/* Keep a count of chars with values < 256 so that we can optimize the case
do {
- /* Inside \Q...\E everything is literal except \E */
-
- if (inescq) {
- if (c == '\\' && ptr[1] == 'E') {
- inescq = FALSE;
- ptr++;
- continue;
- } else
- goto LONE_SINGLE_CHARACTER;
- }
-
- /* Handle POSIX class names. Perl allows a negation extension of the
- form [:^name:]. A square bracket that doesn't match the syntax is
- treated as a literal. We also recognize the POSIX constructions
- [.ch.] and [=ch=] ("collating elements") and fault them, as Perl
- 5.6 and 5.8 do. */
-
- if (c == '[' &&
- (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
- check_posix_syntax(ptr, &tempptr, cd)) {
- BOOL local_negate = FALSE;
- int posix_class, i;
- register const uschar *cbits = cd->cbits;
-
- if (ptr[1] != ':') {
- *errorcodeptr = ERR31;
- goto FAILED;
- }
-
- ptr += 2;
- if (*ptr == '^') {
- local_negate = TRUE;
- ptr++;
- }
-
- posix_class = check_posix_name(ptr, tempptr - ptr);
- if (posix_class < 0) {
- *errorcodeptr = ERR30;
- goto FAILED;
- }
-
- /* If matching is caseless, upper and lower are converted to
- alpha. This relies on the fact that the class table starts with
- alpha, lower, upper as the first 3 entries. */
-
- if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
- posix_class = 0;
-
- /* Or into the map we are building up to 3 of the static class
- tables, or their negations. The [:blank:] class sets up the same
- chars as the [:space:] class (all white space). We remove the vertical
- white space chars afterwards. */
-
- posix_class *= 3;
- for (i = 0; i < 3; i++) {
- BOOL blankclass = strncmp((char *) ptr, "blank", 5) == 0;
- int taboffset = posix_class_maps[posix_class + i];
- if (taboffset < 0)
- break;
- if (local_negate) {
- if (i == 0)
- for (c = 0; c < 32; c++)
- classbits[c] |= ~cbits[c + taboffset];
- else
- for (c = 0; c < 32; c++)
- classbits[c] &= ~cbits[c + taboffset];
- if (blankclass)
- classbits[1] |= 0x3c;
- } else {
- for (c = 0; c < 32; c++)
- classbits[c] |= cbits[c + taboffset];
- if (blankclass)
- classbits[1] &= ~0x3c;
- }
- }
-
- ptr = tempptr + 1;
- class_charcount = 10; /* Set > 1; assumes more than 1 per class */
- continue; /* End of POSIX syntax handling */
- }
-
- /* Backslash may introduce a single character, or it may introduce one
- of the specials, which just set a flag. Escaped items are checked for
- validity in the pre-compiling pass. The sequence \b is a special case.
- Inside a class (and only there) it is treated as backspace. Elsewhere
- it marks a word boundary. Other escapes have preset maps ready to
- or into the one we are building. We assume they have more than one
- character in them, so set class_charcount bigger than one. */
-
- if (c == '\\') {
- c = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);
-
- if (-c == ESC_b)
- c = '\b'; /* \b is backslash in a class */
- else if (-c == ESC_X)
- c = 'X'; /* \X is literal X in a class */
- else if (-c == ESC_Q) { /* Handle start of quoted string */
- if (ptr[1] == '\\' && ptr[2] == 'E') {
- ptr += 2; /* avoid empty string */
- } else
- inescq = TRUE;
- continue;
- }
-
- if (c < 0) {
- register const uschar *cbits = cd->cbits;
- class_charcount += 2; /* Greater than 1 is what matters */
- switch (-c) {
- case ESC_d:
- for (c = 0; c < 32; c++)
- classbits[c] |= cbits[c + cbit_digit];
- continue;
-
- case ESC_D:
- for (c = 0; c < 32; c++)
- classbits[c] |= ~cbits[c + cbit_digit];
- continue;
-
- case ESC_w:
- for (c = 0; c < 32; c++)
- classbits[c] |= cbits[c + cbit_word];
- continue;
-
- case ESC_W:
- for (c = 0; c < 32; c++)
- classbits[c] |= ~cbits[c + cbit_word];
- continue;
-
- case ESC_s:
- for (c = 0; c < 32; c++)
- classbits[c] |= cbits[c + cbit_space];
- classbits[1] &= ~0x08; /* Perl 5.004 onwards omits VT from \s */
- continue;
-
- case ESC_S:
- for (c = 0; c < 32; c++)
- classbits[c] |= ~cbits[c + cbit_space];
- classbits[1] |= 0x08; /* Perl 5.004 onwards omits VT from \s */
- continue;
+ /* Inside \Q...\E everything is literal except \E */
+
+ if (inescq) {
+ if (c == '\\' && ptr[1] == 'E') {
+ inescq = FALSE;
+ ptr++;
+ continue;
+ } else
+ goto LONE_SINGLE_CHARACTER;
+ }
+
+ /* Handle POSIX class names. Perl allows a negation extension of the
+ form [:^name:]. A square bracket that doesn't match the syntax is
+ treated as a literal. We also recognize the POSIX constructions
+ [.ch.] and [=ch=] ("collating elements") and fault them, as Perl
+ 5.6 and 5.8 do. */
+
+ if (c == '[' &&
+ (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+ check_posix_syntax(ptr, &tempptr, cd)) {
+ BOOL local_negate = FALSE;
+ int posix_class, i;
+ register const uschar *cbits = cd->cbits;
+
+ if (ptr[1] != ':') {
+ *errorcodeptr = ERR31;
+ goto FAILED;
+ }
+
+ ptr += 2;
+ if (*ptr == '^') {
+ local_negate = TRUE;
+ ptr++;
+ }
+
+ posix_class = check_posix_name(ptr, tempptr - ptr);
+ if (posix_class < 0) {
+ *errorcodeptr = ERR30;
+ goto FAILED;
+ }
+
+ /* If matching is caseless, upper and lower are converted to
+ alpha. This relies on the fact that the class table starts with
+ alpha, lower, upper as the first 3 entries. */
+
+ if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
+ posix_class = 0;
+
+ /* Or into the map we are building up to 3 of the static class
+ tables, or their negations. The [:blank:] class sets up the same
+ chars as the [:space:] class (all white space). We remove the vertical
+ white space chars afterwards. */
+
+ posix_class *= 3;
+ for (i = 0; i < 3; i++) {
+ BOOL blankclass = strncmp((char *) ptr, "blank", 5) == 0;
+ int taboffset = posix_class_maps[posix_class + i];
+ if (taboffset < 0)
+ break;
+ if (local_negate) {
+ if (i == 0)
+ for (c = 0; c < 32; c++)
+ classbits[c] |= ~cbits[c + taboffset];
+ else
+ for (c = 0; c < 32; c++)
+ classbits[c] &= ~cbits[c + taboffset];
+ if (blankclass)
+ classbits[1] |= 0x3c;
+ } else {
+ for (c = 0; c < 32; c++)
+ classbits[c] |= cbits[c + taboffset];
+ if (blankclass)
+ classbits[1] &= ~0x3c;
+ }
+ }
+
+ ptr = tempptr + 1;
+ class_charcount = 10; /* Set > 1; assumes more than 1 per class */
+ continue; /* End of POSIX syntax handling */
+ }
+
+ /* Backslash may introduce a single character, or it may introduce one
+ of the specials, which just set a flag. Escaped items are checked for
+ validity in the pre-compiling pass. The sequence \b is a special case.
+ Inside a class (and only there) it is treated as backspace. Elsewhere
+ it marks a word boundary. Other escapes have preset maps ready to
+ or into the one we are building. We assume they have more than one
+ character in them, so set class_charcount bigger than one. */
+
+ if (c == '\\') {
+ c = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);
+
+ if (-c == ESC_b)
+ c = '\b'; /* \b is backslash in a class */
+ else if (-c == ESC_X)
+ c = 'X'; /* \X is literal X in a class */
+ else if (-c == ESC_Q) { /* Handle start of quoted string */
+ if (ptr[1] == '\\' && ptr[2] == 'E') {
+ ptr += 2; /* avoid empty string */
+ } else
+ inescq = TRUE;
+ continue;
+ }
+
+ if (c < 0) {
+ register const uschar *cbits = cd->cbits;
+ class_charcount += 2; /* Greater than 1 is what matters */
+ switch (-c) {
+ case ESC_d:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= cbits[c + cbit_digit];
+ continue;
+
+ case ESC_D:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= ~cbits[c + cbit_digit];
+ continue;
+
+ case ESC_w:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= cbits[c + cbit_word];
+ continue;
+
+ case ESC_W:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= ~cbits[c + cbit_word];
+ continue;
+
+ case ESC_s:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= cbits[c + cbit_space];
+ classbits[1] &= ~0x08; /* Perl 5.004 onwards omits VT from \s */
+ continue;
+
+ case ESC_S:
+ for (c = 0; c < 32; c++)
+ classbits[c] |= ~cbits[c + cbit_space];
+ classbits[1] |= 0x08; /* Perl 5.004 onwards omits VT from \s */
+ continue;
#ifdef SUPPORT_UCP
- case ESC_p:
- case ESC_P:
- {
- BOOL negated;
- int property = get_ucp(&ptr, &negated, errorcodeptr);
- if (property < 0)
- goto FAILED;
- class_utf8 = TRUE;
- *class_utf8data++ = ((-c == ESC_p) != negated) ?
- XCL_PROP : XCL_NOTPROP;
- *class_utf8data++ = property;
- class_charcount -= 2; /* Not a < 256 character */
- }
- continue;
+ case ESC_p:
+ case ESC_P:
+ {
+ BOOL negated;
+ int property = get_ucp(&ptr, &negated, errorcodeptr);
+ if (property < 0)
+ goto FAILED;
+ class_utf8 = TRUE;
+ *class_utf8data++ = ((-c == ESC_p) != negated) ?
+ XCL_PROP : XCL_NOTPROP;
+ *class_utf8data++ = property;
+ class_charcount -= 2; /* Not a < 256 character */
+ }
+ continue;
#endif
- /* Unrecognized escapes are faulted if PCRE is running in its
- strict mode. By default, for compatibility with Perl, they are
- treated as literals. */
-
- default:
- if ((options & PCRE_EXTRA) != 0) {
- *errorcodeptr = ERR7;
- goto FAILED;
- }
- c = *ptr; /* The final character */
- class_charcount -= 2; /* Undo the default count from above */
- }
- }
-
- /* Fall through if we have a single character (c >= 0). This may be
- > 256 in UTF-8 mode. */
-
- }
-
-
- /* End of backslash handling */
- /* A single character may be followed by '-' to form a range. However,
- Perl does not permit ']' to be the end of the range. A '-' character
- here is treated as a literal. */
- if (ptr[1] == '-' && ptr[2] != ']') {
- int d;
- ptr += 2;
-
- d = *ptr; /* Not UTF-8 mode */
-
- /* The second part of a range can be a single-character escape, but
- not any of the other escapes. Perl 5.6 treats a hyphen as a literal
- in such circumstances. */
-
- if (d == '\\') {
- const uschar *oldptr = ptr;
- d = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);
-
- /* \b is backslash; \X is literal X; any other special means the '-'
- was literal */
-
- if (d < 0) {
- if (d == -ESC_b)
- d = '\b';
- else if (d == -ESC_X)
- d = 'X';
- else {
- ptr = oldptr - 2;
- goto LONE_SINGLE_CHARACTER; /* A few lines below */
- }
- }
- }
-
- /* The check that the two values are in the correct order happens in
- the pre-pass. Optimize one-character ranges */
-
- if (d == c)
- goto LONE_SINGLE_CHARACTER; /* A few lines below */
-
- /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless
- matching, we have to use an XCLASS with extra data items. Caseless
- matching for characters > 127 is available only if UCP support is
- available. */
-
-
- /* We use the bit map for all cases when not in UTF-8 mode; else
- ranges that lie entirely within 0-127 when there is UCP support; else
- for partial ranges without UCP support. */
-
- for (; c <= d; c++) {
- classbits[c / 8] |= (1 << (c & 7));
- if ((options & PCRE_CASELESS) != 0) {
- int uc = cd->fcc[c]; /* flip case */
- classbits[uc / 8] |= (1 << (uc & 7));
- }
- class_charcount++; /* in case a one-char range */
- class_lastchar = c;
- }
-
- continue; /* Go get the next char in the class */
- }
-
- /* Handle a lone single character - we can get here for a normal
- non-escape char, or after \ that introduces a single character or for an
- apparent range that isn't. */
+ /* Unrecognized escapes are faulted if PCRE is running in its
+ strict mode. By default, for compatibility with Perl, they are
+ treated as literals. */
+
+ default:
+ if ((options & PCRE_EXTRA) != 0) {
+ *errorcodeptr = ERR7;
+ goto FAILED;
+ }
+ c = *ptr; /* The final character */
+ class_charcount -= 2; /* Undo the default count from above */
+ }
+ }
+
+ /* Fall through if we have a single character (c >= 0). This may be
+ > 256 in UTF-8 mode. */
+
+ }
+
+
+ /* End of backslash handling */
+ /* A single character may be followed by '-' to form a range. However,
+ Perl does not permit ']' to be the end of the range. A '-' character
+ here is treated as a literal. */
+ if (ptr[1] == '-' && ptr[2] != ']') {
+ int d;
+ ptr += 2;
+
+ d = *ptr; /* Not UTF-8 mode */
+
+ /* The second part of a range can be a single-character escape, but
+ not any of the other escapes. Perl 5.6 treats a hyphen as a literal
+ in such circumstances. */
+
+ if (d == '\\') {
+ const uschar *oldptr = ptr;
+ d = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);
+
+ /* \b is backslash; \X is literal X; any other special means the '-'
+ was literal */
+
+ if (d < 0) {
+ if (d == -ESC_b)
+ d = '\b';
+ else if (d == -ESC_X)
+ d = 'X';
+ else {
+ ptr = oldptr - 2;
+ goto LONE_SINGLE_CHARACTER; /* A few lines below */
+ }
+ }
+ }
+
+ /* The check that the two values are in the correct order happens in
+ the pre-pass. Optimize one-character ranges */
+
+ if (d == c)
+ goto LONE_SINGLE_CHARACTER; /* A few lines below */
+
+ /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless
+ matching, we have to use an XCLASS with extra data items. Caseless
+ matching for characters > 127 is available only if UCP support is
+ available. */
+
+
+ /* We use the bit map for all cases when not in UTF-8 mode; else
+ ranges that lie entirely within 0-127 when there is UCP support; else
+ for partial ranges without UCP support. */
+
+ for (; c <= d; c++) {
+ classbits[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0) {
+ int uc = cd->fcc[c]; /* flip case */
+ classbits[uc / 8] |= (1 << (uc & 7));
+ }
+ class_charcount++; /* in case a one-char range */
+ class_lastchar = c;
+ }
+
+ continue; /* Go get the next char in the class */
+ }
+
+ /* Handle a lone single character - we can get here for a normal
+ non-escape char, or after \ that introduces a single character or for an
+ apparent range that isn't. */
LONE_SINGLE_CHARACTER:
- /* Handle a character that cannot go in the bit map */
+ /* Handle a character that cannot go in the bit map */
- /* Handle a single-byte character */
- {
- classbits[c / 8] |= (1 << (c & 7));
- if ((options & PCRE_CASELESS) != 0) {
- c = cd->fcc[c]; /* flip case */
- classbits[c / 8] |= (1 << (c & 7));
- }
- class_charcount++;
- class_lastchar = c;
- }
+ /* Handle a single-byte character */
+ {
+ classbits[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0) {
+ c = cd->fcc[c]; /* flip case */
+ classbits[c / 8] |= (1 << (c & 7));
+ }
+ class_charcount++;
+ class_lastchar = c;
+ }
}
/* Loop until ']' reached; the check for end of string happens inside the
reqbyte, save the previous value for reinstating. */
if (class_charcount == 1) {
- zeroreqbyte = reqbyte;
-
- /* The OP_NOT opcode works on one-byte characters only. */
-
- if (negate_class) {
- if (firstbyte == REQ_UNSET)
- firstbyte = REQ_NONE;
- zerofirstbyte = firstbyte;
- *code++ = OP_NOT;
- *code++ = class_lastchar;
- break;
- }
-
- /* For a single, positive character, get the value into mcbuffer, and
- then we can handle this with the normal one-character code. */
-
- {
- mcbuffer[0] = class_lastchar;
- mclength = 1;
- }
- goto ONE_CHAR;
+ zeroreqbyte = reqbyte;
+
+ /* The OP_NOT opcode works on one-byte characters only. */
+
+ if (negate_class) {
+ if (firstbyte == REQ_UNSET)
+ firstbyte = REQ_NONE;
+ zerofirstbyte = firstbyte;
+ *code++ = OP_NOT;
+ *code++ = class_lastchar;
+ break;
+ }
+
+ /* For a single, positive character, get the value into mcbuffer, and
+ then we can handle this with the normal one-character code. */
+
+ {
+ mcbuffer[0] = class_lastchar;
+ mclength = 1;
+ }
+ goto ONE_CHAR;
}
repeat count. Any reqbyte setting must remain unchanged after any kind of
repeat. */
if (firstbyte == REQ_UNSET)
- firstbyte = REQ_NONE;
+ firstbyte = REQ_NONE;
zerofirstbyte = firstbyte;
zeroreqbyte = reqbyte;
setting must remain unchanged after any kind of repeat. */
if (negate_class) {
- *code++ = OP_NCLASS;
- for (c = 0; c < 32; c++)
- code[c] = ~classbits[c];
+ *code++ = OP_NCLASS;
+ for (c = 0; c < 32; c++)
+ code[c] = ~classbits[c];
} else {
- *code++ = OP_CLASS;
- memcpy(code, classbits, 32);
+ *code++ = OP_CLASS;
+ memcpy(code, classbits, 32);
}
code += 32;
break;
case '{':
if (!is_quantifier)
- goto NORMAL_CHAR;
+ goto NORMAL_CHAR;
ptr = read_repeat_counts(ptr + 1, &repeat_min, &repeat_max, errorcodeptr);
if (*errorcodeptr != 0)
- goto FAILED;
+ goto FAILED;
goto REPEAT;
case '*':
REPEAT:
if (previous == NULL) {
- *errorcodeptr = ERR9;
- goto FAILED;
+ *errorcodeptr = ERR9;
+ goto FAILED;
}
if (repeat_min == 0) {
- firstbyte = zerofirstbyte; /* Adjust for zero repeat */
- reqbyte = zeroreqbyte; /* Ditto */
+ firstbyte = zerofirstbyte; /* Adjust for zero repeat */
+ reqbyte = zeroreqbyte; /* Ditto */
}
/* Remember whether this is a variable length repeat */
reqvary = (repeat_min == repeat_max) ? 0 : REQ_VARY;
- op_type = 0; /* Default single-char op codes */
- possessive_quantifier = FALSE; /* Default not possessive quantifier */
+ op_type = 0; /* Default single-char op codes */
+ possessive_quantifier = FALSE; /* Default not possessive quantifier */
/* Save start of previous item, in case we have to move it up to make space
for an inserted OP_ONCE for the additional '+' extension. */
repeat type to the non-default. */
if (ptr[1] == '+') {
- repeat_type = 0; /* Force greedy */
- possessive_quantifier = TRUE;
- ptr++;
+ repeat_type = 0; /* Force greedy */
+ possessive_quantifier = TRUE;
+ ptr++;
} else if (ptr[1] == '?') {
- repeat_type = greedy_non_default;
- ptr++;
+ repeat_type = greedy_non_default;
+ ptr++;
} else
- repeat_type = greedy_default;
+ repeat_type = greedy_default;
/* If previous was a recursion, we need to wrap it inside brackets so that
it can be replicated if necessary. */
if (*previous == OP_RECURSE) {
- memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);
- code += 1 + LINK_SIZE;
- *previous = OP_BRA;
- PUT(previous, 1, code - previous);
- *code = OP_KET;
- PUT(code, 1, code - previous);
- code += 1 + LINK_SIZE;
+ memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);
+ code += 1 + LINK_SIZE;
+ *previous = OP_BRA;
+ PUT(previous, 1, code - previous);
+ *code = OP_KET;
+ PUT(code, 1, code - previous);
+ code += 1 + LINK_SIZE;
}
/* If previous was a character match, abolish the item and generate a
instead. */
if (*previous == OP_CHAR || *previous == OP_CHARNC) {
- /* Deal with UTF-8 characters that take up more than one byte. It's
- easier to write this out separately than try to macrify it. Use c to
- hold the length of the character in bytes, plus 0x80 to flag that it's a
- length rather than a small character. */
+ /* Deal with UTF-8 characters that take up more than one byte. It's
+ easier to write this out separately than try to macrify it. Use c to
+ hold the length of the character in bytes, plus 0x80 to flag that it's a
+ length rather than a small character. */
- /* Handle the case of a single byte - either with no UTF8 support, or
- with UTF-8 disabled, or for a UTF-8 character < 128. */
+ /* Handle the case of a single byte - either with no UTF8 support, or
+ with UTF-8 disabled, or for a UTF-8 character < 128. */
- {
- c = code[-1];
- if (repeat_min > 1)
- reqbyte = c | req_caseopt | cd->req_varyopt;
- }
+ {
+ c = code[-1];
+ if (repeat_min > 1)
+ reqbyte = c | req_caseopt | cd->req_varyopt;
+ }
- goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
+ goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
}
/* If previous was a single negated character ([^a] or similar), we use
repeat_type. OP_NOT is currently used only for single-byte chars. */
else if (*previous == OP_NOT) {
- op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */
- c = previous[1];
- goto OUTPUT_SINGLE_REPEAT;
+ op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */
+ c = previous[1];
+ goto OUTPUT_SINGLE_REPEAT;
}
/* If previous was a character type match (\d or similar), abolish it and
makes it horribly messy. */
else if (*previous < OP_EODN) {
- uschar *oldcode;
- int prop_type;
- op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */
- c = *previous;
+ uschar *oldcode;
+ int prop_type;
+ op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */
+ c = *previous;
OUTPUT_SINGLE_REPEAT:
- prop_type = (*previous == OP_PROP || *previous == OP_NOTPROP) ?
- previous[1] : -1;
-
- oldcode = code;
- code = previous; /* Usually overwrite previous item */
-
- /* If the maximum is zero then the minimum must also be zero; Perl allows
- this case, so we do too - by simply omitting the item altogether. */
-
- if (repeat_max == 0)
- goto END_REPEAT;
-
- /* All real repeats make it impossible to handle partial matching (maybe
- one day we will be able to remove this restriction). */
-
- if (repeat_max != 1)
- cd->nopartial = TRUE;
-
- /* Combine the op_type with the repeat_type */
-
- repeat_type += op_type;
-
- /* A minimum of zero is handled either as the special case * or ?, or as
- an UPTO, with the maximum given. */
-
- if (repeat_min == 0) {
- if (repeat_max == -1)
- *code++ = OP_STAR + repeat_type;
- else if (repeat_max == 1)
- *code++ = OP_QUERY + repeat_type;
- else {
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max);
- }
- }
-
- /* A repeat minimum of 1 is optimized into some special cases. If the
- maximum is unlimited, we use OP_PLUS. Otherwise, the original item it
- left in place and, if the maximum is greater than 1, we use OP_UPTO with
- one less than the maximum. */
-
- else if (repeat_min == 1) {
- if (repeat_max == -1)
- *code++ = OP_PLUS + repeat_type;
- else {
- code = oldcode; /* leave previous item in place */
- if (repeat_max == 1)
- goto END_REPEAT;
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max - 1);
- }
- }
-
- /* The case {n,n} is just an EXACT, while the general case {n,m} is
- handled as an EXACT followed by an UPTO. */
-
- else {
- *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
- PUT2INC(code, 0, repeat_min);
-
- /* If the maximum is unlimited, insert an OP_STAR. Before doing so,
- we have to insert the character for the previous code. For a repeated
- Unicode property match, there is an extra byte that defines the
- required property. In UTF-8 mode, long characters have their length in
- c, with the 0x80 bit as a flag. */
-
- if (repeat_max < 0) {
- {
- *code++ = c;
- if (prop_type >= 0)
- *code++ = prop_type;
- }
- *code++ = OP_STAR + repeat_type;
- }
-
- /* Else insert an UPTO if the max is greater than the min, again
- preceded by the character, for the previously inserted code. */
-
- else if (repeat_max != repeat_min) {
- *code++ = c;
- if (prop_type >= 0)
- *code++ = prop_type;
- repeat_max -= repeat_min;
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max);
- }
- }
-
- /* The character or character type itself comes last in all cases. */
-
- *code++ = c;
-
- /* For a repeated Unicode property match, there is an extra byte that
- defines the required property. */
+ prop_type = (*previous == OP_PROP || *previous == OP_NOTPROP) ?
+ previous[1] : -1;
+
+ oldcode = code;
+ code = previous; /* Usually overwrite previous item */
+
+ /* If the maximum is zero then the minimum must also be zero; Perl allows
+ this case, so we do too - by simply omitting the item altogether. */
+
+ if (repeat_max == 0)
+ goto END_REPEAT;
+
+ /* All real repeats make it impossible to handle partial matching (maybe
+ one day we will be able to remove this restriction). */
+
+ if (repeat_max != 1)
+ cd->nopartial = TRUE;
+
+ /* Combine the op_type with the repeat_type */
+
+ repeat_type += op_type;
+
+ /* A minimum of zero is handled either as the special case * or ?, or as
+ an UPTO, with the maximum given. */
+
+ if (repeat_min == 0) {
+ if (repeat_max == -1)
+ *code++ = OP_STAR + repeat_type;
+ else if (repeat_max == 1)
+ *code++ = OP_QUERY + repeat_type;
+ else {
+ *code++ = OP_UPTO + repeat_type;
+ PUT2INC(code, 0, repeat_max);
+ }
+ }
+
+ /* A repeat minimum of 1 is optimized into some special cases. If the
+ maximum is unlimited, we use OP_PLUS. Otherwise, the original item it
+ left in place and, if the maximum is greater than 1, we use OP_UPTO with
+ one less than the maximum. */
+
+ else if (repeat_min == 1) {
+ if (repeat_max == -1)
+ *code++ = OP_PLUS + repeat_type;
+ else {
+ code = oldcode; /* leave previous item in place */
+ if (repeat_max == 1)
+ goto END_REPEAT;
+ *code++ = OP_UPTO + repeat_type;
+ PUT2INC(code, 0, repeat_max - 1);
+ }
+ }
+
+ /* The case {n,n} is just an EXACT, while the general case {n,m} is
+ handled as an EXACT followed by an UPTO. */
+
+ else {
+ *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
+ PUT2INC(code, 0, repeat_min);
+
+ /* If the maximum is unlimited, insert an OP_STAR. Before doing so,
+ we have to insert the character for the previous code. For a repeated
+ Unicode property match, there is an extra byte that defines the
+ required property. In UTF-8 mode, long characters have their length in
+ c, with the 0x80 bit as a flag. */
+
+ if (repeat_max < 0) {
+ {
+ *code++ = c;
+ if (prop_type >= 0)
+ *code++ = prop_type;
+ }
+ *code++ = OP_STAR + repeat_type;
+ }
+
+ /* Else insert an UPTO if the max is greater than the min, again
+ preceded by the character, for the previously inserted code. */
+
+ else if (repeat_max != repeat_min) {
+ *code++ = c;
+ if (prop_type >= 0)
+ *code++ = prop_type;
+ repeat_max -= repeat_min;
+ *code++ = OP_UPTO + repeat_type;
+ PUT2INC(code, 0, repeat_max);
+ }
+ }
+
+ /* The character or character type itself comes last in all cases. */
+
+ *code++ = c;
+
+ /* For a repeated Unicode property match, there is an extra byte that
+ defines the required property. */
#ifdef SUPPORT_UCP
- if (prop_type >= 0)
- *code++ = prop_type;
+ if (prop_type >= 0)
+ *code++ = prop_type;
#endif
}
stuff after it, but just skip the item if the repeat was {0,0}. */
else if (*previous == OP_CLASS ||
- *previous == OP_NCLASS || *previous == OP_REF) {
- if (repeat_max == 0) {
- code = previous;
- goto END_REPEAT;
- }
-
- /* All real repeats make it impossible to handle partial matching (maybe
- one day we will be able to remove this restriction). */
-
- if (repeat_max != 1)
- cd->nopartial = TRUE;
-
- if (repeat_min == 0 && repeat_max == -1)
- *code++ = OP_CRSTAR + repeat_type;
- else if (repeat_min == 1 && repeat_max == -1)
- *code++ = OP_CRPLUS + repeat_type;
- else if (repeat_min == 0 && repeat_max == 1)
- *code++ = OP_CRQUERY + repeat_type;
- else {
- *code++ = OP_CRRANGE + repeat_type;
- PUT2INC(code, 0, repeat_min);
- if (repeat_max == -1)
- repeat_max = 0; /* 2-byte encoding for max */
- PUT2INC(code, 0, repeat_max);
- }
+ *previous == OP_NCLASS || *previous == OP_REF) {
+ if (repeat_max == 0) {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ /* All real repeats make it impossible to handle partial matching (maybe
+ one day we will be able to remove this restriction). */
+
+ if (repeat_max != 1)
+ cd->nopartial = TRUE;
+
+ if (repeat_min == 0 && repeat_max == -1)
+ *code++ = OP_CRSTAR + repeat_type;
+ else if (repeat_min == 1 && repeat_max == -1)
+ *code++ = OP_CRPLUS + repeat_type;
+ else if (repeat_min == 0 && repeat_max == 1)
+ *code++ = OP_CRQUERY + repeat_type;
+ else {
+ *code++ = OP_CRRANGE + repeat_type;
+ PUT2INC(code, 0, repeat_min);
+ if (repeat_max == -1)
+ repeat_max = 0; /* 2-byte encoding for max */
+ PUT2INC(code, 0, repeat_max);
+ }
}
/* If previous was a bracket group, we may have to replicate it in certain
cases. */
else if (*previous >= OP_BRA || *previous == OP_ONCE ||
- *previous == OP_COND) {
- register int i;
- int ketoffset = 0;
- int len = code - previous;
- uschar *bralink = NULL;
-
- /* If the maximum repeat count is unlimited, find the end of the bracket
- by scanning through from the start, and compute the offset back to it
- from the current code pointer. There may be an OP_OPT setting following
- the final KET, so we can't find the end just by going back from the code
- pointer. */
-
- if (repeat_max == -1) {
- register uschar *ket = previous;
- do
- ket += GET(ket, 1);
- while (*ket != OP_KET);
- ketoffset = code - ket;
- }
-
- /* The case of a zero minimum is special because of the need to stick
- OP_BRAZERO in front of it, and because the group appears once in the
- data, whereas in other cases it appears the minimum number of times. For
- this reason, it is simplest to treat this case separately, as otherwise
- the code gets far too messy. There are several special subcases when the
- minimum is zero. */
-
- if (repeat_min == 0) {
- /* If the maximum is also zero, we just omit the group from the output
- altogether. */
-
- if (repeat_max == 0) {
- code = previous;
- goto END_REPEAT;
- }
-
- /* If the maximum is 1 or unlimited, we just have to stick in the
- BRAZERO and do no more at this point. However, we do need to adjust
- any OP_RECURSE calls inside the group that refer to the group itself or
- any internal group, because the offset is from the start of the whole
- regex. Temporarily terminate the pattern while doing this. */
-
- if (repeat_max <= 1) {
- *code = OP_END;
- adjust_recurse(previous, 1, utf8, cd);
- memmove(previous + 1, previous, len);
- code++;
- *previous++ = OP_BRAZERO + repeat_type;
- }
-
- /* If the maximum is greater than 1 and limited, we have to replicate
- in a nested fashion, sticking OP_BRAZERO before each set of brackets.
- The first one has to be handled carefully because it's the original
- copy, which has to be moved up. The remainder can be handled by code
- that is common with the non-zero minimum case below. We have to
- adjust the value or repeat_max, since one less copy is required. Once
- again, we may have to adjust any OP_RECURSE calls inside the group. */
-
- else {
- int offset;
- *code = OP_END;
- adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd);
- memmove(previous + 2 + LINK_SIZE, previous, len);
- code += 2 + LINK_SIZE;
- *previous++ = OP_BRAZERO + repeat_type;
- *previous++ = OP_BRA;
-
- /* We chain together the bracket offset fields that have to be
- filled in later when the ends of the brackets are reached. */
-
- offset = (bralink == NULL) ? 0 : previous - bralink;
- bralink = previous;
- PUTINC(previous, 0, offset);
- }
-
- repeat_max--;
- }
-
- /* If the minimum is greater than zero, replicate the group as many
- times as necessary, and adjust the maximum to the number of subsequent
- copies that we need. If we set a first char from the group, and didn't
- set a required char, copy the latter from the former. */
-
- else {
- if (repeat_min > 1) {
- if (groupsetfirstbyte && reqbyte < 0)
- reqbyte = firstbyte;
- for (i = 1; i < repeat_min; i++) {
- memcpy(code, previous, len);
- code += len;
- }
- }
- if (repeat_max > 0)
- repeat_max -= repeat_min;
- }
-
- /* This code is common to both the zero and non-zero minimum cases. If
- the maximum is limited, it replicates the group in a nested fashion,
- remembering the bracket starts on a stack. In the case of a zero minimum,
- the first one was set up above. In all cases the repeat_max now specifies
- the number of additional copies needed. */
-
- if (repeat_max >= 0) {
- for (i = repeat_max - 1; i >= 0; i--) {
- *code++ = OP_BRAZERO + repeat_type;
-
- /* All but the final copy start a new nesting, maintaining the
- chain of brackets outstanding. */
-
- if (i != 0) {
- int offset;
- *code++ = OP_BRA;
- offset = (bralink == NULL) ? 0 : code - bralink;
- bralink = code;
- PUTINC(code, 0, offset);
- }
-
- memcpy(code, previous, len);
- code += len;
- }
-
- /* Now chain through the pending brackets, and fill in their length
- fields (which are holding the chain links pro tem). */
-
- while (bralink != NULL) {
- int oldlinkoffset;
- int offset = code - bralink + 1;
- uschar *bra = code - offset;
- oldlinkoffset = GET(bra, 1);
- bralink = (oldlinkoffset == 0) ? NULL : bralink - oldlinkoffset;
- *code++ = OP_KET;
- PUTINC(code, 0, offset);
- PUT(bra, 1, offset);
- }
- }
-
- /* If the maximum is unlimited, set a repeater in the final copy. We
- can't just offset backwards from the current code point, because we
- don't know if there's been an options resetting after the ket. The
- correct offset was computed above. */
-
- else
- code[-ketoffset] = OP_KETRMAX + repeat_type;
+ *previous == OP_COND) {
+ register int i;
+ int ketoffset = 0;
+ int len = code - previous;
+ uschar *bralink = NULL;
+
+ /* If the maximum repeat count is unlimited, find the end of the bracket
+ by scanning through from the start, and compute the offset back to it
+ from the current code pointer. There may be an OP_OPT setting following
+ the final KET, so we can't find the end just by going back from the code
+ pointer. */
+
+ if (repeat_max == -1) {
+ register uschar *ket = previous;
+ do
+ ket += GET(ket, 1);
+ while (*ket != OP_KET);
+ ketoffset = code - ket;
+ }
+
+ /* The case of a zero minimum is special because of the need to stick
+ OP_BRAZERO in front of it, and because the group appears once in the
+ data, whereas in other cases it appears the minimum number of times. For
+ this reason, it is simplest to treat this case separately, as otherwise
+ the code gets far too messy. There are several special subcases when the
+ minimum is zero. */
+
+ if (repeat_min == 0) {
+ /* If the maximum is also zero, we just omit the group from the output
+ altogether. */
+
+ if (repeat_max == 0) {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ /* If the maximum is 1 or unlimited, we just have to stick in the
+ BRAZERO and do no more at this point. However, we do need to adjust
+ any OP_RECURSE calls inside the group that refer to the group itself or
+ any internal group, because the offset is from the start of the whole
+ regex. Temporarily terminate the pattern while doing this. */
+
+ if (repeat_max <= 1) {
+ *code = OP_END;
+ adjust_recurse(previous, 1, utf8, cd);
+ memmove(previous + 1, previous, len);
+ code++;
+ *previous++ = OP_BRAZERO + repeat_type;
+ }
+
+ /* If the maximum is greater than 1 and limited, we have to replicate
+ in a nested fashion, sticking OP_BRAZERO before each set of brackets.
+ The first one has to be handled carefully because it's the original
+ copy, which has to be moved up. The remainder can be handled by code
+ that is common with the non-zero minimum case below. We have to
+ adjust the value or repeat_max, since one less copy is required. Once
+ again, we may have to adjust any OP_RECURSE calls inside the group. */
+
+ else {
+ int offset;
+ *code = OP_END;
+ adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd);
+ memmove(previous + 2 + LINK_SIZE, previous, len);
+ code += 2 + LINK_SIZE;
+ *previous++ = OP_BRAZERO + repeat_type;
+ *previous++ = OP_BRA;
+
+ /* We chain together the bracket offset fields that have to be
+ filled in later when the ends of the brackets are reached. */
+
+ offset = (bralink == NULL) ? 0 : previous - bralink;
+ bralink = previous;
+ PUTINC(previous, 0, offset);
+ }
+
+ repeat_max--;
+ }
+
+ /* If the minimum is greater than zero, replicate the group as many
+ times as necessary, and adjust the maximum to the number of subsequent
+ copies that we need. If we set a first char from the group, and didn't
+ set a required char, copy the latter from the former. */
+
+ else {
+ if (repeat_min > 1) {
+ if (groupsetfirstbyte && reqbyte < 0)
+ reqbyte = firstbyte;
+ for (i = 1; i < repeat_min; i++) {
+ memcpy(code, previous, len);
+ code += len;
+ }
+ }
+ if (repeat_max > 0)
+ repeat_max -= repeat_min;
+ }
+
+ /* This code is common to both the zero and non-zero minimum cases. If
+ the maximum is limited, it replicates the group in a nested fashion,
+ remembering the bracket starts on a stack. In the case of a zero minimum,
+ the first one was set up above. In all cases the repeat_max now specifies
+ the number of additional copies needed. */
+
+ if (repeat_max >= 0) {
+ for (i = repeat_max - 1; i >= 0; i--) {
+ *code++ = OP_BRAZERO + repeat_type;
+
+ /* All but the final copy start a new nesting, maintaining the
+ chain of brackets outstanding. */
+
+ if (i != 0) {
+ int offset;
+ *code++ = OP_BRA;
+ offset = (bralink == NULL) ? 0 : code - bralink;
+ bralink = code;
+ PUTINC(code, 0, offset);
+ }
+
+ memcpy(code, previous, len);
+ code += len;
+ }
+
+ /* Now chain through the pending brackets, and fill in their length
+ fields (which are holding the chain links pro tem). */
+
+ while (bralink != NULL) {
+ int oldlinkoffset;
+ int offset = code - bralink + 1;
+ uschar *bra = code - offset;
+ oldlinkoffset = GET(bra, 1);
+ bralink = (oldlinkoffset == 0) ? NULL : bralink - oldlinkoffset;
+ *code++ = OP_KET;
+ PUTINC(code, 0, offset);
+ PUT(bra, 1, offset);
+ }
+ }
+
+ /* If the maximum is unlimited, set a repeater in the final copy. We
+ can't just offset backwards from the current code point, because we
+ don't know if there's been an options resetting after the ket. The
+ correct offset was computed above. */
+
+ else
+ code[-ketoffset] = OP_KETRMAX + repeat_type;
}
/* Else there's some kind of shambles */
else {
- *errorcodeptr = ERR11;
- goto FAILED;
+ *errorcodeptr = ERR11;
+ goto FAILED;
}
/* If the character following a repeat is '+', we wrap the entire repeated
repeated. However, we don't support '+' after a greediness '?'. */
if (possessive_quantifier) {
- int len = code - tempcode;
- memmove(tempcode + 1 + LINK_SIZE, tempcode, len);
- code += 1 + LINK_SIZE;
- len += 1 + LINK_SIZE;
- tempcode[0] = OP_ONCE;
- *code++ = OP_KET;
- PUTINC(code, 0, len);
- PUT(tempcode, 1, len);
+ int len = code - tempcode;
+ memmove(tempcode + 1 + LINK_SIZE, tempcode, len);
+ code += 1 + LINK_SIZE;
+ len += 1 + LINK_SIZE;
+ tempcode[0] = OP_ONCE;
+ *code++ = OP_KET;
+ PUTINC(code, 0, len);
+ PUT(tempcode, 1, len);
}
/* In all case we no longer have a previous item. We also set the
skipbytes = 0;
if (*(++ptr) == '?') {
- int set, unset;
- int *optset;
-
- switch (*(++ptr)) {
- case '#': /* Comment; skip to ket */
- ptr++;
- while (*ptr != ')')
- ptr++;
- continue;
-
- case ':': /* Non-extracting bracket */
- bravalue = OP_BRA;
- ptr++;
- break;
-
- case '(':
- bravalue = OP_COND; /* Conditional group */
-
- /* Condition to test for recursion */
-
- if (ptr[1] == 'R') {
- code[1 + LINK_SIZE] = OP_CREF;
- PUT2(code, 2 + LINK_SIZE, CREF_RECURSE);
- skipbytes = 3;
- ptr += 3;
- }
-
- /* Condition to test for a numbered subpattern match. We know that
- if a digit follows ( then there will just be digits until ) because
- the syntax was checked in the first pass. */
-
- else if ((digitab[ptr[1]] && ctype_digit) != 0) {
- int condref; /* Don't amalgamate; some compilers */
- condref = *(++ptr) - '0'; /* grumble at autoincrement in declaration */
- while (*(++ptr) != ')')
- condref = condref * 10 + *ptr - '0';
- if (condref == 0) {
- *errorcodeptr = ERR35;
- goto FAILED;
- }
- ptr++;
- code[1 + LINK_SIZE] = OP_CREF;
- PUT2(code, 2 + LINK_SIZE, condref);
- skipbytes = 3;
- }
- /* For conditions that are assertions, we just fall through, having
- set bravalue above. */
- break;
-
- case '=': /* Positive lookahead */
- bravalue = OP_ASSERT;
- ptr++;
- break;
-
- case '!': /* Negative lookahead */
- bravalue = OP_ASSERT_NOT;
- ptr++;
- break;
-
- case '<': /* Lookbehinds */
- switch (*(++ptr)) {
- case '=': /* Positive lookbehind */
- bravalue = OP_ASSERTBACK;
- ptr++;
- break;
-
- case '!': /* Negative lookbehind */
- bravalue = OP_ASSERTBACK_NOT;
- ptr++;
- break;
- }
- break;
-
- case '>': /* One-time brackets */
- bravalue = OP_ONCE;
- ptr++;
- break;
-
- case 'C': /* Callout - may be followed by digits; */
- previous_callout = code; /* Save for later completion */
- after_manual_callout = 1; /* Skip one item before completing */
- *code++ = OP_CALLOUT; /* Already checked that the terminating */
- { /* closing parenthesis is present. */
- int n = 0;
- while ((digitab[*(++ptr)] & ctype_digit) != 0)
- n = n * 10 + *ptr - '0';
- if (n > 255) {
- *errorcodeptr = ERR38;
- goto FAILED;
- }
- *code++ = n;
- PUT(code, 0, ptr - cd->start_pattern + 1); /* Pattern offset */
- PUT(code, LINK_SIZE, 0); /* Default length */
- code += 2 * LINK_SIZE;
- }
- previous = NULL;
- continue;
-
- case 'P': /* Named subpattern handling */
- if (*(++ptr) == '<') { /* Definition */
- int i, namelen;
- uschar *slot = cd->name_table;
- const uschar *name; /* Don't amalgamate; some compilers */
- name = ++ptr; /* grumble at autoincrement in declaration */
-
- while (*ptr++ != '>') ;
- namelen = ptr - name - 1;
-
- for (i = 0; i < cd->names_found; i++) {
- int crc = memcmp(name, slot + 2, namelen);
- if (crc == 0) {
- if (slot[2 + namelen] == 0) {
- *errorcodeptr = ERR43;
- goto FAILED;
- }
- crc = -1; /* Current name is substring */
- }
- if (crc < 0) {
- memmove(slot + cd->name_entry_size, slot,
- (cd->names_found - i) * cd->name_entry_size);
- break;
- }
- slot += cd->name_entry_size;
- }
-
- PUT2(slot, 0, *brackets + 1);
- memcpy(slot + 2, name, namelen);
- slot[2 + namelen] = 0;
- cd->names_found++;
- goto NUMBERED_GROUP;
- }
-
- if (*ptr == '=' || *ptr == '>') { /* Reference or recursion */
- int i, namelen;
- int type = *ptr++;
- const uschar *name = ptr;
- uschar *slot = cd->name_table;
-
- while (*ptr != ')')
- ptr++;
- namelen = ptr - name;
-
- for (i = 0; i < cd->names_found; i++) {
- if (strncmp((char *) name, (char *) slot + 2, namelen) == 0)
- break;
- slot += cd->name_entry_size;
- }
- if (i >= cd->names_found) {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
-
- recno = GET2(slot, 0);
-
- if (type == '>')
- goto HANDLE_RECURSION; /* A few lines below */
-
- /* Back reference */
-
- previous = code;
- *code++ = OP_REF;
- PUT2INC(code, 0, recno);
- cd->backref_map |= (recno < 32) ? (1 << recno) : 1;
- if (recno > cd->top_backref)
- cd->top_backref = recno;
- continue;
- }
-
- /* Should never happen */
- break;
-
- case 'R': /* Pattern recursion */
- ptr++; /* Same as (?0) */
- /* Fall through */
-
- /* Recursion or "subroutine" call */
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- const uschar *called;
- recno = 0;
- while ((digitab[*ptr] & ctype_digit) != 0)
- recno = recno * 10 + *ptr++ - '0';
-
- /* Come here from code above that handles a named recursion */
-
- HANDLE_RECURSION:
-
- previous = code;
-
- /* Find the bracket that is being referenced. Temporarily end the
- regex in case it doesn't exist. */
-
- *code = OP_END;
- called = (recno == 0) ?
- cd->start_code : find_bracket(cd->start_code, utf8, recno);
-
- if (called == NULL) {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
-
- /* If the subpattern is still open, this is a recursive call. We
- check to see if this is a left recursion that could loop for ever,
- and diagnose that case. */
-
- if (GET(called, 1) == 0
- && could_be_empty(called, code, bcptr, utf8)) {
- *errorcodeptr = ERR40;
- goto FAILED;
- }
-
- /* Insert the recursion/subroutine item */
-
- *code = OP_RECURSE;
- PUT(code, 1, called - cd->start_code);
- code += 1 + LINK_SIZE;
- }
- continue;
-
- /* Character after (? not specially recognized */
-
- default: /* Option setting */
- set = unset = 0;
- optset = &set;
-
- while (*ptr != ')' && *ptr != ':') {
- switch (*ptr++) {
- case '-':
- optset = &unset;
- break;
-
- case 'i':
- *optset |= PCRE_CASELESS;
- break;
- case 'm':
- *optset |= PCRE_MULTILINE;
- break;
- case 's':
- *optset |= PCRE_DOTALL;
- break;
- case 'x':
- *optset |= PCRE_EXTENDED;
- break;
- case 'U':
- *optset |= PCRE_UNGREEDY;
- break;
- case 'X':
- *optset |= PCRE_EXTRA;
- break;
- }
- }
-
- /* Set up the changed option bits, but don't change anything yet. */
-
- newoptions = (options | set) & (~unset);
-
- /* If the options ended with ')' this is not the start of a nested
- group with option changes, so the options change at this level. Compile
- code to change the ims options if this setting actually changes any of
- them. We also pass the new setting back so that it can be put at the
- start of any following branches, and when this group ends (if we are in
- a group), a resetting item can be compiled.
-
- Note that if this item is right at the start of the pattern, the
- options will have been abstracted and made global, so there will be no
- change to compile. */
-
- if (*ptr == ')') {
- if ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) {
- *code++ = OP_OPT;
- *code++ = newoptions & PCRE_IMS;
- }
-
- /* Change options at this level, and pass them back for use
- in subsequent branches. Reset the greedy defaults and the case
- value for firstbyte and reqbyte. */
-
- *optionsptr = options = newoptions;
- greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);
- greedy_non_default = greedy_default ^ 1;
- req_caseopt = ((options & PCRE_CASELESS) != 0) ? REQ_CASELESS : 0;
-
- previous = NULL; /* This item can't be repeated */
- continue; /* It is complete */
- }
-
- /* If the options ended with ':' we are heading into a nested group
- with possible change of options. Such groups are non-capturing and are
- not assertions of any kind. All we need to do is skip over the ':';
- the newoptions value is handled below. */
-
- bravalue = OP_BRA;
- ptr++;
- }
+ int set, unset;
+ int *optset;
+
+ switch (*(++ptr)) {
+ case '#': /* Comment; skip to ket */
+ ptr++;
+ while (*ptr != ')')
+ ptr++;
+ continue;
+
+ case ':': /* Non-extracting bracket */
+ bravalue = OP_BRA;
+ ptr++;
+ break;
+
+ case '(':
+ bravalue = OP_COND; /* Conditional group */
+
+ /* Condition to test for recursion */
+
+ if (ptr[1] == 'R') {
+ code[1 + LINK_SIZE] = OP_CREF;
+ PUT2(code, 2 + LINK_SIZE, CREF_RECURSE);
+ skipbytes = 3;
+ ptr += 3;
+ }
+
+ /* Condition to test for a numbered subpattern match. We know that
+ if a digit follows ( then there will just be digits until ) because
+ the syntax was checked in the first pass. */
+
+ else if ((digitab[ptr[1]] && ctype_digit) != 0) {
+ int condref; /* Don't amalgamate; some compilers */
+ condref = *(++ptr) - '0'; /* grumble at autoincrement in declaration */
+ while (*(++ptr) != ')')
+ condref = condref * 10 + *ptr - '0';
+ if (condref == 0) {
+ *errorcodeptr = ERR35;
+ goto FAILED;
+ }
+ ptr++;
+ code[1 + LINK_SIZE] = OP_CREF;
+ PUT2(code, 2 + LINK_SIZE, condref);
+ skipbytes = 3;
+ }
+ /* For conditions that are assertions, we just fall through, having
+ set bravalue above. */
+ break;
+
+ case '=': /* Positive lookahead */
+ bravalue = OP_ASSERT;
+ ptr++;
+ break;
+
+ case '!': /* Negative lookahead */
+ bravalue = OP_ASSERT_NOT;
+ ptr++;
+ break;
+
+ case '<': /* Lookbehinds */
+ switch (*(++ptr)) {
+ case '=': /* Positive lookbehind */
+ bravalue = OP_ASSERTBACK;
+ ptr++;
+ break;
+
+ case '!': /* Negative lookbehind */
+ bravalue = OP_ASSERTBACK_NOT;
+ ptr++;
+ break;
+ }
+ break;
+
+ case '>': /* One-time brackets */
+ bravalue = OP_ONCE;
+ ptr++;
+ break;
+
+ case 'C': /* Callout - may be followed by digits; */
+ previous_callout = code; /* Save for later completion */
+ after_manual_callout = 1; /* Skip one item before completing */
+ *code++ = OP_CALLOUT; /* Already checked that the terminating */
+ { /* closing parenthesis is present. */
+ int n = 0;
+ while ((digitab[*(++ptr)] & ctype_digit) != 0)
+ n = n * 10 + *ptr - '0';
+ if (n > 255) {
+ *errorcodeptr = ERR38;
+ goto FAILED;
+ }
+ *code++ = n;
+ PUT(code, 0, ptr - cd->start_pattern + 1); /* Pattern offset */
+ PUT(code, LINK_SIZE, 0); /* Default length */
+ code += 2 * LINK_SIZE;
+ }
+ previous = NULL;
+ continue;
+
+ case 'P': /* Named subpattern handling */
+ if (*(++ptr) == '<') { /* Definition */
+ int i, namelen;
+ uschar *slot = cd->name_table;
+ const uschar *name; /* Don't amalgamate; some compilers */
+ name = ++ptr; /* grumble at autoincrement in declaration */
+
+ while (*ptr++ != '>') ;
+ namelen = ptr - name - 1;
+
+ for (i = 0; i < cd->names_found; i++) {
+ int crc = memcmp(name, slot + 2, namelen);
+ if (crc == 0) {
+ if (slot[2 + namelen] == 0) {
+ *errorcodeptr = ERR43;
+ goto FAILED;
+ }
+ crc = -1; /* Current name is substring */
+ }
+ if (crc < 0) {
+ memmove(slot + cd->name_entry_size, slot,
+ (cd->names_found - i) * cd->name_entry_size);
+ break;
+ }
+ slot += cd->name_entry_size;
+ }
+
+ PUT2(slot, 0, *brackets + 1);
+ memcpy(slot + 2, name, namelen);
+ slot[2 + namelen] = 0;
+ cd->names_found++;
+ goto NUMBERED_GROUP;
+ }
+
+ if (*ptr == '=' || *ptr == '>') { /* Reference or recursion */
+ int i, namelen;
+ int type = *ptr++;
+ const uschar *name = ptr;
+ uschar *slot = cd->name_table;
+
+ while (*ptr != ')')
+ ptr++;
+ namelen = ptr - name;
+
+ for (i = 0; i < cd->names_found; i++) {
+ if (strncmp((char *) name, (char *) slot + 2, namelen) == 0)
+ break;
+ slot += cd->name_entry_size;
+ }
+ if (i >= cd->names_found) {
+ *errorcodeptr = ERR15;
+ goto FAILED;
+ }
+
+ recno = GET2(slot, 0);
+
+ if (type == '>')
+ goto HANDLE_RECURSION; /* A few lines below */
+
+ /* Back reference */
+
+ previous = code;
+ *code++ = OP_REF;
+ PUT2INC(code, 0, recno);
+ cd->backref_map |= (recno < 32) ? (1 << recno) : 1;
+ if (recno > cd->top_backref)
+ cd->top_backref = recno;
+ continue;
+ }
+
+ /* Should never happen */
+ break;
+
+ case 'R': /* Pattern recursion */
+ ptr++; /* Same as (?0) */
+ /* Fall through */
+
+ /* Recursion or "subroutine" call */
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ const uschar *called;
+ recno = 0;
+ while ((digitab[*ptr] & ctype_digit) != 0)
+ recno = recno * 10 + *ptr++ - '0';
+
+ /* Come here from code above that handles a named recursion */
+
+ HANDLE_RECURSION:
+
+ previous = code;
+
+ /* Find the bracket that is being referenced. Temporarily end the
+ regex in case it doesn't exist. */
+
+ *code = OP_END;
+ called = (recno == 0) ?
+ cd->start_code : find_bracket(cd->start_code, utf8, recno);
+
+ if (called == NULL) {
+ *errorcodeptr = ERR15;
+ goto FAILED;
+ }
+
+ /* If the subpattern is still open, this is a recursive call. We
+ check to see if this is a left recursion that could loop for ever,
+ and diagnose that case. */
+
+ if (GET(called, 1) == 0
+ && could_be_empty(called, code, bcptr, utf8)) {
+ *errorcodeptr = ERR40;
+ goto FAILED;
+ }
+
+ /* Insert the recursion/subroutine item */
+
+ *code = OP_RECURSE;
+ PUT(code, 1, called - cd->start_code);
+ code += 1 + LINK_SIZE;
+ }
+ continue;
+
+ /* Character after (? not specially recognized */
+
+ default: /* Option setting */
+ set = unset = 0;
+ optset = &set;
+
+ while (*ptr != ')' && *ptr != ':') {
+ switch (*ptr++) {
+ case '-':
+ optset = &unset;
+ break;
+
+ case 'i':
+ *optset |= PCRE_CASELESS;
+ break;
+ case 'm':
+ *optset |= PCRE_MULTILINE;
+ break;
+ case 's':
+ *optset |= PCRE_DOTALL;
+ break;
+ case 'x':
+ *optset |= PCRE_EXTENDED;
+ break;
+ case 'U':
+ *optset |= PCRE_UNGREEDY;
+ break;
+ case 'X':
+ *optset |= PCRE_EXTRA;
+ break;
+ }
+ }
+
+ /* Set up the changed option bits, but don't change anything yet. */
+
+ newoptions = (options | set) & (~unset);
+
+ /* If the options ended with ')' this is not the start of a nested
+ group with option changes, so the options change at this level. Compile
+ code to change the ims options if this setting actually changes any of
+ them. We also pass the new setting back so that it can be put at the
+ start of any following branches, and when this group ends (if we are in
+ a group), a resetting item can be compiled.
+
+ Note that if this item is right at the start of the pattern, the
+ options will have been abstracted and made global, so there will be no
+ change to compile. */
+
+ if (*ptr == ')') {
+ if ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) {
+ *code++ = OP_OPT;
+ *code++ = newoptions & PCRE_IMS;
+ }
+
+ /* Change options at this level, and pass them back for use
+ in subsequent branches. Reset the greedy defaults and the case
+ value for firstbyte and reqbyte. */
+
+ *optionsptr = options = newoptions;
+ greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);
+ greedy_non_default = greedy_default ^ 1;
+ req_caseopt = ((options & PCRE_CASELESS) != 0) ? REQ_CASELESS : 0;
+
+ previous = NULL; /* This item can't be repeated */
+ continue; /* It is complete */
+ }
+
+ /* If the options ended with ':' we are heading into a nested group
+ with possible change of options. Such groups are non-capturing and are
+ not assertions of any kind. All we need to do is skip over the ':';
+ the newoptions value is handled below. */
+
+ bravalue = OP_BRA;
+ ptr++;
+ }
}
/* If PCRE_NO_AUTO_CAPTURE is set, all unadorned brackets become
non-capturing and behave like (?:...) brackets */
else if ((options & PCRE_NO_AUTO_CAPTURE) != 0) {
- bravalue = OP_BRA;
+ bravalue = OP_BRA;
}
/* Else we have a referencing group; adjust the opcode. If the bracket
else {
NUMBERED_GROUP:
- if (++(*brackets) > EXTRACT_BASIC_MAX) {
- bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;
- code[1 + LINK_SIZE] = OP_BRANUMBER;
- PUT2(code, 2 + LINK_SIZE, *brackets);
- skipbytes = 3;
- } else
- bravalue = OP_BRA + *brackets;
+ if (++(*brackets) > EXTRACT_BASIC_MAX) {
+ bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;
+ code[1 + LINK_SIZE] = OP_BRANUMBER;
+ PUT2(code, 2 + LINK_SIZE, *brackets);
+ skipbytes = 3;
+ } else
+ bravalue = OP_BRA + *brackets;
}
/* Process nested bracketed re. Assertions may not be repeated, but other
previous = (bravalue >= OP_ONCE) ? code : NULL;
*code = bravalue;
tempcode = code;
- tempreqvary = cd->req_varyopt; /* Save value before bracket */
-
- if (!compile_regex(newoptions, /* The complete new option state */
- options & PCRE_IMS, /* The previous ims option state */
- brackets, /* Extracting bracket count */
- &tempcode, /* Where to put code (updated) */
- &ptr, /* Input pointer (updated) */
- errorcodeptr, /* Where to put an error message */
- (bravalue == OP_ASSERTBACK || bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
- skipbytes, /* Skip over OP_COND/OP_BRANUMBER */
- &subfirstbyte, /* For possible first char */
- &subreqbyte, /* For possible last char */
- bcptr, /* Current branch chain */
- cd)) /* Tables block */
- goto FAILED;
+ tempreqvary = cd->req_varyopt; /* Save value before bracket */
+
+ if (!compile_regex(newoptions, /* The complete new option state */
+ options & PCRE_IMS, /* The previous ims option state */
+ brackets, /* Extracting bracket count */
+ &tempcode, /* Where to put code (updated) */
+ &ptr, /* Input pointer (updated) */
+ errorcodeptr, /* Where to put an error message */
+ (bravalue == OP_ASSERTBACK || bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
+ skipbytes, /* Skip over OP_COND/OP_BRANUMBER */
+ &subfirstbyte, /* For possible first char */
+ &subreqbyte, /* For possible last char */
+ bcptr, /* Current branch chain */
+ cd)) /* Tables block */
+ goto FAILED;
/* At the end of compiling, code is still pointing to the start of the
group, while tempcode has been updated to point past the end of the group
two branches in the group. */
else if (bravalue == OP_COND) {
- uschar *tc = code;
- condcount = 0;
+ uschar *tc = code;
+ condcount = 0;
- do {
- condcount++;
- tc += GET(tc, 1);
- }
- while (*tc != OP_KET);
+ do {
+ condcount++;
+ tc += GET(tc, 1);
+ }
+ while (*tc != OP_KET);
- if (condcount > 2) {
- *errorcodeptr = ERR27;
- goto FAILED;
- }
+ if (condcount > 2) {
+ *errorcodeptr = ERR27;
+ goto FAILED;
+ }
- /* If there is just one branch, we must not make use of its firstbyte or
- reqbyte, because this is equivalent to an empty second branch. */
+ /* If there is just one branch, we must not make use of its firstbyte or
+ reqbyte, because this is equivalent to an empty second branch. */
- if (condcount == 1)
- subfirstbyte = subreqbyte = REQ_NONE;
+ if (condcount == 1)
+ subfirstbyte = subreqbyte = REQ_NONE;
}
/* Handle updating of the required and first characters. Update for normal
groupsetfirstbyte = FALSE;
if (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_COND) {
- /* If we have not yet set a firstbyte in this branch, take it from the
- subpattern, remembering that it was set here so that a repeat of more
- than one can replicate it as reqbyte if necessary. If the subpattern has
- no firstbyte, set "none" for the whole branch. In both cases, a zero
- repeat forces firstbyte to "none". */
-
- if (firstbyte == REQ_UNSET) {
- if (subfirstbyte >= 0) {
- firstbyte = subfirstbyte;
- groupsetfirstbyte = TRUE;
- } else
- firstbyte = REQ_NONE;
- zerofirstbyte = REQ_NONE;
- }
-
- /* If firstbyte was previously set, convert the subpattern's firstbyte
- into reqbyte if there wasn't one, using the vary flag that was in
- existence beforehand. */
-
- else if (subfirstbyte >= 0 && subreqbyte < 0)
- subreqbyte = subfirstbyte | tempreqvary;
-
- /* If the subpattern set a required byte (or set a first byte that isn't
- really the first byte - see above), set it. */
-
- if (subreqbyte >= 0)
- reqbyte = subreqbyte;
+ /* If we have not yet set a firstbyte in this branch, take it from the
+ subpattern, remembering that it was set here so that a repeat of more
+ than one can replicate it as reqbyte if necessary. If the subpattern has
+ no firstbyte, set "none" for the whole branch. In both cases, a zero
+ repeat forces firstbyte to "none". */
+
+ if (firstbyte == REQ_UNSET) {
+ if (subfirstbyte >= 0) {
+ firstbyte = subfirstbyte;
+ groupsetfirstbyte = TRUE;
+ } else
+ firstbyte = REQ_NONE;
+ zerofirstbyte = REQ_NONE;
+ }
+
+ /* If firstbyte was previously set, convert the subpattern's firstbyte
+ into reqbyte if there wasn't one, using the vary flag that was in
+ existence beforehand. */
+
+ else if (subfirstbyte >= 0 && subreqbyte < 0)
+ subreqbyte = subfirstbyte | tempreqvary;
+
+ /* If the subpattern set a required byte (or set a first byte that isn't
+ really the first byte - see above), set it. */
+
+ if (subreqbyte >= 0)
+ reqbyte = subreqbyte;
}
/* For a forward assertion, we take the reqbyte, if set. This can be
firstbyte, looking for an asserted first char. */
else if (bravalue == OP_ASSERT && subreqbyte >= 0)
- reqbyte = subreqbyte;
+ reqbyte = subreqbyte;
/* Now update the main code pointer to the end of the group. */
/* Error if hit end of pattern */
if (*ptr != ')') {
- *errorcodeptr = ERR14;
- goto FAILED;
+ *errorcodeptr = ERR14;
+ goto FAILED;
}
break;
have to change if any new ones are ever created. */
if (c < 0) {
- if (-c == ESC_Q) { /* Handle start of quoted string */
- if (ptr[1] == '\\' && ptr[2] == 'E')
- ptr += 2; /* avoid empty string */
- else
- inescq = TRUE;
- continue;
- }
+ if (-c == ESC_Q) { /* Handle start of quoted string */
+ if (ptr[1] == '\\' && ptr[2] == 'E')
+ ptr += 2; /* avoid empty string */
+ else
+ inescq = TRUE;
+ continue;
+ }
- /* For metasequences that actually match a character, we disable the
- setting of a first character if it hasn't already been set. */
+ /* For metasequences that actually match a character, we disable the
+ setting of a first character if it hasn't already been set. */
- if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)
- firstbyte = REQ_NONE;
+ if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)
+ firstbyte = REQ_NONE;
- /* Set values to reset to if this is followed by a zero repeat. */
+ /* Set values to reset to if this is followed by a zero repeat. */
- zerofirstbyte = firstbyte;
- zeroreqbyte = reqbyte;
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = reqbyte;
- /* Back references are handled specially */
+ /* Back references are handled specially */
- if (-c >= ESC_REF) {
- int number = -c - ESC_REF;
- previous = code;
- *code++ = OP_REF;
- PUT2INC(code, 0, number);
- }
+ if (-c >= ESC_REF) {
+ int number = -c - ESC_REF;
+ previous = code;
+ *code++ = OP_REF;
+ PUT2INC(code, 0, number);
+ }
- /* So are Unicode property matches, if supported. We know that get_ucp
- won't fail because it was tested in the pre-pass. */
+ /* So are Unicode property matches, if supported. We know that get_ucp
+ won't fail because it was tested in the pre-pass. */
#ifdef SUPPORT_UCP
- else if (-c == ESC_P || -c == ESC_p) {
- BOOL negated;
- int value = get_ucp(&ptr, &negated, errorcodeptr);
- previous = code;
- *code++ = ((-c == ESC_p) != negated) ? OP_PROP : OP_NOTPROP;
- *code++ = value;
- }
+ else if (-c == ESC_P || -c == ESC_p) {
+ BOOL negated;
+ int value = get_ucp(&ptr, &negated, errorcodeptr);
+ previous = code;
+ *code++ = ((-c == ESC_p) != negated) ? OP_PROP : OP_NOTPROP;
+ *code++ = value;
+ }
#endif
- /* For the rest, we can obtain the OP value by negating the escape
- value */
+ /* For the rest, we can obtain the OP value by negating the escape
+ value */
- else {
- previous = (-c > ESC_b && -c < ESC_Z) ? code : NULL;
- *code++ = -c;
- }
- continue;
+ else {
+ previous = (-c > ESC_b && -c < ESC_Z) ? code : NULL;
+ *code++ = -c;
+ }
+ continue;
}
/* We have a data character whose value is in c. In UTF-8 mode it may have
{
- mcbuffer[0] = c;
- mclength = 1;
+ mcbuffer[0] = c;
+ mclength = 1;
}
goto ONE_CHAR;
previous = code;
*code++ = ((options & PCRE_CASELESS) != 0) ? OP_CHARNC : OP_CHAR;
for (c = 0; c < mclength; c++)
- *code++ = mcbuffer[c];
+ *code++ = mcbuffer[c];
/* Set the first and required bytes appropriately. If no previous first
byte, set it from this character, but revert to none on a zero repeat.
repeat. */
if (firstbyte == REQ_UNSET) {
- zerofirstbyte = REQ_NONE;
- zeroreqbyte = reqbyte;
-
- /* If the character is more than one byte long, we can set firstbyte
- only if it is not to be matched caselessly. */
-
- if (mclength == 1 || req_caseopt == 0) {
- firstbyte = mcbuffer[0] | req_caseopt;
- if (mclength != 1)
- reqbyte = code[-1] | cd->req_varyopt;
- } else
- firstbyte = reqbyte = REQ_NONE;
+ zerofirstbyte = REQ_NONE;
+ zeroreqbyte = reqbyte;
+
+ /* If the character is more than one byte long, we can set firstbyte
+ only if it is not to be matched caselessly. */
+
+ if (mclength == 1 || req_caseopt == 0) {
+ firstbyte = mcbuffer[0] | req_caseopt;
+ if (mclength != 1)
+ reqbyte = code[-1] | cd->req_varyopt;
+ } else
+ firstbyte = reqbyte = REQ_NONE;
}
/* firstbyte was previously set; we can set reqbyte only the length is
1 or the matching is caseful. */
else {
- zerofirstbyte = firstbyte;
- zeroreqbyte = reqbyte;
- if (mclength == 1 || req_caseopt == 0)
- reqbyte = code[-1] | req_caseopt | cd->req_varyopt;
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = reqbyte;
+ if (mclength == 1 || req_caseopt == 0)
+ reqbyte = code[-1] | req_caseopt | cd->req_varyopt;
}
- break; /* End of literal character handling */
+ break; /* End of literal character handling */
}
- } /* end of big loop */
+ } /* end of big loop */
/* Control never reaches here by falling through, only by a goto for all the
error states. Pass back the position in the pattern so that it can be displayed
static BOOL
compile_regex(int options, int oldims, int *brackets, uschar ** codeptr,
- const uschar ** ptrptr, int *errorcodeptr, BOOL lookbehind,
- int skipbytes, int *firstbyteptr, int *reqbyteptr,
- branch_chain * bcptr, compile_data * cd)
+ const uschar ** ptrptr, int *errorcodeptr, BOOL lookbehind,
+ int skipbytes, int *firstbyteptr, int *reqbyteptr,
+ branch_chain * bcptr, compile_data * cd)
{
const uschar *ptr = *ptrptr;
uschar *code = *codeptr;
/* Now compile the branch */
if (!compile_branch(&options, brackets, &code, &ptr, errorcodeptr,
- &branchfirstbyte, &branchreqbyte, &bc, cd)) {
+ &branchfirstbyte, &branchreqbyte, &bc, cd)) {
*ptrptr = ptr;
return FALSE;
}
no reqbyte, it takes on the value of the old firstbyte. */
if (firstbyte >= 0 && firstbyte != branchfirstbyte) {
- if (reqbyte < 0)
- reqbyte = firstbyte;
- firstbyte = REQ_NONE;
+ if (reqbyte < 0)
+ reqbyte = firstbyte;
+ firstbyte = REQ_NONE;
}
/* If we (now or from before) have no firstbyte, a firstbyte from the
branch becomes a reqbyte if there isn't a branch reqbyte. */
if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)
- branchreqbyte = branchfirstbyte;
+ branchreqbyte = branchfirstbyte;
/* Now ensure that the reqbytes match */
if ((reqbyte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY))
- reqbyte = REQ_NONE;
+ reqbyte = REQ_NONE;
else
- reqbyte |= branchreqbyte; /* To "or" REQ_VARY */
+ reqbyte |= branchreqbyte; /* To "or" REQ_VARY */
}
/* If lookbehind, check that this branch matches a fixed-length string,
*code = OP_END;
length = find_fixedlength(last_branch, options);
if (length < 0) {
- *errorcodeptr = (length == -2) ? ERR36 : ERR25;
- *ptrptr = ptr;
- return FALSE;
+ *errorcodeptr = (length == -2) ? ERR36 : ERR25;
+ *ptrptr = ptr;
+ return FALSE;
}
PUT(reverse_count, 0, length);
}
if (*ptr != '|') {
int length = code - last_branch;
do {
- int prev_length = GET(last_branch, 1);
- PUT(last_branch, 1, length);
- length = prev_length;
- last_branch -= length;
+ int prev_length = GET(last_branch, 1);
+ PUT(last_branch, 1, length);
+ length = prev_length;
+ last_branch -= length;
}
while (length > 0);
/* Resetting option if needed */
if ((options & PCRE_IMS) != oldims && *ptr == ')') {
- *code++ = OP_OPT;
- *code++ = oldims;
+ *code++ = OP_OPT;
+ *code++ = oldims;
}
/* Set values to pass back */
static BOOL
is_anchored(register const uschar * code, int *options,
- unsigned int bracket_map, unsigned int backref_map)
+ unsigned int bracket_map, unsigned int backref_map)
{
do {
const uschar *scode =
first_significant_code(code + 1 + LINK_SIZE, options, PCRE_MULTILINE,
- FALSE);
+ FALSE);
register int op = *scode;
/* Capturing brackets */
int new_map;
op -= OP_BRA;
if (op > EXTRACT_BASIC_MAX)
- op = GET2(scode, 2 + LINK_SIZE);
+ op = GET2(scode, 2 + LINK_SIZE);
new_map = bracket_map | ((op < 32) ? (1 << op) : 1);
if (!is_anchored(scode, options, new_map, backref_map))
- return FALSE;
+ return FALSE;
}
/* Other brackets */
else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) {
if (!is_anchored(scode, options, bracket_map, backref_map))
- return FALSE;
+ return FALSE;
}
/* .* is not anchored unless DOTALL is set and it isn't in brackets that
are or may be referenced. */
else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) &&
- (*options & PCRE_DOTALL) != 0) {
+ (*options & PCRE_DOTALL) != 0) {
if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0)
- return FALSE;
+ return FALSE;
}
/* Check for explicit anchoring */
else if (op != OP_SOD && op != OP_SOM &&
- ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
+ ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
return FALSE;
code += GET(code, 1);
}
- while (*code == OP_ALT); /* Loop for each alternative */
+ while (*code == OP_ALT); /* Loop for each alternative */
return TRUE;
}
static BOOL
is_startline(const uschar * code, unsigned int bracket_map,
- unsigned int backref_map)
+ unsigned int backref_map)
{
do {
const uschar *scode = first_significant_code(code + 1 + LINK_SIZE, NULL, 0,
- FALSE);
+ FALSE);
register int op = *scode;
/* Capturing brackets */
int new_map;
op -= OP_BRA;
if (op > EXTRACT_BASIC_MAX)
- op = GET2(scode, 2 + LINK_SIZE);
+ op = GET2(scode, 2 + LINK_SIZE);
new_map = bracket_map | ((op < 32) ? (1 << op) : 1);
if (!is_startline(scode, new_map, backref_map))
- return FALSE;
+ return FALSE;
}
/* Other brackets */
else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) {
if (!is_startline(scode, bracket_map, backref_map))
- return FALSE;
+ return FALSE;
}
/* .* means "start at start or after \n" if it isn't in brackets that
else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR) {
if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0)
- return FALSE;
+ return FALSE;
}
/* Check for explicit circumflex */
code += GET(code, 1);
}
- while (*code == OP_ALT); /* Loop for each alternative */
+ while (*code == OP_ALT); /* Loop for each alternative */
return TRUE;
}
int d;
const uschar *scode =
first_significant_code(code + 1 + LINK_SIZE, options, PCRE_CASELESS,
- TRUE);
+ TRUE);
register int op = *scode;
if (op >= OP_BRA)
case OP_ONCE:
case OP_COND:
if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)
- return -1;
+ return -1;
if (c < 0)
- c = d;
+ c = d;
else if (c != d)
- return -1;
+ return -1;
break;
- case OP_EXACT: /* Fall through */
+ case OP_EXACT: /* Fall through */
scode += 2;
case OP_CHAR:
case OP_PLUS:
case OP_MINPLUS:
if (!inassert)
- return -1;
+ return -1;
if (c < 0) {
- c = scode[1];
- if ((*options & PCRE_CASELESS) != 0)
- c |= REQ_CASELESS;
+ c = scode[1];
+ if ((*options & PCRE_CASELESS) != 0)
+ c |= REQ_CASELESS;
} else if (c != scode[1])
- return -1;
+ return -1;
break;
}
pcre *pcre_compile2(const char *, int, int *, const char **,
- int *, const unsigned char *);
+ int *, const unsigned char *);
/*************************************************
pcre *
pcre_compile(const char *pattern, int options, const char **errorptr,
- int *erroroffset, const unsigned char *tables)
+ int *erroroffset, const unsigned char *tables)
{
return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
}
pcre *
pcre_compile2(const char *pattern, int options, int *errorcodeptr,
- const char **errorptr, int *erroroffset,
- const unsigned char *tables)
+ const char **errorptr, int *erroroffset,
+ const unsigned char *tables)
{
real_pcre *re;
- int length = 1 + LINK_SIZE; /* For initial BRA plus length */
+ int length = 1 + LINK_SIZE; /* For initial BRA plus length */
int c, firstbyte, reqbyte;
int bracount = 0;
int branch_extra = 0;
if (inescq) {
if ((options & PCRE_AUTO_CALLOUT) != 0)
- length += 2 + 2 * LINK_SIZE;
+ length += 2 + 2 * LINK_SIZE;
goto NORMAL_CHAR;
}
if ((options & PCRE_EXTENDED) != 0) {
if ((compile_block.ctypes[c] & ctype_space) != 0)
- continue;
+ continue;
if (c == '#') {
- /* The space before the ; is to avoid a warning on a silly compiler
- on the Macintosh. */
- while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
- if (c == 0)
- break;
- continue;
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
+ if (c == 0)
+ break;
+ continue;
}
}
- item_count++; /* Is zero for the first non-comment item */
+ item_count++; /* Is zero for the first non-comment item */
/* Allow space for auto callout before every item except quantifiers. */
if ((options & PCRE_AUTO_CALLOUT) != 0 &&
- c != '*' && c != '+' && c != '?' &&
- (c != '{' || !is_counted_repeat(ptr + 1)))
+ c != '*' && c != '+' && c != '?' &&
+ (c != '{' || !is_counted_repeat(ptr + 1)))
length += 2 + 2 * LINK_SIZE;
switch (c) {
case '\\':
c = check_escape(&ptr, &errorcode, bracount, options, FALSE);
if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
+ goto PCRE_ERROR_RETURN;
- lastitemlength = 1; /* Default length of last item for repeats */
+ lastitemlength = 1; /* Default length of last item for repeats */
- if (c >= 0) { /* Data character */
- length += 2; /* For a one-byte character */
+ if (c >= 0) { /* Data character */
+ length += 2; /* For a one-byte character */
- continue;
+ continue;
}
/* If \Q, enter "literal" mode */
if (-c == ESC_Q) {
- inescq = TRUE;
- continue;
+ inescq = TRUE;
+ continue;
}
/* \X is supported only if Unicode property support is compiled */
#ifndef SUPPORT_UCP
if (-c == ESC_X) {
- errorcode = ERR45;
- goto PCRE_ERROR_RETURN;
+ errorcode = ERR45;
+ goto PCRE_ERROR_RETURN;
}
#endif
else if (-c == ESC_P || -c == ESC_p) {
#ifdef SUPPORT_UCP
- BOOL negated;
- length += 2;
- lastitemlength = 2;
- if (get_ucp(&ptr, &negated, &errorcode) < 0)
- goto PCRE_ERROR_RETURN;
- continue;
+ BOOL negated;
+ length += 2;
+ lastitemlength = 2;
+ if (get_ucp(&ptr, &negated, &errorcode) < 0)
+ goto PCRE_ERROR_RETURN;
+ continue;
#else
- errorcode = ERR45;
- goto PCRE_ERROR_RETURN;
+ errorcode = ERR45;
+ goto PCRE_ERROR_RETURN;
#endif
}
back reference. */
if (c <= -ESC_REF) {
- int refnum = -c - ESC_REF;
- compile_block.backref_map |= (refnum < 32) ? (1 << refnum) : 1;
- if (refnum > compile_block.top_backref)
- compile_block.top_backref = refnum;
- length += 2; /* For single back reference */
- if (ptr[1] == '{' && is_counted_repeat(ptr + 2)) {
- ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
- if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
- if ((min == 0 && (max == 1 || max == -1)) || (min == 1 && max == -1))
- length++;
- else
- length += 5;
- if (ptr[1] == '?')
- ptr++;
- }
+ int refnum = -c - ESC_REF;
+ compile_block.backref_map |= (refnum < 32) ? (1 << refnum) : 1;
+ if (refnum > compile_block.top_backref)
+ compile_block.top_backref = refnum;
+ length += 2; /* For single back reference */
+ if (ptr[1] == '{' && is_counted_repeat(ptr + 2)) {
+ ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
+ if (errorcode != 0)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) || (min == 1 && max == -1))
+ length++;
+ else
+ length += 5;
+ if (ptr[1] == '?')
+ ptr++;
+ }
}
continue;
- case '^': /* Single-byte metacharacters */
+ case '^': /* Single-byte metacharacters */
case '.':
case '$':
length++;
lastitemlength = 1;
continue;
- case '*': /* These repeats won't be after brackets; */
- case '+': /* those are handled separately */
+ case '*': /* These repeats won't be after brackets; */
+ case '+': /* those are handled separately */
case '?':
length++;
- goto POSESSIVE; /* A few lines below */
+ goto POSESSIVE; /* A few lines below */
/* This covers the cases of braced repeats after a single char, metachar,
class, or back reference. */
case '{':
if (!is_counted_repeat(ptr + 1))
- goto NORMAL_CHAR;
+ goto NORMAL_CHAR;
ptr = read_repeat_counts(ptr + 1, &min, &max, &errorcode);
if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
+ goto PCRE_ERROR_RETURN;
/* These special cases just insert one extra opcode */
if ((min == 0 && (max == 1 || max == -1)) || (min == 1 && max == -1))
- length++;
+ length++;
/* These cases might insert additional copies of a preceding character. */
else {
- if (min != 1) {
- length -= lastitemlength; /* Uncount the original char or metachar */
- if (min > 0)
- length += 3 + lastitemlength;
- }
- length += lastitemlength + ((max > 0) ? 3 : 1);
+ if (min != 1) {
+ length -= lastitemlength; /* Uncount the original char or metachar */
+ if (min > 0)
+ length += 3 + lastitemlength;
+ }
+ length += lastitemlength + ((max > 0) ? 3 : 1);
}
if (ptr[1] == '?')
- ptr++; /* Needs no extra length */
+ ptr++; /* Needs no extra length */
- POSESSIVE: /* Test for possessive quantifier */
+ POSESSIVE: /* Test for possessive quantifier */
if (ptr[1] == '+') {
- ptr++;
- length += 2 + 2 * LINK_SIZE; /* Allow for atomic brackets */
+ ptr++;
+ length += 2 + 2 * LINK_SIZE; /* Allow for atomic brackets */
}
continue;
case '[':
if (*(++ptr) == '^') {
- class_optcount = 10; /* Greater than one */
- ptr++;
+ class_optcount = 10; /* Greater than one */
+ ptr++;
} else
- class_optcount = 0;
+ class_optcount = 0;
/* Written as a "do" so that an initial ']' is taken as data */
if (*ptr != 0)
- do {
- /* Inside \Q...\E everything is literal except \E */
-
- if (inescq) {
- if (*ptr != '\\' || ptr[1] != 'E')
- goto GET_ONE_CHARACTER;
- inescq = FALSE;
- ptr += 1;
- continue;
- }
-
- /* Outside \Q...\E, check for escapes */
-
- if (*ptr == '\\') {
- c = check_escape(&ptr, &errorcode, bracount, options, TRUE);
- if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
-
- /* \b is backspace inside a class; \X is literal */
-
- if (-c == ESC_b)
- c = '\b';
- else if (-c == ESC_X)
- c = 'X';
-
- /* \Q enters quoting mode */
-
- else if (-c == ESC_Q) {
- inescq = TRUE;
- continue;
- }
-
- /* Handle escapes that turn into characters */
-
- if (c >= 0)
- goto NON_SPECIAL_CHARACTER;
-
- /* Escapes that are meta-things. The normal ones just affect the
- bit map, but Unicode properties require an XCLASS extended item. */
-
- else {
- class_optcount = 10; /* \d, \s etc; make sure > 1 */
- }
- }
-
- /* Check the syntax for POSIX stuff. The bits we actually handle are
- checked during the real compile phase. */
-
- else if (*ptr == '[' && check_posix_syntax(ptr, &ptr, &compile_block)) {
- ptr++;
- class_optcount = 10; /* Make sure > 1 */
- }
-
- /* Anything else increments the possible optimization count. We have to
- detect ranges here so that we can compute the number of extra ranges for
- caseless wide characters when UCP support is available. If there are wide
- characters, we are going to have to use an XCLASS, even for single
- characters. */
-
- else {
- int d;
-
- GET_ONE_CHARACTER:
-
- c = *ptr;
-
- /* Come here from handling \ above when it escapes to a char value */
-
- NON_SPECIAL_CHARACTER:
- class_optcount++;
-
- d = -1;
- if (ptr[1] == '-') {
- uschar const *hyptr = ptr++;
- if (ptr[1] == '\\') {
- ptr++;
- d = check_escape(&ptr, &errorcode, bracount, options, TRUE);
- if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
- if (-d == ESC_b)
- d = '\b'; /* backspace */
- else if (-d == ESC_X)
- d = 'X'; /* literal X in a class */
- } else if (ptr[1] != 0 && ptr[1] != ']') {
- ptr++;
- d = *ptr;
- }
- if (d < 0)
- ptr = hyptr; /* go back to hyphen as data */
- }
-
- /* If d >= 0 we have a range. In UTF-8 mode, if the end is > 255, or >
- 127 for caseless matching, we will need to use an XCLASS. */
-
- if (d >= 0) {
- class_optcount = 10; /* Ensure > 1 */
- if (d < c) {
- errorcode = ERR8;
- goto PCRE_ERROR_RETURN;
- }
-
-
- }
-
- /* We have a single character. There is nothing to be done unless we
- are in UTF-8 mode. If the char is > 255, or 127 when caseless, we must
- allow for an XCL_SINGLE item, doubled for caselessness if there is UCP
- support. */
-
- else {
- }
- }
- }
- while (*(++ptr) != 0 && (inescq || *ptr != ']')); /* Concludes "do" above */
-
- if (*ptr == 0) { /* Missing terminating ']' */
- errorcode = ERR6;
- goto PCRE_ERROR_RETURN;
+ do {
+ /* Inside \Q...\E everything is literal except \E */
+
+ if (inescq) {
+ if (*ptr != '\\' || ptr[1] != 'E')
+ goto GET_ONE_CHARACTER;
+ inescq = FALSE;
+ ptr += 1;
+ continue;
+ }
+
+ /* Outside \Q...\E, check for escapes */
+
+ if (*ptr == '\\') {
+ c = check_escape(&ptr, &errorcode, bracount, options, TRUE);
+ if (errorcode != 0)
+ goto PCRE_ERROR_RETURN;
+
+ /* \b is backspace inside a class; \X is literal */
+
+ if (-c == ESC_b)
+ c = '\b';
+ else if (-c == ESC_X)
+ c = 'X';
+
+ /* \Q enters quoting mode */
+
+ else if (-c == ESC_Q) {
+ inescq = TRUE;
+ continue;
+ }
+
+ /* Handle escapes that turn into characters */
+
+ if (c >= 0)
+ goto NON_SPECIAL_CHARACTER;
+
+ /* Escapes that are meta-things. The normal ones just affect the
+ bit map, but Unicode properties require an XCLASS extended item. */
+
+ else {
+ class_optcount = 10; /* \d, \s etc; make sure > 1 */
+ }
+ }
+
+ /* Check the syntax for POSIX stuff. The bits we actually handle are
+ checked during the real compile phase. */
+
+ else if (*ptr == '[' && check_posix_syntax(ptr, &ptr, &compile_block)) {
+ ptr++;
+ class_optcount = 10; /* Make sure > 1 */
+ }
+
+ /* Anything else increments the possible optimization count. We have to
+ detect ranges here so that we can compute the number of extra ranges for
+ caseless wide characters when UCP support is available. If there are wide
+ characters, we are going to have to use an XCLASS, even for single
+ characters. */
+
+ else {
+ int d;
+
+ GET_ONE_CHARACTER:
+
+ c = *ptr;
+
+ /* Come here from handling \ above when it escapes to a char value */
+
+ NON_SPECIAL_CHARACTER:
+ class_optcount++;
+
+ d = -1;
+ if (ptr[1] == '-') {
+ uschar const *hyptr = ptr++;
+ if (ptr[1] == '\\') {
+ ptr++;
+ d = check_escape(&ptr, &errorcode, bracount, options, TRUE);
+ if (errorcode != 0)
+ goto PCRE_ERROR_RETURN;
+ if (-d == ESC_b)
+ d = '\b'; /* backspace */
+ else if (-d == ESC_X)
+ d = 'X'; /* literal X in a class */
+ } else if (ptr[1] != 0 && ptr[1] != ']') {
+ ptr++;
+ d = *ptr;
+ }
+ if (d < 0)
+ ptr = hyptr; /* go back to hyphen as data */
+ }
+
+ /* If d >= 0 we have a range. In UTF-8 mode, if the end is > 255, or >
+ 127 for caseless matching, we will need to use an XCLASS. */
+
+ if (d >= 0) {
+ class_optcount = 10; /* Ensure > 1 */
+ if (d < c) {
+ errorcode = ERR8;
+ goto PCRE_ERROR_RETURN;
+ }
+
+
+ }
+
+ /* We have a single character. There is nothing to be done unless we
+ are in UTF-8 mode. If the char is > 255, or 127 when caseless, we must
+ allow for an XCL_SINGLE item, doubled for caselessness if there is UCP
+ support. */
+
+ else {
+ }
+ }
+ }
+ while (*(++ptr) != 0 && (inescq || *ptr != ']')); /* Concludes "do" above */
+
+ if (*ptr == 0) { /* Missing terminating ']' */
+ errorcode = ERR6;
+ goto PCRE_ERROR_RETURN;
}
/* We can optimize when there was only one optimizable character. Repeats
code. Here, we handle repeats for the class opcodes. */
if (class_optcount == 1)
- length += 3;
+ length += 3;
else {
- length += 33;
-
- /* A repeat needs either 1 or 5 bytes. If it is a possessive quantifier,
- we also need extra for wrapping the whole thing in a sub-pattern. */
-
- if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr + 2)) {
- ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
- if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
- if ((min == 0 && (max == 1 || max == -1)) || (min == 1 && max == -1))
- length++;
- else
- length += 5;
- if (ptr[1] == '+') {
- ptr++;
- length += 2 + 2 * LINK_SIZE;
- } else if (ptr[1] == '?')
- ptr++;
- }
+ length += 33;
+
+ /* A repeat needs either 1 or 5 bytes. If it is a possessive quantifier,
+ we also need extra for wrapping the whole thing in a sub-pattern. */
+
+ if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr + 2)) {
+ ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
+ if (errorcode != 0)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) || (min == 1 && max == -1))
+ length++;
+ else
+ length += 5;
+ if (ptr[1] == '+') {
+ ptr++;
+ length += 2 + 2 * LINK_SIZE;
+ } else if (ptr[1] == '?')
+ ptr++;
+ }
}
continue;
/* Handle special forms of bracket, which all start (? */
if (ptr[1] == '?') {
- int set, unset;
- int *optset;
-
- switch (c = ptr[2]) {
- /* Skip over comments entirely */
- case '#':
- ptr += 3;
- while (*ptr != 0 && *ptr != ')')
- ptr++;
- if (*ptr == 0) {
- errorcode = ERR18;
- goto PCRE_ERROR_RETURN;
- }
- continue;
-
- /* Non-referencing groups and lookaheads just move the pointer on, and
- then behave like a non-special bracket, except that they don't increment
- the count of extracting brackets. Ditto for the "once only" bracket,
- which is in Perl from version 5.005. */
-
- case ':':
- case '=':
- case '!':
- case '>':
- ptr += 2;
- break;
-
- /* (?R) specifies a recursive call to the regex, which is an extension
- to provide the facility which can be obtained by (?p{perl-code}) in
- Perl 5.6. In Perl 5.8 this has become (??{perl-code}).
-
- From PCRE 4.00, items such as (?3) specify subroutine-like "calls" to
- the appropriate numbered brackets. This includes both recursive and
- non-recursive calls. (?R) is now synonymous with (?0). */
-
- case 'R':
- ptr++;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- ptr += 2;
- if (c != 'R')
- while ((digitab[*(++ptr)] & ctype_digit) != 0) ;
- if (*ptr != ')') {
- errorcode = ERR29;
- goto PCRE_ERROR_RETURN;
- }
- length += 1 + LINK_SIZE;
-
- /* If this item is quantified, it will get wrapped inside brackets so
- as to use the code for quantified brackets. We jump down and use the
- code that handles this for real brackets. */
-
- if (ptr[1] == '+' || ptr[1] == '*' || ptr[1] == '?' || ptr[1] == '{') {
- length += 2 + 2 * LINK_SIZE; /* to make bracketed */
- duplength = 5 + 3 * LINK_SIZE;
- goto HANDLE_QUANTIFIED_BRACKETS;
- }
- continue;
-
- /* (?C) is an extension which provides "callout" - to provide a bit of
- the functionality of the Perl (?{...}) feature. An optional number may
- follow (default is zero). */
-
- case 'C':
- ptr += 2;
- while ((digitab[*(++ptr)] & ctype_digit) != 0) ;
- if (*ptr != ')') {
- errorcode = ERR39;
- goto PCRE_ERROR_RETURN;
- }
- length += 2 + 2 * LINK_SIZE;
- continue;
-
- /* Named subpatterns are an extension copied from Python */
-
- case 'P':
- ptr += 3;
-
- /* Handle the definition of a named subpattern */
-
- if (*ptr == '<') {
- const uschar *p; /* Don't amalgamate; some compilers */
- p = ++ptr; /* grumble at autoincrement in declaration */
- while ((compile_block.ctypes[*ptr] & ctype_word) != 0)
- ptr++;
- if (*ptr != '>') {
- errorcode = ERR42;
- goto PCRE_ERROR_RETURN;
- }
- name_count++;
- if (ptr - p > max_name_size)
- max_name_size = (ptr - p);
- capturing = TRUE; /* Named parentheses are always capturing */
- break;
- }
-
- /* Handle back references and recursive calls to named subpatterns */
-
- if (*ptr == '=' || *ptr == '>') {
- while ((compile_block.ctypes[*(++ptr)] & ctype_word) != 0) ;
- if (*ptr != ')') {
- errorcode = ERR42;
- goto PCRE_ERROR_RETURN;
- }
- break;
- }
-
- /* Unknown character after (?P */
-
- errorcode = ERR41;
- goto PCRE_ERROR_RETURN;
-
- /* Lookbehinds are in Perl from version 5.005 */
-
- case '<':
- ptr += 3;
- if (*ptr == '=' || *ptr == '!') {
- branch_newextra = 1 + LINK_SIZE;
- length += 1 + LINK_SIZE; /* For the first branch */
- break;
- }
- errorcode = ERR24;
- goto PCRE_ERROR_RETURN;
-
- /* Conditionals are in Perl from version 5.005. The bracket must either
- be followed by a number (for bracket reference) or by an assertion
- group, or (a PCRE extension) by 'R' for a recursion test. */
-
- case '(':
- if (ptr[3] == 'R' && ptr[4] == ')') {
- ptr += 4;
- length += 3;
- } else if ((digitab[ptr[3]] & ctype_digit) != 0) {
- ptr += 4;
- length += 3;
- while ((digitab[*ptr] & ctype_digit) != 0)
- ptr++;
- if (*ptr != ')') {
- errorcode = ERR26;
- goto PCRE_ERROR_RETURN;
- }
- } else { /* An assertion must follow */
-
- ptr++; /* Can treat like ':' as far as spacing is concerned */
- if (ptr[2] != '?' ||
- (ptr[3] != '=' && ptr[3] != '!' && ptr[3] != '<')) {
- ptr += 2; /* To get right offset in message */
- errorcode = ERR28;
- goto PCRE_ERROR_RETURN;
- }
- }
- break;
-
- /* Else loop checking valid options until ) is met. Anything else is an
- error. If we are without any brackets, i.e. at top level, the settings
- act as if specified in the options, so massage the options immediately.
- This is for backward compatibility with Perl 5.004. */
-
- default:
- set = unset = 0;
- optset = &set;
- ptr += 2;
-
- for (;; ptr++) {
- c = *ptr;
- switch (c) {
- case 'i':
- *optset |= PCRE_CASELESS;
- continue;
-
- case 'm':
- *optset |= PCRE_MULTILINE;
- continue;
-
- case 's':
- *optset |= PCRE_DOTALL;
- continue;
-
- case 'x':
- *optset |= PCRE_EXTENDED;
- continue;
-
- case 'X':
- *optset |= PCRE_EXTRA;
- continue;
-
- case 'U':
- *optset |= PCRE_UNGREEDY;
- continue;
-
- case '-':
- optset = &unset;
- continue;
-
- /* A termination by ')' indicates an options-setting-only item; if
- this is at the very start of the pattern (indicated by item_count
- being zero), we use it to set the global options. This is helpful
- when analyzing the pattern for first characters, etc. Otherwise
- nothing is done here and it is handled during the compiling
- process.
-
- We allow for more than one options setting at the start. If such
- settings do not change the existing options, nothing is compiled.
- However, we must leave space just in case something is compiled.
- This can happen for pathological sequences such as (?i)(?-i)
- because the global options will end up with -i set. The space is
- small and not significant. (Before I did this there was a reported
- bug with (?i)(?-i) in a machine-generated pattern.)
-
- [Historical note: Up to Perl 5.8, options settings at top level
- were always global settings, wherever they appeared in the pattern.
- That is, they were equivalent to an external setting. From 5.8
- onwards, they apply only to what follows (which is what you might
- expect).] */
-
- case ')':
- if (item_count == 0) {
- options = (options | set) & (~unset);
- set = unset = 0; /* To save length */
- item_count--; /* To allow for several */
- length += 2;
- }
-
- /* Fall through */
-
- /* A termination by ':' indicates the start of a nested group with
- the given options set. This is again handled at compile time, but
- we must allow for compiled space if any of the ims options are
- set. We also have to allow for resetting space at the end of
- the group, which is why 4 is added to the length and not just 2.
- If there are several changes of options within the same group, this
- will lead to an over-estimate on the length, but this shouldn't
- matter very much. We also have to allow for resetting options at
- the start of any alternations, which we do by setting
- branch_newextra to 2. Finally, we record whether the case-dependent
- flag ever changes within the regex. This is used by the "required
- character" code. */
-
- case ':':
- if (((set | unset) & PCRE_IMS) != 0) {
- length += 4;
- branch_newextra = 2;
- if (((set | unset) & PCRE_CASELESS) != 0)
- options |= PCRE_ICHANGED;
- }
- goto END_OPTIONS;
-
- /* Unrecognized option character */
-
- default:
- errorcode = ERR12;
- goto PCRE_ERROR_RETURN;
- }
- }
-
- /* If we hit a closing bracket, that's it - this is a freestanding
- option-setting. We need to ensure that branch_extra is updated if
- necessary. The only values branch_newextra can have here are 0 or 2.
- If the value is 2, then branch_extra must either be 2 or 5, depending
- on whether this is a lookbehind group or not. */
-
- END_OPTIONS:
- if (c == ')') {
- if (branch_newextra == 2 &&
- (branch_extra == 0 || branch_extra == 1 + LINK_SIZE))
- branch_extra += branch_newextra;
- continue;
- }
-
- /* If options were terminated by ':' control comes here. This is a
- non-capturing group with an options change. There is nothing more that
- needs to be done because "capturing" is already set FALSE by default;
- we can just fall through. */
-
- }
+ int set, unset;
+ int *optset;
+
+ switch (c = ptr[2]) {
+ /* Skip over comments entirely */
+ case '#':
+ ptr += 3;
+ while (*ptr != 0 && *ptr != ')')
+ ptr++;
+ if (*ptr == 0) {
+ errorcode = ERR18;
+ goto PCRE_ERROR_RETURN;
+ }
+ continue;
+
+ /* Non-referencing groups and lookaheads just move the pointer on, and
+ then behave like a non-special bracket, except that they don't increment
+ the count of extracting brackets. Ditto for the "once only" bracket,
+ which is in Perl from version 5.005. */
+
+ case ':':
+ case '=':
+ case '!':
+ case '>':
+ ptr += 2;
+ break;
+
+ /* (?R) specifies a recursive call to the regex, which is an extension
+ to provide the facility which can be obtained by (?p{perl-code}) in
+ Perl 5.6. In Perl 5.8 this has become (??{perl-code}).
+
+ From PCRE 4.00, items such as (?3) specify subroutine-like "calls" to
+ the appropriate numbered brackets. This includes both recursive and
+ non-recursive calls. (?R) is now synonymous with (?0). */
+
+ case 'R':
+ ptr++;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ ptr += 2;
+ if (c != 'R')
+ while ((digitab[*(++ptr)] & ctype_digit) != 0) ;
+ if (*ptr != ')') {
+ errorcode = ERR29;
+ goto PCRE_ERROR_RETURN;
+ }
+ length += 1 + LINK_SIZE;
+
+ /* If this item is quantified, it will get wrapped inside brackets so
+ as to use the code for quantified brackets. We jump down and use the
+ code that handles this for real brackets. */
+
+ if (ptr[1] == '+' || ptr[1] == '*' || ptr[1] == '?' || ptr[1] == '{') {
+ length += 2 + 2 * LINK_SIZE; /* to make bracketed */
+ duplength = 5 + 3 * LINK_SIZE;
+ goto HANDLE_QUANTIFIED_BRACKETS;
+ }
+ continue;
+
+ /* (?C) is an extension which provides "callout" - to provide a bit of
+ the functionality of the Perl (?{...}) feature. An optional number may
+ follow (default is zero). */
+
+ case 'C':
+ ptr += 2;
+ while ((digitab[*(++ptr)] & ctype_digit) != 0) ;
+ if (*ptr != ')') {
+ errorcode = ERR39;
+ goto PCRE_ERROR_RETURN;
+ }
+ length += 2 + 2 * LINK_SIZE;
+ continue;
+
+ /* Named subpatterns are an extension copied from Python */
+
+ case 'P':
+ ptr += 3;
+
+ /* Handle the definition of a named subpattern */
+
+ if (*ptr == '<') {
+ const uschar *p; /* Don't amalgamate; some compilers */
+ p = ++ptr; /* grumble at autoincrement in declaration */
+ while ((compile_block.ctypes[*ptr] & ctype_word) != 0)
+ ptr++;
+ if (*ptr != '>') {
+ errorcode = ERR42;
+ goto PCRE_ERROR_RETURN;
+ }
+ name_count++;
+ if (ptr - p > max_name_size)
+ max_name_size = (ptr - p);
+ capturing = TRUE; /* Named parentheses are always capturing */
+ break;
+ }
+
+ /* Handle back references and recursive calls to named subpatterns */
+
+ if (*ptr == '=' || *ptr == '>') {
+ while ((compile_block.ctypes[*(++ptr)] & ctype_word) != 0) ;
+ if (*ptr != ')') {
+ errorcode = ERR42;
+ goto PCRE_ERROR_RETURN;
+ }
+ break;
+ }
+
+ /* Unknown character after (?P */
+
+ errorcode = ERR41;
+ goto PCRE_ERROR_RETURN;
+
+ /* Lookbehinds are in Perl from version 5.005 */
+
+ case '<':
+ ptr += 3;
+ if (*ptr == '=' || *ptr == '!') {
+ branch_newextra = 1 + LINK_SIZE;
+ length += 1 + LINK_SIZE; /* For the first branch */
+ break;
+ }
+ errorcode = ERR24;
+ goto PCRE_ERROR_RETURN;
+
+ /* Conditionals are in Perl from version 5.005. The bracket must either
+ be followed by a number (for bracket reference) or by an assertion
+ group, or (a PCRE extension) by 'R' for a recursion test. */
+
+ case '(':
+ if (ptr[3] == 'R' && ptr[4] == ')') {
+ ptr += 4;
+ length += 3;
+ } else if ((digitab[ptr[3]] & ctype_digit) != 0) {
+ ptr += 4;
+ length += 3;
+ while ((digitab[*ptr] & ctype_digit) != 0)
+ ptr++;
+ if (*ptr != ')') {
+ errorcode = ERR26;
+ goto PCRE_ERROR_RETURN;
+ }
+ } else { /* An assertion must follow */
+
+ ptr++; /* Can treat like ':' as far as spacing is concerned */
+ if (ptr[2] != '?' ||
+ (ptr[3] != '=' && ptr[3] != '!' && ptr[3] != '<')) {
+ ptr += 2; /* To get right offset in message */
+ errorcode = ERR28;
+ goto PCRE_ERROR_RETURN;
+ }
+ }
+ break;
+
+ /* Else loop checking valid options until ) is met. Anything else is an
+ error. If we are without any brackets, i.e. at top level, the settings
+ act as if specified in the options, so massage the options immediately.
+ This is for backward compatibility with Perl 5.004. */
+
+ default:
+ set = unset = 0;
+ optset = &set;
+ ptr += 2;
+
+ for (;; ptr++) {
+ c = *ptr;
+ switch (c) {
+ case 'i':
+ *optset |= PCRE_CASELESS;
+ continue;
+
+ case 'm':
+ *optset |= PCRE_MULTILINE;
+ continue;
+
+ case 's':
+ *optset |= PCRE_DOTALL;
+ continue;
+
+ case 'x':
+ *optset |= PCRE_EXTENDED;
+ continue;
+
+ case 'X':
+ *optset |= PCRE_EXTRA;
+ continue;
+
+ case 'U':
+ *optset |= PCRE_UNGREEDY;
+ continue;
+
+ case '-':
+ optset = &unset;
+ continue;
+
+ /* A termination by ')' indicates an options-setting-only item; if
+ this is at the very start of the pattern (indicated by item_count
+ being zero), we use it to set the global options. This is helpful
+ when analyzing the pattern for first characters, etc. Otherwise
+ nothing is done here and it is handled during the compiling
+ process.
+
+ We allow for more than one options setting at the start. If such
+ settings do not change the existing options, nothing is compiled.
+ However, we must leave space just in case something is compiled.
+ This can happen for pathological sequences such as (?i)(?-i)
+ because the global options will end up with -i set. The space is
+ small and not significant. (Before I did this there was a reported
+ bug with (?i)(?-i) in a machine-generated pattern.)
+
+ [Historical note: Up to Perl 5.8, options settings at top level
+ were always global settings, wherever they appeared in the pattern.
+ That is, they were equivalent to an external setting. From 5.8
+ onwards, they apply only to what follows (which is what you might
+ expect).] */
+
+ case ')':
+ if (item_count == 0) {
+ options = (options | set) & (~unset);
+ set = unset = 0; /* To save length */
+ item_count--; /* To allow for several */
+ length += 2;
+ }
+
+ /* Fall through */
+
+ /* A termination by ':' indicates the start of a nested group with
+ the given options set. This is again handled at compile time, but
+ we must allow for compiled space if any of the ims options are
+ set. We also have to allow for resetting space at the end of
+ the group, which is why 4 is added to the length and not just 2.
+ If there are several changes of options within the same group, this
+ will lead to an over-estimate on the length, but this shouldn't
+ matter very much. We also have to allow for resetting options at
+ the start of any alternations, which we do by setting
+ branch_newextra to 2. Finally, we record whether the case-dependent
+ flag ever changes within the regex. This is used by the "required
+ character" code. */
+
+ case ':':
+ if (((set | unset) & PCRE_IMS) != 0) {
+ length += 4;
+ branch_newextra = 2;
+ if (((set | unset) & PCRE_CASELESS) != 0)
+ options |= PCRE_ICHANGED;
+ }
+ goto END_OPTIONS;
+
+ /* Unrecognized option character */
+
+ default:
+ errorcode = ERR12;
+ goto PCRE_ERROR_RETURN;
+ }
+ }
+
+ /* If we hit a closing bracket, that's it - this is a freestanding
+ option-setting. We need to ensure that branch_extra is updated if
+ necessary. The only values branch_newextra can have here are 0 or 2.
+ If the value is 2, then branch_extra must either be 2 or 5, depending
+ on whether this is a lookbehind group or not. */
+
+ END_OPTIONS:
+ if (c == ')') {
+ if (branch_newextra == 2 &&
+ (branch_extra == 0 || branch_extra == 1 + LINK_SIZE))
+ branch_extra += branch_newextra;
+ continue;
+ }
+
+ /* If options were terminated by ':' control comes here. This is a
+ non-capturing group with an options change. There is nothing more that
+ needs to be done because "capturing" is already set FALSE by default;
+ we can just fall through. */
+
+ }
}
/* Ordinary parentheses, not followed by '?', are capturing unless
PCRE_NO_AUTO_CAPTURE is set. */
else
- capturing = (options & PCRE_NO_AUTO_CAPTURE) == 0;
+ capturing = (options & PCRE_NO_AUTO_CAPTURE) == 0;
/* Capturing brackets must be counted so we can process escapes in a
Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to need
an additional 3 bytes of memory per capturing bracket. */
if (capturing) {
- bracount++;
- if (bracount > EXTRACT_BASIC_MAX)
- bracket_length += 3;
+ bracount++;
+ if (bracount > EXTRACT_BASIC_MAX)
+ bracket_length += 3;
}
/* Save length for computing whole length at end if there's a repeat that
will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */
if (brastackptr >= sizeof(brastack) / sizeof(int)) {
- errorcode = ERR19;
- goto PCRE_ERROR_RETURN;
+ errorcode = ERR19;
+ goto PCRE_ERROR_RETURN;
}
bralenstack[brastackptr] = branch_extra;
case ')':
length += 1 + LINK_SIZE;
if (brastackptr > 0) {
- duplength = length - brastack[--brastackptr];
- branch_extra = bralenstack[brastackptr];
+ duplength = length - brastack[--brastackptr];
+ branch_extra = bralenstack[brastackptr];
} else
- duplength = 0;
+ duplength = 0;
/* The following code is also used when a recursion such as (?3) is
followed by a quantifier, because in that case, it has to be wrapped inside
automatically; for the others we need an increment. */
if ((c = ptr[1]) == '{' && is_counted_repeat(ptr + 2)) {
- ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
- if (errorcode != 0)
- goto PCRE_ERROR_RETURN;
+ ptr = read_repeat_counts(ptr + 2, &min, &max, &errorcode);
+ if (errorcode != 0)
+ goto PCRE_ERROR_RETURN;
} else if (c == '*') {
- min = 0;
- max = -1;
- ptr++;
+ min = 0;
+ max = -1;
+ ptr++;
} else if (c == '+') {
- min = 1;
- max = -1;
- ptr++;
+ min = 1;
+ max = -1;
+ ptr++;
} else if (c == '?') {
- min = 0;
- max = 1;
- ptr++;
+ min = 0;
+ max = 1;
+ ptr++;
} else {
- min = 1;
- max = 1;
+ min = 1;
+ max = 1;
}
/* If the minimum is zero, we have to allow for an OP_BRAZERO before the
bracket set. */
if (min == 0) {
- length++;
- if (max > 0)
- length += (max - 1) * (duplength + 3 + 2 * LINK_SIZE);
+ length++;
+ if (max > 0)
+ length += (max - 1) * (duplength + 3 + 2 * LINK_SIZE);
}
/* When the minimum is greater than zero, we have to replicate up to
but one of the optional copies. */
else {
- length += (min - 1) * duplength;
- if (max > min) /* Need this test as max=-1 means no limit */
- length += (max - min) * (duplength + 3 + 2 * LINK_SIZE)
- - (2 + 2 * LINK_SIZE);
+ length += (min - 1) * duplength;
+ if (max > min) /* Need this test as max=-1 means no limit */
+ length += (max - min) * (duplength + 3 + 2 * LINK_SIZE)
+ - (2 + 2 * LINK_SIZE);
}
/* Allow space for once brackets for "possessive quantifier" */
if (ptr[1] == '+') {
- ptr++;
- length += 2 + 2 * LINK_SIZE;
+ ptr++;
+ length += 2 + 2 * LINK_SIZE;
}
continue;
NORMAL_CHAR:
if (inescq && c == '\\' && ptr[1] == 'E') {
- inescq = FALSE;
- ptr++;
- continue;
+ inescq = FALSE;
+ ptr++;
+ continue;
}
- length += 2; /* For a one-byte character */
- lastitemlength = 1; /* Default length of last item for repeats */
+ length += 2; /* For a one-byte character */
+ lastitemlength = 1; /* Default length of last item for repeats */
/* In UTF-8 mode, check for additional bytes. */
}
}
- length += 2 + LINK_SIZE; /* For final KET and END */
+ length += 2 + LINK_SIZE; /* For final KET and END */
if ((options & PCRE_AUTO_CALLOUT) != 0)
- length += 2 + 2 * LINK_SIZE; /* For final callout */
+ length += 2 + 2 * LINK_SIZE; /* For final callout */
if (length > MAX_PATTERN_SIZE) {
errorcode = ERR20;
*code = OP_BRA;
bracount = 0;
(void) compile_regex(options, options & PCRE_IMS, &bracount, &code, &ptr,
- &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL,
- &compile_block);
+ &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL,
+ &compile_block);
re->top_bracket = bracount;
re->top_backref = compile_block.top_backref;
re->options |= PCRE_ANCHORED;
else {
if (firstbyte < 0)
- firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);
- if (firstbyte >= 0) { /* Remove caseless flag for non-caseable chars */
- int ch = firstbyte & 255;
- re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&
- compile_block.fcc[ch] == ch) ? ch : firstbyte;
- re->options |= PCRE_FIRSTSET;
+ firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);
+ if (firstbyte >= 0) { /* Remove caseless flag for non-caseable chars */
+ int ch = firstbyte & 255;
+ re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&
+ compile_block.fcc[ch] == ch) ? ch : firstbyte;
+ re->options |= PCRE_FIRSTSET;
} else if (is_startline(codestart, 0, compile_block.backref_map))
- re->options |= PCRE_STARTLINE;
+ re->options |= PCRE_STARTLINE;
}
}
((re->options & PCRE_ANCHORED) == 0 || (reqbyte & REQ_VARY) != 0)) {
int ch = reqbyte & 255;
re->req_byte = ((reqbyte & REQ_CASELESS) != 0 &&
- compile_block.fcc[ch] ==
- ch) ? (reqbyte & ~REQ_CASELESS) : reqbyte;
+ compile_block.fcc[ch] ==
+ ch) ? (reqbyte & ~REQ_CASELESS) : reqbyte;
re->options |= PCRE_REQCHSET;
}
/* Flag bits for the match() function */
-#define match_condassert 0x01 /* Called to check a condition assertion */
-#define match_isgroup 0x02 /* Set if start of bracketed group */
+#define match_condassert 0x01 /* Called to check a condition assertion */
+#define match_isgroup 0x02 /* Set if start of bracketed group */
/* Non-error returns from the match() function. Error returns are externally
defined PCRE_ERROR_xxx codes, which are all negative. */
static BOOL
match_ref(int offset, register const uschar * eptr, int length, match_data * md,
- unsigned long int ims)
+ unsigned long int ims)
{
const uschar *p = md->start_subject + md->offset_vector[offset];
if ((ims & PCRE_CASELESS) != 0) {
while (length-- > 0)
if (md->lcc[*p++] != md->lcc[*eptr++])
- return FALSE;
+ return FALSE;
} else {
while (length-- > 0)
if (*p++ != *eptr++)
- return FALSE;
+ return FALSE;
}
return TRUE;
so they can be ordinary variables in all cases. Mark them with "register"
because they are used a lot in loops. */
- register int rrc; /* Returns from recursive calls */
- register int i; /* Used for loops not involving calls to RMATCH() */
- register int c; /* Character values not kept over RMATCH() calls */
- register BOOL utf8; /* Local copy of UTF-8 flag for speed */
+ register int rrc; /* Returns from recursive calls */
+ register int i; /* Used for loops not involving calls to RMATCH() */
+ register int c; /* Character values not kept over RMATCH() calls */
+ register BOOL utf8; /* Local copy of UTF-8 flag for speed */
/* When recursion is not being used, all "local" variables that have to be
preserved over calls to RMATCH() are part of a "frame" which is obtained from
#ifdef NO_RECURSE
heapframe *frame = malloc(sizeof(heapframe));
- frame->Xprevframe = NULL; /* Marks the top level */
+ frame->Xprevframe = NULL; /* Marks the top level */
/* Copy in the original argument variables */
#define fc c
- const uschar *callpat; /* them within each of those blocks. */
- const uschar *data; /* However, in order to accommodate the */
- const uschar *next; /* version of this code that uses an */
- const uschar *pp; /* external "stack" implemented on the */
- const uschar *prev; /* heap, it is easier to declare them */
- const uschar *saved_eptr; /* all here, so the declarations can */
+ const uschar *callpat; /* them within each of those blocks. */
+ const uschar *data; /* However, in order to accommodate the */
+ const uschar *next; /* version of this code that uses an */
+ const uschar *pp; /* external "stack" implemented on the */
+ const uschar *prev; /* heap, it is easier to declare them */
+ const uschar *saved_eptr; /* all here, so the declarations can */
/* be cut out in a block. The only */
- recursion_info new_recursive; /* declarations within blocks below are */
+ recursion_info new_recursive; /* declarations within blocks below are */
/* for variables that do not have to */
- BOOL cur_is_word; /* be preserved over a recursive call */
- BOOL condition; /* to RMATCH(). */
+ BOOL cur_is_word; /* be preserved over a recursive call */
+ BOOL condition; /* to RMATCH(). */
BOOL minimize;
BOOL prev_is_word;
if (md->match_call_count++ >= md->match_limit)
RRETURN(PCRE_ERROR_MATCHLIMIT);
- original_ims = ims; /* Save for resetting on ')' */
- utf8 = md->utf8; /* Local copy of the flag */
+ original_ims = ims; /* Save for resetting on ')' */
+ utf8 = md->utf8; /* Local copy of the flag */
/* At the start of a bracketed group, add the current subject pointer to the
stack of such pointers, to be re-instated at the end of the group when we hit
number from a dummy opcode at the start. */
if (number > EXTRACT_BASIC_MAX)
- number = GET2(ecode, 2 + LINK_SIZE);
+ number = GET2(ecode, 2 + LINK_SIZE);
offset = number << 1;
if (offset < md->offset_max) {
- save_offset1 = md->offset_vector[offset];
- save_offset2 = md->offset_vector[offset + 1];
- save_offset3 = md->offset_vector[md->offset_end - number];
- save_capture_last = md->capture_last;
+ save_offset1 = md->offset_vector[offset];
+ save_offset2 = md->offset_vector[offset + 1];
+ save_offset3 = md->offset_vector[md->offset_end - number];
+ save_capture_last = md->capture_last;
- md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
+ md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
- do {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- md->capture_last = save_capture_last;
- ecode += GET(ecode, 1);
- }
- while (*ecode == OP_ALT);
+ do {
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ md->capture_last = save_capture_last;
+ ecode += GET(ecode, 1);
+ }
+ while (*ecode == OP_ALT);
- md->offset_vector[offset] = save_offset1;
- md->offset_vector[offset + 1] = save_offset2;
- md->offset_vector[md->offset_end - number] = save_offset3;
+ md->offset_vector[offset] = save_offset1;
+ md->offset_vector[offset + 1] = save_offset2;
+ md->offset_vector[md->offset_end - number] = save_offset3;
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
}
/* Insufficient room for saving captured contents */
else
- op = OP_BRA;
+ op = OP_BRA;
}
/* Other types of node can be handled by a switch */
switch (op) {
- case OP_BRA: /* Non-capturing bracket: optimized */
+ case OP_BRA: /* Non-capturing bracket: optimized */
do {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- ecode += GET(ecode, 1);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
RRETURN(MATCH_NOMATCH);
exactly what going to the ket would do. */
case OP_COND:
- if (ecode[LINK_SIZE + 1] == OP_CREF) { /* Condition extract or recurse test */
- offset = GET2(ecode, LINK_SIZE + 2) << 1; /* Doubled ref number */
- condition = (offset == CREF_RECURSE * 2) ?
- (md->recursive != NULL) :
- (offset < offset_top && md->offset_vector[offset] >= 0);
- RMATCH(rrc, eptr, ecode + (condition ?
- (LINK_SIZE + 4) : (LINK_SIZE + 1 +
- GET(ecode, 1))),
- offset_top, md, ims, eptrb, match_isgroup);
- RRETURN(rrc);
+ if (ecode[LINK_SIZE + 1] == OP_CREF) { /* Condition extract or recurse test */
+ offset = GET2(ecode, LINK_SIZE + 2) << 1; /* Doubled ref number */
+ condition = (offset == CREF_RECURSE * 2) ?
+ (md->recursive != NULL) :
+ (offset < offset_top && md->offset_vector[offset] >= 0);
+ RMATCH(rrc, eptr, ecode + (condition ?
+ (LINK_SIZE + 4) : (LINK_SIZE + 1 +
+ GET(ecode, 1))),
+ offset_top, md, ims, eptrb, match_isgroup);
+ RRETURN(rrc);
}
/* The condition is an assertion. Call match() to evaluate it - setting
the final argument TRUE causes it to stop at the end of an assertion. */
else {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
- match_condassert | match_isgroup);
- if (rrc == MATCH_MATCH) {
- ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
- while (*ecode == OP_ALT)
- ecode += GET(ecode, 1);
- } else if (rrc != MATCH_NOMATCH) {
- RRETURN(rrc); /* Need braces because of following else */
- } else
- ecode += GET(ecode, 1);
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- match_isgroup);
- RRETURN(rrc);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_condassert | match_isgroup);
+ if (rrc == MATCH_MATCH) {
+ ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
+ while (*ecode == OP_ALT)
+ ecode += GET(ecode, 1);
+ } else if (rrc != MATCH_NOMATCH) {
+ RRETURN(rrc); /* Need braces because of following else */
+ } else
+ ecode += GET(ecode, 1);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup);
+ RRETURN(rrc);
}
/* Control never reaches here */
case OP_END:
if (md->recursive != NULL && md->recursive->group_num == 0) {
- recursion_info *rec = md->recursive;
- md->recursive = rec->prevrec;
- memmove(md->offset_vector, rec->offset_save,
- rec->saved_max * sizeof(int));
- md->start_match = rec->save_start;
- ims = original_ims;
- ecode = rec->after_call;
- break;
+ recursion_info *rec = md->recursive;
+ md->recursive = rec->prevrec;
+ memmove(md->offset_vector, rec->offset_save,
+ rec->saved_max * sizeof(int));
+ md->start_match = rec->save_start;
+ ims = original_ims;
+ ecode = rec->after_call;
+ break;
}
/* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
string - backtracking will then try other alternatives, if any. */
if (md->notempty && eptr == md->start_match)
- RRETURN(MATCH_NOMATCH);
- md->end_match_ptr = eptr; /* Record where we ended */
- md->end_offset_top = offset_top; /* and how many extracts were taken */
+ RRETURN(MATCH_NOMATCH);
+ md->end_match_ptr = eptr; /* Record where we ended */
+ md->end_offset_top = offset_top; /* and how many extracts were taken */
RRETURN(MATCH_MATCH);
/* Change option settings */
case OP_ASSERT:
case OP_ASSERTBACK:
do {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
- match_isgroup);
- if (rrc == MATCH_MATCH)
- break;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- ecode += GET(ecode, 1);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_isgroup);
+ if (rrc == MATCH_MATCH)
+ break;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
if (*ecode == OP_KET)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
/* If checking an assertion for a condition, return MATCH_MATCH. */
if ((flags & match_condassert) != 0)
- RRETURN(MATCH_MATCH);
+ RRETURN(MATCH_MATCH);
/* Continue from after the assertion, updating the offsets high water
mark, since extracts may have been taken during the assertion. */
do
- ecode += GET(ecode, 1);
+ ecode += GET(ecode, 1);
while (*ecode == OP_ALT);
ecode += 1 + LINK_SIZE;
offset_top = md->end_offset_top;
case OP_ASSERT_NOT:
case OP_ASSERTBACK_NOT:
do {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
- match_isgroup);
- if (rrc == MATCH_MATCH)
- RRETURN(MATCH_NOMATCH);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- ecode += GET(ecode, 1);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_isgroup);
+ if (rrc == MATCH_MATCH)
+ RRETURN(MATCH_NOMATCH);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
if ((flags & match_condassert) != 0)
- RRETURN(MATCH_MATCH);
+ RRETURN(MATCH_MATCH);
ecode += 1 + LINK_SIZE;
continue;
/* No UTF-8 support, or not in UTF-8 mode: count is byte count */
{
- eptr -= GET(ecode, 1);
- if (eptr < md->start_subject)
- RRETURN(MATCH_NOMATCH);
+ eptr -= GET(ecode, 1);
+ if (eptr < md->start_subject)
+ RRETURN(MATCH_NOMATCH);
}
/* Skip to next op code */
case OP_CALLOUT:
if (pcre_callout != NULL) {
- pcre_callout_block cb;
- cb.version = 1; /* Version 1 of the callout block */
- cb.callout_number = ecode[1];
- cb.offset_vector = md->offset_vector;
- cb.subject = (const char *) md->start_subject;
- cb.subject_length = md->end_subject - md->start_subject;
- cb.start_match = md->start_match - md->start_subject;
- cb.current_position = eptr - md->start_subject;
- cb.pattern_position = GET(ecode, 2);
- cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
- cb.capture_top = offset_top / 2;
- cb.capture_last = md->capture_last;
- cb.callout_data = md->callout_data;
- if ((rrc = (*pcre_callout) (&cb)) > 0)
- RRETURN(MATCH_NOMATCH);
- if (rrc < 0)
- RRETURN(rrc);
+ pcre_callout_block cb;
+ cb.version = 1; /* Version 1 of the callout block */
+ cb.callout_number = ecode[1];
+ cb.offset_vector = md->offset_vector;
+ cb.subject = (const char *) md->start_subject;
+ cb.subject_length = md->end_subject - md->start_subject;
+ cb.start_match = md->start_match - md->start_subject;
+ cb.current_position = eptr - md->start_subject;
+ cb.pattern_position = GET(ecode, 2);
+ cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
+ cb.capture_top = offset_top / 2;
+ cb.capture_last = md->capture_last;
+ cb.callout_data = md->callout_data;
+ if ((rrc = (*pcre_callout) (&cb)) > 0)
+ RRETURN(MATCH_NOMATCH);
+ if (rrc < 0)
+ RRETURN(rrc);
}
ecode += 2 + 2 * LINK_SIZE;
break;
case OP_RECURSE:
{
- callpat = md->start_code + GET(ecode, 1);
- new_recursive.group_num = *callpat - OP_BRA;
-
- /* For extended extraction brackets (large number), we have to fish out
- the number from a dummy opcode at the start. */
-
- if (new_recursive.group_num > EXTRACT_BASIC_MAX)
- new_recursive.group_num = GET2(callpat, 2 + LINK_SIZE);
-
- /* Add to "recursing stack" */
-
- new_recursive.prevrec = md->recursive;
- md->recursive = &new_recursive;
-
- /* Find where to continue from afterwards */
-
- ecode += 1 + LINK_SIZE;
- new_recursive.after_call = ecode;
-
- /* Now save the offset data. */
-
- new_recursive.saved_max = md->offset_end;
- if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
- new_recursive.offset_save = stacksave;
- else {
- new_recursive.offset_save =
- (int *) malloc(new_recursive.saved_max * sizeof(int));
- if (new_recursive.offset_save == NULL)
- RRETURN(PCRE_ERROR_NOMEMORY);
- }
-
- memcpy(new_recursive.offset_save, md->offset_vector,
- new_recursive.saved_max * sizeof(int));
- new_recursive.save_start = md->start_match;
- md->start_match = eptr;
-
- /* OK, now we can do the recursion. For each top-level alternative we
- restore the offset and recursion data. */
-
- do {
- RMATCH(rrc, eptr, callpat + 1 + LINK_SIZE, offset_top, md, ims,
- eptrb, match_isgroup);
- if (rrc == MATCH_MATCH) {
- md->recursive = new_recursive.prevrec;
- if (new_recursive.offset_save != stacksave)
- free(new_recursive.offset_save);
- RRETURN(MATCH_MATCH);
- } else if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
-
- md->recursive = &new_recursive;
- memcpy(md->offset_vector, new_recursive.offset_save,
- new_recursive.saved_max * sizeof(int));
- callpat += GET(callpat, 1);
- }
- while (*callpat == OP_ALT);
-
- md->recursive = new_recursive.prevrec;
- if (new_recursive.offset_save != stacksave)
- free(new_recursive.offset_save);
- RRETURN(MATCH_NOMATCH);
+ callpat = md->start_code + GET(ecode, 1);
+ new_recursive.group_num = *callpat - OP_BRA;
+
+ /* For extended extraction brackets (large number), we have to fish out
+ the number from a dummy opcode at the start. */
+
+ if (new_recursive.group_num > EXTRACT_BASIC_MAX)
+ new_recursive.group_num = GET2(callpat, 2 + LINK_SIZE);
+
+ /* Add to "recursing stack" */
+
+ new_recursive.prevrec = md->recursive;
+ md->recursive = &new_recursive;
+
+ /* Find where to continue from afterwards */
+
+ ecode += 1 + LINK_SIZE;
+ new_recursive.after_call = ecode;
+
+ /* Now save the offset data. */
+
+ new_recursive.saved_max = md->offset_end;
+ if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
+ new_recursive.offset_save = stacksave;
+ else {
+ new_recursive.offset_save =
+ (int *) malloc(new_recursive.saved_max * sizeof(int));
+ if (new_recursive.offset_save == NULL)
+ RRETURN(PCRE_ERROR_NOMEMORY);
+ }
+
+ memcpy(new_recursive.offset_save, md->offset_vector,
+ new_recursive.saved_max * sizeof(int));
+ new_recursive.save_start = md->start_match;
+ md->start_match = eptr;
+
+ /* OK, now we can do the recursion. For each top-level alternative we
+ restore the offset and recursion data. */
+
+ do {
+ RMATCH(rrc, eptr, callpat + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, match_isgroup);
+ if (rrc == MATCH_MATCH) {
+ md->recursive = new_recursive.prevrec;
+ if (new_recursive.offset_save != stacksave)
+ free(new_recursive.offset_save);
+ RRETURN(MATCH_MATCH);
+ } else if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+
+ md->recursive = &new_recursive;
+ memcpy(md->offset_vector, new_recursive.offset_save,
+ new_recursive.saved_max * sizeof(int));
+ callpat += GET(callpat, 1);
+ }
+ while (*callpat == OP_ALT);
+
+ md->recursive = new_recursive.prevrec;
+ if (new_recursive.offset_save != stacksave)
+ free(new_recursive.offset_save);
+ RRETURN(MATCH_NOMATCH);
}
/* Control never reaches here */
case OP_ONCE:
{
- prev = ecode;
- saved_eptr = eptr;
-
- do {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
- eptrb, match_isgroup);
- if (rrc == MATCH_MATCH)
- break;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- ecode += GET(ecode, 1);
- }
- while (*ecode == OP_ALT);
-
- /* If hit the end of the group (which could be repeated), fail */
-
- if (*ecode != OP_ONCE && *ecode != OP_ALT)
- RRETURN(MATCH_NOMATCH);
-
- /* Continue as from after the assertion, updating the offsets high water
- mark, since extracts may have been taken. */
-
- do
- ecode += GET(ecode, 1);
- while (*ecode == OP_ALT);
-
- offset_top = md->end_offset_top;
- eptr = md->end_match_ptr;
-
- /* For a non-repeating ket, just continue at this level. This also
- happens for a repeating ket if no characters were matched in the group.
- This is the forcible breaking of infinite loops as implemented in Perl
- 5.005. If there is an options reset, it will get obeyed in the normal
- course of events. */
-
- if (*ecode == OP_KET || eptr == saved_eptr) {
- ecode += 1 + LINK_SIZE;
- break;
- }
-
- /* The repeating kets try the rest of the pattern or restart from the
- preceding bracket, in the appropriate order. We need to reset any options
- that changed within the bracket before re-running it, so check the next
- opcode. */
-
- if (ecode[1 + LINK_SIZE] == OP_OPT) {
- ims = (ims & ~PCRE_IMS) | ecode[4];
- }
-
- if (*ecode == OP_KETRMIN) {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- } else { /* OP_KETRMAX */
-
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
+ prev = ecode;
+ saved_eptr = eptr;
+
+ do {
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, match_isgroup);
+ if (rrc == MATCH_MATCH)
+ break;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ ecode += GET(ecode, 1);
+ }
+ while (*ecode == OP_ALT);
+
+ /* If hit the end of the group (which could be repeated), fail */
+
+ if (*ecode != OP_ONCE && *ecode != OP_ALT)
+ RRETURN(MATCH_NOMATCH);
+
+ /* Continue as from after the assertion, updating the offsets high water
+ mark, since extracts may have been taken. */
+
+ do
+ ecode += GET(ecode, 1);
+ while (*ecode == OP_ALT);
+
+ offset_top = md->end_offset_top;
+ eptr = md->end_match_ptr;
+
+ /* For a non-repeating ket, just continue at this level. This also
+ happens for a repeating ket if no characters were matched in the group.
+ This is the forcible breaking of infinite loops as implemented in Perl
+ 5.005. If there is an options reset, it will get obeyed in the normal
+ course of events. */
+
+ if (*ecode == OP_KET || eptr == saved_eptr) {
+ ecode += 1 + LINK_SIZE;
+ break;
+ }
+
+ /* The repeating kets try the rest of the pattern or restart from the
+ preceding bracket, in the appropriate order. We need to reset any options
+ that changed within the bracket before re-running it, so check the next
+ opcode. */
+
+ if (ecode[1 + LINK_SIZE] == OP_OPT) {
+ ims = (ims & ~PCRE_IMS) | ecode[4];
+ }
+
+ if (*ecode == OP_KETRMIN) {
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ } else { /* OP_KETRMAX */
+
+ RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
}
RRETURN(MATCH_NOMATCH);
case OP_ALT:
do
- ecode += GET(ecode, 1);
+ ecode += GET(ecode, 1);
while (*ecode == OP_ALT);
break;
case OP_BRAZERO:
{
- next = ecode + 1;
- RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- do
- next += GET(next, 1);
- while (*next == OP_ALT);
- ecode = next + 1 + LINK_SIZE;
+ next = ecode + 1;
+ RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ do
+ next += GET(next, 1);
+ while (*next == OP_ALT);
+ ecode = next + 1 + LINK_SIZE;
}
break;
case OP_BRAMINZERO:
{
- next = ecode + 1;
- do
- next += GET(next, 1);
- while (*next == OP_ALT);
- RMATCH(rrc, eptr, next + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- ecode++;
+ next = ecode + 1;
+ do
+ next += GET(next, 1);
+ while (*next == OP_ALT);
+ RMATCH(rrc, eptr, next + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ ecode++;
}
break;
case OP_KETRMIN:
case OP_KETRMAX:
{
- prev = ecode - GET(ecode, 1);
- saved_eptr = eptrb->epb_saved_eptr;
+ prev = ecode - GET(ecode, 1);
+ saved_eptr = eptrb->epb_saved_eptr;
- /* Back up the stack of bracket start pointers. */
+ /* Back up the stack of bracket start pointers. */
- eptrb = eptrb->epb_prev;
+ eptrb = eptrb->epb_prev;
- if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
- *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
- *prev == OP_ONCE) {
- md->end_match_ptr = eptr; /* For ONCE */
- md->end_offset_top = offset_top;
- RRETURN(MATCH_MATCH);
- }
+ if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
+ *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
+ *prev == OP_ONCE) {
+ md->end_match_ptr = eptr; /* For ONCE */
+ md->end_offset_top = offset_top;
+ RRETURN(MATCH_MATCH);
+ }
- /* In all other cases except a conditional group we have to check the
- group number back at the start and if necessary complete handling an
- extraction by setting the offsets and bumping the high water mark. */
+ /* In all other cases except a conditional group we have to check the
+ group number back at the start and if necessary complete handling an
+ extraction by setting the offsets and bumping the high water mark. */
- if (*prev != OP_COND) {
- number = *prev - OP_BRA;
+ if (*prev != OP_COND) {
+ number = *prev - OP_BRA;
- /* For extended extraction brackets (large number), we have to fish out
- the number from a dummy opcode at the start. */
+ /* For extended extraction brackets (large number), we have to fish out
+ the number from a dummy opcode at the start. */
- if (number > EXTRACT_BASIC_MAX)
- number = GET2(prev, 2 + LINK_SIZE);
- offset = number << 1;
+ if (number > EXTRACT_BASIC_MAX)
+ number = GET2(prev, 2 + LINK_SIZE);
+ offset = number << 1;
#ifdef DEBUG
- printf("end bracket %d", number);
- printf("\n");
+ printf("end bracket %d", number);
+ printf("\n");
#endif
- /* Test for a numbered group. This includes groups called as a result
- of recursion. Note that whole-pattern recursion is coded as a recurse
- into group 0, so it won't be picked up here. Instead, we catch it when
- the OP_END is reached. */
-
- if (number > 0) {
- md->capture_last = number;
- if (offset >= md->offset_max)
- md->offset_overflow = TRUE;
- else {
- md->offset_vector[offset] =
- md->offset_vector[md->offset_end - number];
- md->offset_vector[offset + 1] = eptr - md->start_subject;
- if (offset_top <= offset)
- offset_top = offset + 2;
- }
-
- /* Handle a recursively called group. Restore the offsets
- appropriately and continue from after the call. */
-
- if (md->recursive != NULL && md->recursive->group_num == number) {
- recursion_info *rec = md->recursive;
- md->recursive = rec->prevrec;
- md->start_match = rec->save_start;
- memcpy(md->offset_vector, rec->offset_save,
- rec->saved_max * sizeof(int));
- ecode = rec->after_call;
- ims = original_ims;
- break;
- }
- }
- }
-
- /* Reset the value of the ims flags, in case they got changed during
- the group. */
-
- ims = original_ims;
-
- /* For a non-repeating ket, just continue at this level. This also
- happens for a repeating ket if no characters were matched in the group.
- This is the forcible breaking of infinite loops as implemented in Perl
- 5.005. If there is an options reset, it will get obeyed in the normal
- course of events. */
-
- if (*ecode == OP_KET || eptr == saved_eptr) {
- ecode += 1 + LINK_SIZE;
- break;
- }
-
- /* The repeating kets try the rest of the pattern or restart from the
- preceding bracket, in the appropriate order. */
-
- if (*ecode == OP_KETRMIN) {
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- } else { /* OP_KETRMAX */
-
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
- 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
+ /* Test for a numbered group. This includes groups called as a result
+ of recursion. Note that whole-pattern recursion is coded as a recurse
+ into group 0, so it won't be picked up here. Instead, we catch it when
+ the OP_END is reached. */
+
+ if (number > 0) {
+ md->capture_last = number;
+ if (offset >= md->offset_max)
+ md->offset_overflow = TRUE;
+ else {
+ md->offset_vector[offset] =
+ md->offset_vector[md->offset_end - number];
+ md->offset_vector[offset + 1] = eptr - md->start_subject;
+ if (offset_top <= offset)
+ offset_top = offset + 2;
+ }
+
+ /* Handle a recursively called group. Restore the offsets
+ appropriately and continue from after the call. */
+
+ if (md->recursive != NULL && md->recursive->group_num == number) {
+ recursion_info *rec = md->recursive;
+ md->recursive = rec->prevrec;
+ md->start_match = rec->save_start;
+ memcpy(md->offset_vector, rec->offset_save,
+ rec->saved_max * sizeof(int));
+ ecode = rec->after_call;
+ ims = original_ims;
+ break;
+ }
+ }
+ }
+
+ /* Reset the value of the ims flags, in case they got changed during
+ the group. */
+
+ ims = original_ims;
+
+ /* For a non-repeating ket, just continue at this level. This also
+ happens for a repeating ket if no characters were matched in the group.
+ This is the forcible breaking of infinite loops as implemented in Perl
+ 5.005. If there is an options reset, it will get obeyed in the normal
+ course of events. */
+
+ if (*ecode == OP_KET || eptr == saved_eptr) {
+ ecode += 1 + LINK_SIZE;
+ break;
+ }
+
+ /* The repeating kets try the rest of the pattern or restart from the
+ preceding bracket, in the appropriate order. */
+
+ if (*ecode == OP_KETRMIN) {
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ } else { /* OP_KETRMAX */
+
+ RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
}
RRETURN(MATCH_NOMATCH);
case OP_CIRC:
if (md->notbol && eptr == md->start_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
if ((ims & PCRE_MULTILINE) != 0) {
- if (eptr != md->start_subject && eptr[-1] != NEWLINE)
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
+ if (eptr != md->start_subject && eptr[-1] != NEWLINE)
+ RRETURN(MATCH_NOMATCH);
+ ecode++;
+ break;
}
/* ... else fall through */
case OP_SOD:
if (eptr != md->start_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_SOM:
if (eptr != md->start_subject + md->start_offset)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_DOLL:
if ((ims & PCRE_MULTILINE) != 0) {
- if (eptr < md->end_subject) {
- if (*eptr != NEWLINE)
- RRETURN(MATCH_NOMATCH);
- } else {
- if (md->noteol)
- RRETURN(MATCH_NOMATCH);
- }
- ecode++;
- break;
+ if (eptr < md->end_subject) {
+ if (*eptr != NEWLINE)
+ RRETURN(MATCH_NOMATCH);
+ } else {
+ if (md->noteol)
+ RRETURN(MATCH_NOMATCH);
+ }
+ ecode++;
+ break;
} else {
- if (md->noteol)
- RRETURN(MATCH_NOMATCH);
- if (!md->endonly) {
- if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != NEWLINE))
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
- }
+ if (md->noteol)
+ RRETURN(MATCH_NOMATCH);
+ if (!md->endonly) {
+ if (eptr < md->end_subject - 1 ||
+ (eptr == md->end_subject - 1 && *eptr != NEWLINE))
+ RRETURN(MATCH_NOMATCH);
+ ecode++;
+ break;
+ }
}
/* ... else fall through */
case OP_EOD:
if (eptr < md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_EODN:
if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != NEWLINE))
- RRETURN(MATCH_NOMATCH);
+ (eptr == md->end_subject - 1 && *eptr != NEWLINE))
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_WORD_BOUNDARY:
{
- /* Find out if the previous and current characters are "word" characters.
- It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
- be "non-word" characters. */
+ /* Find out if the previous and current characters are "word" characters.
+ It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
+ be "non-word" characters. */
- /* More streamlined when not in UTF-8 mode */
+ /* More streamlined when not in UTF-8 mode */
- {
- prev_is_word = (eptr != md->start_subject) &&
- ((md->ctypes[eptr[-1]] & ctype_word) != 0);
- cur_is_word = (eptr < md->end_subject) &&
- ((md->ctypes[*eptr] & ctype_word) != 0);
- }
+ {
+ prev_is_word = (eptr != md->start_subject) &&
+ ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+ cur_is_word = (eptr < md->end_subject) &&
+ ((md->ctypes[*eptr] & ctype_word) != 0);
+ }
- /* Now see if the situation is what we want */
+ /* Now see if the situation is what we want */
- if ((*ecode++ == OP_WORD_BOUNDARY) ?
- cur_is_word == prev_is_word : cur_is_word != prev_is_word)
- RRETURN(MATCH_NOMATCH);
+ if ((*ecode++ == OP_WORD_BOUNDARY) ?
+ cur_is_word == prev_is_word : cur_is_word != prev_is_word)
+ RRETURN(MATCH_NOMATCH);
}
break;
case OP_ANY:
if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject
- && *eptr == NEWLINE)
- RRETURN(MATCH_NOMATCH);
+ && *eptr == NEWLINE)
+ RRETURN(MATCH_NOMATCH);
if (eptr++ >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_ANYBYTE:
if (eptr++ >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_NOT_DIGIT:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_DIGIT:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_NOT_WHITESPACE:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_WHITESPACE:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_NOT_WORDCHAR:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_WORDCHAR:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
if ((md->ctypes[c] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
break;
case OP_PROP:
case OP_NOTPROP:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
{
- int chartype, rqdtype;
- int othercase;
- int category = _pcre_ucp_findchar(c, &chartype, &othercase);
-
- rqdtype = *(++ecode);
- ecode++;
-
- if (rqdtype >= 128) {
- if ((rqdtype - 128 != category) == (op == OP_PROP))
- RRETURN(MATCH_NOMATCH);
- } else {
- if ((rqdtype != chartype) == (op == OP_PROP))
- RRETURN(MATCH_NOMATCH);
- }
+ int chartype, rqdtype;
+ int othercase;
+ int category = _pcre_ucp_findchar(c, &chartype, &othercase);
+
+ rqdtype = *(++ecode);
+ ecode++;
+
+ if (rqdtype >= 128) {
+ if ((rqdtype - 128 != category) == (op == OP_PROP))
+ RRETURN(MATCH_NOMATCH);
+ } else {
+ if ((rqdtype != chartype) == (op == OP_PROP))
+ RRETURN(MATCH_NOMATCH);
+ }
}
break;
case OP_EXTUNI:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
{
- int chartype;
- int othercase;
- int category = _pcre_ucp_findchar(c, &chartype, &othercase);
- if (category == ucp_M)
- RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject) {
- int len = 1;
- if (!utf8)
- c = *eptr;
- else {
- GETCHARLEN(c, eptr, len);
- }
- category = _pcre_ucp_findchar(c, &chartype, &othercase);
- if (category != ucp_M)
- break;
- eptr += len;
- }
+ int chartype;
+ int othercase;
+ int category = _pcre_ucp_findchar(c, &chartype, &othercase);
+ if (category == ucp_M)
+ RRETURN(MATCH_NOMATCH);
+ while (eptr < md->end_subject) {
+ int len = 1;
+ if (!utf8)
+ c = *eptr;
+ else {
+ GETCHARLEN(c, eptr, len);
+ }
+ category = _pcre_ucp_findchar(c, &chartype, &othercase);
+ if (category != ucp_M)
+ break;
+ eptr += len;
+ }
}
ecode++;
break;
case OP_REF:
{
- offset = GET2(ecode, 1) << 1; /* Doubled ref number */
- ecode += 3; /* Advance past item */
-
- /* If the reference is unset, set the length to be longer than the amount
- of subject left; this ensures that every attempt at a match fails. We
- can't just fail here, because of the possibility of quantifiers with zero
- minima. */
-
- length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
- md->end_subject - eptr + 1 :
- md->offset_vector[offset + 1] - md->offset_vector[offset];
-
- /* Set up for repetition, or handle the non-repeated case */
-
- switch (*ecode) {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- c = *ecode++ - OP_CRSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0)
- max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- min = GET2(ecode, 1);
- max = GET2(ecode, 3);
- if (max == 0)
- max = INT_MAX;
- ecode += 5;
- break;
-
- default: /* No repeat follows */
- if (!match_ref(offset, eptr, length, md, ims))
- RRETURN(MATCH_NOMATCH);
- eptr += length;
- continue; /* With the main loop */
- }
-
- /* If the length of the reference is zero, just continue with the
- main loop. */
-
- if (length == 0)
- continue;
-
- /* First, ensure the minimum number of matches are present. We get back
- the length of the reference string explicitly rather than passing the
- address of eptr, so that eptr can be a register variable. */
-
- for (i = 1; i <= min; i++) {
- if (!match_ref(offset, eptr, length, md, ims))
- RRETURN(MATCH_NOMATCH);
- eptr += length;
- }
-
- /* If min = max, continue at the same level without recursion.
- They are not both allowed to be zero. */
-
- if (min == max)
- continue;
-
- /* If minimizing, keep trying and advancing the pointer */
-
- if (minimize) {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || !match_ref(offset, eptr, length, md, ims))
- RRETURN(MATCH_NOMATCH);
- eptr += length;
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest string and work backwards */
-
- else {
- pp = eptr;
- for (i = min; i < max; i++) {
- if (!match_ref(offset, eptr, length, md, ims))
- break;
- eptr += length;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- eptr -= length;
- }
- RRETURN(MATCH_NOMATCH);
- }
+ offset = GET2(ecode, 1) << 1; /* Doubled ref number */
+ ecode += 3; /* Advance past item */
+
+ /* If the reference is unset, set the length to be longer than the amount
+ of subject left; this ensures that every attempt at a match fails. We
+ can't just fail here, because of the possibility of quantifiers with zero
+ minima. */
+
+ length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
+ md->end_subject - eptr + 1 :
+ md->offset_vector[offset + 1] - md->offset_vector[offset];
+
+ /* Set up for repetition, or handle the non-repeated case */
+
+ switch (*ecode) {
+ case OP_CRSTAR:
+ case OP_CRMINSTAR:
+ case OP_CRPLUS:
+ case OP_CRMINPLUS:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ c = *ecode++ - OP_CRSTAR;
+ minimize = (c & 1) != 0;
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
+ if (max == 0)
+ max = INT_MAX;
+ break;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ minimize = (*ecode == OP_CRMINRANGE);
+ min = GET2(ecode, 1);
+ max = GET2(ecode, 3);
+ if (max == 0)
+ max = INT_MAX;
+ ecode += 5;
+ break;
+
+ default: /* No repeat follows */
+ if (!match_ref(offset, eptr, length, md, ims))
+ RRETURN(MATCH_NOMATCH);
+ eptr += length;
+ continue; /* With the main loop */
+ }
+
+ /* If the length of the reference is zero, just continue with the
+ main loop. */
+
+ if (length == 0)
+ continue;
+
+ /* First, ensure the minimum number of matches are present. We get back
+ the length of the reference string explicitly rather than passing the
+ address of eptr, so that eptr can be a register variable. */
+
+ for (i = 1; i <= min; i++) {
+ if (!match_ref(offset, eptr, length, md, ims))
+ RRETURN(MATCH_NOMATCH);
+ eptr += length;
+ }
+
+ /* If min = max, continue at the same level without recursion.
+ They are not both allowed to be zero. */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, keep trying and advancing the pointer */
+
+ if (minimize) {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || !match_ref(offset, eptr, length, md, ims))
+ RRETURN(MATCH_NOMATCH);
+ eptr += length;
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing, find the longest string and work backwards */
+
+ else {
+ pp = eptr;
+ for (i = min; i < max; i++) {
+ if (!match_ref(offset, eptr, length, md, ims))
+ break;
+ eptr += length;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ eptr -= length;
+ }
+ RRETURN(MATCH_NOMATCH);
+ }
}
/* Control never gets here */
case OP_NCLASS:
case OP_CLASS:
{
- data = ecode + 1; /* Save for matching */
- ecode += 33; /* Advance past the item */
-
- switch (*ecode) {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- c = *ecode++ - OP_CRSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0)
- max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- min = GET2(ecode, 1);
- max = GET2(ecode, 3);
- if (max == 0)
- max = INT_MAX;
- ecode += 5;
- break;
-
- default: /* No repeat follows */
- min = max = 1;
- break;
- }
-
- /* First, ensure the minimum number of matches are present. */
-
- /* Not UTF-8 mode */
- {
- for (i = 1; i <= min; i++) {
- if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
- c = *eptr++;
- if ((data[c / 8] & (1 << (c & 7))) == 0)
- RRETURN(MATCH_NOMATCH);
- }
- }
-
- /* If max == min we can continue with the main loop without the
- need to recurse. */
-
- if (min == max)
- continue;
-
- /* If minimizing, keep testing the rest of the expression and advancing
- the pointer while it matches the class. */
-
- if (minimize) {
- /* Not UTF-8 mode */
- {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
- c = *eptr++;
- if ((data[c / 8] & (1 << (c & 7))) == 0)
- RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest possible run, then work backwards. */
-
- else {
- pp = eptr;
-
- /* Not UTF-8 mode */
- {
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject)
- break;
- c = *eptr;
- if ((data[c / 8] & (1 << (c & 7))) == 0)
- break;
- eptr++;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- eptr--;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
- }
-
- RRETURN(MATCH_NOMATCH);
- }
+ data = ecode + 1; /* Save for matching */
+ ecode += 33; /* Advance past the item */
+
+ switch (*ecode) {
+ case OP_CRSTAR:
+ case OP_CRMINSTAR:
+ case OP_CRPLUS:
+ case OP_CRMINPLUS:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ c = *ecode++ - OP_CRSTAR;
+ minimize = (c & 1) != 0;
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
+ if (max == 0)
+ max = INT_MAX;
+ break;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ minimize = (*ecode == OP_CRMINRANGE);
+ min = GET2(ecode, 1);
+ max = GET2(ecode, 3);
+ if (max == 0)
+ max = INT_MAX;
+ ecode += 5;
+ break;
+
+ default: /* No repeat follows */
+ min = max = 1;
+ break;
+ }
+
+ /* First, ensure the minimum number of matches are present. */
+
+ /* Not UTF-8 mode */
+ {
+ for (i = 1; i <= min; i++) {
+ if (eptr >= md->end_subject)
+ RRETURN(MATCH_NOMATCH);
+ c = *eptr++;
+ if ((data[c / 8] & (1 << (c & 7))) == 0)
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+
+ /* If max == min we can continue with the main loop without the
+ need to recurse. */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, keep testing the rest of the expression and advancing
+ the pointer while it matches the class. */
+
+ if (minimize) {
+ /* Not UTF-8 mode */
+ {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject)
+ RRETURN(MATCH_NOMATCH);
+ c = *eptr++;
+ if ((data[c / 8] & (1 << (c & 7))) == 0)
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing, find the longest possible run, then work backwards. */
+
+ else {
+ pp = eptr;
+
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject)
+ break;
+ c = *eptr;
+ if ((data[c / 8] & (1 << (c & 7))) == 0)
+ break;
+ eptr++;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ eptr--;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
+ }
+
+ RRETURN(MATCH_NOMATCH);
+ }
}
/* Control never gets here */
/* Non-UTF-8 mode */
{
- if (md->end_subject - eptr < 1)
- RRETURN(MATCH_NOMATCH);
- if (ecode[1] != *eptr++)
- RRETURN(MATCH_NOMATCH);
- ecode += 2;
+ if (md->end_subject - eptr < 1)
+ RRETURN(MATCH_NOMATCH);
+ if (ecode[1] != *eptr++)
+ RRETURN(MATCH_NOMATCH);
+ ecode += 2;
}
break;
/* Non-UTF-8 mode */
{
- if (md->end_subject - eptr < 1)
- RRETURN(MATCH_NOMATCH);
- if (md->lcc[ecode[1]] != md->lcc[*eptr++])
- RRETURN(MATCH_NOMATCH);
- ecode += 2;
+ if (md->end_subject - eptr < 1)
+ RRETURN(MATCH_NOMATCH);
+ if (md->lcc[ecode[1]] != md->lcc[*eptr++])
+ RRETURN(MATCH_NOMATCH);
+ ecode += 2;
}
break;
case OP_MINQUERY:
c = *ecode++ - OP_STAR;
minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
if (max == 0)
- max = INT_MAX;
+ max = INT_MAX;
/* Common code for all repeated single-character matches. We can give
up quickly if there are fewer than the minimum number of characters left in
/* When not in UTF-8 mode, load a single-byte character. */
{
- if (min > md->end_subject - eptr)
- RRETURN(MATCH_NOMATCH);
- fc = *ecode++;
+ if (min > md->end_subject - eptr)
+ RRETURN(MATCH_NOMATCH);
+ fc = *ecode++;
}
/* The value of fc at this point is always less than 256, though we may or
if ((ims & PCRE_CASELESS) != 0) {
- fc = md->lcc[fc];
- for (i = 1; i <= min; i++)
- if (fc != md->lcc[*eptr++])
- RRETURN(MATCH_NOMATCH);
- if (min == max)
- continue;
- if (minimize) {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject || fc != md->lcc[*eptr++])
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
- } else {
- pp = eptr;
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject || fc != md->lcc[*eptr])
- break;
- eptr++;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- eptr--;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
+ fc = md->lcc[fc];
+ for (i = 1; i <= min; i++)
+ if (fc != md->lcc[*eptr++])
+ RRETURN(MATCH_NOMATCH);
+ if (min == max)
+ continue;
+ if (minimize) {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject || fc != md->lcc[*eptr++])
+ RRETURN(MATCH_NOMATCH);
+ }
+ /* Control never gets here */
+ } else {
+ pp = eptr;
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject || fc != md->lcc[*eptr])
+ break;
+ eptr++;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ eptr--;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
+ RRETURN(MATCH_NOMATCH);
+ }
+ /* Control never gets here */
}
/* Caseful comparisons (includes all multi-byte characters) */
else {
- for (i = 1; i <= min; i++)
- if (fc != *eptr++)
- RRETURN(MATCH_NOMATCH);
- if (min == max)
- continue;
- if (minimize) {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject || fc != *eptr++)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
- } else {
- pp = eptr;
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject || fc != *eptr)
- break;
- eptr++;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- eptr--;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
- RRETURN(MATCH_NOMATCH);
- }
+ for (i = 1; i <= min; i++)
+ if (fc != *eptr++)
+ RRETURN(MATCH_NOMATCH);
+ if (min == max)
+ continue;
+ if (minimize) {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject || fc != *eptr++)
+ RRETURN(MATCH_NOMATCH);
+ }
+ /* Control never gets here */
+ } else {
+ pp = eptr;
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject || fc != *eptr)
+ break;
+ eptr++;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ eptr--;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
+ RRETURN(MATCH_NOMATCH);
+ }
}
/* Control never gets here */
case OP_NOT:
if (eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
ecode++;
GETCHARINCTEST(c, eptr);
if ((ims & PCRE_CASELESS) != 0) {
- c = md->lcc[c];
- if (md->lcc[*ecode++] == c)
- RRETURN(MATCH_NOMATCH);
+ c = md->lcc[c];
+ if (md->lcc[*ecode++] == c)
+ RRETURN(MATCH_NOMATCH);
} else {
- if (*ecode++ == c)
- RRETURN(MATCH_NOMATCH);
+ if (*ecode++ == c)
+ RRETURN(MATCH_NOMATCH);
}
break;
case OP_NOTMINQUERY:
c = *ecode++ - OP_NOTSTAR;
minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
if (max == 0)
- max = INT_MAX;
+ max = INT_MAX;
/* Common code for all repeated single-byte matches. We can give up quickly
if there are fewer than the minimum number of bytes left in the
REPEATNOTCHAR:
if (min > md->end_subject - eptr)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
fc = *ecode++;
/* The code is duplicated for the caseless and caseful cases, for speed,
characters and work backwards. */
if ((ims & PCRE_CASELESS) != 0) {
- fc = md->lcc[fc];
-
-
- /* Not UTF-8 mode */
- {
- for (i = 1; i <= min; i++)
- if (fc == md->lcc[*eptr++])
- RRETURN(MATCH_NOMATCH);
- }
-
- if (min == max)
- continue;
-
- if (minimize) {
- /* Not UTF-8 mode */
- {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject
- || fc == md->lcc[*eptr++])
- RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- /* Maximize case */
-
- else {
- pp = eptr;
-
- /* Not UTF-8 mode */
- {
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject || fc == md->lcc[*eptr])
- break;
- eptr++;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- eptr--;
- }
- }
-
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
+ fc = md->lcc[fc];
+
+
+ /* Not UTF-8 mode */
+ {
+ for (i = 1; i <= min; i++)
+ if (fc == md->lcc[*eptr++])
+ RRETURN(MATCH_NOMATCH);
+ }
+
+ if (min == max)
+ continue;
+
+ if (minimize) {
+ /* Not UTF-8 mode */
+ {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject
+ || fc == md->lcc[*eptr++])
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ /* Control never gets here */
+ }
+
+ /* Maximize case */
+
+ else {
+ pp = eptr;
+
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject || fc == md->lcc[*eptr])
+ break;
+ eptr++;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ eptr--;
+ }
+ }
+
+ RRETURN(MATCH_NOMATCH);
+ }
+ /* Control never gets here */
}
/* Caseful comparisons */
else {
- /* Not UTF-8 mode */
- {
- for (i = 1; i <= min; i++)
- if (fc == *eptr++)
- RRETURN(MATCH_NOMATCH);
- }
-
- if (min == max)
- continue;
-
- if (minimize) {
- /* Not UTF-8 mode */
- {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject || fc == *eptr++)
- RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- /* Maximize case */
-
- else {
- pp = eptr;
-
- /* Not UTF-8 mode */
- {
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject || fc == *eptr)
- break;
- eptr++;
- }
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- eptr--;
- }
- }
-
- RRETURN(MATCH_NOMATCH);
- }
+ /* Not UTF-8 mode */
+ {
+ for (i = 1; i <= min; i++)
+ if (fc == *eptr++)
+ RRETURN(MATCH_NOMATCH);
+ }
+
+ if (min == max)
+ continue;
+
+ if (minimize) {
+ /* Not UTF-8 mode */
+ {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject || fc == *eptr++)
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ /* Control never gets here */
+ }
+
+ /* Maximize case */
+
+ else {
+ pp = eptr;
+
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject || fc == *eptr)
+ break;
+ eptr++;
+ }
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ eptr--;
+ }
+ }
+
+ RRETURN(MATCH_NOMATCH);
+ }
}
/* Control never gets here */
case OP_TYPEMINQUERY:
c = *ecode++ - OP_TYPESTAR;
minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
if (max == 0)
- max = INT_MAX;
+ max = INT_MAX;
/* Common code for all repeated single character type matches. Note that
in UTF-8 mode, '.' matches a character of any length, but for the other
character types, the valid characters are all one-byte long. */
REPEATTYPE:
- ctype = *ecode++; /* Code for the character type */
+ ctype = *ecode++; /* Code for the character type */
#ifdef SUPPORT_UCP
if (ctype == OP_PROP || ctype == OP_NOTPROP) {
- prop_fail_result = ctype == OP_NOTPROP;
- prop_type = *ecode++;
- if (prop_type >= 128) {
- prop_test_against = prop_type - 128;
- prop_test_variable = &prop_category;
- } else {
- prop_test_against = prop_type;
- prop_test_variable = &prop_chartype;
- }
+ prop_fail_result = ctype == OP_NOTPROP;
+ prop_type = *ecode++;
+ if (prop_type >= 128) {
+ prop_test_against = prop_type - 128;
+ prop_test_variable = &prop_category;
+ } else {
+ prop_test_against = prop_type;
+ prop_test_variable = &prop_chartype;
+ }
} else
- prop_type = -1;
+ prop_type = -1;
#endif
/* First, ensure the minimum number of matches are present. Use inline
and single-bytes. */
if (min > md->end_subject - eptr)
- RRETURN(MATCH_NOMATCH);
+ RRETURN(MATCH_NOMATCH);
if (min > 0) {
#ifdef SUPPORT_UCP
- if (prop_type > 0) {
- for (i = 1; i <= min; i++) {
- GETCHARINC(c, eptr);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if ((*prop_test_variable == prop_test_against) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- }
-
- /* Match extended Unicode sequences. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI) {
- for (i = 1; i <= min; i++) {
- GETCHARINCTEST(c, eptr);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category == ucp_M)
- RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject) {
- int len = 1;
- if (!utf8)
- c = *eptr;
- else {
- GETCHARLEN(c, eptr, len);
- }
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category != ucp_M)
- break;
- eptr += len;
- }
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
+ if (prop_type > 0) {
+ for (i = 1; i <= min; i++) {
+ GETCHARINC(c, eptr);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if ((*prop_test_variable == prop_test_against) == prop_fail_result)
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+
+ /* Match extended Unicode sequences. We will get here only if the
+ support is in the binary; otherwise a compile-time error occurs. */
+
+ else if (ctype == OP_EXTUNI) {
+ for (i = 1; i <= min; i++) {
+ GETCHARINCTEST(c, eptr);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category == ucp_M)
+ RRETURN(MATCH_NOMATCH);
+ while (eptr < md->end_subject) {
+ int len = 1;
+ if (!utf8)
+ c = *eptr;
+ else {
+ GETCHARLEN(c, eptr, len);
+ }
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category != ucp_M)
+ break;
+ eptr += len;
+ }
+ }
+ }
+
+ else
+#endif /* SUPPORT_UCP */
/* Handle all other cases when the coding is UTF-8 */
- /* Code for the non-UTF-8 case for minimum matching of operators other
- than OP_PROP and OP_NOTPROP. */
-
- switch (ctype) {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0) {
- for (i = 1; i <= min; i++)
- if (*eptr++ == NEWLINE)
- RRETURN(MATCH_NOMATCH);
- } else
- eptr += min;
- break;
-
- case OP_ANYBYTE:
- eptr += min;
- break;
-
- case OP_NOT_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
+ /* Code for the non-UTF-8 case for minimum matching of operators other
+ than OP_PROP and OP_NOTPROP. */
+
+ switch (ctype) {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0) {
+ for (i = 1; i <= min; i++)
+ if (*eptr++ == NEWLINE)
+ RRETURN(MATCH_NOMATCH);
+ } else
+ eptr += min;
+ break;
+
+ case OP_ANYBYTE:
+ eptr += min;
+ break;
+
+ case OP_NOT_DIGIT:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_digit) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_DIGIT:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_digit) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_NOT_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_space) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_space) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_word) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_word) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ default:
+ RRETURN(PCRE_ERROR_INTERNAL);
+ }
}
/* If min = max, continue at the same level without recursing */
if (min == max)
- continue;
+ continue;
/* If minimizing, we have to test the rest of the pattern before each
subsequent match. Again, separate the UTF-8 case for speed, and also
if (minimize) {
#ifdef SUPPORT_UCP
- if (prop_type > 0) {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
- GETCHARINC(c, eptr);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if ((*prop_test_variable == prop_test_against) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- }
-
- /* Match extended Unicode sequences. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI) {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
- GETCHARINCTEST(c, eptr);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category == ucp_M)
- RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject) {
- int len = 1;
- if (!utf8)
- c = *eptr;
- else {
- GETCHARLEN(c, eptr, len);
- }
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category != ucp_M)
- break;
- eptr += len;
- }
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
-
- /* Not UTF-8 mode */
- {
- for (fi = min;; fi++) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (fi >= max || eptr >= md->end_subject)
- RRETURN(MATCH_NOMATCH);
- c = *eptr++;
- switch (ctype) {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_ANYBYTE:
- break;
-
- case OP_NOT_DIGIT:
- if ((md->ctypes[c] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_DIGIT:
- if ((md->ctypes[c] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
- }
- /* Control never gets here */
+ if (prop_type > 0) {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject)
+ RRETURN(MATCH_NOMATCH);
+ GETCHARINC(c, eptr);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if ((*prop_test_variable == prop_test_against) == prop_fail_result)
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+
+ /* Match extended Unicode sequences. We will get here only if the
+ support is in the binary; otherwise a compile-time error occurs. */
+
+ else if (ctype == OP_EXTUNI) {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject)
+ RRETURN(MATCH_NOMATCH);
+ GETCHARINCTEST(c, eptr);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category == ucp_M)
+ RRETURN(MATCH_NOMATCH);
+ while (eptr < md->end_subject) {
+ int len = 1;
+ if (!utf8)
+ c = *eptr;
+ else {
+ GETCHARLEN(c, eptr, len);
+ }
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category != ucp_M)
+ break;
+ eptr += len;
+ }
+ }
+ }
+
+ else
+#endif /* SUPPORT_UCP */
+
+ /* Not UTF-8 mode */
+ {
+ for (fi = min;; fi++) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (fi >= max || eptr >= md->end_subject)
+ RRETURN(MATCH_NOMATCH);
+ c = *eptr++;
+ switch (ctype) {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_ANYBYTE:
+ break;
+
+ case OP_NOT_DIGIT:
+ if ((md->ctypes[c] & ctype_digit) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_DIGIT:
+ if ((md->ctypes[c] & ctype_digit) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_NOT_WHITESPACE:
+ if ((md->ctypes[c] & ctype_space) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_WHITESPACE:
+ if ((md->ctypes[c] & ctype_space) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_NOT_WORDCHAR:
+ if ((md->ctypes[c] & ctype_word) != 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ case OP_WORDCHAR:
+ if ((md->ctypes[c] & ctype_word) == 0)
+ RRETURN(MATCH_NOMATCH);
+ break;
+
+ default:
+ RRETURN(PCRE_ERROR_INTERNAL);
+ }
+ }
+ }
+ /* Control never gets here */
}
/* If maximizing it is worth using inline code for speed, doing the type
UTF-8 and UCP stuff separate. */
else {
- pp = eptr; /* Remember where we started */
+ pp = eptr; /* Remember where we started */
#ifdef SUPPORT_UCP
- if (prop_type > 0) {
- for (i = min; i < max; i++) {
- int len = 1;
- if (eptr >= md->end_subject)
- break;
- GETCHARLEN(c, eptr, len);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if ((*prop_test_variable == prop_test_against) == prop_fail_result)
- break;
- eptr += len;
- }
-
- /* eptr is now past the end of the maximum run */
-
- for (;;) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (eptr-- == pp)
- break; /* Stop if tried at original pos */
- BACKCHAR(eptr);
- }
- }
-
- /* Match extended Unicode sequences. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI) {
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject)
- break;
- GETCHARINCTEST(c, eptr);
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category == ucp_M)
- break;
- while (eptr < md->end_subject) {
- int len = 1;
- if (!utf8)
- c = *eptr;
- else {
- GETCHARLEN(c, eptr, len);
- }
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category != ucp_M)
- break;
- eptr += len;
- }
- }
-
- /* eptr is now past the end of the maximum run */
-
- for (;;) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- if (eptr-- == pp)
- break; /* Stop if tried at original pos */
- for (;;) { /* Move back over one extended */
- int len = 1;
- BACKCHAR(eptr);
- if (!utf8)
- c = *eptr;
- else {
- GETCHARLEN(c, eptr, len);
- }
- prop_category =
- _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
- if (prop_category != ucp_M)
- break;
- eptr--;
- }
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
-
-
- /* Not UTF-8 mode */
- {
- switch (ctype) {
- case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0) {
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject || *eptr == NEWLINE)
- break;
- eptr++;
- }
- break;
- }
- /* For DOTALL case, fall through and treat as \C */
-
- case OP_ANYBYTE:
- c = max - min;
- if (c > md->end_subject - eptr)
- c = md->end_subject - eptr;
- eptr += c;
- break;
-
- case OP_NOT_DIGIT:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_digit) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_DIGIT:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_digit) == 0)
- break;
- eptr++;
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_space) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_WHITESPACE:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_space) == 0)
- break;
- eptr++;
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_word) != 0)
- break;
- eptr++;
- }
- break;
-
- case OP_WORDCHAR:
- for (i = min; i < max; i++) {
- if (eptr >= md->end_subject
- || (md->ctypes[*eptr] & ctype_word) == 0)
- break;
- eptr++;
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
-
- /* eptr is now past the end of the maximum run */
-
- while (eptr >= pp) {
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
- eptr--;
- if (rrc != MATCH_NOMATCH)
- RRETURN(rrc);
- }
- }
-
- /* Get here if we can't make it match with any permitted repetitions */
-
- RRETURN(MATCH_NOMATCH);
+ if (prop_type > 0) {
+ for (i = min; i < max; i++) {
+ int len = 1;
+ if (eptr >= md->end_subject)
+ break;
+ GETCHARLEN(c, eptr, len);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if ((*prop_test_variable == prop_test_against) == prop_fail_result)
+ break;
+ eptr += len;
+ }
+
+ /* eptr is now past the end of the maximum run */
+
+ for (;;) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (eptr-- == pp)
+ break; /* Stop if tried at original pos */
+ BACKCHAR(eptr);
+ }
+ }
+
+ /* Match extended Unicode sequences. We will get here only if the
+ support is in the binary; otherwise a compile-time error occurs. */
+
+ else if (ctype == OP_EXTUNI) {
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject)
+ break;
+ GETCHARINCTEST(c, eptr);
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category == ucp_M)
+ break;
+ while (eptr < md->end_subject) {
+ int len = 1;
+ if (!utf8)
+ c = *eptr;
+ else {
+ GETCHARLEN(c, eptr, len);
+ }
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category != ucp_M)
+ break;
+ eptr += len;
+ }
+ }
+
+ /* eptr is now past the end of the maximum run */
+
+ for (;;) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ if (eptr-- == pp)
+ break; /* Stop if tried at original pos */
+ for (;;) { /* Move back over one extended */
+ int len = 1;
+ BACKCHAR(eptr);
+ if (!utf8)
+ c = *eptr;
+ else {
+ GETCHARLEN(c, eptr, len);
+ }
+ prop_category =
+ _pcre_ucp_findchar(c, &prop_chartype, &prop_othercase);
+ if (prop_category != ucp_M)
+ break;
+ eptr--;
+ }
+ }
+ }
+
+ else
+#endif /* SUPPORT_UCP */
+
+
+ /* Not UTF-8 mode */
+ {
+ switch (ctype) {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0) {
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject || *eptr == NEWLINE)
+ break;
+ eptr++;
+ }
+ break;
+ }
+ /* For DOTALL case, fall through and treat as \C */
+
+ case OP_ANYBYTE:
+ c = max - min;
+ if (c > md->end_subject - eptr)
+ c = md->end_subject - eptr;
+ eptr += c;
+ break;
+
+ case OP_NOT_DIGIT:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_digit) != 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_DIGIT:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_digit) == 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_NOT_WHITESPACE:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_space) != 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_WHITESPACE:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_space) == 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_word) != 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_WORDCHAR:
+ for (i = min; i < max; i++) {
+ if (eptr >= md->end_subject
+ || (md->ctypes[*eptr] & ctype_word) == 0)
+ break;
+ eptr++;
+ }
+ break;
+
+ default:
+ RRETURN(PCRE_ERROR_INTERNAL);
+ }
+
+ /* eptr is now past the end of the maximum run */
+
+ while (eptr >= pp) {
+ RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ eptr--;
+ if (rrc != MATCH_NOMATCH)
+ RRETURN(rrc);
+ }
+ }
+
+ /* Get here if we can't make it match with any permitted repetitions */
+
+ RRETURN(MATCH_NOMATCH);
}
/* Control never gets here */
that "continue" in the code above comes out to here to repeat the main
loop. */
- } /* End of main loop */
+ } /* End of main loop */
/* Control never reaches here */
}
int
pcre_exec(const pcre * argument_re, const pcre_extra * extra_data,
- const char *subject, int length, int start_offset, int options,
- int *offsets, int offsetcount)
+ const char *subject, int length, int start_offset, int options,
+ int *offsets, int offsetcount)
{
int rc, resetcount, ocount;
int first_byte = -1;
match_block.partial = (options & PCRE_PARTIAL) != 0;
match_block.hitend = FALSE;
- match_block.recursive = NULL; /* No recursion at top level */
+ match_block.recursive = NULL; /* No recursion at top level */
match_block.lcc = tables + lcc_offset;
match_block.ctypes = tables + ctypes_offset;
if ((re->options & PCRE_FIRSTSET) != 0) {
first_byte = re->first_byte & 255;
if ((first_byte_caseless =
- ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
- first_byte = match_block.lcc[first_byte];
+ ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
+ first_byte = match_block.lcc[first_byte];
} else
if (!startline && study != NULL &&
- (study->options & PCRE_STUDY_MAPPED) != 0)
+ (study->options & PCRE_STUDY_MAPPED) != 0)
start_bits = study->start_bits;
}
if ((re->options & PCRE_REQCHSET) != 0) {
req_byte = re->req_byte & 255;
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
- req_byte2 = (tables + fcc_offset)[req_byte]; /* case flipped */
+ req_byte2 = (tables + fcc_offset)[req_byte]; /* case flipped */
}
/* Loop for handling unanchored repeated matching attempts; for anchored regexs
register int *iptr = match_block.offset_vector;
register int *iend = iptr + resetcount;
while (iptr < iend)
- *iptr++ = -1;
+ *iptr++ = -1;
}
/* Advance to a unique first char if possible. If firstline is TRUE, the
if (firstline) {
const uschar *t = start_match;
while (t < save_end_subject && *t != '\n')
- t++;
+ t++;
end_subject = t;
}
if (first_byte >= 0) {
if (first_byte_caseless)
- while (start_match < end_subject &&
- match_block.lcc[*start_match] != first_byte)
- start_match++;
+ while (start_match < end_subject &&
+ match_block.lcc[*start_match] != first_byte)
+ start_match++;
else
- while (start_match < end_subject && *start_match != first_byte)
- start_match++;
+ while (start_match < end_subject && *start_match != first_byte)
+ start_match++;
}
/* Or to just after \n for a multiline match if possible */
else if (startline) {
if (start_match > match_block.start_subject + start_offset) {
- while (start_match < end_subject && start_match[-1] != NEWLINE)
- start_match++;
+ while (start_match < end_subject && start_match[-1] != NEWLINE)
+ start_match++;
}
}
else if (start_bits != NULL) {
while (start_match < end_subject) {
- register unsigned int c = *start_match;
- if ((start_bits[c / 8] & (1 << (c & 7))) == 0)
- start_match++;
- else
- break;
+ register unsigned int c = *start_match;
+ if ((start_bits[c / 8] & (1 << (c & 7))) == 0)
+ start_match++;
+ else
+ break;
}
}
end_subject = save_end_subject;
-#ifdef DEBUG /* Sigh. Some compilers never learn. */
+#ifdef DEBUG /* Sigh. Some compilers never learn. */
printf(">>>> Match against: ");
pchars(start_match, end_subject - start_match, TRUE, &match_block);
printf("\n");
*/
if (req_byte >= 0 &&
- end_subject - start_match < REQ_BYTE_MAX && !match_block.partial) {
+ end_subject - start_match < REQ_BYTE_MAX && !match_block.partial) {
register const uschar *p = start_match + ((first_byte >= 0) ? 1 : 0);
/* We don't need to repeat the search if we haven't yet reached the
place we found it at last time. */
if (p > req_byte_ptr) {
- if (req_byte_caseless) {
- while (p < end_subject) {
- register int pp = *p++;
- if (pp == req_byte || pp == req_byte2) {
- p--;
- break;
- }
- }
- } else {
- while (p < end_subject) {
- if (*p++ == req_byte) {
- p--;
- break;
- }
- }
- }
-
- /* If we can't find the required character, break the matching loop */
-
- if (p >= end_subject)
- break;
-
- /* If we have found the required character, save the point where we
- found it, so that we don't search again next time round the loop if
- the start hasn't passed this character yet. */
-
- req_byte_ptr = p;
+ if (req_byte_caseless) {
+ while (p < end_subject) {
+ register int pp = *p++;
+ if (pp == req_byte || pp == req_byte2) {
+ p--;
+ break;
+ }
+ }
+ } else {
+ while (p < end_subject) {
+ if (*p++ == req_byte) {
+ p--;
+ break;
+ }
+ }
+ }
+
+ /* If we can't find the required character, break the matching loop */
+
+ if (p >= end_subject)
+ break;
+
+ /* If we have found the required character, save the point where we
+ found it, so that we don't search again next time round the loop if
+ the start hasn't passed this character yet. */
+
+ req_byte_ptr = p;
}
}
match_block.match_call_count = 0;
rc = match(start_match, match_block.start_code, 2, &match_block, ims, NULL,
- match_isgroup);
+ match_isgroup);
/* When the result is no match, if the subject's first character was a
newline and the PCRE_FIRSTLINE option is set, break (which will return
if (rc == MATCH_NOMATCH) {
if (firstline && *start_match == NEWLINE)
- break;
+ break;
start_match++;
continue;
}
if (using_temporary_offsets) {
if (offsetcount >= 4) {
- memcpy(offsets + 2, match_block.offset_vector + 2,
- (offsetcount - 2) * sizeof(int));
+ memcpy(offsets + 2, match_block.offset_vector + 2,
+ (offsetcount - 2) * sizeof(int));
}
if (match_block.end_offset_top > offsetcount)
- match_block.offset_overflow = TRUE;
+ match_block.offset_overflow = TRUE;
free(match_block.offset_vector);
}
/* shs encryption didn't match. Try crypt(3) */
if (strcmp(crypt(password, "XX"), saved) != 0)
/* Nope */
-#endif /* HAS_CRYPT */
+#endif /* HAS_CRYPT */
/* crypt() didn't work. Try plaintext, being sure to not
* allow unencrypted entry of encrypted password */
if ((strcmp(saved, password) != 0)
- || (strlen(password) < 4)
- || ((password[0] == 'X') && (password[1] == 'X'))) {
- /* Nothing worked. You lose. */
- free(saved);
- return 0;
+ || (strlen(password) < 4)
+ || ((password[0] == 'X') && (password[1] == 'X'))) {
+ /* Nothing worked. You lose. */
+ free(saved);
+ return 0;
}
/* Something worked. Change password to SHS-encrypted */
(void) atr_add(player, pword_attr, passwd, GOD, NOTHING);
*/
dbref
connect_player(const char *name, const char *password, const char *host,
- const char *ip, char *errbuf)
+ const char *ip, char *errbuf)
{
dbref player;
char isgst = 0;
/* Default error */
strcpy(errbuf,
- T("Either that player does not exist, or has a different password."));
+ T("Either that player does not exist, or has a different password."));
if (!name || !*name)
return NOTHING;
/* See if player is allowed to connect like this */
if (!isgst && ( Going(player) || Going_Twice(player) )) {
do_log(LT_CONN, 0, 0,
- T("Connection to GOING player %s not allowed from %s (%s)"), name,
- host, ip);
+ T("Connection to GOING player %s not allowed from %s (%s)"), name,
+ host, ip);
return NOTHING;
}
if (!Site_Can_Connect(host, player) || !Site_Can_Connect(ip, player)) {
if (!Deny_Silent_Site(host, player) && !Deny_Silent_Site(ip, player)) {
do_log(LT_CONN, 0, 0,
- T("Connection to %s not allowed from %s (%s)"), name,
- host, ip);
+ T("Connection to %s not allowed from %s (%s)"), name,
+ host, ip);
strcpy(errbuf, T("Player connections not allowed."));
}
return NOTHING;
}
if (Suspect_Site(host, player) || Suspect_Site(ip, player)) {
do_log(LT_CONN, 0, 0,
- T("Connection from Suspect site. Setting %s(#%d) suspect."),
- Name(player), player);
+ T("Connection from Suspect site. Setting %s(#%d) suspect."),
+ Name(player), player);
set_flag_internal(player, "SUSPECT");
}
return player;
*/
dbref create_guest(const char *host, const char *ip) {
- int i , mg;
- char *guest_name;
- dbref gst_id;
-
- mg = MAX_GUESTS == 0 ? 100 : MAX_GUESTS;
- guest_name = (char *) mush_malloc(BUFFER_LEN, "gst_buf");
- gst_id = NOTHING;
-
- for( i = 0 ; i < mg ; i++) {
- /* reset vars */
- memset(guest_name, '\0', BUFFER_LEN);
- gst_id = NOTHING;
- strncpy(guest_name, T(GUEST_PREFIX), BUFFER_LEN-1);
- strcat(guest_name, GUEST_NUMBER(i+1));
- if(ok_player_name(guest_name, NOTHING, NOTHING))
- break;
- else if((gst_id = lookup_player(guest_name)) != NOTHING && !Connected(gst_id))
- break;
- else continue;
- }
- if(gst_id == NOTHING) {
- if(i >= mg) {
- mush_free((Malloc_t) guest_name, "gst_buf");
- return NOTHING;
- } else if(DBTOP_MAX && (db_top >= DBTOP_MAX + 1) && (first_free == NOTHING)) {
- mush_free((Malloc_t) guest_name, "gst_buf");
- do_log(LT_CONN, 0, 0, T("Failed creation (no db space) from %s"), host);
- return NOTHING;
- }
- gst_id = make_player(guest_name, "", host, ip);
- } else { /* Reset Guest */
- object_flag_type flags;
- flags = string_to_bits("FLAG", options.player_flags);
- copy_flag_bitmask("FLAG", Flags(gst_id), flags);
- }
- mush_free((Malloc_t) guest_name, "gst_buf");
- atr_add(gst_id, "DESCRIBE", GUEST_DESCRIBE, gst_id, NOTHING);
-
- SLEVEL(gst_id) = LEVEL_GUEST;
- Home(gst_id) = options.guest_start;
- if(GoodObject(options.guest_start) && IsRoom(options.guest_start)) {
- Contents(Location(gst_id)) = remove_first(Contents(Location(gst_id)), gst_id);
- Location(gst_id) = GUEST_START;
- PUSH(gst_id, Contents(options.guest_start));
- }
- return gst_id;
+ int i , mg;
+ char *guest_name;
+ dbref gst_id;
+
+ mg = MAX_GUESTS == 0 ? 100 : MAX_GUESTS;
+ guest_name = (char *) mush_malloc(BUFFER_LEN, "gst_buf");
+ gst_id = NOTHING;
+
+ for( i = 0 ; i < mg ; i++) {
+ /* reset vars */
+ memset(guest_name, '\0', BUFFER_LEN);
+ gst_id = NOTHING;
+ strncpy(guest_name, T(GUEST_PREFIX), BUFFER_LEN-1);
+ strcat(guest_name, GUEST_NUMBER(i+1));
+ if(ok_player_name(guest_name, NOTHING, NOTHING))
+ break;
+ else if((gst_id = lookup_player(guest_name)) != NOTHING && !Connected(gst_id))
+ break;
+ else continue;
+ }
+ if(gst_id == NOTHING) {
+ if(i >= mg) {
+ mush_free((Malloc_t) guest_name, "gst_buf");
+ return NOTHING;
+ } else if(DBTOP_MAX && (db_top >= DBTOP_MAX + 1) && (first_free == NOTHING)) {
+ mush_free((Malloc_t) guest_name, "gst_buf");
+ do_log(LT_CONN, 0, 0, T("Failed creation (no db space) from %s"), host);
+ return NOTHING;
+ }
+ gst_id = make_player(guest_name, "", host, ip);
+ } else { /* Reset Guest */
+ object_flag_type flags;
+ flags = string_to_bits("FLAG", options.player_flags);
+ copy_flag_bitmask("FLAG", Flags(gst_id), flags);
+ }
+ mush_free((Malloc_t) guest_name, "gst_buf");
+ atr_add(gst_id, "DESCRIBE", GUEST_DESCRIBE, gst_id, NOTHING);
+
+ SLEVEL(gst_id) = LEVEL_GUEST;
+ Home(gst_id) = options.guest_start;
+ if(GoodObject(options.guest_start) && IsRoom(options.guest_start)) {
+ Contents(Location(gst_id)) = remove_first(Contents(Location(gst_id)), gst_id);
+ Location(gst_id) = GUEST_START;
+ PUSH(gst_id, Contents(options.guest_start));
+ }
+ return gst_id;
}
/** Attempt to create a new player object.
* \param name name of player to create.
*/
dbref
create_player(const char *name, const char *password, const char *host,
- const char *ip)
+ const char *ip)
{
dbref player;
if (!ok_player_name(name, NOTHING, NOTHING)) {
*/
dbref
email_register_player(const char *name, const char *email, const char *host,
- const char *ip)
+ const char *ip)
{
char *p;
char passwd[BUFFER_LEN];
p++;
if (!Site_Can_Register(p)) {
if (!Deny_Silent_Site(p, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0,
- T("Failed registration (bad site in email: %s) from %s"),
- email, host);
+ do_log(LT_CONN, 0, 0,
+ T("Failed registration (bad site in email: %s) from %s"),
+ email, host);
}
return NOTHING;
}
if (!Site_Can_Register(email)) {
*p = '!';
if (!Deny_Silent_Site(email, AMBIGUOUS)) {
- do_log(LT_CONN, 0, 0,
- T("Failed registration (bad site in email: %s) from %s"),
- email, host);
+ do_log(LT_CONN, 0, 0,
+ T("Failed registration (bad site in email: %s) from %s"),
+ email, host);
}
return NOTHING;
} else
} else {
if (!Deny_Silent_Site(host, AMBIGUOUS)) {
do_log(LT_CONN, 0, 0, T("Failed registration (bad email: %s) from %s"),
- email, host);
+ email, host);
}
return NOTHING;
}
#endif
popen(tprintf("%s -t", SENDMAIL), "w")) == NULL) {
do_log(LT_CONN, 0, 0,
- T("Failed registration of %s by %s: unable to open sendmail"),
- name, email);
+ T("Failed registration of %s by %s: unable to open sendmail"),
+ name, email);
reserve_fd();
return NOTHING;
}
fprintf(fp, T("The password is %s\n"), passwd);
fprintf(fp, "\n");
fprintf(fp, T("To access this character, connect to %s and type:\n"),
- MUDNAME);
+ MUDNAME);
fprintf(fp, "\tconnect \"%s\" %s\n", name, passwd);
fprintf(fp, "\n");
pclose(fp);
#else
dbref
email_register_player(const char *name, const char *email, const char *host,
- const char *ip)
+ const char *ip)
{
do_log(LT_CONN, 0, 0, T("Failed registration (no sendmail) from %s"), host);
return NOTHING;
static dbref
make_player(const char *name, const char *password, const char *host,
- const char *ip)
+ const char *ip)
{
dbref player;
/* Modtime tracks login failures */
ModTime(player) = (time_t) 0;
(void) atr_add(player, "XYXXY", mush_crypt(password), GOD, NOTHING);
- giveto(player, START_BONUS); /* starting bonus */
+ giveto(player, START_BONUS); /* starting bonus */
(void) atr_add(player, "LAST", show_time(mudtime, 0), GOD, NOTHING);
(void) atr_add(player, "LASTSITE", host, GOD, NOTHING);
(void) atr_add(player, "LASTIP", ip, GOD, NOTHING);
sprintf(temp, "%d", START_QUOTA);
(void) atr_add(player, "RQUOTA", temp, GOD, NOTHING);
(void) atr_add(player, "ICLOC", EMPTY_ATTRS ? "" : " ", GOD,
- AF_MDARK | AF_PRIVATE | AF_NOCOPY);
+ AF_MDARK | AF_PRIVATE | AF_NOCOPY);
#ifdef USE_MAILER
(void) atr_add(player, "MAILCURF", "0", GOD,
- AF_LOCKED | AF_NOPROG);
+ AF_LOCKED | AF_NOPROG);
add_folder_name(player, 0, "inbox");
#endif
/* link him to PLAYER_START */
add_player(player);
add_lock(GOD, player, Basic_Lock, parse_boolexp(player, "=me", Basic_Lock),
- -1);
+ -1);
add_lock(GOD, player, Enter_Lock, parse_boolexp(player, "=me", Basic_Lock),
- -1);
+ -1);
add_lock(GOD, player, Use_Lock, parse_boolexp(player, "=me", Basic_Lock), -1);
current_state.players++;
sp = old;
bp = old_eval;
process_expression(old_eval, &bp, &sp, player, player, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
old = old_eval;
sp = newobj;
bp = new_eval;
process_expression(new_eval, &bp, &sp, player, player, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
newobj = new_eval;
}
*/
void
reset_player_list(dbref player, const char *oldname, const char *oldalias,
- const char *name, const char *alias)
+ const char *name, const char *alias)
{
char tbuf1[BUFFER_LEN];
char tbuf2[BUFFER_LEN];
}
opt = 1;
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
- (char *) &opt, sizeof(opt)) < 0) {
+ (char *) &opt, sizeof(opt)) < 0) {
perror("setsockopt");
exit(1);
}
#ifdef HAS_SYSCONF
errno = 0;
if ((open_max = sysconf(_SC_OPEN_MAX)) < 0) {
- if (errno == 0) /* Value was indeterminate */
+ if (errno == 0) /* Value was indeterminate */
open_max = 0;
}
if (open_max)
int forbidden_name(const char *name);
void do_switch(dbref player, char *expression, char **argv,
- dbref cause, int first, int notifyme, int regexp);
+ dbref cause, int first, int notifyme, int regexp);
void do_verb(dbref player, dbref cause, char *arg1, char **argv);
static int grep_util_helper(dbref player, dbref thing, dbref parent,
- char const *pattern, ATTR *atr, void *args);
+ char const *pattern, ATTR *atr, void *args);
static int grep_helper(dbref player, dbref thing, dbref parent,
- char const *pattern, ATTR *atr, void *args);
+ char const *pattern, ATTR *atr, void *args);
void do_grep(dbref player, char *obj, char *lookfor, int flag, int insensitive);
int pay_quota(dbref, int);
extern PRIV attr_privs_view[];
#ifdef HAS_VSNPRINTF
static char buff[BUFFER_LEN];
#else
- static char buff[BUFFER_LEN * 3]; /* safety margin */
+ static char buff[BUFFER_LEN * 3]; /* safety margin */
#endif
va_list args;
/* charges left, decrement and execute */
int res;
if ((res = queue_attribute(thing, awhat, player)))
- (void) atr_add(thing, "CHARGES", tprintf("%d", num - 1),
- Owner(b->creator), NOTHING);
+ (void) atr_add(thing, "CHARGES", tprintf("%d", num - 1),
+ Owner(b->creator), NOTHING);
return res;
} else {
/* no charges left, try to execute runout */
/* Bunch o' nulls */
static char *myenv[10] = { NULL };
return real_did_it(player, thing, what, def, owhat, odef, awhat, loc, myenv,
- NA_INTER_HEAR);
+ NA_INTER_HEAR);
}
/** A wrapper for real_did_it that can set %0 and %1 to dbrefs.
*/
int
did_it_with(dbref player, dbref thing, const char *what, const char *def,
- const char *owhat, const char *odef, const char *awhat,
- dbref loc, dbref env0, dbref env1, int flags)
+ const char *owhat, const char *odef, const char *awhat,
+ dbref loc, dbref env0, dbref env1, int flags)
{
char *myenv[10] = { NULL };
char e0[SBUF_LEN], e1[SBUF_LEN], *ep;
}
return real_did_it(player, thing, what, def, owhat, odef, awhat, loc, myenv,
- flags);
+ flags);
}
*/
int
did_it_interact(dbref player, dbref thing, const char *what, const char *def,
- const char *owhat, const char *odef, const char *awhat,
- dbref loc, int flags)
+ const char *owhat, const char *odef, const char *awhat,
+ dbref loc, int flags)
{
/* Bunch o' nulls */
static char *myenv[10] = { NULL };
return real_did_it(player, thing, what, def, owhat, odef, awhat, loc, myenv,
- flags);
+ flags);
}
/** Take an action on an object and trigger attributes.
*/
int
real_did_it(dbref player, dbref thing, const char *what, const char *def,
- const char *owhat, const char *odef, const char *awhat, dbref loc,
- char *myenv[10], int flags)
+ const char *owhat, const char *odef, const char *awhat, dbref loc,
+ char *myenv[10], int flags)
{
ATTR *d;
if (what && *what) {
d = atr_get(thing, what);
if (d) {
- attribs_used = 1;
- if (!need_pres) {
- need_pres = 1;
- save_global_regs("did_it_save", preserveq);
- save_global_env("did_it_save", preserves);
- }
- restore_global_env("did_it", myenv);
- asave = safe_atr_value(d);
- ap = asave;
- bp = buff;
- process_expression(buff, &bp, &ap, thing, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
- *bp = '\0';
- notify_by(thing, player, buff);
- free((Malloc_t) asave);
+ attribs_used = 1;
+ if (!need_pres) {
+ need_pres = 1;
+ save_global_regs("did_it_save", preserveq);
+ save_global_env("did_it_save", preserves);
+ }
+ restore_global_env("did_it", myenv);
+ asave = safe_atr_value(d);
+ ap = asave;
+ bp = buff;
+ process_expression(buff, &bp, &ap, thing, player, player,
+ PE_DEFAULT, PT_DEFAULT, NULL);
+ *bp = '\0';
+ notify_by(thing, player, buff);
+ free((Malloc_t) asave);
} else if (def && *def)
- notify_by(thing, player, def);
+ notify_by(thing, player, def);
}
/* message to neighbors */
if (!DarkLegal(player)) {
if (owhat && *owhat) {
- d = atr_get(thing, owhat);
- if (d) {
- attribs_used = 1;
- if (!need_pres) {
- need_pres = 1;
- save_global_regs("did_it_save", preserveq);
- save_global_env("did_it_save", preserves);
- }
- restore_global_env("did_it", myenv);
- asave = safe_atr_value(d);
- ap = asave;
- bp = buff;
- safe_str(Name(player), buff, &bp);
- safe_chr(' ', buff, &bp);
- sp = bp;
- process_expression(buff, &bp, &ap, thing, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
- *bp = '\0';
- if (bp != sp)
- notify_except2(Contents(loc), player, thing, buff, flags);
- free((Malloc_t) asave);
- } else {
- if (odef && *odef) {
- notify_except2(Contents(loc), player, thing,
- tprintf("%s %s", Name(player), odef), flags);
- }
- }
+ d = atr_get(thing, owhat);
+ if (d) {
+ attribs_used = 1;
+ if (!need_pres) {
+ need_pres = 1;
+ save_global_regs("did_it_save", preserveq);
+ save_global_env("did_it_save", preserves);
+ }
+ restore_global_env("did_it", myenv);
+ asave = safe_atr_value(d);
+ ap = asave;
+ bp = buff;
+ safe_str(Name(player), buff, &bp);
+ safe_chr(' ', buff, &bp);
+ sp = bp;
+ process_expression(buff, &bp, &ap, thing, player, player,
+ PE_DEFAULT, PT_DEFAULT, NULL);
+ *bp = '\0';
+ if (bp != sp)
+ notify_except2(Contents(loc), player, thing, buff, flags);
+ free((Malloc_t) asave);
+ } else {
+ if (odef && *odef) {
+ notify_except2(Contents(loc), player, thing,
+ tprintf("%s %s", Name(player), odef), flags);
+ }
+ }
}
}
}
if(can_interact(thing, player, INTERACT_SEE)) {
if (DarkLegal(thing) || (ldark && !Light(thing))) {
if (!lck) {
- if (CanSee(player, loc) || (loc == player) || controls(player, loc))
- return thing;
- lck = 1;
+ if (CanSee(player, loc) || (loc == player) || controls(player, loc))
+ return thing;
+ lck = 1;
}
- if (controls(player, thing)) /* this is what causes DARK objects to show */
- return thing;
+ if (controls(player, thing)) /* this is what causes DARK objects to show */
+ return thing;
} else {
return thing;
}
return 1;
if (Inherit_Powers(who) && div_powover(Owner(who), Owner(who), "Privilege")
- && LEVEL(who) >= LEVEL(what) && CanModify(Owner(who), what))
+ && LEVEL(who) >= LEVEL(what) && CanModify(Owner(who), what))
return 1;
if (div_powover(what,what,"Privilege"))
if ((tmp = Pennies(owner)) >= cost) {
if (Track_Money(owner)) {
notify_format(owner, T("GAME: %s(%s) spend %d %s."),
- Name(who), unparse_dbref(who), cost,
- (cost == 1) ? MONEY : MONIES);
+ Name(who), unparse_dbref(who), cost,
+ (cost == 1) ? MONEY : MONIES);
}
s_Pennies(owner, tmp - cost);
return 1;
} else {
if (Track_Money(owner)) {
notify_format(owner, T("GAME: %s(%s) tried to spend %d %s."),
- Name(who), unparse_dbref(who), cost,
- (cost == 1) ? MONEY : MONIES);
+ Name(who), unparse_dbref(who), cost,
+ (cost == 1) ? MONEY : MONIES);
}
return 0;
}
for (i = 0; i < db_top; i++)
if (!IsGarbage(i) && ((!IsDivision(who) && Owner(i) == Owner(who))
- || (IsDivision(who) && !IsPlayer(i) && IsDivision(Division(i)) && div_inscope(who,i))))
+ || (IsDivision(who) && !IsPlayer(i) && IsDivision(Division(i)) && div_inscope(who,i))))
owned++;
- owned--; /* don't count the player or division itself */
+ owned--; /* don't count the player or division itself */
if (!IsDivision(who) && (owned <= START_QUOTA))
limit = START_QUOTA - owned;
return;
(void) atr_add(Owner(who), "RQUOTA",
- tprintf("%d", get_current_quota(who) + payment), GOD, NOTHING);
+ tprintf("%d", get_current_quota(who) + payment), GOD, NOTHING);
/* Check If Division Quota has to be adjusted now */
if(GoodObject(Division(who)) && !NoQuota(Division(who)))
(void) atr_add(Division(who), "RQUOTA",
- tprintf("%d", get_current_quota(Division(who)) + payment), GOD, NOTHING);
+ tprintf("%d", get_current_quota(Division(who)) + payment), GOD, NOTHING);
}
/* figure out how much we have, and if it's big enough */
curr = get_current_quota(who);
- if (USE_QUOTA && (curr - cost < 0)) /* not enough */
+ if (USE_QUOTA && (curr - cost < 0)) /* not enough */
return 0;
change_quota(who, -cost);
/* No magic cookies */
return (name
- && *name
- && *name != LOOKUP_TOKEN
- && *name != NUMBER_TOKEN
- && *name != NOT_TOKEN && strcasecmp((char *) name, "me")
- && strcasecmp((char *) name, "home")
- && strcasecmp((char *) name, "here"));
+ && *name
+ && *name != LOOKUP_TOKEN
+ && *name != NUMBER_TOKEN
+ && *name != NOT_TOKEN && strcasecmp((char *) name, "me")
+ && strcasecmp((char *) name, "home")
+ && strcasecmp((char *) name, "here"));
}
/** Is a name a valid player name when applied by player to thing?
/* A player may only change to a forbidden name if they're already
using that name. */
if (forbidden_name(name) && !((lookup == thing) ||
- (GoodObject(player) && Director(player))))
+ (GoodObject(player) && Director(player))))
return 0;
return ((lookup == NOTHING) || (lookup == thing));
while (sp && *sp && *sp == ' ')
sp++;
if (!sp || !*sp)
- return OPAE_NULL; /* No null aliases */
+ return OPAE_NULL; /* No null aliases */
if (!ok_player_name(sp, player, thing))
return OPAE_INVALID;
cnt++;
return 0;
default:
if (!isupper((unsigned char) *name) && !isdigit((unsigned char) *name)
- && !ispunct((unsigned char) *name))
+ && !ispunct((unsigned char) *name))
return 0;
}
/* Everything else must be printable and non-space, and we need
*/
*q++ = '\0';
if (strncasecmp((char *) p, "SEND", n) == 0
- || strncasecmp((char *) p, "XCH_CMD", n) == 0)
- return 0;
+ || strncasecmp((char *) p, "XCH_CMD", n) == 0)
+ return 0;
while (*q && isspace(*q))
- q++;
+ q++;
while (*q && !isspace(*q))
- q++;
+ q++;
p = q;
} else
- return 0; /* Malformed param without an = */
+ return 0; /* Malformed param without an = */
}
return 1;
}
*/
void
do_switch(dbref player, char *expression, char **argv, dbref cause,
- int first, int notifyme, int regexp)
+ int first, int notifyme, int regexp)
{
int any = 0, a;
char buff[BUFFER_LEN], *bp;
ap = argv[a];
bp = buff;
process_expression(buff, &bp, &ap, player, cause, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
/* check for a match */
if (regexp ? quick_regexp_match(buff, expression, 0)
- : local_wild_match(buff, expression)) {
+ : local_wild_match(buff, expression)) {
any = 1;
tbuf1 = replace_string("#$", expression, argv[a + 1]);
parse_que(player, tbuf1, cause);
dbref
parse_match_possessor(dbref player, const char **str)
{
- const char *box; /* name of container */
- char *obj; /* name of object */
+ const char *box; /* name of container */
+ char *obj; /* name of object */
box = *str;
/* check to see if we have an 's sequence */
if ((obj = strchr(box, '\'')) == NULL)
return NOTHING;
- *obj++ = '\0'; /* terminate */
+ *obj++ = '\0'; /* terminate */
if ((*obj == '\0') || ((*obj != 's') && (*obj != 'S')))
return NOTHING;
/* skip over the 's' and whitespace */
*/
void
page_return(dbref player, dbref target, const char *type,
- const char *message, const char *def)
+ const char *message, const char *def)
{
ATTR *d;
char buff[BUFFER_LEN], *bp, *asave;
ap = asave;
bp = buff;
process_expression(buff, &bp, &ap, target, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free((Malloc_t) asave);
if (*buff) {
- ptr = (struct tm *) localtime(&mudtime);
- notify_format(player, T("%s message from %s: %s"), type,
- Name(target), buff);
- if (!Haven(target))
- notify_format(target,
- T("[%d:%02d] %s message sent to %s."), ptr->tm_hour,
- ptr->tm_min, type, Name(player));
+ ptr = (struct tm *) localtime(&mudtime);
+ notify_format(player, T("%s message from %s: %s"), type,
+ Name(target), buff);
+ if (!Haven(target))
+ notify_format(target,
+ T("[%d:%02d] %s message sent to %s."), ptr->tm_hour,
+ ptr->tm_min, type, Name(player));
}
} else if (def && *def)
notify(player, def);
*/
if (!((controls(player, victim) && controls(player, actor)) ||
- ((controls(cause, actor) && Can_Examine(player, victim))))) {
+ ((controls(cause, actor) && Can_Examine(player, victim))))) {
notify(player, T("Permission denied."));
return;
}
}
real_did_it(actor, victim,
- upcasestr(argv[2]), argv[3], upcasestr(argv[4]), argv[5],
- NULL, Location(actor), global_eval_context.wenv, NA_INTER_HEAR);
+ upcasestr(argv[2]), argv[3], upcasestr(argv[4]), argv[5],
+ NULL, Location(actor), global_eval_context.wenv, NA_INTER_HEAR);
for (i = 0; i < 10; i++)
global_eval_context.wenv[i] = wsave[i];
/** Structure for passing arguments to grep_util_helper().
*/
struct guh_args {
- char *buff; /**< Buffer for output */
- char *bp; /**< Pointer to buff's current position */
- char *lookfor; /**< Pattern to grep for */
- int sensitive; /**< If 1, case-sensitive match; if 0, insensitive */
+ char *buff; /**< Buffer for output */
+ char *bp; /**< Pointer to buff's current position */
+ char *lookfor; /**< Pattern to grep for */
+ int sensitive; /**< If 1, case-sensitive match; if 0, insensitive */
};
static int
grep_util_helper(dbref player __attribute__ ((__unused__)),
- dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *atr, void *args)
+ dbref thing __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *atr, void *args)
{
struct guh_args *guh = args;
int found = 0;
char *s;
int len;
- s = (char *) atr_value(atr); /* warning: static */
+ s = (char *) atr_value(atr); /* warning: static */
len = strlen(guh->lookfor);
found = 0;
while (*s && !found) {
if ((guh->sensitive && !strncmp(guh->lookfor, s, len)) ||
- (!guh->sensitive && !strncasecmp(guh->lookfor, s, len)))
+ (!guh->sensitive && !strncasecmp(guh->lookfor, s, len)))
found = 1;
else
s++;
static int
wildgrep_util_helper(dbref player __attribute__ ((__unused__)),
- dbref thing __attribute__ ((__unused__)),
- dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *atr, void *args)
+ dbref thing __attribute__ ((__unused__)),
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *atr, void *args)
{
struct guh_args *guh = args;
int found = 0;
*/
char *
grep_util(dbref player, dbref thing, char *pattern, char *lookfor,
- int sensitive, int wild)
+ int sensitive, int wild)
{
struct guh_args guh;
guh.lookfor = lookfor;
guh.sensitive = sensitive;
(void) atr_iter_get(player, thing, pattern, 0, wild ? wildgrep_util_helper
- : grep_util_helper, &guh);
+ : grep_util_helper, &guh);
*guh.bp = '\0';
return guh.buff;
}
/** Structure for grep_helper() arguments. */
struct gh_args {
- char *lookfor; /**< Pattern to look for. */
- int len; /**< Length of lookfor. */
- int insensitive; /**< if 1, case-insensitive matching; if 0, sensitive */
+ char *lookfor; /**< Pattern to look for. */
+ int len; /**< Length of lookfor. */
+ int insensitive; /**< if 1, case-insensitive matching; if 0, sensitive */
};
static int
grep_helper(dbref player, dbref thing __attribute__ ((__unused__)),
dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *atr, void *args)
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *atr, void *args)
{
struct gh_args *gh = args;
int found;
found = 0;
tbp = tbuf1;
- s = (char *) atr_value(atr); /* warning: static */
+ s = (char *) atr_value(atr); /* warning: static */
while (s && *s) {
if ((gh->insensitive && !strncasecmp(gh->lookfor, s, gh->len)) ||
- (!gh->insensitive && !strncmp(gh->lookfor, s, gh->len))) {
+ (!gh->insensitive && !strncmp(gh->lookfor, s, gh->len))) {
found = 1;
strncpy(buf, s, gh->len);
buf[gh->len] = '\0';
/* if we got it, display it */
if (found)
notify_format(player, "%s%s [#%d%s]%s %s",
- ANSI_HILITE, AL_NAME(atr),
- Owner(AL_CREATOR(atr)),
- privs_to_letters(attr_privs_view, AL_FLAGS(atr)),
- ANSI_NORMAL, tbuf1);
+ ANSI_HILITE, AL_NAME(atr),
+ Owner(AL_CREATOR(atr)),
+ privs_to_letters(attr_privs_view, AL_FLAGS(atr)),
+ ANSI_NORMAL, tbuf1);
return found;
}
/* find the attribute pattern */
pattern = strchr(obj, '/');
if (!pattern)
- pattern = (char *) "*"; /* set it to global match */
+ pattern = (char *) "*"; /* set it to global match */
else
*pattern++ = '\0';
} else {
tp = grep_util(player, thing, pattern, lookfor, !insensitive, 0);
notify_format(player, T("Matches of '%s' on %s(#%d): %s"), lookfor,
- Name(thing), thing, tp);
+ Name(thing), thing, tp);
mush_free((Malloc_t) tp, "grep_util.buff");
}
}
if (*p == '!') {
not = 1;
if (!*++p)
- continue;
+ continue;
}
ltr = 0;
if (strlen(p) == 1) {
/* One-letter string is treated as a character if possible */
ltr = letter_to_privs(table, p, 0);
if (not)
- no |= ltr;
+ no |= ltr;
else
- yes |= ltr;
+ yes |= ltr;
}
/* If we didn't handle a one-char string as a character,
* or if the string is longer than one char, use prefix-matching
*/
if (!ltr) {
for (c = table; c->name; c++) {
- if (string_prefix(c->name, p)) {
- if (not)
- no |= c->bits_to_set;
- else
- yes |= c->bits_to_set;
- break;
- }
+ if (string_prefix(c->name, p)) {
+ if (not)
+ no |= c->bits_to_set;
+ else
+ yes |= c->bits_to_set;
+ break;
+ }
}
}
}
if (*p == '!') {
not = 1;
if (!*++p)
- continue;
+ continue;
}
for (c = table; c->name; c++) {
if (!strcasecmp(c->name, p)) {
- if (not)
- no |= c->bits_to_set;
- else
- yes |= c->bits_to_set;
- break;
+ if (not)
+ no |= c->bits_to_set;
+ else
+ yes |= c->bits_to_set;
+ break;
}
}
}
/* One-letter string is treated as a character if possible */
ltr = letter_to_privs(table, p, 0);
if (not)
- *clrprivs |= ltr;
+ *clrprivs |= ltr;
else
- *setprivs |= ltr;
+ *setprivs |= ltr;
}
if (ltr) {
found++;
} else {
for (c = table; c->name; c++) {
- if (string_prefix(c->name, p)) {
- found++;
- if (not)
- *clrprivs |= c->bits_to_set;
- else
- *setprivs |= c->bits_to_set;
- break;
- }
+ if (string_prefix(c->name, p)) {
+ found++;
+ if (not)
+ *clrprivs |= c->bits_to_set;
+ else
+ *setprivs |= c->bits_to_set;
+ break;
+ }
}
}
}
if (*p == '!') {
not = 1;
if (!*++p)
- break;
+ break;
}
for (c = table; c->name; c++) {
if (c->letter == *p) {
- if (not)
- no |= c->bits_to_set;
- else
- yes |= c->bits_to_set;
- break;
+ if (not)
+ no |= c->bits_to_set;
+ else
+ yes |= c->bits_to_set;
+ break;
}
}
}
for (c = table; c->name; c++) {
if (privs & c->bits_to_show) {
if (bp != buf)
- safe_chr(' ', buf, &bp);
+ safe_chr(' ', buf, &bp);
safe_str(c->name, buf, &bp);
privs &= ~c->bits_to_set;
}
int password_handler(DESC *, char *);
/* Telnet codes */
-#define IAC 255 /**< interpret as command */
-#define GOAHEAD 249 /**< go ahead */
+#define IAC 255 /**< interpret as command */
+#define GOAHEAD 249 /**< go ahead */
#define UNDEFINED_PROMPT "\x1B[1m>\x1b[0m"
-#define PI_LOCK 0x1
-#define PI_PROMPT 0x2
+#define PI_LOCK 0x1
+#define PI_PROMPT 0x2
#define PI_INTERNAL_PROMPT 0x40
extern DESC *descriptor_list;
for (i = 0; i < NUMQ && i < rcnt; i++)
if (p_buf[i] && strlen(p_buf[i]) > 0) {
strcpy(global_eval_context.renv[i], p_buf[i]);
- global_eval_context.rnxt[i] = global_eval_context.renv[i];
+ global_eval_context.rnxt[i] = global_eval_context.renv[i];
}
for (; i < (rcnt - 1); i+= 2) {
/** A ptab entry. */
typedef struct ptab_entry {
- void *data; /**< pointer to data */
- char key[BUFFER_LEN]; /**< the index key */
+ void *data; /**< pointer to data */
+ char key[BUFFER_LEN]; /**< the index key */
} ptab_entry;
/** The memory usage of a ptab entry, not including data. */
if (!tab || !key || !*key || tab->state)
return NULL;
- if (tab->len < 10) { /* Just do a linear search for small tables */
+ if (tab->len < 10) { /* Just do a linear search for small tables */
for (nun = 0; nun < tab->len; nun++) {
if (string_prefix(tab->tab[nun]->key, key)) {
- if (nun + 1 < tab->len && string_prefix(tab->tab[nun + 1]->key, key))
- return NULL;
- else
- return tab->tab[nun]->data;
+ if (nun + 1 < tab->len && string_prefix(tab->tab[nun + 1]->key, key))
+ return NULL;
+ else
+ return tab->tab[nun]->data;
}
}
- } else { /* Binary search of the index */
+ } else { /* Binary search of the index */
int left = 0;
int cmp;
int right = tab->len - 1;
nun = (left + right) / 2;
if (left > right)
- break;
+ break;
cmp = strcasecmp(key, tab->tab[nun]->key);
if (cmp == 0) {
- return tab->tab[nun]->data;
+ return tab->tab[nun]->data;
} else if (cmp < 0) {
- int mem;
- /* We need to catch the first unique prefix */
- if (string_prefix(tab->tab[nun]->key, key)) {
- for (mem = nun - 1; mem >= 0; mem--) {
- if (string_prefix(tab->tab[mem]->key, key)) {
- if (strcasecmp(tab->tab[mem]->key, key) == 0)
- return tab->tab[mem]->data;
- } else
- break;
- }
- /* Non-unique prefix */
- if (mem != nun - 1)
- return NULL;
- for (mem = nun + 1; mem < tab->len; mem++) {
- if (string_prefix(tab->tab[mem]->key, key)) {
- if (strcasecmp(tab->tab[mem]->key, key) == 0)
- return tab->tab[mem]->data;
- } else
- break;
- }
- if (mem != nun + 1)
- return NULL;
- return tab->tab[nun]->data;
- }
- if (left == right)
- break;
- right = nun - 1;
- } else { /* cmp > 0 */
- if (left == right)
- break;
- left = nun + 1;
+ int mem;
+ /* We need to catch the first unique prefix */
+ if (string_prefix(tab->tab[nun]->key, key)) {
+ for (mem = nun - 1; mem >= 0; mem--) {
+ if (string_prefix(tab->tab[mem]->key, key)) {
+ if (strcasecmp(tab->tab[mem]->key, key) == 0)
+ return tab->tab[mem]->data;
+ } else
+ break;
+ }
+ /* Non-unique prefix */
+ if (mem != nun - 1)
+ return NULL;
+ for (mem = nun + 1; mem < tab->len; mem++) {
+ if (string_prefix(tab->tab[mem]->key, key)) {
+ if (strcasecmp(tab->tab[mem]->key, key) == 0)
+ return tab->tab[mem]->data;
+ } else
+ break;
+ }
+ if (mem != nun + 1)
+ return NULL;
+ return tab->tab[nun]->data;
+ }
+ if (left == right)
+ break;
+ right = nun - 1;
+ } else { /* cmp > 0 */
+ if (left == right)
+ break;
+ left = nun + 1;
}
}
}
if (!tab || !key || tab->state)
return -1;
- if (tab->len < 10) { /* Just do a linear search for small tables */
+ if (tab->len < 10) { /* Just do a linear search for small tables */
int cmp;
for (nun = 0; nun < tab->len; nun++) {
cmp = strcasecmp(tab->tab[nun]->key, key);
if (cmp == 0)
- return nun;
+ return nun;
else if (cmp > 0)
- return -1;
+ return -1;
}
- } else { /* Binary search of the index */
+ } else { /* Binary search of the index */
int left = 0;
int cmp;
int right = tab->len - 1;
nun = (left + right) / 2;
if (left > right)
- break;
+ break;
cmp = strcasecmp(key, tab->tab[nun]->key);
if (cmp == 0)
- return nun;
+ return nun;
if (left == right)
- break;
+ break;
if (cmp < 0)
- right = nun - 1;
- else /* cmp > 0 */
- left = nun + 1;
+ right = nun - 1;
+ else /* cmp > 0 */
+ left = nun + 1;
}
}
return -1;
mem += PTAB_SIZE + strlen(tab->tab[nun]->key) + 1;
notify_format(player, "%-10s %7d %14.3f %39d", pname, tab->len, log(tab->len),
- mem);
+ mem);
}
/* check recipient */
switch (who =
- match_result(player, recipient, TYPE_PLAYER,
- MAT_NEAR_THINGS | MAT_ENGLISH)) {
+ match_result(player, recipient, TYPE_PLAYER,
+ MAT_NEAR_THINGS | MAT_ENGLISH)) {
case NOTHING:
notify(player, T("Give to whom?"));
return;
if (!is_strict_integer(amnt)) {
dbref thing;
switch (thing =
- match_result(player, amnt, TYPE_THING,
- MAT_POSSESSION | MAT_ENGLISH)) {
+ match_result(player, amnt, TYPE_THING,
+ MAT_POSSESSION | MAT_ENGLISH)) {
case NOTHING:
- notify(player, T("You don't have that!"));
+ notify(player, T("You don't have that!"));
return;
case AMBIGUOUS:
notify(player, T("I don't know which you mean!"));
* do this.
*/
if (thing == player) {
- notify(player, T("You can't give yourself away!"));
- return;
+ notify(player, T("You can't give yourself away!"));
+ return;
}
/* Don't give things to themselves. */
if (thing == who) {
- notify(player, T("You can't give an object to itself!"));
- return;
+ notify(player, T("You can't give an object to itself!"));
+ return;
}
if (!eval_lock(player, thing, Give_Lock)) {
- notify(player, T("You can't give that away."));
- return;
+ notify(player, T("You can't give that away."));
+ return;
}
if (Mobile(thing) && (EnterOk(who) || controls(player, who))) {
- moveto(thing, who);
+ moveto(thing, who);
- /* Notify the giver with their GIVE message */
- bp = tbuf1;
- safe_format(tbuf1, &bp, T("You gave %s to %s."), Name(thing),
- Name(who));
- *bp = '\0';
- did_it_with(player, player, "GIVE", tbuf1, "OGIVE", NULL,
- "AGIVE", NOTHING, thing, who, NA_INTER_SEE);
+ /* Notify the giver with their GIVE message */
+ bp = tbuf1;
+ safe_format(tbuf1, &bp, T("You gave %s to %s."), Name(thing),
+ Name(who));
+ *bp = '\0';
+ did_it_with(player, player, "GIVE", tbuf1, "OGIVE", NULL,
+ "AGIVE", NOTHING, thing, who, NA_INTER_SEE);
- /* Notify the object that it's been given */
- notify_format(thing, T("%s gave you to %s."), Name(player), Name(who));
+ /* Notify the object that it's been given */
+ notify_format(thing, T("%s gave you to %s."), Name(player), Name(who));
- /* Recipient gets success message on thing and receive on self */
- did_it(who, thing, "SUCCESS", NULL, "OSUCCESS", NULL, "ASUCCESS",
- NOTHING);
- bp = tbuf1;
- safe_format(tbuf1, &bp, T("%s gave you %s."), Name(player),
- Name(thing));
- *bp = '\0';
- did_it_with(who, who, "RECEIVE", tbuf1, "ORECEIVE", NULL,
- "ARECEIVE", NOTHING, thing, player, NA_INTER_SEE);
+ /* Recipient gets success message on thing and receive on self */
+ did_it(who, thing, "SUCCESS", NULL, "OSUCCESS", NULL, "ASUCCESS",
+ NOTHING);
+ bp = tbuf1;
+ safe_format(tbuf1, &bp, T("%s gave you %s."), Name(player),
+ Name(thing));
+ *bp = '\0';
+ did_it_with(who, who, "RECEIVE", tbuf1, "ORECEIVE", NULL,
+ "ARECEIVE", NOTHING, thing, player, NA_INTER_SEE);
} else
- notify(player, T("Permission denied."));
+ notify(player, T("Permission denied."));
}
return;
}
return;
} else if (amount == 0) {
notify_format(player,
- T("You must specify a positive number of %s."), MONIES);
+ T("You must specify a positive number of %s."), MONIES);
return;
}
if (MoneyAdmin(player) && (amount < 0) && (Pennies(who) + amount < 0))
a = atr_get(who, "COST");
if (!a) {
- /* No cost attribute */
- notify_format(player, T("%s refuses your money."), Name(who));
- giveto(player, amount);
- return;
+ /* No cost attribute */
+ notify_format(player, T("%s refuses your money."), Name(who));
+ giveto(player, amount);
+ return;
}
save_global_regs("give_save", preserveq);
save_global_env("give_save", preserves);
*pb = '\0';
global_eval_context.wenv[0] = paid;
process_expression(fbuff, &fbp, &ap, who, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*fbp = '\0';
free((Malloc_t) asave);
restore_global_regs("give_save", preserveq);
restore_global_env("give_save", preserves);
if (amount < (cost = atoi(fbuff))) {
- notify(player, T("Feeling poor today?"));
- giveto(player, amount);
- return;
+ notify(player, T("Feeling poor today?"));
+ giveto(player, amount);
+ return;
}
if (cost < 0)
- return;
+ return;
if ((amount - cost) > 0) {
- notify_format(player, T("You get %d in change."), amount - cost);
+ notify_format(player, T("You get %d in change."), amount - cost);
} else {
- notify_format(player, T("You paid %d %s."), amount,
- ((amount == 1) ? MONEY : MONIES));
+ notify_format(player, T("You paid %d %s."), amount,
+ ((amount == 1) ? MONEY : MONIES));
}
giveto(player, amount - cost);
giveto(who, cost);
safe_integer_sbuf(cost, paid, &pb);
*pb = '\0';
real_did_it(player, who, "PAYMENT", NULL, "OPAYMENT", NULL, "APAYMENT",
- NOTHING, pay_env, NA_INTER_SEE);
+ NOTHING, pay_env, NA_INTER_SEE);
return;
} else {
/* give pennies to a player */
if (amount > 0) {
- notify_format(player,
- T("You give %d %s to %s."), amount,
- ((amount == 1) ? MONEY : MONIES), Name(who));
+ notify_format(player,
+ T("You give %d %s to %s."), amount,
+ ((amount == 1) ? MONEY : MONIES), Name(who));
} else {
- notify_format(player, T("You took %d %s from %s!"), abs(amount),
- ((abs(amount) == 1) ? MONEY : MONIES), Name(who));
+ notify_format(player, T("You took %d %s from %s!"), abs(amount),
+ ((abs(amount) == 1) ? MONEY : MONIES), Name(who));
}
if (IsPlayer(who) && !silent) {
- if (amount > 0) {
- notify_format(who, T("%s gives you %d %s."), Name(player),
- amount, ((amount == 1) ? MONEY : MONIES));
- } else {
- notify_format(who, T("%s took %d %s from you!"), Name(player),
- abs(amount), ((abs(amount) == 1) ? MONEY : MONIES));
- }
+ if (amount > 0) {
+ notify_format(who, T("%s gives you %d %s."), Name(player),
+ amount, ((amount == 1) ? MONEY : MONIES));
+ } else {
+ notify_format(who, T("%s took %d %s from you!"), Name(player),
+ abs(amount), ((abs(amount) == 1) ? MONEY : MONIES));
+ }
}
giveto(who, amount);
safe_integer_sbuf(amount, paid, &pb);
*pb = '\0';
real_did_it(player, who, "PAYMENT", NULL, "OPAYMENT", NULL, "APAYMENT",
- NOTHING, pay_env, NA_INTER_SEE);
+ NOTHING, pay_env, NA_INTER_SEE);
}
}
}
int affordable;
int costcount, ci;
int count, i;
- int low, high; /* lower bound, upper bound of cost */
+ int low, high; /* lower bound, upper bound of cost */
ATTR *a;
if (!GoodObject(Location(player)))
if (from != NULL && *from) {
switch (vendor =
- match_result(player, from, TYPE_PLAYER,
- MAT_NEAR_THINGS | MAT_ENGLISH)) {
+ match_result(player, from, TYPE_PLAYER,
+ MAT_NEAR_THINGS | MAT_ENGLISH)) {
case NOTHING:
notify(player, T("Buy from whom?"));
return;
continue;
for (i = 0; i < count; i++) {
if (!strncasecmp(finditem, r[i], len)) {
- /* Check cost */
- cost = r[i] + len;
- if (!*cost)
- continue;
- costcount = list2arr(c, BUFFER_LEN / 2, cost, ',');
- for (ci = 0; ci < costcount; ci++) {
- cost = c[ci];
- /* Formats:
- * 10,2000+,10-100
- */
- if ((plus = strchr(cost, '-'))) {
- *(plus++) = '\0';
- if (!is_strict_integer(cost))
- continue;
- if (!is_strict_integer(plus))
- continue;
- low = parse_integer(cost);
- high = parse_integer(plus);
- if (price < 0) {
- boughtit = low;
- } else if (price >= low && price <= high) {
- boughtit = price;
- }
- } else if ((plus = strchr(cost, '+'))) {
- *(plus++) = '\0';
- if (!is_strict_integer(cost))
- continue;
- low = parse_integer(cost);
- if (price < 0) {
- boughtit = low;
- } else if (price > low) {
- boughtit = price;
- }
- } else if (is_strict_integer(cost)) {
- low = parse_integer(cost);
- if (price < 0) {
- boughtit = low;
- } else if (low == price) {
- boughtit = price;
- }
- } else {
- continue;
- }
- if (boughtit >= 0) {
- if (!payfor(player, boughtit)) {
- affordable = 0;
- boughtit = 0;
- continue;
- }
- bp = strchr(finditem, ':');
- if (bp)
- *bp = '\0';
- for (bp = finditem; *bp; bp++)
- *bp = DOWNCASE(*bp);
- bp = buff;
- safe_format(buff, &bp, "You buy a %s from %s.",
- finditem, Name(vendor));
- *bp = '\0';
- bp = obuff;
- safe_format(obuff, &bp, "buys a %s from %s.",
- finditem, Name(vendor));
- buy_env[0] = finditem;
- buy_env[1] = buycost;
- bp = buycost;
- safe_integer(boughtit, buycost, &bp);
- *bp = '\0';
- real_did_it(player, vendor, "BUY", buff, "OBUY", obuff, "ABUY",
- NOTHING, buy_env, NA_INTER_SEE);
- return;
- }
- }
+ /* Check cost */
+ cost = r[i] + len;
+ if (!*cost)
+ continue;
+ costcount = list2arr(c, BUFFER_LEN / 2, cost, ',');
+ for (ci = 0; ci < costcount; ci++) {
+ cost = c[ci];
+ /* Formats:
+ * 10,2000+,10-100
+ */
+ if ((plus = strchr(cost, '-'))) {
+ *(plus++) = '\0';
+ if (!is_strict_integer(cost))
+ continue;
+ if (!is_strict_integer(plus))
+ continue;
+ low = parse_integer(cost);
+ high = parse_integer(plus);
+ if (price < 0) {
+ boughtit = low;
+ } else if (price >= low && price <= high) {
+ boughtit = price;
+ }
+ } else if ((plus = strchr(cost, '+'))) {
+ *(plus++) = '\0';
+ if (!is_strict_integer(cost))
+ continue;
+ low = parse_integer(cost);
+ if (price < 0) {
+ boughtit = low;
+ } else if (price > low) {
+ boughtit = price;
+ }
+ } else if (is_strict_integer(cost)) {
+ low = parse_integer(cost);
+ if (price < 0) {
+ boughtit = low;
+ } else if (low == price) {
+ boughtit = price;
+ }
+ } else {
+ continue;
+ }
+ if (boughtit >= 0) {
+ if (!payfor(player, boughtit)) {
+ affordable = 0;
+ boughtit = 0;
+ continue;
+ }
+ bp = strchr(finditem, ':');
+ if (bp)
+ *bp = '\0';
+ for (bp = finditem; *bp; bp++)
+ *bp = DOWNCASE(*bp);
+ bp = buff;
+ safe_format(buff, &bp, "You buy a %s from %s.",
+ finditem, Name(vendor));
+ *bp = '\0';
+ bp = obuff;
+ safe_format(obuff, &bp, "buys a %s from %s.",
+ finditem, Name(vendor));
+ buy_env[0] = finditem;
+ buy_env[1] = buycost;
+ bp = buycost;
+ safe_integer(boughtit, buycost, &bp);
+ *bp = '\0';
+ real_did_it(player, vendor, "BUY", buff, "OBUY", obuff, "ABUY",
+ NOTHING, buy_env, NA_INTER_SEE);
+ return;
+ }
+ }
}
}
} while (!from && ((vendor = Next(vendor)) != NOTHING));
notify(player, T("I can't find that item with that price here."));
} else {
notify_format(player, T("%s isn't selling that item for that price"),
- Name(vendor));
+ Name(vendor));
}
} else if (affordable) {
if (!from) {
void s_Pennies(dbref thing, int amnt) {
- if(amnt > HUGE_INT)
- Pennies(thing) = (int) HUGE_INT;
- else if(amnt < 0)
- Pennies(thing) = 0;
- else Pennies(thing) = amnt;
+ if(amnt > HUGE_INT)
+ Pennies(thing) = (int) HUGE_INT;
+ else if(amnt < 0)
+ Pennies(thing) = 0;
+ else Pennies(thing) = amnt;
}
for(current = 0 ; current < db_top ; current++)
if(has_flag_by_name(current, "ICFUNCS", TYPE_ROOM)) {
- db[current].rplog.bufferq = allocate_bufferq(RPBUF_SIZE);
- db[current].rplog.status = 0;
+ db[current].rplog.bufferq = allocate_bufferq(RPBUF_SIZE);
+ db[current].rplog.status = 0;
} else {
db[current].rplog.bufferq = NULL;
}
if(db[room].rplog.bufferq && has_flag_by_name(room, "ICFUNCS", TYPE_ROOM)) {
if(db[room].rplog.status == 1) { /* Check Size.. We might need to make it bigger */
if(db[room].rplog.bufferq->num_buffered == (lines =
- bufferq_lines(db[room].rplog.bufferq)) && lines < RPBUF_MAXSIZE )
- reallocate_bufferq(db[room].rplog.bufferq,lines+1);
+ bufferq_lines(db[room].rplog.bufferq)) && lines < RPBUF_MAXSIZE )
+ reallocate_bufferq(db[room].rplog.bufferq,lines+1);
}
add_to_bufferq(db[room].rplog.bufferq, 0, player, str);
}
char *bq;
time_t timeof;
if((mudtime % 3600)==0) { /* reset all things in a combat status
- * that have been ina combat status over 24 hours */
+ * that have been ina combat status over 24 hours */
for(i = 0; i < db_top; i++)
if(IsGarbage(i))
- continue;
+ continue;
else if(db[i].rplog.bufferq != NULL) {
- if(db[i].rplog.status == 1) {
- bq = db[i].rplog.bufferq->buffer;
- bq += sizeof(int) + sizeof(dbref) + sizeof(int);
- /* K.. we're pointed here.. make sure we're not greater than the buffer end though... */
- if(bq >= db[i].rplog.bufferq->buffer_end) /* OOo... we are, nothings ever been done here.. So lets continue */
- continue;
- memcpy(&timeof, bq, sizeof(time_t));
- if(timeof < (mudtime-RPRESET_TIME)) {
- /* make sure its small.. */
- reallocate_bufferq(db[i].rplog.bufferq, RPBUF_SIZE);
- expire_bufferq(db[i].rplog.bufferq, (time_t) (mudtime - 1200));
- }
- } else { /* Otherwise just do message expirations */
- expire_bufferq(db[i].rplog.bufferq, (time_t) (mudtime - 1200));
- }
+ if(db[i].rplog.status == 1) {
+ bq = db[i].rplog.bufferq->buffer;
+ bq += sizeof(int) + sizeof(dbref) + sizeof(int);
+ /* K.. we're pointed here.. make sure we're not greater than the buffer end though... */
+ if(bq >= db[i].rplog.bufferq->buffer_end) /* OOo... we are, nothings ever been done here.. So lets continue */
+ continue;
+ memcpy(&timeof, bq, sizeof(time_t));
+ if(timeof < (mudtime-RPRESET_TIME)) {
+ /* make sure its small.. */
+ reallocate_bufferq(db[i].rplog.bufferq, RPBUF_SIZE);
+ expire_bufferq(db[i].rplog.bufferq, (time_t) (mudtime - 1200));
+ }
+ } else { /* Otherwise just do message expirations */
+ expire_bufferq(db[i].rplog.bufferq, (time_t) (mudtime - 1200));
+ }
}
}
}
stamp = show_time(timestamp, 0);
notify_format(player, "[%s] %s", stamp, buf);
}
- }
+ }
}
}
skip--;
for(cur_obj = 0 ; cur_obj < db_top ; cur_obj++)
if(has_flag_by_name(cur_obj, "ICFUNCS", TYPE_ROOM)
- && (db[cur_obj].rplog.bufferq)) {
+ && (db[cur_obj].rplog.bufferq)) {
free_bufferq(db[cur_obj].rplog.bufferq);
db[cur_obj].rplog.bufferq = NULL;
db[cur_obj].rplog.status = 0;
#include "copyrite.h"
#include "config.h"
-#include <windows.h> /* for service and thread routines */
+#include <windows.h> /* for service and thread routines */
#include <stdlib.h>
#include <process.h>
void mainthread(int argc, char **argv);
-SERVICE_STATUS ssStatus; /* current status of the service */
+SERVICE_STATUS ssStatus; /* current status of the service */
SERVICE_STATUS_HANDLE sshStatusHandle;
DWORD dwGlobalErr;
VOID service_main(DWORD dwArgc, LPTSTR * lpszArgv);
VOID WINAPI service_ctrl(DWORD dwCtrlCode);
BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
- DWORD dwWin32ExitCode,
- DWORD dwCheckPoint, DWORD dwWaitHint);
+ DWORD dwWin32ExitCode,
+ DWORD dwCheckPoint, DWORD dwWaitHint);
VOID worker_thread(VOID * notused);
VOID StopService(LPTSTR lpszMsg);
status = get_service_status(&svcstatus, TRUE);
if (status == 0 && svcstatus.dwCurrentState == SERVICE_RUNNING) {
- fprintf(stderr, T("The MUSH is already running as a service.\n"));
- return 1;
+ fprintf(stderr, T("The MUSH is already running as a service.\n"));
+ return 1;
}
worker_thread(NULL);
} else
fprintf(stderr, T("Attempting to start CobraMUSH as a service ...\n"));
if (!StartServiceCtrlDispatcher(dispatchTable)) {
fprintf(stderr,
- T
- ("Unable to start service, assuming running console-mode application.\n"));
+ T
+ ("Unable to start service, assuming running console-mode application.\n"));
fprintf(stderr,
- T
- ("You can save time on the next invocation by specifying: cobramush /run\n"));
+ T
+ ("You can save time on the next invocation by specifying: cobramush /run\n"));
worker_thread(NULL);
}
- } /* end of argc == 1 */
+ } /* end of argc == 1 */
return 0;
-} /* end of main */
+} /* end of main */
/* service_main() -- */
/* report the status to Service Control Manager. */
- if (!ReportStatusToSCMgr(SERVICE_START_PENDING, /* service state */
- NO_ERROR, /* exit code */
- 1, /* checkpoint */
- 3000)) /* wait hint */
+ if (!ReportStatusToSCMgr(SERVICE_START_PENDING, /* service state */
+ NO_ERROR, /* exit code */
+ 1, /* checkpoint */
+ 3000)) /* wait hint */
goto cleanup;
/* start the thread that performs the work of the service. */
- threadHandle = (HANDLE) _beginthreadex(NULL, /* security attributes */
- 0, /* stack size (0 means inherit parent's stack size) */
- (LPTHREAD_START_ROUTINE) worker_thread, NULL, /* argument to thread */
- 0, /* thread creation flags */
- &TID); /* pointer to thread ID */
+ threadHandle = (HANDLE) _beginthreadex(NULL, /* security attributes */
+ 0, /* stack size (0 means inherit parent's stack size) */
+ (LPTHREAD_START_ROUTINE) worker_thread, NULL, /* argument to thread */
+ 0, /* thread creation flags */
+ &TID); /* pointer to thread ID */
if (!threadHandle)
goto cleanup;
/* report the status to the service control manager. */
- if (!ReportStatusToSCMgr(SERVICE_RUNNING, /* service state */
- NO_ERROR, /* exit code */
- 0, /* checkpoint */
- 0)) /* wait hint */
+ if (!ReportStatusToSCMgr(SERVICE_RUNNING, /* service state */
+ NO_ERROR, /* exit code */
+ 0, /* checkpoint */
+ 0)) /* wait hint */
goto cleanup;
/* wait indefinitely until threadHandle is signaled. */
/* The thread handle is signalled when the thread terminates */
- dwWait = WaitForSingleObject(threadHandle, /* event object */
- INFINITE); /* wait indefinitely */
+ dwWait = WaitForSingleObject(threadHandle, /* event object */
+ INFINITE); /* wait indefinitely */
cleanup:
/* process, the StartServiceCtrlDispatcher function in */
/* the main thread returns, terminating the process. */
return;
-} /* end of service_main */
+} /* end of service_main */
/* Report the status, specifying the checkpoint and waithint, */
/* before setting the termination event. */
- ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */
- NO_ERROR, /* exit code */
- 1, /* checkpoint */
- 10000); /* waithint (10 secs) */
+ ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */
+ NO_ERROR, /* exit code */
+ 1, /* checkpoint */
+ 10000); /* waithint (10 secs) */
shutdown_flag = 1;
default:
break;
- } /* end of switch */
+ } /* end of switch */
/* send a status response. */
ReportStatusToSCMgr(dwState, NO_ERROR, 0, 0);
-} /* end of service_ctrl */
+} /* end of service_ctrl */
/* utility functions... */
/* to the service control manager. */
static BOOL
ReportStatusToSCMgr(DWORD dwCurrentState,
- DWORD dwWin32ExitCode, DWORD dwCheckPoint, DWORD dwWaitHint)
+ DWORD dwWin32ExitCode, DWORD dwCheckPoint, DWORD dwWaitHint)
{
BOOL fResult;
ssStatus.dwWaitHint = dwWaitHint;
/* Report the status of the service to the service control manager. */
- if (!(fResult = SetServiceStatus(sshStatusHandle, /* service reference handle */
- &ssStatus))) { /* SERVICE_STATUS structure */
+ if (!(fResult = SetServiceStatus(sshStatusHandle, /* service reference handle */
+ &ssStatus))) { /* SERVICE_STATUS structure */
/* If an error occurs, stop the service. */
StopService("SetServiceStatus");
}
return fResult;
-} /* end of ReportStatusToSCMgr */
+} /* end of ReportStatusToSCMgr */
lpszStrings[1] = lpszMsg;
if (hEventSource) {
- ReportEvent(hEventSource, /* handle of event source */
- EVENTLOG_ERROR_TYPE, /* event type */
- 0, /* event category */
- 0, /* event ID */
- NULL, /* current user's SID */
- 2, /* strings in lpszStrings */
- 0, /* no bytes of raw data */
- lpszStrings, /* array of error strings */
- NULL); /* no raw data */
+ ReportEvent(hEventSource, /* handle of event source */
+ EVENTLOG_ERROR_TYPE, /* event type */
+ 0, /* event category */
+ 0, /* event ID */
+ NULL, /* current user's SID */
+ 2, /* strings in lpszStrings */
+ 0, /* no bytes of raw data */
+ lpszStrings, /* array of error strings */
+ NULL); /* no raw data */
(VOID) DeregisterEventSource(hEventSource);
}
if (threadHandle)
TerminateThread(threadHandle, 1);
-} /* end of StopService */
+} /* end of StopService */
/* called at shutdown, ctrl-c etc. */
}
return FALSE;
-} /* end of shut_down_handler */
+} /* end of shut_down_handler */
/*
mainthread(argc, argv);
-} /* end of worker_thread */
+} /* end of worker_thread */
void WIN32_CDECL
Win32_Exit(int exit_code)
else
_exit(exit_code);
-} /* end of Win32_Exit */
+} /* end of Win32_Exit */
/* this is called from db_write (every 256 objects) */
/* to keep the service manager happy (it needs a checkpoint every 3 seconds) */
static DWORD checkpoint = 1;
if (threadHandle && shutdown_flag)
- ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */
- NO_ERROR, /* exit code */
- ++checkpoint, /* checkpoint */
- 3000); /* waithint (3 seconds) */
+ ReportStatusToSCMgr(SERVICE_STOP_PENDING, /* current state */
+ NO_ERROR, /* exit code */
+ ++checkpoint, /* checkpoint */
+ 3000); /* waithint (3 seconds) */
-} /* end of shutdown_checkpoint */
+} /* end of shutdown_checkpoint */
/* We need to close these handles so often I'll do it in a separate routine */
if (SCmanager)
CloseServiceHandle(SCmanager);
SCmanager = NULL;
-} /* end of close_service_handles */
+} /* end of close_service_handles */
/* We put out *so* many error messages, let's centralise the whole thing */
if (error_code)
fprintf(stderr, " ** Error %ld\n ** %s\n",
- error_code, convert_error(error_code));
+ error_code, convert_error(error_code));
close_service_handles();
return TRUE;
-} /* end of service_error */
+} /* end of service_error */
/*
Open a handle to the Service Control Manager.
if (!SCmanager)
return service_error(GetLastError(),
- T("Unable to talk to the Service Control Manager"));
+ T("Unable to talk to the Service Control Manager"));
return FALSE;
-} /* end of openServiceManager */
+} /* end of openServiceManager */
/*
return service_error(GetLastError(), T("Cannot access service definition"));
return FALSE;
-} /* end of get_service */
+} /* end of get_service */
/*
Opens the service manager and gets the status, optionally leaving
return 0;
-} /* end of get_service_status */
+} /* end of get_service_status */
/*
Install this service.
Now create the service definition.
*/
- service = CreateService(SCmanager, THIS_SERVICE, THIS_SERVICE_DISPLAY, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, fullfilename, NULL, /* no load ordering group */
- NULL, /* no tag identifier */
- NULL, /* no dependencies */
- NULL, /* LocalSystem account */
- NULL); /* no password */
+ service = CreateService(SCmanager, THIS_SERVICE, THIS_SERVICE_DISPLAY, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, fullfilename, NULL, /* no load ordering group */
+ NULL, /* no tag identifier */
+ NULL, /* no dependencies */
+ NULL, /* LocalSystem account */
+ NULL); /* no password */
if (!service)
return service_error(GetLastError(), T("Unable to create service"));
fprintf(stderr, T("Service successfully installed\n"));
return FALSE;
-} /* end of CmdInstallService */
+} /* end of CmdInstallService */
/*
Remove this service.
if (svcstatus.dwCurrentState != SERVICE_STOPPED)
return service_error(0,
- T
- ("You must stop the service before you can remove it."));
+ T
+ ("You must stop the service before you can remove it."));
/*
Everything is fine, so delete the service definition.
fprintf(stderr, T("Service successfully removed\n"));
return FALSE;
-} /* end of CmdRemoveService */
+} /* end of CmdRemoveService */
/*
fprintf(stderr, T("Start request sent to service\n"));
return FALSE;
-} /* end of CmdStartService */
+} /* end of CmdStartService */
/*
Stop this service.
fprintf(stderr, T("Stop request sent to service\n"));
return FALSE;
-} /* end of CmdStopService */
+} /* end of CmdStopService */
/*
default:
p = T("Unrecognised status.");
break;
- } /* end of switch */
+ } /* end of switch */
fprintf(stderr, "%s\n", p);
return FALSE;
-} /* end of CmdStatusService */
+} /* end of CmdStatusService */
{
fprintf(stderr, T("Usage is :-\n"));
fprintf(stderr, T(" %s - runs as a service, or stand-alone\n"),
- THIS_SERVICE);
+ THIS_SERVICE);
fprintf(stderr, T(" %s /run - runs stand-alone\n"), THIS_SERVICE);
fprintf(stderr, T(" %s /start - starts this service\n"), THIS_SERVICE);
fprintf(stderr, T(" %s /stop - stops this service\n"), THIS_SERVICE);
fprintf(stderr, T(" %s /install - installs this service\n"), THIS_SERVICE);
fprintf(stderr, T(" %s /remove - removes (un-installs) this service\n"),
- THIS_SERVICE);
+ THIS_SERVICE);
fprintf(stderr, T(" %s /status - displays the status of this service\n"),
- THIS_SERVICE);
+ THIS_SERVICE);
fprintf(stderr, T(" %s /help - displays this information\n"),
- THIS_SERVICE);
-} /* end of CmdDisplayFormat */
+ THIS_SERVICE);
+} /* end of CmdDisplayFormat */
static char *
convert_error(DWORD error)
static char buff[100];
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- error, LANG_NEUTRAL, (LPTSTR) & formattedmsg, 0, NULL)) {
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error, LANG_NEUTRAL, (LPTSTR) & formattedmsg, 0, NULL)) {
sprintf(buff, "<Error code: %ld>", error);
return buff;
} else
return formattedmsg;
-} /* end of convert_error */
+} /* end of convert_error */
-#endif /* WIN32SERVICES */
-#endif /* WIN32 */
+#endif /* WIN32SERVICES */
+#endif /* WIN32 */
static int af_helper(dbref player, dbref thing, dbref parent,
char const *pattern, ATTR *atr, void *args);
static int gedit_helper(dbref player, dbref thing, dbref parent, char const *pattern,
- ATTR *atr, void *args);
+ ATTR *atr, void *args);
static int wipe_helper(dbref player, dbref thing, dbref parent, char const *pattern,
- ATTR *atr, void *args);
+ ATTR *atr, void *args);
static void copy_attrib_flags(dbref player, dbref target, ATTR *atr, int flags);
/* check for renaming a player */
if (IsPlayer(thing)) {
if (PLAYER_NAME_SPACES) {
- if (*newname == '\"') {
- for (; *newname && ((*newname == '\"')
- || isspace((unsigned char) *newname));
- newname++) ;
- password = newname;
- while (*password && (*password != '\"')) {
- while (*password && (*password != '\"'))
- password++;
- if (*password == '\"') {
- *password++ = '\0';
- while (*password && isspace((unsigned char) *password))
- password++;
- break;
- }
- }
- } else {
- password = newname;
- while (*password && !isspace((unsigned char) *password))
- password++;
- if (*password) {
- *password++ = '\0';
- while (*password && isspace((unsigned char) *password))
- password++;
- }
- }
+ if (*newname == '\"') {
+ for (; *newname && ((*newname == '\"')
+ || isspace((unsigned char) *newname));
+ newname++) ;
+ password = newname;
+ while (*password && (*password != '\"')) {
+ while (*password && (*password != '\"'))
+ password++;
+ if (*password == '\"') {
+ *password++ = '\0';
+ while (*password && isspace((unsigned char) *password))
+ password++;
+ break;
+ }
+ }
+ } else {
+ password = newname;
+ while (*password && !isspace((unsigned char) *password))
+ password++;
+ if (*password) {
+ *password++ = '\0';
+ while (*password && isspace((unsigned char) *password))
+ password++;
+ }
+ }
} else {
- /* split off password */
- for (password = newname + strlen(newname) - 1;
- *password && !isspace((unsigned char) *password); password--) ;
- for (; *password && isspace((unsigned char) *password); password--) ;
- /* eat whitespace */
- if (*password) {
- *++password = '\0'; /* terminate name */
- password++;
- while (*password && isspace((unsigned char) *password))
- password++;
- }
+ /* split off password */
+ for (password = newname + strlen(newname) - 1;
+ *password && !isspace((unsigned char) *password); password--) ;
+ for (; *password && isspace((unsigned char) *password); password--) ;
+ /* eat whitespace */
+ if (*password) {
+ *++password = '\0'; /* terminate name */
+ password++;
+ while (*password && isspace((unsigned char) *password))
+ password++;
+ }
}
if (!ok_player_name(newname, player, thing)) {
- notify(player, T("You can't give a player that name."));
- return;
+ notify(player, T("You can't give a player that name."));
+ return;
}
/* everything ok, notify */
do_log(LT_CONN, 0, 0, T("Name change by %s(#%d) to %s"),
- Name(thing), thing, newname);
+ Name(thing), thing, newname);
/* everything ok, we can fall through to change the name */
} else {
if (!ok_name(newname)) {
- notify(player, T("That is not a reasonable name."));
- return;
+ notify(player, T("That is not a reasonable name."));
+ return;
}
}
if (!AreQuiet(player, thing))
notify(player, T("Name set."));
real_did_it(player, thing, NULL, NULL, "ONAME", NULL, "ANAME", NOTHING,
- myenv, NA_INTER_PRESENCE);
+ myenv, NA_INTER_PRESENCE);
mush_free(myenv[0], "string");
mush_free(myenv[1], "string");
}
if (!can_pay_fees(newowner, Pennies(thing))) {
/* not enough money or quota */
if (newowner != player)
- notify(player,
- T
- ("That player doesn't have enough money or quota to receive that object."));
+ notify(player,
+ T
+ ("That player doesn't have enough money or quota to receive that object."));
return;
}
/* Credit the current owner */
* passes the lock?
*/
if (!(OOREF(player,controls(player, newowner),controls(ooref, newowner)) ||
- (ZMaster(newowner) && eval_lock(player, newowner, Zone_Lock))))
+ (ZMaster(newowner) && eval_lock(player, newowner, Zone_Lock))))
return 0;
/* Target player is legitimate. Does player control the object? */
if (!preserve || !Director(player)) {
set_flag_internal(thing, "HALT");
if(DPBITS(thing))
- mush_free(DPBITS(thing), "POWER_SPOT"); /* wipe out all powers */
+ mush_free(DPBITS(thing), "POWER_SPOT"); /* wipe out all powers */
DPBITS(thing) = NULL;
do_halt(thing, "", thing);
} else {
adjust_powers(thing, newowner);
if (DPBITS(thing))
notify(player,
- T
- ("Warning: @CHOWN/PRESERVE on a target with @power privileges."));
+ T
+ ("Warning: @CHOWN/PRESERVE on a target with @power privileges."));
}
}
zone = NOTHING;
else {
if ((zone = noisy_match_result(player, newobj, NOTYPE, MAT_EVERYTHING))
- == NOTHING)
+ == NOTHING)
return 0;
}
* this allows players to @chzone themselves to an object they own.
*/
if (!(God(player) || (Director(player) && controls(player, thing))
- || Owns(player, thing))) {
+ || Owns(player, thing))) {
if (noisy)
notify(player, T("You don't have the power to shift reality."));
return 0;
* Note that an object with no chzone-lock isn't valid
*/
if (!((Director(player) && controls(player, zone))
- || (zone == NOTHING) || Owns(player, zone) ||
- ((getlock(zone, Chzone_Lock) != TRUE_BOOLEXP) &&
- eval_lock(player, zone, Chzone_Lock)))) {
+ || (zone == NOTHING) || Owns(player, zone) ||
+ ((getlock(zone, Chzone_Lock) != TRUE_BOOLEXP) &&
+ eval_lock(player, zone, Chzone_Lock)))) {
if (noisy)
notify(player, T("You cannot move that object to that zone."));
return 0;
for (tmp = Zone(zone); GoodObject(tmp); tmp = Zone(tmp)) {
if (tmp == thing) {
- notify(player, T("You can't make circular zones!"));
- return 0;
+ notify(player, T("You can't make circular zones!"));
+ return 0;
}
- if (tmp == Zone(tmp)) /* Ran into an object zoned to itself */
- break;
+ if (tmp == Zone(tmp)) /* Ran into an object zoned to itself */
+ break;
zone_depth--;
if(!zone_depth) {
- notify(player, T("Overly deep zone chain"));
- return 0;
+ notify(player, T("Overly deep zone chain"));
+ return 0;
}
}
}
* This checks for many trivial elocks (canuse/1, where &canuse=1)
*/
if (zone != NOTHING)
- check_zone_lock(player, zone, noisy);
+ check_zone_lock(player, zone, noisy);
/* Warn admins when they zone their stuff */
if ((zone != NOTHING) && Admin(Owner(thing))) {
if (noisy)
} else {
if (noisy && (zone != NOTHING)) {
if (Admin(thing) && noisy)
- notify(player, T("Warning: @chzoning an administrator."));
+ notify(player, T("Warning: @chzoning an administrator."));
}
}
if (noisy)
/** Structure for af_helper() data. */
struct af_args {
- int setf; /**< flag bits to set */
- int clrf; /**< flag bits to clear */
- char *setflags; /**< list of names of flags to set */
- char *clrflags; /**< list of names of flags to clear */
+ int setf; /**< flag bits to set */
+ int clrf; /**< flag bits to clear */
+ char *setflags; /**< list of names of flags to set */
+ char *clrflags; /**< list of names of flags to clear */
};
static int
af_helper(dbref player, dbref thing, dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *atr, void *args)
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *atr, void *args)
{
struct af_args *af = args;
* There is one special case - the resetting of the SAFE flag.
*/
if (!(Can_Write_Attr(player, thing, AL_ATTR(atr)) ||
- ((af->clrf & AF_SAFE) &&
- Can_Write_Attr_Ignore_Safe(player, thing, AL_ATTR(atr))))) {
+ ((af->clrf & AF_SAFE) &&
+ Can_Write_Attr_Ignore_Safe(player, thing, AL_ATTR(atr))))) {
notify_format(player, T("You cannot change that flag on %s/%s"),
- Name(thing), AL_NAME(atr));
+ Name(thing), AL_NAME(atr));
return 0;
}
AL_FLAGS(atr) &= ~af->clrf;
if (!AreQuiet(player, thing))
notify_format(player, T("%s/%s - %s reset."), Name(thing), AL_NAME(atr),
- af->clrflags);
+ af->clrflags);
}
if (af->setf) {
AL_FLAGS(atr) |= af->setf;
if (!AreQuiet(player, thing))
notify_format(player, T("%s/%s - %s set."), Name(thing), AL_NAME(atr),
- af->setflags);
+ af->setflags);
}
return 1;
return;
if (!Can_Write_Attr(player, target, AL_ATTR(atr))) {
notify_format(player,
- T("You cannot set attrib flags on %s/%s"), Name(target),
- AL_NAME(atr));
+ T("You cannot set attrib flags on %s/%s"), Name(target),
+ AL_NAME(atr));
return;
}
AL_FLAGS(atr) = flags;
*/
void
do_attrib_flags(dbref player, const char *obj, const char *atrname,
- const char *flag)
+ const char *flag)
{
struct af_args af;
dbref thing;
strcpy(tbuf1, newpair[i]);
q = strchr(tbuf1, '/');
if (!q || !*q) {
- q = (char *) AL_NAME(a);
+ q = (char *) AL_NAME(a);
} else {
- *q++ = '\0';
+ *q++ = '\0';
}
newobj = noisy_match_result(player, tbuf1, NOTYPE, MAT_EVERYTHING);
if (GoodObject(newobj) &&
- ((newobj != oldobj) || strcasecmp(AL_NAME(a), q)) &&
- do_set_atr(newobj, q, text, player, 1))
- copies++;
+ ((newobj != oldobj) || strcasecmp(AL_NAME(a), q)) &&
+ do_set_atr(newobj, q, text, player, 1))
+ copies++;
/* copy the attribute flags too */
if (!noflagcopy)
- copy_attrib_flags(player, newobj,
- atr_get_noparent(newobj, strupper(q)), a->flags);
+ copy_attrib_flags(player, newobj,
+ atr_get_noparent(newobj, strupper(q)), a->flags);
}
}
- free((Malloc_t) text); /* safe_uncompress malloc()s memory */
+ free((Malloc_t) text); /* safe_uncompress malloc()s memory */
if (copies) {
notify_format(player, T("Attribute %s (%d copies)"),
- (move ? "moved" : "copied"), copies);
+ (move ? "moved" : "copied"), copies);
if (move)
do_set_atr(oldobj, AL_NAME(a), NULL, player, 1);
} else {
notify_format(player, T("Unable to %s attribute."),
- (move ? "move" : "copy"));
+ (move ? "move" : "copy"));
}
return;
}
static int
gedit_helper(dbref player, dbref thing,
- dbref parent __attribute__ ((__unused__)),
- char const *pattern
- __attribute__ ((__unused__)), ATTR *a, void *args)
+ dbref parent __attribute__ ((__unused__)),
+ char const *pattern
+ __attribute__ ((__unused__)), ATTR *a, void *args)
{
int ansi_long_flag = 0;
const char *r;
tbufp = tbuf1;
tbufap = tbuf_ansi;
- if (!a) { /* Shouldn't ever happen, but better safe than sorry */
+ if (!a) { /* Shouldn't ever happen, but better safe than sorry */
notify(player, T("No such attribute, try set instead."));
return 0;
}
notify(player, T("You need to control an attribute to edit it."));
return 0;
}
- s = (char *) atr_value(a); /* warning: pointer to static buffer */
+ s = (char *) atr_value(a); /* warning: pointer to static buffer */
if (vlen == 1 && *val == '$') {
/* append */
safe_str(r, tbuf1, &tbufp);
if (safe_format(tbuf_ansi, &tbufap, "%s%s%s%s", s, ANSI_HILITE, r,
- ANSI_NORMAL))
+ ANSI_NORMAL))
ansi_long_flag = 1;
} else if (vlen == 1 && *val == '^') {
/* prepend */
safe_str(s, tbuf1, &tbufp);
if (safe_format(tbuf_ansi, &tbufap, "%s%s%s%s", ANSI_HILITE, r, ANSI_NORMAL,
- s))
+ s))
ansi_long_flag = 1;
} else if (!*val) {
/* insert replacement string between every character */
/* Add one at the start */
if (!safe_strl(r, rlen, tbuf1, &tbufp)) {
if (gargs->target != EDIT_FIRST) {
- for (last = 0; last < haystack->len; last++) {
- /* Add the next character */
- if (safe_ansi_string(haystack, last, 1, tbuf1, &tbufp)) {
- too_long = 1;
- break;
- }
- if (!ansi_long_flag) {
- if (safe_ansi_string(haystack, last, 1, tbuf_ansi, &tbufap))
- ansi_long_flag = 1;
- }
- /* Copy in r */
- if (safe_strl(r, rlen, tbuf1, &tbufp)) {
- too_long = 1;
- break;
- }
- if (!ansi_long_flag) {
- if (safe_format(tbuf_ansi, &tbufap, "%s%s%s", ANSI_HILITE, r,
- ANSI_NORMAL))
- ansi_long_flag = 1;
- }
- }
+ for (last = 0; last < haystack->len; last++) {
+ /* Add the next character */
+ if (safe_ansi_string(haystack, last, 1, tbuf1, &tbufp)) {
+ too_long = 1;
+ break;
+ }
+ if (!ansi_long_flag) {
+ if (safe_ansi_string(haystack, last, 1, tbuf_ansi, &tbufap))
+ ansi_long_flag = 1;
+ }
+ /* Copy in r */
+ if (safe_strl(r, rlen, tbuf1, &tbufp)) {
+ too_long = 1;
+ break;
+ }
+ if (!ansi_long_flag) {
+ if (safe_format(tbuf_ansi, &tbufap, "%s%s%s", ANSI_HILITE, r,
+ ANSI_NORMAL))
+ ansi_long_flag = 1;
+ }
+ }
}
}
free_ansi_string(haystack);
haystack = parse_ansi_string(s);
while (last < haystack->len
- && (p = strstr(haystack->text + last, val)) != NULL) {
+ && (p = strstr(haystack->text + last, val)) != NULL) {
if (safe_ansi_string(haystack, last, p - (haystack->text + last),
- tbuf1, &tbufp)) {
- too_long = 1;
- break;
+ tbuf1, &tbufp)) {
+ too_long = 1;
+ break;
}
if (!ansi_long_flag) {
- if (safe_ansi_string(haystack, last, p - (haystack->text + last),
- tbuf_ansi, &tbufap))
- ansi_long_flag = 1;
+ if (safe_ansi_string(haystack, last, p - (haystack->text + last),
+ tbuf_ansi, &tbufap))
+ ansi_long_flag = 1;
}
/* Copy in r */
if (safe_strl(r, rlen, tbuf1, &tbufp)) {
- too_long = 1;
- break;
+ too_long = 1;
+ break;
}
if (!ansi_long_flag) {
- if (safe_format(tbuf_ansi, &tbufap, "%s%s%s", ANSI_HILITE, r,
- ANSI_NORMAL))
- ansi_long_flag = 1;
+ if (safe_format(tbuf_ansi, &tbufap, "%s%s%s", ANSI_HILITE, r,
+ ANSI_NORMAL))
+ ansi_long_flag = 1;
}
last = p - haystack->text + vlen;
if (gargs->target == EDIT_FIRST)
- break;
+ break;
}
if (last < haystack->len && !too_long) {
safe_ansi_string(haystack, last, haystack->len, tbuf1, &tbufp);
if (!ansi_long_flag) {
- if (safe_ansi_string(haystack, last, haystack->len, tbuf_ansi, &tbufap))
- ansi_long_flag = 1;
+ if (safe_ansi_string(haystack, last, haystack->len, tbuf_ansi, &tbufap))
+ ansi_long_flag = 1;
}
}
free_ansi_string(haystack);
if (gargs->doit) {
if (do_set_atr(thing, AL_NAME(a), tbuf1, player, 0) &&
- !AreQuiet(player, thing)) {
+ !AreQuiet(player, thing)) {
if (!ansi_long_flag && ShowAnsi(player))
- notify_format(player, "%s - Set: %s", AL_NAME(a), tbuf_ansi);
+ notify_format(player, "%s - Set: %s", AL_NAME(a), tbuf_ansi);
else
- notify_format(player, "%s - Set: %s", AL_NAME(a), tbuf1);
+ notify_format(player, "%s - Set: %s", AL_NAME(a), tbuf1);
}
} else {
/* We don't do it - we just pemit it. */
/* trigger modifies the stack */
for (a = 0; a < 10; a++) {
if(!argv[a+1])
- break;
+ break;
global_eval_context.wnxt[a] = argv[a + 1];
}
while(a < 10)
- global_eval_context.wnxt[a++] = NULL;
+ global_eval_context.wnxt[a++] = NULL;
if (charge_action(player, thing, upcasestr(s))) {
if (!AreQuiet(player, thing))
if ((thing =
noisy_match_result(player, what, TYPE_THING,
- MAT_NEAR_THINGS)) != NOTHING) {
+ MAT_NEAR_THINGS)) != NOTHING) {
if (!eval_lock(player, thing, Use_Lock)) {
fail_lock(player, thing, Use_Lock, T("Permission denied."), NOTHING);
return;
if (!parent_name || !*parent_name || !strcasecmp(parent_name, "none"))
parent = NOTHING;
else if ((parent = noisy_match_result(player, parent_name, NOTYPE,
- MAT_EVERYTHING)) == NOTHING)
+ MAT_EVERYTHING)) == NOTHING)
return;
/* do control check */
notify(player, "You can't only @parent the master division.");
return;
} else {
- /* this is a master division */
+ /* this is a master division */
/* check parent recursion.. for a division */
for(i = 0, check = parent; i < MAX_PARENTS && check != NOTHING
- ; i++ , check = Parent(check))
- if(IsDivision(check)) {
- notify(player, T("A division is not allowed to be in your parent tree."));
- return;
- }
+ ; i++ , check = Parent(check))
+ if(IsDivision(check)) {
+ notify(player, T("A division is not allowed to be in your parent tree."));
+ return;
+ }
}
}
if (parent != NOTHING) {
for (i = 0, check = Parent(parent);
- (i < MAX_PARENTS) && (check != NOTHING); i++, check = Parent(check)) {
+ (i < MAX_PARENTS) && (check != NOTHING); i++, check = Parent(check)) {
if (check == thing) {
- notify(player, T("You are not allowed to be your own ancestor!"));
- return;
+ notify(player, T("You are not allowed to be your own ancestor!"));
+ return;
}
}
if (i >= MAX_PARENTS) {
return;
}
if (Owner(parent) != Owner(thing)
- && !has_flag_by_name(parent, "AUTH_PARENT", NOTYPE)) {
+ && !has_flag_by_name(parent, "AUTH_PARENT", NOTYPE)) {
notify(player, T("Warning: Parent and child are owned by different players and parent is not set AUTH_PARENT."));
}
}
* attr still works, though.
*/
if (wildcard(pattern) && (AL_FLAGS(atr) & AF_PRIVILEGE) && !Director(player))
- return 0;
+ return 0;
return do_set_atr(thing, AL_NAME(atr), NULL, player, 0) == 1;
}
/* The SHS f() functions */
-#define f1(x, y, z) ( (x & y) | (~x & z) ) /* rounds 0-19 */
-#define f2(x, y, z) ( x ^ y ^ z ) /* rounds 20-39 */
-#define f3(x, y, z) ( (x & y) | (x & z) | (y & z) ) /* rounds 40-59 */
-#define f4(x, y, z) ( x ^ y ^ z ) /* rounds 60-79 */
+#define f1(x, y, z) ( (x & y) | (~x & z) ) /* rounds 0-19 */
+#define f2(x, y, z) ( x ^ y ^ z ) /* rounds 20-39 */
+#define f3(x, y, z) ( (x & y) | (x & z) | (y & z) ) /* rounds 40-59 */
+#define f4(x, y, z) ( x ^ y ^ z ) /* rounds 60-79 */
/* The SHS mysterious constants */
LONG h0, h1, h2, h3, h4;
LONG A, B, C, D, E;
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/* Initialise the SHS values */
shsInfo->digest[3] += D;
shsInfo->digest[4] += E;
-} /* end of shsTransform */
+} /* end of shsTransform */
static void byteReverse(LONG * buffer, int byteCount);
static void
value = (buffer[count] << 16) | (buffer[count] >> 16);
buffer[count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8);
}
-} /* end of byteReverse */
+} /* end of byteReverse */
/** Update SHS for a block of data. This code assumes that the buffer
/* Update bitcount */
if ((shsInfo->countLo + ((LONG) count << 3)) < shsInfo->countLo)
- shsInfo->countHi++; /* Carry from low to high bitcount */
+ shsInfo->countHi++; /* Carry from low to high bitcount */
shsInfo->countLo += ((LONG) count << 3);
shsInfo->countHi += ((LONG) count >> 29);
shsTransform(shsInfo);
buffer += SHS_BLOCKSIZE;
count -= SHS_BLOCKSIZE;
- } /* end of looping processing each chunk */
+ } /* end of looping processing each chunk */
/* Handle any remaining bytes of data. This should only happen once on the final lot of data */
byteReverse(shsInfo->data, SHS_DIGESTSIZE);
}
-#endif /* HAS_OPENSSL */
+#endif /* HAS_OPENSSL */
if (sigaction(signo, &act, &oact) < 0)
return SIG_ERR;
return oact.sa_handler;
-#else /* No sigaction, drat. */
+#else /* No sigaction, drat. */
return signal(signo, func);
#endif
}
*/
void
reload_sig_handler(int signo __attribute__ ((__unused__)),
- Sigfunc func __attribute__ ((__unused__)))
+ Sigfunc func __attribute__ ((__unused__)))
{
#if !(defined(HAS_SIGACTION) || defined(SIGNALS_KEPT))
signal(signo, func);
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(signo, &act, NULL);
-#else /* No sigaction, drat. */
+#else /* No sigaction, drat. */
signal(signo, SIG_IGN);
#endif
}
static dbref speech_loc(dbref thing);
void propagate_sound(dbref thing, const char *msg);
static void do_audible_stuff(dbref loc, dbref *excs, int numexcs,
- const char *msg);
+ const char *msg);
static void do_one_remit(dbref player, const char *target, const char *msg,
- int flags);
+ int flags);
static int dbref_comp(const void *a, const void *b);
dbref na_zemit(dbref current, void *data);
return;
}
- recurse = 1; /* Protect use from recursive teach */
+ recurse = 1; /* Protect use from recursive teach */
notify_except(Contents(loc), NOTHING,
- tprintf(T("%s types --> %s%s%s"), spname(player),
- ANSI_HILITE, tbuf1, ANSI_NORMAL), NA_INTER_HEAR);
- command = mush_strdup(tbuf1, "string"); /* process_command is destructive */
+ tprintf(T("%s types --> %s%s%s"), spname(player),
+ ANSI_HILITE, tbuf1, ANSI_NORMAL), NA_INTER_HEAR);
+ command = mush_strdup(tbuf1, "string"); /* process_command is destructive */
process_command(player, command, cause, cause, 1);
mush_free(command, "string");
- recurse = 0; /* Ok, we can be called again safely */
+ recurse = 0; /* Ok, we can be called again safely */
}
/** The say command.
/* notify everybody */
notify_format(player, T("You say, \"%s\""), tbuf1);
notify_except(Contents(loc), player,
- tprintf(T("%s says, \"%s\""), spname(player), tbuf1),
- NA_INTER_HEAR);
+ tprintf(T("%s says, \"%s\""), spname(player), tbuf1),
+ NA_INTER_HEAR);
}
/** A comparator for raw dbrefs.
return;
}
- oneloc = 1; /* we are only oemitting to one location */
+ oneloc = 1; /* we are only oemitting to one location */
} else {
temp = list;
}
* locs[0..10] are corresponding dbrefs of locations
*/
if (GoodObject(who) && GoodObject(Location(who))
- && (CanSpeak(player, Location(who)))
+ && (CanSpeak(player, Location(who)))
) {
if (pass[0] < 10) {
- locs[pass[0]] = Location(who);
- pass[pass[0] + 2] = who;
- pass[0]++;
+ locs[pass[0]] = Location(who);
+ pass[pass[0] + 2] = who;
+ pass[0]++;
} else {
- notify(player, T("Too many people to oemit to."));
- break;
+ notify(player, T("Too many people to oemit to."));
+ break;
}
}
}
continue;
pass[1] = locs[i];
notify_anything_loc(orator, na_exceptN, pass, ns_esnotify, na_flags,
- message, locs[i]);
+ message, locs[i]);
do_audible_stuff(pass[1], &pass[2], pass[0], message);
}
}
while (head && *head) {
current = next_in_list(start);
who = match_result(player, current, TYPE_PLAYER, MAT_NEAR_THINGS |
- MAT_CONTAINER );
+ MAT_CONTAINER );
if (!GoodObject(who) || !can_interact(player, who, INTERACT_HEAR)) {
safe_chr(' ', tbuf, &tp);
safe_str_space(current, tbuf, &tp);
if (GoodObject(who))
- notify_format(player, T("%s can't hear you."), Name(who));
+ notify_format(player, T("%s can't hear you."), Name(who));
} else {
/* A good whisper */
good[gcount++] = who;
if (gcount >= 100) {
- notify(player, T("Too many people to whisper to."));
- break;
+ notify(player, T("Too many people to whisper to."));
+ break;
}
}
}
if (key == 1) {
notify_format(player, (gcount > 1) ? T("%s sense: %s%s%s") :
- T("%s senses: %s%s%s"), tbuf + 4, Name(player), gap, arg2);
+ T("%s senses: %s%s%s"), tbuf + 4, Name(player), gap, arg2);
p = tprintf("You sense: %s%s%s", Name(player), gap, arg2);
} else {
notify_format(player, T("You whisper, \"%s\"%s."), arg2, tbuf);
p = tprintf("%s whispers%s: %s", Name(player),
- gcount > 1 ? tbuf : "", arg2);
+ gcount > 1 ? tbuf : "", arg2);
}
for (who = 0; who < gcount; who++) {
DOLIST(first, first) {
overheard = 1;
for (who = 0; who < gcount; who++) {
- if ((first == player) || (first == good[who])) {
- overheard = 0;
- break;
- }
+ if ((first == player) || (first == good[who])) {
+ overheard = 0;
+ break;
+ }
}
if (overheard)
- notify_noecho(first, p);
+ notify_noecho(first, p);
}
}
mush_free((Malloc_t) tbuf, "string");
who = noisy_match_result(player, p, NOTYPE, MAT_PLAYER | MAT_ABSOLUTE);
if (GoodObject(who) && okay_pemit(player, who)) {
if (nospoof && Nospoof(who)) {
- if (Paranoid(who)) {
- if (!nspbuf) {
- bp = nspbuf = mush_malloc(BUFFER_LEN, "string");
- if (player == Owner(player))
- safe_format(nspbuf, &bp, "[%s(#%d)->] %s", Name(player),
- player, message);
- else
- safe_format(nspbuf, &bp, "[%s(#%d)'s %s(#%d)->] %s",
- Name(Owner(player)), Owner(player),
- Name(player), player, message);
- *bp = '\0';
- }
- notify(who, nspbuf);
- } else {
- if (!nsbuf) {
- bp = nsbuf = mush_malloc(BUFFER_LEN, "string");
- safe_format(nsbuf, &bp, "[%s->] %s", Name(player), message);
- *bp = '\0';
- }
- notify(who, nsbuf);
- }
+ if (Paranoid(who)) {
+ if (!nspbuf) {
+ bp = nspbuf = mush_malloc(BUFFER_LEN, "string");
+ if (player == Owner(player))
+ safe_format(nspbuf, &bp, "[%s(#%d)->] %s", Name(player),
+ player, message);
+ else
+ safe_format(nspbuf, &bp, "[%s(#%d)'s %s(#%d)->] %s",
+ Name(Owner(player)), Owner(player),
+ Name(player), player, message);
+ *bp = '\0';
+ }
+ notify(who, nspbuf);
+ } else {
+ if (!nsbuf) {
+ bp = nsbuf = mush_malloc(BUFFER_LEN, "string");
+ safe_format(nsbuf, &bp, "[%s->] %s", Name(player), message);
+ *bp = '\0';
+ }
+ notify(who, nsbuf);
+ }
} else {
- notify_must_puppet(who, message);
+ notify_must_puppet(who, message);
}
}
}
nospoof = (flags & PEMIT_SPOOF) ? 0 : 1;
switch (who = match_result(player, arg1, NOTYPE,
- MAT_OBJECTS | MAT_HERE | MAT_CONTAINER)) {
+ MAT_OBJECTS | MAT_HERE | MAT_CONTAINER)) {
case NOTHING:
notify(player, T("I don't see that here."));
break;
default:
if (!okay_pemit(player, who)) {
notify_format(player,
- T("I'm sorry, but %s wishes to be left alone now."),
- Name(who));
+ T("I'm sorry, but %s wishes to be left alone now."),
+ Name(who));
return;
}
if (!silent)
notify_format(player, T("You pemit \"%s\" to %s."), arg2, Name(who));
if (nospoof && Nospoof(who)) {
if (Paranoid(who)) {
- if (player == Owner(player))
- notify_format(who, "[%s(#%d)->%s] %s", Name(player), player,
- Name(who), arg2);
- else
- notify_format(who, "[%s(#%d)'s %s(#%d)->%s] %s",
- Name(Owner(player)), Owner(player),
- Name(player), player, Name(who), arg2);
+ if (player == Owner(player))
+ notify_format(who, "[%s(#%d)->%s] %s", Name(player), player,
+ Name(who), arg2);
+ else
+ notify_format(who, "[%s(#%d)'s %s(#%d)->%s] %s",
+ Name(Owner(player)), Owner(player),
+ Name(player), player, Name(who), arg2);
} else
- notify_format(who, "[%s->%s] %s", Name(player), Name(who), arg2);
+ notify_format(who, "[%s->%s] %s", Name(player), Name(who), arg2);
} else {
notify_must_puppet(who, arg2);
}
/* notify everybody */
if (!space)
notify_except(Contents(loc), NOTHING,
- tprintf("%s %s", spname(player), tbuf1), NA_INTER_HEAR);
+ tprintf("%s %s", spname(player), tbuf1), NA_INTER_HEAR);
else
notify_except(Contents(loc), NOTHING,
- tprintf("%s%s", spname(player), tbuf1), NA_INTER_HEAR);
+ tprintf("%s%s", spname(player), tbuf1), NA_INTER_HEAR);
}
/** The *wall commands.
switch (*message) {
case SAY_TOKEN:
if (CHAT_STRIP_QUOTE)
- message++;
+ message++;
break;
case SEMI_POSE_TOKEN:
gap = "";
flag_broadcast(mask, 0, "%s [%s]: %s", prefix, Name(player), message);
else
flag_broadcast(mask, 0,
- "%s %s %s, \"%s\"", prefix, Name(player),
- target == WALL_ALL ? "shouts" : "says", message);
+ "%s %s %s, \"%s\"", prefix, Name(player),
+ target == WALL_ALL ? "shouts" : "says", message);
}
/** The page command.
*/
void
do_page(dbref player, const char *arg1, const char *arg2, dbref cause,
- int noeval, int multipage, int override, int has_eq)
+ int noeval, int multipage, int override, int has_eq)
{
dbref target;
const char *message;
if (*arg1 && has_eq) {
/* page to=[msg]. Always evaluate to, maybe evaluate msg */
process_expression(tbuf2, &tp2, &arg1, player, cause, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*tp2 = '\0';
head = tbuf2;
message = arg2;
notify_format(player, T("You last paged %s."), head);
mush_free((Malloc_t) tbuf2, "string");
if (hp)
- free((Malloc_t) hp);
+ free((Malloc_t) hp);
return;
}
}
target = short_page(current);
if (target == NOTHING) {
notify_format(player,
- T("I can't find who you're trying to page with: %s"),
- current);
+ T("I can't find who you're trying to page with: %s"),
+ current);
safe_chr(' ', tbuf, &tp);
safe_str_space(current, tbuf, &tp);
} else if (target == AMBIGUOUS) {
notify_format(player,
- T("I'm not sure who you want to page with: %s"), current);
+ T("I'm not sure who you want to page with: %s"), current);
safe_chr(' ', tbuf, &tp);
safe_str_space(current, tbuf, &tp);
} else {
fails_lock = !(override || eval_lock(player, target, Page_Lock));
is_haven = !override && Haven(target);
if (!Connected(target) || (Dark(target) && (is_haven || fails_lock))) {
- /* A player isn't connected if they aren't connected, or if
- * they're DARK and HAVEN, or DARK and the pagelock fails. */
- page_return(player, target, "Away", "AWAY",
- tprintf(T("%s is not connected."), Name(target)));
- if (fails_lock)
- fail_lock(player, target, Page_Lock, NULL, NOTHING);
- safe_chr(' ', tbuf, &tp);
- safe_str_space(current, tbuf, &tp);
+ /* A player isn't connected if they aren't connected, or if
+ * they're DARK and HAVEN, or DARK and the pagelock fails. */
+ page_return(player, target, "Away", "AWAY",
+ tprintf(T("%s is not connected."), Name(target)));
+ if (fails_lock)
+ fail_lock(player, target, Page_Lock, NULL, NOTHING);
+ safe_chr(' ', tbuf, &tp);
+ safe_str_space(current, tbuf, &tp);
#ifdef RPMODE_SYS
} else if(RPMODE(player) && LEVEL(target) < 23) {
- notify(player, "You can't do that in RPMODE.");
- safe_chr(' ', tbuf, &tp);
- safe_str_space(Name(target), tbuf, &tp);
+ notify(player, "You can't do that in RPMODE.");
+ safe_chr(' ', tbuf, &tp);
+ safe_str_space(Name(target), tbuf, &tp);
#endif
} else if (is_haven) {
- page_return(player, target, "Haven", "HAVEN",
- tprintf(T("%s is not accepting any pages."), Name(target)));
- safe_chr(' ', tbuf, &tp);
- safe_str_space(Name(target), tbuf, &tp);
+ page_return(player, target, "Haven", "HAVEN",
+ tprintf(T("%s is not accepting any pages."), Name(target)));
+ safe_chr(' ', tbuf, &tp);
+ safe_str_space(Name(target), tbuf, &tp);
} else if (fails_lock) {
- page_return(player, target, "Haven", "HAVEN",
- tprintf(T("%s is not accepting your pages."),
- Name(target)));
- fail_lock(player, target, Page_Lock, NULL, NOTHING);
- safe_chr(' ', tbuf, &tp);
- safe_str_space(Name(target), tbuf, &tp);
+ page_return(player, target, "Haven", "HAVEN",
+ tprintf(T("%s is not accepting your pages."),
+ Name(target)));
+ fail_lock(player, target, Page_Lock, NULL, NOTHING);
+ safe_chr(' ', tbuf, &tp);
+ safe_str_space(Name(target), tbuf, &tp);
} else if(RPMODE(target) && LEVEL(player) < 23 && LEVEL(target) < 23 ) {
- page_return(player, target,
- "RPMode", "RPMODE",
- tprintf(T("%s is in RPMode and can not communicate OOCly at this moment."), Name(target)));
- safe_chr(' ', tbuf , &tp);
- safe_str_space(current, tbuf, &tp);
- } else if(hidden(target) && !CanSee(player,target)){
- /* this is a page that appears bad, but is good */
- page_return(player, target, "Away", "AWAY",
- tprintf(T("%s is not connected."), Name(target)));
- safe_chr(' ', tbuf, &tp);
- safe_str_space(current, tbuf, &tp);
+ page_return(player, target,
+ "RPMode", "RPMODE",
+ tprintf(T("%s is in RPMode and can not communicate OOCly at this moment."), Name(target)));
+ safe_chr(' ', tbuf , &tp);
+ safe_str_space(current, tbuf, &tp);
+ } else if(hidden(target) && !CanSee(player,target)){
+ /* this is a page that appears bad, but is good */
+ page_return(player, target, "Away", "AWAY",
+ tprintf(T("%s is not connected."), Name(target)));
+ safe_chr(' ', tbuf, &tp);
+ safe_str_space(current, tbuf, &tp);
almost_good[ag_count] = target;
ag_count++;
} else {
- /* This is a good page */
- good[gcount] = target;
- gcount++;
+ /* This is a good page */
+ good[gcount] = target;
+ gcount++;
}
}
}
mush_panic("Unable to allocate memory in do_page");
process_expression(msgbuf, &mb, &message, player, cause, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*mb = '\0';
message = msgbuf;
}
if(gcount > 0) {
if (key == 1)
notify_format(player, T("Long distance to %s%s: %s%s%s"),
- ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2,
- Name(player), gap, message);
+ ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2,
+ Name(player), gap, message);
else
notify_format(player, T("You paged %s%s with '%s'"),
- ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2,
- message);
+ ((gcount > 1) && (!multipage)) ? "(blind) " : "", tbuf2,
+ message);
}
/* Figure out the 'name' of the player */
for (i = 0; i < (gcount+ag_count); i++) {
if(i >= gcount || gcount == 0)
- gptr = almost_good + (i-gcount);
+ gptr = almost_good + (i-gcount);
else
- gptr = good + i;
+ gptr = good + i;
if (!IsPlayer(player) && Nospoof((dbref)*gptr))
notify_format((dbref)*gptr, "[#%d] %s%s", player,(i >= gcount || gcount == 0) ? "Hidden Receive>": "" , tbuf);
char *filter;
ATTR *a;
char *p, *bp;
- char *temp; /* need this so we don't leak memory
- * by failing to free the storage
- * allocated by safe_uncompress
- */
+ char *temp; /* need this so we don't leak memory
+ * by failing to free the storage
+ * allocated by safe_uncompress
+ */
int i;
int matched = 0;
for (i = 0; (i < MAX_ARG) && !matched; i++) {
p = bp = filter;
process_expression(p, &bp, (char const **) &filter, 0, 0, 0,
- PE_NOTHING, PT_COMMA, NULL);
+ PE_NOTHING, PT_COMMA, NULL);
if (*filter == ',')
*filter++ = '\0';
- if (*p == '\0' && *filter == '\0') /* No more filters */
+ if (*p == '\0' && *filter == '\0') /* No more filters */
break;
- if (*p == '\0') /* Empty filter */
+ if (*p == '\0') /* Empty filter */
continue;
if (AF_Regexp(a))
matched = quick_regexp_match(p, msg, AF_Case(a));
asave = safe_atr_value(a);
ap = asave;
process_expression(tbuf1, &bp, &ap, thing, orator, orator,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
free((Malloc_t) asave);
restore_global_regs("prefix_save", preserve);
for (j = 0; j < 10; j++)
if (IsExit(thing)) {
notify_anything(orator, na_next, &Contents(loc), NULL, NA_INTER_HEAR,
- tbuf1);
+ tbuf1);
} else {
pass[0] = Contents(loc);
pass[1] = thing;
if (IsRoom(loc)) {
DOLIST(e, Exits(loc)) {
if (Audible(e))
- propagate_sound(e, msg);
+ propagate_sound(e, msg);
}
} else {
for (i = 0; i < numexcs; i++)
if (*(excs + i) == loc)
- exclude = 1;
+ exclude = 1;
if (!exclude)
propagate_sound(loc, msg);
}
notify(player, T("There can't be anything in that!"));
} else if (!okay_pemit(player, room)) {
notify_format(player,
- T("I'm sorry, but %s wishes to be left alone now."),
- Name(room));
+ T("I'm sorry, but %s wishes to be left alone now."),
+ Name(room));
} else if (!CanSpeak(player,room)) {
notify(player, T("You may not speak there!"));
} else {
if (!(flags & PEMIT_SILENT) && (Location(player) != room)) {
- const char *rmno;
- rmno = unparse_object(player, room);
- notify_format(player, T("You remit, \"%s\" in %s"), msg, rmno);
+ const char *rmno;
+ rmno = unparse_object(player, room);
+ notify_format(player, T("You remit, \"%s\" in %s"), msg, rmno);
}
if (flags & PEMIT_SPOOF)
- na_flags |= NA_SPOOF;
+ na_flags |= NA_SPOOF;
notify_anything_loc(player, na_loc, &room, ns_esnotify, na_flags,
- msg, room);
+ msg, room);
do_audible_stuff(room, NULL, 0, msg);
}
}
if (((room = Location(player)) == player) || !GoodObject(room)) {
notify(player, T("Invalid container object."));
do_rawlog(LT_ERR, T("** BAD CONTAINER ** #%d is inside #%d."), player,
- room);
+ room);
return;
}
while (!IsRoom(room) && (rec < 15)) {
do {
if (this == NOTHING) {
for (room = dbrefs[1]; room < db_top; room++) {
- if (IsRoom(room) && (Zone(room) == dbrefs[2])
- && CanSpeak(dbrefs[3], room))
- break;
+ if (IsRoom(room) && (Zone(room) == dbrefs[2])
+ && CanSpeak(dbrefs[3], room))
+ break;
}
if (!(room < db_top))
- return NOTHING;
+ return NOTHING;
this = room;
dbrefs[1] = room + 1;
} else if (IsRoom(this)) {
}
void sql_startup() {
- sql_init();
+ sql_init();
- /* Delete All Entries in Auth_T Table to start with */
- if(mysql_struct) mysql_query(mysql_struct, "DELETE FROM auth_t");
- sql_up = 1;
+ /* Delete All Entries in Auth_T Table to start with */
+ if(mysql_struct) mysql_query(mysql_struct, "DELETE FROM auth_t");
+ sql_up = 1;
#ifdef _SWMP_
- sql_env[0] = -1;
- sql_env[1] = -1;
+ sql_env[0] = -1;
+ sql_env[1] = -1;
#endif
}
mysql_struct = mysql_init(NULL);
if (!mysql_real_connect
- (mysql_struct, SQL_HOST, SQL_USER, SQL_PASS, SQL_DB, 3306, 0, 0)) {
- do_rawlog(LT_ERR, "Failed mysql connection: %s\n",
- mysql_error(mysql_struct));
- sql_shutdown();
- sleep(1);
+ (mysql_struct, SQL_HOST, SQL_USER, SQL_PASS, SQL_DB, 3306, 0, 0)) {
+ do_rawlog(LT_ERR, "Failed mysql connection: %s\n",
+ mysql_error(mysql_struct));
+ sql_shutdown();
+ sleep(1);
}
retries--;
}
strncpy(numbuff, unparse_integer(rownum), 20);
wenv[0] = numbuff;
for (i = 0; (i < numfields) && (i < 9); i++) {
- wenv[i + 1] = row_p[i];
+ wenv[i + 1] = row_p[i];
if (!wenv[i + 1])
- wenv[i + 1] = (char *) "";
+ wenv[i + 1] = (char *) "";
}
/* Now call the ufun. */
if (call_ufun(&ufun, wenv, i + 1, rbuff, executor, enactor, pe_info))
}
for (i = 0; i < numfields; i++) {
if (i > 0) {
- if (safe_str(fieldsep, buff, bp))
- goto finished;
+ if (safe_str(fieldsep, buff, bp))
+ goto finished;
}
if (row_p[i] && *row_p[i])
- if (safe_str(row_p[i], buff, bp))
- goto finished; /* We filled the buffer, best stop */
+ if (safe_str(row_p[i], buff, bp))
+ goto finished; /* We filled the buffer, best stop */
}
}
finished:
rownum++;
if (numfields > 0) {
for (i = 0; i < numfields; i++) {
- cell = row_p[i];
- notify_format(player, "Row %d, Field %s: %s",
- rownum, fields[i].name, (cell && *cell) ? cell : "NULL");
+ cell = row_p[i];
+ notify_format(player, "Row %d, Field %s: %s",
+ rownum, fields[i].name, (cell && *cell) ? cell : "NULL");
}
} else
notify_format(player, "Row %d: NULL", rownum);
#ifdef _SWMP_ /* SWM Protocol */
/* Do secondly checks on Authentication Table & Query Tables */
void sql_timer() {
- /* query variables */
- MYSQL_RES *qres, *qres2;
- MYSQL_ROW row_p, row_p2;
- int num_rows = 0 , got_rows = 0, got_fields = 0;
- int got_fields2 = 0, got_rows2 = 0;
- int i, j;
- char *str;
- char buf[BUFFER_LEN];
- dbref player;
-
- qres = NULL;
- qres2 = NULL;
-
- if(!sql_up || !GoodObject(SQLCMD_MasterRoom))
- return;
+ /* query variables */
+ MYSQL_RES *qres, *qres2;
+ MYSQL_ROW row_p, row_p2;
+ int num_rows = 0 , got_rows = 0, got_fields = 0;
+ int got_fields2 = 0, got_rows2 = 0;
+ int i, j;
+ char *str;
+ char buf[BUFFER_LEN];
+ dbref player;
+
+ qres = NULL;
+ qres2 = NULL;
+
+ if(!sql_up || !GoodObject(SQLCMD_MasterRoom))
+ return;
if(!mysql_struct) {
if((mudtime % 60) == 0) { /* If its down, try every minute to get it back up. */
sql_init();
- if(!mysql_struct)
- return;
- } else return;
+ if(!mysql_struct)
+ return;
+ } else return;
}
- /* Before we do anything lets delete old shit */
+ /* Before we do anything lets delete old shit */
mysql_query(mysql_struct, tprintf("DELETE FROM auth_t WHERE last < %d", mudtime-1800));
- /* We're connected.. Check Authentication Table */
- got_rows = mysql_query(mysql_struct, "SELECT * FROM auth_t WHERE authcode=0");
+ /* We're connected.. Check Authentication Table */
+ got_rows = mysql_query(mysql_struct, "SELECT * FROM auth_t WHERE authcode=0");
- if(got_rows != 0) {
- do_log(LT_ERR, 0, 0, "SQL-> (%s:%d) %s", __FILE__, __LINE__, mysql_error(mysql_struct));
- goto query_table;
- }
+ if(got_rows != 0) {
+ do_log(LT_ERR, 0, 0, "SQL-> (%s:%d) %s", __FILE__, __LINE__, mysql_error(mysql_struct));
+ goto query_table;
+ }
- qres = mysql_store_result(mysql_struct);
+ qres = mysql_store_result(mysql_struct);
if (qres == NULL) {
/* Oops, we should have had data! */
if(!mysql_field_count(mysql_struct))
- goto query_table;
+ goto query_table;
}
got_rows = mysql_num_rows(qres);
if(got_rows < 1)
- goto query_table;
+ goto query_table;
got_fields = mysql_num_fields(qres);
}
for(i = 0, row_p = mysql_fetch_row(qres) ; i < got_rows ; i++, row_p = mysql_fetch_row(qres)) {
- if((player = lookup_player(row_p[4])) == NOTHING ||
- !Site_Can_Connect((const char *) row_p[1],player ) ||
- !password_check(player, (const char *)row_p[5])) {
- /* Mark this row as bad auth, can't find user */
- j = -1;
- } else j = 1;
-
- if( mysql_query(mysql_struct,
- tprintf("UPDATE auth_t SET authcode=%d, pass=\"LOGGEDIN\", user=\"%d\" WHERE last = %d AND id = %d",
- j, player, atoi(row_p[3]), atoi(row_p[0]))) != 0)
- do_log(LT_ERR, 0, 0, "SQL-> (%s/%d) %s ", __FILE__, __LINE__, mysql_error(mysql_struct));
+ if((player = lookup_player(row_p[4])) == NOTHING ||
+ !Site_Can_Connect((const char *) row_p[1],player ) ||
+ !password_check(player, (const char *)row_p[5])) {
+ /* Mark this row as bad auth, can't find user */
+ j = -1;
+ } else j = 1;
+
+ if( mysql_query(mysql_struct,
+ tprintf("UPDATE auth_t SET authcode=%d, pass=\"LOGGEDIN\", user=\"%d\" WHERE last = %d AND id = %d",
+ j, player, atoi(row_p[3]), atoi(row_p[0]))) != 0)
+ do_log(LT_ERR, 0, 0, "SQL-> (%s/%d) %s ", __FILE__, __LINE__, mysql_error(mysql_struct));
}
qres = mysql_store_result(mysql_struct);
if(qres == NULL) {
- do_log(LT_ERR, 0 , 0, "SQL: Error(%s:%d): %s", __FILE__, __LINE__, mysql_error(mysql_struct));
- return;
+ do_log(LT_ERR, 0 , 0, "SQL: Error(%s:%d): %s", __FILE__, __LINE__, mysql_error(mysql_struct));
+ return;
}
got_rows = mysql_num_rows(qres);
if(got_rows < 1)
- goto st_finish;
+ goto st_finish;
got_fields = mysql_num_fields(qres);
if(!got_fields)
- goto st_finish;
+ goto st_finish;
if(got_fields < 4 || got_fields > 4) {
- do_log(LT_ERR, 0, 0, "SQL 'query_t' table %s fields.", got_fields < 4 ? "not enough" : "too many");
- goto st_finish;
+ do_log(LT_ERR, 0, 0, "SQL 'query_t' table %s fields.", got_fields < 4 ? "not enough" : "too many");
+ goto st_finish;
}
for(i = 0, row_p = mysql_fetch_row(qres); i < got_rows && row_p != NULL ; i++, row_p = mysql_fetch_row(qres)) {
- sql_env[0] = atoi(row_p[0]);
- sql_env[1] = atoi(row_p[1]);
- /* Load AUTHID we're assosciated with */
- got_rows2 = mysql_query(mysql_struct,
- tprintf("SELECT * FROM auth_t WHERE id = %d", atoi(row_p[1])));
- if(got_rows2 != 0) {
- /* Update Return Result As No Authorized user logged in */
- mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"%s\" WHERE id = %d", mysql_error(mysql_struct),atoi(row_p[0]) ));
- continue;
-
- }
- qres2 = mysql_store_result(mysql_struct);
-
- /* Not in auth_t table */
- if(qres2 == NULL) {
- mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"%s\" WHERE id = %d", mysql_error(mysql_struct), atoi(row_p[0]) ));
- continue;
- }
-
- got_rows2 = mysql_num_rows(qres2);
+ sql_env[0] = atoi(row_p[0]);
+ sql_env[1] = atoi(row_p[1]);
+ /* Load AUTHID we're assosciated with */
+ got_rows2 = mysql_query(mysql_struct,
+ tprintf("SELECT * FROM auth_t WHERE id = %d", atoi(row_p[1])));
+ if(got_rows2 != 0) {
+ /* Update Return Result As No Authorized user logged in */
+ mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"%s\" WHERE id = %d", mysql_error(mysql_struct),atoi(row_p[0]) ));
+ continue;
+
+ }
+ qres2 = mysql_store_result(mysql_struct);
+
+ /* Not in auth_t table */
+ if(qres2 == NULL) {
+ mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"%s\" WHERE id = %d", mysql_error(mysql_struct), atoi(row_p[0]) ));
+ continue;
+ }
+
+ got_rows2 = mysql_num_rows(qres2);
if(got_rows2 < 1) {
/* Update Return Result As No Authorized user logged in */
- mysql_free_result(qres2);
+ mysql_free_result(qres2);
mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"not logged in\" WHERE id = %d", atoi(row_p[0]) ));
continue;
}
- /* Fucked up auth_t Table*/
- if(got_rows > 1) {
- mysql_free_result(qres2);
- mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"ERROR: Identical User IDs logged in.\" WHERE id = %d", atoi(row_p[0]) ));
- continue;
- }
- row_p2 = mysql_fetch_row(qres2);
-
- player = atoi(row_p2[4]);
- /* They Aren't Real */
- if(!GoodObject(player) || !IsPlayer(player)) {
- mysql_free_result(qres2);
- mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"ERROR: NonExistent Player ID logged into.\" WHERE id = %d", atoi(row_p[0]) ));
- /* Delete Auth Table ID Entry , they shouldn't be there*/
- mysql_query(mysql_struct, tprintf("DELETE FROM auth_t WHERE user=\"%d\"", player));
- /* Delete Us Too */
- continue;
-
- }
-
- memset(buf, '\0', BUFFER_LEN);
- strncpy(buf, row_p[3], BUFFER_LEN-1);
- j = sqllist_check(Contents(SQLCMD_MasterRoom), player, '$', ':', buf, 0);
- if(j < 1) {
- mysql_free_result(qres2);
- mysql_query(mysql_struct, tprintf("UPDATE query_t SET query=\"-1\", io=0 WHERE id = %d", atoi(row_p[0]) ));
- continue;
- }
- mysql_free_result(qres2);
-
- sql_env[0] = -1;
- sql_env[1] = -1;
+ /* Fucked up auth_t Table*/
+ if(got_rows > 1) {
+ mysql_free_result(qres2);
+ mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"ERROR: Identical User IDs logged in.\" WHERE id = %d", atoi(row_p[0]) ));
+ continue;
+ }
+ row_p2 = mysql_fetch_row(qres2);
+
+ player = atoi(row_p2[4]);
+ /* They Aren't Real */
+ if(!GoodObject(player) || !IsPlayer(player)) {
+ mysql_free_result(qres2);
+ mysql_query(mysql_struct, tprintf("UPDATE query_t SET io=0, query=\"ERROR: NonExistent Player ID logged into.\" WHERE id = %d", atoi(row_p[0]) ));
+ /* Delete Auth Table ID Entry , they shouldn't be there*/
+ mysql_query(mysql_struct, tprintf("DELETE FROM auth_t WHERE user=\"%d\"", player));
+ /* Delete Us Too */
+ continue;
+
+ }
+
+ memset(buf, '\0', BUFFER_LEN);
+ strncpy(buf, row_p[3], BUFFER_LEN-1);
+ j = sqllist_check(Contents(SQLCMD_MasterRoom), player, '$', ':', buf, 0);
+ if(j < 1) {
+ mysql_free_result(qres2);
+ mysql_query(mysql_struct, tprintf("UPDATE query_t SET query=\"-1\", io=0 WHERE id = %d", atoi(row_p[0]) ));
+ continue;
+ }
+ mysql_free_result(qres2);
+
+ sql_env[0] = -1;
+ sql_env[1] = -1;
}
sql_env[0] = -1;
sql_env[1] = -1;
if (atr_comm_match(thing, player, type, end, str, just_match, NULL, NULL, NULL))
match = 1;
else
- match = 0;
+ match = 0;
thing = Next(thing);
}
/* Do secondly checks on Authentication Table & Query Tables */
void sql_timer() {
- return;
+ return;
}
void
#include "confmagic.h"
#ifndef UCHAR_MAX
-#define UCHAR_MAX 255 /**< Largest unsigned character */
+#define UCHAR_MAX 255 /**< Largest unsigned character */
#endif
/* Various constants. Their import is either bleedingly obvious
* or explained below. */
-#define ST_MAX_DEPTH 64 /**< Max depth of the tree */
-#define ST_RED 1 /**< This node is red */
-#define ST_BLACK 0 /**< This node is black */
-#define ST_COLOR 1 /**< Bit mask for colors */
+#define ST_MAX_DEPTH 64 /**< Max depth of the tree */
+#define ST_RED 1 /**< This node is red */
+#define ST_BLACK 0 /**< This node is black */
+#define ST_COLOR 1 /**< Bit mask for colors */
#define ST_USE_STEP 2
#define ST_USE_LIMIT (UCHAR_MAX - ST_USE_STEP + 1)
*/
static StrNode *path[ST_MAX_DEPTH];
-unsigned long st_mem = 0; /**< Memory used by string trees */
+unsigned long st_mem = 0; /**< Memory used by string trees */
static void st_left_rotate(int tree_depth, StrNode **root);
static void st_right_rotate(int tree_depth, StrNode **root);
st_stats_header(dbref player)
{
notify(player,
- "Tree Entries Leaves MinDep Max Avg PermEnt AvgTmpC ~Memory");
+ "Tree Entries Leaves MinDep Max Avg PermEnt AvgTmpC ~Memory");
}
/** Statistics about the tree.
bytes = (sizeof(StrNode) - BUFFER_LEN) * root->count + root->mem;
st_traverse_stats(root->root, &maxdepth, &mindepth, &avgdepth, &leaves,
- &perms, &nperms);
+ &perms, &nperms);
notify_format(player, "%-10s %7ld %7d %6d %4d %4d %9lu %11.3f %7lu",
- name, root->count, leaves, mindepth, maxdepth,
- avgdepth, perms,
- ((double) nperms / (double) (root->count - perms)), bytes);
+ name, root->count, leaves, mindepth, maxdepth,
+ avgdepth, perms,
+ ((double) nperms / (double) (root->count - perms)), bytes);
}
/* Tree rotations. These preserve left-to-right ordering,
StrNode *y;
y = path[tree_depth - 1]->right;
if (y && (y->info & ST_COLOR) == ST_RED) {
- /* Hmph. Uncle is red. Push the mess up the tree. */
- path[tree_depth]->info &= ~ST_RED;
- y->info &= ~ST_RED;
- tree_depth--;
- path[tree_depth]->info |= ST_RED;
- tree_depth--;
+ /* Hmph. Uncle is red. Push the mess up the tree. */
+ path[tree_depth]->info &= ~ST_RED;
+ y->info &= ~ST_RED;
+ tree_depth--;
+ path[tree_depth]->info |= ST_RED;
+ tree_depth--;
} else {
- /* Okay, uncle is black. We can fix everything, now. */
- if (path[tree_depth + 1] == path[tree_depth]->right) {
- st_left_rotate(tree_depth, &root->root);
- path[tree_depth + 1]->info &= ~ST_RED;
- } else {
- path[tree_depth]->info &= ~ST_RED;
- }
- path[tree_depth - 1]->info |= ST_RED;
- st_right_rotate(tree_depth - 1, &root->root);
- break;
+ /* Okay, uncle is black. We can fix everything, now. */
+ if (path[tree_depth + 1] == path[tree_depth]->right) {
+ st_left_rotate(tree_depth, &root->root);
+ path[tree_depth + 1]->info &= ~ST_RED;
+ } else {
+ path[tree_depth]->info &= ~ST_RED;
+ }
+ path[tree_depth - 1]->info |= ST_RED;
+ st_right_rotate(tree_depth - 1, &root->root);
+ break;
}
} else {
StrNode *y;
y = path[tree_depth - 1]->left;
if (y && (y->info & ST_COLOR) == ST_RED) {
- /* Hmph. Uncle is red. Push the mess up the tree. */
- path[tree_depth]->info &= ~ST_RED;
- y->info &= ~ST_RED;
- tree_depth--;
- path[tree_depth]->info |= ST_RED;
- tree_depth--;
+ /* Hmph. Uncle is red. Push the mess up the tree. */
+ path[tree_depth]->info &= ~ST_RED;
+ y->info &= ~ST_RED;
+ tree_depth--;
+ path[tree_depth]->info |= ST_RED;
+ tree_depth--;
} else {
- /* Okay, uncle is black. We can fix everything, now. */
- if (path[tree_depth + 1] == path[tree_depth]->left) {
- st_right_rotate(tree_depth, &root->root);
- path[tree_depth + 1]->info &= ~ST_RED;
- } else {
- path[tree_depth]->info &= ~ST_RED;
- }
- path[tree_depth - 1]->info |= ST_RED;
- st_left_rotate(tree_depth - 1, &root->root);
- break;
+ /* Okay, uncle is black. We can fix everything, now. */
+ if (path[tree_depth + 1] == path[tree_depth]->left) {
+ st_right_rotate(tree_depth, &root->root);
+ path[tree_depth + 1]->info &= ~ST_RED;
+ } else {
+ path[tree_depth]->info &= ~ST_RED;
+ }
+ path[tree_depth - 1]->info |= ST_RED;
+ st_left_rotate(tree_depth - 1, &root->root);
+ break;
}
}
}
if ((y->info & ST_COLOR) == ST_BLACK) {
while (x != root->root && (!x || (x->info & ST_COLOR) == ST_BLACK)) {
if (x == path[tree_depth - 1]->left) {
- StrNode *w = path[tree_depth - 1]->right;
- assert(w);
- if (w && (w->info & ST_COLOR) == ST_RED) {
- w->info &= ~ST_RED;
- path[tree_depth - 1]->info |= ST_RED;
- st_left_rotate(tree_depth - 1, &root->root);
- path[tree_depth] = path[tree_depth - 1];
- path[tree_depth - 1] = w;
- tree_depth++;
- w = path[tree_depth - 1]->right;
- assert(w);
- }
- assert((w->info & ST_COLOR) == ST_BLACK);
- if ((!w->left || (w->left->info & ST_COLOR) == ST_BLACK) &&
- (!w->right || (w->right->info & ST_COLOR) == ST_BLACK)) {
- w->info |= ST_RED;
- x = path[tree_depth - 1];
- tree_depth--;
- } else {
- if (!w->right || (w->right->info & ST_COLOR) == ST_BLACK) {
- assert(w->left);
- w->left->info &= ~ST_RED;
- path[tree_depth] = w;
- st_right_rotate(tree_depth, &root->root);
- w = path[tree_depth - 1]->right;
- assert(w);
- }
- w->info =
- (w->info & ~ST_COLOR) | (path[tree_depth - 1]->info & ST_COLOR);
- path[tree_depth - 1]->info &= ~ST_RED;
- assert(w->right);
- w->right->info &= ~ST_RED;
- st_left_rotate(tree_depth - 1, &root->root);
- x = root->root;
- }
+ StrNode *w = path[tree_depth - 1]->right;
+ assert(w);
+ if (w && (w->info & ST_COLOR) == ST_RED) {
+ w->info &= ~ST_RED;
+ path[tree_depth - 1]->info |= ST_RED;
+ st_left_rotate(tree_depth - 1, &root->root);
+ path[tree_depth] = path[tree_depth - 1];
+ path[tree_depth - 1] = w;
+ tree_depth++;
+ w = path[tree_depth - 1]->right;
+ assert(w);
+ }
+ assert((w->info & ST_COLOR) == ST_BLACK);
+ if ((!w->left || (w->left->info & ST_COLOR) == ST_BLACK) &&
+ (!w->right || (w->right->info & ST_COLOR) == ST_BLACK)) {
+ w->info |= ST_RED;
+ x = path[tree_depth - 1];
+ tree_depth--;
+ } else {
+ if (!w->right || (w->right->info & ST_COLOR) == ST_BLACK) {
+ assert(w->left);
+ w->left->info &= ~ST_RED;
+ path[tree_depth] = w;
+ st_right_rotate(tree_depth, &root->root);
+ w = path[tree_depth - 1]->right;
+ assert(w);
+ }
+ w->info =
+ (w->info & ~ST_COLOR) | (path[tree_depth - 1]->info & ST_COLOR);
+ path[tree_depth - 1]->info &= ~ST_RED;
+ assert(w->right);
+ w->right->info &= ~ST_RED;
+ st_left_rotate(tree_depth - 1, &root->root);
+ x = root->root;
+ }
} else {
- StrNode *w = path[tree_depth - 1]->left;
- assert(w);
- if (w && (w->info & ST_COLOR) == ST_RED) {
- w->info &= ~ST_RED;
- path[tree_depth - 1]->info |= ST_RED;
- st_right_rotate(tree_depth - 1, &root->root);
- path[tree_depth] = path[tree_depth - 1];
- path[tree_depth - 1] = w;
- tree_depth++;
- w = path[tree_depth - 1]->left;
- assert(w);
- }
- assert((w->info & ST_COLOR) == ST_BLACK);
- if ((!w->right || (w->right->info & ST_COLOR) == ST_BLACK) &&
- (!w->left || (w->left->info & ST_COLOR) == ST_BLACK)) {
- w->info |= ST_RED;
- x = path[tree_depth - 1];
- tree_depth--;
- } else {
- if (!w->left || (w->left->info & ST_COLOR) == ST_BLACK) {
- assert(w->right);
- w->right->info &= ~ST_RED;
- path[tree_depth] = w;
- st_left_rotate(tree_depth, &root->root);
- w = path[tree_depth - 1]->left;
- assert(w);
- }
- w->info =
- (w->info & ~ST_COLOR) | (path[tree_depth - 1]->info & ST_COLOR);
- path[tree_depth - 1]->info &= ~ST_RED;
- assert(w->left);
- w->left->info &= ~ST_RED;
- st_right_rotate(tree_depth - 1, &root->root);
- x = root->root;
- }
+ StrNode *w = path[tree_depth - 1]->left;
+ assert(w);
+ if (w && (w->info & ST_COLOR) == ST_RED) {
+ w->info &= ~ST_RED;
+ path[tree_depth - 1]->info |= ST_RED;
+ st_right_rotate(tree_depth - 1, &root->root);
+ path[tree_depth] = path[tree_depth - 1];
+ path[tree_depth - 1] = w;
+ tree_depth++;
+ w = path[tree_depth - 1]->left;
+ assert(w);
+ }
+ assert((w->info & ST_COLOR) == ST_BLACK);
+ if ((!w->right || (w->right->info & ST_COLOR) == ST_BLACK) &&
+ (!w->left || (w->left->info & ST_COLOR) == ST_BLACK)) {
+ w->info |= ST_RED;
+ x = path[tree_depth - 1];
+ tree_depth--;
+ } else {
+ if (!w->left || (w->left->info & ST_COLOR) == ST_BLACK) {
+ assert(w->right);
+ w->right->info &= ~ST_RED;
+ path[tree_depth] = w;
+ st_left_rotate(tree_depth, &root->root);
+ w = path[tree_depth - 1]->left;
+ assert(w);
+ }
+ w->info =
+ (w->info & ~ST_COLOR) | (path[tree_depth - 1]->info & ST_COLOR);
+ path[tree_depth - 1]->info &= ~ST_RED;
+ assert(w->left);
+ w->left->info &= ~ST_RED;
+ st_right_rotate(tree_depth - 1, &root->root);
+ x = root->root;
+ }
}
}
if (x)
tmp = leader[tree_depth * 2];
leader[tree_depth * 2] = '\0';
printf("%s%c-+ %c %d %s%s\n", leader, lead,
- (node->info & ST_COLOR) ? 'r' : 'b', node->info / ST_USE_STEP,
- node->string, looped ? " -LOOPING" : "");
+ (node->info & ST_COLOR) ? 'r' : 'b', node->info / ST_USE_STEP,
+ node->string, looped ? " -LOOPING" : "");
leader[tree_depth * 2] = ' ' + '|' - tmp;
leader[0] = ' ';
if (node->right && !looped)
unsigned long *perms, unsigned long *nperms, int count);
static void
st_depth_helper(StrNode *node, int *maxdepth, int *mindepth,
- int *avgdepth, int *leaves, unsigned long *perms,
- unsigned long *nperms, int count)
+ int *avgdepth, int *leaves, unsigned long *perms,
+ unsigned long *nperms, int count)
{
if (!node)
return;
if (node->left) {
/* Inner node */
st_depth_helper(node->left, maxdepth, mindepth, avgdepth, leaves, perms,
- nperms, count + 1);
+ nperms, count + 1);
}
if (node->right) {
/* Inner node */
st_depth_helper(node->right, maxdepth, mindepth, avgdepth, leaves, perms,
- nperms, count + 1);
+ nperms, count + 1);
}
- if (!node->left && !node->right) { /* This is a leaf node */
+ if (!node->left && !node->right) { /* This is a leaf node */
(*leaves)++;
(*avgdepth) += count;
if (*mindepth > count)
/* Find the depth and number of permanment nodes */
static void
st_traverse_stats(StrNode *node, int *maxdepth, int *mindepth, int *avgdepth,
- int *leaves, unsigned long *perms, unsigned long *nperms)
+ int *leaves, unsigned long *perms, unsigned long *nperms)
{
*maxdepth = 0;
*mindepth = node ? (ST_MAX_DEPTH + 1) : 0;
return 0;
}
-#endif /* !WIN32 */
-#endif /* !HAS_STRCASECMP */
+#endif /* !WIN32 */
+#endif /* !HAS_STRCASECMP */
/** Does string begin with prefix?
* This comparison is case-insensitive.
if (*sub != '\0') {
while (*src) {
if (string_prefix(src, sub))
- return src;
+ return src;
/* else scan to beginning of next word */
while (*src && (isalpha((unsigned char) *src)
- || isdigit((unsigned char) *src)))
- src++;
+ || isdigit((unsigned char) *src)))
+ src++;
while (*src && !isalpha((unsigned char) *src)
- && !isdigit((unsigned char) *src))
- src++;
+ && !isdigit((unsigned char) *src))
+ src++;
}
}
return NULL;
*/
int
safe_accent(const char *RESTRICT base, const char *RESTRICT tmplate, size_t len,
- char *buff, char **bp)
+ char *buff, char **bp)
{
/* base and tmplate must be the same length */
size_t n;
case 'A':
switch (tmplate[n]) {
case '`':
- c = 192;
- break;
+ c = 192;
+ break;
case '\'':
- c = 193;
- break;
+ c = 193;
+ break;
case '^':
- c = 194;
- break;
+ c = 194;
+ break;
case '~':
- c = 195;
- break;
+ c = 195;
+ break;
case ':':
- c = 196;
- break;
+ c = 196;
+ break;
case 'o':
- c = 197;
- break;
+ c = 197;
+ break;
case 'e':
case 'E':
- c = 198;
- break;
+ c = 198;
+ break;
default:
- c = 'A';
+ c = 'A';
}
break;
case 'a':
switch (tmplate[n]) {
case '`':
- c = 224;
- break;
+ c = 224;
+ break;
case '\'':
- c = 225;
- break;
+ c = 225;
+ break;
case '^':
- c = 226;
- break;
+ c = 226;
+ break;
case '~':
- c = 227;
- break;
+ c = 227;
+ break;
case ':':
- c = 228;
- break;
+ c = 228;
+ break;
case 'o':
- c = 229;
- break;
+ c = 229;
+ break;
case 'e':
case 'E':
- c = 230;
- break;
+ c = 230;
+ break;
default:
- c = 'a';
+ c = 'a';
}
break;
case 'C':
if (tmplate[n] == ',')
- c = 199;
+ c = 199;
else
- c = 'C';
+ c = 'C';
break;
case 'c':
if (tmplate[n] == ',')
- c = 231;
+ c = 231;
else
- c = 'c';
+ c = 'c';
break;
case 'E':
switch (tmplate[n]) {
case '`':
- c = 200;
- break;
+ c = 200;
+ break;
case '\'':
- c = 201;
- break;
+ c = 201;
+ break;
case '^':
- c = 202;
- break;
+ c = 202;
+ break;
case ':':
- c = 203;
- break;
+ c = 203;
+ break;
default:
- c = 'E';
+ c = 'E';
}
break;
case 'e':
switch (tmplate[n]) {
case '`':
- c = 232;
- break;
+ c = 232;
+ break;
case '\'':
- c = 233;
- break;
+ c = 233;
+ break;
case '^':
- c = 234;
- break;
+ c = 234;
+ break;
case ':':
- c = 235;
- break;
+ c = 235;
+ break;
default:
- c = 'e';
+ c = 'e';
}
break;
case 'I':
switch (tmplate[n]) {
case '`':
- c = 204;
- break;
+ c = 204;
+ break;
case '\'':
- c = 205;
- break;
+ c = 205;
+ break;
case '^':
- c = 206;
- break;
+ c = 206;
+ break;
case ':':
- c = 207;
- break;
+ c = 207;
+ break;
default:
- c = 'I';
+ c = 'I';
}
break;
case 'i':
switch (tmplate[n]) {
case '`':
- c = 236;
- break;
+ c = 236;
+ break;
case '\'':
- c = 237;
- break;
+ c = 237;
+ break;
case '^':
- c = 238;
- break;
+ c = 238;
+ break;
case ':':
- c = 239;
- break;
+ c = 239;
+ break;
default:
- c = 'i';
+ c = 'i';
}
break;
case 'N':
if (tmplate[n] == '~')
- c = 209;
+ c = 209;
else
- c = 'N';
+ c = 'N';
break;
case 'n':
if (tmplate[n] == '~')
- c = 241;
+ c = 241;
else
- c = 'n';
+ c = 'n';
break;
case 'O':
switch (tmplate[n]) {
case '`':
- c = 210;
- break;
+ c = 210;
+ break;
case '\'':
- c = 211;
- break;
+ c = 211;
+ break;
case '^':
- c = 212;
- break;
+ c = 212;
+ break;
case '~':
- c = 213;
- break;
+ c = 213;
+ break;
case ':':
- c = 214;
- break;
+ c = 214;
+ break;
default:
- c = 'O';
+ c = 'O';
}
break;
case 'o':
switch (tmplate[n]) {
case '&':
- c = 240;
- break;
+ c = 240;
+ break;
case '`':
- c = 242;
- break;
+ c = 242;
+ break;
case '\'':
- c = 243;
- break;
+ c = 243;
+ break;
case '^':
- c = 244;
- break;
+ c = 244;
+ break;
case '~':
- c = 245;
- break;
+ c = 245;
+ break;
case ':':
- c = 246;
- break;
+ c = 246;
+ break;
default:
- c = 'o';
+ c = 'o';
}
break;
case 'U':
switch (tmplate[n]) {
case '`':
- c = 217;
- break;
+ c = 217;
+ break;
case '\'':
- c = 218;
- break;
+ c = 218;
+ break;
case '^':
- c = 219;
- break;
+ c = 219;
+ break;
case ':':
- c = 220;
- break;
+ c = 220;
+ break;
default:
- c = 'U';
+ c = 'U';
}
break;
case 'u':
switch (tmplate[n]) {
case '`':
- c = 249;
- break;
+ c = 249;
+ break;
case '\'':
- c = 250;
- break;
+ c = 250;
+ break;
case '^':
- c = 251;
- break;
+ c = 251;
+ break;
case ':':
- c = 252;
- break;
+ c = 252;
+ break;
default:
- c = 'u';
+ c = 'u';
}
break;
case 'Y':
if (tmplate[n] == '\'')
- c = 221;
+ c = 221;
else
- c = 'Y';
+ c = 'Y';
break;
case 'y':
if (tmplate[n] == '\'')
- c = 253;
+ c = 253;
else if (tmplate[n] == ':')
- c = 255;
+ c = 255;
else
- c = 'y';
+ c = 'y';
break;
case '?':
if (tmplate[n] == 'u')
- c = 191;
+ c = 191;
else
- c = '?';
+ c = '?';
break;
case '!':
if (tmplate[n] == 'u')
- c = 161;
+ c = 161;
else
- c = '!';
+ c = '!';
break;
case '<':
if (tmplate[n] == '"')
- c = 171;
+ c = 171;
else
- c = '<';
+ c = '<';
break;
case '>':
if (tmplate[n] == '"')
- c = 187;
+ c = 187;
else
- c = '>';
+ c = '>';
break;
case 's':
if (tmplate[n] == 'B')
- c = 223;
+ c = 223;
else
- c = 's';
+ c = 's';
break;
case 'p':
if (tmplate[n] == '|')
- c = 254;
+ c = 254;
else
- c = 'p';
+ c = 'p';
break;
case 'P':
if (tmplate[n] == '|')
- c = 222;
+ c = 222;
else
- c = 'P';
+ c = 'P';
break;
case 'D':
if (tmplate[n] == '-')
- c = 208;
+ c = 208;
else
- c = 'D';
+ c = 'D';
break;
default:
c = base[n];
}
if (isprint(c)) {
if (safe_chr((char) c, buff, bp))
- return 1;
+ return 1;
} else {
if (safe_chr(base[n], buff, bp))
- return 1;
+ return 1;
}
}
return 0;
if (strchr(c, ' ')) {
if (safe_chr('"', buff, bp) || safe_str(c, buff, bp) ||
- safe_chr('"', buff, bp)) {
+ safe_chr('"', buff, bp)) {
*bp = saved;
return 1;
}
*/
char *
replace_string(const char *RESTRICT old, const char *RESTRICT newbit,
- const char *RESTRICT string)
+ const char *RESTRICT string)
{
char *result, *r;
size_t len, newlen;
while (*string) {
char *s = strstr(string, old);
- if (s) { /* Match found! */
+ if (s) { /* Match found! */
safe_strl(string, s - string, result, &r);
safe_strl(newbit, newlen, result, &r);
string = s + len;
*/
char *
replace_string2(const char *old[2], const char *newbits[2],
- const char *RESTRICT string)
+ const char *RESTRICT string)
{
char *result, *rp;
char firsts[3] = { '\0', '\0', '\0' };
string += skip;
}
if(*string) {
- if (strncmp(string, old[0], oldlens[0]) == 0) { /* Copy the first */
- safe_strl(newbits[0], newlens[0], result, &rp);
- string += oldlens[0];
- } else if (strncmp(string, old[1], oldlens[1]) == 0) { /* The second */
- safe_strl(newbits[1], newlens[1], result, &rp);
- string += oldlens[1];
- } else {
- safe_chr(*string, result, &rp);
- string++;
- }
+ if (strncmp(string, old[0], oldlens[0]) == 0) { /* Copy the first */
+ safe_strl(newbits[0], newlens[0], result, &rp);
+ string += oldlens[0];
+ } else if (strncmp(string, old[1], oldlens[1]) == 0) { /* The second */
+ safe_strl(newbits[1], newlens[1], result, &rp);
+ string += oldlens[1];
+ } else {
+ safe_chr(*string, result, &rp);
+ string++;
+ }
}
}
*str++ = '\0';
if (sep == ' ') {
while (*str == sep)
- str++;
+ str++;
}
} else {
str = NULL;
while (*p) {
if (*p == ESC_CHAR) {
while ((*p) && (*p != 'm'))
- p++;
+ p++;
} else if (*p == TAG_START) {
while ((*p) && (*p != TAG_END))
- p++;
+ p++;
} else {
i++;
}
while (*p && numchars > 0) {
if (*p == ESC_CHAR) {
while ((*p) && (*p != 'm')) {
- p++;
- i++;
+ p++;
+ i++;
}
} else if (*p == TAG_START) {
while ((*p) && (*p != TAG_END)) {
- p++;
- i++;
+ p++;
+ i++;
}
} else
numchars--;
int
format_long(long val, char *buff, char **bp, int maxlen, int base)
{
- char stack[128]; /* Even a negative 64 bit number will only be 21
- digits or so max. This should be plenty of
- buffer room. */
+ char stack[128]; /* Even a negative 64 bit number will only be 21
+ digits or so max. This should be plenty of
+ buffer room. */
char *current;
int size = 0, neg = 0;
ldiv_t r;
easy way out since this value is rarely encountered. */
switch (base) {
case 10:
- return safe_format(buff, bp, "%ld", val);
+ return safe_format(buff, bp, "%ld", val);
case 16:
- return safe_format(buff, bp, "%lx", val);
+ return safe_format(buff, bp, "%lx", val);
case 8:
- return safe_format(buff, bp, "%lo", val);
+ return safe_format(buff, bp, "%lo", val);
default:
- /* Weird base /and/ LONG_MIN. Fix someday. */
- return 0;
+ /* Weird base /and/ LONG_MIN. Fix someday. */
+ return 0;
}
}
switch (size % 8) {
case 0:
while (current < stack + sizeof(stack)) {
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 7:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 6:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 5:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 4:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 3:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 2:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
case 1:
- *((*bp)++) = *(current++);
+ *((*bp)++) = *(current++);
}
}
} else {
while (current < stack + sizeof(stack)) {
if (*bp - buff >= maxlen - 1) {
- return 1;
+ return 1;
}
*((*bp)++) = *(current++);
}
mush_free(d2, "string");
return result;
}
-#endif /* HAS_STRXFRM && !WIN32 */
+#endif /* HAS_STRXFRM && !WIN32 */
/** Return a string pointer past any ansi/html markup at the start.
* \param p a string.
while (*p == ESC_CHAR || *p == TAG_START) {
if (*p == ESC_CHAR) {
while (*p && *p != 'm')
- p++;
- } else { /* TAG_START */
+ p++;
+ } else { /* TAG_START */
while (*p && *p != TAG_END)
- p++;
+ p++;
}
if (*p)
p++;
y = skip_leading_ansi(src);
if (y != src) {
if (current)
- mush_free(current, "markup_codes");
+ mush_free(current, "markup_codes");
current = mush_strndup(src, y - src, "markup_codes");
src = y;
}
for (p = 0; p < as->len; p++)
if (as->codes[p]) {
if (current)
- mush_free(current, "markup_codes");
+ mush_free(current, "markup_codes");
current = mush_strdup(as->codes[p], "markup_codes");
} else {
if (!current)
- current = mush_strdup(ANSI_NORMAL, "markup_codes");
+ current = mush_strdup(ANSI_NORMAL, "markup_codes");
as->codes[p] = mush_strdup(current, "markup_codes");
}
if (current)
for (p = 0; p <= as->len; p++) {
if (as->codes[p]) {
if (normal) {
- if (strcmp(as->codes[p], ANSI_NORMAL) == 0) {
- mush_free(as->codes[p], "markup_codes");
- as->codes[p] = NULL;
- continue;
- } else {
- normal = 0;
- }
+ if (strcmp(as->codes[p], ANSI_NORMAL) == 0) {
+ mush_free(as->codes[p], "markup_codes");
+ as->codes[p] = NULL;
+ continue;
+ } else {
+ normal = 0;
+ }
}
m = p;
for (p++; p < as->len; p++) {
- if (as->codes[p] && strcmp(as->codes[p], as->codes[m]) == 0) {
- mush_free(as->codes[p], "markup_codes");
- as->codes[p] = NULL;
- } else {
- p--;
- break;
- }
+ if (as->codes[p] && strcmp(as->codes[p], as->codes[m]) == 0) {
+ mush_free(as->codes[p], "markup_codes");
+ as->codes[p] = NULL;
+ } else {
+ p--;
+ break;
+ }
}
}
}
/* p is now pointing to a starting code */
q = p;
while ((q >= 0) && as->codes[q] && !is_end_html_code(as->codes[q]) &&
- !is_end_ansi_code(as->codes[q])) {
+ !is_end_ansi_code(as->codes[q])) {
if (is_ansi_code(as->codes[q]))
- in_ansi = 1;
+ in_ansi = 1;
else if (is_start_html_code(as->codes[q]))
- in_html++;
+ in_html++;
q--;
}
/* p is now pointing to the first starting code, and we know if we're
*/
for (q = q + 1; q <= p; q++) {
if (safe_str(as->codes[q], buff, bp))
- return 1;
+ return 1;
}
}
for (p = (int) start; p < (int) (start + len) && p < (int) as->len; p++) {
if (as->codes[p]) {
if (safe_str(as->codes[p], buff, bp))
- return 1;
+ return 1;
if (is_end_ansi_code(as->codes[p]))
- in_ansi = 0;
+ in_ansi = 0;
else if (is_ansi_code(as->codes[p]))
- in_ansi = 1;
+ in_ansi = 1;
if (is_end_html_code(as->codes[p]))
- in_html--;
+ in_html--;
else if (is_start_html_code(as->codes[p]))
- in_html++;
+ in_html++;
}
if (safe_chr(as->text[p], buff, bp))
return 1;
break;
if (as->codes[p]) {
if (is_end_ansi_code(as->codes[p])) {
- in_ansi = 0;
- if (safe_str(as->codes[p], buff, bp))
- return 1;
+ in_ansi = 0;
+ if (safe_str(as->codes[p], buff, bp))
+ return 1;
} else if (is_end_html_code(as->codes[p])) {
- in_html--;
- if (safe_str(as->codes[p], buff, bp))
- return 1;
+ in_html--;
+ if (safe_str(as->codes[p], buff, bp))
+ return 1;
}
}
p++;
*/
void
safe_itemizer(int cur_num, int done, const char *delim, const char *conjoin,
- const char *space, char *buff, char **bp)
+ const char *space, char *buff, char **bp)
{
/* We don't do anything if it's the first one */
if (cur_num == 1)
reload_sig_handler(SIGUSR1, usr1_handler);
}
-#endif /* WIN32 */
+#endif /* WIN32 */
/** Set up signal handlers.
*/
do {
for (aptr = List(end_obj); aptr; aptr = AL_NEXT(aptr))
if (aptr->data != NULL_CHUNK_REFERENCE)
- actual++;
+ actual++;
for (lptr = Locks(end_obj); lptr; lptr = L_NEXT(lptr))
if (L_KEY(lptr) != NULL_CHUNK_REFERENCE)
- actual++;
+ actual++;
#ifdef USE_MAILER
if (IsPlayer(end_obj)) {
for (mp = find_exact_starting_point(end_obj); mp; mp = mp->next)
- if (mp->msgid != NULL_CHUNK_REFERENCE)
- actual++;
+ if (mp->msgid != NULL_CHUNK_REFERENCE)
+ actual++;
}
#endif
end_obj = (end_obj + 1) % db_top;
mush_free((Malloc_t) refs, "migration reference array");
refs =
(chunk_reference_t **) mush_malloc(actual * sizeof(chunk_reference_t *),
- "migration reference array");
+ "migration reference array");
refs_size = actual;
if (!refs)
mush_panic("Could not allocate migration reference array");
}
#ifdef DEBUG_MIGRATE
do_rawlog(LT_TRACE, "Migrate asked %d, actual objects #%d to #%d for %d",
- amount, start_obj, (end_obj + db_top - 1) % db_top, actual);
+ amount, start_obj, (end_obj + db_top - 1) % db_top, actual);
#endif
actual = 0;
do {
for (aptr = List(start_obj); aptr; aptr = AL_NEXT(aptr))
if (aptr->data != NULL_CHUNK_REFERENCE) {
- refs[actual] = &(aptr->data);
- actual++;
+ refs[actual] = &(aptr->data);
+ actual++;
}
for (lptr = Locks(start_obj); lptr; lptr = L_NEXT(lptr))
if (L_KEY(lptr) != NULL_CHUNK_REFERENCE) {
- refs[actual] = &(lptr->key);
- actual++;
+ refs[actual] = &(lptr->key);
+ actual++;
}
#ifdef USE_MAILER
if (IsPlayer(start_obj)) {
for (mp = find_exact_starting_point(start_obj); mp; mp = mp->next)
- if (mp->msgid != NULL_CHUNK_REFERENCE) {
- refs[actual] = &(mp->msgid);
- actual++;
- }
+ if (mp->msgid != NULL_CHUNK_REFERENCE) {
+ refs[actual] = &(mp->msgid);
+ actual++;
+ }
}
#endif
start_obj = (start_obj + 1) % db_top;
}
/* A USR1 does a shutdown/reboot */
if (usr1_triggered) {
- do_reboot(NOTHING, 0); /* We don't return from this */
- usr1_triggered = 0; /* But just in case */
+ do_reboot(NOTHING, 0); /* We don't return from this */
+ usr1_triggered = 0; /* But just in case */
}
if (!globals.on_second)
return;
fork_and_dump(1);
strcpy(global_eval_context.ccom, "");
flag_broadcast(0, "ON-VACATION", "%s",
- T
- ("Your ON-VACATION flag is set! If you're back, clear it."));
+ T
+ ("Your ON-VACATION flag is set! If you're back, clear it."));
} else if (NO_FORK &&
- (options.dump_counter - 60 == mudtime) &&
- *options.dump_warning_1min) {
+ (options.dump_counter - 60 == mudtime) &&
+ *options.dump_warning_1min) {
flag_broadcast(0, 0, "%s", options.dump_warning_1min);
} else if (NO_FORK &&
- (options.dump_counter - 300 == mudtime) &&
- *options.dump_warning_5min) {
+ (options.dump_counter - 300 == mudtime) &&
+ *options.dump_warning_5min) {
flag_broadcast(0, 0, "%s", options.dump_warning_5min);
}
if (options.warn_interval && (options.warn_counter <= mudtime)) {
}
sig_atomic_t cpu_time_limit_hit = 0; /** Was the cpu time limit hit? */
-int cpu_limit_warning_sent = 0; /** Have we issued a cpu limit warning? */
+int cpu_limit_warning_sent = 0; /** Have we issued a cpu limit warning? */
#ifndef PROFILING
#if defined(HAS_ITIMER)
}
#endif
#endif
-int timer_set = 0; /**< Is a CPU timer set? */
+int timer_set = 0; /**< Is a CPU timer set? */
/** Start the cpu timer (before running a command).
*/
cpu_time_limit_hit = 0;
cpu_limit_warning_sent = 0;
timer_set = 1;
-#if defined(HAS_ITIMER) /* UNIX way */
+#if defined(HAS_ITIMER) /* UNIX way */
{
struct itimerval time_limit;
if (options.queue_entry_cpu_time > 0) {
time_limit.it_interval.tv_sec = 0;
time_limit.it_interval.tv_usec = 0;
if (setitimer(ITIMER_PROF, &time_limit, NULL)) {
- perror("setitimer");
- timer_set = 0;
+ perror("setitimer");
+ timer_set = 0;
}
} else
timer_set = 0;
}
-#elif defined(WIN32) /* Windoze way */
+#elif defined(WIN32) /* Windoze way */
if (options.queue_entry_cpu_time > 0)
timer_id = SetTimer(NULL, 0, (unsigned) options.queue_entry_cpu_time,
- (TIMERPROC) win32_timer);
+ (TIMERPROC) win32_timer);
else
timer_set = 0;
#endif
***/
const char *
real_unparse(dbref player, dbref loc, int obey_myopic, int use_nameformat,
- int use_nameaccent)
+ int use_nameaccent)
{
static char buf[BUFFER_LEN], *bp;
static char tbuf1[BUFFER_LEN];
couldunparse = 0;
if (!(GoodObject(loc) || (loc == NOTHING) || (loc == AMBIGUOUS) ||
- (loc == HOME)))
+ (loc == HOME)))
return T("*NOTHING*");
switch (loc) {
case NOTHING:
strcpy(tbuf1, Name(loc));
if (IsExit(loc) && obey_myopic) {
if ((p = strchr(tbuf1, ';')))
- *p = '\0';
+ *p = '\0';
}
/* Don't let 'em get dbrefs when they're IC */
if ((Can_Examine(player, loc) || can_link_to(player, loc) ||
- JumpOk(loc) || ChownOk(loc) || DestOk(loc)) &&
- (!Myopic(player) || !obey_myopic) &&
- !(use_nameformat && got_nameformat)
- ) {
+ JumpOk(loc) || ChownOk(loc) || DestOk(loc)) &&
+ (!Myopic(player) || !obey_myopic) &&
+ !(use_nameformat && got_nameformat)
+ ) {
/* show everything */
if (SUPPORT_PUEBLO)
- couldunparse = 1;
+ couldunparse = 1;
bp = buf;
if (ANSI_NAMES && ShowAnsi(player) && !got_nameformat)
- safe_format(buf, &bp, "%s%s%s(#%d%s)", ANSI_HILITE, tbuf1,
- ANSI_NORMAL, loc, unparse_flags(loc, player));
+ safe_format(buf, &bp, "%s%s%s(#%d%s)", ANSI_HILITE, tbuf1,
+ ANSI_NORMAL, loc, unparse_flags(loc, player));
else
- safe_format(buf, &bp, "%s(#%d%s)", tbuf1, loc,
- unparse_flags(loc, player));
+ safe_format(buf, &bp, "%s(#%d%s)", tbuf1, loc,
+ unparse_flags(loc, player));
*bp = '\0';
} else {
/* show only the name */
if (ANSI_NAMES && ShowAnsi(player) && !got_nameformat) {
- bp = buf;
- safe_format(buf, &bp, "%s%s%s", ANSI_HILITE, tbuf1, ANSI_NORMAL);
- *bp = '\0';
+ bp = buf;
+ safe_format(buf, &bp, "%s%s%s", ANSI_HILITE, tbuf1, ANSI_NORMAL);
+ *bp = '\0';
} else
- strcpy(buf, tbuf1);
+ strcpy(buf, tbuf1);
}
}
/* buf now contains the default formatting of the name. If we
sp = save = safe_atr_value(a);
bp = tbuf1;
process_expression(tbuf1, &bp, &sp, loc, player, player,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
free((Malloc_t) save);
for (j = 0; j < 10; j++) {
char *
unparse_number(NVAL num)
{
- static char str[100]; /* Should be large enough for even the HUGE floats */
+ static char str[100]; /* Should be large enough for even the HUGE floats */
char *p;
sprintf(str, "%.*f", FLOAT_PRECISION, num);
#endif
#ifdef WIN32
#include <wtypes.h>
-#include <winbase.h> /* For GetCurrentProcessId() */
+#include <winbase.h> /* For GetCurrentProcessId() */
#endif
#include "conf.h"
ptr = malloc(size);
if (ptr == NULL)
do_log(LT_ERR, 0, 0, "mush_malloc failed to malloc %ld bytes for %s",
- size, check);
+ size, check);
return ptr;
}
*/
void
mush_free(Malloc_t RESTRICT ptr, const char *RESTRICT check
- __attribute__ ((__unused__)))
+ __attribute__ ((__unused__)))
{
del_check(check);
free(ptr);
*/
int
fetch_ufun_attrib(char *attrname, dbref executor, ufun_attrib * ufun,
- int accept_lambda)
+ int accept_lambda)
{
ATTR *attrib;
dbref thing;
int pe_flags = PE_UDEFAULT;
if (!ufun)
- return 0; /* We should never NOT receive a ufun. */
+ return 0; /* We should never NOT receive a ufun. */
ufun->errmess = (char *) "";
/* find our object and attribute */
*/
int
call_ufun(ufun_attrib * ufun, char **wenv_args, int wenv_argc, char *ret,
- dbref executor, dbref enactor, PE_Info * pe_info)
+ dbref executor, dbref enactor, PE_Info * pe_info)
{
char rbuff[BUFFER_LEN];
char *rp;
ap = ufun->contents;
pe_ret = process_expression(ret, &rp, &ap, ufun->thing, executor,
- enactor, ufun->pe_flags, PT_DEFAULT, pe_info);
+ enactor, ufun->pe_flags, PT_DEFAULT, pe_info);
*rp = '\0';
/* Restore the old wenv */
if (IsRoom(room)) {
thing = Exits(room);
while (thing != NOTHING) {
- if (thing == door)
- return room;
- thing = Next(thing);
+ if (thing == door)
+ return room;
+ thing = Next(thing);
}
}
return NOTHING;
/* have to find it */
DOLIST(prev, first) {
if (Next(prev) == what) {
- Next(prev) = Next(what);
- return first;
+ Next(prev) = Next(what);
+ return first;
}
}
return first;
close(fd);
if (r <= 0) {
do_rawlog(LT_ERR,
- "Couldn't read from /dev/urandom! Resorting to normal seeding method.");
+ "Couldn't read from /dev/urandom! Resorting to normal seeding method.");
} else {
do_rawlog(LT_ERR, "Seeded RNG from /dev/urandom");
init_by_array(buf, r / sizeof(unsigned long));
}
} else
do_rawlog(LT_ERR,
- "Couldn't open /dev/urandom to seed random number generator. Resorting to normal seeding method.");
+ "Couldn't open /dev/urandom to seed random number generator. Resorting to normal seeding method.");
#endif
/* Default seeder. Pick a seed that's fairly random */
/* Period parameters */
#define M 397 /**< PRNG constant */
-#define MATRIX_A 0x9908b0dfUL /**< PRNG constant vector a */
-#define UPPER_MASK 0x80000000UL /**< PRNG most significant w-r bits */
-#define LOWER_MASK 0x7fffffffUL /**< PRNG least significant r bits */
+#define MATRIX_A 0x9908b0dfUL /**< PRNG constant vector a */
+#define UPPER_MASK 0x80000000UL /**< PRNG most significant w-r bits */
+#define LOWER_MASK 0x7fffffffUL /**< PRNG least significant r bits */
-static unsigned long mt[N]; /* the array for the state vector */
-static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */
+static unsigned long mt[N]; /* the array for the state vector */
+static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */
/** initializes mt[N] with a seed.
* \param a seed value.
k = (N > key_length ? N : key_length);
for (; k; k--) {
mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL))
- + init_key[j] + j; /* non linear */
- mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+ + init_key[j] + j; /* non linear */
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
i++;
j++;
if (i >= N) {
}
for (k = N - 1; k; k--) {
mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1566083941UL))
- - i; /* non linear */
- mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+ - i; /* non linear */
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
i++;
if (i >= N) {
mt[0] = mt[N - 1];
}
}
- mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
+ mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
}
/* generates a random number on [0,0xffffffff]-interval */
static unsigned long mag01[2] = { 0x0UL, MATRIX_A };
/* mag01[x] = x * MATRIX_A for x=0,1 */
- if (mti >= N) { /* generate N words at one time */
+ if (mti >= N) { /* generate N words at one time */
int kk;
- if (mti == N + 1) /* if init_genrand() has not been called, */
- init_genrand(5489UL); /* a default initial seed is used */
+ if (mti == N + 1) /* if init_genrand() has not been called, */
+ init_genrand(5489UL); /* a default initial seed is used */
for (kk = 0; kk < N - M; kk++) {
y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK);
char *
shortname(dbref it)
{
- static char n[BUFFER_LEN]; /* STATIC */
+ static char n[BUFFER_LEN]; /* STATIC */
char *s;
strncpy(n, Name(it), BUFFER_LEN - 1);
* If yes, returns 1
*/
char check_know(dbref p1, dbref p2) {
- ATTR *a;
- dbref num;
- char *b, *s, *e;
- char di = 0; /* variable set when in dbref isolating */
-
- /* Quick Check first */
- if(p1 == p2)
- return 1;
- /* load @XY_KNOW attribute into the register, & check for p2 in it */
-
- a = atr_get(p1, "XY_KNOW");
- if(!a) /* they know no one */
- return 0;
- b = s = e = safe_atr_value(a);
- if(!s)
- return 0;
-
- /* isolate each dbref in the attribute & check if p2 matches anywhere */
- while(*s && *e)
- if(di) {
- if(*e && e[1] != '\0' && !isspace(*e)) {
- e++;
- continue;
- }
- if(isspace(*e))
- *e = '\0';
- num = parse_dbref(s);
- if(num == p2) { /* FOUND 'EM! */
- mush_free(b, "ATRFREE");
- return 1;
- }
- if(e[1] != '\0') {
- di = 0;
- s = e++;
- s++;
- } else break;
- } else if(*s == '#')
- di = 1;
- else if(isspace(*s))
- s++, e++;
- mush_free(b,"ATRFREE");
- return 0;
+ ATTR *a;
+ dbref num;
+ char *b, *s, *e;
+ char di = 0; /* variable set when in dbref isolating */
+
+ /* Quick Check first */
+ if(p1 == p2)
+ return 1;
+ /* load @XY_KNOW attribute into the register, & check for p2 in it */
+
+ a = atr_get(p1, "XY_KNOW");
+ if(!a) /* they know no one */
+ return 0;
+ b = s = e = safe_atr_value(a);
+ if(!s)
+ return 0;
+
+ /* isolate each dbref in the attribute & check if p2 matches anywhere */
+ while(*s && *e)
+ if(di) {
+ if(*e && e[1] != '\0' && !isspace(*e)) {
+ e++;
+ continue;
+ }
+ if(isspace(*e))
+ *e = '\0';
+ num = parse_dbref(s);
+ if(num == p2) { /* FOUND 'EM! */
+ mush_free(b, "ATRFREE");
+ return 1;
+ }
+ if(e[1] != '\0') {
+ di = 0;
+ s = e++;
+ s++;
+ } else break;
+ } else if(*s == '#')
+ di = 1;
+ else if(isspace(*s))
+ s++, e++;
+ mush_free(b,"ATRFREE");
+ return 0;
}
* of overhead
*/
const char *know_name_qk(dbref player) {
- static char final_buffer[ROCC_LIMIT];
- ATTR *a, *ao;
- char *race, *ro, *p;
- dbref spot;
- /* to navigate backwards through content list */
- struct object_ptr {
- dbref cur;
- struct object_ptr *back;
- } *optr_add,*optr_nav;
- int occ = 0;
+ static char final_buffer[ROCC_LIMIT];
+ ATTR *a, *ao;
+ char *race, *ro, *p;
+ dbref spot;
+ /* to navigate backwards through content list */
+ struct object_ptr {
+ dbref cur;
+ struct object_ptr *back;
+ } *optr_add,*optr_nav;
+ int occ = 0;
/* ONLY PLAYERS! OR WE CRASH! */
if(Typeof(player) != TYPE_PLAYER)
- return shortname(player);
-
- /* initialize variables */
- memset(final_buffer, '\0', ROCC_LIMIT);
- p = final_buffer;
- spot = Contents(Location(player));
-
-
- /* Isolate player Race. */
- a = atr_get(player, "RACE");
- if(!a)
- race = strdup(DEF_RACE_NAME);
- else race = safe_atr_value(a);
-
- safe_str(race, final_buffer, &p);
-
- /* Now we have the race, loop through location contents to see which 'occurance' player
- * is of that race
- */
- /* first lets make our backwrds list */
- optr_nav = optr_add = NULL;
- DOLIST(spot,spot) {
- if(!IsPlayer(spot))
- continue;
- optr_nav = optr_add;
- optr_add = mush_malloc(sizeof(struct object_ptr *) , "OPTR_ADD");
- if(!optr_add)
- mush_panic("Can't Allocate OPTR_ADD");
- if(optr_nav == NULL) {
- optr_add->back = NULL;
- } else optr_add->back = optr_nav;
- optr_add->cur = spot;
- }
-
- /* now loop through our backwards list */
- for(optr_nav = optr_add; optr_nav ; optr_nav = optr_nav->back) {
- /* grab race */
- ao = atr_get(optr_nav->cur, "RACE");
- if(!ao)
- ro = strdup(DEF_RACE_NAME); /* It's your average no race dude */
- else ro = safe_atr_value(ao);
- if(!strcasecmp(race, ro)) {
- occ++;
- if(optr_nav->cur == player) break;
- }
-
- free(ro);
- }
- /* attach occ to final_buffer */
- safe_chr('-', final_buffer, &p);
- safe_number(occ, final_buffer, &p);
+ return shortname(player);
+
+ /* initialize variables */
+ memset(final_buffer, '\0', ROCC_LIMIT);
+ p = final_buffer;
+ spot = Contents(Location(player));
+
+
+ /* Isolate player Race. */
+ a = atr_get(player, "RACE");
+ if(!a)
+ race = strdup(DEF_RACE_NAME);
+ else race = safe_atr_value(a);
+
+ safe_str(race, final_buffer, &p);
+
+ /* Now we have the race, loop through location contents to see which 'occurance' player
+ * is of that race
+ */
+ /* first lets make our backwrds list */
+ optr_nav = optr_add = NULL;
+ DOLIST(spot,spot) {
+ if(!IsPlayer(spot))
+ continue;
+ optr_nav = optr_add;
+ optr_add = mush_malloc(sizeof(struct object_ptr *) , "OPTR_ADD");
+ if(!optr_add)
+ mush_panic("Can't Allocate OPTR_ADD");
+ if(optr_nav == NULL) {
+ optr_add->back = NULL;
+ } else optr_add->back = optr_nav;
+ optr_add->cur = spot;
+ }
+
+ /* now loop through our backwards list */
+ for(optr_nav = optr_add; optr_nav ; optr_nav = optr_nav->back) {
+ /* grab race */
+ ao = atr_get(optr_nav->cur, "RACE");
+ if(!ao)
+ ro = strdup(DEF_RACE_NAME); /* It's your average no race dude */
+ else ro = safe_atr_value(ao);
+ if(!strcasecmp(race, ro)) {
+ occ++;
+ if(optr_nav->cur == player) break;
+ }
+
+ free(ro);
+ }
+ /* attach occ to final_buffer */
+ safe_chr('-', final_buffer, &p);
+ safe_number(occ, final_buffer, &p);
- /* free up & return */
- for(optr_nav = optr_add;;optr_nav = optr_add) {
- if(!optr_nav)
- break;
- optr_add = optr_add->back;
- mush_free(optr_nav, "OPTR_ADD");
- }
-
- free(race);
- free(ro);
- *p = '\0';
- return final_buffer;
-
+ /* free up & return */
+ for(optr_nav = optr_add;;optr_nav = optr_add) {
+ if(!optr_nav)
+ break;
+ optr_add = optr_add->back;
+ mush_free(optr_nav, "OPTR_ADD");
+ }
+
+ free(race);
+ free(ro);
+ *p = '\0';
+ return final_buffer;
+
}
#endif
notify_format(player, T("You are connected to %s"), MUDNAME);
strcpy(buff, ctime(&globals.start_time));
- buff[strlen(buff) - 1] = '\0'; /* eat the newline */
+ buff[strlen(buff) - 1] = '\0'; /* eat the newline */
notify_format(player, T("Last restarted: %s"), buff);
notify_format(player, "CobraMUSH v%s [%s]", VERSION, VBRANCH);
/* We might check for both locked and unlocked warnings if we can't
* figure out a lock.
*/
-#define W_UNLOCKED 0x1 /**< Check for unlocked-object warnings */
-#define W_LOCKED 0x2 /**< Check for locked-object warnings */
-
-#define W_EXIT_ONEWAY 0x1 /**< Find one-way exits */
-#define W_EXIT_MULTIPLE 0x2 /**< Find multiple exits to same place */
-#define W_EXIT_MSGS 0x4 /**< Find exits without messages */
-#define W_EXIT_DESC 0x8 /**< Find exits without descs */
-#define W_EXIT_UNLINKED 0x10 /**< Find unlinked exits */
+#define W_UNLOCKED 0x1 /**< Check for unlocked-object warnings */
+#define W_LOCKED 0x2 /**< Check for locked-object warnings */
+
+#define W_EXIT_ONEWAY 0x1 /**< Find one-way exits */
+#define W_EXIT_MULTIPLE 0x2 /**< Find multiple exits to same place */
+#define W_EXIT_MSGS 0x4 /**< Find exits without messages */
+#define W_EXIT_DESC 0x8 /**< Find exits without descs */
+#define W_EXIT_UNLINKED 0x10 /**< Find unlinked exits */
/* Space for more exit stuff */
-#define W_THING_MSGS 0x100 /**< Find things without messages */
-#define W_THING_DESC 0x200 /**< Find things without descs */
+#define W_THING_MSGS 0x100 /**< Find things without messages */
+#define W_THING_DESC 0x200 /**< Find things without descs */
/* Space for more thing stuff */
-#define W_ROOM_DESC 0x1000 /**< Find rooms without descs */
+#define W_ROOM_DESC 0x1000 /**< Find rooms without descs */
/* Space for more room stuff */
-#define W_PLAYER_DESC 0x10000 /**< Find players without descs */
+#define W_PLAYER_DESC 0x10000 /**< Find players without descs */
-#define W_LOCK_PROBS 0x100000 /**< Find bad locks */
+#define W_LOCK_PROBS 0x100000 /**< Find bad locks */
/* Groups of warnings */
#define W_NONE 0 /**< No warnings */
/** A structure representing a topology warning check. */
typedef struct a_tcheck {
- const char *name; /**< Name of warning. */
- warn_type flag; /**< Bitmask of warning. */
+ const char *name; /**< Name of warning. */
+ warn_type flag; /**< Bitmask of warning. */
} tcheck;
static tcheck checklist[] = {
- {"none", W_NONE}, /* MUST BE FIRST! */
+ {"none", W_NONE}, /* MUST BE FIRST! */
{"exit-unlinked", W_EXIT_UNLINKED},
{"thing-desc", W_THING_DESC},
{"room-desc", W_ROOM_DESC},
#ifdef HAS_VSNPRINTF
char buff[BUFFER_LEN];
#else
- char buff[BUFFER_LEN * 3]; /* safety margin */
+ char buff[BUFFER_LEN * 3]; /* safety margin */
#endif
va_list args;
va_end(args);
notify_format(player, T("Warning '%s' for %s:"),
- name, unparse_object(player, i));
+ name, unparse_object(player, i));
notify(player, buff);
}
dst = Destination(i);
if ((flags & W_EXIT_UNLINKED) && (dst == NOTHING))
complain(player, i, "exit-unlinked",
- T("exit is unlinked; anyone can steal it"));
+ T("exit is unlinked; anyone can steal it"));
if ((flags & W_EXIT_UNLINKED) && dst == AMBIGUOUS) {
ATTR *a;
var = "EXITTO";
if (!a)
complain(player, i, "exit-unlinked",
- T("Variable exit has no %s attribute"), var);
+ T("Variable exit has no %s attribute"), var);
else {
const char *x = atr_value(a);
if (!x || !*x)
- complain(player, i, "exit-unlinked",
- T("Variable exit has empty %s attribute"), var);
+ complain(player, i, "exit-unlinked",
+ T("Variable exit has empty %s attribute"), var);
}
}
if (flags & W_EXIT_MSGS) {
lt = warning_lock_type(getlock(i, Basic_Lock));
if ((lt & W_UNLOCKED) &&
- (!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
- !atr_get(i, "SUCCESS")))
- complain(player, i, "exit-msgs",
- T("possibly unlocked exit missing succ/osucc/odrop"));
+ (!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
+ !atr_get(i, "SUCCESS")))
+ complain(player, i, "exit-msgs",
+ T("possibly unlocked exit missing succ/osucc/odrop"));
if ((lt & W_LOCKED) && !atr_get(i, "FAILURE"))
- complain(player, i, "exit-msgs",
- T("possibly locked exit missing fail"));
+ complain(player, i, "exit-msgs",
+ T("possibly locked exit missing fail"));
}
if (flags & W_EXIT_DESC) {
if (!atr_get(i, "DESCRIBE"))
- complain(player, i, "exit-desc", T("exit is missing description"));
+ complain(player, i, "exit-desc", T("exit is missing description"));
}
}
src = Source(i);
for (j = Exits(dst); GoodObject(j); j = Next(j))
if (Location(j) == src) {
if (!(flags & W_EXIT_MULTIPLE))
- return;
+ return;
else
- count++;
+ count++;
}
if ((count == 0) && (flags & W_EXIT_ONEWAY))
complain(player, i, "exit-oneway", T("exit has no return exit"));
else if ((count > 1) && (flags & W_EXIT_MULTIPLE))
complain(player, i, "exit-multiple",
- T("exit has multiple (%d) return exits"), count);
+ T("exit has multiple (%d) return exits"), count);
}
if (flags & W_THING_MSGS) {
lt = warning_lock_type(getlock(i, Basic_Lock));
if ((lt & W_UNLOCKED) &&
- (!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
- !atr_get(i, "SUCCESS") || !atr_get(i, "DROP")))
+ (!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
+ !atr_get(i, "SUCCESS") || !atr_get(i, "DROP")))
complain(player, i, "thing-msgs",
- T("possibly unlocked thing missing succ/osucc/drop/odrop"));
+ T("possibly unlocked thing missing succ/osucc/drop/odrop"));
if ((lt & W_LOCKED) && !atr_get(i, "FAILURE"))
complain(player, i, "thing-msgs",
- T("possibly locked thing missing fail"));
+ T("possibly locked thing missing fail"));
}
}
Warnings(thing) = w;
if (Warnings(thing))
notify_format(player, T("@warnings set to: %s"),
- unparse_warnings(Warnings(thing)));
+ unparse_warnings(Warnings(thing)));
else
notify(player, T("@warnings cleared."));
} else {
while (w && *w) {
found = 0;
if (*w == '!') {
- /* Found a negated warning */
- w++;
- for (c = checklist; c->name; c++) {
- if (!strcasecmp(w, c->name)) {
- negate_flags |= c->flag;
- found++;
- }
- }
+ /* Found a negated warning */
+ w++;
+ for (c = checklist; c->name; c++) {
+ if (!strcasecmp(w, c->name)) {
+ negate_flags |= c->flag;
+ found++;
+ }
+ }
} else {
- for (c = checklist; c->name; c++) {
- if (!strcasecmp(w, c->name)) {
- flags |= c->flag;
- found++;
- }
- }
+ for (c = checklist; c->name; c++) {
+ if (!strcasecmp(w, c->name)) {
+ flags |= c->flag;
+ found++;
+ }
+ }
}
/* At this point, we haven't matched any warnings. */
if (!found && player != NOTHING) {
- notify_format(player, T("Unknown warning: %s"), w);
+ notify_format(player, T("Unknown warning: %s"), w);
}
w = split_token(&s, ' ');
}
const unsigned char *tables = NULL; /** Pointer to character tables */
-static char wspace[3 * BUFFER_LEN + NUMARGS]; /* argument return buffer */
- /* big to match tprintf */
+static char wspace[3 * BUFFER_LEN + NUMARGS]; /* argument return buffer */
+ /* big to match tprintf */
static int wild1
(const char *RESTRICT tstr, const char *RESTRICT dstr, int arg,
char *RESTRICT wbuf, int cs);
static int wild(const char *RESTRICT s, const char *RESTRICT d, int p, int cs);
static int check_literals(const char *RESTRICT tstr, const char *RESTRICT dstr,
- int cs);
+ int cs);
static char *strip_backslashes(const char *str);
/** Do a wildcard match, without remembering the wild data.
* end of data.
*/
if (!*dstr)
- return 0;
+ return 0;
break;
case '\\':
/* Escape character. Move up, and force literal
* If matching end of data, return true.
*/
if (NOTEQUAL(cs, *dstr, *tstr))
- return 0;
+ return 0;
if (!*dstr)
- return 1;
+ return 1;
}
tstr++;
dstr++;
while ((*tstr == '?') || (*tstr == '*')) {
if (*tstr == '?') {
if (!*dstr)
- return 0;
+ return 0;
dstr++;
}
tstr++;
* end of data.
*/
if (!*dstr || *dstr == '`')
- return 0;
+ return 0;
break;
case '`':
/* Delimiter match. Special handling if at end of pattern. */
if (*dstr != '`')
- return 0;
+ return 0;
if (!tstr[1])
- return !strchr(dstr + 1, '`');
+ return !strchr(dstr + 1, '`');
break;
case '\\':
/* Escape character. Move up, and force literal
* If matching end of data, return true.
*/
if (NOTEQUAL(0, *dstr, *tstr))
- return 0;
+ return 0;
if (!*dstr)
- return 1;
+ return 1;
}
tstr++;
dstr++;
while (starcount < 2 && ((*tstr == '?') || (*tstr == '*'))) {
if (*tstr == '?') {
if (!*dstr || *dstr == '`')
- return 0;
+ return 0;
dstr++;
starcount = 0;
} else
/* Scan for possible matches. */
while (*dstr) {
if (*dstr != '`' && atr_wild(tstr + 1, dstr + 1))
- return 1;
+ return 1;
dstr++;
}
} else {
/* Scan for possible matches. */
while (*dstr) {
if (EQUAL(0, *dstr, *tstr) && atr_wild(tstr + 1, dstr + 1))
- return 1;
+ return 1;
if (starcount < 2 && *dstr == '`')
- return 0;
+ return 0;
dstr++;
}
}
* end of data.
*/
if (!*dstr)
- return 0;
+ return 0;
global_eval_context.wnxt[arg++] = wbuf;
*wbuf++ = *dstr;
/* Jump to the fast routine if we can. */
if (arg >= NUMARGS)
- return quick_wild_new(tstr + 1, dstr + 1, cs);
+ return quick_wild_new(tstr + 1, dstr + 1, cs);
break;
case '\\':
/* Escape character. Move up, and force literal
* If matching end of data, return true.
*/
if (NOTEQUAL(cs, *dstr, *tstr))
- return 0;
+ return 0;
if (!*dstr)
- return 1;
+ return 1;
}
tstr++;
dstr++;
/* Jump to the fast routine if we can. */
if (argpos >= NUMARGS)
- return quick_wild_new(tstr, dstr, cs);
+ return quick_wild_new(tstr, dstr, cs);
/* Fill in any intervening '?'s */
while (argpos < arg) {
- global_eval_context.wnxt[argpos++] = wbuf;
- *wbuf++ = *datapos++;
- *wbuf++ = '\0';
+ global_eval_context.wnxt[argpos++] = wbuf;
+ *wbuf++ = *datapos++;
+ *wbuf++ = '\0';
- /* Jump to the fast routine if we can. */
- if (argpos >= NUMARGS)
- return quick_wild_new(tstr, dstr, cs);
+ /* Jump to the fast routine if we can. */
+ if (argpos >= NUMARGS)
+ return quick_wild_new(tstr, dstr, cs);
}
}
/* Skip over the '*' for now... */
numextra = 0;
while (*tstr == '?') {
if (!*dstr)
- return 0;
+ return 0;
tstr++;
dstr++;
arg++;
wnext++;
while (1) {
if (EQUAL(cs, *dstr, *tstr) &&
- ((arg < NUMARGS) ? wild1(tstr, dstr, arg, wnext, cs)
- : quick_wild_new(tstr, dstr, cs)))
- break;
+ ((arg < NUMARGS) ? wild1(tstr, dstr, arg, wnext, cs)
+ : quick_wild_new(tstr, dstr, cs)))
+ break;
if (!*dstr)
- return 0;
+ return 0;
dstr++;
wnext++;
}
int subpatterns;
if ((re = pcre_compile(s, (cs ? 0 : PCRE_CASELESS), &errptr, &erroffset,
- tables)) == NULL) {
+ tables)) == NULL) {
/*
* This is a matching error. We have an error message in
* errptr that we can ignore, since we're doing
int erroffset;
int offsets[99];
int r;
- int flags = 0; /* There's a PCRE_NO_AUTO_CAPTURE flag to turn all raw
- ()'s into (?:)'s, which would be nice to use,
- except that people might use backreferences in
- their patterns. Argh. */
+ int flags = 0; /* There's a PCRE_NO_AUTO_CAPTURE flag to turn all raw
+ ()'s into (?:)'s, which would be nice to use,
+ except that people might use backreferences in
+ their patterns. Argh. */
if (!cs)
flags |= PCRE_CASELESS;
#endif
struct search_spec {
- dbref owner; /**< Limit to this owner, if specified */
- int type; /**< Limit to this type */
- dbref parent; /**< Limit to children of this parent */
- dbref zone; /**< Limit to those in this zone */
- dbref division; /**< Limit to those in this division */
- dbref subdivision; /**< Limit to those in this division's subdivisions */
- char flags[BUFFER_LEN]; /**< Limit to those with these flags */
- char lflags[BUFFER_LEN]; /**< Limit to those with these flags */
- int search_powers; /**< If set, apply powers restriction */
- unsigned char powers[BUFFER_LEN]; /**< Limit to those with these powers */
- char eval[BUFFER_LEN]; /**< Limit to those where this evals true */
- char name[BUFFER_LEN]; /**< Limit to those prefix-matching this name */
- dbref low; /**< Limit to dbrefs here or higher */
- dbref high; /**< Limit to dbrefs here or lower */
+ dbref owner; /**< Limit to this owner, if specified */
+ int type; /**< Limit to this type */
+ dbref parent; /**< Limit to children of this parent */
+ dbref zone; /**< Limit to those in this zone */
+ dbref division; /**< Limit to those in this division */
+ dbref subdivision; /**< Limit to those in this division's subdivisions */
+ char flags[BUFFER_LEN]; /**< Limit to those with these flags */
+ char lflags[BUFFER_LEN]; /**< Limit to those with these flags */
+ int search_powers; /**< If set, apply powers restriction */
+ unsigned char powers[BUFFER_LEN]; /**< Limit to those with these powers */
+ char eval[BUFFER_LEN]; /**< Limit to those where this evals true */
+ char name[BUFFER_LEN]; /**< Limit to those prefix-matching this name */
+ dbref low; /**< Limit to dbrefs here or higher */
+ dbref high; /**< Limit to dbrefs here or lower */
int start; /**< Limited results: start at this one. */
int count; /**< Limited results: return this many */
int end; /**< Limited results: return until this one.*/
int tport_control_ok(dbref player, dbref victim, dbref loc);
static int mem_usage(dbref thing);
static int raw_search(dbref player, const char *owner, int nargs,
- const char **args, dbref **result, PE_Info * pe_info);
+ const char **args, dbref **result, PE_Info * pe_info);
static int fill_search_spec(dbref player, const char *owner, int nargs,
- const char **args, struct search_spec *spec);
+ const char **args, struct search_spec *spec);
#ifdef INFO_SLAVE
void kill_info_slave(void);
}
if (player == AMBIGUOUS) {
notify_format(creator, T("Failure creating '%s' (bad password)"),
- player_name);
+ player_name);
return NOTHING;
}
notify_format(creator, T("New player '%s' (#%d) created with password '%s'"),
- player_name, player, player_password);
+ player_name, player, player_password);
do_log(LT_WIZ, creator, player, T("Player creation"));
return player;
}
else {
who = lookup_player(arg1);
if (who == NOTHING && ((who = match_result(player, arg1, TYPE_DIVISION, MAT_EVERYTHING)) == NOTHING
- || Typeof(who) != TYPE_DIVISION)) {
+ || Typeof(who) != TYPE_DIVISION)) {
notify(player, T("No such player or division."));
return;
}
return;
}
/* count up all owned objects */
- owned = -1; /* a player is never included in his own
- * quota */
+ owned = -1; /* a player is never included in his own
+ * quota */
for (thing = 0; thing < db_top; thing++) {
if (Owner(thing) == who && !IsDivision(who)) {
if (!IsGarbage(thing))
- ++owned;
+ ++owned;
} else if(IsDivision(who) && IsDivision(Division(thing)) && div_inscope(who,thing) ) { /* incase we're doing division quotas */
if(!IsGarbage(thing) && !IsPlayer(thing)) /* we don't include garbage or player objects in div quotas */
- ++owned;
+ ++owned;
}
/* And No matter what.. we have to calculate the same info from the division we're in.. */
if( !IsMasterDivision(Division(who)) && !IsGarbage(thing) && !IsPlayer(thing) && IsDivision(Division(thing))&&
- div_inscope(Division(who), thing))
- downed++;
+ div_inscope(Division(who), thing))
+ downed++;
}
if(!IsMasterDivision(Division(who)) && !NoQuota(Division(who)))
if (!set_q) {
limit = get_current_quota(who);
notify_format(player, T("Objects: %d Limit: %d"), owned, (downed + dlimit) < (owned + limit) && dlimit != NOTHING
- ? (downed + dlimit) : (owned + limit));
+ ? (downed + dlimit) : (owned + limit));
return;
}
/* set a new quota */
if (!arg2 || !*arg2) {
limit = get_current_quota(who);
notify_format(player, T("Objects: %d Limit: %d"), owned, (downed + dlimit) < (owned + limit) && dlimit != NOTHING ?
- (downed + dlimit) : (owned + limit));
+ (downed + dlimit) : (owned + limit));
notify(player, T("What do you want to set the quota to?"));
return;
}
limit = owned + get_current_quota(who) + atoi(arg2);
else
limit = atoi(arg2);
- if (limit < owned) /* always have enough quota for your objects */
+ if (limit < owned) /* always have enough quota for your objects */
limit = owned;
if(limit < dlimit && dlimit != NOTHING)
limit = dlimit;
(void) atr_add(!IsDivision(who) ? Owner(who) : who, "RQUOTA", tprintf("%d", limit - owned), GOD,
- NOTHING);
+ NOTHING);
notify_format(player, T("Objects: %d Limit: %d"), owned, limit);
}
continue;
/* count up all owned objects */
- owned = -1; /* a player is never included in his own
- * quota */
+ owned = -1; /* a player is never included in his own
+ * quota */
for (thing = 0; thing < db_top; thing++) {
if (Owner(thing) == who)
- if (!IsGarbage(thing))
- ++owned;
+ if (!IsGarbage(thing))
+ ++owned;
}
if (NoQuota(who)) {
if (!quiet)
- notify_format(player, "%s: Objects: %d Limit: UNLIMITED",
- Name(who), owned);
+ notify_format(player, "%s: Objects: %d Limit: UNLIMITED",
+ Name(who), owned);
continue;
}
if (!quiet) {
oldlimit = get_current_quota(who);
notify_format(player, "%s: Objects: %d Limit: %d",
- Name(who), owned, oldlimit);
+ Name(who), owned, oldlimit);
}
if (limit != -1) {
if (limit <= owned) {
- (void) atr_add(who, "RQUOTA", "0", GOD, NOTHING);
+ (void) atr_add(who, "RQUOTA", "0", GOD, NOTHING);
} else {
- (void) atr_add(who, "RQUOTA", tprintf("%d", limit - owned), GOD,
- NOTHING);
+ (void) atr_add(who, "RQUOTA", tprintf("%d", limit - owned), GOD,
+ NOTHING);
}
}
}
return 0;
if(RPMODE(victim) && !(Can_RPTEL(player)||Director(player))) /* require RPTEL power to tport things in RPMODE */
- return 0;
+ return 0;
if (Tel_Thing(player, victim))
return 1;
*/
void
do_teleport(dbref player, const char *arg1, const char *arg2, int silent,
- int inside)
+ int inside)
{
dbref victim;
dbref destination;
dbref loc;
const char *to;
- dbref absroom; /* "absolute room", for NO_TEL check */
+ dbref absroom; /* "absolute room", for NO_TEL check */
/* get victim, destination */
if (*arg2 == '\0') {
to = arg1;
} else {
if ((victim =
- noisy_match_result(player, arg1, NOTYPE,
- MAT_OBJECTS | MAT_ENGLISH)) == NOTHING) {
+ noisy_match_result(player, arg1, NOTYPE,
+ MAT_OBJECTS | MAT_ENGLISH)) == NOTHING) {
return;
}
to = arg2;
*/
if (player == victim) {
if (Fixed(victim) || RPMODE(victim))
- notify(player, T("You can't do that IC!"));
+ notify(player, T("You can't do that IC!"));
else
- safe_tel(victim, HOME, silent);
+ safe_tel(victim, HOME, silent);
return;
} else
destination = Home(victim);
return;
}
if (recursive_member(destination, victim, 0)
- || (victim == destination)) {
+ || (victim == destination)) {
notify(player, T("Bad destination."));
return;
}
if (!Tel_Where(player, destination)
- && IsPlayer(victim) && IsPlayer(destination)) {
+ && IsPlayer(victim) && IsPlayer(destination)) {
notify(player, T("Bad destination."));
return;
}
if (IsExit(victim)) {
/* Teleporting an exit means moving its source */
if (!IsRoom(destination)) {
- notify(player, T("Exits can only be teleported to other rooms."));
- return;
+ notify(player, T("Exits can only be teleported to other rooms."));
+ return;
}
if (Going(destination)) {
- notify(player,
- T("You can't move an exit to someplace that's crumbling."));
- return;
+ notify(player,
+ T("You can't move an exit to someplace that's crumbling."));
+ return;
}
if (!GoodObject(Home(victim)))
- loc = find_entrance(victim);
+ loc = find_entrance(victim);
else
- loc = Home(victim);
+ loc = Home(victim);
/* Unlike normal teleport, you must control the destination
* or have the open_anywhere power
*/
if (!(tport_control_ok(player, victim, loc) &&
- (controls(player, destination) || CanOpen(player, destination)))) {
- notify(player, T("Permission denied."));
- return;
+ (controls(player, destination) || CanOpen(player, destination)))) {
+ notify(player, T("Permission denied."));
+ return;
}
/* Remove it from its old room */
Exits(loc) = remove_first(Exits(loc), victim);
Source(victim) = destination;
PUSH(victim, Exits(destination));
if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player)))
- notify(player, T("Teleported."));
+ notify(player, T("Teleported."));
return;
}
loc = Location(victim);
/* if properly empowered and destination is player, tel to location */
if (IsPlayer(destination) && Can_Locate(player,destination) && Tel_Where(player, destination) && IsPlayer(victim)
- && !inside) {
+ && !inside) {
if (!silent && loc != Location(destination))
- did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc);
+ did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc);
safe_tel(victim, Location(destination), silent);
if (!silent && loc != Location(destination))
- did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT",
- Location(destination));
+ did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT",
+ Location(destination));
return;
}
/* check needed for NOTHING. Especially important for unlinked exits */
/* At this point, they're in a bad location, so let's check
* if home is valid before sending them there. */
if (!GoodObject(Home(victim)))
- Home(victim) = PLAYER_START;
+ Home(victim) = PLAYER_START;
do_move(victim, "home", 0);
return;
} else {
/* if player is inside himself, send him home */
if (absroom == victim) {
- notify(player, T("What are you doing inside of yourself?"));
- if (Home(victim) == absroom)
- Home(victim) = PLAYER_START;
- do_move(victim, "home", 0);
- return;
+ notify(player, T("What are you doing inside of yourself?"));
+ if (Home(victim) == absroom)
+ Home(victim) = PLAYER_START;
+ do_move(victim, "home", 0);
+ return;
}
/* find the "absolute" room */
absroom = absolute_room(victim);
if (absroom == NOTHING) {
- notify(victim, T("You're in the void - sending you home."));
- if (Home(victim) == Location(victim))
- Home(victim) = PLAYER_START;
- do_move(victim, "home", 0);
- return;
+ notify(victim, T("You're in the void - sending you home."));
+ if (Home(victim) == Location(victim))
+ Home(victim) = PLAYER_START;
+ do_move(victim, "home", 0);
+ return;
}
/* if there are a lot of containers, send him home */
if (absroom == AMBIGUOUS) {
- notify(victim, T("You're in too many containers."));
- if (Home(victim) == Location(victim))
- Home(victim) = PLAYER_START;
- do_move(victim, "home", 0);
- return;
+ notify(victim, T("You're in too many containers."));
+ if (Home(victim) == Location(victim))
+ Home(victim) = PLAYER_START;
+ do_move(victim, "home", 0);
+ return;
}
/* note that we check the NO_TEL status of the victim rather
* than the player that issued the command. This prevents someone
/* now check to see if the absolute room is set NO_TEL */
if (NoTel(absroom) && !controls(player, absroom)
- && !Tel_Where(player, absroom)) {
- notify(player, T("Teleports are not allowed in this room."));
- return;
+ && !Tel_Where(player, absroom)) {
+ notify(player, T("Teleports are not allowed in this room."));
+ return;
}
/* Check leave lock on room, if necessary */
if (!controls(player, absroom) && !Tel_Where(player, absroom) &&
- !eval_lock(player, absroom, Leave_Lock)) {
- fail_lock(player, absroom, Leave_Lock,
- T("Teleports are not allowed in this room."), NOTHING);
- return;
+ !eval_lock(player, absroom, Leave_Lock)) {
+ fail_lock(player, absroom, Leave_Lock,
+ T("Teleports are not allowed in this room."), NOTHING);
+ return;
}
/* Now check the Z_TEL status of the victim's room.
* the destination must also be a room in the same zone
*/
if (GoodObject(Zone(absroom)) && (ZTel(absroom) || ZTel(Zone(absroom)))
- && !controls(player, absroom) && !Tel_Where(player, absroom)
- && (Zone(absroom) != Zone(destination))) {
- notify(player,
- T("You may not teleport out of the zone from this room."));
- return;
+ && !controls(player, absroom) && !Tel_Where(player, absroom)
+ && (Zone(absroom) != Zone(destination))) {
+ notify(player,
+ T("You may not teleport out of the zone from this room."));
+ return;
}
}
if (!IsExit(destination)) {
if (tport_control_ok(player, victim, Location(victim)) &&
- tport_dest_ok(player, victim, destination)
- && (Tel_Thing(player, victim) ||
- (Tel_Where(player, destination) && (player == victim)) ||
- (destination == Owner(victim)) ||
- (!Fixed(Owner(victim)) && !Fixed(player)))) {
- if (!silent && loc != destination)
- did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc);
- safe_tel(victim, destination, silent);
- if (!silent && loc != destination)
- did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT",
- destination);
- if ((victim != player) && !(Puppet(victim) &&
- (Owner(victim) == Owner(player)))) {
- if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player)))
- notify(player, T("Teleported."));
- }
- return;
+ tport_dest_ok(player, victim, destination)
+ && (Tel_Thing(player, victim) ||
+ (Tel_Where(player, destination) && (player == victim)) ||
+ (destination == Owner(victim)) ||
+ (!Fixed(Owner(victim)) && !Fixed(player)))) {
+ if (!silent && loc != destination)
+ did_it(victim, victim, NULL, NULL, "OXTPORT", NULL, NULL, loc);
+ safe_tel(victim, destination, silent);
+ if (!silent && loc != destination)
+ did_it(victim, victim, "TPORT", NULL, "OTPORT", NULL, "ATPORT",
+ destination);
+ if ((victim != player) && !(Puppet(victim) &&
+ (Owner(victim) == Owner(player)))) {
+ if (!Quiet(player) && !(Quiet(victim) && (Owner(victim) == player)))
+ notify(player, T("Teleported."));
+ }
+ return;
}
/* we can't do it */
fail_lock(player, destination, Enter_Lock, T("Permission denied."),
- Location(player));
+ Location(player));
return;
} else {
/* attempted teleport to an exit */
if ((Tel_Thing(player, victim) || controls(player, victim)
- || controls(player, Location(victim)))
- && !Fixed(Owner(victim)) && !Fixed(player)) {
- do_move(victim, to, 0);
+ || controls(player, Location(victim)))
+ && !Fixed(Owner(victim)) && !Fixed(player)) {
+ do_move(victim, to, 0);
} else {
- notify(player, T("Permission denied."));
- if (victim != player)
- notify_format(victim,
- T("%s tries to impose his will on you and fails."),
- Name(player));
+ notify(player, T("Permission denied."));
+ if (victim != player)
+ notify_format(victim,
+ T("%s tries to impose his will on you and fails."),
+ Name(player));
}
}
}
{
/* Log forces when necessary */
if (Owner(victim) != Owner(player))
- do_log(LT_WIZ, player, victim, "** FORCE: %s", command);
+ do_log(LT_WIZ, player, victim, "** FORCE: %s", command);
}
}
if (God(victim) && !God(player)) {
s = command + 1;
while (*s && !isspace((unsigned char) *s)) {
if (!isdigit((unsigned char) *s))
- return 0; /* #1a is no good */
+ return 0; /* #1a is no good */
s++;
}
if (!*s)
- return 0; /* dbref with no action is no good */
- *s = '='; /* Replace the first space with = so we have #3= <action> */
+ return 0; /* dbref with no action is no good */
+ *s = '='; /* Replace the first space with = so we have #3= <action> */
return 1;
}
if (owner == ANY_OWNER || owner == Owner(i)) {
si.total++;
if (IsGarbage(i)) {
- si.garbage++;
+ si.garbage++;
} else {
- switch (Typeof(i)) {
- case TYPE_ROOM:
- si.rooms++;
- break;
- case TYPE_EXIT:
- si.exits++;
- break;
- case TYPE_THING:
- si.things++;
- break;
- case TYPE_PLAYER:
- si.players++;
- break;
+ switch (Typeof(i)) {
+ case TYPE_ROOM:
+ si.rooms++;
+ break;
+ case TYPE_EXIT:
+ si.exits++;
+ break;
+ case TYPE_THING:
+ si.things++;
+ break;
+ case TYPE_PLAYER:
+ si.players++;
+ break;
case TYPE_DIVISION:
si.divisions++;
break;
- default:
- break;
- }
+ default:
+ break;
+ }
}
}
}
si = get_stats(owner);
if (owner == ANY_OWNER) {
notify_format(player,
- T
- ("%d objects = %d rooms, %d exits, %d things, %d players, %d divisions, %d garbage."),
- si->total, si->rooms, si->exits, si->things, si->players,
- si->divisions, si->garbage);
+ T
+ ("%d objects = %d rooms, %d exits, %d things, %d players, %d divisions, %d garbage."),
+ si->total, si->rooms, si->exits, si->things, si->players,
+ si->divisions, si->garbage);
if (first_free != NOTHING)
notify_format(player, T("The next object to be created will be #%d."),
- first_free);
+ first_free);
} else {
notify_format(player,
- T("%d objects = %d rooms, %d exits, %d things, %d players, %d divisions."),
- si->total - si->garbage, si->rooms, si->exits, si->things,
- si->players, si->divisions);
+ T("%d objects = %d rooms, %d exits, %d things, %d players, %d divisions."),
+ si->total - si->garbage, si->rooms, si->exits, si->things,
+ si->players, si->divisions);
}
}
*/
void
do_newpassword(dbref player, dbref cause,
- const char *name, const char *password)
+ const char *name, const char *password)
{
dbref victim;
sp = password;
bp = pass_eval;
process_expression(pass_eval, &bp, &sp, player, player, cause,
- PE_DEFAULT, PT_DEFAULT, NULL);
+ PE_DEFAULT, PT_DEFAULT, NULL);
*bp = '\0';
password = pass_eval;
}
Typeof(victim) != TYPE_DIVISION )) {
notify(player, T("No such player or division."));
} else if(CanNewpass(player, victim)
- || (Can_BCREATE(player) && (has_flag_by_name(victim, "BUILDER",
- TYPE_PLAYER))
- && (LEVEL(player) >= LEVEL(victim)))) {
+ || (Can_BCREATE(player) && (has_flag_by_name(victim, "BUILDER",
+ TYPE_PLAYER))
+ && (LEVEL(player) >= LEVEL(victim)))) {
if(Typeof(victim) != TYPE_DIVISION && Typeof(victim) != TYPE_PLAYER) {
notify(player, "Wtf happened?");
- return;
+ return;
}
if (*password != '\0' && !ok_password(password)) {
/* Wiz can set null passwords, but not bad passwords */
(void) atr_add(victim, "XYXXY", mush_crypt(password), GOD, NOTHING);
notify_format(player, T("Password for %s changed."), Name(victim));
notify_format(victim, T("Your password has been changed by %s."),
- Name(player));
+ Name(player));
do_log(LT_WIZ, player, victim, "*** NEWPASSWORD ***");
}
} else {
else if (victim == NOTHING) {
d = port_desc(atoi(name));
if (!d) {
- notify(player, "There is no one connected on that descriptor.");
- return;
+ notify(player, "There is no one connected on that descriptor.");
+ return;
} else
- victim = AMBIGUOUS;
+ victim = AMBIGUOUS;
}
break;
case BOOT_NAME:
/* boot by name */
if ((victim =
- noisy_match_result(player, name, TYPE_PLAYER,
- MAT_LIMITED | MAT_ME)) == NOTHING) {
+ noisy_match_result(player, name, TYPE_PLAYER,
+ MAT_LIMITED | MAT_ME)) == NOTHING) {
notify(player, T("No such connected player."));
return;
}
n_target = player;
} else {
if ((n_target =
- noisy_match_result(player, target, TYPE_PLAYER,
- MAT_LIMITED)) == NOTHING)
+ noisy_match_result(player, target, TYPE_PLAYER,
+ MAT_LIMITED)) == NOTHING)
return;
}
notify(player, object_header(player, thing));
notify_format(player, T("Flags value: %s"),
- bits_to_string("FLAG", Flags(thing), GOD, NOTHING));
+ bits_to_string("FLAG", Flags(thing), GOD, NOTHING));
notify_format(player, "Next: %d", Next(thing));
notify_format(player, "Contents: %d", Contents(thing));
/* First argument is a player, so we could have a quoted name */
if (PLAYER_NAME_SPACES && *arg1 == '\"') {
for (; *arg1 && ((*arg1 == '\"') || isspace((unsigned char) *arg1));
- arg1++) ;
+ arg1++) ;
strcpy(tbuf, arg1);
while (*arg2 && (*arg2 != '\"')) {
while (*arg2 && (*arg2 != '\"'))
- arg2++;
+ arg2++;
if (*arg2 == '\"') {
- *arg2++ = '\0';
- while (*arg2 && isspace((unsigned char) *arg2))
- arg2++;
- break;
+ *arg2++ = '\0';
+ while (*arg2 && isspace((unsigned char) *arg2))
+ arg2++;
+ break;
}
}
} else {
if (!*arg2) {
if (!arg3[1] || !*arg3[1])
- arg2 = (char *) ""; /* arg1 */
+ arg2 = (char *) ""; /* arg1 */
else {
- arg2 = (char *) arg1; /* arg2=arg3 */
+ arg2 = (char *) arg1; /* arg2=arg3 */
tbuf[0] = '\0';
}
}
for (n = 0; n < nresults; n++) {
switch (Typeof(results[n])) {
case TYPE_THING:
- things[nthings++] = results[n];
- break;
+ things[nthings++] = results[n];
+ break;
case TYPE_EXIT:
- exits[nexits++] = results[n];
- break;
+ exits[nexits++] = results[n];
+ break;
case TYPE_ROOM:
- rooms[nrooms++] = results[n];
- break;
+ rooms[nrooms++] = results[n];
+ break;
case TYPE_PLAYER:
- players[nplayers++] = results[n];
- break;
+ players[nplayers++] = results[n];
+ break;
case TYPE_DIVISION:
divisions[ndivisions++] = results[n];
break;
default:
- /* Unknown type. Ignore. */
- do_rawlog(LT_ERR, T("Weird type for dbref #%d"), results[n]);
+ /* Unknown type. Ignore. */
+ do_rawlog(LT_ERR, T("Weird type for dbref #%d"), results[n]);
}
}
if (nrooms) {
notify(player, "\nROOMS:");
for (n = 0; n < nrooms; n++) {
- tbp = tbuf;
- safe_format(tbuf, &tbp, "%s [owner: ", object_header(player, rooms[n]));
- safe_str(object_header(player, Owner(rooms[n])), tbuf, &tbp);
- safe_chr(']', tbuf, &tbp);
- *tbp = '\0';
- notify(player, tbuf);
+ tbp = tbuf;
+ safe_format(tbuf, &tbp, "%s [owner: ", object_header(player, rooms[n]));
+ safe_str(object_header(player, Owner(rooms[n])), tbuf, &tbp);
+ safe_chr(']', tbuf, &tbp);
+ *tbp = '\0';
+ notify(player, tbuf);
}
}
notify(player, "\nEXITS:");
for (n = 0; n < nexits; n++) {
- tbp = tbuf;
- if (Source(exits[n]) == NOTHING)
- from = NOTHING;
- else
- from = Source(exits[n]);
- to = Destination(exits[n]);
- safe_format(tbuf, &tbp, "%s [from ", object_header(player, exits[n]));
- safe_str((from == NOTHING) ? "NOWHERE" : object_header(player, from),
- tbuf, &tbp);
- safe_str(" to ", tbuf, &tbp);
- safe_str((to == NOTHING) ? "NOWHERE" : object_header(player, to),
- tbuf, &tbp);
- safe_chr(']', tbuf, &tbp);
- *tbp = '\0';
- notify(player, tbuf);
+ tbp = tbuf;
+ if (Source(exits[n]) == NOTHING)
+ from = NOTHING;
+ else
+ from = Source(exits[n]);
+ to = Destination(exits[n]);
+ safe_format(tbuf, &tbp, "%s [from ", object_header(player, exits[n]));
+ safe_str((from == NOTHING) ? "NOWHERE" : object_header(player, from),
+ tbuf, &tbp);
+ safe_str(" to ", tbuf, &tbp);
+ safe_str((to == NOTHING) ? "NOWHERE" : object_header(player, to),
+ tbuf, &tbp);
+ safe_chr(']', tbuf, &tbp);
+ *tbp = '\0';
+ notify(player, tbuf);
}
}
if (nthings) {
notify(player, "\nTHINGS:");
for (n = 0; n < nthings; n++) {
- tbp = tbuf;
- safe_format(tbuf, &tbp, "%s [owner: ",
- object_header(player, things[n]));
- safe_str(object_header(player, Owner(things[n])), tbuf, &tbp);
- safe_chr(']', tbuf, &tbp);
- *tbp = '\0';
- notify(player, tbuf);
+ tbp = tbuf;
+ safe_format(tbuf, &tbp, "%s [owner: ",
+ object_header(player, things[n]));
+ safe_str(object_header(player, Owner(things[n])), tbuf, &tbp);
+ safe_chr(']', tbuf, &tbp);
+ *tbp = '\0';
+ notify(player, tbuf);
}
}
if (nplayers) {
notify(player, "\nPLAYERS:");
for (n = 0; n < nplayers; n++) {
- tbp = tbuf;
- safe_str(object_header(player, players[n]), tbuf, &tbp);
- if (Can_Examine(player, players[n]))
- safe_format(tbuf, &tbp,
- T(" [location: %s]"),
- object_header(player, Location(players[n])));
- *tbp = '\0';
- notify(player, tbuf);
+ tbp = tbuf;
+ safe_str(object_header(player, players[n]), tbuf, &tbp);
+ if (Can_Examine(player, players[n]))
+ safe_format(tbuf, &tbp,
+ T(" [location: %s]"),
+ object_header(player, Location(players[n])));
+ *tbp = '\0';
+ notify(player, tbuf);
}
}
if (ndivisions) {
notify(player, "\nDIVISIONS:");
for (n = 0; n < ndivisions; n++) {
- tbp = tbuf;
- safe_format(tbuf, &tbp, "%s [owner: ",
- object_header(player, divisions[n]));
- safe_str(object_header(player, Owner(divisions[n])), tbuf, &tbp);
- safe_chr(']', tbuf, &tbp);
- *tbp = '\0';
- notify(player, tbuf);
+ tbp = tbuf;
+ safe_format(tbuf, &tbp, "%s [owner: ",
+ object_header(player, divisions[n]));
+ safe_str(object_header(player, Owner(divisions[n])), tbuf, &tbp);
+ safe_chr(']', tbuf, &tbp);
+ *tbp = '\0';
+ notify(player, tbuf);
}
}
notify(player, T("---------- Search Done ----------"));
notify_format(player,
- T
- ("Totals: Rooms...%d Exits...%d Things...%d Players...%d Divisions...%d"),
- nrooms, nexits, nthings, nplayers, ndivisions);
+ T
+ ("Totals: Rooms...%d Exits...%d Things...%d Players...%d Divisions...%d"),
+ nrooms, nexits, nthings, nplayers, ndivisions);
mush_free((Malloc_t) rooms, "dbref_list");
mush_free((Malloc_t) exits, "dbref_list");
mush_free((Malloc_t) things, "dbref_list");
} else {
nresults =
raw_search(executor, args[0], nargs - 1, (const char **) (args + 1),
- &results, pe_info);
+ &results, pe_info);
}
if (nresults < 0) {
int first = 1, n;
if (!rev) {
for (n = 0; n < nresults; n++) {
- if (first)
- first = 0;
- else if (safe_chr(' ', buff, bp))
- break;
- if (safe_dbref(results[n], buff, bp))
- break;
+ if (first)
+ first = 0;
+ else if (safe_chr(' ', buff, bp))
+ break;
+ if (safe_dbref(results[n], buff, bp))
+ break;
}
} else {
for (n = nresults - 1; n >= 0; n--) {
- if (first)
- first = 0;
- else if (safe_chr(' ', buff, bp))
- break;
- if (safe_dbref(results[n], buff, bp))
- break;
+ if (first)
+ first = 0;
+ else if (safe_chr(' ', buff, bp))
+ break;
+ if (safe_dbref(results[n], buff, bp))
+ break;
}
}
}
#ifdef WIN32
-#pragma warning( disable : 4761) /* Disable bogus conversion warning */
+#pragma warning( disable : 4761) /* Disable bogus conversion warning */
#endif
/* ARGSUSED */
FUNCTION(fun_hidden)
{
dbref it = match_thing(executor, args[0]);
if (CanSee(executor, it) && ((Admin(executor) ||
- Location(executor) == Location(it) || Location(it) == executor))) {
+ Location(executor) == Location(it) || Location(it) == executor))) {
if ((it == NOTHING) || (!IsPlayer(it))) {
notify(executor, T("Couldn't find that player."));
safe_str("#-1", buff, bp);
safe_boolean(hidden(it), buff, bp);
return;
} else {
- notify(executor, T("Permission denied."));
- safe_str("#-1", buff, bp);
- return;
+ notify(executor, T("Permission denied."));
+ safe_str("#-1", buff, bp);
+ return;
}
}
#ifdef WIN32
-#pragma warning( default : 4761) /* Re-enable conversion warning */
+#pragma warning( default : 4761) /* Re-enable conversion warning */
#endif
/* ARGSUSED */
return;
}
if (!(Do_Quotas(executor, who) || CanSee(executor, who)
- || controls(executor, who))) {
+ || controls(executor, who))) {
notify(executor, T("You can't see someone else's quota!"));
safe_str("#-1", buff, bp);
return;
return;
}
/* count up all owned objects */
- owned = -1; /* a player is never included in his own
- * quota */
+ owned = -1; /* a player is never included in his own
+ * quota */
for (thing = 0; thing < db_top; thing++) {
if (Owner(thing) == who)
if (!IsGarbage(thing))
- ++owned;
+ ++owned;
}
safe_integer(owned + get_current_quota(who), buff, bp);
*/
void
do_sitelock(dbref player, const char *site, const char *opts, const char *who,
- enum sitelock_type type)
+ enum sitelock_type type)
{
if (opts && *opts) {
notify(player, T("No valid options found."));
return;
}
- if (who && *who) { /* Specify a character */
+ if (who && *who) { /* Specify a character */
whod = lookup_player(who);
if (!GoodObject(whod)) {
- notify(player, T("Who do you want to lock?"));
- return;
+ notify(player, T("Who do you want to lock?"));
+ return;
}
}
write_access_file();
if (whod != AMBIGUOUS) {
notify_format(player,
- T("Site %s access options for %s(%s) set to %s"),
- site, Name(whod), unparse_dbref(whod), opts);
+ T("Site %s access options for %s(%s) set to %s"),
+ site, Name(whod), unparse_dbref(whod), opts);
do_log(LT_WIZ, player, NOTHING,
- T("*** SITELOCK *** %s for %s(%s) --> %s"), site,
- Name(whod), unparse_dbref(whod), opts);
+ T("*** SITELOCK *** %s for %s(%s) --> %s"), site,
+ Name(whod), unparse_dbref(whod), opts);
} else {
notify_format(player, T("Site %s access options set to %s"), site, opts);
do_log(LT_WIZ, player, NOTHING, "*** SITELOCK *** %s --> %s", site, opts);
do_log(LT_WIZ, player, NOTHING, "*** SITELOCK *** %s", site);
break;
case SITELOCK_CHECK:{
- struct access *ap;
- char tbuf[BUFFER_LEN], *bp;
- int rulenum;
- if (!site || !*site) {
- do_list_access(player);
- return;
- }
- ap = site_check_access(site, AMBIGUOUS, &rulenum);
- bp = tbuf;
- format_access(ap, rulenum, AMBIGUOUS, tbuf, &bp);
- *bp = '\0';
- notify(player, tbuf);
- break;
+ struct access *ap;
+ char tbuf[BUFFER_LEN], *bp;
+ int rulenum;
+ if (!site || !*site) {
+ do_list_access(player);
+ return;
+ }
+ ap = site_check_access(site, AMBIGUOUS, &rulenum);
+ bp = tbuf;
+ format_access(ap, rulenum, AMBIGUOUS, tbuf, &bp);
+ *bp = '\0';
+ notify(player, tbuf);
+ break;
}
case SITELOCK_REMOVE:{
- int n;
- n = remove_access_sitelock(site);
- if (n > 0)
- write_access_file();
- notify_format(player, T("%d sitelocks removed."), n);
- break;
+ int n;
+ n = remove_access_sitelock(site);
+ if (n > 0)
+ write_access_file();
+ notify_format(player, T("%d sitelocks removed."), n);
+ break;
}
}
}
} else {
notify(player, T("Any name matching these wildcard patterns is banned:"));
while (fgets(buffer, sizeof buffer, fp)) {
- if ((p = strchr(buffer, '\r')) != NULL)
- *p = '\0';
- else if ((p = strchr(buffer, '\n')) != NULL)
- *p = '\0';
- notify(player, buffer);
+ if ((p = strchr(buffer, '\r')) != NULL)
+ *p = '\0';
+ else if ((p = strchr(buffer, '\n')) != NULL)
+ *p = '\0';
+ notify(player, buffer);
}
fclose(fp);
}
- } else if (name[0] == '!') { /* Delete a name */
+ } else if (name[0] == '!') { /* Delete a name */
if ((fp = fopen(NAMES_FILE, FOPEN_READ)) != NULL) {
if ((fptmp = fopen("tmp.tmp", FOPEN_WRITE)) == NULL) {
- notify(player, T("Unable to delete name."));
- fclose(fp);
+ notify(player, T("Unable to delete name."));
+ fclose(fp);
} else {
- while (fgets(buffer, sizeof buffer, fp)) {
- if ((p = strchr(buffer, '\r')) != NULL)
- *p = '\0';
- else if ((p = strchr(buffer, '\n')) != NULL)
- *p = '\0';
- if (strcasecmp(buffer, name + 1) == 0)
- /* Replace the name with #NAME, to allow things like
- keeping track of unlocked feature names. */
- fprintf(fptmp, "#%s\n", buffer);
- else
- fprintf(fptmp, "%s\n", buffer);
- }
- fclose(fp);
- fclose(fptmp);
+ while (fgets(buffer, sizeof buffer, fp)) {
+ if ((p = strchr(buffer, '\r')) != NULL)
+ *p = '\0';
+ else if ((p = strchr(buffer, '\n')) != NULL)
+ *p = '\0';
+ if (strcasecmp(buffer, name + 1) == 0)
+ /* Replace the name with #NAME, to allow things like
+ keeping track of unlocked feature names. */
+ fprintf(fptmp, "#%s\n", buffer);
+ else
+ fprintf(fptmp, "%s\n", buffer);
+ }
+ fclose(fp);
+ fclose(fptmp);
#ifdef WIN32
- /* Windows can't rename to an existing file. */
- if (unlink(NAMES_FILE) != 0) {
- notify(player, T("Unable to delete name."));
- } else
+ /* Windows can't rename to an existing file. */
+ if (unlink(NAMES_FILE) != 0) {
+ notify(player, T("Unable to delete name."));
+ } else
#endif
- if (rename("tmp.tmp", NAMES_FILE) == 0) {
- notify(player, T("Name removed."));
- do_log(LT_WIZ, player, NOTHING, "*** UNLOCKED NAME *** %s", name + 1);
- } else {
- notify(player, T("Unable to delete name."));
- }
+ if (rename("tmp.tmp", NAMES_FILE) == 0) {
+ notify(player, T("Name removed."));
+ do_log(LT_WIZ, player, NOTHING, "*** UNLOCKED NAME *** %s", name + 1);
+ } else {
+ notify(player, T("Unable to delete name."));
+ }
}
} else
notify(player, T("Unable to delete name."));
- } else { /* Add a name */
+ } else { /* Add a name */
if ((fp = fopen(NAMES_FILE, FOPEN_READ)) != NULL) {
if ((fptmp = fopen("tmp.tmp", FOPEN_WRITE)) == NULL) {
- notify(player, T("Unable to lock name."));
+ notify(player, T("Unable to lock name."));
} else {
- /* Read the names file, looking for #NAME and writing it
- without the commenting #. Otherwise, add the new name
- to the end of the file */
- char commented[BUFFER_LEN + 1];
- int found = 0;
- commented[0] = '#';
- strcpy(commented + 1, name);
- while (fgets(buffer, sizeof buffer, fp) != NULL) {
- if ((p = strchr(buffer, '\r')) != NULL)
- *p = '\0';
- else if ((p = strchr(buffer, '\n')) != NULL)
- *p = '\0';
- if (strcasecmp(commented, buffer) == 0) {
- fprintf(fptmp, "%s\n", name);
- found = 1;
- } else
- fprintf(fptmp, "%s\n", buffer);
- }
- if (!found)
- fprintf(fptmp, "%s\n", name);
- fclose(fp);
- fclose(fptmp);
+ /* Read the names file, looking for #NAME and writing it
+ without the commenting #. Otherwise, add the new name
+ to the end of the file */
+ char commented[BUFFER_LEN + 1];
+ int found = 0;
+ commented[0] = '#';
+ strcpy(commented + 1, name);
+ while (fgets(buffer, sizeof buffer, fp) != NULL) {
+ if ((p = strchr(buffer, '\r')) != NULL)
+ *p = '\0';
+ else if ((p = strchr(buffer, '\n')) != NULL)
+ *p = '\0';
+ if (strcasecmp(commented, buffer) == 0) {
+ fprintf(fptmp, "%s\n", name);
+ found = 1;
+ } else
+ fprintf(fptmp, "%s\n", buffer);
+ }
+ if (!found)
+ fprintf(fptmp, "%s\n", name);
+ fclose(fp);
+ fclose(fptmp);
#ifdef WIN32
- /* Windows can't rename to an existing file. */
- if (unlink(NAMES_FILE) != 0) {
- notify(player, T("Unable to lock name."));
- } else
+ /* Windows can't rename to an existing file. */
+ if (unlink(NAMES_FILE) != 0) {
+ notify(player, T("Unable to lock name."));
+ } else
#endif
- if (rename("tmp.tmp", NAMES_FILE) == 0) {
- notify_format(player, T("Name %s locked."), name);
- do_log(LT_WIZ, player, NOTHING, "*** NAMELOCK *** %s", name);
- } else
- notify(player, T("Unable to lock name."));
+ if (rename("tmp.tmp", NAMES_FILE) == 0) {
+ notify_format(player, T("Name %s locked."), name);
+ do_log(LT_WIZ, player, NOTHING, "*** NAMELOCK *** %s", name);
+ } else
+ notify(player, T("Unable to lock name."));
}
}
}
int k;
ATTR *m;
lock_list *l;
- k = sizeof(struct object); /* overhead */
- k += strlen(Name(thing)) + 1; /* The name */
+ k = sizeof(struct object); /* overhead */
+ k += strlen(Name(thing)) + 1; /* The name */
for (m = List(thing); m; m = AL_NEXT(m)) {
k += sizeof(ATTR);
if (AL_STR(m) && *AL_STR(m))
strcpy(spec->name, "");
spec->low = 0;
spec->high = db_top - 1;
- spec->start = 1; /* 1-indexed */
+ spec->start = 1; /* 1-indexed */
spec->count = 0;
/* set limits on who we search */
/* A special old-timey kludge */
if (class && !*class && restriction && *restriction) {
if (isdigit(*restriction) || ((*restriction == '#') && *(restriction + 1)
- && isdigit(*(restriction + 1)))) {
+ && isdigit(*(restriction + 1)))) {
size_t offset = 0;
if (*restriction == '#')
offset = 1;
spec->high = parse_integer(restriction + offset);
if (!GoodObject(spec->high))
- spec->high = db_top - 1;
- continue;
+ spec->high = db_top - 1;
+ continue;
}
}
if (!class || !*class || !restriction)
if (!GoodObject(spec->low))
spec->low = 0;
if (isdigit(*restriction) || ((*restriction == '#') && *(restriction + 1)
- && isdigit(*(restriction + 1)))) {
- offset = 0;
- if (*restriction == '#')
- offset = 1;
- spec->high = parse_integer(restriction + offset);
- if (!GoodObject(spec->high))
- spec->high = db_top - 1;
+ && isdigit(*(restriction + 1)))) {
+ offset = 0;
+ if (*restriction == '#')
+ offset = 1;
+ spec->high = parse_integer(restriction + offset);
+ if (!GoodObject(spec->high))
+ spec->high = db_top - 1;
}
continue;
}
offset = 1;
spec->low = parse_integer(restriction + offset);
if (!GoodObject(spec->low))
- spec->low = 0;
+ spec->low = 0;
continue;
} else if (string_prefix("maxdb", class)) {
size_t offset = 0;
if (*restriction == '#')
- offset = 1;
+ offset = 1;
spec->high = parse_integer(restriction + offset);
if (!GoodObject(spec->high))
- spec->low = db_top - 1;
+ spec->low = db_top - 1;
continue;
}
if (string_prefix("type", class)) {
if (string_prefix("things", restriction)
- || string_prefix("objects", restriction)) {
- spec->type = TYPE_THING;
+ || string_prefix("objects", restriction)) {
+ spec->type = TYPE_THING;
} else if (string_prefix("rooms", restriction)) {
- spec->type = TYPE_ROOM;
+ spec->type = TYPE_ROOM;
} else if (string_prefix("exits", restriction)) {
- spec->type = TYPE_EXIT;
+ spec->type = TYPE_EXIT;
} else if (string_prefix("rooms", restriction)) {
- spec->type = TYPE_ROOM;
+ spec->type = TYPE_ROOM;
} else if (string_prefix("players", restriction)) {
- spec->type = TYPE_PLAYER;
+ spec->type = TYPE_PLAYER;
} else if (string_prefix("divisions", restriction)) {
spec->type = TYPE_DIVISION;
} else {
- notify(player, T("Unknown type."));
- return -1;
+ notify(player, T("Unknown type."));
+ return -1;
}
} else if (string_prefix("things", class)
- || string_prefix("objects", class)) {
+ || string_prefix("objects", class)) {
strcpy(spec->name, restriction);
spec->type = TYPE_THING;
} else if (string_prefix("exits", class)) {
} else if (string_prefix("start", class)) {
spec->start = parse_integer(restriction);
if (spec->start < 1) {
- notify(player, T("Invalid start index"));
- return -1;
+ notify(player, T("Invalid start index"));
+ return -1;
}
} else if (string_prefix("count", class)) {
spec->count = parse_integer(restriction);
if (spec->count < 1) {
- notify(player, T("Invalid count index"));
- return -1;
+ notify(player, T("Invalid count index"));
+ return -1;
}
} else if (string_prefix("parent", class)) {
if (!*restriction) {
- spec->parent = NOTHING;
- continue;
+ spec->parent = NOTHING;
+ continue;
}
if (!is_objid(restriction)) {
- notify(player, T("Unknown parent."));
- return -1;
+ notify(player, T("Unknown parent."));
+ return -1;
}
spec->parent = parse_objid(restriction);
if (!GoodObject(spec->parent)) {
- notify(player, T("Unknown parent."));
- return -1;
+ notify(player, T("Unknown parent."));
+ return -1;
}
} else if (string_prefix("zone", class)) {
if (!*restriction) {
- spec->zone = NOTHING;
- continue;
+ spec->zone = NOTHING;
+ continue;
}
if (!is_objid(restriction)) {
- notify(player, T("Unknown zone."));
- return -1;
+ notify(player, T("Unknown zone."));
+ return -1;
}
spec->zone = parse_objid(restriction);
if (!GoodObject(spec->zone)) {
- notify(player, T("Unknown zone."));
- return -1;
+ notify(player, T("Unknown zone."));
+ return -1;
}
} else if (string_prefix("division", class)) {
if (!*restriction) {
} else if (string_prefix("eval", class)) {
strcpy(spec->eval, restriction);
} else if (string_prefix("ethings", class) ||
- string_prefix("eobjects", class)) {
+ string_prefix("eobjects", class)) {
strcpy(spec->eval, restriction);
spec->type = TYPE_THING;
} else if (string_prefix("eexits", class)) {
div_pbits tmpbits;
/* Handle the checking later. */
if (!restriction || !*restriction) {
- notify(player, T("You must give a list of power names."));
- return -1;
+ notify(player, T("You must give a list of power names."));
+ return -1;
}
spec->search_powers = 1;
tmpbits = string_to_dpbits(restriction);
} else if (string_prefix("flags", class)) {
/* Handle the checking later. */
if (!restriction || !*restriction) {
- notify(player, T("You must give a string of flag characters."));
- return -1;
+ notify(player, T("You must give a string of flag characters."));
+ return -1;
}
strcpy(spec->flags, restriction);
} else if (string_prefix("lflags", class)) {
/* Handle the checking later. */
if (!restriction || !*restriction) {
- notify(player, T("You must give a list of flag names."));
- return -1;
+ notify(player, T("You must give a list of flag names."));
+ return -1;
}
strcpy(spec->lflags, restriction);
} else {
/* Does the actual searching */
static int
raw_search(dbref player, const char *owner, int nargs, const char **args,
- dbref **result, PE_Info * pe_info)
+ dbref **result, PE_Info * pe_info)
{
size_t result_size;
size_t nresults = 0;
/* make sure player has money to do the search */
if (!payfor(player, FIND_COST)) {
notify_format(player, T("Searches cost %d %s."), FIND_COST,
- ((FIND_COST == 1) ? MONEY : MONIES));
+ ((FIND_COST == 1) ? MONEY : MONIES));
return -1;
}
if (spec.division != ANY_OWNER && Division(n) != spec.division)
continue;
if (spec.subdivision != ANY_OWNER
- && !(div_inscope(spec.subdivision, n) && SDIV(n).object != NOTHING))
+ && !(div_inscope(spec.subdivision, n) && SDIV(n).object != NOTHING))
continue;
if (spec.parent != ANY_OWNER && Parent(n) != spec.parent)
continue;
ebuf2 = ebuf1;
bp = tbuf1;
process_expression(tbuf1, &bp, &ebuf2, player, player, player,
- PE_DEFAULT, PT_DEFAULT, pe_info);
+ PE_DEFAULT, PT_DEFAULT, pe_info);
mush_free((Malloc_t) ebuf1, "replace_string.buff");
*bp = '\0';
if (!parse_boolean(tbuf1))
- continue;
+ continue;
}
/* Only include the matching dbrefs from start to start+count */
dbref *newresults;
result_size *= 2;
newresults =
- (dbref *) realloc((Malloc_t) *result, sizeof(dbref) * result_size);
+ (dbref *) realloc((Malloc_t) *result, sizeof(dbref) * result_size);
if (!newresults)
- mush_panic(T("Couldn't reallocate memory in search!"));
+ mush_panic(T("Couldn't reallocate memory in search!"));
*result = newresults;
}
+++ /dev/null
-#!/usr/local/bin/perl
-#
-# Generate game/txt/hlp/ files from the CHANGES file(s).
-# Should be run by Makefile from top-level directory
-#
-# Usage: mkvershlp game/txt/hlp CHANGES.176 CHANGES.OLD ...
-#
-# Each file CHANGES.<blah> generates file pennv<blah>.hlp in the
-# specified directory.
-#
-use strict;
-use Sort::Versions;
-use Text::Wrap;
-
-my $targetdir = shift;
-my @sources = @ARGV;
-my $verspat = '^Version (\S+) patchlevel (\S+)';
-my %patchlevels;
-
-@sources = sort byrevision @sources;
-
-my $really_started = 0;
-foreach my $file (@sources) {
- warn "Can't open $file!\n", next unless open(IN,"<$file");
- my $target = $file;
- $target =~ s/.*\.(.*)/pennv$1.hlp/;
- open(OUT,">$targetdir/$target") or die "Unable to open $targetdir/$target\n";
- my $started = 0;
- while (<IN>) {
- if (/$verspat/o) {
- print OUT "& $1p$2\n";
- push @{$patchlevels{$1}}, $2;
- unless ($started) {
- # This is the first one
- unless ($really_started) {
- print OUT <<'EOP';
-& changes
-This is a list of changes in this patchlevel which are probably of
-interest to players. More information about new commands and functions
-can probably be gotten via 'help <name of whatever>'. 'help credits'
-lists the [initials] of developers and porters that are used in the list
-of changes.
-
-Information about changes in prior releases can be found under
-help topics named for each release (e.g. 'help 1.7.2p30').
-A list of the patchlevels associated with each release can
-be read in 'help patchlevels'.
-
-EOP
- $really_started = 1;
- }
- $started = 1;
- }
- print OUT;
- } elsif ($started) {
- print OUT;
- }
- }
- close IN;
-}
-
-# Now spew the patchlevels list. Special case for 1.50
-$patchlevels{'1.5.0'} = $patchlevels{'1.50'};
-delete($patchlevels{'1.50'});
-my @versions = reverse sort versions keys %patchlevels;
-print OUT <<EOP;
-& patchlevels
-For information on a specific patchlevel of one of the versions listed,
-type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3'
-
-EOP
-foreach (@versions) {
- my @pls = sort {$a <=> $b} @{$patchlevels{$_}};
- my $line;
- if ($_ eq "1.5.0") {
- $line = "1.50: ". join(", ",@pls). "\n";
- } else {
- $line = "$_: ". join(", ",@pls). "\n";
- }
- print OUT wrap(""," ",$line);
-}
-
-close OUT;
-
-
-# A sort subroutine to order CHANGES.<blah> in reverse chronological
-# order
-sub byrevision {
- return $b cmp $a if ($a =~ /\d/ and $b =~ /\d/);
- return $a cmp $b;
-}
-