zoomtst3: print event name
[yaz-moved-to-github.git] / src / sortspec.c
index 7b5d096..d469718 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
  * See the file LICENSE for details.
- *
- * $Id: sortspec.c,v 1.5 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file sortspec.c
 #include <stdlib.h>
 
 #include <yaz/proto.h>
-#include <yaz/oid.h>
 #include <yaz/sortspec.h>
+#include <yaz/oid_db.h>
 
 Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
 {
-    char sort_string_buf[32], sort_flags[32];
+    char sort_string_buf[64], sort_flags[64];
     Z_SortKeySpecList *sksl = (Z_SortKeySpecList *)
         odr_malloc (out, sizeof(*sksl));
     int off;
@@ -27,7 +25,7 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
     sksl->num_specs = 0;
     sksl->specs = (Z_SortKeySpec **)odr_malloc (out, sizeof(sksl->specs) * 20);
     
-    while ((sscanf (arg, "%31s %31s%n", sort_string_buf,
+    while ((sscanf (arg, "%63s %63s%n", sort_string_buf,
                     sort_flags, &off)) == 2  && off > 1)
     {
         int i;
@@ -49,8 +47,7 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
             sk->which = Z_SortKey_sortAttributes;
             sk->u.sortAttributes = (Z_SortAttributes *)
                 odr_malloc (out, sizeof(*sk->u.sortAttributes));
-            sk->u.sortAttributes->id = 
-                yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
+            sk->u.sortAttributes->id = odr_oiddup(out, yaz_oid_attset_bib_1);
             sk->u.sortAttributes->list = (Z_AttributeList *)
                 odr_malloc (out, sizeof(*sk->u.sortAttributes->list));
             sk->u.sortAttributes->list->attributes = (Z_AttributeElement **)
@@ -109,6 +106,20 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
             case 's':
                 *sks->caseSensitivity = Z_SortKeySpec_caseSensitive;
                 break;
+            case '!':
+                sks->which = Z_SortKeySpec_abort;
+                sks->u.abort = odr_nullval();
+                break;
+            case '=':
+                sks->which = Z_SortKeySpec_missingValueData;
+                sks->u.missingValueData = (Odr_oct*)
+                    odr_malloc(out, sizeof(Odr_oct));
+                i++;
+                sks->u.missingValueData->len = strlen(sort_flags+i);
+                sks->u.missingValueData->size = sks->u.missingValueData->len;
+                sks->u.missingValueData->buf = (unsigned char*)
+                                          odr_strdup(out, sort_flags+i);
+                i += strlen(sort_flags+i);
             }
         }
     }
@@ -119,6 +130,7 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab