Annotation of 43BSDReno/usr.sbin/sendmail/praliases/praliases.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Eric P. Allman
        !             3:  * Copyright (c) 1988 Regents of the University of California.
        !             4:  * All rights reserved.
        !             5:  *
        !             6:  * Redistribution and use in source and binary forms are permitted provided
        !             7:  * that: (1) source distributions retain this entire copyright notice and
        !             8:  * comment, and (2) distributions including binaries display the following
        !             9:  * acknowledgement:  ``This product includes software developed by the
        !            10:  * University of California, Berkeley and its contributors'' in the
        !            11:  * documentation or other materials provided with the distribution and in
        !            12:  * all advertising materials mentioning features or use of this software.
        !            13:  * Neither the name of the University nor the names of its contributors may
        !            14:  * be used to endorse or promote products derived from this software without
        !            15:  * specific prior written permission.
        !            16:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            19:  */
        !            20: 
        !            21: #ifndef lint
        !            22: char copyright[] =
        !            23: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
        !            24:  All rights reserved.\n";
        !            25: #endif /* not lint */
        !            26: 
        !            27: #ifndef lint
        !            28: static char sccsid[] = "@(#)praliases.c        5.5 (Berkeley) 6/1/90";
        !            29: #endif /* not lint */
        !            30: 
        !            31: #include <sendmail.h>
        !            32: 
        !            33: typedef struct {
        !            34:        char *dptr;
        !            35:        int dsize;
        !            36: } datum;
        !            37: 
        !            38: 
        !            39: main(argc, argv)
        !            40:        char **argv;
        !            41: {
        !            42:        extern char *optarg;
        !            43:        extern int optind;
        !            44:        static char *filename = "/usr/lib/aliases";
        !            45:        datum content, key, firstkey(), nextkey(), fetch();
        !            46:        int ch;
        !            47: 
        !            48:        while ((ch = getopt(argc, argv, "f:")) != EOF)
        !            49:                switch((char)ch) {
        !            50:                case 'f':
        !            51:                        filename = optarg;
        !            52:                        break;
        !            53:                case '?':
        !            54:                default:
        !            55:                        fputs("usage: praliases [-f file]\n", stderr);
        !            56:                        exit(EX_USAGE);
        !            57:                }
        !            58:        argc -= optind;
        !            59:        argv += optind;
        !            60: 
        !            61:        if (dbminit(filename) < 0)
        !            62:                exit(EX_OSFILE);
        !            63:        if (!argc)
        !            64:                for (key = firstkey(); key.dptr; key = nextkey(key)) {
        !            65:                        content = fetch(key);
        !            66:                        printf("%s:%s\n", key.dptr, content.dptr);
        !            67:                }
        !            68:        else for (; *argv; ++argv) {
        !            69:                key.dptr = *argv;
        !            70:                key.dsize = strlen(*argv) + 1;
        !            71:                content = fetch(key);
        !            72:                if (!content.dptr)
        !            73:                        printf("%s: No such key\n", key.dptr);
        !            74:                else
        !            75:                        printf("%s:%s\n", key.dptr, content.dptr);
        !            76:        }
        !            77:        exit(EX_OK);
        !            78: }

unix.superglobalmegacorp.com

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