Convert ubik_Call(x) calls to ubik_x()
[openafs.git] / src / bucoord / commands.c
index aca15b8..244f4a7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -9,78 +9,62 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
-RCSID
-    ("$Header$");
+#include <roken.h>
 
-#include <afs/stds.h>
-#include <sys/types.h>
-#include <afs/cmd.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <strings.h>
+#ifdef HAVE_POSIX_REGEX                /* use POSIX regexp library */
+#include <regex.h>
 #endif
-#include <errno.h>
+
+#include <afs/cmd.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 <time.h>
-
-#include <string.h>
+#include <ubik.h>
 #include <lock.h>
-#include <afs/butc.h>
 #include <afs/tcdata.h>
 #include <afs/butx.h>
+#include <afs/vsutils_prototypes.h>
+
 #include "bc.h"
 #include "error_macros.h"
-
+#include "bucoord_internal.h"
+#include "bucoord_prototypes.h"
 
 extern struct bc_config *bc_globalConfig;
-extern char *ktime_GetDateUsage();
-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 void bc_HandleMisc();
-extern afs_int32 ScanDumpHdr();
-extern afs_int32 ScanTapeVolume();
 extern char *whoami;
-extern int VL_ListEntry();
-extern int VL_ListAttributesN2();
-extern struct ktc_token ttoken;
-extern char *tailCompPtr();
-extern statusP createStatusNode();
 
 char *loadFile;
 extern afs_int32 lastTaskCode;
 
-#ifdef AFS_DEC_ENV
-#define HOSTADDR(sockaddr) (sockaddr)->sin_addr.S_un.S_addr
-#else
 #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
-#endif
+
+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 a, b, c;
+    int code = -1;
     static afs_int32 use = 2;
 
     if (use == 2) {            /* Use EvalVolumeSet2() */
@@ -109,11 +93,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;
@@ -126,7 +109,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);
        }
@@ -147,7 +130,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;
@@ -162,11 +145,10 @@ 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, *tss;
+    struct serversort *ss, **pss;
     struct partitionsort *ps, **pps;
     afs_int32 r;
     afs_int32 scount, pcount;
@@ -201,14 +183,14 @@ randSPEntries(serverlist, avols)
        }
        free(ss);
     }
+    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;
@@ -220,8 +202,8 @@ 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, *nss;
-    struct partitionsort *ps = 0, *nps;
+    struct serversort *servers = 0, *ss = 0;
+    struct partitionsort *ps = 0;
 
     *avols = (struct bc_volumeDump *)0;
     bulkentries.nbulkentries_len = 0;
@@ -229,7 +211,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
 
     /* For each of the volume set entries - collect the volumes that match it */
     for (tve = avs->ventries; tve; tve = tve->next) {
-       /* Put together a call to the vlserver for this vlentry. The 
+       /* Put together a call to the vlserver for this vlentry. The
         * performance gain is from letting the vlserver expand the
         * volumeset and not this routine.
         */
@@ -250,7 +232,7 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
            bulkentries.nbulkentries_val = 0;
            nsi = -1;
            tcode =
-               ubik_Call(VL_ListAttributesN2, uclient, 0, &attributes,
+               ubik_VL_ListAttributesN2(uclient, 0, &attributes,
                          tve->name, si, &nentries, &bulkentries, &nsi);
            if (tcode)
                ERROR(tcode);
@@ -265,6 +247,11 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
            if (nentries == 0)
                ERROR(RXGEN_OPCODE);    /* Use EvalVolumeSet1 */
 
+           if (nentries < 0)
+               nentries = 0;
+           if (nentries > bulkentries.nbulkentries_len)
+               nentries = bulkentries.nbulkentries_len;
+
            /* Step through each entry and add it to the list of volumes */
            entries = bulkentries.nbulkentries_val;
            for (e = 0; e < nentries; e++) {
@@ -293,7 +280,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);
                }
 
@@ -325,14 +312,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);
                    }
@@ -388,29 +375,29 @@ EvalVolumeSet2(aconfig, avs, avols, uclient)
  * EvalVolumeSetOld
  *
  * Description:
- *     Takes the entries in a volumeset and expands them into a list of 
+ *     Takes the entries in a volumeset and expands them into a list of
  *      volumes. Every VLDB volume entry is looked at and compared to the
  *      volumeset entries.
  *
- *      When matching a VLDB volume entry to a volumeset entry, 
+ *      When matching a VLDB volume entry to a volumeset entry,
  *       1. If the RW volume entry matches, that RW volume is used.
  *       2. Otherwise, if the BK volume entry matches, the BK volume is used.
  *       3. Finally, if the RO volume entry matches, the RO volume is used.
- *      For instance: A volumeset entry of ".* .* user.t.*" will match volume 
- *                    "user.troy" and "user.troy.backup". The rules will use 
+ *      For instance: A volumeset entry of ".* .* user.t.*" will match volume
+ *                    "user.troy" and "user.troy.backup". The rules will use
  *                    the RW volume "user.troy".
  *
  *      When a VLDB volume entry matches a volumeset entry (be it RW, BK or RO),
- *      that volume is used and matches against any remaining volumeset entries 
+ *      that volume is used and matches against any remaining volumeset entries
  *      are not even done.
  *      For instance: A 1st volumeset entry ".* .* .*.backup" will match with
- *                    "user.troy.backup". Its 2nd volumeset entry ".* .* .*" 
- *                    would have matched its RW volume "user.troy", but the first 
+ *                    "user.troy.backup". Its 2nd volumeset entry ".* .* .*"
+ *                    would have matched its RW volume "user.troy", but the first
  *                    match is used and the second match isn't even done.
  *
  * Arguments:
  *     aconfig : Global configuration info.
- *     avs     : 
+ *     avs     :
  *     avols   : Ptr to linked list of entries describing volumes to dump.
  *     uclient : Ptr to Ubik client structure.
  *
@@ -425,28 +412,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 */
@@ -457,8 +449,7 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
      */
     for (index = 0; 1; index = next_index) {   /*w */
        memset(&entry, 0, sizeof(entry));
-       code = ubik_Call(VL_ListEntry,  /*Routine to invoke */
-                        uclient,       /*Ubik client structure */
+       code = ubik_VL_ListEntry(uclient,       /*Ubik client structure */
                         0,     /*Ubik flags */
                         index, /*Current index */
                         &count,        /*Ptr to working variable */
@@ -493,13 +484,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;
                }
 
@@ -509,8 +508,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;
@@ -518,13 +522,18 @@ EvalVolumeSet1(aconfig, avs, avols, uclient)
                        }
                    }
 
-                   /* If the BK name matches the volume set entry, take 
+                   /* If the BK name matches the volume set entry, take
                     * it and exit. Second choice is to use the BK volume.
                     */
                    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;
@@ -540,8 +549,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;
@@ -549,7 +563,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 */
@@ -560,7 +574,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);
                }
 
@@ -568,14 +582,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);
                }
@@ -603,6 +617,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);
@@ -611,37 +629,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 {
-       ltime = localtime(date_long);
-       /* 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;
 
@@ -659,8 +681,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;
@@ -706,8 +727,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;
@@ -717,7 +737,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);
@@ -725,14 +745,13 @@ bc_CopyString(astring)
 }
 
 /* concatParams
- * 
+ *
  *    Concatenates the parameters of an option and returns the string.
  *
  */
 
 char *
-concatParams(itemPtr)
-     struct cmd_item *itemPtr;
+concatParams(struct cmd_item *itemPtr)
 {
     struct cmd_item *tempPtr;
     afs_int32 length = 0;
@@ -745,13 +764,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;
@@ -771,12 +790,12 @@ concatParams(itemPtr)
  *     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(", ");
@@ -806,18 +825,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);
     }
@@ -827,13 +845,10 @@ 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;
-    afs_int32 index, dumpID;
     struct rx_connection *tconn;
     afs_int32 portOffset = 0;
 
@@ -844,7 +859,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);
     }
 
@@ -867,7 +882,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))
@@ -894,18 +909,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;
-    statusP ptr;
-    dlqlinkP dptr;
 
-    com_err(whoami, 0, "waiting for job termination");
+    afs_com_err(whoami, 0, "waiting for job termination");
 
     while (usefulJobRunning) {
        usefulJobRunning = (dlqEmpty(&statusHead) ? 0 : 1);
@@ -928,14 +940,10 @@ 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)
 {
-    int i;
     afs_int32 prevTime;
-    struct bc_dumpTask *td;
     dlqlinkP ptr;
     statusP statusPtr;
     char ds[50];
@@ -963,7 +971,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);
 
@@ -988,7 +996,7 @@ bc_JobsCmd(as, arock)
        }
     }
 
-    /* 
+    /*
      * Now print the scheduled dumps.
      */
     if (!dlqEmpty(&statusHead) && as)
@@ -1008,11 +1016,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");
@@ -1032,11 +1040,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");
@@ -1047,29 +1055,25 @@ 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;
     struct bc_dumpTask *td;
     char *tp;
     char tbuffer[256];
-    afs_int32 code;
 
     dlqlinkP ptr;
     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;
        }
 
@@ -1102,7 +1106,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;
        }
 
@@ -1110,21 +1114,19 @@ 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);
        }
        statusPtr->flags |= ABORT_REQUEST;
        unlock_Status();
-       return (0);
     }
     return 0;
 }
 
 /* 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
@@ -1150,15 +1152,16 @@ bc_VolRestoreCmd(as, arock)
     afs_int32 code;
     int oldFlag;
     afs_int32 fromDate;
+    afs_int32 dumpID = 0;
     char *newExt, *timeString;
-    afs_int32 i, portRemain;
+    afs_int32 i;
     afs_int32 *ports = NULL;
     afs_int32 portCount = 0;
     int dontExecute;
 
     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);
     }
 
@@ -1166,7 +1169,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;
        }
     }
@@ -1175,7 +1178,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;
        }
     }
@@ -1184,14 +1187,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);
@@ -1212,8 +1215,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 {
@@ -1224,14 +1227,14 @@ bc_VolRestoreCmd(as, arock)
     oldFlag = 0;
 
     /* Read all the port offsets into the ports array. The first element in the
-     * array is for full restore and the rest are for incremental restores 
+     * array is for full restore and the rest are for incremental restores
      */
     if (as->parms[5].items) {
        for (ti = as->parms[5].items; ti; ti = ti->next)
            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;
        }
 
@@ -1244,17 +1247,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 */ 0, /*append */ 0, dontExecute);
+                      /*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);
 }
@@ -1269,9 +1279,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 */
@@ -1292,7 +1301,7 @@ bc_DiskRestoreCmd(as, arock)
 
     /* parm 0 is the server to restore
      * parm 1 is the partition to restore
-     
+
      * parm 8 and above as in VolRestoreCmd:
      * parm 8 is the new server to restore to
      * parm 9 is the new partition to restore to
@@ -1300,12 +1309,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);
     }
 
@@ -1318,13 +1327,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;
     }
 
@@ -1332,7 +1341,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 */
@@ -1342,7 +1351,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 */
@@ -1355,7 +1364,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;
        }
 
@@ -1376,11 +1385,11 @@ 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);
     }
 
-    /* Since we want only RW volumes, remove any 
+    /* Since we want only RW volumes, remove any
      * BK or RO volumes from the list.
      */
     for (prev = 0, tvol = volsToRestore; tvol; tvol = nextvol) {
@@ -1415,9 +1424,9 @@ bc_DiskRestoreCmd(as, arock)
                       &destServ, destPartition, fromDate, newExt, oldFlag,
                       /*parentDump */ 0, /*dumpLevel */ 0,
                       bc_Restorer, ports, portCount,
-                      /*dumpSched */ 0, /*append */ 0, dontExecute);
+                      /*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);
 }
@@ -1426,9 +1435,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;
@@ -1438,7 +1446,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;
@@ -1450,25 +1457,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);
@@ -1479,7 +1486,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) {
@@ -1491,7 +1498,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);
        }
@@ -1510,12 +1517,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;
@@ -1528,7 +1535,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);
@@ -1543,7 +1550,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);
     }
 
@@ -1554,7 +1561,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;
        }
 
@@ -1573,13 +1580,13 @@ bc_VolsetRestoreCmd(as, arock)
 
     /* Perform the call to start the restore */
     code = bc_StartDmpRst(bc_globalConfig, "disk", "restore", volsToRestore,
-                         /*destserver */ 0, /*destpartition */ 0, fromDate,
+                         /*destserver */ NULL, /*destpartition */ 0, fromDate,
                          newExt, oldFlag,
                          /*parentDump */ 0, /*dumpLevel */ 0,
                          bc_Restorer, ports, portCount,
-                         /*dumpSched */ 0, /*append */ 0, dontExecute);
+                         /*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;
 }
@@ -1609,16 +1616,14 @@ 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 bc_volumeDump *ntve, *tves, *ptves, *rtves;
     struct budb_dumpEntry dumpEntry, de, fde;  /* dump entry */
     afs_uint32 d;
 
@@ -1627,62 +1632,55 @@ bc_DumpCmd(as, arock)
     afs_int32 problemFindingDump;      /* can't find parent(s) */
 
     afs_int32 *portp = NULL;
-    afs_int32 portCount = 0;
     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 */
 
-    struct bc_dumpTask *dumpTaskPtr;   /* for dump thread */
-    afs_int32 dumpTaskSlot;
-    char *junk;
     statusP statusPtr;
-    int r, nservers, ns, serverfound;
 
     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);
     }
 
-    /* 
+    /*
      * Some parameters cannot be specified together
-     * The "-file" option cannot exist with the "-volume", "-dump", 
-     * "-portoffset", or "-append" option 
+     * The "-file" option cannot exist with the "-volume", "-dump",
+     * "-portoffset", or "-append" option
      */
     if (as->parms[6].items) {
        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;
        }
     }
 
-    /* 
+    /*
      * Get the time we are to perform this dump
      */
     if (as->parms[3].items) {
@@ -1698,8 +1696,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
@@ -1707,7 +1705,7 @@ bc_DumpCmd(as, arock)
 
     dontExecute = (as->parms[5].items ? 1 : 0);        /* -n */
 
-    /* 
+    /*
      * If this dump is not a load file, then check the parameters.
      */
     if (!loadfile) {           /*6 */
@@ -1716,10 +1714,9 @@ bc_DumpCmd(as, arock)
 
        /* get the port number, if one was specified */
        if (as->parms[2].items) {
-           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;
            }
 
@@ -1735,13 +1732,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);
@@ -1751,17 +1748,17 @@ bc_DumpCmd(as, arock)
 
     /*6 */
     /*
-     * If given the "-at" option, then add this to the jobs list and return 
+     * If given the "-at" option, then add this to the jobs list and return
      * with no error.
      *
      * Create a status node for this timed dump.
      * Fill in the time to dump and the cmd line for the dump leaving off
-     * the -at option.  If the -n option is there, it is scheduled with 
+     * the -at option.  If the -n option is there, it is scheduled with
      * the Timed dump as opposed to not scheduling the time dump at all.
      */
     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();
@@ -1800,7 +1797,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;
            }
 
@@ -1833,8 +1830,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);
 
@@ -1844,7 +1841,7 @@ bc_DumpCmd(as, arock)
        return (0);
     }
 
-    /* 
+    /*
      * Read and execute the load file if specified.  The work of reading is done
      * in the main routine prior the dispatch call. loadFile and dontExecute are
      * global variables so this can take place in main.
@@ -1852,14 +1849,14 @@ 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);
        return 0;
     }
 
-    /* 
+    /*
      * We are doing a real dump (no load file or timed dump).
      */
     printf("Starting dump of volume set '%s' (dump level '%s')\n", vsName,
@@ -1882,9 +1879,9 @@ bc_DumpCmd(as, arock)
        }
 
        /* We found the most recent dump at this level. Now check
-        * if we should use it by seeing if its full dump hierarchy 
+        * if we should use it by seeing if its full dump hierarchy
         * exists. If it doesn't, we don't want to base our incremental
-        * off of this dump. 
+        * off of this dump.
         */
        if (!parent || (dumpEntry.id > parent)) {
            /* Follow the parent dumps to see if they are all there */
@@ -1910,11 +1907,11 @@ bc_DumpCmd(as, arock)
        }
     }
 
-    /* If the problemflag was raise, it means we are not doing the 
+    /* If the problemflag was raise, it means we are not doing the
      * 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) {
@@ -1927,7 +1924,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) {
@@ -1957,7 +1954,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);
                }
@@ -1976,13 +1973,13 @@ bc_DumpCmd(as, arock)
        return (0);
 
     code = bc_StartDmpRst(bc_globalConfig, dumpPath, vsName, volsToDump,
-                         /*destServer */ 0, /*destPartition */ 0,
+                         /*destServer */ NULL, /*destPartition */ 0,
                          /*fromDate */ 0,
-                         /*newExt */ 0, /*oldFlag */ 0,
+                         /*newExt */ NULL, /*oldFlag */ 0,
                          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 */
@@ -1994,10 +1991,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;
@@ -2012,9 +2007,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;
        }
@@ -2026,8 +2021,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;
        }
@@ -2046,10 +2041,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;
@@ -2058,26 +2051,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;
        }
     }
@@ -2085,7 +2078,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;
        }
@@ -2109,17 +2102,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);
     }
 
@@ -2139,10 +2130,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;
@@ -2150,7 +2139,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);
     }
 
@@ -2180,10 +2169,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;
@@ -2250,10 +2237,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;
@@ -2269,10 +2254,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;
@@ -2287,11 +2270,11 @@ bc_dbVerifyCmd(as, arock)
     detail = (as->parms[0].items ? 1 : 0);     /* print more details */
 
     code =
-       ubik_Call(BUDB_DbVerify, udbHandle.uh_client, 0, &status, &orphans,
+       ubik_BUDB_DbVerify(udbHandle.uh_client, 0, &status, &orphans,
                  &host);
 
     if (code) {
-       com_err(whoami, code, "; Unable to verify database");
+       afs_com_err(whoami, code, "; Unable to verify database");
        return (-1);
     }
 
@@ -2300,7 +2283,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);
@@ -2323,10 +2306,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;
@@ -2340,14 +2323,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);
        }
@@ -2355,7 +2338,7 @@ deleteDump(dumpid, port, force)
 
        /* If dump is to an XBSA server, connect to butc and send it
         * the dump to delete. Butc will contact the XBSA server.
-        * The dump will not be an appended dump because XBSA butc 
+        * The dump will not be an appended dump because XBSA butc
         * does not support the append option.
         */
        if (xbsadump && dumpEntry.nVolumes) {
@@ -2367,7 +2350,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);
            }
@@ -2385,7 +2368,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 */
            }
@@ -2405,7 +2388,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)
@@ -2415,7 +2398,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);
     }
@@ -2428,33 +2411,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_uint32 taskid;
+    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);
     }
 
@@ -2470,8 +2450,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;
@@ -2502,8 +2482,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;
@@ -2511,7 +2491,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);
     }
@@ -2545,7 +2525,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;
@@ -2585,9 +2565,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;
@@ -2599,7 +2578,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);
     }
 
@@ -2622,8 +2601,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;
@@ -2636,7 +2615,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;
     }
 
@@ -2655,9 +2634,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;
@@ -2667,7 +2645,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);
     }
 
@@ -2683,7 +2661,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;
     }
 
@@ -2703,7 +2681,7 @@ bc_restoreDbCmd(as, arock)
 }
 
 /* ----------------------------------
- * supporting routines for database examination 
+ * supporting routines for database examination
  * ----------------------------------
  */
 
@@ -2737,8 +2715,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];
@@ -2850,7 +2828,7 @@ DBLookupByVolume(volumeName)
     }
 
     if (code)
-       com_err(whoami, code, "");
+       afs_com_err(whoami, code, NULL);
     return (code);
 }
 
@@ -2873,9 +2851,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;
@@ -2885,7 +2861,6 @@ dumpInfo(dumpid, detailFlag)
     budb_volumeList vl;
     afs_int32 last, next, dbTime;
     afs_int32 tapedumpid;
-    afs_int32 numTapes;
 
     int tapeNumber;
     int i;
@@ -2921,13 +2896,14 @@ dumpInfo(dumpid, detailFlag)
        printf("----\n");
        printDumpEntry(&dumpEntry);
     } else {
+        time_t t = dumpEntry.created;
        if (dbDump)
            printf("Dump: id %u, created: %s\n", dumpEntry.id,
-                  ctime(&dumpEntry.created));
-       else
+                  ctime(&t));
+       else
            printf("Dump: id %u, level %d, volumes %d, created: %s\n",
                   dumpEntry.id, dumpEntry.level, dumpEntry.nVolumes,
-                  ctime(&dumpEntry.created));
+                  ctime(&t));
     }
 
     if (!detailFlag && (strlen(dumpEntry.tapes.tapeServer) > 0)
@@ -2940,7 +2916,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);
        }
 
@@ -2992,7 +2968,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));
@@ -3061,7 +3037,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;
@@ -3080,8 +3056,8 @@ dumpInfo(dumpid, detailFlag)
     return (code);
 }
 
-compareDump(ptr1, ptr2)
-     struct budb_dumpEntry *ptr1, *ptr2;
+int
+compareDump(struct budb_dumpEntry *ptr1, struct budb_dumpEntry *ptr2)
 {
     if (ptr1->created < ptr2->created)
        return (-1);
@@ -3091,20 +3067,17 @@ compareDump(ptr1, ptr2)
 }
 
 afs_int32
-printRecentDumps(ndumps)
-     int ndumps;
+printRecentDumps(int ndumps)
 {
     afs_int32 code = 0;
     afs_int32 nextindex, index = 0;
     afs_int32 dbTime;
-    afs_int32 tapedumpid;
     budb_dumpList dl;
     struct budb_dumpEntry *dumpPtr;
     int i;
     char ds[50];
 
     extern struct udbHandleS udbHandle;
-    extern compareDump();
 
     do {                       /* while (nextindex != -1) */
        /* initialize the dump list */
@@ -3112,7 +3085,7 @@ printRecentDumps(ndumps)
        dl.budb_dumpList_val = 0;
 
        /* outline algorithm */
-       code = ubik_Call(BUDB_GetDumps, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_NPREVIOUS, "",       /* no name */
+       code = ubik_BUDB_GetDumps(udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_NPREVIOUS, "",     /* no name */
                         0,     /* start */
                         ndumps,        /* end */
                         index, /* index */
@@ -3120,7 +3093,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);
        }
 
@@ -3136,7 +3109,7 @@ printRecentDumps(ndumps)
                printf("%10u %10u %-2d %16s %2d %5d %s", dumpPtr->id,
                       dumpPtr->parent, dumpPtr->level, ds,
                       dumpPtr->tapes.maxTapes - dumpPtr->tapes.b + 1,
-                      dumpPtr->nVolumes, dumpPtr->name, tapedumpid);
+                      dumpPtr->nVolumes, dumpPtr->name);
            if (dumpPtr->initialDumpID) /* an appended dump */
                printf(" (%u)", dumpPtr->initialDumpID);
            else if (dumpPtr->appendedDumpID)   /* has appended dumps */
@@ -3154,32 +3127,29 @@ printRecentDumps(ndumps)
     return (code);
 }
 
-/* bc_dumpInfoCmd 
+/* bc_dumpInfoCmd
  *     list the dumps and contens of the dumps.
  * params:
  *     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;
        }