BSD 4_3_Tahoe release
[unix-history] / usr / src / usr.bin / uucp / uuname.c
index d0abd75..f507a75 100644 (file)
@@ -1,69 +1,63 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)uuname.c   5.1 (Berkeley) 7/2/83";
+static char sccsid[] = "@(#)uuname.c   5.4     (Berkeley) 4/5/88";
 #endif
 
 #include "uucp.h"
 #endif
 
 #include "uucp.h"
-#include <signal.h>
 
 
-/*******
- *      uuname  -  return list of all remote systems 
- *                recognized by uucp, or  (with -l) the local
- *                uucp name.
+/*
+ * return list of all remote systems recognized by uucp, or  (with -l) the
+ * local  uucp name. 
  *
  *
- *      return codes: 0 | 1  (can't read)
+ * return codes: 0 | 1  (can't read) 
  */
  */
-main(argc,argv)
+
+struct timeb Now;
+
+main(argc, argv)
 char *argv[];
 int argc;
 {
 char *argv[];
 int argc;
 {
-       int i;
-       int intrEXIT();
-       FILE *np;
-/* Increase buffers for s and prev.  cornell!pavel */
-       char prev[1000];
-       char s[1000];
+       register FILE *np;
+       register char *buf;
+       char s[BUFSIZ];
+       char prev[BUFSIZ];
 
 
-       chdir(Spool);
        strcpy(Progname, "uuname");
        strcpy(Progname, "uuname");
-       signal(SIGILL, intrEXIT);
-       signal(SIGTRAP, intrEXIT);
-       signal(SIGIOT, intrEXIT);
-       signal(SIGEMT, intrEXIT);
-       signal(SIGFPE, intrEXIT);
-       signal(SIGBUS, intrEXIT);
-       signal(SIGSEGV, intrEXIT);
-       signal(SIGSYS, intrEXIT);
-       signal(SIGINT, intrEXIT);
-       signal(SIGHUP, intrEXIT);
-       signal(SIGQUIT, intrEXIT);
-       signal(SIGTERM, intrEXIT);
 
 
-       if(argv[1][0] == '-' && argv[1][1] == 'l') {
+       if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'l') {
                uucpname(s);
                uucpname(s);
-               printf("%s\n",s);
+               puts(s);
                exit(0);
        }
                exit(0);
        }
-        if(argc != 1) {printf("Usage: uuname [-l]\n"); exit(1);}
-       if((np = fopen(SYSFILE,"r")) == NULL) {
-               printf("%s (name file) protected\n",SYSFILE);
+       if (argc != 1) {
+               fprintf(stderr, "Usage: uuname [-l]\n");
                exit(1);
        }
                exit(1);
        }
-       while ( cfgets(s,sizeof(s),np) != NULL ) {
-               for(i=0; s[i]!=' ' && s[i]!='\t'; i++)
-                       ;
-               s[i]='\0';
+       if ((np = fopen(SYSFILE, "r")) == NULL) {
+               syslog(LOG_WARNING, "fopen(%s) failed: %m", SYSFILE);
+               exit(1);
+       }
+       buf = s;
+       while (cfgets(buf, sizeof(s), np) != NULL) {
+               register char *cp;
+               cp = strpbrk(buf, " \t");
+               if (cp)
+                       *cp = '\0';
                if (strcmp(s, prev) == SAME)
                        continue;
                if (strcmp(s, prev) == SAME)
                        continue;
-               if(s[0]=='x' && s[1]=='x' && s[2]=='x')
+               if (*buf == 'x' && buf[1] == 'x' && buf[2] == 'x')
                        continue;
                        continue;
-               printf("%s\n",s);
-               strcpy(prev, s);
+               puts(buf);
+               if (buf == s)
+                       buf = prev;
+               else
+                       buf = s;
        }
        }
        exit(0);
 }
        exit(0);
 }
-intrEXIT(inter)
+
+cleanup(code)
+int code;
 {
 {
-       exit(inter);
+       exit(code);
 }
 }