xref: /onnv-gate/usr/src/lib/krb5/kadm5/srv/xdr_alloc.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
2*0Sstevel@tonic-gate 
3*0Sstevel@tonic-gate /*
4*0Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5*0Sstevel@tonic-gate  *
6*0Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
7*0Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
8*0Sstevel@tonic-gate  *	source code before consulting with your legal department.
9*0Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
10*0Sstevel@tonic-gate  *	product before consulting with your legal department.
11*0Sstevel@tonic-gate  *
12*0Sstevel@tonic-gate  *	For further information, read the top-level Openvision
13*0Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
14*0Sstevel@tonic-gate  *	copyright.
15*0Sstevel@tonic-gate  *
16*0Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
17*0Sstevel@tonic-gate  *
18*0Sstevel@tonic-gate  */
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate 
21*0Sstevel@tonic-gate /* @(#)xdr_mem.c	2.1 88/07/29 4.0 RPCSRC */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
24*0Sstevel@tonic-gate  * unrestricted use provided that this legend is included on all tape
25*0Sstevel@tonic-gate  * media and as a part of the software program in whole or part.  Users
26*0Sstevel@tonic-gate  * may copy or modify Sun RPC without charge, but are not authorized
27*0Sstevel@tonic-gate  * to license or distribute it to anyone else except as part of a product or
28*0Sstevel@tonic-gate  * program developed by the user.
29*0Sstevel@tonic-gate  *
30*0Sstevel@tonic-gate  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
31*0Sstevel@tonic-gate  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
32*0Sstevel@tonic-gate  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
33*0Sstevel@tonic-gate  *
34*0Sstevel@tonic-gate  * Sun RPC is provided with no support and without any obligation on the
35*0Sstevel@tonic-gate  * part of Sun Microsystems, Inc. to assist in its use, correction,
36*0Sstevel@tonic-gate  * modification or enhancement.
37*0Sstevel@tonic-gate  *
38*0Sstevel@tonic-gate  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
39*0Sstevel@tonic-gate  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
40*0Sstevel@tonic-gate  * OR ANY PART THEREOF.
41*0Sstevel@tonic-gate  *
42*0Sstevel@tonic-gate  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
43*0Sstevel@tonic-gate  * or profits or other special, indirect and consequential damages, even if
44*0Sstevel@tonic-gate  * Sun has been advised of the possibility of such damages.
45*0Sstevel@tonic-gate  *
46*0Sstevel@tonic-gate  * Sun Microsystems, Inc.
47*0Sstevel@tonic-gate  * 2550 Garcia Avenue
48*0Sstevel@tonic-gate  * Mountain View, California  94043
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate #if !defined(lint) && defined(SCCSIDS)
51*0Sstevel@tonic-gate static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
52*0Sstevel@tonic-gate #endif
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
56*0Sstevel@tonic-gate  *
57*0Sstevel@tonic-gate  * $Header: /afs/athena.mit.edu/astaff/project/krbdev/.cvsroot/src/lib/rpc/xdr_alloc.c,v 1.6 1996/07/22 20:41:21 marc Exp $
58*0Sstevel@tonic-gate  *
59*0Sstevel@tonic-gate  * $Log: xdr_alloc.c,v $
60*0Sstevel@tonic-gate  * Revision 1.6  1996/07/22 20:41:21  marc
61*0Sstevel@tonic-gate  * this commit includes all the changes on the OV_9510_INTEGRATION and
62*0Sstevel@tonic-gate  * OV_MERGE branches.  This includes, but is not limited to, the new openvision
63*0Sstevel@tonic-gate  * admin system, and major changes to gssapi to add functionality, and bring
64*0Sstevel@tonic-gate  * the implementation in line with rfc1964.  before committing, the
65*0Sstevel@tonic-gate  * code was built and tested for netbsd and solaris.
66*0Sstevel@tonic-gate  *
67*0Sstevel@tonic-gate  * Revision 1.5.4.1  1996/07/18 04:19:49  marc
68*0Sstevel@tonic-gate  * merged in changes from OV_9510_BP to OV_9510_FINAL1
69*0Sstevel@tonic-gate  *
70*0Sstevel@tonic-gate  * Revision 1.5.2.1  1996/06/20  23:40:30  marc
71*0Sstevel@tonic-gate  * File added to the repository on a branch
72*0Sstevel@tonic-gate  *
73*0Sstevel@tonic-gate  * Revision 1.5  1996/05/12  06:19:25  marc
74*0Sstevel@tonic-gate  * renamed lots of types: u_foo to unsigned foo, and foo32 to rpc_foo32.  This is to make autoconfiscation less painful.
75*0Sstevel@tonic-gate  *
76*0Sstevel@tonic-gate  * Revision 1.4  1995/12/13  14:03:14  grier
77*0Sstevel@tonic-gate  * Longs to ints for Alpha
78*0Sstevel@tonic-gate  *
79*0Sstevel@tonic-gate  * Revision 1.3  1993/12/09  18:57:25  bjaspan
80*0Sstevel@tonic-gate  * [secure-releng/833] misc bugfixes to admin library
81*0Sstevel@tonic-gate  *
82*0Sstevel@tonic-gate  * Revision 1.3  1993/12/06  21:23:08  bjaspan
83*0Sstevel@tonic-gate  * add xdralloc_release
84*0Sstevel@tonic-gate  *
85*0Sstevel@tonic-gate  * Revision 1.2  1993/10/26  21:13:19  bjaspan
86*0Sstevel@tonic-gate  * add casts for correctness
87*0Sstevel@tonic-gate  *
88*0Sstevel@tonic-gate  * Revision 1.1  1993/10/19  03:11:39  bjaspan
89*0Sstevel@tonic-gate  * Initial revision
90*0Sstevel@tonic-gate  *
91*0Sstevel@tonic-gate  */
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #if !defined(lint) && !defined(__CODECENTER__)
94*0Sstevel@tonic-gate static char *rcsid = "$Header: /afs/athena.mit.edu/astaff/project/krbdev/.cvsroot/src/lib/rpc/xdr_alloc.c,v 1.6 1996/07/22 20:41:21 marc Exp $";
95*0Sstevel@tonic-gate #endif
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate #include "admin.h"
98*0Sstevel@tonic-gate #include <rpc/types.h>
99*0Sstevel@tonic-gate #include <rpc/xdr.h>
100*0Sstevel@tonic-gate #include <dyn/dyn.h>
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate static bool_t	xdralloc_putlong();
103*0Sstevel@tonic-gate static bool_t	xdralloc_putbytes();
104*0Sstevel@tonic-gate static unsigned int	xdralloc_getpos();
105*0Sstevel@tonic-gate static rpc_inline_t *	xdralloc_inline();
106*0Sstevel@tonic-gate static void	xdralloc_destroy();
107*0Sstevel@tonic-gate static bool_t	xdralloc_notsup();
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate static struct	xdr_ops xdralloc_ops = {
110*0Sstevel@tonic-gate      xdralloc_notsup,
111*0Sstevel@tonic-gate      xdralloc_putlong,
112*0Sstevel@tonic-gate      xdralloc_notsup,
113*0Sstevel@tonic-gate      xdralloc_putbytes,
114*0Sstevel@tonic-gate      xdralloc_getpos,
115*0Sstevel@tonic-gate      xdralloc_notsup,
116*0Sstevel@tonic-gate      xdralloc_inline,
117*0Sstevel@tonic-gate      xdralloc_destroy,
118*0Sstevel@tonic-gate };
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate /*
121*0Sstevel@tonic-gate  * The procedure xdralloc_create initializes a stream descriptor for a
122*0Sstevel@tonic-gate  * memory buffer.
123*0Sstevel@tonic-gate  */
124*0Sstevel@tonic-gate void xdralloc_create(xdrs, op)
125*0Sstevel@tonic-gate    register XDR *xdrs;
126*0Sstevel@tonic-gate    enum xdr_op op;
127*0Sstevel@tonic-gate {
128*0Sstevel@tonic-gate      xdrs->x_op = op;
129*0Sstevel@tonic-gate      xdrs->x_ops = &xdralloc_ops;
130*0Sstevel@tonic-gate      xdrs->x_private = (caddr_t) DynCreate(sizeof(char), -4);
131*0Sstevel@tonic-gate      /* not allowed to fail */
132*0Sstevel@tonic-gate }
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate caddr_t xdralloc_getdata(xdrs)
135*0Sstevel@tonic-gate    XDR *xdrs;
136*0Sstevel@tonic-gate {
137*0Sstevel@tonic-gate      return (caddr_t) DynGet((DynObject) xdrs->x_private, 0);
138*0Sstevel@tonic-gate }
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate void xdralloc_release(xdrs)
141*0Sstevel@tonic-gate    XDR *xdrs;
142*0Sstevel@tonic-gate {
143*0Sstevel@tonic-gate      DynRelease((DynObject) xdrs->x_private);
144*0Sstevel@tonic-gate }
145*0Sstevel@tonic-gate 
146*0Sstevel@tonic-gate static void xdralloc_destroy(xdrs)
147*0Sstevel@tonic-gate    XDR *xdrs;
148*0Sstevel@tonic-gate {
149*0Sstevel@tonic-gate      DynDestroy((DynObject) xdrs->x_private);
150*0Sstevel@tonic-gate }
151*0Sstevel@tonic-gate 
152*0Sstevel@tonic-gate static bool_t xdralloc_notsup()
153*0Sstevel@tonic-gate {
154*0Sstevel@tonic-gate      return FALSE;
155*0Sstevel@tonic-gate }
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate static bool_t xdralloc_putlong(xdrs, lp)
158*0Sstevel@tonic-gate    register XDR *xdrs;
159*0Sstevel@tonic-gate    rpc_int32 *lp;
160*0Sstevel@tonic-gate {
161*0Sstevel@tonic-gate      int l = htonl((rpc_u_int32) *(int *)lp);
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
164*0Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private), &l,
165*0Sstevel@tonic-gate 		   sizeof(int)) != DYN_OK)
166*0Sstevel@tonic-gate 	  return FALSE;
167*0Sstevel@tonic-gate      return (TRUE);
168*0Sstevel@tonic-gate }
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate static bool_t xdralloc_putbytes(xdrs, addr, len)
171*0Sstevel@tonic-gate    register XDR *xdrs;
172*0Sstevel@tonic-gate    caddr_t addr;
173*0Sstevel@tonic-gate    register unsigned int len;
174*0Sstevel@tonic-gate {
175*0Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
176*0Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private),
177*0Sstevel@tonic-gate 		   addr, len) != DYN_OK)
178*0Sstevel@tonic-gate 	  return FALSE;
179*0Sstevel@tonic-gate      return TRUE;
180*0Sstevel@tonic-gate }
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate static unsigned int xdralloc_getpos(xdrs)
183*0Sstevel@tonic-gate    register XDR *xdrs;
184*0Sstevel@tonic-gate {
185*0Sstevel@tonic-gate      return DynSize((DynObject) xdrs->x_private);
186*0Sstevel@tonic-gate }
187*0Sstevel@tonic-gate 
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate static rpc_inline_t *xdralloc_inline(xdrs, len)
190*0Sstevel@tonic-gate    register XDR *xdrs;
191*0Sstevel@tonic-gate    int len;
192*0Sstevel@tonic-gate {
193*0Sstevel@tonic-gate      return (rpc_inline_t *) 0;
194*0Sstevel@tonic-gate }
195