1*13954Ssam #ifndef lint 2*13954Ssam static char sccsid[] = "@(#)lprm.c 4.5 (Berkeley) 07/17/83"; 3*13954Ssam #endif 4*13954Ssam 512110Sralph /* 612110Sralph * lprm - remove the current user's spool entry 712110Sralph * 812110Sralph * lprm [-] [[job #] [user] ...] 912110Sralph * 1012110Sralph * Using information in the lock file, lprm will kill the 1112110Sralph * currently active daemon (if necessary), remove the associated files, 1212110Sralph * and startup a new daemon. Priviledged users may remove anyone's spool 1312110Sralph * entries, otherwise one can only remove their own. 1412110Sralph */ 1512110Sralph 1612110Sralph #include "lp.h" 1712110Sralph 1812110Sralph /* 1912110Sralph * Stuff for handling job specifications 2012110Sralph */ 2112877Sralph char *user[MAXUSERS]; /* users to process */ 2212877Sralph int users; /* # of users in user array */ 2312877Sralph int requ[MAXREQUESTS]; /* job number of spool entries */ 2412877Sralph int requests; /* # of spool requests */ 2512877Sralph char *person; /* name of person doing lprm */ 2612110Sralph 2712877Sralph static char luser[16]; /* buffer for person */ 2812110Sralph 2912110Sralph struct passwd *getpwuid(); 3012110Sralph 3112110Sralph main(argc, argv) 3212110Sralph char *argv[]; 3312110Sralph { 3412110Sralph register char *arg; 3512110Sralph struct passwd *p; 3612110Sralph struct direct **files; 3712110Sralph int nitems, assasinated = 0; 3812110Sralph 3912110Sralph name = argv[0]; 4012110Sralph gethostname(host, sizeof(host)); 4112110Sralph if ((p = getpwuid(getuid())) == NULL) 4212110Sralph fatal("Who are you?"); 4312110Sralph if (strlen(p->pw_name) >= sizeof(luser)) 4412110Sralph fatal("Your name is too long"); 4512110Sralph strcpy(luser, p->pw_name); 4612110Sralph person = luser; 4712110Sralph while (--argc) { 4812110Sralph if ((arg = *++argv)[0] == '-') 4912110Sralph switch (arg[1]) { 5012110Sralph case 'P': 5112730Sralph if (arg[2]) 5212730Sralph printer = &arg[2]; 5312730Sralph else if (argc > 1) { 5412730Sralph argc--; 5512730Sralph printer = *++argv; 5612730Sralph } 5712110Sralph break; 5812110Sralph case '\0': 5912110Sralph if (!users) { 6012110Sralph users = -1; 6112110Sralph break; 6212110Sralph } 6312110Sralph default: 6412110Sralph usage(); 6512110Sralph } 6612110Sralph else { 6712110Sralph if (users < 0) 6812110Sralph usage(); 6912110Sralph if (isdigit(arg[0])) { 7012110Sralph if (requests >= MAXREQUESTS) 7112110Sralph fatal("Too many requests"); 7212110Sralph requ[requests++] = atoi(arg); 7312110Sralph } else { 7412110Sralph if (users >= MAXUSERS) 7512110Sralph fatal("Too many users"); 7612110Sralph user[users++] = arg; 7712110Sralph } 7812110Sralph } 7912110Sralph } 8012110Sralph if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 8112110Sralph printer = DEFLP; 8212110Sralph 8312110Sralph rmjob(); 8412110Sralph } 8512110Sralph 8612877Sralph static 8712110Sralph usage() 8812110Sralph { 8912110Sralph printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 9012110Sralph exit(2); 9112110Sralph } 92