xref: /titanic_51/usr/src/lib/libresolv2/include/isc/irpmarshall.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1 /*
2  * Copyright 2000-2002 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1999 by Internet Software Consortium.
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
14  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
16  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
17  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20  * SOFTWARE.
21  */
22 
23 /*
24  * $Id: irpmarshall.h,v 8.2 2001/05/29 05:47:10 marka Exp $
25  */
26 
27 #ifndef _IRPMARSHALL_H_INCLUDED
28 #define _IRPMARSHALL_H_INCLUDED
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /* Hide function names */
33 #define irp_marshall_gr __irp_marshall_gr
34 #define irp_marshall_ho __irp_marshall_ho
35 #define irp_marshall_ne __irp_marshall_ne
36 #define irp_marshall_ng __irp_marshall_ng
37 #define irp_marshall_nw __irp_marshall_nw
38 #define irp_marshall_pr __irp_marshall_pr
39 #define irp_marshall_pw __irp_marshall_pw
40 #define irp_marshall_sv __irp_marshall_sv
41 #define irp_unmarshall_gr __irp_unmarshall_gr
42 #define irp_unmarshall_ho __irp_unmarshall_ho
43 #define irp_unmarshall_ne __irp_unmarshall_ne
44 #define irp_unmarshall_ng __irp_unmarshall_ng
45 #define irp_unmarshall_nw __irp_unmarshall_nw
46 #define irp_unmarshall_pr __irp_unmarshall_pr
47 #define irp_unmarshall_pw __irp_unmarshall_pw
48 #define irp_unmarshall_sv __irp_unmarshall_sv
49 
50 #define MAXPADDRSIZE (sizeof "255.255.255.255" + 1)
51 #define ADDR_T_STR(x) (x == AF_INET ? "AF_INET" :\
52 		       (x == AF_INET6 ? "AF_INET6" : "UNKNOWN"))
53 
54 /* See comment below on usage */
55 int irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len);
56 int irp_unmarshall_pw(struct passwd *pw, char *buffer);
57 int irp_marshall_gr(const struct group *gr, char **buffer, size_t *len);
58 int irp_unmarshall_gr(struct group *gr, char *buffer);
59 int irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len);
60 int irp_unmarshall_sv(struct servent *sv, char *buffer);
61 int irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len);
62 int irp_unmarshall_pr(struct protoent *pr, char *buffer);
63 int irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len);
64 int irp_unmarshall_ho(struct hostent *ho, char *buffer);
65 int irp_marshall_ng(const char *host, const char *user, const char *domain,
66 		    char **buffer, size_t *len);
67 int irp_unmarshall_ng(const char **host, const char **user,
68 		      const char **domain, char *buffer);
69 int irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len);
70 int irp_unmarshall_nw(struct nwent *ne, char *buffer);
71 int irp_marshall_ne(struct netent *ne, char **buffer, size_t *len);
72 int irp_unmarshall_ne(struct netent *ne, char *buffer);
73 
74 /*
75  * Functions to marshall and unmarshall various system data structures. We
76  * use a printable ascii format that is as close to various system config
77  * files as reasonable (e.g. /etc/passwd format).
78  *
79  * We are not forgiving with unmarhsalling misformatted buffers. In
80  * particular whitespace in fields is not ignored. So a formatted password
81  * entry "brister  :1364:100:...." will yield a username of "brister   "
82  *
83  * We potentially do a lot of mallocs to fill fields that are of type
84  * (char **) like a hostent h_addr field. Building (for example) the
85  * h_addr field and its associated addresses all in one buffer is
86  * certainly possible, but not done here.
87  *
88  * The following description is true for all the marshalling functions:
89  *
90  */
91 
92 /* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len);
93  *
94  * The argument XX (of type struct passwd for example) is marshalled in the
95  * buffer pointed at by *BUFFER, which is of length *LEN. Returns 0
96  * on success and -1 on failure. Failure will occur if *LEN is
97  * smaller than needed.
98  *
99  * If BUFFER is NULL, then *LEN is set to the size of the buffer
100  * needed to marshall the data and no marshalling is actually done.
101  *
102  * If *BUFFER is NULL, then a buffer large enough will be allocated
103  * with memget() and the size allocated will be stored in *LEN. An extra 2
104  * bytes will be allocated for the client to append CRLF if wanted. The
105  * value of *LEN will include these two bytes.
106  *
107  * All the marshalling functions produce a buffer with the fields
108  * separated by colons (except for the hostent marshalling, which uses '@'
109  * to separate fields). Fields that have multiple subfields (like the
110  * gr_mem field in struct group) have their subparts separated by
111  * commas.
112  */
113 
114 /*
115  * int irp_unmarshall_XX(struct YYYYY *XX, char *buffer);
116  *
117  * The unmashalling functions break apart the buffer and store the
118  * values in the struct pointed to by XX. All pointer values inside
119  * XX are allocated with malloc. All arrays of pointers have a NULL
120  * as the last element.
121  */
122 
123 #endif
124