src/vattr.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  user_attribute

Defines

#define VNAME_SIZE   32

Typedefs

typedef user_attribute VATTR

Functions

void vattr_init (void)
VATTRvattr_rename (char *, char *)
VATTRvattr_find (char *)
VATTRvattr_nfind (int)
VATTRvattr_alloc (char *, int)
VATTRvattr_define (char *, int, int)
void vattr_delete (char *)
VATTRattr_rename (char *, char *)
VATTRvattr_first (void)
VATTRvattr_next (VATTR *)
void list_vhashstats (dbref)


Define Documentation

#define VNAME_SIZE   32

Definition at line 8 of file vattr.h.

Referenced by vattr_define(), and vattr_rename().


Typedef Documentation

typedef struct user_attribute VATTR

Definition at line 10 of file vattr.h.


Function Documentation

VATTR* attr_rename ( char *  ,
char *   
)

void list_vhashstats ( dbref   ) 

VATTR* vattr_alloc ( char *  ,
int   
)

Definition at line 56 of file vattr.c.

References anum_extend(), statedata::attr_next, mudstate, number, and vattr_define().

Referenced by mkattr().

00057 {
00058         int number;
00059 
00060         if(((number = mudstate.attr_next++) & 0x7f) == 0)
00061                 number = mudstate.attr_next++;
00062         anum_extend(number);
00063         return (vattr_define(name, number, flags));
00064 }

VATTR* vattr_define ( char *  ,
int  ,
int   
)

Definition at line 66 of file vattr.c.

References anum_extend(), anum_set, fixcase(), hashadd(), mudstate, ok_attr_name(), store_string(), vattr_find(), statedata::vattr_name_htab, and VNAME_SIZE.

Referenced by db_read(), mmdb_db_read(), and vattr_alloc().

00067 {
00068         VATTR *vp;
00069 
00070         /*
00071          * Be ruthless. 
00072          */
00073 
00074         if(strlen(name) > VNAME_SIZE)
00075                 name[VNAME_SIZE - 1] = '\0';
00076 
00077         fixcase(name);
00078         if(!ok_attr_name(name))
00079                 return (NULL);
00080 
00081         if((vp = vattr_find(name)) != NULL)
00082                 return (vp);
00083 
00084         vp = (VATTR *) malloc(sizeof(VATTR));
00085 
00086         vp->name = store_string(name);
00087         vp->flags = flags;
00088         vp->number = number;
00089 
00090         hashadd(vp->name, (int *) vp, &mudstate.vattr_name_htab);
00091 
00092         anum_extend(vp->number);
00093         anum_set(vp->number, (ATTR *) vp);
00094         return (vp);
00095 }

void vattr_delete ( char *   ) 

Definition at line 124 of file vattr.c.

References anum_set, fixcase(), hashdelete(), hashfind(), mudstate, user_attribute::number, number, ok_attr_name(), and statedata::vattr_name_htab.

Referenced by do_attribute().

00125 {
00126         VATTR *vp;
00127         int number;
00128 
00129         fixcase(name);
00130         if(!ok_attr_name(name))
00131                 return;
00132 
00133         number = 0;
00134 
00135         vp = (VATTR *) hashfind(name, &mudstate.vattr_name_htab);
00136 
00137         if(vp) {
00138                 number = vp->number;
00139                 anum_set(number, NULL);
00140                 hashdelete(name, &mudstate.vattr_name_htab);
00141                 free((char *) vp);
00142         }
00143 
00144         return;
00145 }

VATTR* vattr_find ( char *   ) 

Definition at line 41 of file vattr.c.

References hashfind(), mudstate, ok_attr_name(), and statedata::vattr_name_htab.

Referenced by atr_str(), do_attribute(), and vattr_define().

00042 {
00043         register VATTR *vp;
00044 
00045         if(!ok_attr_name(name))
00046                 return (NULL);
00047 
00048         vp = (VATTR *) hashfind(name, &mudstate.vattr_name_htab);
00049 
00050         /*
00051          * vp is NULL or the right thing. It's right, either way. 
00052          */
00053         return (vp);
00054 }

VATTR* vattr_first ( void   ) 

Definition at line 174 of file vattr.c.

References hash_firstentry(), mudstate, and statedata::vattr_name_htab.

Referenced by db_write(), list_vattrs(), and vattr_next().

00175 {
00176         return (VATTR *) hash_firstentry(&mudstate.vattr_name_htab);
00177 }

void vattr_init ( void   ) 

Definition at line 36 of file vattr.c.

References hashinit(), mudstate, and statedata::vattr_name_htab.

Referenced by main().

00037 {
00038         hashinit(&mudstate.vattr_name_htab, 65536);
00039 }

VATTR* vattr_next ( VATTR  ) 

Definition at line 179 of file vattr.c.

References hash_nextentry(), mudstate, vattr_first(), and statedata::vattr_name_htab.

Referenced by db_write(), and list_vattrs().

00180 {
00181         if(vp == NULL)
00182                 return (vattr_first());
00183 
00184         return ((VATTR *) hash_nextentry(&mudstate.vattr_name_htab));
00185 }

VATTR* vattr_nfind ( int   ) 

VATTR* vattr_rename ( char *  ,
char *   
)

Definition at line 147 of file vattr.c.

References fixcase(), hashfind(), mudstate, user_attribute::name, ok_attr_name(), store_string(), statedata::vattr_name_htab, and VNAME_SIZE.

00148 {
00149         VATTR *vp;
00150 
00151         fixcase(name);
00152         if(!ok_attr_name(name))
00153                 return (NULL);
00154 
00155         /*
00156          * Be ruthless. 
00157          */
00158 
00159         if(strlen(newname) > VNAME_SIZE)
00160                 newname[VNAME_SIZE - 1] = '\0';
00161 
00162         fixcase(newname);
00163         if(!ok_attr_name(newname))
00164                 return (NULL);
00165 
00166         vp = (VATTR *) hashfind(name, &mudstate.vattr_name_htab);
00167 
00168         if(vp)
00169                 vp->name = store_string(newname);
00170 
00171         return (vp);
00172 }


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