|
NAMEstructs_type_id —
structs types for identifiers
LIBRARYPDEL Library (libpdel, -lpdel)SYNOPSIS#include <sys/types.h>
#include
<pdel/structs/structs.h>
#include
<pdel/structs/type/id.h>
DESCRIPTIONTheSTRUCTS_ID_TYPE () macro defines a
structs(3)
type (i.e., a struct structs_type ) for describing an
enumeration or identifier list.
The data structure represented is an integral value that may take
one of a fixed set of values. The possible values are defined by the
idlist argument, which is a pointer to an array of
struct structs_id { const char *id; /* string representation */ u_int32_t value; /* integer representation */ u_int imatch; /* case-insensitive matching allowed */ }; The id points to a unique string
representing the value; imatch, determines whether the
parsing of the ASCII representation is case-insensitive.
value is the actual integer value. The first element
in the array used as the default value. The array is terminated with an
entry having id equal to
vsize is the size of the integral type used to store the value, which must be 1, 2, or 4. SEE ALSOlibpdel(3), structs(3), structs_type(3)EXAMPLES/* Set of possible colors */ enum color { RED, GREEN, BLUE, }; /* The current color */ static enum color current_color; /* Structs type describing something of type "enum color" */ static const struct structs_id color_list[] = { { "red", RED }, { "green", GREEN }, { "blue", BLUE }, { NULL, 0 } }; static const struct structs_type color_type = STRUCTS_ID_TYPE(color_list, sizeof(enum color)); HISTORYThe PDEL library was developed at Packet Design, LLC.http://www.packetdesign.com/
AUTHORSArchie Cobbs ⟨archie@freebsd.org⟩
Visit the GSP FreeBSD Man Page Interface. |