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>
11 #include <afs/param.h>
16 #include "afs/sysincludes.h"
17 #include "afsincludes.h"
19 #else /* defined(UKERNEL) */
20 #if defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
21 #include "afs/sysincludes.h"
22 #include "afsincludes.h"
25 #include "rpc/types.h"
28 #if !defined(AFS_ALPHA_ENV)
30 #define XDR_GETINT32 XDR_GETLONG
33 #define XDR_PUTINT32 XDR_PUTLONG
36 #endif /* defined(UKERNEL) */
44 #define NVALLOC(a) osi_Alloc(a)
45 #define NVFREE(a,b) osi_Free(a,b)
47 #define MAXBS 2048 /* try to avoid horrible allocs */
48 static afs_int32 bslosers = 0;
49 #define NVALLOC(a) malloc(a)
50 #define NVFREE(a,b) free(a)
53 /* these things are defined in R (but not RX's) library. For now, we add them
54 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
56 #ifndef AFS_USR_DARWIN_ENV
61 * Wrapper for xdr_string that can be called directly from
62 * routines like clnt_call; from user-mode xdr package.
65 #ifndef AFS_HPUX110_ENV
67 xdr_wrapstring(XDR * xdrs, char **cpp)
69 if (xdr_string(xdrs, cpp, 1024)) {
74 #endif /* AFS_HPUX110_ENV */
75 #endif /* AFS_SUN5_ENV */
80 * XDR a fixed length array. Unlike variable-length arrays,
81 * the storage of fixed length arrays is static and unfreeable.
82 * > basep: base of the array
83 * > size: size of the array
84 * > elemsize: size of each element
85 * > xdr_elem: routine to XDR each element
88 xdr_vector(register XDR * xdrs, register char *basep, register u_int nelem,
89 register u_int elemsize, register xdrproc_t xdr_elem)
95 for (i = 0; i < nelem; i++) {
96 if (!(*xdr_elem) (xdrs, elptr, (u_int) (~0))) {
108 xdr_CBS(XDR * x, struct CBS * abbs)
111 if (x->x_op == XDR_FREE) {
112 NVFREE(abbs->SeqBody, abbs->SeqLen);
116 if (x->x_op == XDR_ENCODE) {
117 xdr_afs_int32(x, &abbs->SeqLen);
118 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
121 xdr_afs_int32(x, &len);
122 if (len < 0 || len > MAXBS) {
127 abbs->SeqBody = (char *)NVALLOC(len);
129 xdr_opaque(x, abbs->SeqBody, len);
135 xdr_BBS(XDR * x, struct BBS * abbs)
137 afs_int32 maxLen, len;
138 if (x->x_op == XDR_FREE) {
139 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
143 if (x->x_op == XDR_ENCODE) {
144 xdr_afs_int32(x, &abbs->MaxSeqLen);
145 xdr_afs_int32(x, &abbs->SeqLen);
146 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
149 xdr_afs_int32(x, &maxLen);
150 xdr_afs_int32(x, &len);
151 if (len < 0 || len > MAXBS || len > maxLen) {
156 abbs->SeqBody = (char *)NVALLOC(maxLen);
157 abbs->MaxSeqLen = maxLen;
159 xdr_opaque(x, abbs->SeqBody, len);
165 xdr_AFSAccessList(XDR * x, AFSAccessList * abbs)
167 afs_int32 maxLen, len;
168 if (x->x_op == XDR_FREE) {
169 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
173 if (x->x_op == XDR_ENCODE) {
174 xdr_afs_int32(x, &abbs->MaxSeqLen);
175 xdr_afs_int32(x, &abbs->SeqLen);
176 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
179 xdr_afs_int32(x, &maxLen);
180 xdr_afs_int32(x, &len);
181 if (len < 0 || len > MAXBS || len > maxLen) {
186 abbs->SeqBody = (char *)NVALLOC(maxLen);
187 abbs->MaxSeqLen = maxLen;
189 xdr_opaque(x, abbs->SeqBody, len);