Don't pass NULL to strcmp
[openafs.git] / src / bucoord / commands.c
index 78c36bb..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>
@@ -28,54 +23,59 @@ RCSID
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
-#include <strings.h>
 #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 <string.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() */
@@ -104,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;
@@ -121,7 +120,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ss)) {
        *ss = (struct serversort *)malloc(sizeof(struct serversort));
        if (!(*ss)) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            *ss = 0;
            return (BC_NOMEM);
        }
@@ -142,7 +141,7 @@ getSPEntries(server, partition, serverlist, ss, ps)
     if (!(*ps)) {
        *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort));
        if (!(*ps)) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            free(*ss);
            *ps = 0;
            *ss = 0;
@@ -157,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;
@@ -199,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;
@@ -216,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;
@@ -289,7 +286,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                                 entries[e].serverPartition[ei], &servers,
                                 &ss, &ps);
                if (tcode) {
-                   com_err(whoami, tcode, "");
+                   afs_com_err(whoami, tcode, NULL);
                    ERROR(tcode);
                }
 
@@ -321,14 +318,14 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
                    tvd = (struct bc_volumeDump *)
                        malloc(sizeof(struct bc_volumeDump));
                    if (!tvd) {
-                       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)) {
-                       com_err(whoami, BC_NOMEM, "");
+                       afs_com_err(whoami, BC_NOMEM, NULL);
                        free(tvd);
                        ERROR(BC_NOMEM);
                    }
@@ -421,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 */
@@ -489,13 +491,21 @@ 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) {
-                       com_err(whoami, 0,
+                       afs_com_err(whoami, 0,
                                "Can't compile regular expression '%s': %s",
                                patt, errm);
                        return (-1);
                    }
+#endif
                    ctve = tve;
                }
 
@@ -505,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;
@@ -519,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;
@@ -536,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;
@@ -545,7 +570,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                }
 
                if (code < 0)
-                   com_err(whoami, 0, "Internal error in regex package");
+                   afs_com_err(whoami, 0, "Internal error in regex package");
            }                   /*s */
 
            /* If found a match, then create a new volume dump entry */
@@ -556,7 +581,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                                 entry.serverPartition[foundentry], &servers,
                                 &ss, &ps);
                if (code) {
-                   com_err(whoami, code, "");
+                   afs_com_err(whoami, code, NULL);
                    return (code);
                }
 
@@ -564,14 +589,14 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                tvd = (struct bc_volumeDump *)
                    malloc(sizeof(struct bc_volumeDump));
                if (!tvd) {
-                   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)) {
-                   com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    free(tvd);
                    return (BC_NOMEM);
                }
@@ -599,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);
@@ -607,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;
 
@@ -656,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;
@@ -703,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;
@@ -714,7 +744,7 @@ bc_CopyString(astring)
     tlen = strlen(astring);
     tp = (char *)malloc(tlen + 1);     /* don't forget the terminating null */
     if (!tp) {
-       com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (tp);
     }
     strcpy(tp, astring);
@@ -728,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;
@@ -742,13 +771,13 @@ concatParams(itemPtr)
     }
 
     if (length == 0) {         /* no string (0 length) */
-       com_err(whoami, 0, "Can't have zero length date and time string");
+       afs_com_err(whoami, 0, "Can't have zero length date and time string");
        return (NULL);
     }
 
     string = (char *)malloc(length);   /* allocate the string */
     if (!string) {
-       com_err(whoami, BC_NOMEM, "");
+       afs_com_err(whoami, BC_NOMEM, NULL);
        return (NULL);
     }
     string[0] = 0;
@@ -767,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(", ");
@@ -803,18 +832,17 @@ printIfStatus(statusPtr)
 }
 
 afs_int32
-getPortOffset(port)
-     char *port;
+getPortOffset(char *port)
 {
     afs_int32 portOffset;
 
     portOffset = bc_SafeATOI(port);
 
     if (portOffset < 0) {
-       com_err(whoami, 0, "Can't decode port offset '%s'", port);
+       afs_com_err(whoami, 0, "Can't decode port offset '%s'", port);
        return (-1);
     } else if (portOffset > BC_MAXPORTOFFSET) {
-       com_err(whoami, 0, "%u exceeds max port offset %u", portOffset,
+       afs_com_err(whoami, 0, "%u exceeds max port offset %u", portOffset,
                BC_MAXPORTOFFSET);
        return (-1);
     }
@@ -824,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;
@@ -840,7 +866,7 @@ bc_GetTapeStatusCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -863,7 +889,7 @@ bc_GetTapeStatusCmd(as, arock)
        if (code) {
            if (code == TC_NOTASKS)
                break;
-           com_err(whoami, code, "; Can't get status from butc");
+           afs_com_err(whoami, code, "; Can't get status from butc");
            return (-1);
        }
        if ((flags & TSK_STAT_NOTFOUND))
@@ -890,16 +916,15 @@ 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;
 
-    com_err(whoami, 0, "waiting for job termination");
+    afs_com_err(whoami, 0, "waiting for job termination");
 
     while (usefulJobRunning) {
        usefulJobRunning = (dlqEmpty(&statusHead) ? 0 : 1);
@@ -922,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;
@@ -955,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);
 
@@ -1000,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");
@@ -1024,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");
@@ -1039,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;
@@ -1053,14 +1075,12 @@ bc_KillCmd(as, arock)
     statusP statusPtr;
 
     extern dlqlinkT statusHead;
-    extern statusP findStatus();
-
 
     tp = as->parms[0].items->data;
     if (strchr(tp, '.') == 0) {
        slot = bc_SafeATOI(tp);
        if (slot == -1) {
-           com_err(whoami, 0, "Bad syntax for number '%s'", tp);
+           afs_com_err(whoami, 0, "Bad syntax for number '%s'", tp);
            return -1;
        }
 
@@ -1093,7 +1113,7 @@ bc_KillCmd(as, arock)
            }
        }
        if (i >= BC_MAXSIMDUMPS) {
-           com_err(whoami, 0, "Can't find job %s", tp);
+           afs_com_err(whoami, 0, "Can't find job %s", tp);
            return -1;
        }
 
@@ -1101,7 +1121,7 @@ bc_KillCmd(as, arock)
        statusPtr = findStatus(td->dumpID);
 
        if (statusPtr == 0) {
-           com_err(whoami, 0, "Can't locate status - internal error");
+           afs_com_err(whoami, 0, "Can't locate status - internal error");
            unlock_Status();
            return (-1);
        }
@@ -1113,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
@@ -1141,6 +1160,7 @@ bc_VolRestoreCmd(as, arock)
     afs_int32 code;
     int oldFlag;
     afs_int32 fromDate;
+    afs_int32 dumpID = 0;
     char *newExt, *timeString;
     afs_int32 i;
     afs_int32 *ports = NULL;
@@ -1149,7 +1169,7 @@ bc_VolRestoreCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -1157,7 +1177,7 @@ bc_VolRestoreCmd(as, arock)
     if (as->parms[0].items) {
        tp = as->parms[0].items->data;
        if (bc_ParseHost(tp, &destServ)) {
-           com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
+           afs_com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
            return -1;
        }
     }
@@ -1166,7 +1186,7 @@ bc_VolRestoreCmd(as, arock)
     if (as->parms[1].items) {
        tp = as->parms[1].items->data;
        if (bc_GetPartitionID(tp, &destPartition)) {
-           com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
+           afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
            return -1;
        }
     }
@@ -1175,14 +1195,14 @@ bc_VolRestoreCmd(as, arock)
        /* build list of volume items */
        tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
        if (!tvol) {
-           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) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strncpy(tvol->name, ti->data, VOLSER_OLDMAXVOLNAME);
@@ -1203,8 +1223,8 @@ bc_VolRestoreCmd(as, arock)
        code = ktime_DateToLong(timeString, &fromDate);
        free(timeString);
        if (code) {
-           com_err(whoami, 0, "Can't parse restore date and time");
-           com_err(whoami, 0, "%s", ktime_GetDateUsage());
+           afs_com_err(whoami, 0, "Can't parse restore date and time");
+           afs_com_err(whoami, 0, "%s", ktime_GetDateUsage());
            return code;
        }
     } else {
@@ -1222,7 +1242,7 @@ bc_VolRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1235,17 +1255,24 @@ bc_VolRestoreCmd(as, arock)
 
     dontExecute = (as->parms[6].items ? 1 : 0);        /* -n */
 
+    if (as->parms[7].items)
+      {
+       dumpID = atoi(as->parms[7].items->data);
+       if (dumpID <= 0)
+         dumpID = 0;
+      }
+    
     /*
      * Perform the call to start the restore.
      */
     code =
        bc_StartDmpRst(bc_globalConfig, "volume", "restore", volsToRestore,
                       &destServ, destPartition, fromDate, newExt, oldFlag,
-                      /*parentDump */ 0, /*dumpLevel */ 0,
+                      /*parentDump */ dumpID, /*dumpLevel */ 0,
                       bc_Restorer, ports, portCount,
                       /*dumpSched */ NULL, /*append */ 0, dontExecute);
     if (code)
-       com_err(whoami, code, "; Failed to queue restore");
+       afs_com_err(whoami, code, "; Failed to queue restore");
 
     return (code);
 }
@@ -1260,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 */
@@ -1291,12 +1317,12 @@ bc_DiskRestoreCmd(as, arock)
 
     code = bc_UpdateVolumeSet();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve volume sets");
+       afs_com_err(whoami, code, "; Can't retrieve volume sets");
        return (code);
     }
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -1309,13 +1335,13 @@ bc_DiskRestoreCmd(as, arock)
     tvolumeEntry.partname = as->parms[1].items->data;
 
     if (bc_GetPartitionID(tvolumeEntry.partname, &tvolumeEntry.partition)) {
-       com_err(whoami, 0, "Can't parse partition '%s'",
+       afs_com_err(whoami, 0, "Can't parse partition '%s'",
                tvolumeEntry.partname);
        return -1;
     }
 
     if (bc_ParseHost(tvolumeEntry.serverName, &tvolumeEntry.server)) {
-       com_err(whoami, 0, "Can't locate host '%s'", tvolumeEntry.serverName);
+       afs_com_err(whoami, 0, "Can't locate host '%s'", tvolumeEntry.serverName);
        return -1;
     }
 
@@ -1323,7 +1349,7 @@ bc_DiskRestoreCmd(as, arock)
     if (as->parms[8].items) {
        tp = as->parms[8].items->data;
        if (bc_ParseHost(tp, &destServ)) {
-           com_err(whoami, 0, "Can't locate destination host '%s'", tp);
+           afs_com_err(whoami, 0, "Can't locate destination host '%s'", tp);
            return -1;
        }
     } else                     /* use destination host == original host */
@@ -1333,7 +1359,7 @@ bc_DiskRestoreCmd(as, arock)
     if (as->parms[9].items) {
        tp = as->parms[9].items->data;
        if (bc_GetPartitionID(tp, &destPartition)) {
-           com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
+           afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
            return -1;
        }
     } else                     /* use original partition */
@@ -1346,7 +1372,7 @@ bc_DiskRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1367,7 +1393,7 @@ bc_DiskRestoreCmd(as, arock)
        bc_EvalVolumeSet(bc_globalConfig, &tvolumeSet, &volsToRestore,
                         cstruct);
     if (code) {
-       com_err(whoami, code, "; Failed to evaluate volume set");
+       afs_com_err(whoami, code, "; Failed to evaluate volume set");
        return (-1);
     }
 
@@ -1408,7 +1434,7 @@ bc_DiskRestoreCmd(as, arock)
                       bc_Restorer, ports, portCount,
                       /*dumpSched */ NULL, /*append */ 0, dontExecute);
     if (code)
-       com_err(whoami, code, "; Failed to queue restore");
+       afs_com_err(whoami, code, "; Failed to queue restore");
 
     return (code);
 }
@@ -1417,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;
@@ -1429,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;
@@ -1441,25 +1465,25 @@ bc_VolsetRestoreCmd(as, arock)
 
     code = bc_UpdateVolumeSet();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve volume sets");
+       afs_com_err(whoami, code, "; Can't retrieve volume sets");
        return (code);
     }
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
     if (as->parms[0].items) {
        if (as->parms[1].items) {
-           com_err(whoami, 0, "Can't have both -name and -file options");
+           afs_com_err(whoami, 0, "Can't have both -name and -file options");
            return (-1);
        }
 
        volsetName = as->parms[0].items->data;
        volsetPtr = bc_FindVolumeSet(bc_globalConfig, volsetName);
        if (!volsetPtr) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "Can't find volume set '%s' in backup database",
                    volsetName);
            return (-1);
@@ -1470,7 +1494,7 @@ bc_VolsetRestoreCmd(as, arock)
            bc_EvalVolumeSet(bc_globalConfig, volsetPtr, &volsToRestore,
                             cstruct);
        if (code) {
-           com_err(whoami, code, "; Failed to evaluate volume set");
+           afs_com_err(whoami, code, "; Failed to evaluate volume set");
            return (-1);
        }
     } else if (as->parms[1].items) {
@@ -1482,7 +1506,7 @@ bc_VolsetRestoreCmd(as, arock)
 
        fd = fopen(as->parms[1].items->data, "r");
        if (!fd) {
-           com_err(whoami, errno, "; Cannot open file '%s'",
+           afs_com_err(whoami, errno, "; Cannot open file '%s'",
                    as->parms[1].items->data);
            return (-1);
        }
@@ -1501,12 +1525,12 @@ bc_VolsetRestoreCmd(as, arock)
            }
 
            if (bc_ParseHost(server, &destServer)) {
-               com_err(whoami, 0, "Failed to locate host '%s'", server);
+               afs_com_err(whoami, 0, "Failed to locate host '%s'", server);
                continue;
            }
 
            if (bc_GetPartitionID(partition, &destPartition)) {
-               com_err(whoami, 0,
+               afs_com_err(whoami, 0,
                        "Failed to parse destination partition '%s'",
                        partition);
                continue;
@@ -1519,7 +1543,7 @@ bc_VolsetRestoreCmd(as, arock)
 
            tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
            if (!tvol->name) {
-               com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
            strncpy(tvol->name, volume, VOLSER_OLDMAXVOLNAME);
@@ -1534,7 +1558,7 @@ bc_VolsetRestoreCmd(as, arock)
        }
        fclose(fd);
     } else {
-       com_err(whoami, 0, "-name or -file option required");
+       afs_com_err(whoami, 0, "-name or -file option required");
        return (-1);
     }
 
@@ -1545,7 +1569,7 @@ bc_VolsetRestoreCmd(as, arock)
            portCount++;
        ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
        if (!ports) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
 
@@ -1570,7 +1594,7 @@ bc_VolsetRestoreCmd(as, arock)
                          bc_Restorer, ports, portCount,
                          /*dumpSched */ NULL, /*append */ 0, dontExecute);
     if (code)
-       com_err(whoami, code, "; Failed to queue restore");
+       afs_com_err(whoami, code, "; Failed to queue restore");
 
     return code;
 }
@@ -1600,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;
@@ -1621,29 +1644,27 @@ 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) {
-       com_err(whoami, code, "; Can't retrieve dump schedule");
+       afs_com_err(whoami, code, "; Can't retrieve dump schedule");
        return (code);
     }
     code = bc_UpdateVolumeSet();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve volume sets");
+       afs_com_err(whoami, code, "; Can't retrieve volume sets");
        return (code);
     }
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -1656,13 +1677,13 @@ bc_DumpCmd(as, arock)
        loadfile = 1;
        if (as->parms[0].items || as->parms[1].items || as->parms[2].items
            || as->parms[4].items) {
-           com_err(whoami, 0, "Invalid option specified with -file option");
+           afs_com_err(whoami, 0, "Invalid option specified with -file option");
            return -1;
        }
     } else {
        loadfile = 0;
        if (!as->parms[0].items || !as->parms[1].items) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "Must specify volume set name and dump level name");
            return -1;
        }
@@ -1684,8 +1705,8 @@ bc_DumpCmd(as, arock)
        code = ktime_DateToLong(timeString, &atTime);
        free(timeString);
        if (code) {
-           com_err(whoami, 0, "Can't parse dump start date and time");
-           com_err(whoami, 0, "%s", ktime_GetDateUsage());
+           afs_com_err(whoami, 0, "Can't parse dump start date and time");
+           afs_com_err(whoami, 0, "%s", ktime_GetDateUsage());
            return (1);
        }
     } else
@@ -1705,7 +1726,7 @@ bc_DumpCmd(as, arock)
            portCount = 1;
            portp = (afs_int32 *) malloc(sizeof(afs_int32));
            if (!portp) {
-               com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1721,13 +1742,13 @@ bc_DumpCmd(as, arock)
         */
        tvs = bc_FindVolumeSet(bc_globalConfig, vsName);
        if (!tvs) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "Can't find volume set '%s' in backup database", vsName);
            return (-1);
        }
        baseds = bc_FindDumpSchedule(bc_globalConfig, dumpPath);
        if (!baseds) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "Can't find dump schedule '%s' in backup database",
                    dumpPath);
            return (-1);
@@ -1747,7 +1768,7 @@ bc_DumpCmd(as, arock)
      */
     if (doAt) {
        if (atTime < time(0)) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "Time of dump is earlier then current time - not added");
        } else {
            statusPtr = createStatusNode();
@@ -1786,7 +1807,7 @@ bc_DumpCmd(as, arock)
            statusPtr->scheduledDump = atTime;
            statusPtr->cmdLine = (char *)malloc(length);
            if (!statusPtr->cmdLine) {
-               com_err(whoami, BC_NOMEM, "");
+               afs_com_err(whoami, BC_NOMEM, NULL);
                return BC_NOMEM;
            }
 
@@ -1819,8 +1840,8 @@ 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))
-               com_err(whoami, 0,
+           if ((atTime > tokenExpires) && (tokenExpires != NEVERDATE))
+               afs_com_err(whoami, 0,
                        "Warning: job %d starts after expiration of AFS token",
                        statusPtr->jobNumber);
 
@@ -1838,7 +1859,7 @@ bc_DumpCmd(as, arock)
     if (loadfile) {
        loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
        if (!loadFile) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            return BC_NOMEM;
        }
        strcpy(loadFile, as->parms[6].items->data);
@@ -1900,7 +1921,7 @@ bc_DumpCmd(as, arock)
      * dump at the level we requested it be done at.
      */
     if (problemFindingDump) {
-       com_err(whoami, 0,
+       afs_com_err(whoami, 0,
                "Warning: Doing level %d dump due to missing higher-level dumps",
                level);
        if (parent) {
@@ -1913,7 +1934,7 @@ bc_DumpCmd(as, arock)
     /* Expand out the volume set into its component list of volumes. */
     code = bc_EvalVolumeSet(bc_globalConfig, tvs, &volsToDump, cstruct);
     if (code) {
-       com_err(whoami, code, "; Failed to evaluate volume set");
+       afs_com_err(whoami, code, "; Failed to evaluate volume set");
        return (-1);
     }
     if (!volsToDump) {
@@ -1943,7 +1964,7 @@ bc_DumpCmd(as, arock)
                    tve->cloneDate = 0;
 
                if (tve->cloneDate && (tve->cloneDate == tve->date)) {
-                   com_err(whoami, 0,
+                   afs_com_err(whoami, 0,
                            "Warning: Timestamp on volume %s unchanged from previous dump",
                            tve->name);
                }
@@ -1968,7 +1989,7 @@ bc_DumpCmd(as, arock)
                          parent, level, bc_Dumper, portp, /*portCount */ 1,
                          baseds, doAppend, dontExecute);
     if (code)
-       com_err(whoami, code, "; Failed to queue dump");
+       afs_com_err(whoami, code, "; Failed to queue dump");
 
     return (code);
 }                              /*bc_DumpCmd */
@@ -1980,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;
@@ -1998,9 +2017,9 @@ bc_QuitCmd(as, arock)
        statusPtr = (statusP) ptr;
        if (!(statusPtr->flags & ABORT_REQUEST)) {
            unlock_Status();
-           com_err(whoami, 0, "Job %d still running (and not aborted)",
+           afs_com_err(whoami, 0, "Job %d still running (and not aborted)",
                    statusPtr->jobNumber);
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "You must at least 'kill' all running jobs before quitting");
            return -1;
        }
@@ -2012,8 +2031,8 @@ bc_QuitCmd(as, arock)
      */
     for (td = bc_dumpTasks, i = 0; i < BC_MAXSIMDUMPS; i++, td++) {
        if (td->flags & BC_DI_INUSE) {
-           com_err(whoami, 0, "A job is still running");
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0, "A job is still running");
+           afs_com_err(whoami, 0,
                    "You must at least 'kill' all running jobs before quitting");
            return -1;
        }
@@ -2032,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;
@@ -2044,26 +2061,26 @@ bc_LabelTapeCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
     if (as->parms[0].items) {  /* -name */
        tapename = as->parms[0].items->data;
        if (strlen(tapename) >= TC_MAXTAPELEN) {
-           com_err(whoami, 0, "AFS tape name '%s' is too long", tapename);
+           afs_com_err(whoami, 0, "AFS tape name '%s' is too long", tapename);
            return -1;
        }
     }
 
     if (as->parms[3].items) {  /* -pname */
        if (tapename) {
-           com_err(whoami, 0, "Can only specify -name or -pname");
+           afs_com_err(whoami, 0, "Can only specify -name or -pname");
            return -1;
        }
        pname = as->parms[3].items->data;
        if (strlen(pname) >= TC_MAXTAPELEN) {
-           com_err(whoami, 0, "Permanent tape name '%s' is too long", pname);
+           afs_com_err(whoami, 0, "Permanent tape name '%s' is too long", pname);
            return -1;
        }
     }
@@ -2071,7 +2088,7 @@ bc_LabelTapeCmd(as, arock)
     if (as->parms[1].items) {
        size = bc_FloatATOI(as->parms[1].items->data);
        if (size == -1) {
-           com_err(whoami, 0, "Bad syntax for tape size '%s'",
+           afs_com_err(whoami, 0, "Bad syntax for tape size '%s'",
                    as->parms[1].items->data);
            return -1;
        }
@@ -2095,17 +2112,15 @@ 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;
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -2125,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;
@@ -2136,7 +2149,7 @@ bc_ScanDumpsCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -2166,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;
@@ -2236,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;
@@ -2255,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;
@@ -2277,7 +2284,7 @@ bc_dbVerifyCmd(as, arock)
                  &host);
 
     if (code) {
-       com_err(whoami, code, "; Unable to verify database");
+       afs_com_err(whoami, code, "; Unable to verify database");
        return (-1);
     }
 
@@ -2286,7 +2293,7 @@ bc_dbVerifyCmd(as, arock)
     if (status == 0)
        printf("Database OK\n");
     else
-       com_err(whoami, status, "; Database is NOT_OK");
+       afs_com_err(whoami, status, "; Database is NOT_OK");
 
     if (detail) {
        printf("Orphan blocks %d\n", orphans);
@@ -2309,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;
@@ -2326,14 +2333,14 @@ deleteDump(dumpid, port, force)
     if (port >= 0) {
        tcode = bc_UpdateHosts();
        if (tcode) {
-           com_err(whoami, tcode, "; Can't retrieve tape hosts");
+           afs_com_err(whoami, tcode, "; Can't retrieve tape hosts");
            ERROR(tcode);
        }
 
        /* Find the dump in the backup database */
        tcode = bcdb_FindDumpByID(dumpid, &dumpEntry);
        if (tcode) {
-           com_err(whoami, tcode, "; Unable to locate dumpID %u in database",
+           afs_com_err(whoami, tcode, "; Unable to locate dumpID %u in database",
                    dumpid);
            ERROR(tcode);
        }
@@ -2353,7 +2360,7 @@ deleteDump(dumpid, port, force)
            if (tcode) {
                if (tcode == RXGEN_OPCODE)
                    tcode = BC_VERSIONFAIL;
-               com_err(whoami, tcode,
+               afs_com_err(whoami, tcode,
                        "; Unable to delete dumpID %u via butc", dumpid);
                ERROR(tcode);
            }
@@ -2371,7 +2378,7 @@ deleteDump(dumpid, port, force)
            /* Wait for task to finish */
            taskflag = waitForTask(taskId);
            if (taskflag & (TASK_ERROR | ABORT_DONE)) {
-               com_err(whoami, BUTX_DELETEOBJFAIL,
+               afs_com_err(whoami, BUTX_DELETEOBJFAIL,
                        "; Unable to delete dumpID %u via butc", dumpid);
                ERROR(BUTX_DELETEOBJFAIL);      /* the task failed */
            }
@@ -2391,7 +2398,7 @@ deleteDump(dumpid, port, force)
 
        tcode = bcdb_deleteDump(dumpid, 0, 0, &dumps);
        if (tcode) {
-           com_err(whoami, tcode,
+           afs_com_err(whoami, tcode,
                    "; Unable to delete dumpID %u from database", dumpid);
            dumps.budb_dumpsList_len = 0;
            if (!code)
@@ -2401,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);
     }
@@ -2414,32 +2421,30 @@ 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
        && !as->parms[4].items) {
-       com_err(whoami, 0, "Must specify at least one field");
+       afs_com_err(whoami, 0, "Must specify at least one field");
        return (-1);
     }
 
     /* Must have -to option with -from option */
     if (as->parms[1].items && !as->parms[2].items) {
-       com_err(whoami, 0, "Must specify '-to' field with '-from' field");
+       afs_com_err(whoami, 0, "Must specify '-to' field with '-from' field");
        return (-1);
     }
 
@@ -2455,8 +2460,8 @@ bc_deleteDumpCmd(as, arock)
        code = ktime_DateToLong(timeString, &fromTime);
        free(timeString);
        if (code) {
-           com_err(whoami, 0, "Can't parse 'from' date and time");
-           com_err(whoami, 0, "%s", ktime_GetDateUsage());
+           afs_com_err(whoami, 0, "Can't parse 'from' date and time");
+           afs_com_err(whoami, 0, "%s", ktime_GetDateUsage());
            return (-1);
        }
        havetime = 1;
@@ -2487,8 +2492,8 @@ bc_deleteDumpCmd(as, arock)
        code = ktime_DateToLong(timeString, &toTime);
        free(timeString);
        if (code) {
-           com_err(whoami, 0, "Can't parse 'to' date and time");
-           com_err(whoami, 0, "%s", ktime_GetDateUsage());
+           afs_com_err(whoami, 0, "Can't parse 'to' date and time");
+           afs_com_err(whoami, 0, "%s", ktime_GetDateUsage());
            return (-1);
        }
        toTime += 59;
@@ -2496,7 +2501,7 @@ bc_deleteDumpCmd(as, arock)
     }
 
     if (fromTime > toTime) {
-       com_err(whoami, 0,
+       afs_com_err(whoami, 0,
                "'-from' date/time cannot be later than '-to' date/time");
        return (-1);
     }
@@ -2530,7 +2535,7 @@ bc_deleteDumpCmd(as, arock)
        code =
            bcdb_listDumps(sflags, groupId, fromTime, toTime, &dumps, &flags);
        if (code) {
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "; Error while deleting dumps from %u to %u", fromTime,
                    toTime);
            rcode = -1;
@@ -2570,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;
@@ -2584,7 +2588,7 @@ bc_saveDbCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -2607,8 +2611,8 @@ bc_saveDbCmd(as, arock)
        code = ktime_DateToLong(timeString, &toTime);
        free(timeString);
        if (code) {
-           com_err(whoami, 0, "Can't parse '-archive' date and time");
-           com_err(whoami, 0, "%s", ktime_GetDateUsage());
+           afs_com_err(whoami, 0, "Can't parse '-archive' date and time");
+           afs_com_err(whoami, 0, "%s", ktime_GetDateUsage());
            return (-1);
        }
        toTime += 59;
@@ -2621,7 +2625,7 @@ bc_saveDbCmd(as, arock)
 
     code = TC_SaveDb(tconn, toTime, &taskId);
     if (code) {
-       com_err(whoami, code, "; Failed to save database");
+       afs_com_err(whoami, code, "; Failed to save database");
        goto exit;
     }
 
@@ -2640,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;
@@ -2652,7 +2655,7 @@ bc_restoreDbCmd(as, arock)
 
     code = bc_UpdateHosts();
     if (code) {
-       com_err(whoami, code, "; Can't retrieve tape hosts");
+       afs_com_err(whoami, code, "; Can't retrieve tape hosts");
        return (code);
     }
 
@@ -2668,7 +2671,7 @@ bc_restoreDbCmd(as, arock)
 
     code = TC_RestoreDb(tconn, &taskId);
     if (code) {
-       com_err(whoami, code, "; Failed to restore database");
+       afs_com_err(whoami, code, "; Failed to restore database");
        goto exit;
     }
 
@@ -2722,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];
@@ -2835,7 +2838,7 @@ DBLookupByVolume(volumeName)
     }
 
     if (code)
-       com_err(whoami, code, "");
+       afs_com_err(whoami, code, NULL);
     return (code);
 }
 
@@ -2858,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;
@@ -2925,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) {
-           com_err(whoami, BC_NOMEM, "");
+           afs_com_err(whoami, BC_NOMEM, NULL);
            ERROR(BC_NOMEM);
        }
 
@@ -2977,7 +2978,7 @@ dumpInfo(dumpid, detailFlag)
                volumeLinkPtr =
                    (struct volumeLink *)malloc(sizeof(struct volumeLink));
                if (!volumeLinkPtr) {
-                   com_err(whoami, BC_NOMEM, "");
+                   afs_com_err(whoami, BC_NOMEM, NULL);
                    ERROR(BC_NOMEM);
                }
                memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr));
@@ -3046,7 +3047,7 @@ dumpInfo(dumpid, detailFlag)
 
   error_exit:
     if (code)
-       com_err("dumpInfo", code, "; Can't get dump information");
+       afs_com_err("dumpInfo", code, "; Can't get dump information");
 
     /* free all allocated structures */
     tapeLinkPtr = head;
@@ -3066,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);
@@ -3077,8 +3077,7 @@ compareDump(ptr1, ptr2)
 }
 
 afs_int32
-printRecentDumps(ndumps)
-     int ndumps;
+printRecentDumps(int ndumps)
 {
     afs_int32 code = 0;
     afs_int32 nextindex, index = 0;
@@ -3089,7 +3088,6 @@ printRecentDumps(ndumps)
     char ds[50];
 
     extern struct udbHandleS udbHandle;
-    extern compareDump();
 
     do {                       /* while (nextindex != -1) */
        /* initialize the dump list */
@@ -3105,7 +3103,7 @@ printRecentDumps(ndumps)
        if (code) {
            if (code == BUDB_ENDOFLIST)
                return 0;
-           com_err("dumpInfo", code, "; Can't get dump information");
+           afs_com_err("dumpInfo", code, "; Can't get dump information");
            return (code);
        }
 
@@ -3145,26 +3143,23 @@ 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) {
-           com_err(whoami, 0,
+           afs_com_err(whoami, 0,
                    "These options are exclusive - select only one");
            return (BC_BADARG);
        }
        ndumps = atoi(as->parms[0].items->data);
        if (ndumps <= 0) {
-           com_err(whoami, 0, "Must provide a positive number");
+           afs_com_err(whoami, 0, "Must provide a positive number");
            return -1;
        }