projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaz-ztest returns schema for MARCXML test records
[yaz-moved-to-github.git]
/
ztest
/
gfs-example.c
diff --git
a/ztest/gfs-example.c
b/ztest/gfs-example.c
index
05112e2
..
d0f1192
100644
(file)
--- a/
ztest/gfs-example.c
+++ b/
ztest/gfs-example.c
@@
-1,15
+1,16
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
-
/** \file
* \brief Demonstration of Generic Frontend Server API
*/
/** \file
* \brief Demonstration of Generic Frontend Server API
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <yaz/log.h>
#include <yaz/backend.h>
#include <yaz/log.h>
#include <yaz/backend.h>
@@
-17,14
+18,21
@@
#include <yaz/matchstr.h>
#include <yaz/snprintf.h>
#include <yaz/matchstr.h>
#include <yaz/snprintf.h>
+/* session handle . Put anything you like in here! */
+struct my_handle {
+ int counter;
+};
+
static int my_search(void *handle, bend_search_rr *rr)
{
static int my_search(void *handle, bend_search_rr *rr)
{
+ struct my_handle *my_p = (struct my_handle *) handle;
+
if (rr->num_bases != 1)
{
rr->errcode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return 0;
}
if (rr->num_bases != 1)
{
rr->errcode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return 0;
}
- /* Throw Database unavailable if other than Default or Slow */
+ /* Throw Database unavailable if other than Default */
if (!yaz_matchstr (rr->basenames[0], "Default"))
; /* Default is OK in our test */
else
if (!yaz_matchstr (rr->basenames[0], "Default"))
; /* Default is OK in our test */
else
@@
-35,6
+43,7
@@
static int my_search(void *handle, bend_search_rr *rr)
}
rr->hits = 123; /* dummy hit count */
}
rr->hits = 123; /* dummy hit count */
+ my_p->counter++;
return 0;
}
return 0;
}
@@
-52,7
+61,8
@@
static int my_fetch(void *handle, bend_fetch_rr *r)
{
char buf[40];
yaz_snprintf(buf, sizeof(buf), "<record>%d</record>\n", r->number);
{
char buf[40];
yaz_snprintf(buf, sizeof(buf), "<record>%d</record>\n", r->number);
-
+
+ r->output_format = odr_oiddup(r->stream, yaz_oid_recsyn_xml);
r->record = odr_strdup(r->stream, buf);
r->len = strlen(r->record);
}
r->record = odr_strdup(r->stream, buf);
r->len = strlen(r->record);
}
@@
-69,14
+79,14
@@
static bend_initresult *my_init(bend_initrequest *q)
{
bend_initresult *r = (bend_initresult *)
odr_malloc (q->stream, sizeof(*r));
{
bend_initresult *r = (bend_initresult *)
odr_malloc (q->stream, sizeof(*r));
- int *counter = (int *) xmalloc (sizeof(int));
+ struct my_handle *my_p = (struct my_handle *) xmalloc (sizeof(*my_p));
- *counter = 0;
+ my_p->counter = 0;
r->errcode = 0;
r->errstring = 0;
r->errcode = 0;
r->errstring = 0;
- r->handle = counter; /* user handle, in this case a simple int */
+ r->handle = my_p; /* user handle */
q->bend_search = my_search; /* register search handler */
q->bend_search = my_search; /* register search handler */
- q->bend_fetch = my_fetch; /* register fetch handle */
+ q->bend_fetch = my_fetch; /* register fetch handle */
q->query_charset = "UTF-8";
q->records_in_same_charset = 1;
q->query_charset = "UTF-8";
q->records_in_same_charset = 1;