1 /* lprm.c 4.3 83/05/26 */ 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 23 extern char *person; /* name of person doing lprm */ 24 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 int select(); 36 37 name = argv[0]; 38 gethostname(host, sizeof(host)); 39 if ((p = getpwuid(getuid())) == NULL) 40 fatal("Who are you?"); 41 if (strlen(p->pw_name) >= sizeof(luser)) 42 fatal("Your name is too long"); 43 strcpy(luser, p->pw_name); 44 person = luser; 45 while (--argc) { 46 if ((arg = *++argv)[0] == '-') 47 switch (arg[1]) { 48 case 'P': 49 if (arg[2]) 50 printer = &arg[2]; 51 else if (argc > 1) { 52 argc--; 53 printer = *++argv; 54 } 55 break; 56 case '\0': 57 if (!users) { 58 users = -1; 59 break; 60 } 61 default: 62 usage(); 63 } 64 else { 65 if (users < 0) 66 usage(); 67 if (isdigit(arg[0])) { 68 if (requests >= MAXREQUESTS) 69 fatal("Too many requests"); 70 requ[requests++] = atoi(arg); 71 } else { 72 if (users >= MAXUSERS) 73 fatal("Too many users"); 74 user[users++] = arg; 75 } 76 } 77 } 78 if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 79 printer = DEFLP; 80 81 rmjob(); 82 } 83 84 usage() 85 { 86 printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 87 exit(2); 88 } 89