vlserver: Tidy header includes
[openafs.git] / src / vlserver / vlclient.c
index 823d7d6..8c41d18 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,34 +9,16 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
+#include <roken.h>
 
-#include <afs/stds.h>
-#include <sys/types.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
 #ifdef AFS_NT40_ENV
-#include <winsock2.h>
 #include <WINNT/afsevent.h>
 #endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#include <stdio.h>
-#include <string.h>
 #include <ctype.h>
 
 #include <afs/afsutil.h>
@@ -49,6 +31,7 @@
 #include <afs/cmd.h>
 #include <lock.h>
 #include <ubik.h>
+
 #include "vlserver.h"
 
 void fill_listattributes_entry(struct VldbListByAttributes *, char **, int);
@@ -122,8 +105,8 @@ char *(args[50]);
 struct Vlent *
 GetVolume(int vol, struct vldbentry *entry)
 {
-    register int i;
-    register struct Vlent *vl;
+    int i;
+    struct Vlent *vl;
 
     if (!vol)
        return NULL;
@@ -154,7 +137,7 @@ afs_int32
 vl_Initialize(int auth, char *confDir, int server, char *cellp)
 {
     return ugen_ClientInit(auth?0:1, confDir, cellp, 0,
-                         &cstruct, NULL, "vl_Initialize", rxkad_clear, 
+                         &cstruct, NULL, "vl_Initialize", rxkad_clear,
                          MAXSERVERS, AFSCONF_VLDBSERVICE, 50, server,
                          htons(AFSCONF_VLDBPORT), USER_SERVICE_ID);
 }
@@ -163,10 +146,10 @@ vl_Initialize(int auth, char *confDir, int server, char *cellp)
 afs_int32
 GetServer(char *aname)
 {
-    register struct hostent *th;
+    struct hostent *th;
     afs_uint32 addr;
     int b1, b2, b3, b4;
-    register afs_int32 code;
+    afs_int32 code;
 
     code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
     if (code == 4) {
@@ -184,8 +167,8 @@ GetServer(char *aname)
 static int
 handleit(struct cmd_syndesc *as, void *arock)
 {
-    register struct cmd_item *ti;
-    register afs_int32 code, server = 0, sawserver = 0;
+    struct cmd_item *ti;
+    afs_int32 code, server = 0, sawserver = 0;
     afs_int32 id, voltype;
     struct vldbentry entry;
     char *cellp = 0;
@@ -241,11 +224,13 @@ handleit(struct cmd_syndesc *as, void *arock)
            exit(0);
        } else {
            char *oper, *vname;
-           register char **argp = args;
+           char **argp = args;
+
            GetArgs(line, argp, &nargs);
            oper = &argp[0][0];
            ++argp, --nargs;
-           if (!strcmp(oper, "cr")) {
+           if (!*line) {
+           } else if (!strcmp(oper, "cr")) {
                fill_entry(&entry, argp, nargs);
                display_entry(&entry, 0);
                code = ubik_VL_CreateEntry(cstruct, 0, &entry);
@@ -434,8 +419,6 @@ handleit(struct cmd_syndesc *as, void *arock)
                    ("Volumes not found in main hash tables in vldb will be fixed...\n");
                memset(&updateentry, 0, sizeof(updateentry));
                for (index = 0; 1; index = next_index) {
-                   /* FIXME: n2 is never changed for some reason */
-                   int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
                    memset(&entry, 0, sizeof(entry));
                    code =
                        ubik_VL_ListEntry(cstruct, 0, index, &count,
@@ -452,7 +435,6 @@ handleit(struct cmd_syndesc *as, void *arock)
                                  &tentry);
                    if (code == VL_NOENT) {
                        num1++;
-                       n1 = 1;
                        updateentry.Mask = VLUPDATE_VOLNAMEHASH;
                        printf("\tVolume %s %d (not in namehash)\n",
                               entry.name, entry.volumeId[RWVOL]);
@@ -486,13 +468,12 @@ handleit(struct cmd_syndesc *as, void *arock)
                        }
                        x++;
                    }
-                   if (entry.volumeId[BACKVOL] && !n2) {
+                   if (entry.volumeId[BACKVOL]) {
                        code =
                            ubik_VL_GetEntryByID(cstruct, 0,
                                      entry.volumeId[BACKVOL], BACKVOL,
                                      &tentry);
                        if (code == VL_NOENT) {
-                           n3 = 1;
                            num1++;
                            updateentry.Mask = VLUPDATE_BACKUPID;
                            updateentry.BackupId = entry.volumeId[BACKVOL];
@@ -510,12 +491,11 @@ handleit(struct cmd_syndesc *as, void *arock)
                            }
                        }
                    }
-                   if (entry.volumeId[ROVOL && !n2]) {
+                   if (entry.volumeId[ROVOL]) {
                        code =
                            ubik_VL_GetEntryByID(cstruct, 0,
                                      entry.volumeId[ROVOL], ROVOL, &tentry);
                        if (code == VL_NOENT) {
-                           n4 = 1;
                            num1++;
                            updateentry.Mask = VLUPDATE_READONLYID;
                            updateentry.ReadOnlyId = entry.volumeId[ROVOL];
@@ -1004,12 +984,13 @@ handleit(struct cmd_syndesc *as, void *arock)
                    printf("VL_ChangeAddr returned code = %d\n", code);
                    continue;
                }
-           } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h"))
+           } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h") || !strcmp(oper, "help"))
                print_usage();
            else if ((!strcmp(oper, "q")) || !strcmp(oper, "quit"))
                exit(0);
            else {
-               printf("Unknown oper!\n");
+               printf("Unknown oper (%s)!\n", oper);
+               print_usage();
            }
        }
     }
@@ -1021,7 +1002,7 @@ handleit(struct cmd_syndesc *as, void *arock)
 int
 main(int argc, char **argv)
 {
-    register struct cmd_syndesc *ts;
+    struct cmd_syndesc *ts;
     afs_int32 code;
 
     strcpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH);
@@ -1316,7 +1297,7 @@ GetArgs(char *line, char **args, int *nargs)
 {
     *nargs = 0;
     while (*line) {
-       register char *last = line;
+       char *last = line;
        while (isspace(*line))
            line++;
        if (isspace(*last))