Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
STRUCTS_TYPE_ID(3)     FreeBSD Library Functions Manual	    STRUCTS_TYPE_ID(3)

NAME
     structs_type_id --	structs	types for identifiers

LIBRARY
     PDEL Library (libpdel, -lpdel)

SYNOPSIS
     #include <sys/types.h>
     #include <pdel/structs/structs.h>
     #include <pdel/structs/type/id.h>

     STRUCTS_ID_TYPE(idlist, vsize);

DESCRIPTION
     The STRUCTS_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 ar-
     gument, which is a	pointer	to an array of struct structs_id:

	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, deter-
     mines whether the parsing of the ASCII representation is case-insensi-
     tive.  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 NULL.

     vsize is the size of the integral type used to store the value, which
     must be 1,	2, or 4.

SEE ALSO
     libpdel(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));

HISTORY
     The PDEL library was developed at Packet Design, LLC.
     http://www.packetdesign.com/

AUTHORS
     Archie Cobbs <archie@freebsd.org>

FreeBSD	13.0			April 22, 2002			  FreeBSD 13.0

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | SEE ALSO | EXAMPLES | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=structs_type_id&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help