From 58d5f38b10b35ab3712eacde60f2a06fb2f2a062 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 12 Aug 2007 00:39:33 +0000 Subject: [PATCH] pts-20070811 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 --- src/ptserver/NTMakefile | 3 +- src/ptserver/db_verify.c | 4 +-- src/ptserver/map.c | 2 +- src/ptserver/ptclient.c | 4 +-- src/ptserver/pts.c | 75 ++++++++-------------------------------- src/ptserver/ptutils.c | 2 +- src/ptserver/testpt.c | 12 +++---- 7 files changed, 29 insertions(+), 73 deletions(-) diff --git a/src/ptserver/NTMakefile b/src/ptserver/NTMakefile index a39461f12..92746876b 100644 --- a/src/ptserver/NTMakefile +++ b/src/ptserver/NTMakefile @@ -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 diff --git a/src/ptserver/db_verify.c b/src/ptserver/db_verify.c index 144623f5e..62c5f2c42 100644 --- a/src/ptserver/db_verify.c +++ b/src/ptserver/db_verify.c @@ -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; diff --git a/src/ptserver/map.c b/src/ptserver/map.c index 85d23ff9a..a043f40b5 100644 --- a/src/ptserver/map.c +++ b/src/ptserver/map.c @@ -37,7 +37,7 @@ RCSID #ifdef SUPERGROUPS #include #include "map.h" -char *malloc(); +#include "malloc.h" #undef PRINT_MAP_ERROR /* #define MAP_DEBUG /**/ diff --git a/src/ptserver/ptclient.c b/src/ptserver/ptclient.c index 0918e40f6..ba24d6264 100644 --- a/src/ptserver/ptclient.c +++ b/src/ptserver/ptclient.c @@ -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; diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c index 5ffd9a4c7..2cbddf051 100644 --- a/src/ptserver/pts.c +++ b/src/ptserver/pts.c @@ -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 #include @@ -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 */ } diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c index 53704a027..f7ad70d43 100644 --- a/src/ptserver/ptutils.c +++ b/src/ptserver/ptutils.c @@ -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 *)¢ry, (char *)&hentry, sizeof(centry)); + memcpy((char *)¢ry, (char *)&hentry, sizeof(centry)); } /* while there are coentries */ return PRNOENT; } diff --git a/src/ptserver/testpt.c b/src/ptserver/testpt.c index 0655b847d..064cf54f5 100644 --- a/src/ptserver/testpt.c +++ b/src/ptserver/testpt.c @@ -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); } \ -- 2.39.5