1*22433Sdist /* 2*22433Sdist * Copyright (c) 1983 Regents of the University of California. 3*22433Sdist * All rights reserved. The Berkeley software License Agreement 4*22433Sdist * specifies the terms and conditions for redistribution. 5*22433Sdist */ 6*22433Sdist 713954Ssam #ifndef lint 8*22433Sdist char copyright[] = 9*22433Sdist "@(#) Copyright (c) 1983 Regents of the University of California.\n\ 10*22433Sdist All rights reserved.\n"; 11*22433Sdist #endif not lint 1213954Ssam 13*22433Sdist #ifndef lint 14*22433Sdist static char sccsid[] = "@(#)lprm.c 5.1 (Berkeley) 06/06/85"; 15*22433Sdist #endif not lint 16*22433Sdist 1712110Sralph /* 1812110Sralph * lprm - remove the current user's spool entry 1912110Sralph * 2012110Sralph * lprm [-] [[job #] [user] ...] 2112110Sralph * 2212110Sralph * Using information in the lock file, lprm will kill the 2312110Sralph * currently active daemon (if necessary), remove the associated files, 2412110Sralph * and startup a new daemon. Priviledged users may remove anyone's spool 2512110Sralph * entries, otherwise one can only remove their own. 2612110Sralph */ 2712110Sralph 2812110Sralph #include "lp.h" 2912110Sralph 3012110Sralph /* 3112110Sralph * Stuff for handling job specifications 3212110Sralph */ 3312877Sralph char *user[MAXUSERS]; /* users to process */ 3412877Sralph int users; /* # of users in user array */ 3512877Sralph int requ[MAXREQUESTS]; /* job number of spool entries */ 3612877Sralph int requests; /* # of spool requests */ 3712877Sralph char *person; /* name of person doing lprm */ 3812110Sralph 3912877Sralph static char luser[16]; /* buffer for person */ 4012110Sralph 4112110Sralph struct passwd *getpwuid(); 4212110Sralph 4312110Sralph main(argc, argv) 4412110Sralph char *argv[]; 4512110Sralph { 4612110Sralph register char *arg; 4712110Sralph struct passwd *p; 4812110Sralph struct direct **files; 4912110Sralph int nitems, assasinated = 0; 5012110Sralph 5112110Sralph name = argv[0]; 5212110Sralph gethostname(host, sizeof(host)); 5312110Sralph if ((p = getpwuid(getuid())) == NULL) 5412110Sralph fatal("Who are you?"); 5512110Sralph if (strlen(p->pw_name) >= sizeof(luser)) 5612110Sralph fatal("Your name is too long"); 5712110Sralph strcpy(luser, p->pw_name); 5812110Sralph person = luser; 5912110Sralph while (--argc) { 6012110Sralph if ((arg = *++argv)[0] == '-') 6112110Sralph switch (arg[1]) { 6212110Sralph case 'P': 6312730Sralph if (arg[2]) 6412730Sralph printer = &arg[2]; 6512730Sralph else if (argc > 1) { 6612730Sralph argc--; 6712730Sralph printer = *++argv; 6812730Sralph } 6912110Sralph break; 7012110Sralph case '\0': 7112110Sralph if (!users) { 7212110Sralph users = -1; 7312110Sralph break; 7412110Sralph } 7512110Sralph default: 7612110Sralph usage(); 7712110Sralph } 7812110Sralph else { 7912110Sralph if (users < 0) 8012110Sralph usage(); 8112110Sralph if (isdigit(arg[0])) { 8212110Sralph if (requests >= MAXREQUESTS) 8312110Sralph fatal("Too many requests"); 8412110Sralph requ[requests++] = atoi(arg); 8512110Sralph } else { 8612110Sralph if (users >= MAXUSERS) 8712110Sralph fatal("Too many users"); 8812110Sralph user[users++] = arg; 8912110Sralph } 9012110Sralph } 9112110Sralph } 9212110Sralph if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 9312110Sralph printer = DEFLP; 9412110Sralph 9512110Sralph rmjob(); 9612110Sralph } 9712110Sralph 9812877Sralph static 9912110Sralph usage() 10012110Sralph { 10112110Sralph printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 10212110Sralph exit(2); 10312110Sralph } 104