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