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