z-grs.h z-mterm2.h z-opac.h z-rrf1.h z-rrf2.h z-sum.h z-sutrs.h z-uifr1.h \
z-univ.h z-oclcui.h zes-expi.h zes-exps.h zes-order.h zes-pquery.h \
zes-psched.h zes-admin.h zes-pset.h zes-update.h zes-update0.h \
- zoom.h z-charneg.h charneg.h soap.h srw.h zgdu.h
+ zoom.h z-charneg.h charneg.h soap.h srw.h zgdu.h match-str.h
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data.
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Index Data nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * \file match-str.h
+ * \brief Header for YAZ iconv interface
+ */
+
+#ifndef YAZ_MATCH_STR_H
+#define YAZ_MATCH_STR_H
+
+#include <stddef.h>
+#include <yaz/yconfig.h>
+
+YAZ_BEGIN_CDECL
+
+/** \brief match strings - independent of case and '-'
+ \param s1 first string
+ \param s2 second string (May include wildcard ? and .)
+ \retval 0 strings are similar
+ \retval !=0 strings are different
+*/
+YAZ_EXPORT int yaz_matchstr(const char *s1, const char *s2);
+
+/** \brief match a and b with some delimitor for b
+ \param a first second
+ \param b second string
+ \param b_del delimitor for b
+ \retval 0 strings are similar
+ \retval !=0 strings are different
+*/
+YAZ_EXPORT int yaz_strcmp_del(const char *a, const char *b, const char *b_del);
+
+
+/** \brief compares two buffers of different size
+ \param a first buffer
+ \param b second buffer
+ \param len_a length of first buffer
+ \retval len_b length of second buffer
+ \retval 0 buffers are equal
+ \retval >0 a > b
+ \retval <0 a < b
+*/
+int yaz_memcmp(const void *a, const void *b, size_t len_a, size_t len_b);
+
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
#include <yaz/z-charneg.h>
#include <yaz/z-mterm2.h>
#include <yaz/wrbuf.h>
+#include <yaz/match-str.h>
#include <yaz/zgdu.h>
#include <yaz/z-oclcui.h>
/** \brief tests whether conversion is handled by YAZ' iconv or system iconv */
YAZ_EXPORT int yaz_iconv_isbuiltin(yaz_iconv_t cd);
-/** \brief match strings - independent of case and '-'
- \param s1 first string
- \param s2 second string (May include wildcard ? and .)
- \retval 0 strings are similar
- \retval !=0 strings are different
-*/
-YAZ_EXPORT int yaz_matchstr(const char *s1, const char *s2);
-
-/** \brief match a and b with some delimitor for b
- \param a first second
- \param b second string
- \param b_del delimitor for b
- \retval 0 strings are similar
- \retval !=0 strings are different
-*/
-YAZ_EXPORT int yaz_strcmp_del(const char *a, const char *b, const char *b_del);
-
-
-/** \brief compares two buffers of different size
- \param a first buffer
- \param b second buffer
- \param len_a length of first buffer
- \retval len_b length of second buffer
- \retval 0 buffers are equal
- \retval >0 a > b
- \retval <0 a < b
-*/
-int yaz_memcmp(const void *a, const void *b, size_t len_a, size_t len_b);
-
-
-/** \brief decodes UTF-8 sequence
- \param inp input buffer with UTF-8 bytes
- \param inbytesleft length of input buffer
- \param no_read holds number of bytes read if conversion is successful
- \param error pointer to error code if error occurs
- \retval 0 if error
- \retval >0 if conversion is successful
-*/
YAZ_EXPORT unsigned long yaz_read_UTF8_char(unsigned char *inp,
size_t inbytesleft,
size_t *no_read,
#include <yaz/readconf.h>
#include <yaz/marcdisp.h>
#include <yaz/yaz-iconv.h>
+#include <yaz/match-str.h>
/** \mainpage YAZ
\section intro_sec Introduction
#include <yaz/tokenizer.h>
#include <yaz/wrbuf.h>
#include <yaz/z-core.h>
+#include <yaz/match-str.h>
#include <yaz/oid_db.h>
#include <yaz/log.h>
#include <yaz/odr.h>
#include <yaz/yaz-version.h>
#include <yaz/yaz-iconv.h>
+#include <yaz/match-str.h>
#include <yaz/zgdu.h>
#ifdef WIN32
#include <yaz/yconfig.h>
+#include <yaz/match-str.h>
#include <yaz/yaz-iconv.h>
void yaz_iconv_set_errno(yaz_iconv_t cd, int no);
/**
* \file matchstr.c
- * \brief Implements loose string matching
+ * \brief a couple of string utilities
*/
#if HAVE_CONFIG_H
#include <assert.h>
#include <ctype.h>
#include <string.h>
-#include <yaz/yaz-util.h>
+#include <yaz/match-str.h>
int yaz_matchstr(const char *s1, const char *s2)
{
#include <stdlib.h>
#include <yaz/srw.h>
+#include <yaz/match-str.h>
#include <yaz/yaz-iconv.h>
static int hex_digit (int ch)
## Copyright (C) 1995-2008 Index Data
bin_PROGRAMS=yaz-ztest
+noinst_PROGRAMS=gfs-example
yaz_ztest_SOURCES=ztest.c read-grs.c read-marc.c dummy-opac.c ztest.h
+gfs_example_SOURCES=gfs-example.c
EXTRA_DIST=dummy-records dummy-words dummy-grs ztest.pem config1.xml
-yaz_ztest_LDADD=../src/libyaz_server.la $(PTHREAD_LIBS)
+LDADD=../src/libyaz_server.la $(PTHREAD_LIBS)
AM_CPPFLAGS=-I$(top_srcdir)/include $(XML2_CFLAGS)
--- /dev/null
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
+ * See the file LICENSE for details.
+ */
+
+/** \file
+ * \brief Demonstration of Generic Frontend Server API
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <yaz/log.h>
+#include <yaz/backend.h>
+#include <yaz/diagbib1.h>
+#include <yaz/match-str.h>
+#include <yaz/snprintf.h>
+
+static int my_search(void *handle, bend_search_rr *rr)
+{
+ 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 */
+ if (!yaz_matchstr (rr->basenames[0], "Default"))
+ ; /* Default is OK in our test */
+ else
+ {
+ rr->errcode = YAZ_BIB1_DATABASE_UNAVAILABLE;
+ rr->errstring = rr->basenames[0];
+ return 0;
+ }
+
+ rr->hits = 123; /* dummy hit count */
+ return 0;
+}
+
+/* retrieval of a single record (present, and piggy back search) */
+static int my_fetch(void *handle, bend_fetch_rr *r)
+{
+ const Odr_oid *oid = r->request_format;
+
+ r->last_in_set = 0;
+ r->basename = "Default";
+ r->output_format = r->request_format;
+
+ /* if no record syntax was given assume XML */
+ if (!oid || !oid_oidcmp(oid, yaz_oid_recsyn_xml))
+ {
+ char buf[40];
+ yaz_snprintf(buf, sizeof(buf), "<record>%d</record>\n", r->number);
+
+ r->record = odr_strdup(r->stream, buf);
+ r->len = strlen(r->record);
+ }
+ else
+ { /* only xml syntax supported . Return diagnostic */
+ char buf[OID_STR_MAX];
+ r->errcode = YAZ_BIB1_RECORD_SYNTAX_UNSUPP;
+ r->errstring = odr_strdup(r->stream, oid_oid_to_dotstring(oid, buf));
+ }
+ return 0;
+}
+
+static bend_initresult *my_init(bend_initrequest *q)
+{
+ bend_initresult *r = (bend_initresult *)
+ odr_malloc (q->stream, sizeof(*r));
+ int *counter = (int *) xmalloc (sizeof(int));
+
+ *counter = 0;
+ r->errcode = 0;
+ r->errstring = 0;
+ r->handle = counter; /* user handle, in this case a simple int */
+ q->bend_search = my_search; /* register search handler */
+ q->bend_fetch = my_fetch; /* register fetch handle */
+ q->query_charset = "UTF-8";
+ q->records_in_same_charset = 1;
+
+ return r;
+}
+
+static void my_close(void *handle)
+{
+ xfree(handle); /* release our user-defined handle */
+ return;
+}
+
+int main(int argc, char **argv)
+{
+ return statserv_main(argc, argv, my_init, my_close);
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
*/
/** \file
- * \brief Demonstration of server
+ * \brief yaz-ztest Generic Frontend Server
*/
#include <stdio.h>