Annotation of 43BSDReno/contrib/isode-beta/psap/psaptest.c, revision 1.1

1.1     ! root        1: /* psaptest.c - test out -lpsap */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/psap/RCS/psaptest.c,v 7.0 89/11/23 22:13:26 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/psap/RCS/psaptest.c,v 7.0 89/11/23 22:13:26 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       psaptest.c,v $
        !            12:  * Revision 7.0  89/11/23  22:13:26  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                               NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: #include <stdio.h>
        !            29: #include "psap.h"
        !            30: #include "tailor.h"
        !            31: 
        !            32: /*  */
        !            33: 
        !            34: static enum {
        !            35:     ps2pl, ps2ps, pl2pl, pl2ps
        !            36: } mode;
        !            37: 
        !            38: /*  */
        !            39: 
        !            40: /* ARGSUSED */
        !            41: 
        !            42: main (argc, argv, envp)
        !            43: int    argc;
        !            44: char  **argv,
        !            45:       **envp;
        !            46: {
        !            47:     char   *cp;
        !            48:     register PE pe;
        !            49:     register PS ps;
        !            50: 
        !            51:     argc--, argv++;
        !            52:     if (argc != 1) {
        !            53: usage:         ;
        !            54:        fprintf (stderr, "usage: psaptest [ps2pl | ps2ps | pl2pl | pl2ps]\n");
        !            55:        exit (1);
        !            56:     }
        !            57: 
        !            58:     if (strcmp (*argv, "version") == 0) {
        !            59:        printf ("%s\n", psapversion);
        !            60:        exit (0);
        !            61:     }
        !            62: 
        !            63:     if ((cp = getenv ("PSAPTEST")) && *cp) {
        !            64:        psap_log -> ll_events = atoi (cp);
        !            65:        psap_log -> ll_stat |= LLOGTTY;
        !            66:     }
        !            67: 
        !            68:     if (strcmp (*argv, "binary") == 0) {
        !            69:        int     i;
        !            70:        char    buffer[BUFSIZ],
        !            71:                packet[BUFSIZ];
        !            72: 
        !            73:        while (fgets (buffer, sizeof buffer, stdin)) {
        !            74:            if (*buffer == ' ')
        !            75:                (void) strncpy (packet, buffer + 1, i = strlen (buffer) - 2);
        !            76:            else
        !            77:                i = implode ((u_char *) packet, buffer, strlen (buffer) - 1);
        !            78:            (void) fwrite (packet, sizeof *packet, i, stdout);
        !            79:        }
        !            80: 
        !            81:        exit (0);
        !            82:     }
        !            83: 
        !            84:     if (strcmp (*argv, "ps2pl") == 0)
        !            85:        mode = ps2pl;
        !            86:     else
        !            87:        if (strcmp (*argv, "ps2ps") == 0)
        !            88:            mode = ps2ps;
        !            89:        else
        !            90:            if (strcmp (*argv, "pl2pl") == 0)
        !            91:                mode = pl2pl;
        !            92:            else
        !            93:                if (strcmp (*argv, "pl2ps") == 0)
        !            94:                    mode = pl2ps;
        !            95:                else
        !            96:                    goto usage;
        !            97: 
        !            98:     for (;;) {
        !            99:        if ((ps = ps_alloc (std_open)) == NULLPS) {
        !           100:            fprintf (stderr, "ps_alloc(stdin): you lose\n");
        !           101:            exit (1);
        !           102:        }
        !           103:        if (std_setup (ps, stdin) == NOTOK)
        !           104:            ps_die (ps, "std_setup(stdin)");
        !           105: 
        !           106:        switch (mode) {
        !           107:            case ps2pl: 
        !           108:            case ps2ps: 
        !           109:                if ((pe = ps2pe (ps)) == NULLPE)
        !           110:                    if (ps -> ps_errno)
        !           111:                        ps_die (ps, "ps2pe");
        !           112:                    else
        !           113:                        exit (0);
        !           114:                break;
        !           115: 
        !           116:            case pl2ps: 
        !           117:            case pl2pl: 
        !           118:                if ((pe = pl2pe (ps)) == NULLPE)
        !           119:                    if (ps -> ps_errno)
        !           120:                        ps_die (ps, "pl2pe");
        !           121:                    else
        !           122:                        exit (0);
        !           123:                break;
        !           124:        }
        !           125: 
        !           126:        ps_free (ps);
        !           127: 
        !           128:        if ((ps = ps_alloc (std_open)) == NULLPS) {
        !           129:            fprintf (stderr, "ps_alloc(stdout): you lose\n");
        !           130:            exit (1);
        !           131:        }
        !           132:        if (std_setup (ps, stdout) == NOTOK)
        !           133:            ps_die (ps, "std_setup(stdout)");
        !           134: 
        !           135:        switch (mode) {
        !           136:            case ps2ps: 
        !           137:            case pl2ps: 
        !           138:                if (pe2ps (ps, pe) == NOTOK)
        !           139:                    ps_die (ps, "pe2ps");
        !           140:                break;
        !           141: 
        !           142:            case pl2pl: 
        !           143:            case ps2pl: 
        !           144:                if (pe2pl (ps, pe) == NOTOK)
        !           145:                    ps_die (ps, "pe2pl");
        !           146:                break;
        !           147:        }
        !           148: 
        !           149:        ps_free (ps);
        !           150:     }
        !           151: }
        !           152: 
        !           153: /*    ERRORS */
        !           154: 
        !           155: static ps_die (ps, s)
        !           156: register PS     ps;
        !           157: register char   *s;
        !           158: {
        !           159:     fprintf (stderr, "%s: %s\n", s, ps_error (ps -> ps_errno));
        !           160:     exit (1);
        !           161: }

unix.superglobalmegacorp.com

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