Annotation of 43BSDReno/contrib/isode-beta/pepy/pepytest.py, revision 1.1.1.1

1.1       root        1: -- pepytest.py - test out PEPY
                      2: 
                      3: -- $Header: /f/osi/pepy/RCS/pepytest.py,v 7.0 89/11/23 22:11:57 mrose Rel $
                      4: --
                      5: --
                      6: -- $Log:       pepytest.py,v $
                      7: -- Revision 7.0  89/11/23  22:11:57  mrose
                      8: -- Release 6.0
                      9: -- 
                     10: 
                     11: --
                     12: --                               NOTICE
                     13: --
                     14: --    Acquisition, use, and distribution of this module and related
                     15: --    materials are subject to the restrictions of a license agreement.
                     16: --    Consult the Preface in the User's Manual for the full terms of
                     17: --    this agreement.
                     18: --
                     19: --
                     20: 
                     21: 
                     22: PEPYTEST DEFINITIONS   ::=
                     23: 
                     24: %{
                     25: #ifndef        lint
                     26: static char *rcsid = "$Header: /f/osi/pepy/RCS/pepytest.py,v 7.0 89/11/23 22:11:57 mrose Rel $";
                     27: #endif
                     28: 
                     29: #include <stdio.h>
                     30: 
                     31: /*    DATA */
                     32: 
                     33: #define        ps_advise(ps, f) \
                     34:        advise (NULLCP, "%s: %s", (f), ps_error ((ps) -> ps_errno))
                     35: 
                     36: 
                     37: static char *myname = "pepytest";
                     38: 
                     39: static enum { ps2test, pl2test } mode = ps2test;
                     40: 
                     41: 
                     42: void   adios ();
                     43: 
                     44: /*    MAIN */
                     45: 
                     46: /* ARGSUSED */
                     47: 
                     48: main (argc, argv, envp)
                     49: int    argc;
                     50: char  **argv,
                     51:       **envp;
                     52: {
                     53:     register int    status = 0;
                     54:     register char  *cp;
                     55:     register FILE  *fp;
                     56: 
                     57:     myname = *argv;
                     58:     for (argc--, argv++; cp = *argv; argc--, argv++)
                     59:        if (*cp == '-') {
                     60:            if (strcmp (cp + 1, "ps") == 0) {
                     61:                mode = ps2test;
                     62:                continue;
                     63:            }
                     64:            if (strcmp (cp + 1, "pl") == 0) {
                     65:                mode = pl2test;
                     66:                continue;
                     67:            }
                     68:            adios (NULLCP, "usage: %s [ -ps | -pl ] [ files... ]",
                     69:                    myname);
                     70:        }
                     71:        else
                     72:            break;
                     73: 
                     74:     if (argc == 0)
                     75:        status = process ("(stdin)", stdin);
                     76:     else
                     77:        while (cp = *argv++) {
                     78:            if ((fp = fopen (cp, "r")) == NULL) {
                     79:                advise (cp, "unable to read");
                     80:                status++;
                     81:                continue;
                     82:            }
                     83:            status += process (cp, fp);
                     84:            (void) fclose (fp);
                     85:        }
                     86: 
                     87:     exit (status);             /* NOTREACHED */
                     88: }
                     89: 
                     90: /*  */
                     91: 
                     92: static int  process (file, fp)
                     93: register char *file;
                     94: register FILE *fp;
                     95: {
                     96:     register PE            pe;
                     97:     register PS            ps;
                     98: 
                     99:     if ((ps = ps_alloc (std_open)) == NULLPS) {
                    100:        ps_advise (ps, "ps_alloc");
                    101:        return 1;
                    102:     }
                    103:     if (std_setup (ps, fp) == NOTOK) {
                    104:        advise (NULLCP, "%s: std_setup loses", file);
                    105:        return 1;
                    106:     }
                    107: 
                    108:     for (;;) {
                    109:        switch (mode) {
                    110:            case ps2test: 
                    111:                if ((pe = ps2pe (ps)) == NULLPE)
                    112:                    if (ps -> ps_errno) {
                    113:                        ps_advise (ps, "ps2pe");
                    114:                you_lose: ;
                    115:                        ps_free (ps);
                    116:                        return 1;
                    117:                    }
                    118:                    else {
                    119:                done:   ;
                    120:                        ps_free (ps);
                    121:                        return 0;
                    122:                    }
                    123:                break;
                    124: 
                    125:            case pl2test: 
                    126:                if ((pe = pl2pe (ps)) == NULLPE)
                    127:                    if (ps -> ps_errno) {
                    128:                        ps_advise (ps, "pl2pe");
                    129:                        goto you_lose;
                    130:                    }
                    131:                    else
                    132:                        goto done;
                    133:                break;
                    134:        }
                    135: 
                    136:        if (parse_PEPYTEST_PersonnelRecord (pe, 1, NULLIP, NULLVP, NULLCP)
                    137:                == NOTOK)
                    138:            advise (NULLCP, "parse error: %s", PY_pepy);
                    139:        else
                    140:            (void) print_PEPYTEST_PersonnelRecord (pe, 1, NULLIP, NULLVP,
                    141:                                                   NULLCP);
                    142: 
                    143:        pe_free (pe);
                    144:     }
                    145: }
                    146: 
                    147: /*  */
                    148: 
                    149: %}
                    150: 
                    151: BEGIN
                    152: 
                    153: SECTIONS none parse print
                    154: 
                    155: PersonnelRecord
                    156:        ::=
                    157:        [APPLICATION 0]
                    158:            IMPLICIT SET {
                    159:                    Name,
                    160: 
                    161:                title[0]
                    162:                    VisibleString,
                    163: 
                    164:                number
                    165:                    EmployeeNumber,
                    166: 
                    167:                dateOfHire[1]
                    168:                    Date,
                    169: 
                    170:                nameOfSpouse[2]
                    171:                    Name,
                    172: 
                    173:                children[3]
                    174:                    IMPLICIT SEQUENCE OF
                    175:                        ChildInformation
                    176:                    DEFAULT {}
                    177:            }
                    178: 
                    179: 
                    180: ChildInformation ::=
                    181:        SET {
                    182:                Name,
                    183: 
                    184:            dateofBirth[0]
                    185:                Date
                    186:        }
                    187: 
                    188: 
                    189: Name ::=
                    190:        [APPLICATION 1]
                    191:            IMPLICIT SEQUENCE {
                    192:                givenName
                    193:                    VisibleString,
                    194: 
                    195:                initial
                    196:                    VisibleString,
                    197: 
                    198:                familyName
                    199:                    VisibleString
                    200:            }
                    201: 
                    202: 
                    203: EmployeeNumber ::=
                    204:        [APPLICATION 2]
                    205:            IMPLICIT INTEGER
                    206: 
                    207: 
                    208: Date ::=
                    209:        [APPLICATION 3]
                    210:            IMPLICIT VisibleString -- YYYYMMDD
                    211: 
                    212: END
                    213: 
                    214: %{
                    215: 
                    216: /*    ERRORS */
                    217: 
                    218: #include <varargs.h>
                    219: 
                    220: 
                    221: #ifndef        lint
                    222: void   _advise ();
                    223: 
                    224: 
                    225: static void  adios (va_alist)
                    226: va_dcl
                    227: {
                    228:     va_list ap;
                    229: 
                    230:     va_start (ap);
                    231: 
                    232:     _advise (ap);
                    233: 
                    234:     va_end (ap);
                    235: 
                    236:     _exit (1);
                    237: }
                    238: #else
                    239: /* VARARGS */
                    240: 
                    241: static void  adios (what, fmt)
                    242: char   *what,
                    243:        *fmt;
                    244: {
                    245:     adios (what, fmt);
                    246: }
                    247: #endif
                    248: 
                    249: 
                    250: #ifndef        lint
                    251: static void  advise (va_alist)
                    252: va_dcl
                    253: {
                    254:     va_list ap;
                    255: 
                    256:     va_start (ap);
                    257: 
                    258:     _advise (ap);
                    259: 
                    260:     va_end (ap);
                    261: }
                    262: 
                    263: 
                    264: static void  _advise (ap)
                    265: va_list        ap;
                    266: {
                    267:     char    buffer[BUFSIZ];
                    268: 
                    269:     asprintf (buffer, ap);
                    270: 
                    271:     (void) fflush (stdout);
                    272: 
                    273:     fprintf (stderr, "%s: ", myname);
                    274:     (void) fputs (buffer, stderr);
                    275:     (void) fputc ('\n', stderr);
                    276: 
                    277:     (void) fflush (stderr);
                    278: }
                    279: #else
                    280: /* VARARGS */
                    281: 
                    282: static void  advise (what, fmt)
                    283: char   *what,
                    284:        *fmt;
                    285: {
                    286:     advise (what, fmt);
                    287: }
                    288: #endif
                    289: 
                    290: %}

unix.superglobalmegacorp.com

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