bind - Upgraded vendor branch to 9.5.2-P1
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / bind / include / isc / irpmarshall.h
1 /*
2  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (c) 1999 by Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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 DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12  * ANY 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
15  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /*
19  * $Id: irpmarshall.h,v 1.1.2.2 2004/03/09 09:17:26 marka Exp $
20  */
21
22 #ifndef _IRPMARSHALL_H_INCLUDED
23 #define _IRPMARSHALL_H_INCLUDED
24
25 /* Hide function names */
26 #define irp_marshall_gr __irp_marshall_gr
27 #define irp_marshall_ho __irp_marshall_ho
28 #define irp_marshall_ne __irp_marshall_ne
29 #define irp_marshall_ng __irp_marshall_ng
30 #define irp_marshall_nw __irp_marshall_nw
31 #define irp_marshall_pr __irp_marshall_pr
32 #define irp_marshall_pw __irp_marshall_pw
33 #define irp_marshall_sv __irp_marshall_sv
34 #define irp_unmarshall_gr __irp_unmarshall_gr
35 #define irp_unmarshall_ho __irp_unmarshall_ho
36 #define irp_unmarshall_ne __irp_unmarshall_ne
37 #define irp_unmarshall_ng __irp_unmarshall_ng
38 #define irp_unmarshall_nw __irp_unmarshall_nw
39 #define irp_unmarshall_pr __irp_unmarshall_pr
40 #define irp_unmarshall_pw __irp_unmarshall_pw
41 #define irp_unmarshall_sv __irp_unmarshall_sv
42
43 #define MAXPADDRSIZE (sizeof "255.255.255.255" + 1)
44 #define ADDR_T_STR(x) (x == AF_INET ? "AF_INET" :\
45                        (x == AF_INET6 ? "AF_INET6" : "UNKNOWN"))
46
47 /* See comment below on usage */
48 int irp_marshall_pw(const struct passwd *, char **, size_t *);
49 int irp_unmarshall_pw(struct passwd *, char *);
50 int irp_marshall_gr(const struct group *, char **, size_t *);
51 int irp_unmarshall_gr(struct group *, char *);
52 int irp_marshall_sv(const struct servent *, char **, size_t *);
53 int irp_unmarshall_sv(struct servent *, char *);
54 int irp_marshall_pr(struct protoent *, char **, size_t *);
55 int irp_unmarshall_pr(struct protoent *, char *);
56 int irp_marshall_ho(struct hostent *, char **, size_t *);
57 int irp_unmarshall_ho(struct hostent *, char *);
58 int irp_marshall_ng(const char *, const char *, const char *,
59                     char **, size_t *);
60 int irp_unmarshall_ng(const char **, const char **, const char **, char *);
61 int irp_marshall_nw(struct nwent *, char **, size_t *);
62 int irp_unmarshall_nw(struct nwent *, char *);
63 int irp_marshall_ne(struct netent *, char **, size_t *);
64 int irp_unmarshall_ne(struct netent *, char *);
65
66 /*
67  * Functions to marshall and unmarshall various system data structures. We
68  * use a printable ascii format that is as close to various system config
69  * files as reasonable (e.g. /etc/passwd format).
70  *
71  * We are not forgiving with unmarhsalling misformatted buffers. In
72  * particular whitespace in fields is not ignored. So a formatted password
73  * entry "brister  :1364:100:...." will yield a username of "brister   "
74  *
75  * We potentially do a lot of mallocs to fill fields that are of type
76  * (char **) like a hostent h_addr field. Building (for example) the
77  * h_addr field and its associated addresses all in one buffer is
78  * certainly possible, but not done here.
79  *
80  * The following description is true for all the marshalling functions:
81  *
82  */
83
84 /* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len);
85  *
86  * The argument XX (of type struct passwd for example) is marshalled in the
87  * buffer pointed at by *BUFFER, which is of length *LEN. Returns 0
88  * on success and -1 on failure. Failure will occur if *LEN is
89  * smaller than needed.
90  *
91  * If BUFFER is NULL, then *LEN is set to the size of the buffer
92  * needed to marshall the data and no marshalling is actually done.
93  *
94  * If *BUFFER is NULL, then a buffer large enough will be allocated
95  * with memget() and the size allocated will be stored in *LEN. An extra 2
96  * bytes will be allocated for the client to append CRLF if wanted. The
97  * value of *LEN will include these two bytes.
98  *
99  * All the marshalling functions produce a buffer with the fields
100  * separated by colons (except for the hostent marshalling, which uses '@'
101  * to separate fields). Fields that have multiple subfields (like the
102  * gr_mem field in struct group) have their subparts separated by
103  * commas.
104  */
105
106 /*
107  * int irp_unmarshall_XX(struct YYYYY *XX, char *buffer);
108  *
109  * The unmashalling functions break apart the buffer and store the
110  * values in the struct pointed to by XX. All pointer values inside
111  * XX are allocated with malloc. All arrays of pointers have a NULL
112  * as the last element.
113  */
114
115 #endif