home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / UUCP_Blars.lzh / uustat.c < prev    next >
C/C++ Source or Header  |  1991-09-08  |  2KB  |  134 lines

  1. #include <stdio.h>
  2. #include <strings.h>
  3. #include <modes.h>
  4. #include "uucp.h"
  5.  
  6.  
  7. int sys_files, sys_status;
  8.  
  9. char s_spooldir[250], s_libdir[250];
  10. char s_logfile[250];
  11.  
  12. main(argc, argv)
  13.   int  argc;
  14.   char *argv[];
  15. {
  16.   int i, j;
  17.   int snum;
  18.   
  19.   sys_files = sys_status = FALSE;
  20.   snum     = 0;
  21.  
  22.   for (i = 1; i < argc; i++)
  23.     if (argv[i][0] == '-')
  24.       for (j = 1; j < strlen(argv[i]); j++)
  25.         switch (tolower(argv[i][j])) {
  26.           case '?':
  27.             usage();
  28.             exit(1);
  29.           case 's':
  30.             sys_files = TRUE;
  31.             break;
  32.           case 'm':
  33.             sys_status = TRUE;
  34.             break;
  35.           default:
  36.             usage();
  37.             exit(_errmsg(1, "unknown option '%c'\n", argv[i][j]));
  38.         }
  39.     else
  40.       snum++;
  41.       
  42.   if (!sys_files && !sys_status) {
  43.     usage();
  44.     exit(_errmsg(1, "no option given\n"));
  45.   }
  46.  
  47.   setup();
  48.   
  49.   if (sys_files) {
  50.     if (snum == 0) {
  51.       usage();
  52.       exit(_errmsg(1, "no system name given\n"));
  53.     }
  54.  
  55.     for (i = 1; i < argc; i++)
  56.       if (argv[i][0] != '-')
  57.         files(argv[i]);
  58.   }
  59.  
  60.   if (sys_status)
  61.     if (snum == 0)
  62.       status(NULL);
  63.     else
  64.       for (i = 1; i < argc; i++)
  65.         if (argv[i][0] != '-')
  66.           status(argv[i]);
  67. }
  68.  
  69. usage()
  70. {
  71. }
  72.  
  73.  
  74. setup()
  75. {
  76.     strcpy(s_spooldir, SPOOLDIR);
  77.     strcpy(s_spooldir, LIBDIR);
  78.   
  79.   if (chdir(s_spooldir) == -1)
  80.     cant(s_spooldir);
  81.  
  82.   strcpy(s_logfile, ".LOG/logfile");
  83. }
  84.  
  85.  
  86. files(rmtname)
  87.   char *rmtname;
  88. {
  89.   DIR *dp;
  90.   struct dentry 
  91.   int  fn, len, i;
  92.   char cname[40], tmp[132];
  93.  
  94.   static DIR    *dirp = NULL;
  95.   struct direct *dp;
  96.  
  97.   if ((dirp = opendir(s_spooldir)) == (DIR *) NULL)
  98.     exit(_errmsg(errno, "couldn't open dir %s\n", s_spooldir));
  99.  
  100.   sprintf(cname, "C.%.6s", rmtname);
  101.   len = strlen(cname);
  102.  
  103.   while ((dp = readdir(dirp)) != (struct direct *) NULL) {
  104.     if (!strncmp(cname, dp->d_name, len)) {
  105.       strcpy(cfile, dp->d_name);
  106.  
  107.       if ((fpw = fopen(cfile, "r")) == NULL)
  108.         exit(_errmsg(errno, "can't open '%s'\n", cfile));
  109.     }
  110.     
  111.     while (fgets(line, BUFSIZ, fpw) != NULL)
  112.       sscanf(&line[2], "%s ", fromfile);
  113.  
  114.       for (i = 0, cp = line; *cp != '\0'; i++, cp++)
  115.         if (strncmp(cp, "0666", 4) == SAME)
  116.           break;
  117.  
  118.  
  119.       cp  += 4;
  120.       *cp = '\0';
  121.       strcpy(tofile, line);
  122.  
  123.       id[0] = '\0';
  124.       if (cp = index(line+3, ' '))
  125.         if (cp = index(cp+1, ' '))
  126.           sscanf(cp+1, "%s ", id);    /* ID */
  127.  
  128.   }
  129.  
  130.  
  131. }
  132.  
  133.  
  134.