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