Annotation of 43BSDReno/contrib/isode-beta/psap/bitstr2strb.c, revision 1.1.1.1

1.1       root        1: /* bitstr2strb.c - bit string to string of bits */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/psap/RCS/bitstr2strb.c,v 7.0 89/11/23 22:12:33 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/psap/RCS/bitstr2strb.c,v 7.0 89/11/23 22:12:33 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       bitstr2strb.c,v $
                     12:  * Revision 7.0  89/11/23  22:12: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: char   *bitstr2strb (pe, k)
                     36: PE     pe;
                     37: int    *k;
                     38: {
                     39:     register int    i,
                     40:                    j,
                     41:                    len,
                     42:                    bit,
                     43:                    mask;
                     44:     register char   *dp;
                     45:     char   *cp;
                     46: 
                     47:     if (pe == NULLPE)
                     48:        return NULLCP;
                     49: 
                     50:     *k = len = pe -> pe_nbits;
                     51:     if ((cp = dp = calloc (1, (unsigned) (len / 8 + 2))) == NULLCP)
                     52:        return NULLCP;
                     53: 
                     54:     for (bit = i = 0, mask = 1 << (j = 7); i < len; i++) {
                     55:        if (bit_test (pe, i))
                     56:            bit |= mask;
                     57:        if (j-- == 0)
                     58:            *dp++ = bit & 0xff, bit = 0, mask = 1 << (j = 7);
                     59:        else
                     60:            mask >>= 1;
                     61:     }
                     62:     if (j != 7)
                     63:        *dp = bit & 0xff;
                     64: 
                     65:     return cp;
                     66: }

unix.superglobalmegacorp.com

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