DEVEL15-pts-20070811
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 12 Aug 2007 00:41:37 +0000 (00:41 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 12 Aug 2007 00:41:37 +0000 (00:41 +0000)
remove SUPERGROUPS condition for compilation of pts commands:
  Interactive, Quit, Source, Sleep

fix the assignment of 'source' to permit it to function

rename functions to avoid conflicts with Win32 API on Windows

replace bcopy and bzero with memcpy and memset to permit compilation
on Windows

replace ubik_Call(xxx) with ubik_xxx() (testpt.c)

add -DSUPERGROUPS and map.c to NTMakefile

(cherry picked from commit 58d5f38b10b35ab3712eacde60f2a06fb2f2a062)

src/ptserver/NTMakefile
src/ptserver/db_verify.c
src/ptserver/map.c
src/ptserver/ptclient.c
src/ptserver/pts.c
src/ptserver/ptutils.c
src/ptserver/testpt.c

index a39461f..9274687 100644 (file)
@@ -10,7 +10,7 @@
 RELDIR=ptserver
 !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
 !include ..\config\NTMakefile.version
-AFSDEV_AUXCDEFINES = -DAFS_USE_GETTIMEOFDAY
+AFSDEV_AUXCDEFINES = -DAFS_USE_GETTIMEOFDAY -DSUPERGROUPS
 
 ############################################################################
 # Definitions for installing header files
@@ -52,6 +52,7 @@ PTSERVER_EXEOBJS =\
        $(OUT)\ptutils.obj \
        $(OUT)\ptprocs.obj \
        $(OUT)\utils.obj \
+        $(OUT)\map.obj \
        $(OUT)\ptserver.res
 
 
index 144623f..62c5f2c 100644 (file)
@@ -1516,7 +1516,7 @@ void
 zeromap(struct idused *idmap)
 {
     while (idmap) {
-       bzero((char *)idmap->idcount, sizeof idmap->idcount);
+       memset((char *)idmap->idcount, 0, sizeof idmap->idcount);
        idmap = idmap->idnext;
     }
 }
@@ -1541,7 +1541,7 @@ inccount(struct idused **idmapp, int id)
            perror("idmap");
            exit(1);
        }
-       bzero((char *)idmap, sizeof idmap);
+       memset((char *)idmap, 0, sizeof idmap);
        idmap->idstart = id & ~(IDCOUNT - 1);
        idmap->idnext = *idmapp;
        *idmapp = idmap;
index 85d23ff..a043f40 100644 (file)
@@ -37,7 +37,7 @@ RCSID
 #ifdef SUPERGROUPS
 #include <errno.h>
 #include "map.h"
-char *malloc();
+#include "malloc.h"
 
 #undef PRINT_MAP_ERROR
 /* #define MAP_DEBUG /**/
index 0918e40..ba24d62 100644 (file)
@@ -648,7 +648,7 @@ main(argc, argv)
        else if (!strcmp(op, "fih")) {
            char tname[128];
            struct PrUpdateEntry uentry;
-           bzero(&uentry, sizeof(uentry));
+           memset(&uentry, 0, sizeof(uentry));
            /* scanf("%s",name); */
            if (GetString(name, sizeof(name))) {
                code = PRBADARG;
@@ -675,7 +675,7 @@ main(argc, argv)
        } else if (!strcmp(op, "fnh")) {
            int tid;
            struct PrUpdateEntry uentry;
-           bzero(&uentry, sizeof(uentry));
+           memset(&uentry, 0, sizeof(uentry));
            /* scanf("%d", &id); */
            if (GetInt32(&id)) {
                code = PRBADARG;
index 5ffd9a4..2cbddf0 100644 (file)
@@ -7,18 +7,6 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-/*
- *                      (3) add new pts commands:
- *
- *                          Interactive - allow the pts command
- *                                        to be run interactively.
- *                          Quit        - quit interactive mode.
- *                          Source      - allow input to come from a file(s).
- *                          Sleep       - pause for a specified number
- *                                        of seconds.
- *
- */
-
 #include <afsconfig.h>
 #include <afs/param.h>
 
@@ -53,17 +41,6 @@ RCSID
 char *whoami;
 int force = 0;
 
-#if defined(SUPERGROUPS)
-
-/*
- *  Add new pts commands:
- *
- *      Interactive - allow the pts command to be run interactively.
- *      Quit        - quit interactive mode.
- *      Source      - allow input to come from a file(s).
- *      Sleep       - pause for a specified number of seconds.
- */
-
 static int finished;
 static FILE *source;
 extern struct ubik_client *pruclient;
@@ -74,21 +51,21 @@ struct sourcestack {
 } *shead;
 
 int
-Interactive(struct cmd_syndesc *as, char *arock)
+pts_Interactive(struct cmd_syndesc *as, char *arock)
 {
     finished = 0;
     return 0;
 }
 
 int
-Quit(struct cmd_syndesc *as, char *arock)
+pts_Quit(struct cmd_syndesc *as, char *arock)
 {
     finished = 1;
     return 0;
 }
 
 int
-Source(struct cmd_syndesc *as, char *arock)
+pts_Source(struct cmd_syndesc *as, char *arock)
 {
     FILE *fd;
     struct sourcestack *sp;
@@ -116,7 +93,7 @@ Source(struct cmd_syndesc *as, char *arock)
 }
 
 int
-Sleep(struct cmd_syndesc *as, char *arock)
+pts_Sleep(struct cmd_syndesc *as, char *arock)
 {
     int delay;
     if (!as->parms[0].items) {
@@ -125,6 +102,7 @@ Sleep(struct cmd_syndesc *as, char *arock)
     }
     delay = atoi(as->parms[0].items->data);
     IOMGR_Sleep(delay);
+    return 0;
 }
 
 int
@@ -141,8 +119,6 @@ popsource()
     return 1;
 }
 
-#endif /* SUPERGROUPS */
-
 int
 osi_audit()
 {
@@ -188,7 +164,6 @@ GetGlobals(struct cmd_syndesc *as, char *arock)
 int
 CleanUp(struct cmd_syndesc *as, char *arock)
 {
-#if defined(SUPERGROUPS)
     if (as && !strcmp(as->name, "help"))
        return 0;
     if (pruclient) {
@@ -196,14 +171,6 @@ CleanUp(struct cmd_syndesc *as, char *arock)
        pr_End();
        rx_Finalize();
     }
-#else
-    if (!strcmp(as->name, "help"))
-       return 0;
-    /* Need to shutdown the ubik_client & other connections */
-    pr_End();
-    rx_Finalize();
-#endif /* SUPERGROUPS */
-
     return 0;
 }
 
@@ -237,12 +204,12 @@ CreateGroup(struct cmd_syndesc *as, char *arock)
                        id);
                return code;
            }
-#if defined(SUPERGROUPS)
-           if (id == 0) {
+           
+            if (id == 0) {
                printf("0 isn't a valid user id; aborting\n");
                return EINVAL;
            }
-#endif
+
            idi = idi->next;
        } else
            id = 0;
@@ -1023,13 +990,13 @@ main(int argc, char **argv)
 {
     register afs_int32 code;
     register struct cmd_syndesc *ts;
-#if defined(SUPERGROUPS)
+
     char line[2048];
     char *cp, *lastp;
     int parsec;
     char *parsev[CMD_MAXPARMS];
     char *savec;
-#endif
+
 #ifdef WIN32
     WSADATA WSAjunk;
 #endif
@@ -1138,35 +1105,30 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-groups", CMD_FLAG, CMD_OPTIONAL, "list group entries");
     add_std_args(ts);
 
-#if defined(SUPERGROUPS)
-
-    ts = cmd_CreateSyntax("interactive", Interactive, 0,
+    ts = cmd_CreateSyntax("interactive", pts_Interactive, 0,
                          "enter interactive mode");
     add_std_args(ts);
     cmd_CreateAlias(ts, "in");
 
-    ts = cmd_CreateSyntax("quit", Quit, 0, "exit program");
+    ts = cmd_CreateSyntax("quit", pts_Quit, 0, "exit program");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("source", Source, 0, "read commands from file");
+    ts = cmd_CreateSyntax("source", pts_Source, 0, "read commands from file");
     cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "filename");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("sleep", Sleep, 0, "pause for a bit");
+    ts = cmd_CreateSyntax("sleep", pts_Sleep, 0, "pause for a bit");
     cmd_AddParm(ts, "-delay", CMD_SINGLE, 0, "seconds");
     add_std_args(ts);
 
-#endif /* SUPERGROUPS */
-
     cmd_SetBeforeProc(GetGlobals, 0);
 
-#if defined(SUPERGROUPS)
     finished = 1;
+    source = stdin;
     if (code = cmd_Dispatch(argc, argv)) {
        CleanUp(NULL, NULL);
        exit(1);
     }
-    source = stdin;
     while (!finished) {
        if (isatty(fileno(source)))
            fprintf(stderr, "pts> ");
@@ -1200,11 +1162,4 @@ main(int argc, char **argv)
     }
     CleanUp(NULL, NULL);
     exit(0);
-
-#else /* SUPERGROUPS */
-
-    cmd_SetAfterProc(CleanUp, 0);
-    code = cmd_Dispatch(argc, argv);
-    exit(code != 0);
-#endif /* SUPERGROUPS */
 }
index 53704a0..f7ad70d 100644 (file)
@@ -848,7 +848,7 @@ RemoveFromSGEntry(register struct ubik_trans *at, register afs_int32 aid, regist
        }                       /* for all coentry slots */
        hloc = nptr;
        nptr = centry.next;
-       bcopy((char *)&centry, (char *)&hentry, sizeof(centry));
+       memcpy((char *)&centry, (char *)&hentry, sizeof(centry));
     }                          /* while there are coentries */
     return PRNOENT;
 }
index 0655b84..064cf54 100644 (file)
@@ -308,14 +308,14 @@ CreateGroup(int g)
     }
 
     sprintf(name, "%s:%s%d", ownerName, createPrefix, g);
-    code = ubik_Call(PR_NewEntry, pruclient, 0, name, PRGRP, owner, &id);
+    code = ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner, &id);
     if (code) {
        if (code == PREXIST) {
            code = pr_Delete(name);
            if (code == 0) {
                nGDels++;
                code =
-                   ubik_Call(PR_NewEntry, pruclient, 0, name, PRGRP, owner,
+                   ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner,
                              &id);
                if (code == 0) {
                    if (verbose)
@@ -351,7 +351,7 @@ DeleteRandomId(afs_int32 *list)
     for (j = 0; j < number; j++) {     /* find an undeleted id */
        m = (k + j) % number;
        if (id = list[m]) {
-           code = ubik_Call(PR_Delete, pruclient, 0, id);
+           code = ubik_PR_Delete(pruclient, 0, id);
            if (code) {
                afs_com_err(whoami, code, "Couldn't delete %di", id);
                exit(22);
@@ -379,7 +379,7 @@ AddUser(int u, int g)
        CreateGroup(g);
     ui = users[u];
     gi = groups[g];
-    code = ubik_Call(PR_AddToGroup, pruclient, 0, ui, gi);
+    code = ubik_PR_AddToGroup(pruclient, 0, ui, gi);
     if (code) {
        afs_com_err(whoami, code, "couldn't add %d to %d", ui, gi);
        exit(14);
@@ -398,7 +398,7 @@ RemUser(int u, int g)
 
     ui = users[u];
     gi = groups[g];
-    code = ubik_Call(PR_RemoveFromGroup, pruclient, 0, ui, gi);
+    code = ubik_PR_RemoveFromGroup(pruclient, 0, ui, gi);
     if (code) {
        afs_com_err(whoami, code, "couldn't remove %d from %d", ui, gi);
        exit(14);
@@ -656,7 +656,7 @@ TestManyMembers(struct cmd_syndesc *as, char *arock)
                }
 #define GETOWNED(xlist,xid) \
   (xlist).prlist_val = 0; (xlist).prlist_len = 0; \
-  code = ubik_Call (PR_ListOwned, pruclient, 0, (xid), &(xlist), &over); \
+  code = ubik_PR_ListOwned(pruclient, 0, (xid), &(xlist), &over); \
   if (code) { \
       afs_com_err (whoami, code, "getting owner list of (%di)", (xid)); \
       exit (23); } \