Annotation of embedaddon/mpd/src/contrib/libpdel/structs/type/string.h, revision 1.1.1.2
1.1 misho 1:
2: /*
3: * Copyright (c) 2001-2002 Packet Design, LLC.
4: * All rights reserved.
5: *
6: * Subject to the following obligations and disclaimer of warranty,
7: * use and redistribution of this software, in source or object code
8: * forms, with or without modifications are expressly permitted by
9: * Packet Design; provided, however, that:
10: *
11: * (i) Any and all reproductions of the source or object code
12: * must include the copyright notice above and the following
13: * disclaimer of warranties; and
14: * (ii) No rights are granted, in any manner or form, to use
15: * Packet Design trademarks, including the mark "PACKET DESIGN"
16: * on advertising, endorsements, or otherwise except as such
17: * appears in the above copyright notice or in the software.
18: *
19: * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
20: * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
21: * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
22: * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
23: * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
24: * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
25: * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
26: * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
27: * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
28: * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
29: * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
30: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
31: * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
32: * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
33: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
35: * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
36: * THE POSSIBILITY OF SUCH DAMAGE.
37: *
38: * Author: Archie Cobbs <archie@freebsd.org>
39: */
40:
41: #ifndef _PDEL_STRUCTS_TYPE_STRING_H_
42: #define _PDEL_STRUCTS_TYPE_STRING_H_
43:
44: /*********************************************************************
45: STRING TYPES
46: *********************************************************************/
47:
48: __BEGIN_DECLS
49:
50: /*
51: * Dynamically allocated string types
52: *
53: * Type-specific arguments:
54: * [const char *] Memory allocation type
55: * [int] Whether to store empty string as NULL or ""
56: */
57: extern structs_init_t structs_string_init;
58: extern structs_equal_t structs_string_equal;
59: extern structs_ascify_t structs_string_ascify;
60: extern structs_binify_t structs_string_binify;
61: extern structs_encode_t structs_string_encode;
62: extern structs_decode_t structs_string_decode;
63: extern structs_uninit_t structs_string_free;
64:
65: __END_DECLS
66:
67: #define STRUCTS_TYPE_STRING_MTYPE "structs_type_string"
68:
69: #define STRUCTS_STRING_TYPE(mtype, asnull) { \
70: sizeof(char *), \
71: "string", \
72: STRUCTS_TYPE_PRIMITIVE, \
73: structs_string_init, \
74: structs_ascii_copy, \
75: structs_string_equal, \
76: structs_string_ascify, \
77: structs_string_binify, \
78: structs_string_encode, \
79: structs_string_decode, \
80: structs_string_free, \
1.1.1.2 ! misho 81: { { (const void *)(mtype) }, { (void *)(asnull) }, { NULL } } \
1.1 misho 82: }
83:
84: __BEGIN_DECLS
85:
86: /* A string type with allocation type "structs_type_string" and never NULL */
87: extern const struct structs_type structs_type_string;
88:
89: /* A string type with allocation type "structs_type_string" and can be NULL */
90: extern const struct structs_type structs_type_string_null;
91:
92: __END_DECLS
93:
94: /*********************************************************************
95: BOUNDED LENGTH STRING TYPES
96: *********************************************************************/
97:
98: __BEGIN_DECLS
99:
100: /*
101: * Bounded length string types
102: *
103: * Type-specific arguments:
104: * [int] Size of string buffer
105: */
106: extern structs_equal_t structs_bstring_equal;
107: extern structs_ascify_t structs_bstring_ascify;
108: extern structs_binify_t structs_bstring_binify;
109:
110: __END_DECLS
111:
112: #define STRUCTS_FIXEDSTRING_TYPE(bufsize) { \
113: (bufsize), \
114: "fixedstring", \
115: STRUCTS_TYPE_PRIMITIVE, \
116: structs_region_init, \
117: structs_region_copy, \
118: structs_bstring_equal, \
119: structs_bstring_ascify, \
120: structs_bstring_binify, \
121: structs_string_encode, \
122: structs_string_decode, \
123: structs_nothing_free, \
124: { { NULL }, { NULL }, { NULL } } \
125: }
126:
127: #endif /* _PDEL_STRUCTS_TYPE_STRING_H_ */
128:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>