|
|
1.1 root 1: /* num2prim.c - integer to presentation element */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/psap/RCS/num2prim.c,v 7.0 89/11/23 22:12:45 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/psap/RCS/num2prim.c,v 7.0 89/11/23 22:12:45 mrose Rel $
9: *
10: *
11: * $Log: num2prim.c,v $
12: * Revision 7.0 89/11/23 22:12:45 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 num2prim (i, class, id)
36: register integer i;
37: PElementClass class;
38: PElementID id;
39: {
40: register integer mask,
41: sign,
42: n;
43: register PElementData dp;
44: register PE pe;
45:
46: if ((pe = pe_alloc (class, PE_FORM_PRIM, id)) == NULLPE)
47: return NULLPE;
48:
49: sign = i >= 0 ? i : i ^ (-1);
50: mask = 0x1ff << (((n = sizeof i) - 1) * 8 - 1);
51: while (n > 1 && (sign & mask) == 0)
52: mask >>= 8, n--;
53:
54: if ((pe -> pe_prim = PEDalloc (n)) == NULLPED) {
55: pe_free (pe);
56: return NULLPE;
57: }
58:
59: for (dp = pe -> pe_prim + (pe -> pe_len = n); n-- > 0; i >>= 8)
60: *--dp = i & 0xff;
61:
62: return pe;
63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.