/* automatically generated by pepy 8.0 #1 (big-screw), do not edit! */

#include "psap.h"

#ifndef lint
static char *pepyid = "pepy 8.0 #1 (big-screw) of Sat Jun 27 17:49:54 EDT 1992";
#endif

#define	advise	PY_advise

void	advise ();

/* Generated from module VT */
# line 24 "bk_content.py"


#include "vtpm.h"
#include "sector5.h"
#include  <stdio.h>

#undef PEPYPARM
#define PEPYPARM int *

#ifndef PEPYPARM
#define PEPYPARM char *
#endif /* PEPYPARM */
extern PEPYPARM NullParm;

/* ARGSUSED */

int	build_VT_BKQ__pdu (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
    int	p0;

    switch (p0 = (1)) {
        case 1:	/* bkqpdu */
            {
                if (build_VT_BKQcontent (pe, 0, NULL, NULLCP, (PEPYPARM)parm) == NOTOK)
                    return NOTOK;
                (*pe) -> pe_class = PE_CLASS_CONT;
                (*pe) -> pe_id = 8;

#ifdef DEBUG
                (void) testdebug ((*pe), "bkqpdu");
#endif

            }
            break;

        default:
            advise (NULLCP, "BKQ-pdu %s%d", PEPY_ERR_INVALID_CHOICE, 
                    p0);
            return NOTOK;
    }

#ifdef DEBUG
    (void) testdebug ((*pe), "VT.BKQ-pdu");
#endif


    return OK;
}

/* ARGSUSED */

int	unbuild_VT_BKQ__pdu (pe, explicit, len, buffer, parm)
register PE	pe;
int	explicit;
int    *len;
char  **buffer;
PEPYPARM parm;
{
#ifdef DEBUG
    (void) testdebug (pe, "VT.BKQ-pdu");
#endif

    switch (PE_ID (pe -> pe_class, pe -> pe_id)) {
        case PE_ID (PE_CLASS_CONT, 8):	/* bkqpdu */
            {
#ifdef DEBUG
                (void) testdebug (pe, "bkqpdu");
#endif

                if (unbuild_VT_BKQcontent (pe, 0, NULLIP, NULLVP, (PEPYPARM)parm) == NOTOK)
                    return NOTOK;
            }
            break;

        default:
            advise (NULLCP, "BKQ-pdu %s%s/%d/0x%x", PEPY_ERR_UNKNOWN_CHOICE,
                    pe_classlist[pe -> pe_class], pe -> pe_form, pe -> pe_id);
            return NOTOK;
    }

    return OK;
}

/* ARGSUSED */

int	build_VT_BKR__pdu (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
    int	p1;

    switch (p1 = (1)) {
        case 1:	/* bkrpdu */
            {
                if (build_VT_BKRcontent (pe, 0, NULL, NULLCP, (PEPYPARM)parm) == NOTOK)
                    return NOTOK;
                (*pe) -> pe_class = PE_CLASS_CONT;
                (*pe) -> pe_id = 9;

#ifdef DEBUG
                (void) testdebug ((*pe), "bkrpdu");
#endif

            }
            break;

        default:
            advise (NULLCP, "BKR-pdu %s%d", PEPY_ERR_INVALID_CHOICE, 
                    p1);
            return NOTOK;
    }

#ifdef DEBUG
    (void) testdebug ((*pe), "VT.BKR-pdu");
#endif


    return OK;
}

/* ARGSUSED */

int	unbuild_VT_BKR__pdu (pe, explicit, len, buffer, parm)
register PE	pe;
int	explicit;
int    *len;
char  **buffer;
PEPYPARM parm;
{
#ifdef DEBUG
    (void) testdebug (pe, "VT.BKR-pdu");
#endif

    switch (PE_ID (pe -> pe_class, pe -> pe_id)) {
        case PE_ID (PE_CLASS_CONT, 9):	/* bkrpdu */
            {
#ifdef DEBUG
                (void) testdebug (pe, "bkrpdu");
#endif

                if (unbuild_VT_BKRcontent (pe, 0, NULLIP, NULLVP, (PEPYPARM)parm) == NOTOK)
                    return NOTOK;
            }
            break;

        default:
            advise (NULLCP, "BKR-pdu %s%s/%d/0x%x", PEPY_ERR_UNKNOWN_CHOICE,
                    pe_classlist[pe -> pe_class], pe -> pe_form, pe -> pe_id);
            return NOTOK;
    }

    return OK;
}

/* ARGSUSED */

int	build_VT_ExplicitPointer (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
# line 53 "bk_content.py"
    
	EXPL_PTR	*arg = (EXPL_PTR *)parm;

    PE	p2_z = NULLPE;
    register PE *p2 = &p2_z;

    if (((*pe) = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SEQ)) == NULLPE) {
        advise (NULLCP, "ExplicitPointer: %s", PEPY_ERR_NOMEM);
        return NOTOK;
    }
    (*p2) = NULLPE;

    if (arg->xval != NULLCOORD) {	/* x */
        register integer p3 = arg->xval ;

        if (((*p2) = num2prim (p3, PE_CLASS_CONT, 0)) == NULLPE) {
            advise (NULLCP, "x: %s", PEPY_ERR_NOMEM);
            return NOTOK;
        }

#ifdef DEBUG
        (void) testdebug ((*p2), "x");
#endif

    }

    if ((*p2) != NULLPE)
        if (seq_add ((*pe), (*p2), -1) == NOTOK) {
            advise (NULLCP, "ExplicitPointer %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }
    (*p2) = NULLPE;

    if (arg->yval != NULLCOORD) {	/* y */
        register integer p4 = arg->yval ;

        if (((*p2) = num2prim (p4, PE_CLASS_CONT, 1)) == NULLPE) {
            advise (NULLCP, "y: %s", PEPY_ERR_NOMEM);
            return NOTOK;
        }

#ifdef DEBUG
        (void) testdebug ((*p2), "y");
#endif

    }

    if ((*p2) != NULLPE)
        if (seq_add ((*pe), (*p2), -1) == NOTOK) {
            advise (NULLCP, "ExplicitPointer %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }
    (*p2) = NULLPE;

    if (arg->zval != NULLCOORD) {	/* z */
        register integer p5 = arg->zval ;

        if (((*p2) = num2prim (p5, PE_CLASS_CONT, 2)) == NULLPE) {
            advise (NULLCP, "z: %s", PEPY_ERR_NOMEM);
            return NOTOK;
        }

#ifdef DEBUG
        (void) testdebug ((*p2), "z");
#endif

    }

    if ((*p2) != NULLPE)
        if (seq_add ((*pe), (*p2), -1) == NOTOK) {
            advise (NULLCP, "ExplicitPointer %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }

#ifdef DEBUG
    (void) testdebug ((*pe), "VT.ExplicitPointer");
#endif


    return OK;
}

/* ARGSUSED */

int	unbuild_VT_ExplicitPointer (pe, explicit, len, buffer, parm)
register PE	pe;
int	explicit;
int    *len;
char  **buffer;
PEPYPARM parm;
{
# line 53 "bk_content.py"
    
	EXPL_PTR	*arg = (EXPL_PTR *)parm;

    register PE p6;

#ifdef DEBUG
    (void) testdebug (pe, "VT.ExplicitPointer");
#endif

    if (explicit) {
        if (pe -> pe_class != PE_CLASS_UNIV
                || pe -> pe_form != PE_FORM_CONS
                || pe -> pe_id != PE_CONS_SEQ) {
            advise (NULLCP, "ExplicitPointer bad class/form/id: %s/%d/0x%x",
                    pe_classlist[pe -> pe_class], pe -> pe_form, pe -> pe_id);
            return NOTOK;
        }
    }
    else
        if (pe -> pe_form != PE_FORM_CONS) {
            advise (NULLCP, "ExplicitPointer bad form: %d", pe -> pe_form);
            return NOTOK;
        }

    if ((p6 = prim2seq (pe)) == NULLPE) {
        advise (NULLCP, "ExplicitPointer %s%s", PEPY_ERR_BAD_SEQ,
                pe_error (pe -> pe_errno));
        return NOTOK;
    }
    pe = p6;

    {
        register PE p7;

        if ((p7 = first_member (pe)) != NULLPE
                && PE_ID (p7 -> pe_class, p7 -> pe_id)
                        != PE_ID (PE_CLASS_CONT, 0))
            p7 = NULLPE;
        if (p7 != NULLPE) {
            p6 = p7;

            {	/* x */
                register integer p8;

#ifdef DEBUG
                (void) testdebug (p7, "x");
#endif

                if ((p8 = prim2num (p7)) == NOTOK
                        && p7 -> pe_errno != PE_ERR_NONE) {
                    advise (NULLCP, "x %s%s", PEPY_ERR_BAD_INTEGER,
                            pe_error (p7 -> pe_errno));
                    return NOTOK;
                }
                arg->xval  = p8;
            }
        }
    }

    {
        register PE p9;

        if ((p9 = (pe != p6 ? next_member (pe, p6) : first_member (pe))) 
                    != NULLPE
                && PE_ID (p9 -> pe_class, p9 -> pe_id)
                        != PE_ID (PE_CLASS_CONT, 1))
            p9 = NULLPE;
        if (p9 != NULLPE) {
            p6 = p9;

            {	/* y */
                register integer p10;

#ifdef DEBUG
                (void) testdebug (p9, "y");
#endif

                if ((p10 = prim2num (p9)) == NOTOK
                        && p9 -> pe_errno != PE_ERR_NONE) {
                    advise (NULLCP, "y %s%s", PEPY_ERR_BAD_INTEGER,
                            pe_error (p9 -> pe_errno));
                    return NOTOK;
                }
                arg->yval  = p10;
            }
        }
    }

    {
        register PE p11;

        if ((p11 = (pe != p6 ? next_member (pe, p6) : first_member (pe))) != NULLPE) {
            p6 = p11;

            {	/* z */
                register integer p12;

#ifdef DEBUG
                (void) testdebug (p11, "z");
#endif

                if ((p12 = prim2num (p11)) == NOTOK
                        && p11 -> pe_errno != PE_ERR_NONE) {
                    advise (NULLCP, "z %s%s", PEPY_ERR_BAD_INTEGER,
                            pe_error (p11 -> pe_errno));
                    return NOTOK;
                }
                arg->zval  = p12;
            }
        }
    }


    if (pe -> pe_cardinal > 3) {
        advise (NULLCP, "ExplicitPointer %s(3): %d", PEPY_ERR_TOO_MANY_ELEMENTS,
                pe -> pe_cardinal);
        return NOTOK;
    }

    return OK;
}

/* ARGSUSED */

int	build_VT_BKQcontent (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
# line 72 "bk_content.py"
    
	BRcnt	*arg = (BRcnt *)parm;

    PE	p13_z = NULLPE;
    register PE *p13 = &p13_z;

    if (((*pe) = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SEQ)) == NULLPE) {
        advise (NULLCP, "BKQcontent: %s", PEPY_ERR_NOMEM);
        return NOTOK;
    }
    (*p13) = NULLPE;

    if (arg->BKQcont.token_val != NOBKTOK ) {	/* token */
        register integer p14 = arg->BKQcont.token_val;

        if (((*p13) = num2prim (p14, PE_CLASS_UNIV, PE_PRIM_INT)) == NULLPE) {
            advise (NULLCP, "token: %s", PEPY_ERR_NOMEM);
            return NOTOK;
        }
        switch (p14) {
            case 0:	/* initiator */
                break;
            case 1:	/* acceptor */
                break;
            case 2:	/* accChoice */
                break;
        }

#ifdef DEBUG
        (void) testdebug ((*p13), "token");
#endif

    }

    if ((*p13) != NULLPE)
        if (seq_add ((*pe), (*p13), -1) == NOTOK) {
            advise (NULLCP, "BKQcontent %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }
    (*p13) = NULLPE;

    {
        if (build_VT_ExplicitPointer (p13, 0, NULL, NULLCP, (PEPYPARM)&(arg->BKQcont.ExplPtr)) == NOTOK)
            return NOTOK;

#ifdef DEBUG
        (void) testdebug ((*p13), "element");
#endif

    }

    if ((*p13) != NULLPE)
        if (seq_add ((*pe), (*p13), -1) == NOTOK) {
            advise (NULLCP, "BKQcontent %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }

#ifdef DEBUG
    (void) testdebug ((*pe), "VT.BKQcontent");
#endif


    return OK;
}

/* ARGSUSED */

int	unbuild_VT_BKQcontent (pe, explicit, len, buffer, parm)
register PE	pe;
int	explicit;
int    *len;
char  **buffer;
PEPYPARM parm;
{
# line 72 "bk_content.py"
    
	BRcnt	*arg = (BRcnt *)parm;

    register PE p15;

#ifdef DEBUG
    (void) testdebug (pe, "VT.BKQcontent");
#endif

    if (explicit) {
        if (pe -> pe_class != PE_CLASS_UNIV
                || pe -> pe_form != PE_FORM_CONS
                || pe -> pe_id != PE_CONS_SEQ) {
            advise (NULLCP, "BKQcontent bad class/form/id: %s/%d/0x%x",
                    pe_classlist[pe -> pe_class], pe -> pe_form, pe -> pe_id);
            return NOTOK;
        }
    }
    else
        if (pe -> pe_form != PE_FORM_CONS) {
            advise (NULLCP, "BKQcontent bad form: %d", pe -> pe_form);
            return NOTOK;
        }

    if ((p15 = prim2seq (pe)) == NULLPE) {
        advise (NULLCP, "BKQcontent %s%s", PEPY_ERR_BAD_SEQ,
                pe_error (pe -> pe_errno));
        return NOTOK;
    }
    pe = p15;

    {
        register PE p16;

        if ((p16 = first_member (pe)) != NULLPE
                && PE_ID (p16 -> pe_class, p16 -> pe_id)
                        != PE_ID (PE_CLASS_UNIV, 2))
            p16 = NULLPE;
        if (p16 != NULLPE) {
            p15 = p16;

            {	/* token */
                register integer p17;

#ifdef DEBUG
                (void) testdebug (p16, "token");
#endif

                if (p16 -> pe_class != PE_CLASS_UNIV
                        || p16 -> pe_form != PE_FORM_PRIM
                        || p16 -> pe_id != PE_PRIM_INT) {
                    advise (NULLCP, "token bad class/form/id: %s/%d/0x%x",
                            pe_classlist[p16 -> pe_class], p16 -> pe_form, p16 -> pe_id);
                    return NOTOK;
                }

                if ((p17 = prim2num (p16)) == NOTOK
                        && p16 -> pe_errno != PE_ERR_NONE) {
                    advise (NULLCP, "token %s%s", PEPY_ERR_BAD_INTEGER,
                            pe_error (p16 -> pe_errno));
                    return NOTOK;
                }
                arg->BKQcont.token_val = p17;
                switch (p17) {
                    case 0:	/* initiator */
                        break;
                    case 1:	/* acceptor */
                        break;
                    case 2:	/* accChoice */
                        break;
                }
            }
        }
    }

    {
        register PE p18;

        if ((p18 = (pe != p15 ? next_member (pe, p15) : first_member (pe))) != NULLPE) {
            p15 = p18;

            {
#ifdef DEBUG
                (void) testdebug (p18, "element");
#endif

                if (unbuild_VT_ExplicitPointer (p18, 1, NULLIP, NULLVP, (PEPYPARM)&(arg->BKQcont.ExplPtr)) == NOTOK)
                    return NOTOK;
            }
        }
        else {
            advise (NULLCP, "BKQcontent %selement", PEPY_ERR_MISSING);
            return NOTOK;
        }

    }


    if (pe -> pe_cardinal > 2) {
        advise (NULLCP, "BKQcontent %s(2): %d", PEPY_ERR_TOO_MANY_ELEMENTS,
                pe -> pe_cardinal);
        return NOTOK;
    }

    return OK;
}

/* ARGSUSED */

int	build_VT_BKRcontent (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
# line 91 "bk_content.py"
    
	BRcnt *arg = (BRcnt *)parm;

    PE	p19_z = NULLPE;
    register PE *p19 = &p19_z;

    if (((*pe) = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SEQ)) == NULLPE) {
        advise (NULLCP, "BKRcontent: %s", PEPY_ERR_NOMEM);
        return NOTOK;
    }
    (*p19) = NULLPE;

    if (arg->BKRcont.token_val != NOBKTOK ) {	/* token */
        register integer p20 = arg->BKRcont.token_val;

        if (((*p19) = num2prim (p20, PE_CLASS_UNIV, PE_PRIM_INT)) == NULLPE) {
            advise (NULLCP, "token: %s", PEPY_ERR_NOMEM);
            return NOTOK;
        }
        switch (p20) {
            case 0:	/* initiator */
                break;
            case 1:	/* acceptor */
                break;
        }

#ifdef DEBUG
        (void) testdebug ((*p19), "token");
#endif

    }

    if ((*p19) != NULLPE)
        if (seq_add ((*pe), (*p19), -1) == NOTOK) {
            advise (NULLCP, "BKRcontent %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }
    (*p19) = NULLPE;

    {
        if (build_VT_ExplicitPointer (p19, 0, NULL, NULLCP, (PEPYPARM)&(arg->BKRcont.ExplPtr)) == NOTOK)
            return NOTOK;

#ifdef DEBUG
        (void) testdebug ((*p19), "element");
#endif

    }

    if ((*p19) != NULLPE)
        if (seq_add ((*pe), (*p19), -1) == NOTOK) {
            advise (NULLCP, "BKRcontent %s%s", PEPY_ERR_BAD_SEQ,
                    pe_error ((*pe) -> pe_errno));
            return NOTOK;
        }

#ifdef DEBUG
    (void) testdebug ((*pe), "VT.BKRcontent");
#endif


    return OK;
}

/* ARGSUSED */

int	unbuild_VT_BKRcontent (pe, explicit, len, buffer, parm)
register PE	pe;
int	explicit;
int    *len;
char  **buffer;
PEPYPARM parm;
{
# line 91 "bk_content.py"
    
	BRcnt *arg = (BRcnt *)parm;

    register PE p21;

#ifdef DEBUG
    (void) testdebug (pe, "VT.BKRcontent");
#endif

    if (explicit) {
        if (pe -> pe_class != PE_CLASS_UNIV
                || pe -> pe_form != PE_FORM_CONS
                || pe -> pe_id != PE_CONS_SEQ) {
            advise (NULLCP, "BKRcontent bad class/form/id: %s/%d/0x%x",
                    pe_classlist[pe -> pe_class], pe -> pe_form, pe -> pe_id);
            return NOTOK;
        }
    }
    else
        if (pe -> pe_form != PE_FORM_CONS) {
            advise (NULLCP, "BKRcontent bad form: %d", pe -> pe_form);
            return NOTOK;
        }

    if ((p21 = prim2seq (pe)) == NULLPE) {
        advise (NULLCP, "BKRcontent %s%s", PEPY_ERR_BAD_SEQ,
                pe_error (pe -> pe_errno));
        return NOTOK;
    }
    pe = p21;

    {
        register PE p22;

        if ((p22 = first_member (pe)) != NULLPE
                && PE_ID (p22 -> pe_class, p22 -> pe_id)
                        != PE_ID (PE_CLASS_UNIV, 2))
            p22 = NULLPE;
        if (p22 != NULLPE) {
            p21 = p22;

            {	/* token */
                register integer p23;

#ifdef DEBUG
                (void) testdebug (p22, "token");
#endif

                if (p22 -> pe_class != PE_CLASS_UNIV
                        || p22 -> pe_form != PE_FORM_PRIM
                        || p22 -> pe_id != PE_PRIM_INT) {
                    advise (NULLCP, "token bad class/form/id: %s/%d/0x%x",
                            pe_classlist[p22 -> pe_class], p22 -> pe_form, p22 -> pe_id);
                    return NOTOK;
                }

                if ((p23 = prim2num (p22)) == NOTOK
                        && p22 -> pe_errno != PE_ERR_NONE) {
                    advise (NULLCP, "token %s%s", PEPY_ERR_BAD_INTEGER,
                            pe_error (p22 -> pe_errno));
                    return NOTOK;
                }
                arg->BKRcont.token_val = p23;
                switch (p23) {
                    case 0:	/* initiator */
                        break;
                    case 1:	/* acceptor */
                        break;
                }
            }
        }
    }

    {
        register PE p24;

        if ((p24 = (pe != p21 ? next_member (pe, p21) : first_member (pe))) != NULLPE) {
            p21 = p24;

            {
#ifdef DEBUG
                (void) testdebug (p24, "element");
#endif

                if (unbuild_VT_ExplicitPointer (p24, 1, NULLIP, NULLVP, (PEPYPARM)&(arg->BKRcont.ExplPtr)) == NOTOK)
                    return NOTOK;
            }
        }
        else {
            advise (NULLCP, "BKRcontent %selement", PEPY_ERR_MISSING);
            return NOTOK;
        }

    }


    if (pe -> pe_cardinal > 2) {
        advise (NULLCP, "BKRcontent %s(2): %d", PEPY_ERR_TOO_MANY_ELEMENTS,
                pe -> pe_cardinal);
        return NOTOK;
    }

    return OK;
}
