xref: /onnv-gate/usr/src/lib/krb5/kadm5/srv/xdr_alloc.c (revision 7934:6aeeafc994de)
10Sstevel@tonic-gate 
20Sstevel@tonic-gate /*
30Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
60Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
70Sstevel@tonic-gate  *	source code before consulting with your legal department.
80Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
90Sstevel@tonic-gate  *	product before consulting with your legal department.
100Sstevel@tonic-gate  *
110Sstevel@tonic-gate  *	For further information, read the top-level Openvision
120Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
130Sstevel@tonic-gate  *	copyright.
140Sstevel@tonic-gate  *
150Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
160Sstevel@tonic-gate  *
170Sstevel@tonic-gate  */
180Sstevel@tonic-gate 
190Sstevel@tonic-gate 
200Sstevel@tonic-gate /* @(#)xdr_mem.c	2.1 88/07/29 4.0 RPCSRC */
210Sstevel@tonic-gate /*
220Sstevel@tonic-gate  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
230Sstevel@tonic-gate  * unrestricted use provided that this legend is included on all tape
240Sstevel@tonic-gate  * media and as a part of the software program in whole or part.  Users
250Sstevel@tonic-gate  * may copy or modify Sun RPC without charge, but are not authorized
260Sstevel@tonic-gate  * to license or distribute it to anyone else except as part of a product or
270Sstevel@tonic-gate  * program developed by the user.
280Sstevel@tonic-gate  *
290Sstevel@tonic-gate  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
300Sstevel@tonic-gate  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
310Sstevel@tonic-gate  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
320Sstevel@tonic-gate  *
330Sstevel@tonic-gate  * Sun RPC is provided with no support and without any obligation on the
340Sstevel@tonic-gate  * part of Sun Microsystems, Inc. to assist in its use, correction,
350Sstevel@tonic-gate  * modification or enhancement.
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
380Sstevel@tonic-gate  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
390Sstevel@tonic-gate  * OR ANY PART THEREOF.
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
420Sstevel@tonic-gate  * or profits or other special, indirect and consequential damages, even if
430Sstevel@tonic-gate  * Sun has been advised of the possibility of such damages.
440Sstevel@tonic-gate  *
450Sstevel@tonic-gate  * Sun Microsystems, Inc.
460Sstevel@tonic-gate  * 2550 Garcia Avenue
470Sstevel@tonic-gate  * Mountain View, California  94043
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate #if !defined(lint) && defined(SCCSIDS)
500Sstevel@tonic-gate static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
510Sstevel@tonic-gate #endif
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
550Sstevel@tonic-gate  *
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate #include "admin.h"
590Sstevel@tonic-gate #include <rpc/types.h>
600Sstevel@tonic-gate #include <rpc/xdr.h>
610Sstevel@tonic-gate #include <dyn/dyn.h>
620Sstevel@tonic-gate 
63*7934SMark.Phalan@Sun.COM /* Solaris Kerberos - 116 resync */
640Sstevel@tonic-gate static bool_t	xdralloc_putlong();
650Sstevel@tonic-gate static bool_t	xdralloc_putbytes();
660Sstevel@tonic-gate static unsigned int	xdralloc_getpos();
670Sstevel@tonic-gate static rpc_inline_t *	xdralloc_inline();
680Sstevel@tonic-gate static void	xdralloc_destroy();
69*7934SMark.Phalan@Sun.COM static bool_t	xdralloc_notsup_getlong();
70*7934SMark.Phalan@Sun.COM static bool_t	xdralloc_notsup_getbytes();
71*7934SMark.Phalan@Sun.COM static bool_t	xdralloc_notsup_setpos();
720Sstevel@tonic-gate static struct	xdr_ops xdralloc_ops = {
73*7934SMark.Phalan@Sun.COM      xdralloc_notsup_getlong,
740Sstevel@tonic-gate      xdralloc_putlong,
75*7934SMark.Phalan@Sun.COM      xdralloc_notsup_getbytes,
760Sstevel@tonic-gate      xdralloc_putbytes,
770Sstevel@tonic-gate      xdralloc_getpos,
78*7934SMark.Phalan@Sun.COM      xdralloc_notsup_setpos,
790Sstevel@tonic-gate      xdralloc_inline,
800Sstevel@tonic-gate      xdralloc_destroy,
810Sstevel@tonic-gate };
820Sstevel@tonic-gate 
830Sstevel@tonic-gate /*
840Sstevel@tonic-gate  * The procedure xdralloc_create initializes a stream descriptor for a
850Sstevel@tonic-gate  * memory buffer.
860Sstevel@tonic-gate  */
xdralloc_create(XDR * xdrs,enum xdr_op op)87*7934SMark.Phalan@Sun.COM void xdralloc_create(XDR *xdrs, enum xdr_op op)
880Sstevel@tonic-gate {
890Sstevel@tonic-gate      xdrs->x_op = op;
900Sstevel@tonic-gate      xdrs->x_ops = &xdralloc_ops;
910Sstevel@tonic-gate      xdrs->x_private = (caddr_t) DynCreate(sizeof(char), -4);
920Sstevel@tonic-gate      /* not allowed to fail */
930Sstevel@tonic-gate }
940Sstevel@tonic-gate 
xdralloc_getdata(XDR * xdrs)95*7934SMark.Phalan@Sun.COM caddr_t xdralloc_getdata(XDR *xdrs)
960Sstevel@tonic-gate {
970Sstevel@tonic-gate      return (caddr_t) DynGet((DynObject) xdrs->x_private, 0);
980Sstevel@tonic-gate }
990Sstevel@tonic-gate 
xdralloc_release(XDR * xdrs)100*7934SMark.Phalan@Sun.COM void xdralloc_release(XDR *xdrs)
1010Sstevel@tonic-gate {
1020Sstevel@tonic-gate      DynRelease((DynObject) xdrs->x_private);
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate 
xdralloc_destroy(XDR * xdrs)105*7934SMark.Phalan@Sun.COM static void xdralloc_destroy(XDR *xdrs)
1060Sstevel@tonic-gate {
1070Sstevel@tonic-gate      DynDestroy((DynObject) xdrs->x_private);
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate 
xdralloc_notsup_getlong(register XDR * xdrs,long * lp)110*7934SMark.Phalan@Sun.COM static bool_t xdralloc_notsup_getlong(
111*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
112*7934SMark.Phalan@Sun.COM      long *lp)
1130Sstevel@tonic-gate {
1140Sstevel@tonic-gate      return FALSE;
1150Sstevel@tonic-gate }
1160Sstevel@tonic-gate 
xdralloc_putlong(register XDR * xdrs,long * lp)117*7934SMark.Phalan@Sun.COM static bool_t xdralloc_putlong(
118*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
119*7934SMark.Phalan@Sun.COM      long *lp)
1200Sstevel@tonic-gate {
121*7934SMark.Phalan@Sun.COM      int l = htonl((uint32_t) *lp); /* XXX need bounds checking */
122*7934SMark.Phalan@Sun.COM 
123*7934SMark.Phalan@Sun.COM      /* XXX assumes sizeof(int)==4 */
1240Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
1250Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private), &l,
1260Sstevel@tonic-gate 		   sizeof(int)) != DYN_OK)
1270Sstevel@tonic-gate 	  return FALSE;
1280Sstevel@tonic-gate      return (TRUE);
1290Sstevel@tonic-gate }
1300Sstevel@tonic-gate 
131*7934SMark.Phalan@Sun.COM 
xdralloc_notsup_getbytes(register XDR * xdrs,caddr_t addr,register unsigned int len)132*7934SMark.Phalan@Sun.COM static bool_t xdralloc_notsup_getbytes(
133*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
134*7934SMark.Phalan@Sun.COM      caddr_t addr,
135*7934SMark.Phalan@Sun.COM      register unsigned int len)
136*7934SMark.Phalan@Sun.COM {
137*7934SMark.Phalan@Sun.COM      return FALSE;
138*7934SMark.Phalan@Sun.COM }
139*7934SMark.Phalan@Sun.COM 
140*7934SMark.Phalan@Sun.COM 
xdralloc_putbytes(register XDR * xdrs,caddr_t addr,register unsigned int len)141*7934SMark.Phalan@Sun.COM static bool_t xdralloc_putbytes(
142*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
143*7934SMark.Phalan@Sun.COM      caddr_t addr,
144*7934SMark.Phalan@Sun.COM      register unsigned int len)
1450Sstevel@tonic-gate {
1460Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
1470Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private),
148*7934SMark.Phalan@Sun.COM 		   addr, (int) len) != DYN_OK)
1490Sstevel@tonic-gate 	  return FALSE;
1500Sstevel@tonic-gate      return TRUE;
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate 
xdralloc_getpos(XDR * xdrs)153*7934SMark.Phalan@Sun.COM static unsigned int xdralloc_getpos(XDR *xdrs)
1540Sstevel@tonic-gate {
1550Sstevel@tonic-gate      return DynSize((DynObject) xdrs->x_private);
1560Sstevel@tonic-gate }
1570Sstevel@tonic-gate 
xdralloc_notsup_setpos(register XDR * xdrs,unsigned int lp)158*7934SMark.Phalan@Sun.COM static bool_t xdralloc_notsup_setpos(
159*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
160*7934SMark.Phalan@Sun.COM      unsigned int lp)
161*7934SMark.Phalan@Sun.COM {
162*7934SMark.Phalan@Sun.COM      return FALSE;
163*7934SMark.Phalan@Sun.COM }
1640Sstevel@tonic-gate 
165*7934SMark.Phalan@Sun.COM 
166*7934SMark.Phalan@Sun.COM 
xdralloc_inline(register XDR * xdrs,int len)167*7934SMark.Phalan@Sun.COM static rpc_inline_t *xdralloc_inline(
168*7934SMark.Phalan@Sun.COM      register XDR *xdrs,
169*7934SMark.Phalan@Sun.COM      int len)
1700Sstevel@tonic-gate {
1710Sstevel@tonic-gate      return (rpc_inline_t *) 0;
1720Sstevel@tonic-gate }
173