/* 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 UDQPDU */
# line 25 "send_udq.py"

#include <stdio.h>
#include "sector1.h"

#undef PEPYPARM
#define PEPYPARM int *
    


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

/* ARGSUSED */

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

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

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

            }
            break;

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

#ifdef DEBUG
    (void) testdebug ((*pe), "UDQPDU.UDQpdu");
#endif


    return OK;
}

/* ARGSUSED */

int	build_UDQPDU_COupdate (pe, explicit, len, buffer, parm)
register PE     *pe;
int	explicit;
int	len;
char   *buffer;
PEPYPARM parm;
{
# line 47 "send_udq.py"
    
	TEXT_UPDATE	*ud = (TEXT_UPDATE *) parm;
	CO_UPDATE	*arg = (CO_UPDATE *) &(ud->updates.co_list);

    PE	p1_z = NULLPE;
    register PE *p1 = &p1_z;

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

    {	/* coName */
        if (build_UNIV_PrintableString (p1, 0, NULL, arg->co_name, NullParm) == NOTOK)
            return NOTOK;

#ifdef DEBUG
        (void) testdebug ((*p1), "coName");
#endif

    }

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

    {	/* objectUpdate */
        int	p2;

        switch (p2 = (arg->co_type + 1)) {
            case 1:	/* characterUpdate */
                {
                    if (build_UNIV_PrintableString (p1, 0, NULL, arg->co_cmd.char_update, NullParm) == NOTOK)
                        return NOTOK;
                    (*p1) -> pe_class = PE_CLASS_CONT;
                    (*p1) -> pe_id = 0;

#ifdef DEBUG
                    (void) testdebug ((*p1), "characterUpdate");
#endif

                }
                break;
            case 2:	/* booleanUpdate */
                {
                    PE	p3_z = NULLPE;
                    register PE *p3 = &p3_z;

                    if (((*p1) = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS, 1)) == NULLPE) {
                        advise (NULLCP, "booleanUpdate: %s", PEPY_ERR_NOMEM);
                        return NOTOK;
                    }
                    (*p3) = NULLPE;

                    {	/* values */
                        PE	p4_z = NULLPE;
                        register PE *p4 = &p4_z;

                        char *p5;
                        int p6;
                        p5 = arg->co_cmd.bool_update.value ;
                        p6 =  arg->co_cmd.bool_update.val_count;
                        (*p4) = p5 ? strb2bitstr (p5, p6, PE_CLASS_CONT, 0) : NULLPE;
                        if ((*p4) == NULLPE) {
                            advise (NULLCP, "values %s", PEPY_ERR_INIT_FAILED);
                            return NOTOK;
                        }
                        if (((*p3) = bit2prim ((*p4))) == NULLPE) {
                            advise (NULLCP, "values: %s", PEPY_ERR_NOMEM);
                            return NOTOK;
                        }

#ifdef DEBUG
                        (void) testdebug ((*p3), "values");
#endif

                    }

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

                    {	/* mask */
                        PE	p7_z = NULLPE;
                        register PE *p7 = &p7_z;

                        char *p8;
                        int p9;
                        p8 = arg->co_cmd.bool_update.mask ;
                        p9 =  arg->co_cmd.bool_update.mask_count;
                        (*p7) = p8 ? strb2bitstr (p8, p9, PE_CLASS_CONT, 1) : NULLPE;
                        if ((*p7) == NULLPE) {
                            advise (NULLCP, "mask %s", PEPY_ERR_INIT_FAILED);
                            return NOTOK;
                        }
                        if (((*p3) = bit2prim ((*p7))) == NULLPE) {
                            advise (NULLCP, "mask: %s", PEPY_ERR_NOMEM);
                            return NOTOK;
                        }

#ifdef DEBUG
                        (void) testdebug ((*p3), "mask");
#endif

                    }

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

#ifdef DEBUG
                    (void) testdebug ((*p1), "booleanUpdate");
#endif

                }
                break;
            case 3:	/* symbolicUpdate */
                {
                    register integer p10 = arg->co_cmd.sym_update;

                    if (((*p1) = num2prim (p10, PE_CLASS_CONT, 2)) == NULLPE) {
                        advise (NULLCP, "symbolicUpdate: %s", PEPY_ERR_NOMEM);
                        return NOTOK;
                    }

#ifdef DEBUG
                    (void) testdebug ((*p1), "symbolicUpdate");
#endif

                }
                break;
            case 4:	/* integerUpdate */
                {
                    register integer p11 = arg->co_cmd.int_update;

                    if (((*p1) = num2prim (p11, PE_CLASS_CONT, 3)) == NULLPE) {
                        advise (NULLCP, "integerUpdate: %s", PEPY_ERR_NOMEM);
                        return NOTOK;
                    }

#ifdef DEBUG
                    (void) testdebug ((*p1), "integerUpdate");
#endif

                }
                break;
            case 5:	/* bitStringUpdate */
                {
                    PE	p12_z = NULLPE;
                    register PE *p12 = &p12_z;

                    char *p13;
                    int p14;
                    p13 = int2strb (arg->co_cmd.bit_update.bitstring,
				      arg->co_cmd.bit_update.bitcount)
			  ;
                    p14 =  arg->co_cmd.bit_update.bitcount;
                    (*p12) = p13 ? strb2bitstr (p13, p14, PE_CLASS_CONT, 4) : NULLPE;
                    if ((*p12) == NULLPE) {
                        advise (NULLCP, "bitStringUpdate %s", PEPY_ERR_INIT_FAILED);
                        return NOTOK;
                    }
                    if (((*p1) = bit2prim ((*p12))) == NULLPE) {
                        advise (NULLCP, "bitStringUpdate: %s", PEPY_ERR_NOMEM);
                        return NOTOK;
                    }

#ifdef DEBUG
                    (void) testdebug ((*p1), "bitStringUpdate");
#endif

                }
                break;

            default:
                advise (NULLCP, "objectUpdate %s%d", PEPY_ERR_INVALID_CHOICE, 
                        p2);
                return NOTOK;
        }

#ifdef DEBUG
        (void) testdebug ((*p1), "objectUpdate");
#endif

    }

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

#ifdef DEBUG
    (void) testdebug ((*pe), "UDQPDU.COupdate");
#endif


    return OK;
}
