|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 3289 (0xcd9) Types: TextFile Names: »get_filter.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/quipu/dish/get_filter.c«
/* get_filter.c - */ #ifndef lint static char *rcsid = "$Header: /f/osi/quipu/dish/RCS/get_filter.c,v 6.0 89/03/18 23:40:47 mrose Rel $"; #endif /* * $Header: /f/osi/quipu/dish/RCS/get_filter.c,v 6.0 89/03/18 23:40:47 mrose Rel $ * * * $Log: get_filter.c,v $ * Revision 6.0 89/03/18 23:40:47 mrose * Release 5.0 * */ /* * 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. * */ #include "quipu/util.h" #include "quipu/ds_search.h" extern PS opt; extern LLog *log_dua; char *TidyString (); Filter get_filter_aux (str) char *str; { int gotit, bracketed; char ch, och = '\0'; Filter result, next, ptr = NULLFILTER; result = filter_alloc (); result->FUFILT = NULLFILTER; result->flt_next = NULLFILTER; str = TidyString (str); /* Got a multiple-component string for parsing */ do { bracketed = FALSE; if ((gotit = getop (str, &ch)) == -2) return (NULLFILTER); if (gotit < 0) {/* Match an open bracket. */ if (*str == '(') if (str[strlen (str) - 1] == ')') { str[strlen (str) - 1] = '\0'; ++str; bracketed = TRUE; } else { ps_print (opt, "Too many open brackets"); return (NULLFILTER); } if (och == '\0') { if (bracketed == TRUE) { gotit = 0; /* Stop 'while' loop * falling */ continue; /* Parse the internals */ } else break; /* Single item only */ } else ch = och; /* Use last operation */ } if (och == '\0')/* Remember last operation */ och = ch; else if (och != ch) { ps_print (opt, "CAN'T MIX OPERATIONS."); return (NULLFILTER); } if (gotit >= 0) /* If got an op, make it null */ str[gotit] = '\0'; /* Recurse on the 'first' string */ if ((next = get_filter_aux (str)) == NULLFILTER) return (NULLFILTER); if (ptr == NULLFILTER) ptr = next; else filter_append (ptr, next); str += gotit + 1; if (gotit >= 0) { /* Match an and symbol */ if (och == '&') { result->flt_type = FILTER_AND; } else {/* Match an or symbol */ result->flt_type = FILTER_OR; } result->FUFILT = ptr; } } while (gotit >= 0); if (och == '\0') { if (*str == '!') { /* Match a not symbol */ result->flt_type = FILTER_NOT; if ((result->FUFILT = get_filter_aux (str + 1)) == NULLFILTER) return (NULLFILTER); } else if (filteritem (str, result) == NOTOK) return (NULLFILTER); } return (result); } Filter get_filter (str) char *str; { char * ptr; Filter f; ptr = strdup (str); f = get_filter_aux (ptr); free (ptr); return (f); } getop (str, ch) char *str, *ch; { int i, bracket = 0; for (i = 0; i < strlen (str); i++) { if (bracket == 0 && (str[i] == '&' || str[i] == '|')) { *ch = str[i]; return (i); } if (str[i] == '(') ++bracket; if (str[i] == ')') --bracket; if (bracket < 0) { ps_print (opt, "Too many close brackets"); return (-2); } } return (-1); }