|
|
1.1 ! root 1: /* qb2pe.c - create a variable-depth Inline CONStructor PElement */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/psap/RCS/qb2pe.c,v 7.1 90/01/11 23:47:00 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/psap/RCS/qb2pe.c,v 7.1 90/01/11 23:47:00 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: qb2pe.c,v $ ! 12: * Revision 7.1 90/01/11 23:47:00 mrose ! 13: * lint ! 14: * ! 15: * Revision 7.0 89/11/23 22:13:28 mrose ! 16: * Release 6.0 ! 17: * ! 18: */ ! 19: ! 20: /* ! 21: * NOTICE ! 22: * ! 23: * Acquisition, use, and distribution of this module and related ! 24: * materials are subject to the restrictions of a license agreement. ! 25: * Consult the Preface in the User's Manual for the full terms of ! 26: * this agreement. ! 27: * ! 28: */ ! 29: ! 30: ! 31: /* LINTLIBRARY */ ! 32: ! 33: #include <stdio.h> ! 34: #include "psap.h" ! 35: #include "tailor.h" ! 36: ! 37: /* */ ! 38: ! 39: PE qb2pe_aux (); ! 40: ! 41: /* */ ! 42: ! 43: PE qb2pe (qb, len, depth, result) ! 44: register struct qbuf *qb; ! 45: int len, ! 46: depth; ! 47: int *result; ! 48: { ! 49: char *sp; ! 50: register struct qbuf *qp; ! 51: PE pe; ! 52: ! 53: *result = PS_ERR_NONE; ! 54: if (depth <= 0) ! 55: return NULLPE; ! 56: ! 57: if ((qp = qb -> qb_forw) != qb && qp -> qb_forw == qb) ! 58: sp = qp -> qb_data; ! 59: else { ! 60: qp = NULL; ! 61: ! 62: if ((sp = qb2str (qb)) == NULL) { ! 63: *result = PS_ERR_NMEM; ! 64: return NULLPE; ! 65: } ! 66: } ! 67: ! 68: if (pe = qb2pe_aux (sp, len, depth, result)) { ! 69: if (qp) { ! 70: pe -> pe_realbase = (char *) qp; ! 71: ! 72: remque (qp); ! 73: } ! 74: else { ! 75: pe -> pe_realbase = sp; ! 76: ! 77: QBFREE (qb); ! 78: } ! 79: pe -> pe_inline = 0; ! 80: } ! 81: else ! 82: if (qp == NULL) ! 83: free (sp); ! 84: ! 85: #ifdef DEBUG ! 86: if (pe && (psap_log -> ll_events & LLOG_PDUS)) ! 87: pe2text (psap_log, pe, 1, len); ! 88: #endif ! 89: ! 90: return pe; ! 91: } ! 92: ! 93: /* */ ! 94: ! 95: static PE qb2pe_aux (s, len, depth, result) ! 96: register char *s; ! 97: register int len; ! 98: int depth; ! 99: int *result; ! 100: { ! 101: int i; ! 102: register PElementData data; ! 103: register PE pe, ! 104: p, ! 105: q; ! 106: PE *r, ! 107: *rp; ! 108: ! 109: depth--; ! 110: ! 111: if ((pe = str2pe (s, len, &i, result)) == NULLPE) ! 112: return NULLPE; ! 113: ! 114: if (pe -> pe_form == PE_FORM_ICONS) { ! 115: pe -> pe_form = PE_FORM_CONS; ! 116: pe -> pe_prim = NULLPED, pe -> pe_inline = 0; ! 117: pe -> pe_len -= pe -> pe_ilen; ! 118: ! 119: p = NULLPE, r = &pe -> pe_cons; ! 120: for (s += pe -> pe_ilen, len -= pe -> pe_ilen; ! 121: len > 0; ! 122: s += i, len -= i) { ! 123: if ((p = str2pe (s, len, &i, result)) == NULLPE) ! 124: goto out; ! 125: ! 126: if (p -> pe_form == PE_FORM_ICONS) { ! 127: if (depth > 0) { ! 128: if ((q = qb2pe_aux ((char *) p -> pe_prim, i, depth, ! 129: result)) == NULLPE) ! 130: goto out; ! 131: pe_free (p); ! 132: p = q; ! 133: } ! 134: else { ! 135: if ((data = PEDalloc (i)) == NULL) { ! 136: *result = PS_ERR_NMEM; ! 137: goto out; ! 138: } ! 139: PEDcpy (p -> pe_prim, data, i); ! 140: p -> pe_prim = data, p -> pe_inline = 0; ! 141: } ! 142: } ! 143: ! 144: *r = p, rp = r, r = &p -> pe_next; ! 145: } ! 146: ! 147: if (p && p -> pe_class == PE_CLASS_UNIV && p -> pe_id == PE_UNIV_EOC) { ! 148: pe_free (p); ! 149: *rp = NULLPE; ! 150: } ! 151: } ! 152: ! 153: return pe; ! 154: ! 155: out: ; ! 156: pe_free (pe); ! 157: return NULLPE; ! 158: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.