|
|
1.1 ! root 1: /* qbuf2ps.c - qbuf-backed abstractions for PStreams */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/psap/RCS/qbuf2ps.c,v 7.0 89/11/23 22:13:33 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/psap/RCS/qbuf2ps.c,v 7.0 89/11/23 22:13:33 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: qbuf2ps.c,v $ ! 12: * Revision 7.0 89/11/23 22:13:33 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: /* ARGSUSED */ ! 36: ! 37: static int qbuf_read (ps, data, n, in_line) ! 38: register PS ps; ! 39: PElementData data; ! 40: PElementLen n; ! 41: int in_line; ! 42: { ! 43: register int cc, ! 44: i; ! 45: register struct qbuf *qb, ! 46: *qp; ! 47: ! 48: if ((qb = (struct qbuf *) ps -> ps_addr) == NULL) ! 49: return 0; ! 50: ! 51: for (qp = NULL, cc = 0; n > 0; data += i, cc += i, n -= i) { ! 52: if (qp == NULL && (qp = qb -> qb_forw) == qb) ! 53: return cc; ! 54: ! 55: i = min (qp -> qb_len, n); ! 56: bcopy (qp -> qb_data, (char *) data, i); ! 57: ! 58: qp -> qb_data += i, qp -> qb_len -= i; ! 59: if (qp -> qb_len <= 0) { ! 60: remque (qp); ! 61: ! 62: free ((char *) qp); ! 63: qp = NULL; ! 64: } ! 65: } ! 66: ! 67: return cc; ! 68: } ! 69: ! 70: ! 71: static int qbuf_close (ps) ! 72: register PS ps; ! 73: { ! 74: register struct qbuf *qb; ! 75: ! 76: if ((qb = (struct qbuf *) ps -> ps_addr) == NULL) ! 77: return; ! 78: ! 79: QBFREE (qb); ! 80: } ! 81: ! 82: /* */ ! 83: ! 84: int qbuf_open (ps) ! 85: register PS ps; ! 86: { ! 87: ps -> ps_readP = qbuf_read; ! 88: ps -> ps_closeP = qbuf_close; ! 89: ! 90: return OK; ! 91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.