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.1 (Berkeley) 06/06/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 if ((p = getpwuid(getuid())) == NULL) 54 fatal("Who are you?"); 55 if (strlen(p->pw_name) >= sizeof(luser)) 56 fatal("Your name is too long"); 57 strcpy(luser, p->pw_name); 58 person = luser; 59 while (--argc) { 60 if ((arg = *++argv)[0] == '-') 61 switch (arg[1]) { 62 case 'P': 63 if (arg[2]) 64 printer = &arg[2]; 65 else if (argc > 1) { 66 argc--; 67 printer = *++argv; 68 } 69 break; 70 case '\0': 71 if (!users) { 72 users = -1; 73 break; 74 } 75 default: 76 usage(); 77 } 78 else { 79 if (users < 0) 80 usage(); 81 if (isdigit(arg[0])) { 82 if (requests >= MAXREQUESTS) 83 fatal("Too many requests"); 84 requ[requests++] = atoi(arg); 85 } else { 86 if (users >= MAXUSERS) 87 fatal("Too many users"); 88 user[users++] = arg; 89 } 90 } 91 } 92 if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 93 printer = DEFLP; 94 95 rmjob(); 96 } 97 98 static 99 usage() 100 { 101 printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 102 exit(2); 103 } 104