Don't pass NULL to strcmp
[openafs.git] / src / bucoord / commands.c
index 4ff455c..a091ba1 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/stds.h>
 #if defined(AFS_LINUX24_ENV)
 #define _REGEX_RE_COMP
 #endif
 #include <sys/types.h>
-#if defined(AFS_LINUX24_ENV)
-#include <regex.h>
-#endif
 #include <afs/cmd.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
@@ -31,49 +26,56 @@ RCSID
 #endif
 #include <errno.h>
 #include <afs/com_err.h>
+#include <afs/afsutil.h>
 #include <afs/budb.h>
+#include <afs/budb_prototypes.h>
 #include <afs/butc.h>
 #include <afs/bubasics.h>      /* PA */
 #include <afs/volser.h>
 #include <afs/voldefs.h>       /* PA */
 #include <afs/vldbint.h>       /* PA */
 #include <afs/ktime.h>         /* PA */
+#include <ubik.h>
 #include <time.h>
-
 #include <lock.h>
 #include <afs/butc.h>
 #include <afs/tcdata.h>
 #include <afs/butx.h>
+#include <afs/vsutils_prototypes.h>
+#ifdef HAVE_POSIX_REGEX                /* use POSIX regexp library */
+#include <regex.h>
+#endif
 #include "bc.h"
 #include "error_macros.h"
-
+#include "bucoord_internal.h"
+#include "bucoord_prototypes.h"
 
 extern struct bc_config *bc_globalConfig;
-extern struct bc_dumpSchedule *bc_FindDumpSchedule();
-extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cfg,
-                                            char *name);
 extern struct bc_dumpTask bc_dumpTasks[BC_MAXSIMDUMPS];
 extern struct ubik_client *cstruct;
-extern int bc_Dumper();                /* function to do dumps */
-extern int bc_Restorer();      /* function to do restores */
 extern char *whoami;
-extern struct ktc_token ttoken;
-extern char *tailCompPtr();
-extern statusP createStatusNode();
 
 char *loadFile;
 extern afs_int32 lastTaskCode;
 
 #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
 
+static int EvalVolumeSet1(struct bc_config *aconfig, struct bc_volumeSet *avs,
+                         struct bc_volumeDump **avols,
+                         struct ubik_client *uclient);
+
+static int EvalVolumeSet2(struct bc_config *aconfig, struct bc_volumeSet *avs,
+                         struct bc_volumeDump **avols,
+                         struct ubik_client *uclient);
+static int DBLookupByVolume(char *volumeName);
+
 int
-bc_EvalVolumeSet(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     register struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+bc_EvalVolumeSet(struct bc_config *aconfig, 
+                struct bc_volumeSet *avs, 
+                struct bc_volumeDump **avols, 
+                struct ubik_client *uclient)
 {                              /*bc_EvalVolumeSet */
-    int code;
+    int code = -1;
     static afs_int32 use = 2;
 
     if (use == 2) {            /* Use EvalVolumeSet2() */
@@ -102,11 +104,10 @@ struct serversort {
 };
 
 afs_int32
-getSPEntries(server, partition, serverlist, ss, ps)
-     afs_uint32 server;
-     afs_int32 partition;
-     struct serversort **serverlist, **ss;
-     struct partitionsort **ps;
+getSPEntries(afs_uint32 server, afs_int32 partition, 
+            struct serversort **serverlist, 
+            struct serversort **ss, 
+            struct partitionsort **ps)
 {
     if (!(*ss) || ((*ss)->ipaddr != server)) {
        *ps = 0;
@@ -119,7 +120,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ss)) {
        *ss = (struct serversort *)malloc(sizeof(struct serversort));
        if (!(*ss)) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            *ss = 0;
            return (BC_NOMEM);
        }
@@ -140,7 +141,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ps)) {
        *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort));
        if (!(*ps)) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            free(*ss);
            *ps = 0;
            *ss = 0;
@@ -155,9 +156,8 @@ getSPEntries(server, partition, serverlist, ss, ps)
 }
 
 afs_int32
-randSPEntries(serverlist, avols)
-     struct serversort *serverlist;
-     struct bc_volumeDump **avols;
+randSPEntries(struct serversort *serverlist, 
+             struct bc_volumeDump **avols)
 {
     struct serversort *ss, **pss;
     struct partitionsort *ps, **pps;
@@ -197,12 +197,11 @@ randSPEntries(serverlist, avols)
     return 0;
 }
 
-int
-EvalVolumeSet2(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+static int
+EvalVolumeSet2(struct bc_config *aconfig, 
+              struct bc_volumeSet *avs, 
+              struct bc_volumeDump **avols, 
+              struct ubik_client *uclient)
 {                              /*EvalVolumeSet2 */
     struct bc_volumeEntry *tve;
     struct bc_volumeDump *tavols;
@@ -214,7 +213,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
     struct bc_volumeDump *tvd;
     afs_int32 code = 0, tcode;
     afs_int32 count = 0;
-    struct serversort *servers = 0, *lastserver = 0, *ss = 0;
+    struct serversort *servers = 0, *ss = 0;
     struct partitionsort *ps = 0;
 
     *avols = (struct bc_volumeDump *)0;
@@ -287,7 +286,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                                 entries[e].serverPartition[ei], &servers,
                                 &ss, &ps);
                if (tcode) {
-                   afs_com_err(whoami, tcode, "");
+                   afs_com_err(whoami, tcode, NULL);
                    ERROR(tcode);
                }
 
@@ -319,14 +318,14 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                    tvd = (struct bc_volumeDump *)
                        malloc(sizeof(struct bc_volumeDump));
                    if (!tvd) {
-                       afs_com_err(whoami, BC_NOMEM, "");
+                       afs_com_err(whoami, BC_NOMEM, NULL);
                        ERROR(BC_NOMEM);
                    }
                    memset(tvd, 0, sizeof(*tvd));
 
                    tvd->name = (char *)malloc(strlen(entries[e].name) + 10);
                    if (!(tvd->name)) {
-                       afs_com_err(whoami, BC_NOMEM, "");
+                       afs_com_err(whoami, BC_NOMEM, NULL);
                        free(tvd);
                        ERROR(BC_NOMEM);
                    }
@@ -419,28 +418,33 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
  *     None.
  *-----------------------------------------------------------------------------
  */
-int
-EvalVolumeSet1(aconfig, avs, avols, uclient)
-     struct bc_config *aconfig;
-     struct bc_volumeSet *avs;
-     struct bc_volumeDump **avols;
-     struct ubik_client *uclient;
+static int
+EvalVolumeSet1(struct bc_config *aconfig, 
+              struct bc_volumeSet *avs,
+              struct bc_volumeDump **avols, 
+              struct ubik_client *uclient)
 {                              /*EvalVolumeSet1 */
     afs_int32 code;            /*Result of various calls */
-    char *errm;
     struct bc_volumeDump *tvd; /*Ptr to new dump instance */
     struct bc_volumeEntry *tve, *ctve; /*Ptr to new volume entry instance */
     char patt[256];            /*Composite regex; also, target string */
-    int volType;               /*Type of volume that worked */
+    int volType = 0;           /*Type of volume that worked */
     afs_int32 index;           /*Current VLDB entry index */
     afs_int32 count;           /*Needed by VL_ListEntry() */
     afs_int32 next_index;      /*Next index to list */
     struct vldbentry entry;    /*VLDB entry */
     int srvpartpair;           /*Loop counter: server/partition pair */
     afs_int32 total = 0;
-    int found, foundentry;
+    int found;
+    int foundentry = 0;
     struct serversort *servers = 0, *ss = 0;
     struct partitionsort *ps = 0;
+#ifdef HAVE_POSIX_REGEX
+    regex_t re;
+    int need_regfree = 0;
+#else
+    char *errm;
+#endif
 
     *avols = (struct bc_volumeDump *)0;
     ctve = (struct bc_volumeEntry *)0; /* no compiled entry */
@@ -487,6 +491,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                /* If the volume entry is not compiled, then compile it */
                if (ctve != tve) {
                    sprintf(patt, "^%s$", tve->name);
+#ifdef HAVE_POSIX_REGEX
+                   if (regcomp(&re, patt, REG_NOSUB) != 0) {
+                     afs_com_err(whoami, 0, "Can't compile regular expression '%s'", patt);
+                     return (-1);
+                   }
+                   need_regfree = 1;
+#else
                    errm = (char *)re_comp(patt);
                    if (errm) {
                        afs_com_err(whoami, 0,
@@ -494,6 +505,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                                patt, errm);
                        return (-1);
                    }
+#endif
                    ctve = tve;
                }
 
@@ -503,8 +515,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                if (entry.serverFlags[srvpartpair] & ITSRWVOL) {
                    if (entry.flags & RW_EXISTS) {
                        sprintf(patt, "%s", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                       code = regexec(&re, patt, 0, NULL, 0);
+                       if (code == 0) {
+#else
                        code = re_exec(patt);
                        if (code == 1) {
+#endif
                            found = 1;
                            foundentry = srvpartpair;
                            volType = RWVOL;
@@ -517,8 +534,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                     */
                    if (entry.flags & BACK_EXISTS) {
                        sprintf(patt, "%s.backup", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                       code = regexec(&re, patt, 0, NULL, 0);
+                       if (code == 0) {
+#else
                        code = re_exec(patt);
                        if (code == 1) {
+#endif
                            found = 1;
                            foundentry = srvpartpair;
                            volType = BACKVOL;
@@ -534,8 +556,13 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                else if (!found && (entry.serverFlags[srvpartpair] & ITSROVOL)
                         && (entry.flags & RO_EXISTS)) {
                    sprintf(patt, "%s.readonly", entry.name);
+#ifdef HAVE_POSIX_REGEX
+                   code = regexec(&re, patt, 0, NULL, 0);
+                   if (code == 0) {
+#else
                    code = re_exec(patt);
                    if (code == 1) {
+#endif
                        found = 1;
                        foundentry = srvpartpair;
                        volType = ROVOL;
@@ -554,7 +581,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                                 entry.serverPartition[foundentry], &servers,
                                 &ss, &ps);
                if (code) {
-                   afs_com_err(whoami, code, "");
+                   afs_com_err(whoami, code, NULL);
                    return (code);
                }
 
@@ -562,14 +589,14 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                tvd = (struct bc_volumeDump *)
                    malloc(sizeof(struct bc_volumeDump));
                if (!tvd) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    return (BC_NOMEM);
                }
                memset(tvd, 0, sizeof(*tvd));
 
                tvd->name = (char *)malloc(strlen(entry.name) + 10);
                if (!(tvd->name)) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    free(tvd);
                    return (BC_NOMEM);
                }
@@ -597,6 +624,10 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
            }                   /*f */
        }                       /*ve */
     }                          /*w */
+#ifdef HAVE_POSIX_REGEX
+    if (need_regfree)
+       regfree(&re);
+#endif
 
     /* Randomly link the volumedump entries together */
     randSPEntries(servers, avols);
@@ -605,38 +636,41 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
     return (0);
 }                              /*EvalVolumeSet1 */
 
-/* compactDateString
- *     print out a date in compact format, 16 chars, format is
- *     mm/dd/yyyy hh:mm
- * entry:
- *     date_long - ptr to a long containing the time
- * exit:
- *     ptr to a string containing a representation of the date
- */
 char *
-compactDateString(date_long, string, size)
-     afs_int32 *date_long, size;
-     char *string;
+compactTimeString(time_t *date, char *string, afs_int32 size)
 {
     struct tm *ltime;
 
     if (!string)
-       return 0;
+       return NULL;
 
-    if (*date_long == NEVERDATE) {
+    if (*date == NEVERDATE) {
        sprintf(string, "NEVER");
     } else {
-        time_t t = *date_long;
-       ltime = localtime(&t);
-       /* prints date in U.S. format of mm/dd/yyyy */
+       ltime = localtime(date);
        strftime(string, size, "%m/%d/%Y %H:%M", ltime);
     }
     return (string);
 }
 
+/* compactDateString
+ *     print out a date in compact format, 16 chars, format is
+ *     mm/dd/yyyy hh:mm
+ * entry:
+ *     date_long - ptr to a long containing the time
+ * exit:
+ *     ptr to a string containing a representation of the date
+ */
+char *
+compactDateString(afs_uint32 *date_long, char *string, afs_int32 size)
+{
+    time_t t = *date_long;
+    return compactTimeString(&t, string, size);
+}
+
+
 afs_int32
-bc_SafeATOI(anum)
-     char *anum;
+bc_SafeATOI(char *anum)
 {
     afs_int32 total = 0;
 
@@ -654,8 +688,7 @@ bc_SafeATOI(anum)
  *    Return the size in KBytes.
  */
 afs_int32
-bc_FloatATOI(anum)
-     char *anum;
+bc_FloatATOI(char *anum)
 {
     float total = 0;
     afs_int32 rtotal;
@@ -701,8 +734,7 @@ bc_FloatATOI(anum)
 
 /* make a copy of a string so that it can be freed later */
 char *
-bc_CopyString(astring)
-     char *astring;
+bc_CopyString(char *astring)
 {
     afs_int32 tlen;
     char *tp;
@@ -712,7 +744,7 @@ bc_CopyString(astring)
     tlen = strlen(astring);
     tp = (char *)malloc(tlen + 1);     /* don't forget the terminating null */
     if (!tp) {
-       afs_com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (tp);
     }
     strcpy(tp, astring);
@@ -726,8 +758,7 @@ bc_CopyString(astring)
  */
 
 char *
-concatParams(itemPtr)
-     struct cmd_item *itemPtr;
+concatParams(struct cmd_item *itemPtr)
 {
     struct cmd_item *tempPtr;
     afs_int32 length = 0;
@@ -746,7 +777,7 @@ concatParams(itemPtr)
 
     string = (char *)malloc(length);   /* allocate the string */
     if (!string) {
-       afs_com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (NULL);
     }
     string[0] = 0;
@@ -765,13 +796,13 @@ concatParams(itemPtr)
 /* printIfStatus
  *     print out an interface status node as received from butc
  */
-
-printIfStatus(statusPtr)
-     struct tciStatusS *statusPtr;
+void
+printIfStatus(struct tciStatusS *statusPtr)
 {
     printf("Task %d: %s: ", statusPtr->taskId, statusPtr->taskName);
     if (statusPtr->nKBytes)
-       printf("%ld Kbytes transferred", statusPtr->nKBytes);
+       printf("%ld Kbytes transferred", (long unsigned int) statusPtr->nKBytes);
     if (strlen(statusPtr->volumeName) != 0) {
        if (statusPtr->nKBytes)
            printf(", ");
@@ -801,8 +832,7 @@ printIfStatus(statusPtr)
 }
 
 afs_int32
-getPortOffset(port)
-     char *port;
+getPortOffset(char *port)
 {
     afs_int32 portOffset;
 
@@ -822,10 +852,8 @@ getPortOffset(port)
 /* bc_GetTapeStatusCmd
  *     display status of all tasks on a particular tape coordinator
  */
-
-bc_GetTapeStatusCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_GetTapeStatusCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct rx_connection *tconn;
@@ -888,11 +916,10 @@ extern struct Lock dispatchLock;
 /* bc_WaitForNoJobs
  *     wait for all jobs to terminate
  */
-bc_WaitForNoJobs()
+int
+bc_WaitForNoJobs(void)
 {
-    afs_int32 wcode = 0;
     int i;
-    int waitmsg = 1;
     int usefulJobRunning = 1;
 
     extern dlqlinkT statusHead;
@@ -920,10 +947,8 @@ bc_WaitForNoJobs()
  * parameters
  *     ignored - a null "as" prints only jobs.
  */
-
-bc_JobsCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_JobsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 prevTime;
     dlqlinkP ptr;
@@ -953,7 +978,7 @@ bc_JobsCmd(as, arock)
            if (statusPtr->dbDumpId)
                printf(": DumpID %u", statusPtr->dbDumpId);
            if (statusPtr->nKBytes)
-               printf(", %ld Kbytes", statusPtr->nKBytes);
+               printf(", %ld Kbytes", afs_printable_int32_ld(statusPtr->nKBytes));
            if (strlen(statusPtr->volumeName) != 0)
                printf(", volume %s", statusPtr->volumeName);
 
@@ -998,11 +1023,11 @@ bc_JobsCmd(as, arock)
        }
 
        /* Print token expiration time */
-       if ((ttoken.endTime > prevTime)
-           && (ttoken.endTime <= youngest->scheduledDump) && as
-           && (ttoken.endTime != NEVERDATE)) {
-           if (ttoken.endTime > time(0)) {
-               compactDateString(&ttoken.endTime, ds, 50);
+       if ((tokenExpires > prevTime)
+           && (tokenExpires <= youngest->scheduledDump) && as
+           && (tokenExpires != NEVERDATE)) {
+           if (tokenExpires > time(0)) {
+               compactTimeString(&tokenExpires, ds, 50);
                printf("       %16s: TOKEN EXPIRATION\n", ds);
            } else {
                printf("       TOKEN HAS EXPIRED\n");
@@ -1022,11 +1047,11 @@ bc_JobsCmd(as, arock)
     }
 
     /* Print token expiration time if havn't already */
-    if ((ttoken.endTime == NEVERDATE) && as)
+    if ((tokenExpires == NEVERDATE) && as)
        printf("     : TOKEN NEVER EXPIRES\n");
-    else if ((ttoken.endTime > prevTime) && as) {
-       if (ttoken.endTime > time(0)) {
-           compactDateString(&ttoken.endTime, ds, 50);
+    else if ((tokenExpires > prevTime) && as) {
+       if (tokenExpires > time(0)) {
+           compactTimeString(&tokenExpires, ds, 50);
            printf("       %16s: TOKEN EXPIRATION\n", ds);
        } else {
            printf("     : TOKEN HAS EXPIRED\n");
@@ -1037,9 +1062,8 @@ bc_JobsCmd(as, arock)
     return 0;
 }
 
-bc_KillCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_KillCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 i;
     afs_int32 slot;
@@ -1051,8 +1075,6 @@ bc_KillCmd(as, arock)
     statusP statusPtr;
 
     extern dlqlinkT statusHead;
-    extern statusP findStatus();
-
 
     tp = as->parms[0].items->data;
     if (strchr(tp, '.') == 0) {
@@ -1111,9 +1133,8 @@ bc_KillCmd(as, arock)
 }
 
 /* restore a volume or volumes */
-bc_VolRestoreCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_VolRestoreCmd(struct cmd_syndesc *as, void *arock)
 {
     /*
      * parm 0 is the new server to restore to
@@ -1174,14 +1195,14 @@ bc_VolRestoreCmd(as, arock)
        /* build list of volume items */
        tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
        if (!tvol) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        memset(tvol, 0, sizeof(struct bc_volumeDump));
 
        tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
        if (!tvol->name) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strncpy(tvol->name, ti->data, VOLSER_OLDMAXVOLNAME);
@@ -1221,7 +1242,7 @@ bc_VolRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1266,9 +1287,8 @@ bc_VolRestoreCmd(as, arock)
  *     various optional
  */
 
-bc_DiskRestoreCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_DiskRestoreCmd(struct cmd_syndesc *as, void *arock)
 {
     struct bc_volumeSet tvolumeSet;    /* temporary volume set for EvalVolumeSet call */
     struct bc_volumeEntry tvolumeEntry;        /* entry within the volume set */
@@ -1352,7 +1372,7 @@ bc_DiskRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1423,9 +1443,8 @@ bc_DiskRestoreCmd(as, arock)
  *     restore a volumeset or list of volumes.
  */
 
-bc_VolsetRestoreCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_VolsetRestoreCmd(struct cmd_syndesc *as, void *arock)
 {
     int oldFlag;
     long fromDate;
@@ -1435,7 +1454,6 @@ bc_VolsetRestoreCmd(as, arock)
     afs_int32 *ports = NULL;
     afs_int32 portCount = 0;
     afs_int32 code = 0;
-    afs_int32 portoffset = 0;
     char *volsetName;
     struct bc_volumeSet *volsetPtr;    /* Ptr to list of generated volume info */
     struct bc_volumeDump *volsToRestore = (struct bc_volumeDump *)0;
@@ -1525,7 +1543,7 @@ bc_VolsetRestoreCmd(as, arock)
 
            tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
            if (!tvol->name) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
            strncpy(tvol->name, volume, VOLSER_OLDMAXVOLNAME);
@@ -1551,7 +1569,7 @@ bc_VolsetRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1606,14 +1624,13 @@ bc_VolsetRestoreCmd(as, arock)
 int dontExecute;
 
 int
-bc_DumpCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+bc_DumpCmd(struct cmd_syndesc *as, void *arock)
 {                              /*bc_DumpCmd */
-    static char rn[] = "bc_DumpCmd";   /*Routine name */
-    char *dumpPath, *vsName;   /*Ptrs to various names */
-    struct bc_volumeSet *tvs;  /*Ptr to list of generated volume info */
-    struct bc_dumpSchedule *tds, *baseds;      /*Ptr to dump schedule node */
+    char *dumpPath = NULL;
+    char *vsName = NULL;      /*Ptrs to various names */
+    struct bc_volumeSet *tvs = NULL; /*Ptr to list of generated volume info */
+    struct bc_dumpSchedule *tds;
+    struct bc_dumpSchedule *baseds = NULL; /*Ptr to dump schedule node */
     struct bc_volumeDump *tve, *volsToDump;    /*Ptr to individual vols to be dumped */
     struct budb_dumpEntry dumpEntry, de, fde;  /* dump entry */
     afs_uint32 d;
@@ -1627,15 +1644,13 @@ bc_DumpCmd(as, arock)
     afs_int32 doAt, atTime;    /* Time a timed-dump is to start at */
     afs_int32 length;
     char *timeString;
-    int doAppend;              /* Append the dump to dump set */
+    int doAppend = 0;          /* Append the dump to dump set */
     afs_int32 code;            /* Return code */
     int loadfile;              /* whether to load a file or not */
 
     statusP statusPtr;
 
     extern struct bc_dumpTask bc_dumpTasks[];
-    extern afs_int32 bcdb_FindLastVolClone();
-    extern afs_int32 volImageTime();
 
     code = bc_UpdateDumpSchedule();
     if (code) {
@@ -1711,7 +1726,7 @@ bc_DumpCmd(as, arock)
            portCount = 1;
            portp = (afs_int32 *) malloc(sizeof(afs_int32));
            if (!portp) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1792,7 +1807,7 @@ bc_DumpCmd(as, arock)
            statusPtr->scheduledDump = atTime;
            statusPtr->cmdLine = (char *)malloc(length);
            if (!statusPtr->cmdLine) {
-               afs_com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1825,7 +1840,7 @@ bc_DumpCmd(as, arock)
                strcat(statusPtr->cmdLine, " -n");
 
            printf("Add scheduled dump as job %d\n", statusPtr->jobNumber);
-           if ((atTime > ttoken.endTime) && (ttoken.endTime != NEVERDATE))
+           if ((atTime > tokenExpires) && (tokenExpires != NEVERDATE))
                afs_com_err(whoami, 0,
                        "Warning: job %d starts after expiration of AFS token",
                        statusPtr->jobNumber);
@@ -1844,7 +1859,7 @@ bc_DumpCmd(as, arock)
     if (loadfile) {
        loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
        if (!loadFile) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strcpy(loadFile, as->parms[6].items->data);
@@ -1986,10 +2001,8 @@ bc_DumpCmd(as, arock)
  * parameters:
  *     ignored
  */
-
-bc_QuitCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_QuitCmd(struct cmd_syndesc *as, void *arock)
 {
     int i;
     struct bc_dumpTask *td;
@@ -2038,10 +2051,8 @@ bc_QuitCmd(as, arock)
  *     Labels a tape i.e. request the tape coordinator to perform this
  *     operation
  */
-
-bc_LabelTapeCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_LabelTapeCmd(struct cmd_syndesc *as, void *arock)
 {
     char *tapename = 0, *pname = 0;
     afs_int32 size;
@@ -2101,10 +2112,8 @@ bc_LabelTapeCmd(as, arock)
  * params:
  *     optional port number
  */
-
-bc_ReadLabelCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_ReadLabelCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     afs_int32 port = 0;
@@ -2131,10 +2140,8 @@ bc_ReadLabelCmd(as, arock)
  *     read content information from dump tapes, and if user desires,
  *     add it to the database
  */
-
-bc_ScanDumpsCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_ScanDumpsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 port = 0;
     afs_int32 dbAddFlag = 0;
@@ -2172,10 +2179,8 @@ bc_ScanDumpsCmd(as, arock)
  */
 
 afs_int32
-bc_ParseExpiration(paramPtr, expType, expDate)
-     struct cmd_parmdesc *paramPtr;
-     afs_int32 *expType;
-     afs_int32 *expDate;
+bc_ParseExpiration(struct cmd_parmdesc *paramPtr, afs_int32 *expType, 
+                  afs_int32 *expDate)
 {
     struct cmd_item *itemPtr;
     struct ktime_date kt;
@@ -2242,10 +2247,8 @@ bc_ParseExpiration(paramPtr, expType, expDate)
  *     Currently a single option, volumename to search for. Reports
  *     all dumps containing the specified volume
  */
-
-bc_dblookupCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_dblookupCmd(struct cmd_syndesc *as, void *arock)
 {
     struct cmd_item *ciptr;
     afs_int32 code;
@@ -2261,10 +2264,8 @@ bc_dblookupCmd(as, arock)
 
 
 /* for ubik version */
-
-bc_dbVerifyCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_dbVerifyCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 status;
     afs_int32 orphans;
@@ -2315,10 +2316,10 @@ bc_dbVerifyCmd(as, arock)
 /* deleteDump:
  * Delete a dump. If port is >= 0, it means try to delete from XBSA server
  */
-deleteDump(dumpid, port, force)
-     afs_uint32 dumpid;                /* The dumpid to delete */
-     afs_int32 port;           /* port==-1 means don't go to butc */
-     afs_int32 force;
+int
+deleteDump(afs_uint32 dumpid,          /* The dumpid to delete */
+          afs_int32 port,              /* port==-1 means don't go to butc */
+          afs_int32 force)
 {
     afs_int32 code = 0, tcode;
     struct budb_dumpEntry dumpEntry;
@@ -2407,7 +2408,7 @@ deleteDump(dumpid, port, force)
        /* Display the dumps that were deleted - includes appended dumps */
        for (i = 0; i < dumps.budb_dumpsList_len; i++)
            printf("     %u%s\n", dumps.budb_dumpsList_val[i],
-                  (i > 0) ? " Appended Dump" : "");
+                  (i > 0) ? " Appended Dump" : NULL);
        if (dumps.budb_dumpsList_val)
            free(dumps.budb_dumpsList_val);
     }
@@ -2420,21 +2421,19 @@ deleteDump(dumpid, port, force)
  * entry:
  *     dump id - single required arg as param 0.
  */
-
-bc_deleteDumpCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_deleteDumpCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_uint32 dumpid;
     afs_int32 code = 0;
     afs_int32 rcode = 0;
     afs_int32 groupId = 0, havegroupid, sflags, noexecute;
     struct cmd_item *ti;
-    afs_uint32 fromTime = 0, toTime = 0, havetime = 0;
+    afs_int32 fromTime = 0, toTime = 0, havetime = 0;
     char *timeString;
     budb_dumpsList dumps, flags;
     int i;
-    afs_int32 port = -1, dbonly = 0, force;
+    afs_int32 port = -1, force;
 
     /* Must specify at least one of -dumpid, -from, or -to */
     if (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items
@@ -2576,9 +2575,8 @@ bc_deleteDumpCmd(as, arock)
     return (rcode);
 }
 
-bc_saveDbCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_saveDbCmd(struct cmd_syndesc *as, void *arock)
 {
     struct rx_connection *tconn;
     afs_int32 portOffset = 0;
@@ -2646,9 +2644,8 @@ bc_saveDbCmd(as, arock)
     return (code);
 }
 
-bc_restoreDbCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_restoreDbCmd(struct cmd_syndesc *as, void *arock)
 {
     struct rx_connection *tconn;
     afs_int32 portOffset = 0;
@@ -2728,8 +2725,8 @@ struct dumpedVol {
  *     volumeName - volume to lookup
  */
 
-DBLookupByVolume(volumeName)
-     char *volumeName;
+static int
+DBLookupByVolume(char *volumeName)
 {
     struct budb_dumpEntry dumpEntry;
     struct budb_volumeEntry volumeEntry[DBL_MAX_VOLUMES];
@@ -2841,7 +2838,7 @@ DBLookupByVolume(volumeName)
     }
 
     if (code)
-       afs_com_err(whoami, code, "");
+       afs_com_err(whoami, code, NULL);
     return (code);
 }
 
@@ -2864,9 +2861,7 @@ struct tapeLink {
  */
 
 afs_int32
-dumpInfo(dumpid, detailFlag)
-     afs_int32 dumpid;
-     afs_int32 detailFlag;
+dumpInfo(afs_int32 dumpid, afs_int32 detailFlag)
 {
     struct budb_dumpEntry dumpEntry;
     struct tapeLink *head = 0;
@@ -2931,7 +2926,7 @@ dumpInfo(dumpid, detailFlag)
     for (tapeNumber = dumpEntry.tapes.b; tapeNumber <= dumpEntry.tapes.maxTapes; tapeNumber++) {       /*f */
        tapeLinkPtr = (struct tapeLink *)malloc(sizeof(struct tapeLink));
        if (!tapeLinkPtr) {
-           afs_com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            ERROR(BC_NOMEM);
        }
 
@@ -2983,7 +2978,7 @@ dumpInfo(dumpid, detailFlag)
                volumeLinkPtr =
                    (struct volumeLink *)malloc(sizeof(struct volumeLink));
                if (!volumeLinkPtr) {
-                   afs_com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    ERROR(BC_NOMEM);
                }
                memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr));
@@ -3072,8 +3067,7 @@ dumpInfo(dumpid, detailFlag)
 }
 
 int
-compareDump(ptr1, ptr2)
-     struct budb_dumpEntry *ptr1, *ptr2;
+compareDump(struct budb_dumpEntry *ptr1, struct budb_dumpEntry *ptr2)
 {
     if (ptr1->created < ptr2->created)
        return (-1);
@@ -3083,8 +3077,7 @@ compareDump(ptr1, ptr2)
 }
 
 afs_int32
-printRecentDumps(ndumps)
-     int ndumps;
+printRecentDumps(int ndumps)
 {
     afs_int32 code = 0;
     afs_int32 nextindex, index = 0;
@@ -3095,7 +3088,6 @@ printRecentDumps(ndumps)
     char ds[50];
 
     extern struct udbHandleS udbHandle;
-    extern compareDump();
 
     do {                       /* while (nextindex != -1) */
        /* initialize the dump list */
@@ -3151,17 +3143,14 @@ printRecentDumps(ndumps)
  *     as - name of tape
  *     arock -
  */
-bc_dumpInfoCmd(as, arock)
-     struct cmd_syndesc *as;
-     char *arock;
+int
+bc_dumpInfoCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 dumpid;
     afs_int32 detailFlag;
     afs_int32 ndumps;
     afs_int32 code = 0;
 
-    afs_int32 dumpInfo();
-
     if (as->parms[0].items) {
        if (as->parms[1].items) {
            afs_com_err(whoami, 0,