|
|
1.1 root 1: /* obj2prim.c - object identifier to presentation element */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/psap/RCS/obj2prim.c,v 7.0 89/11/23 22:12:46 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/psap/RCS/obj2prim.c,v 7.0 89/11/23 22:12:46 mrose Rel $
9: *
10: *
11: * $Log: obj2prim.c,v $
12: * Revision 7.0 89/11/23 22:12:46 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 obj2prim (o, class, id)
36: register OID o;
37: PElementClass class;
38: PElementID id;
39: {
40: register int i,
41: m,
42: n,
43: *mp,
44: *np;
45: register unsigned int j,
46: *ip;
47: register PElementData dp,
48: ep;
49: register PE pe;
50:
51: if (o == NULLOID || o -> oid_nelem <= 1)
52: return NULLPE;
53:
54: if ((pe = pe_alloc (class, PE_FORM_PRIM, id)) == NULLPE)
55: return NULLPE;
56:
57: if ((np = (int *) malloc ((unsigned) (o -> oid_nelem) * sizeof *np))
58: == NULL) {
59: pe_free (pe);
60: return NULLPE;
61: }
62:
63: for (i = n = 0, ip = o -> oid_elements, mp = np;
64: i < o -> oid_nelem;
65: i++, ip++) {
66: if (ip == o -> oid_elements)
67: j = *ip++ * 40, i++, j+= *ip;
68: else
69: j = *ip;
70: m = 0;
71: do {
72: m++;
73: j >>= 7;
74: }
75: while (j);
76: n += (*mp++ = m);
77: }
78:
79: if ((pe -> pe_prim = PEDalloc (pe -> pe_len = n)) == NULLPED) {
80: free ((char *) np);
81: pe_free (pe);
82: return NULLPE;
83: }
84:
85: dp = pe -> pe_prim;
86: for (i = 0, ip = o -> oid_elements, mp = np;
87: i < o -> oid_nelem;
88: i++, ip++) {
89: if (ip == o -> oid_elements)
90: j = *ip++ * 40, i++, j += *ip;
91: else
92: j = *ip;
93:
94: ep = dp + (m = *mp++) - 1;
95: for (dp = ep; m-- > 0; j >>= 7)
96: *dp-- = (j & 0x7f) | 0x80;
97: *ep &= ~0x80;
98: dp = ep + 1;
99: }
100:
101: free ((char *) np);
102:
103: return pe;
104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.