2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
12 #include "afs/param.h"
14 #include <afs/param.h>
20 #include "afs/sysincludes.h"
21 #include "afsincludes.h"
23 #else /* defined(UKERNEL) */
24 #if defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
25 #include "afs/sysincludes.h"
26 #include "afsincludes.h"
29 #include "rpc/types.h"
32 #if !defined(AFS_ALPHA_ENV)
34 #define XDR_GETINT32 XDR_GETLONG
37 #define XDR_PUTINT32 XDR_PUTLONG
40 #endif /* defined(UKERNEL) */
48 #define NVALLOC(a) osi_Alloc(a)
49 #define NVFREE(a,b) osi_Free(a,b)
51 #define MAXBS 2048 /* try to avoid horrible allocs */
52 static afs_int32 bslosers = 0;
53 #define NVALLOC(a) malloc(a)
54 #define NVFREE(a,b) free(a)
57 /* these things are defined in R (but not RX's) library. For now, we add them
58 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
60 #ifndef AFS_USR_DARWIN_ENV
65 * Wrapper for xdr_string that can be called directly from
66 * routines like clnt_call; from user-mode xdr package.
69 #ifndef AFS_HPUX110_ENV
71 xdr_wrapstring(XDR * xdrs, char **cpp)
73 if (xdr_string(xdrs, cpp, 1024)) {
78 #endif /* AFS_HPUX110_ENV */
79 #endif /* AFS_SUN5_ENV */
84 * XDR a fixed length array. Unlike variable-length arrays,
85 * the storage of fixed length arrays is static and unfreeable.
86 * > basep: base of the array
87 * > size: size of the array
88 * > elemsize: size of each element
89 * > xdr_elem: routine to XDR each element
92 xdr_vector(register XDR * xdrs, register char *basep, register u_int nelem,
93 register u_int elemsize, register xdrproc_t xdr_elem)
99 for (i = 0; i < nelem; i++) {
100 if (!(*xdr_elem) (xdrs, elptr, (u_int) (~0))) {
112 xdr_CBS(XDR * x, struct CBS * abbs)
115 if (x->x_op == XDR_FREE) {
116 NVFREE(abbs->SeqBody, abbs->SeqLen);
120 if (x->x_op == XDR_ENCODE) {
121 xdr_afs_int32(x, &abbs->SeqLen);
122 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
125 xdr_afs_int32(x, &len);
126 if (len < 0 || len > MAXBS) {
131 abbs->SeqBody = (char *)NVALLOC(len);
133 xdr_opaque(x, abbs->SeqBody, len);
139 xdr_BBS(XDR * x, struct BBS * abbs)
141 afs_int32 maxLen, len;
142 if (x->x_op == XDR_FREE) {
143 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
147 if (x->x_op == XDR_ENCODE) {
148 xdr_afs_int32(x, &abbs->MaxSeqLen);
149 xdr_afs_int32(x, &abbs->SeqLen);
150 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
153 xdr_afs_int32(x, &maxLen);
154 xdr_afs_int32(x, &len);
155 if (len < 0 || len > MAXBS || len > maxLen) {
160 abbs->SeqBody = (char *)NVALLOC(maxLen);
161 abbs->MaxSeqLen = maxLen;
163 xdr_opaque(x, abbs->SeqBody, len);
169 xdr_AFSAccessList(XDR * x, AFSAccessList * abbs)
171 afs_int32 maxLen, len;
172 if (x->x_op == XDR_FREE) {
173 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
177 if (x->x_op == XDR_ENCODE) {
178 xdr_afs_int32(x, &abbs->MaxSeqLen);
179 xdr_afs_int32(x, &abbs->SeqLen);
180 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
183 xdr_afs_int32(x, &maxLen);
184 xdr_afs_int32(x, &len);
185 if (len < 0 || len > MAXBS || len > maxLen) {
190 abbs->SeqBody = (char *)NVALLOC(maxLen);
191 abbs->MaxSeqLen = maxLen;
193 xdr_opaque(x, abbs->SeqBody, len);