* Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: srwutil.c,v 1.9 2004-01-09 19:54:05 adam Exp $
+ * $Id: srwutil.c,v 1.17 2004-10-09 08:49:55 adam Exp $
*/
#include <yaz/srw.h>
p1 = strchr(path, '&');
if (!p1)
p1 = strlen(path) + path;
- ret = odr_malloc(o, p1 - path + 1);
+ ret = (char *) odr_malloc(o, p1 - path + 1);
while (*path && *path != '&')
{
if (*path == '+')
*intp = odr_intdup(o, atoi(v));
}
+void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
+ int code, const char *details)
+{
+ d->uri = (char *) odr_malloc(o, 50);
+ sprintf(d->uri, "info:srw/diagnostic/1/%d", code);
+ d->message = 0;
+ if (details)
+ d->details = odr_strdup(o, details);
+ else
+ d->details = 0;
+}
+
void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
int *num, int code, const char *addinfo)
{
if (*num)
memcpy (d_new, *d, *num *sizeof(**d));
*d = d_new;
- (*d + *num)->code = odr_intdup(o, code);
- if (addinfo)
- (*d + *num)->details = odr_strdup(o, addinfo);
- else
- (*d + *num)->details = 0;
+
+ yaz_mk_std_diagnostic(o, *d + *num, code, addinfo);
(*num)++;
}
char *scanClause = 0;
char *recordXPath = 0;
char *recordSchema = 0;
- char *recordPacking = "xml";
+ char *recordPacking = "xml"; /* xml packing is default for SRU */
char *maximumRecords = 0;
char *startRecord = 0;
char **uri_name;
else if (!strcmp(n, "startRecord"))
startRecord = v;
else
- yaz_add_srw_diagnostic(decode, diag, num_diag, 9, n);
+ yaz_add_srw_diagnostic(decode, diag, num_diag, 8, n);
}
}
if (!version)
- yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version");
- else if (version && strcmp(version, "1.1"))
+ {
+ if (uri_name)
+ yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version");
+ version = "1.1";
+ }
+ if (strcmp(version, "1.1"))
yaz_add_srw_diagnostic(decode, diag, num_diag, 5, "1.1");
if (!operation)
{
- yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation");
+ if (uri_name)
+ yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation");
operation = "explain";
}
if (!strcmp(operation, "searchRetrieve"))
Z_SRW_PDU *yaz_srw_get(ODR o, int which)
{
- Z_SRW_PDU *sr = odr_malloc(o, sizeof(*o));
+ Z_SRW_PDU *sr = (Z_SRW_PDU *) odr_malloc(o, sizeof(*o));
sr->srw_version = odr_strdup(o, "1.1");
sr->which = which;
{5, "Unsupported version"},
{6, "Unsupported parameter value"},
{7, "Mandatory parameter not supplied"},
-{8, "Unknown database"},
-{9, "Unknown parameter type"},
+{8, "Unsupported parameter"},
/* Diagnostics Relating to CQL */
{10, "Query syntax error"},
{11, "Unsupported query type"},
{12, "Too many characters in query"},
{13, "Invalid or unsupported use of parentheses"},
{14, "Invalid or unsupported use of quotes"},
-{15, "Unsupported context context set"},
+{15, "Unsupported context set"},
{16, "Unsupported index"},
{17, "Unsupported combination of index and context set"},
{18, "Unsupported combination of indexes"},
108, 27,
108, 45,
- 109, 9,
+ 109, 2,
110, 37,
111, 1,
112, 58,
115, 16,
116, 16,
117, 19,
+ 117, 20,
118, 22,
119, 32,
119, 31,