1: main(argc, argv)
   2: int argc;
   3: char **argv;
   4: {
   5:     int m, a, b;
   6: 
   7:     if(argc != 5) {
   8:         printf("arg count\n");
   9:         goto usage;
  10:     }
  11:     if(*argv[2] == 'b')
  12:         m = 0160666; else
  13:     if(*argv[2] == 'c')
  14:         m = 0120666; else
  15:         goto usage;
  16:     a = number(argv[3]);
  17:     if(a < 0)
  18:         goto usage;
  19:     b = number(argv[4]);
  20:     if(b < 0)
  21:         goto usage;
  22:     if(mknod(argv[1], m, (a<<8)|b) < 0)
  23:         perror("mknod");
  24:     exit();
  25: 
  26: usage:
  27:     printf("usage: mknod name b/c major minor\n");
  28: }
  29: 
  30: number(s)
  31: char *s;
  32: {
  33:     int n, c;
  34: 
  35:     n = 0;
  36:     while(c = *s++) {
  37:         if(c<'0' || c>'9')
  38:             return(-1);
  39:         n = n*10 + c-'0';
  40:     }
  41:     return(n);
  42: }

Defined functions

main defined in line 1; never used
number defined in line 30; used 2 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 525
Valid CSS Valid XHTML 1.0 Strict