1: /* vpq.c		8/6/82
   2:  * Varian and Versatec queue
   3:  */
   4: 
   5: static char vpqSCCSid[] = "@(#)vpq.c	1.3\t8/6/82";
   6: 
   7: #include <sys/param.h>
   8: #include <dir.h>
   9: #include <stat.h>
  10: #include <stdio.h>
  11: #include <errno.h>
  12: #define MAXJOBS 100
  13: 
  14: struct  stat stbuf;
  15: int nextflag;
  16: int linecnt;
  17: FILE    *jf;
  18: char    line[100];
  19: char    username[10];
  20: int cnt;
  21: extern  int errno;
  22: extern  char _sobuf[];
  23: 
  24: main(argc, argv)
  25: int argc;
  26: char **argv;
  27: {
  28:     int varian = 1;
  29:     int versatec = 1;
  30: 
  31:     setbuf(stdout, _sobuf);
  32: 
  33:     argc--, argv++;
  34:     while (argc > 0 && argv[0][0] == '-') {
  35:         switch (argv[0][1]) {
  36: 
  37:         case 'W':       /* Wide: the versatec. */
  38:             varian = 0;
  39:             versatec++;
  40:             break;
  41: 
  42:         case 'b':
  43:             varian++;
  44:             versatec++;
  45:             break;
  46: 
  47:         default:
  48:             fprintf(stderr, "usage: vpq [ -W ] [ -b ]\n");
  49:             exit(1);
  50:         }
  51:         argc--, argv++;
  52:     }
  53:     if (varian)
  54:         queue("/dev/va0", "Varian", "/usr/spool/vad", "/usr/lib/vad");
  55:     if (versatec)
  56:         queue("/dev/vp0", "Versatec", "/usr/spool/vpd", "/usr/lib/vpd");
  57:     exit(0);
  58: }
  59: 
  60: 
  61: queue(device, devname, spooldir, daemon)
  62: char *device, *devname, *spooldir, *daemon;
  63: {
  64:     FILE *vc;
  65:     DIR *df;
  66:     register struct direct *dirp;
  67: 
  68:     printf("%s: ", devname);
  69:     vc = fopen(device, "w");
  70:     if (vc == NULL) {
  71:         if (errno == EIO)
  72:             printf("offline\n");
  73:         else if (errno == ENXIO)
  74:             printf("in use\n");
  75:         else
  76:             printf("not available\n");
  77:     } else {
  78:         printf("ready and idle.\n");
  79:         fclose(vc);
  80:     }
  81:     if (access(daemon, 1))
  82:         printf("Daemon is disabled.\n");
  83:     if (chdir(spooldir) < 0) {
  84:         perror(spooldir);
  85:         return;
  86:     }
  87:     df = opendir(".");
  88:     if (df == NULL) {
  89:         perror(spooldir);
  90:         return;
  91:     }
  92:     linecnt = 0;
  93:     cnt = 0;
  94:     while ((dirp = readdir(df)) != NULL) {
  95:         if (dirp->d_name[0] != 'd')
  96:             continue;
  97:         if (dirp->d_name[1] != 'f')
  98:             continue;
  99:         if (stat(dirp->d_name, &stbuf) < 0)
 100:             continue;
 101:         if (cnt == 0)
 102:             printf("Owner\t  Id      Chars  Filename\n");
 103:         cnt++;
 104:         process(dirp);
 105:     }
 106:     closedir(df);
 107:     if (cnt == 0)
 108:         printf("Queue is empty.\n");
 109:     printf("\n");
 110: }
 111: 
 112: process(dirp)
 113:     register struct direct *dirp;
 114: {
 115: 
 116:     jf = fopen(dirp->d_name, "r");
 117:     if (jf == NULL)
 118:         return;
 119:     while (getline()) {
 120:         switch (line[0]) {
 121: 
 122:         case 'L':
 123:             strcpy(username, line+1);
 124:             break;
 125: 
 126:         case 'C':
 127:         case 'V':
 128:         case 'F':
 129:         case 'G':
 130:         case 'P':
 131:         case 'T':
 132:             if (stat(line+1, &stbuf) < 0)
 133:                 stbuf.st_size = 0;
 134:             printf("%-10s%5s%8d  %s\n", username,
 135:                 &(dirp->d_name[3]), stbuf.st_size, line+1);
 136:             break;
 137:         }
 138:     }
 139:     fclose(jf);
 140: }
 141: 
 142: getline()
 143: {
 144:     register int i, c;
 145: 
 146:     i = 0;
 147:     while ((c = getc(jf)) != '\n') {
 148:         if (c <= 0)
 149:             return(0);
 150:         if (i < 100)
 151:             line[i++] = c;
 152:     }
 153:     line[i++] = 0;
 154:     return (1);
 155: }

Defined functions

getline defined in line 142; used 1 times
main defined in line 24; never used
process defined in line 112; used 1 times
queue defined in line 61; used 2 times

Defined variables

cnt defined in line 20; used 4 times
line defined in line 18; used 6 times
linecnt defined in line 16; used 1 times
  • in line 92
nextflag defined in line 15; never used
stbuf defined in line 14; used 4 times
username defined in line 19; used 2 times
vpqSCCSid defined in line 5; never used

Defined macros

MAXJOBS defined in line 12; never used
Last modified: 1982-08-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 686
Valid CSS Valid XHTML 1.0 Strict