tmi2/
tmi2/bin/
tmi2/etc/
tmi2/lib/
tmi2/lib/adm/
tmi2/lib/adm/daemons/languages/
tmi2/lib/adm/daemons/network/I3/
tmi2/lib/adm/daemons/virtual/template/
tmi2/lib/adm/obj/master/
tmi2/lib/adm/priv/
tmi2/lib/adm/shell/
tmi2/lib/adm/tmp/
tmi2/lib/cmds/
tmi2/lib/d/
tmi2/lib/d/Conf/
tmi2/lib/d/Conf/adm/
tmi2/lib/d/Conf/boards/
tmi2/lib/d/Conf/cmds/
tmi2/lib/d/Conf/data/
tmi2/lib/d/Conf/logs/
tmi2/lib/d/Conf/obj/
tmi2/lib/d/Conf/text/help/
tmi2/lib/d/Fooland/adm/
tmi2/lib/d/Fooland/data/
tmi2/lib/d/Fooland/data/attic/
tmi2/lib/d/Fooland/items/
tmi2/lib/d/TMI/
tmi2/lib/d/TMI/adm/
tmi2/lib/d/TMI/boards/
tmi2/lib/d/TMI/data/
tmi2/lib/d/TMI/rooms/
tmi2/lib/d/grid/
tmi2/lib/d/grid/adm/
tmi2/lib/d/grid/data/
tmi2/lib/d/std/
tmi2/lib/d/std/adm/
tmi2/lib/data/adm/
tmi2/lib/data/adm/daemons/
tmi2/lib/data/adm/daemons/doc_d/
tmi2/lib/data/adm/daemons/emoted/
tmi2/lib/data/adm/daemons/network/http/
tmi2/lib/data/adm/daemons/network/services/mail_q/
tmi2/lib/data/adm/daemons/network/smtp/
tmi2/lib/data/adm/daemons/news/archives/
tmi2/lib/data/attic/connection/
tmi2/lib/data/attic/user/
tmi2/lib/data/std/connection/b/
tmi2/lib/data/std/connection/l/
tmi2/lib/data/std/user/a/
tmi2/lib/data/std/user/b/
tmi2/lib/data/std/user/d/
tmi2/lib/data/std/user/f/
tmi2/lib/data/std/user/l/
tmi2/lib/data/std/user/x/
tmi2/lib/data/u/d/dm/working/doc_d/
tmi2/lib/data/u/l/leto/doc_d/
tmi2/lib/data/u/l/leto/smtp/
tmi2/lib/doc/
tmi2/lib/doc/driverdoc/applies/
tmi2/lib/doc/driverdoc/concepts/
tmi2/lib/doc/driverdoc/driver/
tmi2/lib/doc/driverdoc/efuns/arrays/
tmi2/lib/doc/driverdoc/efuns/buffers/
tmi2/lib/doc/driverdoc/efuns/compile/
tmi2/lib/doc/driverdoc/efuns/ed/
tmi2/lib/doc/driverdoc/efuns/floats/
tmi2/lib/doc/driverdoc/efuns/functions/
tmi2/lib/doc/driverdoc/efuns/general/
tmi2/lib/doc/driverdoc/efuns/numbers/
tmi2/lib/doc/driverdoc/efuns/parsing/
tmi2/lib/doc/driverdoc/lpc/constructs/
tmi2/lib/doc/driverdoc/lpc/preprocessor/
tmi2/lib/doc/driverdoc/lpc/types/
tmi2/lib/doc/driverdoc/platforms/
tmi2/lib/doc/mudlib/
tmi2/lib/ftp/
tmi2/lib/log/
tmi2/lib/obj/net/
tmi2/lib/obj/shells/
tmi2/lib/std/board/
tmi2/lib/std/body/
tmi2/lib/std/fun/
tmi2/lib/std/living/
tmi2/lib/std/object/
tmi2/lib/std/shop/
tmi2/lib/std/socket/
tmi2/lib/std/virtual/
tmi2/lib/student/
tmi2/lib/student/kalypso/
tmi2/lib/student/kalypso/armor/
tmi2/lib/student/kalypso/rooms/
tmi2/lib/student/kalypso/weapons/
tmi2/lib/u/l/leto/
tmi2/lib/u/l/leto/cmds/
tmi2/lib/www/errors/
tmi2/lib/www/gateways/
tmi2/lib/www/images/
tmi2/old/
tmi2/v21.7a10/
tmi2/v21.7a10/ChangeLog.old/
tmi2/v21.7a10/compat/simuls/
tmi2/v21.7a10/include/
tmi2/v21.7a10/testsuite/
tmi2/v21.7a10/testsuite/clone/
tmi2/v21.7a10/testsuite/command/
tmi2/v21.7a10/testsuite/data/
tmi2/v21.7a10/testsuite/etc/
tmi2/v21.7a10/testsuite/include/
tmi2/v21.7a10/testsuite/inherit/
tmi2/v21.7a10/testsuite/inherit/master/
tmi2/v21.7a10/testsuite/log/
tmi2/v21.7a10/testsuite/u/
tmi2/v21.7a10/tmp/
#ifndef MACROS_H
#define MACROS_H

#ifdef __STDC__
#define ANSI_STRING_HACK(x) #x
#define DONT_ASK_WHY(x) (x)
#define WHERE (__FILE__ ":" DONT_ASK_WHY(x))
#else
#define WHERE "non-ansi compilers are a pain"
#endif

/*
 * Some useful macros...
 */
#ifdef BUFSIZ
#  define PROT_STDIO(x) PROT(x)
#else				/* BUFSIZ */
#  define PROT_STDIO(x) ()
#endif				/* BUFSIZ */

/* ANSI/K&R compatibility stuff;
 *
 * The correct way to prototype a function now is:
 *
 * foobar PROT((int, char *));
 *
 * foobar P2(int, x, char *, y) { ... }
 */
/* xlc can't handle an ANSI protoype followed by a K&R def, and varargs
 * functions must be done K&R (b/c va_dcl is K&R style) so don't prototype
 * vararg function arguments under AIX
 */
#ifdef __STDC__
#  define PROT(x) x
#  define P1(t1, v1) (t1 v1)
#  define P2(t1, v1, t2, v2) (t1 v1, t2 v2)
#  define P3(t1, v1, t2, v2, t3, v3) (t1 v1, t2 v2, t3 v3)
#  define P4(t1, v1, t2, v2, t3, v3, t4, v4) (t1 v1, t2 v2, t3 v3, t4 v4)
#  define P5(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5)
#  define P6(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5, t6 v6)
#  define P7(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5, t6 v6, t7 v7)
#  define VOLATILE volatile
#  define SIGNED signed
#else				/* __STDC__ */
#  define PROT(x) ()
#  define P1(t1, v1) (v1) t1 v1;
#  define P2(t1, v1, t2, v2) (v1, v2) t1 v1; t2 v2;
#  define P3(t1, v1, t2, v2, t3, v3) (v1, v2, v3) t1 v1; t2 v2; t3 v3;
#  define P4(t1, v1, t2, v2, t3, v3, t4, v4) (v1, v2, v3, v4) t1 v1; t2 v2; t3 v3; t4 v4;
#  define P5(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) (v1, v2, v3, v4, v5) t1 v1; t2 v2; t3 v3; t4 v4; t5 v5;
#  define P6(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) (v1, v2, v3, v4, v5, v6) t1 v1; t2 v2; t3 v3; t4 v4; t5 v5; t6 v6;
#  define P7(t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) (v1, v2, v3, v4, v5, v6, v7) t1 v1; t2 v2; t3 v3; t4 v4; t5 v5; t6 v6; t7 v7;
#  define VOLATILE
#  define SIGNED
#endif				/* __STDC__ */

/* do things both ways ... */
#ifdef INCL_STDARG_H
#  define PROT1V(x) (x, ...)
#  define P1V(t1, x1) (t1 x1, ...)
#  define V_START(vlist, last_arg) va_start(vlist, last_arg)

#  define PROT2V(x, y) (x, y, ...)
#  define P2V(t1, x1, t2, x2) (t1 x1, t2 x2, ...)
#  define V_START(vlist, last_arg) va_start(vlist, last_arg)

#  define V_VAR(type, var, vlist)
#  define V_DCL(x)
#else
#  define PROT1V(x) ()
#  define P1V(t1, x) (va_alist) va_dcl
#  define V_START(vlist, last_arg) va_start(vlist)

#  define PROT2V(x, y) ()
#  define P2V(t1, x1, t2, x2) (va_alist) va_dcl

#  define V_VAR(type, var, vlist) var = va_arg(vlist, type)
#  define V_DCL(x) x
#endif

#ifndef INLINE
#  if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(lint) && !defined(PEDANTIC)
#    define INLINE inline
#  else
#    ifdef LATTICE
#      define INLINE __inline
#    else
#      define INLINE
#    endif
#  endif
#endif

#define SAFE(x) do { x } while (0)
 

/*
   Define for MALLOC, FREE, REALLOC, and CALLOC depend upon what malloc
   package and optional wrapper is used.  This technique is used because
   overlaying system malloc with another function also named malloc doesn't
   work on most mahines that have shared libraries.  It will also let
   us keep malloc stats even when system malloc is used.

   Please refer to options.h for selecting malloc package and wrapper.
*/
#if defined (WRAPPEDMALLOC) && !defined(IN_MALLOC_WRAPPER)

#  define MALLOC(x)               wrappedmalloc(x)
#  define FREE(x)                 wrappedfree(x)
#  define REALLOC(x, y)           wrappedrealloc(x, y)
#  define CALLOC(x, y)            wrappedcalloc(x, y)
#  define XALLOC(x)               xalloc(x)
#  define DXALLOC(x, t, d)        xalloc(x)
#  define DMALLOC(x, t, d)        MALLOC(x)
#  define DREALLOC(x, y, t, d)    REALLOC(x,y)
#  define DCALLOC(x, y, t, d)     CALLOC(x,y)

#else

#  if defined(DEBUGMALLOC) && !defined(IN_MALLOC_WRAPPER)

#    define MALLOC(x)               debugmalloc(x, 0, (char *)0)
#    define DMALLOC(x, t, d)        debugmalloc(x, t, d)
#    define XALLOC(x)               debugmalloc(x, 0, (char *)0)
#    define DXALLOC(x, t, d)        debugmalloc(x, t, d)
#    define FREE(x)                 debugfree(x)
#    define REALLOC(x,y)            debugrealloc(x,y,0,(char *)0)
#    define DREALLOC(x,y,tag,desc)  debugrealloc(x,y,tag,desc)
#    define CALLOC(x,y)             debugcalloc(x,y,0,(char *)0)
#    define DCALLOC(x,y,tag,desc)   debugcalloc(x,y,tag,desc)

#  else

#    include "malloc.h"

#  endif
#endif

#ifndef MALLOC
#  define MALLOC(x)  puts("You need to specify a malloc package in options.h")
#  define FREE(x)    puts("You need to specify a malloc package in options.h")
#  define REALLOC(x) puts("You need to specify a malloc package in options.h")
#  define CALLOC(x)  puts("You need to specify a malloc package in options.h")
#endif

#define ALLOCATE(type, tag, desc) ((type *)DXALLOC(sizeof(type), tag, desc))
#define CALLOCATE(num, type, tag, desc) ((type *)DXALLOC(sizeof(type[1]) * (num), tag, desc))
#define RESIZE(ptr, num, type, tag, desc) ((type *)DREALLOC((void *)ptr, sizeof(type) * (num), tag, desc))

#ifdef DEBUG
#  define IF_DEBUG(x) x
#  define DEBUG_CHECK(x, y) if (x) fatal(y)
#  define DEBUG_CHECK1(x, y, a) if (x) fatal(y, a)
#  define DEBUG_CHECK2(x, y, a, b) if (x) fatal(y, a, b)
#else
#  define IF_DEBUG(x) 
#  define DEBUG_CHECK(x, y)
#  define DEBUG_CHECK1(x, y, a)
#  define DEBUG_CHECK2(x, y, a, b)
#endif

#if !defined(EDIT_SOURCE) && !defined(_FUNC_SPEC_)
#define COPY2(x, y)      ((char *)(x))[0] = ((char *)(y))[0]; \
                         ((char *)(x))[1] = ((char *)(y))[1]
#define LOAD2(x, y)      ((char *)&(x))[0] = *y++; \
                         ((char *)&(x))[1] = *y++
#define STORE2(x, y)     *x++ = ((char *)(&(y)))[0]; \
                         *x++ = ((char *)(&(y)))[1]

#define COPY4(x, y)      ((char *)(x))[0] = ((char *)(y))[0]; \
                         ((char *)(x))[1] = ((char *)(y))[1]; \
                         ((char *)(x))[2] = ((char *)(y))[2]; \
                         ((char *)(x))[3] = ((char *)(y))[3]
#define LOAD4(x, y)      ((char *)&(x))[0] = *y++; \
                         ((char *)&(x))[1] = *y++; \
                         ((char *)&(x))[2] = *y++; \
                         ((char *)&(x))[3] = *y++
#define STORE4(x, y)     *x++ = ((char *)(&(y)))[0]; \
                         *x++ = ((char *)(&(y)))[1]; \
                         *x++ = ((char *)(&(y)))[2]; \
                         *x++ = ((char *)(&(y)))[3]

#define COPY8(x, y)      ((char *)(x))[0] = ((char *)(y))[0]; \
                         ((char *)(x))[1] = ((char *)(y))[1]; \
                         ((char *)(x))[2] = ((char *)(y))[2]; \
                         ((char *)(x))[3] = ((char *)(y))[3]; \
                         ((char *)(x))[4] = ((char *)(y))[4]; \
                         ((char *)(x))[5] = ((char *)(y))[5]; \
                         ((char *)(x))[6] = ((char *)(y))[6]; \
                         ((char *)(x))[7] = ((char *)(y))[7]
#define LOAD8(x, y)      ((char *)&(x))[0] = *y++; \
                         ((char *)&(x))[1] = *y++; \
                         ((char *)&(x))[2] = *y++; \
                         ((char *)&(x))[3] = *y++; \
                         ((char *)&(x))[4] = *y++; \
                         ((char *)&(x))[5] = *y++; \
                         ((char *)&(x))[6] = *y++; \
                         ((char *)&(x))[7] = *y++;
#define STORE8(x, y)     *x++ = ((char *)(&(y)))[0]; \
                         *x++ = ((char *)(&(y)))[1]; \
                         *x++ = ((char *)(&(y)))[2]; \
                         *x++ = ((char *)(&(y)))[3]; \
                         *x++ = ((char *)(&(y)))[4]; \
                         *x++ = ((char *)(&(y)))[5]; \
                         *x++ = ((char *)(&(y)))[6]; \
                         *x++ = ((char *)(&(y)))[7]

#if SIZEOF_SHORT == 2
#define COPY_SHORT(x, y) COPY2(x,y)
#define LOAD_SHORT(x, y) LOAD2(x,y)
#define STORE_SHORT(x, y) STORE2(x,y)
#else
shorts of size other than 2 not implemented
#endif

#if SIZEOF_INT == 4
#define COPY_INT(x, y) COPY4(x,y)
#define LOAD_INT(x, y) LOAD4(x,y)
#define STORE_INT(x, y) STORE4(x,y)
#define INT_32 int
#else
ints of size other than 4 not implemented
#endif

#if SIZEOF_FLOAT == 4
#define COPY_FLOAT(x, y) COPY4(x,y)
#define LOAD_FLOAT(x, y) LOAD4(x,y)
#define STORE_FLOAT(x, y) STORE4(x,y)
#else
floats of size other than 4 not implemented
#endif

#if SIZEOF_PTR == 4
#  define COPY_PTR(x, y) COPY4(x,y)
#  define LOAD_PTR(x, y) LOAD4(x,y)
#  define STORE_PTR(x, y) STORE4(x,y)

#  define POINTER_INT int
#  define INS_POINTER ins_int
#else
#  if SIZEOF_PTR == 8
#    define COPY_PTR(x, y) COPY8(x,y)
#    define LOAD_PTR(x, y) LOAD8(x,y)
#    define STORE_PTR(x, y) STORE8(x,y)

#    define POINTER_INT long
#    define INS_POINTER ins_long
#  else
pointers of size other than 4 or 8 not implemented
#  endif
#endif
#endif

#ifndef _FUNC_SPEC_
   char *xalloc PROT((int));
#  ifdef DEBUGMALLOC
      char *int_string_copy PROT((char *, char *));
      char *int_string_unlink PROT((char *, char *));
      char *int_new_string PROT((int, char *));
      char *int_alloc_cstring PROT((char *, char *));
#  else
      char *int_string_copy PROT((char *));
      char *int_string_unlink PROT((char *));
      char *int_new_string PROT((int));
      char *int_alloc_cstring PROT((char *));
#  endif
#endif

#ifdef DEBUGMALLOC
#   define string_copy(x,y) int_string_copy(x, y)
#   define string_unlink(x,y) int_string_unlink(x, y)
#   define new_string(x,y) int_new_string(x, y)
#   define alloc_cstring(x,y) int_alloc_cstring(x, y)
#else
#   define string_copy(x,y) int_string_copy(x)
#   define string_unlink(x,y) int_string_unlink(x)
#   define new_string(x,y) int_new_string(x)
#   define alloc_cstring(x,y) int_alloc_cstring(x)
#endif

#endif