|
|
1.1 root 1:
2: #ifndef lint
3: static char *rcsid = "$Header: /f/osi/others/quipu/uips/xd/RCS/filt.c,v 7.1 90/07/27 08:45:57 mrose Exp $";
4: #endif
5:
6: /*
7: * $Header: /f/osi/others/quipu/uips/xd/RCS/filt.c,v 7.1 90/07/27 08:45:57 mrose Exp $
8: */
9:
10: /*
11: * $Log: filt.c,v $
12: * Revision 7.1 90/07/27 08:45:57 mrose
13: * update
14: *
15: * Revision 7.0 90/06/12 13:10:49 mrose
16: * *** empty log message ***
17: *
18: * Revision 1.5 90/04/26 10:22:40 emsrssn
19: * Installation fixed
20: *
21: *
22: * Revision 1.4 90/04/25 17:28:10 emsrssn
23: * Lint tidy up
24: *
25: *
26: * Revision 1.3 90/04/19 13:54:11 emsrssn
27: * keyboard accelerator now activates button highlight.
28: *
29: * search types available is dependent on current position
30: * to prevent unreasonable searches.
31: *
32: * the help popup changes automatically depending on the
33: * position of the cursor
34: *
35: * buttons remain a fixed size when the application is
36: * resized
37: *
38: * command line options are now handled properly
39: *
40: * logging added
41: *
42: * "reads" are now sorted to show mail address at top etc.
43: *
44: *
45: * Revision 1.2 90/03/16 11:29:41 emsrdsm
46: * *** empty log message ***
47: *
48: * Revision 1.1 90/03/09 16:48:58 emsrdsm
49: * Initial revision
50: *
51: * Revision 1.1 90/03/09 12:10:17 emsrdsm
52: * Initial revision
53: *
54: * Revision 1.1 90/03/09 11:36:42 emsrdsm
55: * Initial revision
56: *
57: */
58:
59: #include "quipu/util.h"
60: #include "quipu/common.h"
61: #include "quipu/entry.h"
62: #include "filt.h"
63: #include "y.tab.h"
64: #include "symtab.h"
65:
66: extern unsigned int curr_filt;
67: extern unsigned int filt_num;
68: extern unsigned int typeindx;
69: extern filt_struct *filt_arr[];
70: extern char *filtvalue[];
71: extern char *filttype[];
72: extern char *default_arr[];
73:
74: extern char svalue[], mvalue[];
75:
76: make_type(name_val, filt)
77: char * name_val;
78: filt_struct * filt;
79: {
80: filttype[curr_filt] = (char *) malloc((unsigned int) (strlen(name_val) + 1));
81: (void) strcpy(filttype[curr_filt], name_val);
82:
83: /* if (default_val) {
84: default_arr[curr_filt] =
85: (char *) malloc((unsigned int) (strlen(default_val)+1));
86: (void) strcpy(default_arr[curr_filt], default_val);
87: } else {
88: default_arr[curr_filt] = (char *) malloc((unsigned int) 2);
89: *default_arr[curr_filt] = '\0';
90: }*/
91: filt_arr[curr_filt] = filt;
92: }
93:
94: filt_struct *
95: make_item_filter(oid, match, value)
96: char *oid;
97: int match;
98: char *value;
99: {
100: register filt_struct * filt = (filt_struct *) malloc(sizeof(filt_struct));
101:
102: filt->flt_type = ITEM;
103: filt->next = 0;
104:
105: filt->fu_cont.item.fi_type = match;
106: filt->fu_cont.item.stroid =
107: (char *) malloc((unsigned int) (strlen(oid) + 1));
108: (void) strcpy(filt->fu_cont.item.stroid, oid);
109:
110: if (*value == '*') filt->fu_cont.item.name = (char *) 0;
111: else {
112: filt->fu_cont.item.name =
113: (char *) malloc((unsigned int) (strlen(value) + 1));
114: (void) strcpy(filt->fu_cont.item.name, value);
115: }
116: return filt;
117: }
118:
119: filt_struct *
120: link_filters(filt1, filt2)
121: filt_struct *filt1;
122: filt_struct *filt2;
123: {
124: filt1->next = filt2;
125: return filt1;
126: }
127:
128: filt_struct *
129: make_parent_filter(filt_type, filt1, filt2, filt3)
130: int filt_type;
131: filt_struct * filt1;
132: filt_struct * filt2;
133: filt_struct * filt3;
134: {
135: filt_struct * parent = (filt_struct *) malloc(sizeof(filt_struct));
136:
137: switch (filt_type) {
138:
139: case NOT:
140: parent->flt_type = NOT;
141: parent->fu_cont.sub_filt = filt1;
142: parent->next = 0;
143: break;
144:
145: case AND:
146: parent->flt_type = AND;
147: parent->fu_cont.sub_filt = filt1;
148: filt1->next = filt2;
149: filt2->next = filt3;
150: parent->next = 0;
151: break;
152:
153: default:
154: parent->flt_type = OR;
155: parent->fu_cont.sub_filt = filt1;
156: filt1->next = filt2;
157: filt2->next = filt3;
158: parent->next = 0;
159: break;
160: }
161:
162: return parent;
163: }
164:
165: free_filt(filt)
166: filt_struct *filt;
167: {
168: if (filt) {
169: free_filt(filt->next);
170:
171: if (filt->flt_type = ITEM) {
172: free(filt->fu_cont.item.stroid);
173: if (filt->fu_cont.item.name) free(filt->fu_cont.item.name);
174: } else
175: free_filt(filt->fu_cont.sub_filt);
176:
177: free((char *) filt);
178: } else
179: return;
180: }
181:
182: Filter
183: make_filter(filt)
184: filt_struct *filt;
185: {
186: int type;
187: Filter rfilt, sfilt = filter_alloc();
188:
189: if (!filt)
190: return 0;
191:
192: switch(filt->flt_type) {
193:
194: case ITEM:
195: sfilt->flt_type = FILTER_ITEM;
196: sfilt->flt_next = make_filter(filt->next);
197:
198: (void) strcpy(svalue, (filt->fu_cont.item.name?
199: filt->fu_cont.item.name:
200: mvalue));
201:
202: type = filt->fu_cont.item.fi_type;
203:
204: switch(type) {
205: case APPROX:
206: case EQUAL:
207: sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type =
208: AttrT_new(filt->fu_cont.item.stroid);
209:
210: if ((sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_value =
211: str2AttrV(svalue,
212: sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->
213: oa_syntax)) == NULL) {
214:
215: rfilt = sfilt->flt_next;
216: sfilt->flt_next = NULLFILTER;
217: filter_free(sfilt);
218: return rfilt;
219: }
220:
221: if (type == EQUAL)
222: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY;
223: else
224: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
225:
226: break;
227:
228: case SUBSTRING:
229: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_SUBSTRINGS;
230: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_type =
231: AttrT_new(filt->fu_cont.item.stroid);
232:
233: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_initial =
234: NULLAV;
235: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_final =
236: NULLAV;
237: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_any =
238: avs_comp_new(str2AttrV(svalue,
239: sfilt->flt_un.flt_un_item.fi_un.
240: fi_un_substrings.fi_sub_type->
241: oa_syntax));
242: break;
243:
244: default:
245: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
246: break;
247: }
248: return sfilt;
249:
250:
251: case AND:
252: sfilt->flt_type = FILTER_AND;
253: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
254: sfilt->flt_next = make_filter(filt->next);
255: return sfilt;
256:
257:
258: case OR:
259: sfilt->flt_type = FILTER_OR;
260: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
261: sfilt->flt_next = make_filter(filt->next);
262: return sfilt;
263:
264:
265: case NOT:
266: sfilt->flt_type = FILTER_NOT;
267: sfilt->flt_next = make_filter(filt->next);
268: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
269: return sfilt;
270:
271:
272: default:
273: return NULLFILTER;
274: }
275: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.