1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: char copyright[] =
   9: "@(#) Copyright (c) 1983 Regents of the University of California.\n\
  10:  All rights reserved.\n";
  11: #endif not lint
  12: 
  13: #ifndef lint
  14: static char sccsid[] = "@(#)lprm.c	5.2 (Berkeley) 11/17/85";
  15: #endif not lint
  16: 
  17: /*
  18:  * lprm - remove the current user's spool entry
  19:  *
  20:  * lprm [-] [[job #] [user] ...]
  21:  *
  22:  * Using information in the lock file, lprm will kill the
  23:  * currently active daemon (if necessary), remove the associated files,
  24:  * and startup a new daemon.  Priviledged users may remove anyone's spool
  25:  * entries, otherwise one can only remove their own.
  26:  */
  27: 
  28: #include "lp.h"
  29: 
  30: /*
  31:  * Stuff for handling job specifications
  32:  */
  33: char    *user[MAXUSERS];    /* users to process */
  34: int users;          /* # of users in user array */
  35: int requ[MAXREQUESTS];  /* job number of spool entries */
  36: int requests;       /* # of spool requests */
  37: char    *person;        /* name of person doing lprm */
  38: 
  39: static char luser[16];  /* buffer for person */
  40: 
  41: struct passwd *getpwuid();
  42: 
  43: main(argc, argv)
  44:     char *argv[];
  45: {
  46:     register char *arg;
  47:     struct passwd *p;
  48:     struct direct **files;
  49:     int nitems, assasinated = 0;
  50: 
  51:     name = argv[0];
  52:     gethostname(host, sizeof(host));
  53:     openlog("lpd", 0, LOG_LPR);
  54:     if ((p = getpwuid(getuid())) == NULL)
  55:         fatal("Who are you?");
  56:     if (strlen(p->pw_name) >= sizeof(luser))
  57:         fatal("Your name is too long");
  58:     strcpy(luser, p->pw_name);
  59:     person = luser;
  60:     while (--argc) {
  61:         if ((arg = *++argv)[0] == '-')
  62:             switch (arg[1]) {
  63:             case 'P':
  64:                 if (arg[2])
  65:                     printer = &arg[2];
  66:                 else if (argc > 1) {
  67:                     argc--;
  68:                     printer = *++argv;
  69:                 }
  70:                 break;
  71:             case '\0':
  72:                 if (!users) {
  73:                     users = -1;
  74:                     break;
  75:                 }
  76:             default:
  77:                 usage();
  78:             }
  79:         else {
  80:             if (users < 0)
  81:                 usage();
  82:             if (isdigit(arg[0])) {
  83:                 if (requests >= MAXREQUESTS)
  84:                     fatal("Too many requests");
  85:                 requ[requests++] = atoi(arg);
  86:             } else {
  87:                 if (users >= MAXUSERS)
  88:                     fatal("Too many users");
  89:                 user[users++] = arg;
  90:             }
  91:         }
  92:     }
  93:     if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
  94:         printer = DEFLP;
  95: 
  96:     rmjob();
  97: }
  98: 
  99: static
 100: usage()
 101: {
 102:     printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
 103:     exit(2);
 104: }

Defined functions

main defined in line 43; never used
usage defined in line 99; used 2 times

Defined variables

copyright defined in line 8; never used
luser defined in line 39; used 3 times
person defined in line 37; used 1 times
  • in line 59
requ defined in line 35; used 1 times
  • in line 85
requests defined in line 36; used 2 times
sccsid defined in line 14; never used
user defined in line 33; used 1 times
  • in line 89
users defined in line 34; used 5 times
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1112
Valid CSS Valid XHTML 1.0 Strict