Fix sample PQF
[yaz-moved-to-github.git] / zutil / pquery.c
index 2ced379..2840557 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: pquery.c,v 1.17 2002-09-02 13:59:07 adam Exp $
+ * $Id: pquery.c,v 1.20 2003-01-06 08:20:29 adam Exp $
  */
 
 #include <stdio.h>
@@ -26,6 +26,7 @@ struct yaz_pqf_parser {
     char *right_sep;
     int escape_char;
     int term_type;
+    int external_type;
     int error;
 };
 
@@ -324,16 +325,21 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
         break;
     case Z_Term_characterString:
         term->which = Z_Term_characterString;
-        term->u.characterString = term_octet->buf;  /* null terminated above */
+        term->u.characterString = (char*) term_octet->buf; 
+                                    /* null terminated above */
         break;
     case Z_Term_numeric:
         term->which = Z_Term_numeric;
-        term->u.numeric = odr_intdup (o, atoi(term_octet->buf));
+        term->u.numeric = odr_intdup (o, atoi((char*) (term_octet->buf)));
         break;
     case Z_Term_null:
         term->which = Z_Term_null;
         term->u.null = odr_nullval();
         break;
+    case Z_Term_external:
+        term->which = Z_Term_external;
+       term->u.external = 0;
+       break;
     default:
         term->which = Z_Term_null;
         term->u.null = odr_nullval();
@@ -515,6 +521,12 @@ static void rpn_term_type (struct yaz_pqf_parser *li, ODR o)
         li->term_type = Z_Term_dateTime;
     else if (compare_term (li, "null", 0))
         li->term_type = Z_Term_null;
+    else if (compare_term(li, "range", 0))
+    {
+       /* prepare for external: range search .. */
+        li->term_type = Z_Term_external;
+       li->external_type = VAL_MULTISRCH2;
+    }
     lex (li);
 }
                            
@@ -743,7 +755,7 @@ int p_query_attset (const char *arg)
 
 YAZ_PQF_Parser yaz_pqf_create (void)
 {
-    YAZ_PQF_Parser p = xmalloc (sizeof(*p));
+    YAZ_PQF_Parser p = (YAZ_PQF_Parser) xmalloc (sizeof(*p));
 
     p->error = 0;
     p->left_sep = "{\"";