|
|
BSD 4.3reno
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/filt.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/filt.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*/
/*
* $Log: filt.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.1 90/07/27 08:45:37 mrose
* update
*
* Revision 7.0 90/06/12 13:15:49 mrose
* *** empty log message ***
*
* Revision 1.5 90/04/26 10:21:12 emsrdsm
* *** empty log message ***
*
* Revision 1.4 90/04/25 13:47:24 emsrdsm
* i) lint'ed
*
* Revision 1.3 90/04/20 10:28:16 emsrdsm
* (i) fixed form bug
*
* Revision 1.2 90/04/18 18:48:11 emsrdsm
* i) added logging
*
* Revision 1.1 90/04/10 16:43:44 emsrdsm
* Initial revision
*
*/
#include <string.h>
#include <malloc.h>
#include <ctype.h>
#include "quipu/util.h"
#include "quipu/common.h"
#include "quipu/entry.h"
#include "filt.h"
#include "y.tab.h"
#include "symtab.h"
extern unsigned int curr_filt;
extern unsigned int filt_num;
extern unsigned int typeindx;
extern filt_struct *filt_arr[];
extern char *filtvalue[];
extern char *filttype[];
extern char *default_arr[];
extern char svalue[], mvalue[];
make_type(name_val, filt)
char * name_val;
filt_struct * filt;
{
filttype[curr_filt] = (char *) malloc((unsigned int) (strlen(name_val) + 1));
(void) strcpy(filttype[curr_filt], name_val);
/* if (default_val) {
default_arr[curr_filt] =
(char *) malloc((unsigned int) (strlen(default_val)+1));
(void) strcpy(default_arr[curr_filt], default_val);
} else {
default_arr[curr_filt] = (char *) malloc((unsigned int) 2);
*default_arr[curr_filt] = '\0';
}*/
filt_arr[curr_filt] = filt;
}
filt_struct *
make_item_filter(oid, match, value)
char *oid;
int match;
char *value;
{
register filt_struct * filt = (filt_struct *) malloc(sizeof(filt_struct));
filt->flt_type = ITEM;
filt->next = 0;
filt->fu_cont.item.fi_type = match;
filt->fu_cont.item.stroid =
(char *) malloc((unsigned int) (strlen(oid) + 1));
(void) strcpy(filt->fu_cont.item.stroid, oid);
if (*value == '*') filt->fu_cont.item.name = (char *) 0;
else {
filt->fu_cont.item.name =
(char *) malloc((unsigned int) (strlen(value) + 1));
(void) strcpy(filt->fu_cont.item.name, value);
}
return filt;
}
filt_struct *
link_filters(filt1, filt2)
filt_struct *filt1;
filt_struct *filt2;
{
filt1->next = filt2;
return filt1;
}
filt_struct *
make_parent_filter(filt_type, filt1, filt2, filt3)
int filt_type;
filt_struct * filt1;
filt_struct * filt2;
filt_struct * filt3;
{
filt_struct * parent = (filt_struct *) malloc(sizeof(filt_struct));
switch (filt_type) {
case NOT:
parent->flt_type = NOT;
parent->fu_cont.sub_filt = filt1;
parent->next = 0;
break;
case AND:
parent->flt_type = AND;
parent->fu_cont.sub_filt = filt1;
filt1->next = filt2;
filt2->next = filt3;
parent->next = 0;
break;
default:
parent->flt_type = OR;
parent->fu_cont.sub_filt = filt1;
filt1->next = filt2;
filt2->next = filt3;
parent->next = 0;
break;
}
return parent;
}
free_filt(filt)
filt_struct *filt;
{
if (filt) {
free_filt(filt->next);
if (filt->flt_type = ITEM) {
free(filt->fu_cont.item.stroid);
if (filt->fu_cont.item.name) free(filt->fu_cont.item.name);
} else
free_filt(filt->fu_cont.sub_filt);
free((char *) filt);
} else
return;
}
Filter
make_filter(filt)
filt_struct *filt;
{
int type, count;
char *value;
Filter rfilt, sfilt = filter_alloc();
if (!filt)
return (Filter) 0;
switch(filt->flt_type) {
case ITEM:
sfilt->flt_type = FILTER_ITEM;
sfilt->flt_next = make_filter(filt->next);
if (strcmp(filt->fu_cont.item.stroid, "2.5.4.4"))
(void) strcpy(svalue, (filt->fu_cont.item.name?
filt->fu_cont.item.name:
mvalue));
else if (!filt->fu_cont.item.name) {
count = strlen(mvalue);
value = mvalue + count - 1;
while(!isalpha(*value) && value > mvalue) value--;
while (!isspace(*value) && value > mvalue) value--;
if (mvalue < value) (void) strcpy(svalue, ++value);
else (void) strcpy(svalue, mvalue);
} else (void) strcpy(svalue, filt->fu_cont.item.name);
type = filt->fu_cont.item.fi_type;
switch(type) {
case APPROX:
case EQUAL:
sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type =
AttrT_new(filt->fu_cont.item.stroid);
if ((sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_value =
str2AttrV(svalue,
sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->
oa_syntax)) == NULL) {
rfilt = sfilt->flt_next;
sfilt->flt_next = NULLFILTER;
filter_free(sfilt);
return rfilt;
}
if (type == EQUAL)
sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY;
else
sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
break;
case SUBSTRING:
sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_SUBSTRINGS;
sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_type =
AttrT_new(filt->fu_cont.item.stroid);
sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_initial =
NULLAV;
sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_final =
NULLAV;
sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_any =
avs_comp_new(str2AttrV(svalue,
sfilt->flt_un.flt_un_item.fi_un.
fi_un_substrings.fi_sub_type->
oa_syntax));
break;
default:
sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
break;
}
return sfilt;
case AND:
sfilt->flt_type = FILTER_AND;
sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
sfilt->flt_next = make_filter(filt->next);
return sfilt;
case OR:
sfilt->flt_type = FILTER_OR;
sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
sfilt->flt_next = make_filter(filt->next);
return sfilt;
case NOT:
sfilt->flt_type = FILTER_NOT;
sfilt->flt_next = make_filter(filt->next);
sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
return sfilt;
default:
return NULLFILTER;
}
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.