blob: 2829e35b1d387bf9cc06262469d58002cc894d7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* prim2bit.c - presentation element to bit string */
/*
* isode/psap/prim2bit.c
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include <stdio.h>
#include "psap.h"
/* */
PE prim2bit (pe)
register PE pe;
{
int i;
register PElementData bp;
register PElementLen len;
register PE p;
switch (pe -> pe_form) {
case PE_FORM_PRIM: /* very paranoid... */
if ((bp = pe -> pe_prim) && (len = pe -> pe_len)) {
if ((i = *bp & 0xff) > 7)
return pe_seterr (pe, PE_ERR_BITS, NULLPE);
pe -> pe_nbits = ((len - 1) * 8) - i;
}
else
pe -> pe_nbits = 0;
break;
case PE_FORM_CONS:
pe -> pe_nbits = 0;
for (p = pe -> pe_cons; p; p = p -> pe_next) {
if (prim2bit (p) == NULLPE)
return NULLPE;
pe -> pe_nbits += p -> pe_nbits;
}
break;
}
return pe;
}
|