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