ptclient: rxgk support
[openafs.git] / src / ptserver / ptclient.c
index cacf8c7..ef613f0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -9,43 +9,34 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
+#include <roken.h>
+#include <afs/opr.h>
 
-#ifdef AFS_AIX32_ENV
-#include <signal.h>
-#endif
-#include <sys/types.h>
 #ifdef AFS_NT40_ENV
-#include <winsock2.h>
 #include <WINNT/afsevent.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
 #endif
-#include <stdio.h>
+
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <string.h>
-#include <afs/stds.h>
 #include <afs/com_err.h>
 #include <afs/cellconfig.h>
+#include <afs/afsutil.h>
+
 #include "ptclient.h"
 #include "ptuser.h"
 #include "pterror.h"
 #include "display.h"
-#include <afs/afsutil.h>
-
 
 afs_int32 security = 0;
 char confdir[AFSDIR_PATH_MAX];
 
 char *whoami;
 
-#ifndef AFS_PTHREAD_ENV
 extern struct ubik_client *pruclient;
 static void skip(char **);
 static void PrintHelp(void);
-#endif
 
 static int ignoreExist = 0;
 static char line[256];
@@ -53,9 +44,8 @@ static char *lineProgress;
 
 #define WHITESPACE " \t\n"
 
-#ifndef AFS_PTHREAD_ENV
 int
-osi_audit()
+osi_audit(void)
 {
 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
  * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
@@ -63,7 +53,6 @@ osi_audit()
  */
     return 0;
 }
-#endif /* !AFS_PTHREAD_ENV */
 
 int
 GetToken(char *format, afs_int32 *l)
@@ -133,7 +122,9 @@ PrintEntry(afs_int32 ea, struct prentry *e, int indent)
 {
     /* handle screwed up versions of DumpEntry */
     if (e->flags & PRCONT) {
-       afs_int32 id = *(afs_int32 *) (e->name);
+       afs_int32 id;
+
+       memcpy(&id, e->name, sizeof(id));
        if ((id != PRBADID) && ((id > (1 << 24)) || (id < -(1 << 24)))) {
            /* assume server incorrectly swapped these bytes... */
            int i = 0;
@@ -152,7 +143,6 @@ PrintEntry(afs_int32 ea, struct prentry *e, int indent)
     return pr_PrintEntry(stdout, /*host order */ 1, ea, e, indent);
 }
 
-#ifndef AFS_PTHREAD_ENV
 
 /* main program */
 
@@ -161,7 +151,7 @@ PrintEntry(afs_int32 ea, struct prentry *e, int indent)
 int
 main(int argc, char **argv)
 {
-    register afs_int32 code;
+    afs_int32 code;
     char op[8];
     char name[PR_MAXNAMELEN];
     afs_int32 id, oid = ANONYMOUSID, gid;
@@ -178,11 +168,12 @@ main(int argc, char **argv)
     char *foo;
     afs_int32 over;
     char *cell;
+    afs_int32 rxgk_level = 0;
 
 #ifdef AFS_AIX32_ENV
     /*
-     * The following signal action for AIX is necessary so that in case of a 
-     * crash (i.e. core is generated) we can include the user's data section 
+     * The following signal action for AIX is necessary so that in case of a
+     * crash (i.e. core is generated) we can include the user's data section
      * in the core dump. Unfortunately, by default, only a partial core is
      * generated which, in many cases, isn't too useful.
      */
@@ -211,15 +202,17 @@ main(int argc, char **argv)
            strncpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(confdir));
        else if (IsArg("server"))
            strncpy(confdir, AFSDIR_SERVER_ETC_DIRPATH, sizeof(confdir));
-       else if (IsArg("0") || IsArg("1") || IsArg("2"))
+       else if (IsArg("0") || IsArg("1") || IsArg("2") || IsArg("3"))
            security = atoi(argv[n]);
+       else if (IsArg("-rxgk"))
+           rxgk_level = atoi(argv[++n]);
        else if (IsArg("-ignoreexist"))
            ignoreExist++;
        else if (IsArg("-cell"))
            cell = argv[++n];
        else {
            printf
-               ("Usage is: 'prclient [-testconfdir <dir> | server | client] [0 | 1 | 2] [-ignoreExist] [-cell <cellname>]\n");
+               ("Usage is: 'prclient [-testconfdir <dir> | server | client] [0 | 1 | 2 | 3] [-rxgk 0 | 1 | 2] [-ignoreExist] [-cell <cellname>]\n");
            exit(1);
        }
        n++;
@@ -229,7 +222,7 @@ main(int argc, char **argv)
     if (security == 0)
        printf("Making unauthenticated connection to prserver\n");
 
-    code = pr_Initialize(security, confdir, cell);
+    code = pr_Initialize2(security, confdir, cell, rxgk_level);
     if (code) {
        afs_com_err(whoami, code, "Couldn't initialize protection library");
        exit(1);
@@ -248,7 +241,7 @@ main(int argc, char **argv)
        if (code) {
            afs_com_err(whoami, PRBADARG,
                    "error reading opcode in line '%s', got '%.*s'", line,
-                   sizeof(op), op);
+                   (int) sizeof(op), op);
            exit(1);
        }
        if (strlen(op) == 0)
@@ -330,7 +323,7 @@ main(int argc, char **argv)
            if (CodeOk(code))
                afs_com_err(whoami, code, "on %s %d %d", op, id, gid);
        } else if (!strcmp(op, "iton")) {
-           lid.idlist_val = (afs_int32 *) malloc(20 * sizeof(afs_int32));
+           lid.idlist_val = malloc(20 * sizeof(afs_int32));
            ptr = lid.idlist_val;
            lid.idlist_len = 0;
            foo = line;
@@ -359,13 +352,12 @@ main(int argc, char **argv)
            lid.idlist_val = 0;
            lid.idlist_len = 0;
        } else if (!strcmp(op, "ntoi")) {
-           lnames.namelist_val =
-               (prname *) malloc(PR_MAXLIST * PR_MAXNAMELEN);
+           lnames.namelist_val = malloc(PR_MAXLIST * PR_MAXNAMELEN);
            lnames.namelist_len = 0;
            foo = line;
            skip(&foo);
            for (i = 0; ((lnames.namelist_len < PR_MAXLIST)
-                        && (sscanf(foo, "%s", lnames.namelist_val[i]) !=
+                        && (sscanf(foo, "%63s", lnames.namelist_val[i]) !=
                             EOF)); i++) {
                lnames.namelist_len++;
                skip(&foo);
@@ -704,6 +696,7 @@ main(int argc, char **argv)
        else
            printf("Unknown op: '%s'! ? for help\n", op);
     }
+    return 0;
 }
 
 
@@ -745,4 +738,3 @@ skip(char **s)
     while (**s == ' ')
        (*s)++;
 }
-#endif /* !AFS_PTHREAD_ENV */