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_NBSD50_ENV)
21 #include "afs/afs_osi.h"
23 #if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
24 #include "afs/sysincludes.h"
25 #include "afsincludes.h"
30 #if !defined(AFS_ALPHA_ENV)
32 #define XDR_GETINT32 XDR_GETLONG
35 #define XDR_PUTINT32 XDR_PUTLONG
38 #endif /* defined(UKERNEL) */
47 #define NVALLOC(a) osi_Alloc(a)
48 #define NVFREE(a,b) osi_Free(a,b)
50 #define MAXBS 2048 /* try to avoid horrible allocs */
51 static afs_int32 bslosers = 0;
52 #define NVALLOC(a) malloc(a)
53 #define NVFREE(a,b) free(a)
56 /* these things are defined in R (but not RX's) library. For now, we add them
57 only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
59 #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 */
82 xdr_CBS(XDR * x, struct CBS * abbs)
85 if (x->x_op == XDR_FREE) {
86 NVFREE(abbs->SeqBody, abbs->SeqLen);
90 if (x->x_op == XDR_ENCODE) {
91 xdr_afs_int32(x, &abbs->SeqLen);
92 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
95 xdr_afs_int32(x, &len);
96 if (len < 0 || len > MAXBS) {
101 abbs->SeqBody = NVALLOC(len);
103 xdr_opaque(x, abbs->SeqBody, len);
109 xdr_BBS(XDR * x, struct BBS * abbs)
111 afs_int32 maxLen, len;
112 if (x->x_op == XDR_FREE) {
113 NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
117 if (x->x_op == XDR_ENCODE) {
118 xdr_afs_int32(x, &abbs->MaxSeqLen);
119 xdr_afs_int32(x, &abbs->SeqLen);
120 xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
123 xdr_afs_int32(x, &maxLen);
124 xdr_afs_int32(x, &len);
125 if (len < 0 || len > MAXBS || len > maxLen) {
130 abbs->SeqBody = NVALLOC(maxLen);
131 abbs->MaxSeqLen = maxLen;
133 xdr_opaque(x, abbs->SeqBody, len);
139 xdr_AFSAccessList(XDR * x, AFSAccessList * 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 = NVALLOC(maxLen);
161 abbs->MaxSeqLen = maxLen;
163 xdr_opaque(x, abbs->SeqBody, len);