Annotation of 43BSD/contrib/spms/src/bin/pman/pman.c, revision 1.1

1.1     ! root        1: static char *rcsid = "$Header$";
        !             2: /*
        !             3:  * pman - print project manual
        !             4:  *
        !             5:  * Author: Peter J. Nicklin
        !             6:  */
        !             7: #include <stdio.h>
        !             8: #include "getarg.h"
        !             9: #include "path.h"
        !            10: #include "spms.h"
        !            11: #include "yesno.h"
        !            12: 
        !            13: #define CMDBUFSIZE     1024
        !            14: 
        !            15: char *PGN = "pman";                    /* program name */
        !            16: 
        !            17: main(argc, argv)
        !            18:        int argc;
        !            19:        char **argv;
        !            20: {
        !            21:        extern int PPDEBUG;             /* project pathname debug flag */
        !            22:        char *argvtos();                /* convert cmd arguments to string */
        !            23:        char cmdbuf[CMDBUFSIZE];        /* man command buffer */
        !            24:        char *getcwp();                 /* get current working project */
        !            25:        char *ppathname = CURPROJECT;   /* project pathname */
        !            26:        char *sprintf();                /* print output to string */
        !            27:        int status = 0;                 /* exit status */
        !            28:        int xppath();                   /* expand project pathname */
        !            29:        PATH pathbuf;                   /* pathname struct buffer */
        !            30: 
        !            31:        {
        !            32:        register char *s;               /* option pointer */
        !            33:        while (--argc > 0 && **++argv == '-')
        !            34:                {
        !            35:                for (s = argv[0]+1; *s != '\0'; s++)
        !            36:                        switch (*s)
        !            37:                                {
        !            38:                                case 'D':
        !            39:                                        PPDEBUG = YES;
        !            40:                                        break;
        !            41:                                case 'P':
        !            42:                                        ppathname = GETARG(s);
        !            43:                                        if (*ppathname == '\0')
        !            44:                                                {
        !            45:                                                warn("missing project name");
        !            46:                                                status = 1;
        !            47:                                                }
        !            48:                                        goto endfor;
        !            49:                                default:
        !            50:                                        warn("bad option -%c", *s);
        !            51:                                        status = 1;
        !            52:                                        goto endfor;
        !            53:                                }
        !            54:                endfor: continue;
        !            55:                }
        !            56:        }
        !            57:        if (status == 1 || argc < 1)
        !            58:                fatal("usage: pman [-P projectname] [section] topic ...");
        !            59: 
        !            60:        /* convert project pathname to regular pathname */
        !            61:        if (xppath(ppathname, &pathbuf) == -1)
        !            62:                {
        !            63:                patherr(ppathname);
        !            64:                exit(1);
        !            65:                }
        !            66:        else switch (pathbuf.p_mode & P_IFMT)
        !            67:                {
        !            68:                case P_IFHOME:
        !            69:                case P_IFPROOT:
        !            70:                        break;
        !            71:                default:
        !            72:                        fatal("%s: no such project", ppathname);
        !            73:                        break;
        !            74:                }
        !            75:        sprintf(cmdbuf, "man -P %s/man %s",pathbuf.p_path,argvtos(argc, argv));
        !            76:        system(cmdbuf);
        !            77:        exit(status);
        !            78: }

unix.superglobalmegacorp.com

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