Annotation of 43BSDReno/contrib/isode-beta/pepsy/prnt.c, revision 1.1.1.1

1.1       root        1: /* prnt.c */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/pepsy/RCS/prnt.c,v 7.3 90/07/27 08:48:34 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/pepsy/RCS/prnt.c,v 7.3 90/07/27 08:48:34 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       prnt.c,v $
                     12:  * Revision 7.3  90/07/27  08:48:34  mrose
                     13:  * update
                     14:  * 
                     15:  * Revision 7.2  90/07/09  14:53:08  mrose
                     16:  * sync
                     17:  * 
                     18:  * Revision 7.1  90/07/01  20:02:00  mrose
                     19:  * update
                     20:  * 
                     21:  */
                     22: 
                     23: /*
                     24:  *                               NOTICE
                     25:  *
                     26:  *    Acquisition, use, and distribution of this module and related
                     27:  *    materials are subject to the restrictions of a license agreement.
                     28:  *    Consult the Preface in the User's Manual for the full terms of
                     29:  *    this agreement.
                     30:  *
                     31:  */
                     32: 
                     33: 
                     34: /*
                     35:  * These routines are the driving routines for printing data
                     36:  */
                     37: #include       <stdio.h>
                     38: #include       <ctype.h>
                     39: #include       "psap.h"
                     40: #include       "pepsy.h"
                     41: 
                     42: #define PEPYPARM       char **
                     43: #ifndef        PEPYPARM
                     44: #define PEPYPARM       char **
                     45: #endif
                     46: extern PEPYPARM NullParm;
                     47: 
                     48: #define PRINT_TYPES    0
                     49: #define        CHOICE_PUSH
                     50: 
                     51: 
                     52: extern PE p_setpresent();
                     53: extern IFP vfnx;
                     54: extern FILE *vfp;
                     55: 
                     56: extern ptpe *next_ptpe();
                     57: extern int pepsylose ();
                     58: 
                     59: int     xlevel = 0;
                     60: int     tabed = 0;
                     61: int     xpushed = 0;
                     62: 
                     63: #define NEXT_PTPE(p)   (p = next_ptpe(p))
                     64: #define CHKTAG(mod, p, pe)     p_ismatch(p, mod, pe->pe_class, pe->pe_id)
                     65: 
                     66: /* SUPPRESS 36 *//* for Saber C */
                     67: 
                     68: /*
                     69:  * to guarentee the rules that vname and a vprint-type routine are called
                     70:  * alternatively. Basically can't have two vname's in a row
                     71:  */
                     72: static vnamelock = 0;
                     73:    /* if vnamelock > 0 don't call vname */
                     74: #define VNAME(x)  vnamelock++ > 0 ? 0 : vname(x)
                     75: #define VTAG(class, tag)       vnamelock++ > 0 ? 0 : vtag(class, tag)
                     76: 
                     77: /* as vprint takes a variable number of arguements we have to put all of
                     78:  * the arguements inside () and remove them when we expand to vprint
                     79:  */
                     80: #define VPRINT(x)      vnamelock = 0, vprint x
                     81: #define VSTRING(x)     vnamelock = 0, vstring(x)
                     82: #define VUNKNOWN(x)    vnamelock = 0, vunknown(x)
                     83: #define VPUSH          vnamelock = 0, vpush
                     84: #define VPOP           vnamelock = 0, vpop
                     85: 
                     86: /*
                     87:  * Print out ASN data given in pe using the information given in the tables
                     88:  */
                     89: prnt_f(typ, mod, pe, explicit, len, buf)
                     90: /* ARGSUSED */
                     91: int     typ;                   /* which type it is */
                     92: modtyp *mod;                   /* ASN Module it is from */
                     93: PE      pe;
                     94: int     explicit;      /* nonzero means we are call top level 
                     95:                         * print final \n
                     96:                         */
                     97: int    *len;
                     98: char  **buf;
                     99: {
                    100:     ptpe   *p;
                    101: 
                    102:     if (typ < 0 || typ >= mod->md_nentries) {
                    103:        return (pepsylose (mod, NULLTPE, pe, "prnt_f:Illegal type %d\n",typ));
                    104:     }
                    105: 
                    106:     p = mod->md_ptab[typ];
                    107: 
                    108:     if (p->pe_type != PE_START) {
                    109:        return (pepsylose (mod, p, pe, "prnt_f: missing PE_START\n"));
                    110:     }
                    111: 
                    112: #if EXTRA_BRACKETS
                    113:     if (explicit) {
                    114:        if (p->pe_typename)
                    115:            VNAME(p->pe_typename);
                    116:     }
                    117:     VPUSH();
                    118: #endif
                    119:     if (p_pr_obj(explicit, pe, p, mod) == NOTOK) {
                    120: #if EXTRA_BRACKETS
                    121:        VPOP();
                    122: #endif
                    123:        return (NOTOK);
                    124:     }
                    125: #if EXTRA_BRACKETS
                    126:     VPOP();
                    127: #endif
                    128:     return (OK);
                    129: }
                    130: 
                    131: /*
                    132:  * Parse an object. The top level of an object does not have any
                    133:  * offset field which makes it different to pr_type routine which
                    134:  * must assume that it has an offset.
                    135:  */
                    136: static int
                    137: p_pr_obj(expl, pe, p, mod)
                    138: int     expl;                  /* do we look at the tag */
                    139: PE      pe;
                    140: ptpe   *p;
                    141: modtyp *mod;                   /* Module it is from */
                    142: {
                    143:     int     cnt = 0;
                    144: 
                    145: #if PRINT_TYPES
                    146:     if (p->pe_typename)
                    147:        VNAME(p->pe_typename);
                    148: #endif
                    149: 
                    150:     p++;
                    151:     while (p->pe_type != PE_END) {
                    152: 
                    153:        if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
                    154:            if (DEFAULT(p)) {
                    155:                return (pepsylose (mod, p, pe,
                    156:                    "p_pr_obj:Default not implemented\n"));
                    157:            }
                    158:            else if (OPTIONAL(p))
                    159:                goto next;
                    160:            else {
                    161:                return (pepsylose (mod, p, pe,
                    162:                    "p_pr_obj:missing mandatory parameter", p, mod));
                    163:            }
                    164:        }
                    165:        if (p->pe_typename)
                    166:            VNAME(p->pe_typename);
                    167:        switch (p->pe_type) {
                    168:        case PE_END:
                    169:        case PE_START:
                    170:            goto bad;
                    171: 
                    172:        case UCODE:
                    173:            if ((*mod->md_ducode) (pe, p, mod) != OK)
                    174:                goto bad;
                    175:            break;
                    176: 
                    177:        case ETAG:
                    178:            switch (p->pe_ucode) {
                    179:            default:
                    180:                if (p_pr_etype(pe->pe_cons, p, mod) == NOTOK)
                    181:                    goto bad;
                    182:            }
                    183:            break;
                    184: 
                    185:        case SEQ_START:
                    186:            if (p_pr_seq(pe, p, mod) == NOTOK)
                    187:                goto bad;
                    188:            break;
                    189: 
                    190:        case SEQOF_START:
                    191:            if (p_pr_seqof(pe, p, mod) == NOTOK) {
                    192:                goto bad;
                    193:            }
                    194:            break;
                    195: 
                    196:        case SET_START:
                    197:            if (p_pr_set(pe, p, mod) == NOTOK) {
                    198:                goto bad;
                    199:            }
                    200:            break;
                    201: 
                    202:        case SETOF_START:
                    203:            if (p_pr_setof(pe, p, mod) == NOTOK) {
                    204:                goto bad;
                    205:            }
                    206:            break;
                    207: 
                    208:        case IMP_OBJ:
                    209:            p++;
                    210:            if (p->pe_type == EXTOBJ || p->pe_type == SEXTOBJ) {
                    211:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    212:                    (char **) 0) == NOTOK)
                    213:                    goto bad;
                    214:            } else {
                    215:                if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    216:                    goto bad;
                    217:                }
                    218:            }
                    219:            break;
                    220: 
                    221:        case SOBJECT:
                    222:        case OBJECT:
                    223:            if (p_pr_obj(expl, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    224:                goto bad;
                    225:            }
                    226:            break;
                    227: 
                    228:        case CHOICE_START:
                    229:            if (p_pr_choice(pe, p, mod) == NOTOK)
                    230:                goto bad;
                    231:            break;
                    232: 
                    233:        case SEXTOBJ:
                    234:        case EXTOBJ:
                    235:            if (p[1].pe_type != EXTMOD) {
                    236:                return (pepsylose (mod, p, pe, "p_pr_obj: missing EXTMOD"));
                    237:            }
                    238:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    239:                   (char **) 0) == NOTOK)
                    240:                   goto bad;
                    241:            break;
                    242: 
                    243:        default:
                    244:            if (p_pr_type(expl, pe, p, mod) == NOTOK)
                    245:                goto bad;
                    246:            break;
                    247:        }
                    248:        if (ISDTYPE(p) && cnt > 0)
                    249:            return (pepsylose (mod, p, pe, "p_pr_obj:compound type found\n"));
                    250:        if (ISDTYPE(p) && pe != NULLPE) {
                    251:            return (OK);
                    252:        }
                    253: next:
                    254:        if (NEXT_PTPE(p) == NULLPTPE)
                    255:            goto bad;
                    256:     }
                    257: 
                    258:     return (OK);
                    259: 
                    260: bad:
                    261:     return (NOTOK);
                    262: }
                    263: 
                    264: 
                    265: /*
                    266:  * Parse a single type. If a basic type parse it, if a compound type
                    267:  * call the appropriate parsing routine
                    268:  */
                    269: static int
                    270: p_pr_type(expl, pe, p, mod)
                    271: int     expl;                  /* do we look at the tag */
                    272: PE      pe;
                    273: ptpe   *p;
                    274: modtyp *mod;                   /* Module it is from */
                    275: {
                    276:     int     cnt = 0;
                    277:     int     i;
                    278:     OID     oid;
                    279: 
                    280:     while (p->pe_type != PE_END) {
                    281: 
                    282:        if (ISDTYPE(p) && expl && CHKTAG(mod, p, pe) == 0) {
                    283:            if (DEFAULT(p)) {
                    284: #ifdef PRINT_DEFAULTS
                    285:                setpval(p, p + 1, mod);
                    286: #endif
                    287:                goto next;
                    288:            } else if (OPTIONAL(p))
                    289:                goto next;
                    290:            else {
                    291:                dmp_ptpe("p_pr_type:missing mandatory parameter", p, mod);
                    292:                goto bad;
                    293:            }
                    294:        }
                    295:        switch (p->pe_type) {
                    296:        case PE_END:
                    297:        case PE_START:
                    298:            goto bad;
                    299: 
                    300:        case UCODE:
                    301:            if ((*mod->md_ducode) (pe, p, mod) != OK)
                    302:                goto bad;
                    303:            break;
                    304: 
                    305:        case ETAG:
                    306:            switch (p->pe_ucode) {
                    307:            default:
                    308:                if (p_pr_etype(pe->pe_cons, p, mod) == NOTOK)
                    309:                    goto bad;
                    310:            }
                    311:            break;
                    312: 
                    313:        case SEQ_START:
                    314:            if (p_pr_seq(pe, p, mod) == NOTOK) {
                    315:                goto bad;
                    316:            }
                    317:            break;
                    318: 
                    319:        case SEQOF_START:
                    320:            if (p_pr_seqof(pe, p, mod) == NOTOK) {
                    321:                goto bad;
                    322:            }
                    323:            break;
                    324: 
                    325:        case SET_START:
                    326:            if (p_pr_set(pe, p, mod) == NOTOK) {
                    327:                goto bad;
                    328:            }
                    329:            break;
                    330: 
                    331:        case SETOF_START:
                    332:            if (p_pr_setof(pe, p, mod) == NOTOK) {
                    333:                goto bad;
                    334:            }
                    335:            break;
                    336: 
                    337:        case IMP_OBJ:
                    338:            p++;
                    339:            if (p->pe_type == EXTOBJ) {
                    340:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    341:                    (char **) 0) == NOTOK)
                    342:                    goto bad;
                    343:            } else {
                    344:                if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    345:                    goto bad;
                    346:                }
                    347:            }
                    348:            break;
                    349: 
                    350:        case SOBJECT:
                    351:        case OBJECT:
                    352:            if (p_pr_obj(expl, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    353:                goto bad;
                    354:            }
                    355:            break;
                    356: 
                    357:        case CHOICE_START:
                    358:            if (p_pr_choice(pe, p, mod) == NOTOK)
                    359:                goto bad;
                    360:            break;
                    361: 
                    362:        case SEXTOBJ:
                    363:        case EXTOBJ:
                    364:            if (p[1].pe_type != EXTMOD) {
                    365:                return (pepsylose (mod, p, pe, "p_pr_type: missing EXTMOD"));
                    366:            }
                    367:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    368:                   (char **) 0) == NOTOK)
                    369:                   goto bad;
                    370:            break;
                    371: 
                    372:        case INTEGER:
                    373:            if (pe != NULLPE) {
                    374:                if ((i = prim2num(pe)) == NOTOK && pe->pe_errno != PE_ERR_NONE)
                    375:                    goto bad;
                    376:                VPRINT(("%d", i));
                    377:            }
                    378:            break;
                    379: 
                    380: #ifdef PEPSY_REALS
                    381:        case REALTYPE:
                    382:            if (pe != NULLPE) {
                    383:                double r;
                    384: 
                    385:                if ((r = prim2real(pe)) == NOTOK
                    386:                    && pe->pe_errno != PE_ERR_NONE)
                    387:                    goto bad;
                    388:                VPRINT(("%g", r));
                    389:            }
                    390:            break;
                    391: #endif
                    392: 
                    393:        case BOOLEAN:
                    394:            if (pe != NULLPE) {
                    395:                if ((i = prim2flag(pe)) == NOTOK)
                    396:                    goto bad;
                    397:                VPRINT((i ? "TRUE" : "FALSE"));
                    398:            }
                    399:            break;
                    400: 
                    401:        case T_NULL:
                    402:            VPRINT(("NULL"));
                    403:            break;
                    404: 
                    405:        case SANY:
                    406:            if (pe != NULLPE) {
                    407:                if (pe->pe_errno != PE_ERR_NONE) {
                    408:                    goto bad;
                    409:                } else
                    410:                    VUNKNOWN(pe);
                    411:            }
                    412:            break;
                    413: 
                    414: 
                    415:        case ANY:
                    416:            if (pe != NULLPE) {
                    417:                if (pe->pe_errno != PE_ERR_NONE) {
                    418:                    goto bad;
                    419:                } else
                    420:                    VUNKNOWN(pe);
                    421:            }
                    422:            break;
                    423: 
                    424:        case SOCTETSTRING:
                    425:            if (pe != NULLPE) {
                    426:                VSTRING(pe);
                    427:            }
                    428:            break;
                    429: 
                    430:        case OCTETSTRING:
                    431:            if (pe != NULLPE) {
                    432:                VSTRING(pe);
                    433:            }
                    434:            break;
                    435: 
                    436:        case SBITSTRING:
                    437:            if (pe != NULLPE) {
                    438:                PE      bstr;
                    439: 
                    440:                if ((bstr = prim2bit(pe)) == NULLPE)
                    441:                    goto bad;
                    442:                /* one day get the named bits here */
                    443:                VPRINT(("%s", bit2str(bstr, "\020")));
                    444:            }
                    445:            break;
                    446: 
                    447:        case BITSTRING:
                    448:            if (pe != NULLPE) {
                    449:                PE      bstr;
                    450: 
                    451:                if ((bstr = prim2bit(pe)) == NULLPE)
                    452:                    goto bad;
                    453:                /* one day get the named bits here */
                    454:                VPRINT(("%s", bit2str(bstr, "\020")));
                    455:            }
                    456:            break;
                    457: 
                    458:        case SOBJID:
                    459:            if ((oid = (OID) prim2oid(pe)) == NULLOID) {
                    460:                goto bad;
                    461:            } else {
                    462:                VPRINT(("%s", oid2ode(oid)));
                    463:            }
                    464:            break;
                    465: 
                    466:        case OBJID:
                    467:            if ((oid = (OID) prim2oid(pe)) == NULLOID) {
                    468:                goto bad;
                    469:            } else {
                    470:                VPRINT(("%s", oid2ode(oid)));
                    471:            }
                    472:            break;
                    473: 
                    474:        default:
                    475:            return (pepsylose (mod, p, pe, "p_pr_type: %d not implemented\n",
                    476:                p->pe_type));
                    477:        }
                    478:        if (ISDTYPE(p) && cnt > 0)
                    479:            return (pepsylose (mod, p, pe, "p_pr_type:compound type found\n"));
                    480:        if (ISDTYPE(p) && pe != NULLPE)
                    481:            return (OK);
                    482: next:
                    483:        if (NEXT_PTPE(p) == NULLPTPE)
                    484:            goto bad;
                    485:     }
                    486: 
                    487:     return (OK);
                    488: 
                    489: bad:
                    490:     return (NOTOK);
                    491: }
                    492: 
                    493: /*
                    494:  * Parse a sequence, calling appropriate routines to parse each sub
                    495:  * type
                    496:  */
                    497: static int
                    498: p_pr_seq(head, p, mod)
                    499: PE      head;
                    500: ptpe   *p;
                    501: modtyp *mod;                   /* Module it is from */
                    502: {
                    503:     PE      pe;
                    504: 
                    505:     if (p->pe_type != SEQ_START)
                    506:        return (pepsylose (mod, p, head, "p_pr_seq: missing SEQ_START\n"));
                    507: #if PRINT_TYPES
                    508:     if (p->pe_typename)
                    509:        VNAME(p->pe_typename);
                    510: #endif
                    511:     VPUSH();
                    512: 
                    513:     p++;
                    514:     if (p->pe_type == DFLT_B)
                    515:        p++;
                    516: 
                    517: 
                    518:     pe = first_member(head);
                    519:     while (p->pe_type != PE_END) {
                    520:        if (ISDTYPE(p) && OPTIONAL(p)) {
                    521:            if (pe == NULLPE || CHKTAG(mod, p, pe) == 0)
                    522:                goto next;
                    523:        } else if (ISDTYPE(p) && (pe == NULLPE || CHKTAG(mod, p, pe) == 0)) {
                    524:            if (DEFAULT(p)) {
                    525: #ifdef PRINT_DEFAULTS
                    526:                setpval(p, p + 1, mod);
                    527: #endif
                    528:                goto next;
                    529:            } else {
                    530:                dmp_ptpe("p_pr_seq:missing mandatory parameter", p, mod);
                    531:                goto bad;
                    532:            }
                    533:        }
                    534:        if (p->pe_typename)
                    535:            VNAME(p->pe_typename);
                    536:        switch (p->pe_type) {
                    537:        case OPTL:
                    538:            break;
                    539: 
                    540:        case UCODE:
                    541:            if ((*mod->md_ducode) (pe, p, mod) != OK)
                    542:                goto bad;
                    543:            break;
                    544: 
                    545:        case ETAG:
                    546:            if (p_pr_type(1, pe, p, mod) == NOTOK)
                    547:                goto bad;
                    548:            break;
                    549: 
                    550:        case SEQ_START:
                    551:            if (p_pr_seq(pe, p, mod) == NOTOK) {
                    552:                goto bad;
                    553:            }
                    554:            break;
                    555: 
                    556:        case SEQOF_START:
                    557:            if (p_pr_seqof(pe, p, mod) == NOTOK) {
                    558:                goto bad;
                    559:            }
                    560:            break;
                    561: 
                    562:        case SET_START:
                    563:            if (p_pr_set(pe, p, mod) == NOTOK) {
                    564:                goto bad;
                    565:            }
                    566:            break;
                    567: 
                    568:        case SETOF_START:
                    569:            if (p_pr_setof(pe, p, mod) == NOTOK) {
                    570:                goto bad;
                    571:            }
                    572:            break;
                    573: 
                    574:        case IMP_OBJ:
                    575:            p++;
                    576:            if (p->pe_type == EXTOBJ) {
                    577:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    578:                    (char **) 0) == NOTOK)
                    579:                    goto bad;
                    580:            } else {
                    581:                if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    582:                    goto bad;
                    583:                }
                    584:            }
                    585:            break;
                    586: 
                    587:        case SOBJECT:
                    588:            if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    589:                goto bad;
                    590:            }
                    591:            break;
                    592: 
                    593:        case OBJECT:
                    594:            if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    595:                goto bad;
                    596:            }
                    597:            break;
                    598: 
                    599:        case CHOICE_START:
                    600:            if (p_pr_choice(pe, p, mod) == NOTOK)
                    601:                goto bad;
                    602:            break;
                    603: 
                    604:        case SEXTOBJ:
                    605:            if (p[1].pe_type != EXTMOD) {
                    606:                return (pepsylose (mod, p, pe, "p_pr_seq: missing EXTMOD"));
                    607:            }
                    608:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0,NULLIP,
                    609:                (char **)0) == NOTOK)
                    610:                goto bad;
                    611:            break;
                    612: 
                    613:        case EXTOBJ:
                    614:            if (p[1].pe_type != EXTMOD) {
                    615:                return (pepsylose (mod, p, pe, "p_pr_seq: missing EXTMOD"));
                    616:            }
                    617:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    618:                    (char **)0) == NOTOK)
                    619:                goto bad;
                    620:            break;
                    621: 
                    622:        default:
                    623:            if (p_pr_type(1, pe, p, mod) == NOTOK)
                    624:                goto bad;
                    625:            break;
                    626:        }
                    627: 
                    628:        if (ISDTYPE(p) && pe != NULLPE)
                    629:            pe = next_member(head, pe);
                    630: next:
                    631:        if (NEXT_PTPE(p) == NULLPTPE)
                    632:            goto bad;
                    633:     }
                    634: 
                    635:     VPOP();
                    636:     return (OK);
                    637: 
                    638: bad:
                    639:     VPOP();
                    640:     return (NOTOK);
                    641: }
                    642: 
                    643: 
                    644: /*
                    645:  * Parse a set, calling appropriate routines to parse each sub type
                    646:  */
                    647: static int
                    648: p_pr_set(head, p, mod)
                    649: PE      head;
                    650: ptpe   *p;
                    651: modtyp *mod;                   /* Module it is from */
                    652: {
                    653:     PE      pe;
                    654: 
                    655:     if (p->pe_type != SET_START)
                    656:        return (pepsylose (mod, p, head, "p_pr_seq: missing SET_START\n"));
                    657: #if PRINT_TYPES
                    658:     if (p->pe_typename)
                    659:        VNAME(p->pe_typename);
                    660: #endif
                    661:     VPUSH();
                    662: 
                    663:     p++;
                    664:     if (p->pe_type == DFLT_B)
                    665:        p++;
                    666: 
                    667:     while (p->pe_type != PE_END) {
                    668: 
                    669:        if (ISDTYPE(p) && OPTIONAL(p)) {
                    670:            if ((pe = (PE) p_setpresent(head, p, mod)) == NULLPE)
                    671:                goto next;
                    672:        } else if (ISDTYPE(p) && (pe = (PE) p_setpresent(head, p, mod)) == NULLPE) {
                    673:            if (DEFAULT(p)) {
                    674: #ifdef PRINT_DEFAULTS
                    675:                setpval(p, p + 1, mod);
                    676: #endif
                    677:                goto next;
                    678:            } else {
                    679:                dmp_ptpe("p_pr_set:missing mandatory parameter", p, mod);
                    680:                goto bad;
                    681:            }
                    682:        }
                    683:        if (p->pe_typename)
                    684:            VNAME(p->pe_typename);
                    685:        switch (p->pe_type) {
                    686:        case OPTL:
                    687:            break;
                    688: 
                    689:        case UCODE:
                    690:            if ((*mod->md_ducode) (pe, p, mod) != OK)
                    691:                goto bad;
                    692:            break;
                    693: 
                    694:        case ETAG:
                    695:            if (p_pr_type(1, pe, p, mod) == NOTOK)
                    696:                goto bad;
                    697:            break;
                    698: 
                    699:        case SEQ_START:
                    700:            if (p_pr_seq(pe, p, mod) == NOTOK) {
                    701:                goto bad;
                    702:            }
                    703:            break;
                    704: 
                    705:        case SEQOF_START:
                    706:            if (p_pr_seqof(pe, p, mod) == NOTOK) {
                    707:                goto bad;
                    708:            }
                    709:            break;
                    710: 
                    711:        case SET_START:
                    712:            if (p_pr_set(pe, p, mod) == NOTOK) {
                    713:                goto bad;
                    714:            }
                    715:            break;
                    716: 
                    717:        case SETOF_START:
                    718:            if (p_pr_setof(pe, p, mod) == NOTOK) {
                    719:                goto bad;
                    720:            }
                    721:            break;
                    722: 
                    723:        case IMP_OBJ:
                    724:            p++;
                    725:            if (p->pe_type == EXTOBJ) {
                    726:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    727:                       (char **) 0) == NOTOK)
                    728:                       goto bad;
                    729:            } else {
                    730:                if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    731:                    goto bad;
                    732:                }
                    733:            }
                    734:            break;
                    735: 
                    736:        case SOBJECT:
                    737:            if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    738:                goto bad;
                    739:            }
                    740:            break;
                    741: 
                    742:        case OBJECT:
                    743:            if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    744:                goto bad;
                    745:            }
                    746:            break;
                    747: 
                    748:        case CHOICE_START:
                    749:            if (p_pr_choice(pe, p, mod) == NOTOK)
                    750:                goto bad;
                    751:            break;
                    752: 
                    753:        case SEXTOBJ:
                    754:            if (p[1].pe_type != EXTMOD) {
                    755:                return (pepsylose (mod, p, pe, "p_pr_set: missing EXTMOD"));
                    756:            }
                    757:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP, (char **)0) == NOTOK)
                    758:                    return (NOTOK);
                    759:            break;
                    760: 
                    761:        case EXTOBJ:
                    762:            if (p[1].pe_type != EXTMOD) {
                    763:                return (pepsylose (mod, p, pe, "p_pr_set: missing EXTMOD"));
                    764:            }
                    765:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    766:                (char **)0) == NOTOK)
                    767:                goto bad;
                    768:            break;
                    769: 
                    770:        default:
                    771:            if (p_pr_type(1, pe, p, mod) == NOTOK)
                    772:                goto bad;
                    773:            break;
                    774:        }
                    775: 
                    776: next:
                    777:        if (NEXT_PTPE(p) == NULLPTPE)
                    778:            goto bad;
                    779:     }
                    780: 
                    781:     VPOP();
                    782:     return (OK);
                    783: 
                    784: bad:
                    785:     VPOP();
                    786:     return (NOTOK);
                    787: }
                    788: 
                    789: 
                    790: /*
                    791:  * Parse a sequence of calling appropriate routines to parse each sub
                    792:  * type
                    793:  */
                    794: 
                    795: static int
                    796: p_pr_seqof(head, p, mod)
                    797: PE      head;
                    798: ptpe   *p;
                    799: modtyp *mod;                   /* Module it is from */
                    800: {
                    801:     PE      pe;
                    802:     ptpe   *start;             /* first entry in list */
                    803:     int     dflt = 0;
                    804: 
                    805:     if (p->pe_type != SEQOF_START) {
                    806:        return (pepsylose (mod, p, head, "p_pr_seqof: missing SEQOF_START\n"));
                    807:     }
                    808: #if PRINT_TYPES
                    809:     if (p->pe_typename)
                    810:        VNAME(p->pe_typename);
                    811: #endif
                    812:     VPUSH();
                    813: 
                    814:     p++;
                    815: 
                    816:     if (p->pe_type == DFLT_B)
                    817:        p++;
                    818: 
                    819:     start = p;
                    820: 
                    821: 
                    822:     pe = first_member(head);
                    823:     while (pe != NULLPE) {
                    824:        while (p->pe_type != PE_END) {
                    825: 
                    826:            if (ISDTYPE(p) && CHKTAG(mod, p, pe) == 0) {
                    827:                if (DEFAULT(p))
                    828:                    return (pepsylose (mod, p, pe,
                    829:                        "p_pr_seqof:Default not implemented\n"));
                    830:                else if (OPTIONAL(p))
                    831:                    goto next;
                    832:                else {
                    833:                    return (pepsylose (mod, p, pe,
                    834:                        "p_pr_seqof:missing mandatory parameter"));
                    835:                }
                    836:            }
                    837:            if (p->pe_typename)
                    838:                VNAME(p->pe_typename);
                    839:            switch (p->pe_type) {
                    840:            case UCODE:
                    841:                if ((*mod->md_ducode) (pe, p, mod) != OK)
                    842:                    goto bad;
                    843:                break;
                    844: 
                    845:            case ETAG:
                    846:                if (p_pr_type(1, pe, p, mod) == NOTOK)
                    847:                    goto bad;
                    848:                break;
                    849: 
                    850:                /*
                    851:                 * case SCTRL:  parm = (char *) ((char *) parm);
                    852:                 * break;
                    853:                 */
                    854: 
                    855:            case SEQ_START:
                    856:                if (p_pr_seq(pe, p, mod) == NOTOK) {
                    857:                    goto bad;
                    858:                }
                    859:                break;
                    860: 
                    861:            case SEQOF_START:
                    862:                if (p_pr_seqof(pe, p, mod) == NOTOK) {
                    863:                    goto bad;
                    864:                }
                    865:                break;
                    866: 
                    867:            case SET_START:
                    868:                if (p_pr_set(pe, p, mod) == NOTOK) {
                    869:                    goto bad;
                    870:                }
                    871:                break;
                    872: 
                    873:            case SETOF_START:
                    874:                if (p_pr_setof(pe, p, mod) == NOTOK) {
                    875:                    goto bad;
                    876:                }
                    877:                break;
                    878: 
                    879:            case SOBJECT:
                    880:                if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    881:                    goto bad;
                    882:                }
                    883:                break;
                    884: 
                    885:            case OBJECT:
                    886:                if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                    887:                    goto bad;
                    888:                }
                    889:                break;
                    890: 
                    891:            case CHOICE_START:
                    892:                if (p_pr_choice(pe, p, mod) == NOTOK)
                    893:                    goto bad;
                    894:                break;
                    895: 
                    896:            case SEXTOBJ:
                    897:                if (p[1].pe_type != EXTMOD) {
                    898:                    return (pepsylose (mod, p, pe,"p_pr_seqof:missing EXTMOD"));
                    899:                }
                    900:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                    901:                     (char **)0) == NOTOK)
                    902:                     goto bad;
                    903:                break;
                    904: 
                    905:            case EXTOBJ:
                    906:                if (p[1].pe_type != EXTMOD) {
                    907:                    return (pepsylose (mod, p, pe,"p_pr_seqof:missing EXTMOD"));
                    908:                }
                    909:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP, 
                    910:                    (char **) 0) == NOTOK)
                    911:                    goto bad;
                    912:                break;
                    913: 
                    914:            default:
                    915:                if (p_pr_type(1, pe, p, mod) == NOTOK)
                    916:                    goto bad;
                    917:                break;
                    918:            }
                    919: 
                    920:            if (ISDTYPE(p) && dflt == 0)
                    921:                pe = next_member(head, pe);
                    922:     next:
                    923:            if (NEXT_PTPE(p) == NULLPTPE)
                    924:                goto bad;
                    925:        }
                    926:        /* parm = (char *) (parm); */
                    927:        p = start;
                    928:     }
                    929: 
                    930:     VPOP();
                    931:     return (OK);
                    932: 
                    933: bad:
                    934:     VPOP();
                    935:     return (NOTOK);
                    936: }
                    937: 
                    938: /*
                    939:  * Parse a setof, calling appropriate routines to parse each sub type
                    940:  */
                    941: static int
                    942: p_pr_setof(head, p, mod)
                    943: PE      head;
                    944: ptpe   *p;
                    945: modtyp *mod;                   /* Module it is from */
                    946: {
                    947:     PE      pe;
                    948:     ptpe   *start;
                    949: 
                    950:     if (p->pe_type != SETOF_START)
                    951:        return (pepsylose (mod, p, head, "p_pr_setof: missing SETOF_START\n"));
                    952: #if PRINT_TYPES
                    953:     if (p->pe_typename)
                    954:        VNAME(p->pe_typename);
                    955: #endif
                    956:     VPUSH();
                    957: 
                    958:     p++;
                    959:     if (p->pe_type == DFLT_B)
                    960:        p++;
                    961: 
                    962:     start = p;
                    963: 
                    964:     for (pe = first_member(head); pe; pe = next_member(head, pe)) {
                    965:        while (p->pe_type != PE_END) {
                    966:            if (pe == NULLPE || CHKTAG(mod, p, pe) == 0) {
                    967:                if (DEFAULT(p)) {
                    968: #ifdef PRINT_DEFAULTS
                    969:                    setpval(p, p + 1, mod);
                    970: #endif
                    971:                    goto next;
                    972:                } else {
                    973:                    dmp_ptpe("p_pr_setof:missing mandatory parameter", p, mod);
                    974:                    goto bad;
                    975:                }
                    976:            }
                    977: 
                    978:            if (p->pe_typename)
                    979:                VNAME(p->pe_typename);
                    980:            switch (p->pe_type) {
                    981:            case UCODE:
                    982:                if ((*mod->md_ducode) (pe, p, mod) != OK)
                    983:                    goto bad;
                    984:                break;
                    985: 
                    986:            case ETAG:
                    987:                if (p_pr_type(1, pe->pe_cons, p, mod) == NOTOK)
                    988:                    goto bad;
                    989:                break;
                    990: 
                    991:                /*
                    992:                 * case SCTRL: parm = (char *) (parm); break;
                    993:                 */
                    994: 
                    995:            case SEQ_START:
                    996:                if (p_pr_seq(pe, p, mod) == NOTOK) {
                    997:                    goto bad;
                    998:                }
                    999:                break;
                   1000: 
                   1001:            case SEQOF_START:
                   1002:                if (p_pr_seqof(pe, p, mod) == NOTOK) {
                   1003:                    goto bad;
                   1004:                }
                   1005:                break;
                   1006: 
                   1007:            case SET_START:
                   1008:                if (p_pr_set(pe, p, mod) == NOTOK) {
                   1009:                    goto bad;
                   1010:                }
                   1011:                break;
                   1012: 
                   1013:            case SETOF_START:
                   1014:                if (p_pr_setof(pe, p, mod) == NOTOK) {
                   1015:                    goto bad;
                   1016:                }
                   1017:                break;
                   1018: 
                   1019:            case SOBJECT:
                   1020:                if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                   1021:                    goto bad;
                   1022:                }
                   1023:                break;
                   1024: 
                   1025:            case OBJECT:
                   1026:                if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK) {
                   1027:                    goto bad;
                   1028:                }
                   1029:                break;
                   1030: 
                   1031:            case CHOICE_START:
                   1032:                if (p_pr_choice(pe, p, mod) == NOTOK)
                   1033:                    goto bad;
                   1034:                break;
                   1035: 
                   1036:            case SEXTOBJ:
                   1037:                if (p[1].pe_type != EXTMOD) {
                   1038:                    return (pepsylose (mod, p, pe,"p_pr_setof:missing EXTMOD"));
                   1039:                }
                   1040:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                   1041:                    (char **) 0) == NOTOK)
                   1042:                    goto bad;
                   1043:                break;
                   1044: 
                   1045:            case EXTOBJ:
                   1046:                if (p[1].pe_type != EXTMOD) {
                   1047:                    return (pepsylose (mod, p, pe,"p_pr_setof:missing EXTMOD"));
                   1048:                }
                   1049:                if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                   1050:                    (char **) 0) == NOTOK)
                   1051:                    goto bad;
                   1052:                break;
                   1053: 
                   1054:            default:
                   1055:                if (p_pr_type(1, pe, p, mod) == NOTOK)
                   1056:                    goto bad;
                   1057:                break;
                   1058:            }
                   1059: 
                   1060:     next:
                   1061:            if (NEXT_PTPE(p) == NULLPTPE)
                   1062:                goto bad;
                   1063:        }
                   1064:        /* parm = (char *)(parm); */
                   1065:        p = start;
                   1066:     }
                   1067: 
                   1068:     VPOP();
                   1069:     return (OK);
                   1070: 
                   1071: bad:
                   1072:     VPOP();
                   1073:     return (NOTOK);
                   1074: 
                   1075: }
                   1076: 
                   1077: /*
                   1078:  * parse a choice field. This means find which choice is taken
                   1079:  */
                   1080: static int
                   1081: p_pr_choice(head, p, mod)
                   1082: PE      head;
                   1083: ptpe   *p;
                   1084: modtyp *mod;                   /* Module it is from */
                   1085: {
                   1086:     if (p->pe_type != CHOICE_START) {
                   1087:        return (pepsylose (mod, p, head, "p_pr_choice:missing CHOICE_START"));
                   1088:     }
                   1089: #if PRINT_TYPES
                   1090:     if (p->pe_typename)
                   1091:        VNAME(p->pe_typename);
                   1092: #endif
                   1093: #ifdef CHOICE_PUSH
                   1094:     VPUSH();
                   1095: #endif
                   1096: 
                   1097:     p++;
                   1098:     if (p->pe_type == DFLT_B)
                   1099:        p++;
                   1100: 
                   1101:     if (p->pe_type == SCTRL) {
                   1102:        p++;
                   1103:     }
                   1104: 
                   1105:     for (; p->pe_type != PE_END; NEXT_PTPE(p)) {
                   1106:        if (ISDTYPE(p) && p_ismatch(p, mod, head->pe_class, head->pe_id)) {
                   1107:            if (p->pe_typename)
                   1108:                VNAME(p->pe_typename);
                   1109:            if (p_pr_type(0, head, p, mod) == NOTOK)
                   1110:                return (NOTOK);
                   1111: #ifdef CHOICE_PUSH
                   1112:            VPOP();
                   1113: #endif
                   1114:            return (OK);
                   1115:        }
                   1116:     }
                   1117: 
                   1118:     dmp_ptpe("p_pr_choice: no choice taken", p, mod);
                   1119: #ifdef CHOICE_PUSH
                   1120:        VPOP();
                   1121: #endif
                   1122:     return (NOTOK);
                   1123: }
                   1124: 
                   1125: /*
                   1126:  * Calculate the next ptpe entry in the sequence. Count a sequence as
                   1127:  * one element
                   1128:  */
                   1129: ptpe   *
                   1130: next_ptpe(p)
                   1131: ptpe   *p;
                   1132: {
                   1133:     int     level;
                   1134: 
                   1135:     level = 0;
                   1136:     if (p->pe_type == PE_END) {
                   1137:        (void) pepsylose (NULLMODTYP, p, NULLPE,
                   1138:            "next_ptpe: unexpected PE_END");
                   1139:        return (NULLPTPE);
                   1140:     }
                   1141:     do {
                   1142: again:
                   1143:        switch (p->pe_type) {
                   1144:        case SEQ_START:
                   1145:        case SEQOF_START:
                   1146:        case SET_START:
                   1147:        case SETOF_START:
                   1148:        case CHOICE_START:
                   1149:            level++;
                   1150:            break;
                   1151: 
                   1152:        case UCODE:
                   1153:        case SCTRL:
                   1154:        case CH_ACT:
                   1155:        case INTEGER:
                   1156:        case REALTYPE:
                   1157:        case BOOLEAN:
                   1158:        case SANY:
                   1159:        case ANY:
                   1160:        case T_NULL:
                   1161:        case OBJECT:
                   1162:        case SOBJECT:
                   1163:        case BITSTRING:
                   1164:        case SBITSTRING:
                   1165:        case OCTETSTRING:
                   1166:        case SOCTETSTRING:
                   1167:        case OBJID:
                   1168:        case SOBJID:
                   1169:        case OPTL:
                   1170:        case EXTMOD:
                   1171:        case DFLT_B:
                   1172:            break;
                   1173: 
                   1174:        case IMP_OBJ:
                   1175:        case ETAG:
                   1176:        case EXTOBJ:
                   1177:        case SEXTOBJ:
                   1178:        case DFLT_F:
                   1179:            p++;
                   1180:            goto again;
                   1181: 
                   1182:        case PE_END:
                   1183:            level--;
                   1184:            break;
                   1185: 
                   1186:        default:
                   1187:            (void) pepsylose (NULLMODTYP, p, NULLPE,
                   1188:                "next_ptpe: unknown type %d\n", p->pe_type);
                   1189:            return (NULLPTPE);
                   1190:        }
                   1191:        p++;
                   1192:     } while (level > 0 || p->pe_type == DFLT_B);
                   1193: 
                   1194:     return (p);
                   1195: }
                   1196: 
                   1197: #if 0
                   1198: /*
                   1199:  * check that pe is non null and that the tag and class match and
                   1200:  * return zero if the don't
                   1201:  */
                   1202: p_chktag(mod, p, pe)
                   1203: modtyp *mod;                   /* Module it is from */
                   1204: ptpe   *p;
                   1205: PE      pe;
                   1206: {
                   1207:     int     cl, tag;
                   1208: 
                   1209:     if (pe == NULLPE)
                   1210:        return (0);
                   1211: #if 0
                   1212:     if (p->pe_type == OBJECT && skip_next_tag) /* first time we find
                   1213:                                                 * skip */
                   1214:        return (1);
                   1215:     if (skip_next_tag) {       /* 2nd time reset skip */
                   1216:        skip_next_tag = 0;
                   1217:        return (1);
                   1218:     }
                   1219: #endif
                   1220:     if (!p_findcltag(p, mod, &cl, &tag))
                   1221:        return (0);
                   1222:     if (pe->pe_id != tag || pe->pe_class != cl)
                   1223:        return (0);
                   1224: 
                   1225:     return (1);
                   1226: }
                   1227: #endif
                   1228: 
                   1229: /*
                   1230:  * Parse a single type for explicit tag If a basic type parse it, if
                   1231:  * a compound type call the appropriate parsing routine
                   1232:  */
                   1233: static int
                   1234: p_pr_etype(pe, p, mod)
                   1235: PE      pe;
                   1236: ptpe   *p;
                   1237: modtyp *mod;                   /* Module it is from */
                   1238: {
                   1239:     int     i;
                   1240:     OID     oid;
                   1241: 
                   1242:     if (p->pe_type != ETAG)
                   1243:        return (pepsylose (mod, p, pe, "p_pr_etype: missing ETAG\n"));
                   1244:     
                   1245: 
                   1246:     if (PRINT_TAG(p))
                   1247:        VTAG (CLASS (p), TAG (p));
                   1248:     p++;
                   1249: 
                   1250:     switch (p->pe_type) {
                   1251:     case PE_END:
                   1252:     case PE_START:
                   1253:        goto bad;
                   1254: 
                   1255:     case UCODE:
                   1256:        if ((*mod->md_ducode) (pe, p, mod) != OK)
                   1257:            goto bad;
                   1258:        break;
                   1259: 
                   1260:     case ETAG:
                   1261:        switch (p->pe_ucode) {
                   1262: 
                   1263:        default:
                   1264:            if (p_pr_etype(pe->pe_cons, p, mod) == NOTOK)
                   1265:                goto bad;
                   1266:        }
                   1267:        break;
                   1268: 
                   1269:     case SEQ_START:
                   1270:        if (p_pr_seq(pe, p, mod) == NOTOK)
                   1271:            goto bad;
                   1272:        break;
                   1273: 
                   1274:     case SEQOF_START:
                   1275:        if (p_pr_seqof(pe, p, mod) == NOTOK)
                   1276:            goto bad;
                   1277:        break;
                   1278: 
                   1279:     case SET_START:
                   1280:        if (p_pr_set(pe, p, mod) == NOTOK)
                   1281:            goto bad;
                   1282:        break;
                   1283: 
                   1284:     case SETOF_START:
                   1285:        if (p_pr_setof(pe, p, mod) == NOTOK)
                   1286:            goto bad;
                   1287:        break;
                   1288: 
                   1289:     case IMP_OBJ:
                   1290:        p++;
                   1291:        if (p->pe_type == EXTOBJ) {
                   1292:            if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                   1293:                   (char **) 0) == NOTOK)
                   1294:                   goto bad;
                   1295:        } else {
                   1296:            if (p_pr_obj(0, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
                   1297:                goto bad;
                   1298:        }
                   1299:        break;
                   1300: 
                   1301:     case SOBJECT:
                   1302:        if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
                   1303:            goto bad;
                   1304:        break;
                   1305: 
                   1306:     case OBJECT:
                   1307:        if (p_pr_obj(1, pe, mod->md_ptab[p->pe_tag], mod) == NOTOK)
                   1308:            goto bad;
                   1309:        break;
                   1310: 
                   1311:     case CHOICE_START:
                   1312:        if (p_pr_choice(pe, p, mod) == NOTOK)
                   1313:            goto bad;
                   1314:        break;
                   1315: 
                   1316:     case SEXTOBJ:
                   1317:        if (p[1].pe_type != EXTMOD) {
                   1318:            return (pepsylose (mod, p, pe, "p_pr_etype: missing EXTMOD"));
                   1319:        }
                   1320:        if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                   1321:               (char **) 0) == NOTOK)
                   1322:               goto bad;
                   1323:        break;
                   1324: 
                   1325:     case EXTOBJ:
                   1326:        if (p[1].pe_type != EXTMOD) {
                   1327:            return (pepsylose (mod, p, pe, "p_pr_etype: missing EXTMOD"));
                   1328:        }
                   1329:        if (prnt_f(p->pe_tag, EXT2MOD(mod, (p + 1)), pe, 0, NULLIP,
                   1330:               (char **) 0) == NOTOK)
                   1331:               goto bad;
                   1332:        break;
                   1333: 
                   1334:     case INTEGER:
                   1335:        if (pe != NULLPE) {
                   1336:            if ((i = prim2num(pe)) == NOTOK && pe->pe_errno != PE_ERR_NONE)
                   1337:                goto bad;
                   1338:            VPRINT(("%d", i));
                   1339:        }
                   1340:        break;
                   1341: 
                   1342: #ifdef PEPSY_REALS
                   1343:     case REALTYPE:
                   1344:        if (pe != NULLPE) {
                   1345:            double r;
                   1346: 
                   1347:            if ((r = prim2real(pe)) == NOTOK
                   1348:                && pe->pe_errno != PE_ERR_NONE)
                   1349:                goto bad;
                   1350:            VPRINT(("%g", r));
                   1351:        }
                   1352:        break;
                   1353: #endif
                   1354: 
                   1355: 
                   1356:     case BOOLEAN:
                   1357:        if (pe != NULLPE) {
                   1358:            if ((i= prim2flag(pe)) == NOTOK)
                   1359:                goto bad;
                   1360:            VPRINT((i ? "TRUE" : "FALSE"));
                   1361:        }
                   1362:        break;
                   1363: 
                   1364:     case T_NULL:
                   1365:        VPRINT(("NULL"));
                   1366:        break;
                   1367: 
                   1368:     case ANY:
                   1369:        if (pe != NULLPE) {
                   1370:            if (pe->pe_errno != PE_ERR_NONE) {
                   1371:                goto bad;
                   1372:            } else
                   1373:                VUNKNOWN(pe);
                   1374:        }
                   1375:        break;
                   1376: 
                   1377:     case SANY:
                   1378:        if (pe != NULLPE) {
                   1379:            if (pe->pe_errno != PE_ERR_NONE) {
                   1380:                goto bad;
                   1381:            } else
                   1382:                VUNKNOWN(pe);
                   1383:        }
                   1384:        break;
                   1385: 
                   1386:     case SOCTETSTRING:
                   1387:        if (pe != NULLPE) {
                   1388:            VSTRING(pe);
                   1389:        }
                   1390:        break;
                   1391: 
                   1392:     case OCTETSTRING:
                   1393:        if (pe != NULLPE) {
                   1394:            VSTRING(pe);
                   1395:        }
                   1396:        break;
                   1397: 
                   1398:     case SBITSTRING:
                   1399:        if (pe != NULLPE) {
                   1400:            PE  bstr;
                   1401: 
                   1402:            if ((bstr = prim2bit(pe)) == NULLPE)
                   1403:                goto bad;
                   1404:            /* one day get the named bits here */
                   1405:            VPRINT(("%s", bit2str(bstr, "\020")));
                   1406:        }
                   1407:        break;
                   1408: 
                   1409:     case BITSTRING:
                   1410:        if (pe != NULLPE) {
                   1411:            PE  bstr;
                   1412: 
                   1413:            if ((bstr = prim2bit(pe)) == NULLPE)
                   1414:                goto bad;
                   1415:            /* one day get the named bits here */
                   1416:            VPRINT(("%s", bit2str(bstr, "\020")));
                   1417:        }
                   1418:        break;
                   1419: 
                   1420:     case SOBJID:
                   1421:        if (((OID) oid = prim2oid(pe)) == NULLOID) {
                   1422:            goto bad;
                   1423:        } else {
                   1424:            VPRINT(("%s", oid2ode(oid)));
                   1425:        }
                   1426:        break;
                   1427: 
                   1428:     case OBJID:
                   1429:        if (((OID) oid = prim2oid(pe)) == NULLOID) {
                   1430:            goto bad;
                   1431:        } else {
                   1432:            VPRINT(("%s", oid2ode(oid)));
                   1433:        }
                   1434:        break;
                   1435: 
                   1436:     default:
                   1437:        return (pepsylose (mod, p, pe, "p_pr_etype: %d not implemented\n",
                   1438:            p->pe_type));
                   1439:     }
                   1440: 
                   1441:     return (OK);
                   1442: 
                   1443: bad:
                   1444:     return (NOTOK);
                   1445: }
                   1446: 
                   1447: #if 0
                   1448: /*
                   1449:  * determine what the class and tag must be of the given object
                   1450:  */
                   1451: p_findcltag(p, mod, pcl, ptag)
                   1452: ptpe   *p;
                   1453: modtyp *mod;                   /* Module it is from */
                   1454: int    *pcl, *ptag;
                   1455: {
                   1456:     if (!ISDTYPE(p))
                   1457:        return (0);
                   1458:     if (p->pe_type != OBJECT) {
                   1459:        *pcl = CLASS(p);
                   1460:        *ptag = TAG(p);
                   1461:        return (1);
                   1462:     }
                   1463:     p = mod->md_ptab[p->pe_tag] + 1;
                   1464:     while (p->pe_type != PE_END) {
                   1465:        if (ISDTYPE(p))
                   1466:            return (p_findcltag(p, mod, pcl, ptag));
                   1467:     }
                   1468:     dmp_ptpe("p_findcltag:warning:object with no data in it", p, mod);
                   1469:     return (0);
                   1470: }
                   1471: #endif
                   1472: 
                   1473: /*
                   1474:  * Is there a match at for this tag and class pair. Return 1 if yes 0
                   1475:  * if no We will search through contained objects and through choices
                   1476:  */
                   1477: p_ismatch(p, mod, cl, tag)
                   1478: ptpe   *p;
                   1479: modtyp *mod;                   /* Module it is from */
                   1480: unsigned int cl, tag;
                   1481: {
                   1482:     if (!ISDTYPE(p))
                   1483:        return (0);
                   1484:     switch (p->pe_type) {
                   1485:     case SOBJECT:
                   1486:     case OBJECT:
                   1487:        /* Needs to be changed for optional and default */
                   1488:        return (p_ismatch(p = mod->md_ptab[p->pe_tag] + 1, mod, cl, tag));
                   1489: 
                   1490:     case SEXTOBJ:
                   1491:     case EXTOBJ:
                   1492:        if (p[1].pe_type != EXTMOD) {
                   1493:            (void) pepsylose (mod, p, NULLPE, "p_ismatch: missing EXTMOD");
                   1494:            return (0); /* fixup ismatch return -1 */
                   1495:        }
                   1496:        return (p_ismatch(EXT2MOD(mod, (p + 1))->md_ptab[p->pe_tag] + 1,
                   1497:                          EXT2MOD(mod, (p + 1)), cl, tag));
                   1498: 
                   1499:     case CHOICE_START:
                   1500:        for (p++; p->pe_type != PE_END; p = NEXT_PTPE(p)) {
                   1501:            if (!ISDTYPE(p))
                   1502:                continue;
                   1503:            if (p_ismatch(p, mod, cl, tag))
                   1504:                return (1);
                   1505:        }
                   1506:        return (0);
                   1507: 
                   1508: 
                   1509:     case SANY:
                   1510:        return (1);
                   1511: 
                   1512:     case ANY:
                   1513:        if (STAG(p) == -1)
                   1514:            return (1);
                   1515:        /* else fall through - not sure if this is needed */
                   1516: 
                   1517:     default:
                   1518:        return (tag == TAG(p) && cl == CLASS(p));
                   1519:     }
                   1520:     /* NOTREACHED */
                   1521:     /* return (0); */
                   1522: }
                   1523: 
                   1524: /*
                   1525:  * determine if the given field is present in the data This is simple
                   1526:  * if the field is a simple type with an obvious tag but in the case
                   1527:  * of an object or a CHOICE type the tag is not obvious. If the
                   1528:  * object is a CHOICE there are more than one possible tag that could
                   1529:  * match and in this case we must try to match each one of them.
                   1530:  */
                   1531: PE
                   1532: p_setpresent(head, p, mod)
                   1533: PE      head;
                   1534: ptpe   *p;
                   1535: modtyp *mod;
                   1536: {
                   1537:     PE      pe;
                   1538: 
                   1539:     if (!ISDTYPE(p))
                   1540:        return (NULLPE);
                   1541:     switch (p->pe_type) {
                   1542:     case OBJECT:
                   1543:     case SOBJECT:
                   1544:        {
                   1545:            /* Needs to be changed for optional and default */
                   1546:            return (p_setpresent(head, p = mod->md_ptab[p->pe_tag] + 1, mod));
                   1547:        }
                   1548: 
                   1549:     case CHOICE_START:
                   1550:        for (p++; p->pe_type != PE_END; p = NEXT_PTPE(p)) {
                   1551:            if (!ISDTYPE(p))
                   1552:                continue;
                   1553:            if ((pe = (PE) p_setpresent(head, p, mod)))
                   1554:                return (pe);
                   1555:        }
                   1556:        return (NULLPE);
                   1557: 
                   1558:     default:
                   1559:        return (set_find(head, CLASS(p), TAG(p)));
                   1560:     }
                   1561: }
                   1562: 
                   1563: #ifdef PRINT_DEFAULTS
                   1564: /*
                   1565:  * set the default value to that value in the structure
                   1566:  */
                   1567: setpval(typ, dflt, mod)
                   1568: ptpe   *typ, *dflt;
                   1569: modtyp *mod;
                   1570: {
                   1571:     int     len, i, intval;
                   1572:     char   *ptr, *optr;
                   1573:     PE      pe_ptr;
                   1574: 
                   1575:     switch (typ->pe_type) {
                   1576: 
                   1577:     case INTEGER:
                   1578:        intval = IVAL(mod, dflt);
                   1579:        (*vfnx) (vfp, "%d (DEFAULT INTEGER)\n", intval);
                   1580:        break;
                   1581: 
                   1582: 
                   1583: #ifdef PEPSY_REALS
                   1584:     case REALTYPE:
                   1585:        (*vfnx) (vfp, "%f (DEFAULT Real)\n", RVAL(mod, dflt));
                   1586:        break;
                   1587: #endif
                   1588: 
                   1589:     case BOOLEAN:
                   1590:        intval = IVAL(mod, dflt);
                   1591:        /*
                   1592:         * (*vfnx) (vfp, "%s  %d (DEFAULT BOOLEAN)\n",
                   1593:         * (typ->pe_typename) ? typ->pe_typename : "", charval);
                   1594:         */
                   1595:        (*vfnx) (vfp, "%d (DEFAULT BOOLEAN)\n", intval);
                   1596:        break;
                   1597: 
                   1598:     case T_NULL:
                   1599:        /* Only one value */
                   1600:        break;
                   1601: 
                   1602:     case SBITSTRING:
                   1603:        (PE) pe_ptr = strb2bitstr(PVAL(mod, dflt), IVAL(mod, dflt), 0, 0);
                   1604:        break;
                   1605: 
                   1606:     case BITSTRING:
                   1607:        (PE) pe_ptr =
                   1608:           strb2bitstr(PVAL(mod, dflt), IVAL(mod, dflt), 0, 0);
                   1609:        (*vfnx) (vfp, " '");
                   1610:        optr = ptr = bitstr2strb((PE) pe_ptr, &len);
                   1611:        for (i = 0; i < len; i += 8)
                   1612:            (*vfnx) (vfp, "%.2x", *ptr++);
                   1613:        (*vfnx) (vfp, "'H (DEFAULT BITSTRING)\n");
                   1614:        pe_free (pe_ptr);
                   1615:        free (optr);
                   1616:        break;
                   1617: 
                   1618:     case SOCTETSTRING:
                   1619:     case OCTETSTRING:
                   1620:         ptr = PVAL(mod, dflt); /* array of octets */
                   1621:         i = IVAL(mod, dflt);           /* length of array */
                   1622:        if (printable(ptr, i)) {
                   1623:            (*vfnx) (vfp, "\"");
                   1624:            for (; *ptr && i-- > 0; ptr++)
                   1625:                 (void) fputc(*ptr, vfp);
                   1626:            (*vfnx) (vfp, "\"\n");
                   1627:        } else {
                   1628:            (*vfnx) (vfp, "'");
                   1629:            if (ptr) {
                   1630:                for (; i-- > 0; ptr++)
                   1631:                    (*vfnx) (vfp, "%.2x", *ptr & 0xff);
                   1632:            }
                   1633:            (*vfnx) (vfp, "'H \n");
                   1634:        }
                   1635:        break;
                   1636: 
                   1637:     case OBJECT:
                   1638:        setpval(mod->md_ptab[typ->pe_tag] + 1, dflt, mod);
                   1639:        break;
                   1640: 
                   1641:     case SOBJECT:
                   1642:        setpval(mod->md_ptab[typ->pe_tag] + 1, dflt, mod);
                   1643:        break;
                   1644: 
                   1645:     case IMP_OBJ:
                   1646:        typ++;
                   1647: 
                   1648:     case ANY:
                   1649:     case SANY:
                   1650:     case SEXTOBJ:
                   1651:     case EXTOBJ:
                   1652:     case OBJID:
                   1653:     case SOBJID:
                   1654:     case SEQ_START:
                   1655:     case SET_START:
                   1656:     case -1:                   /* Just use the pepy method of null
                   1657:                                 * pointers */
                   1658:        /*
                   1659:         * This is the posy/pepy hack way of doing things at the
                   1660:         * moment
                   1661:         */
                   1662:        (char *) ptr = NULL;
                   1663:        break;
                   1664: 
                   1665:     default:
                   1666:        return (pepsylose (mod, p, pe, "setpval: type %d not implemented\n",
                   1667:            typ->pe_type));
                   1668:        break;
                   1669:     }
                   1670: 
                   1671: }
                   1672: #endif
                   1673: /*
                   1674:  * return non zero if we can print out the string
                   1675:  */
                   1676: printable(strptr, len)
                   1677: char   *strptr;
                   1678: int    len;
                   1679: {
                   1680:     if (strptr == NULL || *strptr == '\0') {
                   1681:        return (0);
                   1682:     }
                   1683: 
                   1684:      while (len-- > 0) {
                   1685:        if (!isprint(*strptr++))
                   1686:            return (0);
                   1687:     }
                   1688: 
                   1689:     return (1);
                   1690: }
                   1691: 
                   1692: /*
                   1693:  * (Dump) Print out a printable entry in a human recognisable form
                   1694:  */
                   1695: dmp_ptpe(s, p, mod)
                   1696: char   *s;
                   1697: modtyp *mod;                   /* Module it is from */
                   1698: ptpe   *p;
                   1699: {
                   1700:     int     i, j;
                   1701:     ptpe  **par, **prev;
                   1702:     char   *name;
                   1703: 
                   1704:     (void) fprintf(vfp, "%s:(%s)", s, mod->md_name);
                   1705:     /*
                   1706:      * Calculate what table it is in - we assume they are in order of
                   1707:      * increasing address
                   1708:      */
                   1709: 
                   1710:     par = NULL;
                   1711:     if (mod->md_ptab != NULL && mod->md_ptab[0] < p) {
                   1712:        par = mod->md_ptab;
                   1713:        name = "Printing:";
                   1714:     }
                   1715:     if (par == NULL) {
                   1716:        (void) fprintf(vfp, "can't find entry 0x%x\n", p);
                   1717:        return;
                   1718:     }
                   1719:     prev = par;
                   1720:     for (i = mod->md_nentries; i > 0; i--) {
                   1721:        if (*par > p)
                   1722:            break;
                   1723:        par++;
                   1724:     }
                   1725:     if (par == prev) {
                   1726:        (void) pepsylose (mod, p, NULLPE,
                   1727:            "dmp_ptpe:par == prev == 0x%x internal error\n", (int) par);
                   1728:        return;
                   1729:     }
                   1730:     par--;
                   1731:     j = p - *par;
                   1732: 
                   1733:     (void) fprintf(vfp, "%s type %d + %d ", name, par - prev, j);
                   1734:     p_pr_entry(p);
                   1735: }

unix.superglobalmegacorp.com

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