Annotation of 43BSD/usr.lib/lpr/lprm.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.