xref: /titanic_50/usr/src/lib/krb5/kadm5/srv/xdr_alloc.c (revision 159d09a20817016f09b3ea28d1bdada4a336bb91)
17c478bd9Sstevel@tonic-gate 
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
67c478bd9Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
77c478bd9Sstevel@tonic-gate  *	source code before consulting with your legal department.
87c478bd9Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
97c478bd9Sstevel@tonic-gate  *	product before consulting with your legal department.
107c478bd9Sstevel@tonic-gate  *
117c478bd9Sstevel@tonic-gate  *	For further information, read the top-level Openvision
127c478bd9Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
137c478bd9Sstevel@tonic-gate  *	copyright.
147c478bd9Sstevel@tonic-gate  *
157c478bd9Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
167c478bd9Sstevel@tonic-gate  *
177c478bd9Sstevel@tonic-gate  */
187c478bd9Sstevel@tonic-gate 
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate /* @(#)xdr_mem.c	2.1 88/07/29 4.0 RPCSRC */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
237c478bd9Sstevel@tonic-gate  * unrestricted use provided that this legend is included on all tape
247c478bd9Sstevel@tonic-gate  * media and as a part of the software program in whole or part.  Users
257c478bd9Sstevel@tonic-gate  * may copy or modify Sun RPC without charge, but are not authorized
267c478bd9Sstevel@tonic-gate  * to license or distribute it to anyone else except as part of a product or
277c478bd9Sstevel@tonic-gate  * program developed by the user.
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
307c478bd9Sstevel@tonic-gate  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
317c478bd9Sstevel@tonic-gate  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
327c478bd9Sstevel@tonic-gate  *
337c478bd9Sstevel@tonic-gate  * Sun RPC is provided with no support and without any obligation on the
347c478bd9Sstevel@tonic-gate  * part of Sun Microsystems, Inc. to assist in its use, correction,
357c478bd9Sstevel@tonic-gate  * modification or enhancement.
367c478bd9Sstevel@tonic-gate  *
377c478bd9Sstevel@tonic-gate  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
387c478bd9Sstevel@tonic-gate  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
397c478bd9Sstevel@tonic-gate  * OR ANY PART THEREOF.
407c478bd9Sstevel@tonic-gate  *
417c478bd9Sstevel@tonic-gate  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
427c478bd9Sstevel@tonic-gate  * or profits or other special, indirect and consequential damages, even if
437c478bd9Sstevel@tonic-gate  * Sun has been advised of the possibility of such damages.
447c478bd9Sstevel@tonic-gate  *
457c478bd9Sstevel@tonic-gate  * Sun Microsystems, Inc.
467c478bd9Sstevel@tonic-gate  * 2550 Garcia Avenue
477c478bd9Sstevel@tonic-gate  * Mountain View, California  94043
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #if !defined(lint) && defined(SCCSIDS)
507c478bd9Sstevel@tonic-gate static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
557c478bd9Sstevel@tonic-gate  *
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #include "admin.h"
597c478bd9Sstevel@tonic-gate #include <rpc/types.h>
607c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
617c478bd9Sstevel@tonic-gate #include <dyn/dyn.h>
627c478bd9Sstevel@tonic-gate 
63*159d09a2SMark Phalan /* Solaris Kerberos - 116 resync */
647c478bd9Sstevel@tonic-gate static bool_t	xdralloc_putlong();
657c478bd9Sstevel@tonic-gate static bool_t	xdralloc_putbytes();
667c478bd9Sstevel@tonic-gate static unsigned int	xdralloc_getpos();
677c478bd9Sstevel@tonic-gate static rpc_inline_t *	xdralloc_inline();
687c478bd9Sstevel@tonic-gate static void	xdralloc_destroy();
69*159d09a2SMark Phalan static bool_t	xdralloc_notsup_getlong();
70*159d09a2SMark Phalan static bool_t	xdralloc_notsup_getbytes();
71*159d09a2SMark Phalan static bool_t	xdralloc_notsup_setpos();
727c478bd9Sstevel@tonic-gate static struct	xdr_ops xdralloc_ops = {
73*159d09a2SMark Phalan      xdralloc_notsup_getlong,
747c478bd9Sstevel@tonic-gate      xdralloc_putlong,
75*159d09a2SMark Phalan      xdralloc_notsup_getbytes,
767c478bd9Sstevel@tonic-gate      xdralloc_putbytes,
777c478bd9Sstevel@tonic-gate      xdralloc_getpos,
78*159d09a2SMark Phalan      xdralloc_notsup_setpos,
797c478bd9Sstevel@tonic-gate      xdralloc_inline,
807c478bd9Sstevel@tonic-gate      xdralloc_destroy,
817c478bd9Sstevel@tonic-gate };
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * The procedure xdralloc_create initializes a stream descriptor for a
857c478bd9Sstevel@tonic-gate  * memory buffer.
867c478bd9Sstevel@tonic-gate  */
xdralloc_create(XDR * xdrs,enum xdr_op op)87*159d09a2SMark Phalan void xdralloc_create(XDR *xdrs, enum xdr_op op)
887c478bd9Sstevel@tonic-gate {
897c478bd9Sstevel@tonic-gate      xdrs->x_op = op;
907c478bd9Sstevel@tonic-gate      xdrs->x_ops = &xdralloc_ops;
917c478bd9Sstevel@tonic-gate      xdrs->x_private = (caddr_t) DynCreate(sizeof(char), -4);
927c478bd9Sstevel@tonic-gate      /* not allowed to fail */
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate 
xdralloc_getdata(XDR * xdrs)95*159d09a2SMark Phalan caddr_t xdralloc_getdata(XDR *xdrs)
967c478bd9Sstevel@tonic-gate {
977c478bd9Sstevel@tonic-gate      return (caddr_t) DynGet((DynObject) xdrs->x_private, 0);
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate 
xdralloc_release(XDR * xdrs)100*159d09a2SMark Phalan void xdralloc_release(XDR *xdrs)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate      DynRelease((DynObject) xdrs->x_private);
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate 
xdralloc_destroy(XDR * xdrs)105*159d09a2SMark Phalan static void xdralloc_destroy(XDR *xdrs)
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate      DynDestroy((DynObject) xdrs->x_private);
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate 
xdralloc_notsup_getlong(register XDR * xdrs,long * lp)110*159d09a2SMark Phalan static bool_t xdralloc_notsup_getlong(
111*159d09a2SMark Phalan      register XDR *xdrs,
112*159d09a2SMark Phalan      long *lp)
1137c478bd9Sstevel@tonic-gate {
1147c478bd9Sstevel@tonic-gate      return FALSE;
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate 
xdralloc_putlong(register XDR * xdrs,long * lp)117*159d09a2SMark Phalan static bool_t xdralloc_putlong(
118*159d09a2SMark Phalan      register XDR *xdrs,
119*159d09a2SMark Phalan      long *lp)
1207c478bd9Sstevel@tonic-gate {
121*159d09a2SMark Phalan      int l = htonl((uint32_t) *lp); /* XXX need bounds checking */
1227c478bd9Sstevel@tonic-gate 
123*159d09a2SMark Phalan      /* XXX assumes sizeof(int)==4 */
1247c478bd9Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
1257c478bd9Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private), &l,
1267c478bd9Sstevel@tonic-gate 		   sizeof(int)) != DYN_OK)
1277c478bd9Sstevel@tonic-gate 	  return FALSE;
1287c478bd9Sstevel@tonic-gate      return (TRUE);
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate 
131*159d09a2SMark Phalan 
xdralloc_notsup_getbytes(register XDR * xdrs,caddr_t addr,register unsigned int len)132*159d09a2SMark Phalan static bool_t xdralloc_notsup_getbytes(
133*159d09a2SMark Phalan      register XDR *xdrs,
134*159d09a2SMark Phalan      caddr_t addr,
135*159d09a2SMark Phalan      register unsigned int len)
136*159d09a2SMark Phalan {
137*159d09a2SMark Phalan      return FALSE;
138*159d09a2SMark Phalan }
139*159d09a2SMark Phalan 
140*159d09a2SMark Phalan 
xdralloc_putbytes(register XDR * xdrs,caddr_t addr,register unsigned int len)141*159d09a2SMark Phalan static bool_t xdralloc_putbytes(
142*159d09a2SMark Phalan      register XDR *xdrs,
143*159d09a2SMark Phalan      caddr_t addr,
144*159d09a2SMark Phalan      register unsigned int len)
1457c478bd9Sstevel@tonic-gate {
1467c478bd9Sstevel@tonic-gate      if (DynInsert((DynObject) xdrs->x_private,
1477c478bd9Sstevel@tonic-gate 		   DynSize((DynObject) xdrs->x_private),
148*159d09a2SMark Phalan 		   addr, (int) len) != DYN_OK)
1497c478bd9Sstevel@tonic-gate 	  return FALSE;
1507c478bd9Sstevel@tonic-gate      return TRUE;
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate 
xdralloc_getpos(XDR * xdrs)153*159d09a2SMark Phalan static unsigned int xdralloc_getpos(XDR *xdrs)
1547c478bd9Sstevel@tonic-gate {
1557c478bd9Sstevel@tonic-gate      return DynSize((DynObject) xdrs->x_private);
1567c478bd9Sstevel@tonic-gate }
1577c478bd9Sstevel@tonic-gate 
xdralloc_notsup_setpos(register XDR * xdrs,unsigned int lp)158*159d09a2SMark Phalan static bool_t xdralloc_notsup_setpos(
159*159d09a2SMark Phalan      register XDR *xdrs,
160*159d09a2SMark Phalan      unsigned int lp)
161*159d09a2SMark Phalan {
162*159d09a2SMark Phalan      return FALSE;
163*159d09a2SMark Phalan }
1647c478bd9Sstevel@tonic-gate 
165*159d09a2SMark Phalan 
166*159d09a2SMark Phalan 
xdralloc_inline(register XDR * xdrs,int len)167*159d09a2SMark Phalan static rpc_inline_t *xdralloc_inline(
168*159d09a2SMark Phalan      register XDR *xdrs,
169*159d09a2SMark Phalan      int len)
1707c478bd9Sstevel@tonic-gate {
1717c478bd9Sstevel@tonic-gate      return (rpc_inline_t *) 0;
1727c478bd9Sstevel@tonic-gate }
173