X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fpquery.c;h=eccf10b0e33592a937dfb4330b5fffeb53337d21;hb=3111fa3db35d0d3b76ba0f70a2c9ed83d5114c11;hp=40e243df30d1ecf2d6132a7e704eafea56ed9fd7;hpb=8bc8803d672b7ecf182a0bb691885d37cf2a8160;p=yaz-moved-to-github.git diff --git a/util/pquery.c b/util/pquery.c index 40e243d..eccf10b 100644 --- a/util/pquery.c +++ b/util/pquery.c @@ -4,7 +4,28 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: pquery.c,v $ - * Revision 1.1 1995-05-22 15:31:49 adam + * Revision 1.8 1996-01-02 11:46:56 quinn + * Changed 'operator' to 'roperator' to avoid C++ conflict. + * + * Revision 1.7 1995/09/29 17:12:36 quinn + * Smallish + * + * Revision 1.6 1995/09/27 15:03:03 quinn + * Modified function heads & prototypes. + * + * Revision 1.5 1995/06/15 12:31:02 quinn + * *** empty log message *** + * + * Revision 1.4 1995/06/15 07:45:19 quinn + * Moving to v3. + * + * Revision 1.3 1995/06/14 11:06:35 adam + * Bug fix: Attributes wasn't interpreted correctly! + * + * Revision 1.2 1995/05/26 08:56:11 adam + * New function: p_query_scan. + * + * Revision 1.1 1995/05/22 15:31:49 adam * New function, p_query_rpn, to convert from prefix (ascii) to rpn (asn). * */ @@ -77,9 +98,10 @@ static int query_token (const char **qptr, const char **lex_buf, int *lex_len) return 't'; } -static void lex (void) +static int lex (void) { - query_look = query_token (&query_buf, &query_lex_buf, &query_lex_len); + return query_look = + query_token (&query_buf, &query_lex_buf, &query_lex_len); } static Z_AttributesPlusTerm *rpn_term (ODR o, int num_attr, int *attr_list) @@ -96,14 +118,25 @@ static Z_AttributesPlusTerm *rpn_term (ODR o, int num_attr, int *attr_list) if (num_attr) { int i; + int *attr_tmp; + zapt->attributeList = odr_malloc (o, num_attr * sizeof(*zapt->attributeList)); + + attr_tmp = odr_malloc (o, num_attr * 2 * sizeof(int)); + memcpy (attr_tmp, attr_list, num_attr * 2 * sizeof(int)); for (i = 0; i < num_attr; i++) { zapt->attributeList[i] = odr_malloc (o,sizeof(**zapt->attributeList)); - zapt->attributeList[i]->attributeType = &attr_list[2*i]; - zapt->attributeList[i]->attributeValue = &attr_list[2*i+1]; + zapt->attributeList[i]->attributeType = &attr_tmp[2*i]; +#ifdef Z_95 + zapt->attributeList[i]->attributeSet = 0; + zapt->attributeList[i]->which = Z_AttributeValue_numeric; + zapt->attributeList[i]->value.numeric = &attr_tmp[2*i+1]; +#else + zapt->attributeList[i]->attributeValue = &attr_tmp[2*i+1]; +#endif } } else @@ -154,7 +187,7 @@ static Z_Complex *rpn_complex (ODR o, int num_attr, int max_attr, zc = odr_malloc (o, sizeof(*zc)); zo = odr_malloc (o, sizeof(*zo)); - zc->operator = zo; + zc->roperator = zo; switch (query_look) { case 'a': @@ -235,3 +268,29 @@ Z_RPNQuery *p_query_rpn (ODR o, const char *qbuf) return zq; } +Z_AttributesPlusTerm *p_query_scan (ODR o, const char *qbuf) +{ + int attr_list[1024]; + int num_attr = 0; + int max_attr = 512; + const char *cp; + + query_buf = qbuf; + while (lex() == 'l') + { + lex (); + if (!query_look) + return NULL; + if (!(cp = strchr (query_lex_buf, '='))) + return NULL; + if (num_attr >= max_attr) + return NULL; + attr_list[2*num_attr] = atoi (query_lex_buf); + attr_list[2*num_attr+1] = atoi (cp+1); + num_attr++; + } + if (!query_look) + return NULL; + return rpn_term (o, num_attr, attr_list); +} +