Annotation of embedaddon/libpdel/structs/type/structs_type_id.3, revision 1.1.1.1

1.1       misho       1: .\" Copyright (c) 2001-2002 Packet Design, LLC.
                      2: .\" All rights reserved.
                      3: .\" 
                      4: .\" Subject to the following obligations and disclaimer of warranty,
                      5: .\" use and redistribution of this software, in source or object code
                      6: .\" forms, with or without modifications are expressly permitted by
                      7: .\" Packet Design; provided, however, that:
                      8: .\" 
                      9: .\"    (i)  Any and all reproductions of the source or object code
                     10: .\"         must include the copyright notice above and the following
                     11: .\"         disclaimer of warranties; and
                     12: .\"    (ii) No rights are granted, in any manner or form, to use
                     13: .\"         Packet Design trademarks, including the mark "PACKET DESIGN"
                     14: .\"         on advertising, endorsements, or otherwise except as such
                     15: .\"         appears in the above copyright notice or in the software.
                     16: .\" 
                     17: .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
                     18: .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
                     19: .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
                     20: .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
                     21: .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
                     22: .\" OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
                     23: .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
                     24: .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
                     25: .\" RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
                     26: .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
                     27: .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
                     28: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
                     29: .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
                     30: .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
                     31: .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     32: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
                     33: .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
                     34: .\" THE POSSIBILITY OF SUCH DAMAGE.
                     35: .\"
                     36: .\" Author: Archie Cobbs <archie@freebsd.org>
                     37: .\"
                     38: .\" $Id: structs_type_id.3,v 1.7 2004/12/16 16:49:56 archie Exp $
                     39: .\"
                     40: .Dd April 22, 2002
                     41: .Dt STRUCTS_TYPE_ID 3
                     42: .Os
                     43: .Sh NAME
                     44: .Nm structs_type_id
                     45: .Nd structs types for identifiers
                     46: .Sh LIBRARY
                     47: PDEL Library (libpdel, \-lpdel)
                     48: .Sh SYNOPSIS
                     49: .In sys/types.h
                     50: .In pdel/structs/structs.h
                     51: .In pdel/structs/type/id.h
                     52: .Fn STRUCTS_ID_TYPE idlist vsize
                     53: .Sh DESCRIPTION
                     54: The
                     55: .Fn STRUCTS_ID_TYPE
                     56: macro defines a
                     57: .Xr structs 3
                     58: type (i.e., a
                     59: .Dv "struct structs_type" )
                     60: for describing an enumeration or identifier list.
                     61: .Pp
                     62: The data structure represented is an integral value that may
                     63: take one of a fixed set of values.
                     64: The possible values are defined by the
                     65: .Fa idlist
                     66: argument, which is a pointer to an array of
                     67: .Li "struct structs_id" :
                     68: .Pp
                     69: .Bd -literal -compact -offset 3n
                     70: struct structs_id {
                     71:     const char  *id;        /* string representation */
                     72:     u_int32_t   value;      /* integer representation */
                     73:     u_int       imatch;     /* case-insensitive matching allowed */
                     74: };
                     75: .Ed
                     76: .Pp
                     77: The
                     78: .Fa id
                     79: points to a unique string representing the value;
                     80: .Fa imatch ,
                     81: determines whether the parsing of the ASCII representation is
                     82: case-insensitive.
                     83: .Fa value
                     84: is the actual integer value.
                     85: The first element in the array used as the default value.
                     86: The array is terminated with an entry having
                     87: .Fa id
                     88: equal to
                     89: .Dv NULL .
                     90: .Pp
                     91: .Fa vsize
                     92: is the size of the integral type used to store the value, which must
                     93: be 1, 2, or 4.
                     94: .Sh SEE ALSO
                     95: .Xr libpdel 3 ,
                     96: .Xr structs 3 ,
                     97: .Xr structs_type 3
                     98: .Sh EXAMPLES
                     99: .Bd -literal -offset 0n
                    100: 
                    101: /* Set of possible colors */
                    102: enum color {
                    103:        RED,
                    104:        GREEN,
                    105:        BLUE,
                    106: };
                    107: 
                    108: /* The current color */
                    109: static enum color current_color;
                    110: 
                    111: /* Structs type describing something of type "enum color" */
                    112: static const struct structs_id color_list[] = {
                    113:        { "red", RED },
                    114:        { "green", GREEN },
                    115:        { "blue", BLUE },
                    116:        { NULL, 0 }
                    117: };
                    118: static const struct structs_type color_type
                    119:        = STRUCTS_ID_TYPE(color_list, sizeof(enum color));
                    120: .Ed
                    121: .Sh HISTORY
                    122: The PDEL library was developed at Packet Design, LLC.
                    123: .Dv "http://www.packetdesign.com/"
                    124: .Sh AUTHORS
                    125: .An Archie Cobbs Aq archie@freebsd.org

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>