.TH IDF 3 "$Revision$" .ad .SH NAME init_idf, str2idf, findidf\ \-\ a namelist module .SH SYNOPSIS .PP .B void init_idf() .PP .B struct idf *str2idf(tag, cpy) .br .B char *tag; .PP .B struct idf *findidf(tag) .br .B char *tag; .SH DESCRIPTION This is a generic namelist module. It provides a fast mechanism for associating information with identifiers. To get an instantiation, the user must provide two files \fIidf.h\fR and \fIidf.c\fR. \fIidf.h\fR could contain the following: .br .PP .RS .nf #define IDF_TYPE struct id_info #define IDF_HSIZE 8 #include .fi .RE .PP and \fIidf.c\fR could contain: .br .PP .RS .nf #include "id_info.h" /* contains definition for struct id_info */ #include "idf.h" #include .fi .RE .PP IDF_TYPE denotes a type containing all information associated with an identifier. If it is not defined, the instantiation will not contain any user-defined information. .PP IDF_HSIZE denotes the number of significant characters for the hashing function. It's default value is 64. Notice that this value does \fBnot\fP denote the number of significant characters, but only the number of characters that are used for hashing. .PP The user can also define IDF_NAME, to give a name to the selector in the idf-structure. It's default value is \fIid_user\fP. .PP The routine \fIinit_idf\fR initializes the namelist. .PP The function \fIstr2idf\fR searches for the string \fItag\fR in the namelist, and creates an entry for it if necessary. A pointer to this entry is returned. If \fIcpy\fR is non-zero, a copy of the \fItag\fR is made, otherwise the \fItag\fR itself is used. The entry has the following structure, defined in \fIidf_pkg.spec\fR: .PP .nf struct idf { struct idf *next; \kx/* links idf-structures together */ char *id_text;\h'|\nxu'/* string representing the name */ #ifdef IDF_TYPE IDF_TYPE IDF_NAME;\h'|\nxu'/* user defined type */ #endif }; .fi .PP The field \fIid_text\fR will point to a copy of \fItag\fR, or to the \fItag\fR itself, depending on \fIcpy\fR. The field \fInext\fR is used for internal information and must not be changed by the user of this module. The user-defined part of the structure is initialized with zeros. .PP The function \fIfindidf\fP searches for the string \fItag\fP in the namelist, but returns 0 when it is not present. .SH "MODULES USED" alloc(3) .SH FILES ~em/modules/pkg/idf_pkg.spec .br ~em/modules/pkg/idf_pkg.body