Commit | Line | Data |
---|---|---|
53102063 C |
1 | /* ftambits.c - FPM: encode/decode BIT STRINGs */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/ftam/RCS/ftambits.c,v 7.2 91/02/22 09:22:39 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/ftam/RCS/ftambits.c,v 7.2 91/02/22 09:22:39 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: ftambits.c,v $ | |
12 | * Revision 7.2 91/02/22 09:22:39 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.1 90/11/21 11:30:06 mrose | |
16 | * sun | |
17 | * | |
18 | * Revision 7.0 89/11/23 21:53:25 mrose | |
19 | * Release 6.0 | |
20 | * | |
21 | */ | |
22 | ||
23 | /* | |
24 | * NOTICE | |
25 | * | |
26 | * Acquisition, use, and distribution of this module and related | |
27 | * materials are subject to the restrictions of a license agreement. | |
28 | * Consult the Preface in the User's Manual for the full terms of | |
29 | * this agreement. | |
30 | * | |
31 | */ | |
32 | ||
33 | ||
34 | /* LINTLIBRARY */ | |
35 | ||
36 | #include <stdio.h> | |
37 | #include "fpkt.h" | |
38 | ||
39 | /* \f */ | |
40 | ||
41 | PE bits2fpm (fsb, pairs, actions, fti) | |
42 | register struct ftamblk *fsb; | |
43 | struct pair pairs[]; | |
44 | int actions; | |
45 | struct FTAMindication *fti; | |
46 | { | |
47 | register struct pair *pp; | |
48 | register PE fpm; | |
49 | ||
50 | if ((fpm = prim2bit (pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_BITS))) | |
51 | == NULLPE) { | |
52 | no_mem: ; | |
53 | (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); | |
54 | if (fpm) | |
55 | pe_free (fpm); | |
56 | return NULLPE; | |
57 | } | |
58 | ||
59 | for (pp = pairs; pp -> p_mask; pp++) | |
60 | if ((actions & pp -> p_mask) && bit_on (fpm, pp -> p_bitno) == NOTOK) | |
61 | goto no_mem; | |
62 | ||
63 | return fpm; | |
64 | } | |
65 | ||
66 | /* \f */ | |
67 | ||
68 | /* ARGSUSED */ | |
69 | ||
70 | int fpm2bits (fsb, pairs, fpm, actions, fti) | |
71 | struct ftamblk *fsb; | |
72 | struct pair pairs[]; | |
73 | register PE fpm; | |
74 | int *actions; | |
75 | struct FTAMindication *fti; | |
76 | { | |
77 | register int i; | |
78 | register int bits_set=0; | |
79 | register struct pair *pp; | |
80 | ||
81 | i = 0; | |
82 | for (pp = pairs; pp -> p_mask; pp++) | |
83 | if (bit_test (fpm, pp -> p_bitno) > OK) { | |
84 | i |= pp -> p_mask; | |
85 | bits_set++; | |
86 | } | |
87 | ||
88 | *actions = i; | |
89 | if (bits_set == 0) | |
90 | return NOTOK; | |
91 | else | |
92 | return (bits_set); | |
93 | } |