src/db.h

Go to the documentation of this file.
00001 
00002 /* db.h */
00003 
00004 #include "copyright.h"
00005 
00006 #ifndef __DB_H
00007 #define __DB_H
00008 
00009 #include "config.h"
00010 #include "mudconf.h"
00011 
00012 #include <sys/file.h>
00013 
00014 
00015 #define ITER_PARENTS(t,p,l)     for ((l)=0, (p)=(t); \
00016                                      (Good_obj(p) && \
00017                                       ((l) < mudconf.parent_nest_lim)); \
00018                                      (p)=Parent(p), (l)++)
00019 
00020 #define Hasprivs(x)      (Royalty(x) || Wizard(x))
00021 int get_atr();
00022 
00023 typedef struct attr ATTR;
00024 struct attr {
00025     const char *name;           /* This has to be first.  braindeath. */
00026     int number;                 /* attr number */
00027     int flags;
00028     int (*check)(int, dbref, dbref, int, char *);
00029 };
00030 
00031 typedef struct atrlist ATRLIST;
00032 struct atrlist {
00033     char *data;                 /* Attribute text. */
00034     int size;                   /* Length of attribute */
00035     int number;                 /* Attribute number. */
00036 };
00037 
00038 typedef struct stack STACK;
00039 struct stack {
00040     char *data;
00041     STACK *next;
00042 };
00043 
00044 extern ATTR *atr_num(int anum);
00045 extern ATTR *atr_str(char *s);
00046 
00047 extern ATTR attr[];
00048 
00049 extern ATTR **anum_table;
00050 
00051 #define anum_get(x)     (anum_table[(x)])
00052 #define anum_set(x,v)   anum_table[(x)] = v
00053 extern void anum_extend(int);
00054 
00055 #define ATR_INFO_CHAR   '\1'    /* Leadin char for attr control data */
00056 
00057 /* Boolean expressions, for locks */
00058 #define BOOLEXP_AND     0
00059 #define BOOLEXP_OR      1
00060 #define BOOLEXP_NOT     2
00061 #define BOOLEXP_CONST   3
00062 #define BOOLEXP_ATR     4
00063 #define BOOLEXP_INDIR   5
00064 #define BOOLEXP_CARRY   6
00065 #define BOOLEXP_IS      7
00066 #define BOOLEXP_OWNER   8
00067 #define BOOLEXP_EVAL    9
00068 
00069 typedef struct boolexp BOOLEXP;
00070 struct boolexp {
00071     boolexp_type type;
00072     struct boolexp *sub1;
00073     struct boolexp *sub2;
00074     dbref thing;                /* thing refers to an object */
00075 };
00076 
00077 #define TRUE_BOOLEXP ((BOOLEXP *) 0)
00078 
00079 /* Database format information */
00080 
00081 #define F_UNKNOWN       0       /* Unknown database format */
00082 #define F_MUSH          1       /* MUSH format (many variants) */
00083 #define F_MUSE          2       /* MUSE format */
00084 #define F_MUD           3       /* Old TinyMUD format */
00085 #define F_MUCK          4       /* TinyMUCK format */
00086 #define F_MUX           5       /* TinyMUX format */
00087 
00088 #define V_MASK          0x000000ff      /* Database version */
00089 #define V_ZONE          0x00000100      /* ZONE/DOMAIN field */
00090 #define V_LINK          0x00000200      /* LINK field (exits from objs) */
00091 #define V_GDBM          0x00000400      /* attrs are in a gdbm db, not here */
00092 #define V_ATRNAME       0x00000800      /* NAME is an attr, not in the hdr */
00093 #define V_ATRKEY        0x00001000      /* KEY is an attr, not in the hdr */
00094 #define V_PERNKEY       0x00001000      /* PERN: Extra locks in object hdr */
00095 #define V_PARENT        0x00002000      /* db has the PARENT field */
00096 #define V_COMM          0x00004000      /* PERN: Comm status in header */
00097 #define V_ATRMONEY      0x00008000      /* Money is kept in an attribute */
00098 #define V_XFLAGS        0x00010000      /* An extra word of flags */
00099 #define V_POWERS        0x00020000      /* Powers? */
00100 #define V_3FLAGS        0x00040000      /* Adding a 3rd flag word */
00101 #define V_QUOTED        0x00080000      /* Quoted strings, ala PennMUSH */
00102 
00103 /* Some defines for DarkZone's flavor of PennMUSH */
00104 #define DB_CHANNELS    0x2      /*  Channel system */
00105 #define DB_SLOCK       0x4      /*  Slock */
00106 #define DB_MC          0x8      /*  Master Create Time + modifed */
00107 #define DB_MPAR        0x10     /*  Multiple Parent Code */
00108 #define DB_CLASS       0x20     /*  Class System */
00109 #define DB_RANK        0x40     /*  Rank */
00110 #define DB_DROPLOCK    0x80     /*  Drop/TelOut Lock */
00111 #define DB_GIVELOCK    0x100    /*  Give/TelIn Lock */
00112 #define DB_GETLOCK     0x200    /*  Get Lock */
00113 #define DB_THREEPOW    0x400    /*  Powers have Three Long Words */
00114 
00115 /* special dbref's */
00116 #define NOTHING         (-1)    /* null dbref */
00117 #define AMBIGUOUS       (-2)    /* multiple possibilities, for matchers */
00118 #define HOME            (-3)    /* virtual room, represents mover's home */
00119 #define NOPERM          (-4)    /* Error status, no permission */
00120 #define NOSLAVE         (-5)    /* Don't send to slaves */
00121 
00122 typedef struct object OBJ;
00123 struct object {
00124     dbref location;             /* PLAYER, THING: where it is */
00125     /* ROOM: dropto: */
00126     /* EXIT: where it goes to */
00127     dbref contents;             /* PLAYER, THING, ROOM: head of contentslist */
00128     /* EXIT: unused */
00129     dbref exits;                /* PLAYER, THING, ROOM: head of exitslist */
00130     /* EXIT: where it is */
00131     dbref next;                 /* PLAYER, THING: next in contentslist */
00132     /* EXIT: next in exitslist */
00133     /* ROOM: unused */
00134     dbref link;                 /* PLAYER, THING: home location */
00135     /* ROOM, EXIT: unused */
00136     dbref parent;               /* ALL: defaults for attrs, exits, $cmds, */
00137     dbref owner;                /* PLAYER: domain number + class + moreflags */
00138     /* THING, ROOM, EXIT: owning player number */
00139 
00140     dbref zone;                 /* Whatever the object is zoned to. */
00141 
00142     FLAG flags;                 /* ALL: Flags set on the object */
00143     FLAG flags2;                /* ALL: even more flags */
00144     FLAG flags3;                /* ALL: yet _more_ flags */
00145 
00146     POWER powers;               /* ALL: Powers on object */
00147     POWER powers2;              /* ALL: even more powers */
00148 
00149     STACK *stackhead;           /* Every object has a stack. */
00150 
00151     ATRLIST *ahead;             /* The head of the attribute list. */
00152     int at_count;               /* How many attributes do we have? */
00153 };
00154 
00155 typedef char *NAME;
00156 
00157 extern OBJ *db;
00158 extern NAME *names;
00159 
00160 #define Location(t)             db[t].location
00161 
00162 #define Zone(t)                 db[t].zone
00163 
00164 #define Contents(t)             db[t].contents
00165 #define Exits(t)                db[t].exits
00166 #define Next(t)                 db[t].next
00167 #define Link(t)                 db[t].link
00168 #define Owner(t)                db[t].owner
00169 #define Parent(t)               db[t].parent
00170 #define Flags(t)                db[t].flags
00171 #define Flags2(t)               db[t].flags2
00172 #define Flags3(t)               db[t].flags3
00173 #define Powers(t)               db[t].powers
00174 #define Powers2(t)              db[t].powers2
00175 #define Stack(t)                db[t].stackhead
00176 #define Home(t)                 Link(t)
00177 #define Dropto(t)               Location(t)
00178 
00179 #define i_Name(t)               if (mudconf.cache_names) purenames[t] = NULL;
00180 
00181 #define s_Location(t,n)         db[t].location = (n)
00182 
00183 #define s_Zone(t,n)             db[t].zone = (n)
00184 
00185 #define s_Contents(t,n)         db[t].contents = (n)
00186 #define s_Exits(t,n)            db[t].exits = (n)
00187 #define s_Next(t,n)             db[t].next = (n)
00188 #define s_Link(t,n)             db[t].link = (n)
00189 #define s_Owner(t,n)            db[t].owner = (n)
00190 #define s_Parent(t,n)           db[t].parent = (n)
00191 #define s_Flags(t,n)            db[t].flags = (n)
00192 #define s_Flags2(t,n)           db[t].flags2 = (n)
00193 #define s_Flags3(t,n)           db[t].flags3 = (n)
00194 #define s_Powers(t,n)           db[t].powers = (n)
00195 #define s_Powers2(t,n)          db[t].powers2 = (n)
00196 #define s_Stack(t,n)            db[t].stackhead = (n)
00197 #define s_Home(t,n)             s_Link(t,n)
00198 #define s_Dropto(t,n)           s_Location(t,n)
00199 
00200 extern int Pennies(dbref);
00201 extern void s_Pennies(dbref, int);
00202 
00203 extern dbref getref(FILE *);
00204 extern void putref(FILE *, dbref);
00205 extern BOOLEXP *dup_bool(BOOLEXP *);
00206 extern void free_boolexp(BOOLEXP *);
00207 extern dbref parse_dbref(const char *);
00208 extern int mkattr(char *);
00209 extern void al_add(dbref, int);
00210 extern void al_delete(dbref, int);
00211 extern void al_destroy(dbref);
00212 extern void al_store(void);
00213 extern void db_grow(dbref);
00214 extern void db_free(void);
00215 extern void db_make_minimal(void);
00216 extern dbref db_read(FILE *, int *, int *, int *);
00217 extern dbref db_write(FILE *, int, int);
00218 extern void destroy_thing(dbref);
00219 extern void destroy_exit(dbref);
00220 extern void load_restart_db(void);
00221 extern void dump_database_internal(int);
00222 
00223 #define DOLIST(thing,list) \
00224         for ((thing)=(list); \
00225              ((thing)!=NOTHING) && (Next(thing)!=(thing)); \
00226              (thing)=Next(thing))
00227 #define SAFE_DOLIST(thing,next,list) \
00228         for ((thing)=(list),(next)=((thing)==NOTHING ? NOTHING: Next(thing)); \
00229              (thing)!=NOTHING && (Next(thing)!=(thing)); \
00230              (thing)=(next), (next)=Next(next))
00231 #define DO_WHOLE_DB(thing) \
00232         for ((thing)=0; (thing)<mudstate.db_top; (thing)++)
00233 
00234 #define DO_WHOLE_DB_REV(thing) \
00235         for ((thing)=mudstate.db_top-1; (thing)>0; (thing)--)
00236 
00237 #define HAG_WAS_HERE
00238 #define Dropper(thing)  (Connected(Owner(thing)) && Hearer(thing))
00239 
00240 #define DUMP_NORMAL  0
00241 #define DUMP_CRASHED 1
00242 #define DUMP_RESTART 2
00243 #define DUMP_KILLED  4
00244 
00245 #endif                          /* __DB_H */

Generated on Mon May 28 04:25:19 2007 for BattletechMUX by  doxygen 1.4.7