Next: gpl - GNU General Public License, Previous: gperf - perform a perfect hash function, Up: Common Scheme Functions [Contents][Index]
Usage: (gperf-code st-name)
Returns the contents of the emitted code, suitable
for inclusion in another program. The interface contains
the following elements:
containg the fields: {char const * name, int const id; };
This is the hashing function with local only scope (static).
This is the searching and validation function. The first argument
is the string to look up, the second is its length.
It returns a pointer to the corresponding <st-name>_index
entry.
Use this in your template as follows where "<st-name>" was
set to be "lookup
":
[+ (make-gperf "lookup" (join "\n" (stack "name_list"))) (gperf-code "lookup") +] void my_fun(char * str) { struct lookup_index * li = lookup_find(str, strlen(str)); if (li != NULL) printf("%s yields %d\n", str, li->idx);
Arguments:
st-name - the name of the gperf hash list