Import bind 9.5.2 vendor sources.
[dragonfly.git] / contrib / bind-9.5.2 / lib / isccc / include / isccc / sexpr.h
1 /*
2  * Portions Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
3  * Portions Copyright (C) 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
12  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * Portions Copyright (C) 2001  Nominum, Inc.
18  *
19  * Permission to use, copy, modify, and/or distribute this software for any
20  * purpose with or without fee is hereby granted, provided that the above
21  * copyright notice and this permission notice appear in all copies.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
24  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
26  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30  */
31
32 /* $Id: sexpr.h,v 1.11 2007/08/28 07:20:43 tbox Exp $ */
33
34 #ifndef ISCCC_SEXPR_H
35 #define ISCCC_SEXPR_H 1
36
37 /*! \file isccc/sexpr.h */
38
39 #include <stdio.h>
40
41 #include <isc/lang.h>
42 #include <isccc/types.h>
43
44 ISC_LANG_BEGINDECLS
45
46 /*% dotted pair structure */
47 struct isccc_dottedpair {
48         isccc_sexpr_t *car;
49         isccc_sexpr_t *cdr;
50 };
51
52 /*% iscc_sexpr structure */
53 struct isccc_sexpr {
54         unsigned int                    type;
55         union {
56                 char *                  as_string;
57                 isccc_dottedpair_t      as_dottedpair;
58                 isccc_region_t          as_region;
59         }                               value;
60 };
61
62 #define ISCCC_SEXPRTYPE_NONE            0x00    /*%< Illegal. */
63 #define ISCCC_SEXPRTYPE_T                       0x01
64 #define ISCCC_SEXPRTYPE_STRING          0x02
65 #define ISCCC_SEXPRTYPE_DOTTEDPAIR      0x03
66 #define ISCCC_SEXPRTYPE_BINARY          0x04
67
68 #define ISCCC_SEXPR_CAR(s)              (s)->value.as_dottedpair.car
69 #define ISCCC_SEXPR_CDR(s)              (s)->value.as_dottedpair.cdr
70
71 isccc_sexpr_t *
72 isccc_sexpr_cons(isccc_sexpr_t *car, isccc_sexpr_t *cdr);
73
74 isccc_sexpr_t *
75 isccc_sexpr_tconst(void);
76
77 isccc_sexpr_t *
78 isccc_sexpr_fromstring(const char *str);
79
80 isccc_sexpr_t *
81 isccc_sexpr_frombinary(const isccc_region_t *region);
82
83 void
84 isccc_sexpr_free(isccc_sexpr_t **sexprp);
85
86 void
87 isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream);
88
89 isccc_sexpr_t *
90 isccc_sexpr_car(isccc_sexpr_t *list);
91
92 isccc_sexpr_t *
93 isccc_sexpr_cdr(isccc_sexpr_t *list);
94
95 void
96 isccc_sexpr_setcar(isccc_sexpr_t *pair, isccc_sexpr_t *car);
97
98 void
99 isccc_sexpr_setcdr(isccc_sexpr_t *pair, isccc_sexpr_t *cdr);
100
101 isccc_sexpr_t *
102 isccc_sexpr_addtolist(isccc_sexpr_t **l1p, isccc_sexpr_t *l2);
103
104 isc_boolean_t
105 isccc_sexpr_listp(isccc_sexpr_t *sexpr);
106
107 isc_boolean_t
108 isccc_sexpr_emptyp(isccc_sexpr_t *sexpr);
109
110 isc_boolean_t
111 isccc_sexpr_stringp(isccc_sexpr_t *sexpr);
112
113 isc_boolean_t
114 isccc_sexpr_binaryp(isccc_sexpr_t *sexpr);
115
116 char *
117 isccc_sexpr_tostring(isccc_sexpr_t *sexpr);
118
119 isccc_region_t *
120 isccc_sexpr_tobinary(isccc_sexpr_t *sexpr);
121
122 ISC_LANG_ENDDECLS
123
124 #endif /* ISCCC_SEXPR_H */