Start development on 386BSD 0.0
[unix-history] / .ref-BSD-4_3_Net_2 / usr / src / contrib / isode / dsap / common / cilist.c
CommitLineData
f522e28b
C
1/* cilist.c - Case Ignore List */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/dsap/common/RCS/cilist.c,v 7.1 91/02/22 09:18:49 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/dsap/common/RCS/cilist.c,v 7.1 91/02/22 09:18:49 mrose Interim $
9 *
10 *
11 * $Log: cilist.c,v $
12 * Revision 7.1 91/02/22 09:18:49 mrose
13 * Interim 6.8
14 *
15 * Revision 7.0 90/08/24 12:10:42 mrose
16 * *** empty log message ***
17 *
18 */
19
20/*
21 * NOTICE
22 *
23 * Acquisition, use, and distribution of this module and related
24 * materials are subject to the restrictions of a license agreement.
25 * Consult the Preface in the User's Manual for the full terms of
26 * this agreement.
27 *
28 */
29
30
31/*
32 SYNTAX:
33 list = <list_component> | <list_component> '$' <list>
34 list_component = [ '{T61}' ] <string>
35
36 EXAMPLE:
37 An example $ of a case ignore list $ syntax attribute
38*/
39
40/* LINTLIBRARY */
41
42#include "quipu/util.h"
43#include "quipu/attrvalue.h"
44#include "quipu/syntaxes.h"
45
46static cilistfree (cilist)
47struct CIList * cilist;
48{
49 struct CIList * next;
50 for (; cilist != NULLCILIST; cilist = next) {
51 next = cilist->l_next;
52 free (cilist->l_str);
53 free ( (char *)cilist);
54 }
55}
56
57static cilistcmp (a,b)
58struct CIList * a, *b;
59{
60int res;
61
62 for (; (a != NULLCILIST) && (b != NULLCILIST) ;
63 a = a->l_next, b=b->l_next)
64 if ((res = lexequ (a->l_str, b->l_str)) != 0)
65 return (res);
66
67 if ( a != b)
68 return ( a > b ? 1 : -1 );
69 else
70 return (0);
71
72}
73
74static struct CIList * cilistcpy (a)
75struct CIList * a;
76{
77struct CIList * b, *c, *result = NULLCILIST;
78
79 c = result; /* to keep lint quiet ! */
80
81 for (; a != NULLCILIST; a = a->l_next) {
82 b = (struct CIList *) smalloc (sizeof (struct CIList));
83 b -> l_type = a->l_type;
84 b -> l_str = strdup (a->l_str);
85
86 if (result == NULLCILIST)
87 result = b;
88 else
89 c->l_next = b;
90 c = b;
91 }
92
93 b->l_next = NULLCILIST;
94 return (result);
95}
96
97static struct CIList* cilistparse (str)
98char * str;
99{
100struct CIList * result = NULLCILIST;
101struct CIList * a, *b;
102char * ptr;
103char * mark = NULLCP;
104char t61_str = FALSE;
105extern char t61_flag;
106char * octparse ();
107char * prtparse ();
108
109 b = result; /* to keep lint quiet */
110
111 if (t61_flag) {
112 t61_str = TRUE;
113 t61_flag = FALSE; /* indicate recognition */
114 }
115
116 ptr = str = SkipSpace(str);
117
118 while (ptr) {
119 mark = NULLCP;
120 a = (struct CIList *) smalloc (sizeof (struct CIList));
121
122 if ( (ptr=index (str,'$')) != NULLCP) {
123 *ptr-- = 0;
124 if (isspace (*ptr)) {
125 *ptr = 0;
126 mark = ptr;
127 }
128 ptr++;
129 }
130
131 if (*str == 0) {
132 parse_error ("Null string not allowed",NULLCP);
133 return NULLCILIST;
134 }
135
136 if ((t61_str) || (! check_print_string(str))) {
137 a -> l_type = 1;
138 if ((a -> l_str = octparse (str)) == NULLCP)
139 return (NULLCILIST);
140 } else {
141 a -> l_str = strdup(str);
142 a -> l_type = 2;
143 }
144
145 if (result == NULLCILIST)
146 result = a;
147 else
148 b->l_next = a;
149 b = a;
150
151 t61_str = FALSE;
152
153 if (ptr != NULLCP) {
154 *ptr++ = '$';
155 if (mark != NULLCP)
156 *mark = ' ';
157 str = (SkipSpace(ptr));
158 ptr = str;
159
160 if (*ptr++ == '{') {
161 if (( str = index (ptr,'}')) == 0) {
162 parse_error ("close bracket missing '%s'",--ptr);
163 return (NULLCILIST);
164 }
165 *str = 0;
166 if (lexequ ("T.61",ptr) != 0) {
167 *str = '}';
168 parse_error ("{T.61} expected '%s'",--ptr);
169 return (NULLCILIST);
170 }
171 *str++ = '}';
172 str = (SkipSpace(str));
173 t61_str = TRUE;
174 }
175 }
176 }
177
178 a -> l_next = NULLCILIST ;
179
180 return (result);
181}
182
183static cilistprint (ps,cilist,format)
184PS ps;
185struct CIList * cilist;
186int format;
187{
188char * prefix = NULLCP;
189
190 for (; cilist != NULLCILIST; cilist = cilist->l_next) {
191 if (prefix != NULLCP)
192 ps_print (ps,prefix);
193
194 if (cilist->l_type == 1) {
195 if (format != READOUT)
196 ps_print (ps,"{T.61}");
197 octprint (ps,cilist->l_str,format);
198 } else
199 ps_print (ps,cilist->l_str);
200
201 if (format == READOUT)
202 prefix = "\n\t\t\t";
203 else
204 prefix = " $\\\n\t";
205 }
206}
207
208
209static PE cilistenc (m)
210struct CIList * m;
211{
212PE ret_pe;
213
214 (void) encode_SA_CaseIgnoreList (&ret_pe,0,0,NULLCP,m);
215
216 return (ret_pe);
217}
218
219static struct CIList * cilistdec (pe)
220PE pe;
221{
222struct CIList * m;
223
224 if (decode_SA_CaseIgnoreList (pe,1,NULLIP,NULLVP,&m) == NOTOK)
225 return (NULLCILIST);
226 return (m);
227}
228
229cilist_syntax ()
230{
231 (void) add_attribute_syntax ("CaseIgnoreList",
232 (IFP) cilistenc, (IFP) cilistdec,
233 (IFP) cilistparse, cilistprint,
234 (IFP) cilistcpy, cilistcmp,
235 cilistfree, NULLCP,
236 NULLIFP, TRUE);
237
238}
239