|
|
1.1 root 1: /* sprintb.c - sprintf on bits */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/compat/RCS/sprintb.c,v 7.0 89/11/23 21:23:33 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/compat/RCS/sprintb.c,v 7.0 89/11/23 21:23:33 mrose Rel $
9: *
10: *
11: * $Log: sprintb.c,v $
12: * Revision 7.0 89/11/23 21:23: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 "general.h"
32: #include "manifest.h"
33:
34: /* */
35:
36: char *sprintb (v, bits)
37: register int v;
38: register char *bits;
39: {
40: register int i,
41: j;
42: register char c,
43: *bp;
44: static char buffer[BUFSIZ];
45:
46: (void) sprintf (buffer, bits && *bits == 010 ? "0%o" : "0x%x", v);
47: bp = buffer + strlen (buffer);
48:
49: if (bits && *++bits) {
50: j = 0;
51: *bp++ = '<';
52: while (i = *bits++)
53: if (v & (1 << (i - 1))) {
54: if (j++)
55: *bp++ = ',';
56: for (; (c = *bits) > 32; bits++)
57: *bp++ = c;
58: }
59: else
60: for (; *bits > 32; bits++)
61: continue;
62: *bp++ = '>';
63: *bp = NULL;
64: }
65:
66: return buffer;
67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.