-/*
- * Copyright (C) 1995-2005, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 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;
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;
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 **)
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);
}
}
}