mux/src/db.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include "attrs.h"
#include "command.h"
#include "comsys.h"
#include "interface.h"
#include "powers.h"
#include "vattr.h"
#include "ansi.h"

Include dependency graph for db.cpp:

Go to the source code of this file.

Data Structures

struct  atrcount

Defines

#define O_ACCMODE   (O_RDONLY|O_WRONLY|O_RDWR)
#define SIZE_HACK   1
#define STATE_START   0
#define STATE_HAVE_ESC   1

Typedefs

typedef atrcount ATRCOUNT

Functions

void fwdlist_set (dbref thing, FWDLIST *ifp)
void fwdlist_clr (dbref thing)
int fwdlist_load (FWDLIST *fp, dbref player, char *atext)
int fwdlist_rewrite (FWDLIST *fp, char *atext)
bool fwdlist_ck (dbref player, dbref thing, int anum, char *atext)
FWDLISTfwdlist_get (dbref thing)
const char * Name (dbref thing)
const char * PureName (dbref thing)
const char * Moniker (dbref thing)
void s_Name (dbref thing, const char *s)
void s_Moniker (dbref thing, const char *s)
void s_Pass (dbref thing, const char *s)
void do_attribute (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *aname, char *value)
void do_fixdb (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *arg1, char *arg2)
char * MakeCanonicalAttributeName (const char *pName, int *pnName, bool *pbValid)
char * MakeCanonicalAttributeCommand (const char *pName, int *pnName, bool *pbValid)
void init_attrtab (void)
ATTRatr_str (char *s)
void anum_extend (int newtop)
ATTRatr_num (int anum)
static void SetupThrottle (dbref executor)
static void SetupGlobalThrottle (void)
bool ThrottlePlayerCreate (void)
bool ThrottleAttributeNames (dbref executor)
bool ThrottleMail (dbref executor)
int mkattr (dbref executor, char *buff)
static int al_decode (char **app)
static char * al_code (char *ap, int atrnum)
bool Commer (dbref thing)
static void al_extend (char **buffer, size_t *bufsiz, size_t len, bool copy)
void al_store (void)
static char * al_fetch (dbref thing)
static bool al_add (dbref thing, int attrnum)
static void al_delete (dbref thing, int attrnum)
static DCL_INLINE void makekey (dbref thing, int atr, Aname *abuff)
static char * atr_encode (char *iattr, dbref thing, dbref owner, int flags, int atr)
static const char * atr_decode_flags_owner (const char *iattr, dbref *owner, int *flags)
static void atr_decode_LEN (const char *iattr, int nLen, char *oattr, dbref thing, dbref *owner, int *flags, size_t *pLen)
void atr_clr (dbref thing, int atr)
void atr_add_raw_LEN (dbref thing, int atr, const char *szValue, int nValue)
void atr_add_raw (dbref thing, int atr, const char *szValue)
void atr_add (dbref thing, int atr, char *buff, dbref owner, int flags)
void atr_set_flags (dbref thing, int atr, dbref flags)
int get_atr (char *name)
const char * atr_get_raw_LEN (dbref thing, int atr, size_t *pLen)
const char * atr_get_raw (dbref thing, int atr)
char * atr_get_str_LEN (char *s, dbref thing, int atr, dbref *owner, int *flags, size_t *pLen)
char * atr_get_str (char *s, dbref thing, int atr, dbref *owner, int *flags)
char * atr_get_LEN (dbref thing, int atr, dbref *owner, int *flags, size_t *pLen)
char * atr_get_real (dbref thing, int atr, dbref *owner, int *flags, const char *file, const int line)
bool atr_get_info (dbref thing, int atr, dbref *owner, int *flags)
char * atr_pget_str_LEN (char *s, dbref thing, int atr, dbref *owner, int *flags, size_t *pLen)
char * atr_pget_str (char *s, dbref thing, int atr, dbref *owner, int *flags)
char * atr_pget_LEN (dbref thing, int atr, dbref *owner, int *flags, size_t *pLen)
char * atr_pget_real (dbref thing, int atr, dbref *owner, int *flags, const char *file, const int line)
bool atr_pget_info (dbref thing, int atr, dbref *owner, int *flags)
void atr_free (dbref thing)
void atr_cpy (dbref dest, dbref source, bool bInternal)
void atr_chown (dbref obj)
int atr_next (char **attrp)
void atr_push (void)
void atr_pop (void)
int atr_head (dbref thing, char **attrp)
static void initialize_objects (dbref first, dbref last)
void db_grow (dbref newtop)
void db_free (void)
void db_make_minimal (void)
dbref parse_dbref (const char *s)
void putref (FILE *f, dbref ref)
char * getstring_noalloc (FILE *f, int new_strings)
void putstring (FILE *f, const char *pRaw)
int getref (FILE *f)
void free_boolexp (BOOLEXP *b)
static BOOLEXPdup_bool (BOOLEXP *b)
int init_dbfile (char *game_dir_file, char *game_pag_file, int nCachePages)
bool check_zone_handler (dbref player, dbref thing, bool bPlayerCheck)
void ReleaseAllResources (dbref obj)
void dump_restart_db (void)
void load_restart_db (void)
int ReplaceFile (char *old_name, char *new_name)
void RemoveFile (char *name)

Variables

OBJdb = NULL
ATTR attr []
char * aszSpecialDBRefNames [1-NOPERM]
ATTR ** anum_table = NULL
int anum_alc_top = 0
static const unsigned char decode_table [256]
static const int action_table [2][8]
static const unsigned char encode_table [256]


Define Documentation

#define O_ACCMODE   (O_RDONLY|O_WRONLY|O_RDWR)

Definition at line 23 of file db.cpp.

#define SIZE_HACK   1

Definition at line 2517 of file db.cpp.

Referenced by db_free(), and db_grow().

#define STATE_HAVE_ESC   1

Definition at line 2775 of file db.cpp.

Referenced by getstring_noalloc().

#define STATE_START   0

Definition at line 2774 of file db.cpp.

Referenced by getstring_noalloc().


Typedef Documentation

typedef struct atrcount ATRCOUNT

Definition at line 28 of file db.cpp.


Function Documentation

static bool al_add ( dbref  thing,
int  attrnum 
) [static]

Definition at line 1525 of file db.cpp.

References al_code(), al_decode(), al_extend(), al_fetch(), ATR_BUF_INCR, LBUF_SIZE, statedata::mod_alist, statedata::mod_alist_len, statedata::mod_size, and mudstate.

Referenced by atr_add_raw_LEN().

01526 {
01527     char *abuf = al_fetch(thing);
01528     char *cp = abuf;
01529     int anum;
01530 
01531     // See if attr is in the list.  If so, exit (need not do anything).
01532     //
01533     while (*cp)
01534     {
01535         anum = al_decode(&cp);
01536         if (anum == attrnum)
01537         {
01538             return true;
01539         }
01540     }
01541 
01542     // The attribute isn't there, so we need to try to add it.
01543     //
01544     int iPosition = cp - abuf;
01545 
01546     // If we are too large for an attribute
01547     //
01548     if (iPosition + ATR_BUF_INCR >= LBUF_SIZE)
01549     {
01550         return false;
01551     }
01552 
01553     // Extend it.
01554     //
01555     al_extend(&mudstate.mod_alist, &mudstate.mod_size, (iPosition + ATR_BUF_INCR), true);
01556     if (mudstate.mod_alist != abuf)
01557     {
01558         // extend returned different buffer, re-position the end
01559         //
01560         cp = mudstate.mod_alist + iPosition;
01561     }
01562 
01563     // Add the new attribute on to the end.
01564     //
01565     cp = al_code(cp, attrnum);
01566     *cp = '\0';
01567     mudstate.mod_alist_len = cp - mudstate.mod_alist;
01568     return true;
01569 }

static char* al_code ( char *  ap,
int  atrnum 
) [static]

Definition at line 1332 of file db.cpp.

Referenced by al_add(), and al_delete().

01333 {
01334     int bits;
01335     for (;;)
01336     {
01337         bits = atrnum & 0x7F;
01338         if (atrnum <= 0x7F)
01339         {
01340             break;
01341         }
01342         atrnum >>= 7;
01343         bits |= 0x80;
01344         *ap++ = (char)bits;
01345     }
01346     *ap++ = (char)bits;
01347     return ap;
01348 }

static int al_decode ( char **  app  )  [static]

Definition at line 1300 of file db.cpp.

Referenced by al_add(), al_delete(), and atr_next().

01301 {
01302     char *ap = *app;
01303 
01304     int atrnum = 0, atrshft = 0;
01305     for (;;)
01306     {
01307         int ch = *ap++;
01308         int bits = ch & 0x7F;
01309 
01310         if (atrshft > 0)
01311             atrnum |= (bits << atrshft);
01312         else
01313             atrnum = bits;
01314 
01315         if ((ch & 0x80) == 0)
01316         {
01317             *app = ap;
01318             return atrnum;
01319         }
01320         atrshft += 7;
01321     }
01322 }

static void al_delete ( dbref  thing,
int  attrnum 
) [static]

Definition at line 1573 of file db.cpp.

References A_LIST, al_code(), al_decode(), al_fetch(), statedata::mod_alist, statedata::mod_alist_len, and mudstate.

Referenced by atr_clr().

01574 {
01575     int anum;
01576     char *abuf, *cp, *dp;
01577 
01578     // If trying to modify List attrib, return.  Otherwise, get the attribute list.
01579     //
01580     if (attrnum == A_LIST)
01581     {
01582         return;
01583     }
01584     abuf = al_fetch(thing);
01585     if (!abuf)
01586     {
01587         return;
01588     }
01589 
01590     cp = abuf;
01591     while (*cp)
01592     {
01593         dp = cp;
01594         anum = al_decode(&cp);
01595         if (anum == attrnum)
01596         {
01597             while (*cp)
01598             {
01599                 anum = al_decode(&cp);
01600                 dp = al_code(dp, anum);
01601             }
01602             *dp = '\0';
01603             mudstate.mod_alist_len = dp - mudstate.mod_alist;
01604             return;
01605         }
01606     }
01607     return;
01608 }

static void al_extend ( char **  buffer,
size_t *  bufsiz,
size_t  len,
bool  copy 
) [static]

Definition at line 1452 of file db.cpp.

References ATR_BUF_CHUNK, ISOUTOFMEMORY, MEMALLOC, and MEMFREE.

Referenced by al_add(), al_fetch(), and atr_head().

01453 {
01454     if (len > *bufsiz)
01455     {
01456         int newsize = len + ATR_BUF_CHUNK;
01457         char *tbuff = (char *)MEMALLOC(newsize);
01458         ISOUTOFMEMORY(tbuff);
01459         if (*buffer)
01460         {
01461             if (copy)
01462             {
01463                 memcpy(tbuff, *buffer, *bufsiz);
01464             }
01465             MEMFREE(*buffer);
01466             *buffer = NULL;
01467         }
01468         *buffer = tbuff;
01469         *bufsiz = newsize;
01470     }
01471 }

static char* al_fetch ( dbref  thing  )  [static]

Definition at line 1493 of file db.cpp.

References A_LIST, al_extend(), al_store(), atr_get_raw_LEN(), statedata::mod_al_id, statedata::mod_alist, statedata::mod_alist_len, statedata::mod_size, and mudstate.

Referenced by al_add(), and al_delete().

01494 {
01495     // We only need fetch if we change things.
01496     //
01497     if (mudstate.mod_al_id == thing)
01498     {
01499         return mudstate.mod_alist;
01500     }
01501 
01502     // Save old list, then fetch and set up the attribute list.
01503     //
01504     al_store();
01505     size_t len;
01506     const char *astr = atr_get_raw_LEN(thing, A_LIST, &len);
01507     if (astr)
01508     {
01509         al_extend(&mudstate.mod_alist, &mudstate.mod_size, len+1, false);
01510         memcpy(mudstate.mod_alist, astr, len+1);
01511         mudstate.mod_alist_len = len;
01512     }
01513     else
01514     {
01515         al_extend(&mudstate.mod_alist, &mudstate.mod_size, 1, false);
01516         *mudstate.mod_alist = '\0';
01517         mudstate.mod_alist_len = 0;
01518     }
01519     mudstate.mod_al_id = thing;
01520     return mudstate.mod_alist;
01521 }

void al_store ( void   ) 

Definition at line 1475 of file db.cpp.

References A_LIST, atr_add_raw_LEN(), atr_clr(), statedata::mod_al_id, statedata::mod_alist, statedata::mod_alist_len, mudstate, and NOTHING.

Referenced by al_fetch(), atr_free(), dbconvert(), do_dbclean(), do_restart(), do_shutdown(), dump_database(), fork_and_dump(), and sighandler().

01476 {
01477     if (mudstate.mod_al_id != NOTHING)
01478     {
01479         if (mudstate.mod_alist_len)
01480         {
01481             atr_add_raw_LEN(mudstate.mod_al_id, A_LIST, mudstate.mod_alist, mudstate.mod_alist_len);
01482         }
01483         else
01484         {
01485             atr_clr(mudstate.mod_al_id, A_LIST);
01486         }
01487     }
01488     mudstate.mod_al_id = NOTHING;
01489 }

void anum_extend ( int  newtop  ) 

Definition at line 1112 of file db.cpp.

References anum_table, statedata::bStandAlone, confdata::init_size, ISOUTOFMEMORY, MEMALLOC, MEMFREE, mudconf, and mudstate.

Referenced by init_attrtab(), vattr_alloc_LEN(), and vattr_define_LEN().

01113 {
01114     ATTR **anum_table2;
01115     int delta, i;
01116 
01117     if (mudstate.bStandAlone)
01118     {
01119         delta = 1000;
01120     }
01121     else
01122     {
01123         delta = mudconf.init_size;
01124     }
01125     if (newtop <= anum_alc_top)
01126     {
01127         return;
01128     }
01129     if (newtop < anum_alc_top + delta)
01130     {
01131         newtop = anum_alc_top + delta;
01132     }
01133     if (anum_table == NULL)
01134     {
01135         anum_table = (ATTR **) MEMALLOC((newtop + 1) * sizeof(ATTR *));
01136         ISOUTOFMEMORY(anum_table);
01137         for (i = 0; i <= newtop; i++)
01138         {
01139             anum_table[i] = NULL;
01140         }
01141     }
01142     else
01143     {
01144         anum_table2 = (ATTR **) MEMALLOC((newtop + 1) * sizeof(ATTR *));
01145         ISOUTOFMEMORY(anum_table2);
01146         for (i = 0; i <= anum_alc_top; i++)
01147         {
01148             anum_table2[i] = anum_table[i];
01149         }
01150         for (i = anum_alc_top + 1; i <= newtop; i++)
01151         {
01152             anum_table2[i] = NULL;
01153         }
01154         MEMFREE((char *)anum_table);
01155         anum_table = anum_table2;
01156     }
01157     anum_alc_top = newtop;
01158 }

void atr_add ( dbref  thing,
int  atr,
char *  buff,
dbref  owner,
int  flags 
)

Definition at line 2008 of file db.cpp.

References AMATCH_CMD, AMATCH_LISTEN, atr_add_raw(), atr_clr(), atr_encode(), statedata::bfCommands, statedata::bfListens, statedata::bfNoCommands, statedata::bfNoListens, CBitField::Clear(), mudstate, and set_modified().

Referenced by add_folder_name(), atr_chown(), atr_cpy(), atr_set_flags(), check_dead_refs(), do_alias(), do_chanlog(), do_chown(), do_edit(), do_edit_msg(), do_forwardlist(), do_mvattr(), SendChannelMessage(), set_attr_internal(), and set_player_folder().

02009 {
02010     set_modified(thing);
02011 
02012     if (!buff || !*buff)
02013     {
02014         atr_clr(thing, atr);
02015     }
02016     else
02017     {
02018         switch (buff[0])
02019         {
02020         case AMATCH_LISTEN:
02021 
02022             // Since this could be a ^-Command, we no longer assert that the
02023             // object has none.
02024             //
02025             mudstate.bfNoListens.Clear(thing);
02026             break;
02027 
02028         case AMATCH_CMD:
02029 
02030             // Since this could be a $-Command, we no longer assert that the
02031             // object has none.
02032             //
02033             mudstate.bfNoCommands.Clear(thing);
02034             break;
02035         }
02036 
02037         // Since this could overwrite an existing ^-Command or $-Command, we
02038         // longer assert that the object has one.
02039         //
02040         mudstate.bfListens.Clear(thing);
02041         mudstate.bfCommands.Clear(thing);
02042 
02043         char *tbuff = atr_encode(buff, thing, owner, flags, atr);
02044         atr_add_raw(thing, atr, tbuff);
02045     }
02046 }

void atr_add_raw ( dbref  thing,
int  atr,
const char *  szValue 
)

Definition at line 2003 of file db.cpp.

References atr_add_raw_LEN().

Referenced by add_quota(), atr_add(), connect_player(), create_obj(), db_read(), dbclean_RenumberAttributes(), did_it(), do_destroy(), do_expmail_start(), do_icmd(), do_lock(), do_mail_cc(), do_mail_fwd(), do_mail_reply(), do_page(), do_pcreate(), do_postpend(), do_prepend(), do_prog(), get_list(), get_slave_result(), mung_quotas(), pay_quota(), pcache_save(), record_login(), s_Moniker(), s_Name(), s_Pass(), s_Pennies(), s_PenniesDirect(), set_modified(), and shutdownsock().

02004 {
02005     atr_add_raw_LEN(thing, atr, szValue, szValue ? strlen(szValue) : 0);
02006 }

void atr_add_raw_LEN ( dbref  thing,
int  atr,
const char *  szValue,
int  nValue 
)

Definition at line 1843 of file db.cpp.

References A_DAILY, A_FORWARDLIST, A_LIST, A_LISTEN, A_QUEUEMAX, A_STARTUP, A_TIMEOUT, al_add(), atr_clr(), ATRLIST_CHUNK, cache_put(), db, desc_reload(), FLAG_WORD1, FLAG_WORD2, object::fs, HAS_DAILY, HAS_FWDLIST, HAS_LISTEN, HAS_STARTUP, INITIAL_ATRLIST_SIZE, ISOUTOFMEMORY, LBUF_SIZE, makekey(), MEMALLOC, MEMFREE, pcache_reload(), StringCloneLen(), and flagset::word.

Referenced by add_to(), al_store(), atr_add_raw(), and put_ConnectionInfoFields().

01844 {
01845     if (  !szValue
01846        || '\0' == szValue[0])
01847     {
01848         atr_clr(thing, atr);
01849         return;
01850     }
01851 
01852 #ifdef MEMORY_BASED
01853     ATRLIST *list;
01854     bool found = false;
01855     int hi, lo, mid;
01856     char *text = StringCloneLen(szValue, nValue);
01857 
01858     if (!db[thing].pALHead)
01859     {
01860         db[thing].nALAlloc = INITIAL_ATRLIST_SIZE;
01861         list = (ATRLIST *)MEMALLOC(db[thing].nALAlloc*sizeof(ATRLIST));
01862         ISOUTOFMEMORY(list);
01863         db[thing].pALHead  = list;
01864         db[thing].nALUsed  = 1;
01865         list[0].number = atr;
01866         list[0].data = text;
01867         list[0].size = nValue + 1;
01868         found = true;
01869     }
01870     else
01871     {
01872         // Binary search for the attribute
01873         //
01874         lo = 0;
01875         hi = db[thing].nALUsed - 1;
01876 
01877         list = db[thing].pALHead;
01878         while (lo <= hi)
01879         {
01880             mid = ((hi - lo) >> 1) + lo;
01881             if (list[mid].number > atr)
01882             {
01883                 hi = mid - 1;
01884             }
01885             else if (list[mid].number < atr)
01886             {
01887                 lo = mid + 1;
01888             }
01889             else // if (list[mid].number == atr)
01890             {
01891                 MEMFREE(list[mid].data);
01892                 list[mid].data = text;
01893                 list[mid].size = nValue + 1;
01894                 found = true;
01895                 break;
01896             }
01897         }
01898 
01899         if (!found)
01900         {
01901             // We didn't find it, and lo == hi + 1.  The attribute should be
01902             // inserted between (0,hi) and (lo,nALUsed-1).
01903             //
01904             if (db[thing].nALUsed < db[thing].nALAlloc)
01905             {
01906                 memmove( list + lo + 1,
01907                          list + lo,
01908                          (db[thing].nALUsed - lo) * sizeof(ATRLIST));
01909             }
01910             else
01911             {
01912                 // Expand the list.
01913                 //
01914                 db[thing].nALAlloc += ATRLIST_CHUNK;
01915                 list = (ATRLIST *)MEMALLOC(db[thing].nALAlloc
01916                      * sizeof(ATRLIST));
01917                 ISOUTOFMEMORY(list);
01918 
01919                 // Copy bottom part.
01920                 //
01921                 if (lo > 0)
01922                 {
01923                     memcpy(list, db[thing].pALHead, lo * sizeof(ATRLIST));
01924                 }
01925     
01926                 // Copy top part.
01927                 //
01928                 if (lo < db[thing].nALUsed)
01929                 {
01930                     memcpy( list + lo + 1,
01931                             db[thing].pALHead + lo,
01932                             (db[thing].nALUsed - lo) * sizeof(ATRLIST));
01933                 }
01934                 MEMFREE(db[thing].pALHead);
01935                 db[thing].pALHead = list;
01936             }
01937             db[thing].nALUsed++;
01938             list[lo].data = text;
01939             list[lo].number = atr;
01940             list[lo].size = nValue + 1;
01941         }
01942     }
01943 
01944 #else // MEMORY_BASED
01945 
01946     if (nValue > LBUF_SIZE-1)
01947     {
01948         nValue = LBUF_SIZE-1;
01949     }
01950 
01951     Aname okey;
01952     makekey(thing, atr, &okey);
01953     if (atr == A_LIST)
01954     {
01955         // A_LIST is never compressed and it's never listed within itself.
01956         //
01957         cache_put(&okey, szValue, nValue+1);
01958     }
01959     else
01960     {
01961         if (!al_add(thing, atr))
01962         {
01963             return;
01964         }
01965         cache_put(&okey, szValue, nValue+1);
01966     }
01967 #endif // MEMORY_BASED
01968 
01969     switch (atr)
01970     {
01971     case A_STARTUP:
01972 
01973         db[thing].fs.word[FLAG_WORD1] |= HAS_STARTUP;
01974         break;
01975 
01976     case A_DAILY:
01977 
01978         db[thing].fs.word[FLAG_WORD2] |= HAS_DAILY;
01979         break;
01980 
01981     case A_FORWARDLIST:
01982 
01983         db[thing].fs.word[FLAG_WORD2] |= HAS_FWDLIST;
01984         break;
01985 
01986     case A_LISTEN:
01987 
01988         db[thing].fs.word[FLAG_WORD2] |= HAS_LISTEN;
01989         break;
01990 
01991     case A_TIMEOUT:
01992 
01993         desc_reload(thing);
01994         break;
01995 
01996     case A_QUEUEMAX:
01997 
01998         pcache_reload(thing);
01999         break;
02000     }
02001 }

void atr_chown ( dbref  obj  ) 

Definition at line 2359 of file db.cpp.

References AF_LOCK, atr_add(), atr_get, atr_head(), atr_next(), atr_pop(), atr_push(), free_lbuf, and Owner.

Referenced by do_chown().

02360 {
02361     dbref owner = Owner(obj);
02362 
02363     char *as;
02364     atr_push();
02365     for (int atr = atr_head(obj, &as); atr; atr = atr_next(&as))
02366     {
02367         int   aflags;
02368         dbref aowner;
02369         char *buf = atr_get(obj, atr, &aowner, &aflags);
02370         if (  aowner != owner
02371            && !(aflags & AF_LOCK))
02372         {
02373             atr_add(obj, atr, buf, owner, aflags);
02374         }
02375         free_lbuf(buf);
02376     }
02377     atr_pop();
02378 }

void atr_clr ( dbref  thing,
int  atr 
)

Definition at line 1739 of file db.cpp.

References A_DAILY, A_FORWARDLIST, A_LISTEN, A_QUEUEMAX, A_STARTUP, A_TIMEOUT, al_delete(), statedata::bfCommands, statedata::bfListens, statedata::bStandAlone, cache_del(), CBitField::Clear(), db, desc_reload(), FLAG_WORD1, FLAG_WORD2, object::fs, fwdlist_clr(), HAS_DAILY, HAS_FWDLIST, HAS_LISTEN, HAS_STARTUP, makekey(), MEMFREE, mudstate, mux_assert, pcache_reload(), and flagset::word.

Referenced by al_store(), atr_add(), atr_add_raw_LEN(), atr_free(), dbclean_CheckALISTtoAT(), dbclean_CheckALISTtoDB(), do_alias(), do_chanlog(), do_expmail_start(), do_forwardlist(), do_icmd(), do_mvattr(), do_unlock(), do_wipe(), nfy_que(), shutdownsock(), and CGuests::WipeAttrs().

01740 {
01741 #ifdef MEMORY_BASED
01742 
01743     if (  !db[thing].nALUsed
01744        || !db[thing].pALHead)
01745     {
01746         return;
01747     }
01748 
01749     mux_assert(0 <= db[thing].nALUsed);
01750 
01751     // Binary search for the attribute.
01752     //
01753     int lo = 0;
01754     int mid;
01755     int hi = db[thing].nALUsed - 1;
01756     ATRLIST *list = db[thing].pALHead;
01757     while (lo <= hi)
01758     {
01759         mid = ((hi - lo) >> 1) + lo;
01760         if (list[mid].number > atr)
01761         {
01762             hi = mid - 1;
01763         }
01764         else if (list[mid].number < atr)
01765         {
01766             lo = mid + 1;
01767         }
01768         else // (list[mid].number == atr)
01769         {
01770             MEMFREE(list[mid].data);
01771             list[mid].data = NULL;
01772             db[thing].nALUsed--;
01773             if (mid != db[thing].nALUsed)
01774             {
01775                 memmove( list + mid,
01776                          list + mid + 1,
01777                          (db[thing].nALUsed - mid) * sizeof(ATRLIST));
01778             }
01779             break;
01780         }
01781     }
01782 #else // MEMORY_BASED
01783     Aname okey;
01784 
01785     makekey(thing, atr, &okey);
01786     cache_del(&okey);
01787     al_delete(thing, atr);
01788 #endif // MEMORY_BASED
01789 
01790     switch (atr)
01791     {
01792     case A_STARTUP:
01793 
01794         db[thing].fs.word[FLAG_WORD1] &= ~HAS_STARTUP;
01795         break;
01796 
01797     case A_DAILY:
01798 
01799         db[thing].fs.word[FLAG_WORD2] &= ~HAS_DAILY;
01800         break;
01801 
01802     case A_FORWARDLIST:
01803 
01804         db[thing].fs.word[FLAG_WORD2] &= ~HAS_FWDLIST;
01805         if (!mudstate.bStandAlone)
01806         {
01807             // We should clear the hashtable, too.
01808             //
01809             fwdlist_clr(thing);
01810         }
01811         break;
01812 
01813     case A_LISTEN:
01814 
01815         db[thing].fs.word[FLAG_WORD2] &= ~HAS_LISTEN;
01816         break;
01817 
01818     case A_TIMEOUT:
01819 
01820         desc_reload(thing);
01821         break;
01822 
01823     case A_QUEUEMAX:
01824 
01825         pcache_reload(thing);
01826         break;
01827 
01828     default:
01829 
01830         // Since this could overwrite an existing ^-Command or $-Command, we
01831         // longer assert that the object has one.
01832         //
01833         mudstate.bfListens.Clear(thing);
01834         mudstate.bfCommands.Clear(thing);
01835         break;
01836     }
01837 }

void atr_cpy ( dbref  dest,
dbref  source,
bool  bInternal 
)

Definition at line 2310 of file db.cpp.

References AF_GOD, AF_INTERNAL, AF_LOCK, AF_NOCLONE, AF_WIZARD, atr_add(), atr_get, atr_head(), atr_next(), atr_num(), atr_pop(), atr_push(), Controls, attr::flags, free_lbuf, God, Owner, and Wizard.

Referenced by CGuests::Create(), do_clone(), and CGuests::MakeGuestChar().

02311 {
02312     dbref owner = Owner(dest);
02313 
02314     char *as;
02315     atr_push();
02316     for (int atr = atr_head(source, &as); atr; atr = atr_next(&as))
02317     {
02318         int   aflags;
02319         dbref aowner;
02320         char *buf = atr_get(source, atr, &aowner, &aflags);
02321 
02322         if (!(aflags & AF_LOCK))
02323         {
02324             // Change owner.
02325             //
02326             aowner = owner;
02327         }
02328 
02329         ATTR *at = atr_num(atr);
02330         if (  atr
02331            && at)
02332         {
02333             if (  !(at->flags & (AF_INTERNAL|AF_NOCLONE))
02334                && (  bInternal
02335                   || God(owner)
02336                   || (  !God(dest)
02337                      && !(aflags & AF_LOCK)
02338                      && (  (  Controls(owner, dest)
02339                            && !(at->flags & (AF_WIZARD|AF_GOD))
02340                            && !(aflags & (AF_WIZARD|AF_GOD)))
02341                         || (  Wizard(owner)
02342                            && !(at->flags & AF_GOD))))))
02343             {
02344                 // Only set attrs that owner has perm to set.
02345                 //
02346                 atr_add(dest, atr, buf, aowner, aflags);
02347             }
02348         }
02349         free_lbuf(buf);
02350     }
02351     atr_pop();
02352 }

static const char* atr_decode_flags_owner ( const char *  iattr,
dbref owner,
int *  flags 
) [static]

Definition at line 1642 of file db.cpp.

References ATR_INFO_CHAR, mux_isdigit, and NOTHING.

Referenced by atr_decode_LEN().

01643 {
01644     // See if the first char of the attribute is the special character
01645     //
01646     *flags = 0;
01647     if (*iattr != ATR_INFO_CHAR)
01648     {
01649         return iattr;
01650     }
01651 
01652     // It has the special character, crack the attr apart.
01653     //
01654     const char *cp = iattr + 1;
01655 
01656     // Get the attribute owner
01657     //
01658     bool neg = false;
01659     if (*cp == '-')
01660     {
01661         neg = true;
01662         cp++;
01663     }
01664     int tmp_owner = 0;
01665     unsigned int ch = *cp;
01666     while (mux_isdigit(ch))
01667     {
01668         cp++;
01669         tmp_owner = 10*tmp_owner + (ch-'0');
01670         ch = *cp;
01671     }
01672     if (neg)
01673     {
01674         tmp_owner = -tmp_owner;
01675     }
01676 
01677     // If delimiter is not ':', just return attribute
01678     //<