Use xdr_alloc and xdr_free within ptuser
[openafs.git] / src / fsint / afsaux.c
index 562efdf..b5f85bd 100644 (file)
@@ -9,26 +9,25 @@
 
 #include <afsconfig.h>
 #ifdef KERNEL
-#include "../afs/param.h"
+#include "afs/param.h"
 #else
 #include <afs/param.h>
 #endif
 
-RCSID("$Header$");
 
 #ifdef KERNEL
 #if defined(UKERNEL)
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
-#include "../rx/xdr.h"
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
+#include "rx/xdr.h"
 #else /* defined(UKERNEL) */
-#if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
+#if defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
 #else
-#include "../h/types.h"
-#include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "h/types.h"
+#include "rpc/types.h"
+#include "rx/xdr.h"
 #endif
 #if !defined(AFS_ALPHA_ENV)
 #ifndef        XDR_GETINT32
@@ -38,23 +37,19 @@ RCSID("$Header$");
 #define        XDR_PUTINT32    XDR_PUTLONG
 #endif
 #endif
-#ifndef AFS_LINUX22_ENV
-#include "../rpc/auth.h"
-#endif
 #endif /* defined(UKERNEL) */
-#include "../afsint/afsint.h"
+#include "afsint.h"
 #else /* KERNEL */
 # include <rx/xdr.h>
 # include "afsint.h"
 #endif /* KERNEL */
 
-#define MAXBS  2048            /* try to avoid horrible allocs */
-static afs_int32 bslosers = 0;
-
 #ifdef KERNEL
 #define        NVALLOC(a)      osi_Alloc(a)
 #define        NVFREE(a,b)     osi_Free(a,b)
 #else /* KERNEL */
+#define MAXBS  2048            /* try to avoid horrible allocs */
+static afs_int32 bslosers = 0;
 #define        NVALLOC(a)      malloc(a)
 #define        NVFREE(a,b)     free(a)
 #endif /* KERNEL */
@@ -66,42 +61,6 @@ static afs_int32 bslosers = 0;
 #ifdef AFS_AIXNFS11
 #define        AUTH_DES 1
 #endif
-#if (defined(AFS_AIX_ENV) && !defined(AUTH_DES)) || (!defined(AFS_SUN_ENV)) && !defined(AFS_SGI_ENV) && !defined(AFS_ALPHA_ENV) && !defined(AFS_SUN5_ENV)
-#ifndef        AFS_AIX32_ENV
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
-/*
- * XDR chars; from user mode xdr package.
- */
-bool_t
-xdr_char(xdrs, sp)
-       register XDR *xdrs;
-       char *sp;
-{
-       afs_int32 l;
-
-       switch (xdrs->x_op) {
-
-       case XDR_ENCODE:
-               l = (afs_int32) *sp;
-               return (XDR_PUTINT32(xdrs, &l));
-
-       case XDR_DECODE:
-               if (!XDR_GETINT32(xdrs, &l)) {
-                       return (FALSE);
-               }
-               *sp = (char) l;
-               return (TRUE);
-
-       case XDR_FREE:
-               return (TRUE);
-       }
-       return (FALSE);
-}
-#endif /* AFS_HPUX110_ENV && AFS_LINUX20_ENV */
-#endif 
-#endif /* defined(AFS_AIX_ENV) && !defined(AUTH_DES) */
-
-
 /* 
  * Wrapper for xdr_string that can be called directly from 
  * routines like clnt_call; from user-mode xdr package.
@@ -109,14 +68,12 @@ xdr_char(xdrs, sp)
 #ifndef        AFS_SUN5_ENV
 #ifndef AFS_HPUX110_ENV
 bool_t
-xdr_wrapstring(xdrs, cpp)
-       XDR *xdrs;
-       char **cpp;
+xdr_wrapstring(XDR * xdrs, char **cpp)
 {
-       if (xdr_string(xdrs, cpp, 1024)) {
-               return(TRUE);
-       }
-       return(FALSE);
+    if (xdr_string(xdrs, cpp, 1024)) {
+       return (TRUE);
+    }
+    return (FALSE);
 }
 #endif /* AFS_HPUX110_ENV */
 #endif /* AFS_SUN5_ENV */
@@ -132,35 +89,31 @@ xdr_wrapstring(xdrs, cpp)
  * > xdr_elem: routine to XDR each element
  */
 bool_t
-xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
-       register XDR *xdrs;
-       register char *basep;
-       register u_int nelem;
-       register u_int elemsize;
-       register xdrproc_t xdr_elem;    
+xdr_vector(register XDR * xdrs, register char *basep, register u_int nelem,
+          register u_int elemsize, register xdrproc_t xdr_elem)
 {
-       register u_int i;
-       register char *elptr;
+    register u_int i;
+    register char *elptr;
 
-       elptr = basep;
-       for (i = 0; i < nelem; i++) {
-               if (! (*xdr_elem)(xdrs, elptr, (u_int) (~0))) {
-                       return(FALSE);
-               }
-               elptr += elemsize;
+    elptr = basep;
+    for (i = 0; i < nelem; i++) {
+       if (!(*xdr_elem) (xdrs, elptr, (u_int) (~0))) {
+           return (FALSE);
        }
-       return(TRUE);   
+       elptr += elemsize;
+    }
+    return (TRUE);
 }
 #endif
 #endif /* KERNEL */
 
 #ifndef KERNEL
-xdr_CBS(x, abbs)
-    XDR *x;
-    struct CBS *abbs; {
+bool_t
+xdr_CBS(XDR * x, struct CBS * abbs)
+{
     afs_int32 len;
     if (x->x_op == XDR_FREE) {
-       NVFREE(abbs->SeqBody,abbs->SeqLen);
+       NVFREE(abbs->SeqBody, abbs->SeqLen);
        return TRUE;
     }
 
@@ -168,20 +121,23 @@ xdr_CBS(x, abbs)
        xdr_afs_int32(x, &abbs->SeqLen);
        xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
        return TRUE;
-    }
-    else {
+    } else {
        xdr_afs_int32(x, &len);
-       if (len < 0 || len > MAXBS) {bslosers++; return FALSE;}
-       if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(len);
+       if (len < 0 || len > MAXBS) {
+           bslosers++;
+           return FALSE;
+       }
+       if (!abbs->SeqBody)
+           abbs->SeqBody = (char *)NVALLOC(len);
        abbs->SeqLen = len;
        xdr_opaque(x, abbs->SeqBody, len);
        return TRUE;
     }
 }
 
-xdr_BBS(x, abbs)
-    XDR *x;
-    struct BBS *abbs; {
+bool_t
+xdr_BBS(XDR * x, struct BBS * abbs)
+{
     afs_int32 maxLen, len;
     if (x->x_op == XDR_FREE) {
        NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
@@ -193,12 +149,15 @@ xdr_BBS(x, abbs)
        xdr_afs_int32(x, &abbs->SeqLen);
        xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
        return TRUE;
-    }
-    else {
+    } else {
        xdr_afs_int32(x, &maxLen);
        xdr_afs_int32(x, &len);
-       if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
-       if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
+       if (len < 0 || len > MAXBS || len > maxLen) {
+           bslosers++;
+           return FALSE;
+       }
+       if (!abbs->SeqBody)
+           abbs->SeqBody = (char *)NVALLOC(maxLen);
        abbs->MaxSeqLen = maxLen;
        abbs->SeqLen = len;
        xdr_opaque(x, abbs->SeqBody, len);
@@ -206,9 +165,9 @@ xdr_BBS(x, abbs)
     }
 }
 
-xdr_AFSAccessList(x, abbs)
-    XDR *x;
-    struct BBS *abbs; {
+bool_t
+xdr_AFSAccessList(XDR * x, AFSAccessList * abbs)
+{
     afs_int32 maxLen, len;
     if (x->x_op == XDR_FREE) {
        NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
@@ -220,12 +179,15 @@ xdr_AFSAccessList(x, abbs)
        xdr_afs_int32(x, &abbs->SeqLen);
        xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
        return TRUE;
-    }
-    else {
+    } else {
        xdr_afs_int32(x, &maxLen);
        xdr_afs_int32(x, &len);
-       if (len < 0 || len > MAXBS || len > maxLen) {bslosers++; return FALSE;}
-       if (!abbs->SeqBody) abbs->SeqBody = (char *) NVALLOC(maxLen);
+       if (len < 0 || len > MAXBS || len > maxLen) {
+           bslosers++;
+           return FALSE;
+       }
+       if (!abbs->SeqBody)
+           abbs->SeqBody = (char *)NVALLOC(maxLen);
        abbs->MaxSeqLen = maxLen;
        abbs->SeqLen = len;
        xdr_opaque(x, abbs->SeqBody, len);