The following is a list of the types of hash items and how RibAddItem() is called depending on the type:
If ((type & kRIB_HASH_TYPEMASK) == (kRIB_HASH_RIREQUESTCODE) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int requestcode,
int ripID );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_VARIABLE)
&& !(classNtype & kRIB_ARRAY_DECLARED) -- Notice the negation '!'.
then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int classNtype,
char *variablename );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_VARIABLE)
&& (classNtype & kRIB_ARRAY_DECLARED) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int classNtype,
char *variablename, int ntype );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_STRINGTOKEN) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int code, char *string );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_STRING) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int code, char *string );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_LIGHTHANDLE)
or (type & kRIB_HASH_TYPEMASK == kRIB_HASH_OBJECTHANDLE) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int handle,
void *extended_data );
If ((type & kRIB_HASH_TYPEMASK) == kRIB_HASH_COORDSYS) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, char *name,
void *extended_data );
if ((type & kRIB_HASH_TYPEMASK) >= kRIB_HASH_USER) then use
RibAddItem( RIB_HASHHND hash, RIB_UINT32 type, int code,
void *data, void *extended_data );
/* Constants for hashatom.type */
#define kRIB_HASH_TYPEMASK 0x00ffffff
#define kRIB_HASH_FLAGMASK 0xff000000
enum {
kRIB_HASH_UNKNOWN,
kRIB_HASH_RIREQUESTCODE,
kRIB_HASH_LIGHTHANDLE,
kRIB_HASH_OBJECTHANDLE,
kRIB_HASH_STRINGTOKEN,
kRIB_HASH_STRING,
kRIB_HASH_VARIABLE,
kRIB_HASH_COORDSYS,
kRIB_HASH_LAST,
kRIB_HASH_USER = 1024
};
#define kRIB_HASH_FREEDATA 0x01000000
#define kRIB_HASH_FREEEXTDATA 0x02000000
To add user data to the hash table use a RibAddItem() with the following parameters:
RibAddItem( (RIB_HASHHND)hash, (RIB_UINT32)type, (int)code,
(void*) data, (void*) extended_data );
Store a pointer to data of any format in extended_data and
set type to any value above or equal to kRIB_HASH_USER.
The values code and data have a special meanings to
RibAddItem(). If data
is a NULL pointer, then
RibAddItem() adds the item
into the hash table by using code to create the hash value.
If data is not a NULL pointer, it is assumed to be a pointer
to a NULL terminated string and is used to create a hash value instead
of using code.
Refer to RibHashValueFromInt() for how code is used to create a hash value and RibHashValueFromString() for how data is used to create a hash value.
When hash table is destroyed by RibDestroyHashTable() the data pointed to by data and extended_data are freed if the value type given to RibAddItem() had the values kRIB_HASH_FREEDATA and kRIB_HASH_FREEEXTDATA ORed in respectively. Without ORing in the values kRIB_HASH_FREEDATA and kRIB_HASH_FREEEXTDATA, the memory blocks pointed to by data and extended_data are not freed. Not using kRIB_HASH_FREEDATA allows constant strings stored in an applications data segment to be untouched since free() would not work on such memory anyway.