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