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

1.1     ! root        1: /* prim2qb.c - presentation element to qbuf */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/psap/RCS/prim2qb.c,v 7.0 89/11/23 22:13:13 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/psap/RCS/prim2qb.c,v 7.0 89/11/23 22:13:13 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       prim2qb.c,v $
        !            12:  * Revision 7.0  89/11/23  22:13:13  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                               NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: /* LINTLIBRARY */
        !            29: 
        !            30: #include <stdio.h>
        !            31: #include "psap.h"
        !            32: 
        !            33: /*  */
        !            34: 
        !            35: struct qbuf *prim2qb (pe)
        !            36: register PE    pe;
        !            37: {
        !            38:     register struct qbuf *qb,
        !            39:                         *qp;
        !            40:     register PE            p;
        !            41:     register PElementClass class;
        !            42:     register PElementID id;
        !            43: 
        !            44:     if ((qb = (struct qbuf *) malloc (sizeof *qb)) == NULL)
        !            45:        return pe_seterr (pe, PE_ERR_NMEM, (struct qbuf *) NULL);
        !            46:     qb -> qb_forw = qb -> qb_back = qb;
        !            47:     qb -> qb_data = NULL, qb -> qb_len = 0;
        !            48:        
        !            49:     switch (pe -> pe_form) {
        !            50:        case PE_FORM_PRIM:
        !            51:            if ((qp = str2qb ((char *) pe -> pe_prim, (int) pe -> pe_len, 0))
        !            52:                    == NULL) {
        !            53:                pe -> pe_errno = PE_ERR_NMEM;
        !            54:                goto out;
        !            55:            }
        !            56:            qb -> qb_len = qp -> qb_len;
        !            57:            insque (qp, qb);
        !            58:            break;
        !            59: 
        !            60:        case PE_FORM_CONS:
        !            61:            if ((p = pe -> pe_cons) == NULLPE)
        !            62:                break;
        !            63:            class = p -> pe_class, id = p -> pe_id;
        !            64:            for (p = pe -> pe_cons; p; p = p -> pe_next) {
        !            65:                register struct qbuf *qpp,
        !            66:                                     *qbp;
        !            67: 
        !            68:                if ((p -> pe_class != class || p -> pe_id != id)
        !            69:                        && (p -> pe_class != PE_CLASS_UNIV
        !            70:                                || p -> pe_id != PE_PRIM_OCTS)) {
        !            71:                    pe -> pe_errno = PE_ERR_TYPE;
        !            72:                    goto out;
        !            73:                }
        !            74:                if ((qp = prim2qb (p)) == NULL) {
        !            75:                    pe -> pe_errno = p -> pe_errno;
        !            76:                    goto out;
        !            77:                }
        !            78: 
        !            79:                for (qpp = qp -> qb_forw; qpp != qp; qpp = qbp) {
        !            80:                    qbp = qpp -> qb_forw;
        !            81: 
        !            82:                    remque (qpp);
        !            83:                    insque (qpp, qb -> qb_back);
        !            84: 
        !            85:                    qb -> qb_len += qpp -> qb_len;
        !            86:                }
        !            87:                free ((char *) qp);
        !            88:            }
        !            89:            break;
        !            90:     }
        !            91: 
        !            92:     return qb;
        !            93: 
        !            94: out: ;
        !            95:     qb_free (qb);
        !            96: 
        !            97:     return NULL;
        !            98: }

unix.superglobalmegacorp.com

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