|
|
1.1 ! root 1: /* strb2bitstr.c - string of bits to bit string */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/psap/RCS/strb2bitstr.c,v 7.0 89/11/23 22:13:50 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/psap/RCS/strb2bitstr.c,v 7.0 89/11/23 22:13:50 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: strb2bitstr.c,v $ ! 12: * Revision 7.0 89/11/23 22:13:50 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: PE strb2bitstr (cp, len, class, id) ! 36: register char *cp; ! 37: register int len; ! 38: PElementClass class; ! 39: PElementID id; ! 40: { ! 41: register int i, ! 42: j, ! 43: bit, ! 44: mask; ! 45: register PE p; ! 46: ! 47: if ((p = pe_alloc (class, PE_FORM_PRIM, id)) == NULLPE) ! 48: return NULLPE; ! 49: ! 50: p = prim2bit (p); ! 51: if (len > 0 && bit_off (p, len - 1) == NOTOK) { ! 52: no_mem: ; ! 53: pe_free (p); ! 54: return NULLPE; ! 55: } ! 56: ! 57: for (bit = (*cp & 0xff), i = 0, mask = 1 << (j = 7); i < len; i++) { ! 58: if ((bit & mask) && bit_on (p, i) == NOTOK) ! 59: goto no_mem; ! 60: if (j-- == 0) ! 61: bit = *++cp & 0xff, mask = 1 << (j = 7); ! 62: else ! 63: mask >>= 1; ! 64: } ! 65: ! 66: return p; ! 67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.