Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

Guardian Native C Library Calls (g - i) hsearch(3)
NAME
hsearch - Searches a hash table
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <search.h>
ENTRY *hsearch(
ENTRY item,
ACTION action);
PARAMETERS
item Identies a structure of the type ENTRY as dened in the search.h header le.
The structure contains two pointers:
char *key Points to the comparison key string.
char *data Points to any other data associated with the char *key parame-
ter.
Pointers to types other than char should be cast as char *.
action Species a value for an ACTION enum type, which indicates what is to be done
with an item key when it cannot be found in the hash table. The following two
actions can be specied for this parameter:
ENTER Enter the key specied by the item parameter into the hash table
at the appropriate place. When the table is full, a null pointer is
returned.
FIND Do not enter the item key into the table, but return a null pointer
when an item key cannot be found in the hash table.
DESCRIPTION
The hsearch(), hcreate() and hdestroy( ) functions are used to manage hash table operations.
The hsearch() function searches a hash table. It returns a pointer into a hash table that indicates
where a given entry can be found. The hsearch() function uses open addressing with a hash
function.
NOTES
The hcreate() function initializes the hash table. You must call the hcreate() function before
calling the hsearch() function.
RETURN VALUES
The hsearch() function returns a null pointer when the action parameter is FIND and the key
pointed to by item cannot be found, or when the specied action is ENTER and the hash table is
full.
ERRORS
If any of the following conditions occurs, the hsearch() function sets errno to the value that
corresponds to the condition.
[ENOMEM] The table is full.
527192-005 Hewlett-Packard Company 353