* Makeconfig (sysd-rules-patterns): New variable.
[glibc.git] / nis / yp_xdr.c
blobbdd5d8725f0a2c5b1668b8686dd88d2e0cfa4d0a
1 /*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
25 * Sun Microsystems, Inc.
26 * 2550 Garcia Avenue
27 * Mountain View, California 94043
30 #include <rpcsvc/yp.h>
31 #include <rpcsvc/ypclnt.h>
33 bool_t
34 xdr_ypstat (XDR *xdrs, ypstat *objp)
36 return xdr_enum (xdrs, (enum_t *) objp);
38 libnsl_hidden_def (xdr_ypstat)
40 bool_t
41 xdr_ypxfrstat (XDR *xdrs, ypxfrstat *objp)
43 return xdr_enum (xdrs, (enum_t *) objp);
45 libnsl_hidden_def (xdr_ypxfrstat)
47 bool_t
48 xdr_domainname (XDR *xdrs, domainname *objp)
50 return xdr_string (xdrs, objp, ~0);
52 libnsl_hidden_def (xdr_domainname)
54 bool_t
55 xdr_mapname (XDR *xdrs, mapname *objp)
57 return xdr_string (xdrs, objp, ~0);
59 libnsl_hidden_def (xdr_mapname)
61 bool_t
62 xdr_peername (XDR *xdrs, peername *objp)
64 return xdr_string (xdrs, objp, ~0);
66 libnsl_hidden_def (xdr_peername)
68 bool_t
69 xdr_keydat (XDR *xdrs, keydat *objp)
71 return xdr_bytes (xdrs, (char **) &objp->keydat_val,
72 (u_int *) &objp->keydat_len, ~0);
74 libnsl_hidden_def (xdr_keydat)
76 bool_t
77 xdr_valdat (XDR *xdrs, valdat *objp)
79 return xdr_bytes (xdrs, (char **) &objp->valdat_val,
80 (u_int *) &objp->valdat_len, ~0);
82 libnsl_hidden_def (xdr_valdat)
84 bool_t
85 xdr_ypmap_parms (XDR *xdrs, ypmap_parms *objp)
87 if (!xdr_domainname (xdrs, &objp->domain))
88 return FALSE;
89 if (!xdr_mapname (xdrs, &objp->map))
90 return FALSE;
91 if (!xdr_u_int (xdrs, &objp->ordernum))
92 return FALSE;
93 return xdr_peername (xdrs, &objp->peer);
95 libnsl_hidden_def (xdr_ypmap_parms)
97 bool_t
98 xdr_ypreq_key (XDR *xdrs, ypreq_key *objp)
100 if (!xdr_domainname (xdrs, &objp->domain))
101 return FALSE;
102 if (!xdr_mapname (xdrs, &objp->map))
103 return FALSE;
104 return xdr_keydat (xdrs, &objp->key);
106 libnsl_hidden_def (xdr_ypreq_key)
108 bool_t
109 xdr_ypreq_nokey (XDR *xdrs, ypreq_nokey *objp)
111 if (!xdr_domainname (xdrs, &objp->domain))
112 return FALSE;
113 return xdr_mapname (xdrs, &objp->map);
115 libnsl_hidden_def (xdr_ypreq_nokey)
117 bool_t
118 xdr_ypreq_xfr (XDR *xdrs, ypreq_xfr *objp)
120 if (!xdr_ypmap_parms (xdrs, &objp->map_parms))
121 return FALSE;
122 if (!xdr_u_int (xdrs, &objp->transid))
123 return FALSE;
124 if (!xdr_u_int (xdrs, &objp->prog))
125 return FALSE;
126 return xdr_u_int (xdrs, &objp->port);
129 bool_t
130 xdr_ypresp_val (XDR *xdrs, ypresp_val *objp)
132 if (!xdr_ypstat (xdrs, &objp->stat))
133 return FALSE;
134 return xdr_valdat (xdrs, &objp->val);
136 libnsl_hidden_def (xdr_ypresp_val)
138 bool_t
139 xdr_ypresp_key_val (XDR *xdrs, ypresp_key_val *objp)
141 if (!xdr_ypstat (xdrs, &objp->stat))
142 return FALSE;
143 if (!xdr_valdat (xdrs, &objp->val))
144 return FALSE;
145 return xdr_keydat (xdrs, &objp->key);
147 libnsl_hidden_def (xdr_ypresp_key_val)
149 bool_t
150 xdr_ypresp_master (XDR *xdrs, ypresp_master *objp)
152 if (!xdr_ypstat (xdrs, &objp->stat))
153 return FALSE;
154 return xdr_peername (xdrs, &objp->peer);
156 libnsl_hidden_def (xdr_ypresp_master)
158 bool_t
159 xdr_ypresp_order (XDR *xdrs, ypresp_order *objp)
161 if (!xdr_ypstat (xdrs, &objp->stat))
162 return FALSE;
163 return xdr_u_int (xdrs, &objp->ordernum);
165 libnsl_hidden_def (xdr_ypresp_order)
167 bool_t
168 xdr_ypresp_all (XDR *xdrs, ypresp_all *objp)
170 if (!xdr_bool (xdrs, &objp->more))
171 return FALSE;
172 switch (objp->more)
174 case TRUE:
175 return xdr_ypresp_key_val (xdrs, &objp->ypresp_all_u.val);
176 case FALSE:
177 break;
178 default:
179 return FALSE;
181 return TRUE;
183 libnsl_hidden_def (xdr_ypresp_all)
185 bool_t
186 xdr_ypresp_xfr (XDR *xdrs, ypresp_xfr *objp)
188 if (!xdr_u_int (xdrs, &objp->transid))
189 return FALSE;
190 return xdr_ypxfrstat (xdrs, &objp->xfrstat);
193 bool_t
194 xdr_ypmaplist (XDR *xdrs, ypmaplist *objp)
196 if (!xdr_mapname (xdrs, &objp->map))
197 return FALSE;
198 /* Prevent gcc warning about alias violation. */
199 char **tp = (void *) &objp->next;
200 return xdr_pointer (xdrs, tp, sizeof (ypmaplist), (xdrproc_t) xdr_ypmaplist);
202 libnsl_hidden_def (xdr_ypmaplist)
204 bool_t
205 xdr_ypresp_maplist (XDR *xdrs, ypresp_maplist *objp)
207 if (!xdr_ypstat (xdrs, &objp->stat))
208 return FALSE;
209 /* Prevent gcc warning about alias violation. */
210 char **tp = (void *) &objp->maps;
211 return xdr_pointer (xdrs, tp, sizeof (ypmaplist), (xdrproc_t) xdr_ypmaplist);
213 libnsl_hidden_def (xdr_ypresp_maplist)
215 bool_t
216 xdr_yppush_status (XDR *xdrs, yppush_status *objp)
218 return xdr_enum (xdrs, (enum_t *) objp);
220 libnsl_hidden_def (xdr_yppush_status)
222 bool_t
223 xdr_yppushresp_xfr (XDR *xdrs, yppushresp_xfr *objp)
225 if (!xdr_u_int (xdrs, &objp->transid))
226 return FALSE;
227 return xdr_yppush_status (xdrs, &objp->status);
230 bool_t
231 xdr_ypbind_resptype (XDR *xdrs, ypbind_resptype *objp)
233 return xdr_enum (xdrs, (enum_t *) objp);
235 libnsl_hidden_def (xdr_ypbind_resptype)
237 bool_t
238 xdr_ypbind_binding (XDR *xdrs, ypbind_binding *objp)
240 if (!xdr_opaque (xdrs, objp->ypbind_binding_addr, 4))
241 return FALSE;
242 return xdr_opaque (xdrs, objp->ypbind_binding_port, 2);
244 libnsl_hidden_def (xdr_ypbind_binding)
246 bool_t
247 xdr_ypbind_resp (XDR *xdrs, ypbind_resp *objp)
249 if (!xdr_ypbind_resptype (xdrs, &objp->ypbind_status))
250 return FALSE;
251 switch (objp->ypbind_status)
253 case YPBIND_FAIL_VAL:
254 return xdr_u_int (xdrs, &objp->ypbind_resp_u.ypbind_error);
255 case YPBIND_SUCC_VAL:
256 return xdr_ypbind_binding (xdrs, &objp->ypbind_resp_u.ypbind_bindinfo);
258 return FALSE;
260 libnsl_hidden_def (xdr_ypbind_resp)
262 bool_t
263 xdr_ypbind_setdom (XDR *xdrs, ypbind_setdom *objp)
265 if (!xdr_domainname (xdrs, &objp->ypsetdom_domain))
266 return FALSE;
267 if (!xdr_ypbind_binding (xdrs, &objp->ypsetdom_binding))
268 return FALSE;
269 return xdr_u_int (xdrs, &objp->ypsetdom_vers);
272 bool_t
273 xdr_ypall(XDR *xdrs, struct ypall_callback *incallback)
275 struct ypresp_key_val out;
276 char key[YPMAXRECORD], val[YPMAXRECORD];
279 * Set up key/val struct to be used during the transaction.
281 memset(&out, 0, sizeof out);
282 out.key.keydat_val = key;
283 out.key.keydat_len = sizeof(key);
284 out.val.valdat_val = val;
285 out.val.valdat_len = sizeof(val);
287 for (;;) {
288 bool_t more, status;
290 /* Values pending? */
291 if (!xdr_bool(xdrs, &more))
292 return FALSE; /* can't tell! */
293 if (!more)
294 return TRUE; /* no more */
296 /* Transfer key/value pair. */
297 status = xdr_ypresp_key_val(xdrs, &out);
300 * If we succeeded, call the callback function.
301 * The callback will return TRUE when it wants
302 * no more values. If we fail, indicate the
303 * error.
305 if (status) {
306 if ((*incallback->foreach)(out.stat,
307 (char *)out.key.keydat_val, out.key.keydat_len,
308 (char *)out.val.valdat_val, out.val.valdat_len,
309 incallback->data))
310 return TRUE;
311 } else
312 return FALSE;