25 #include <libxml/parser.h>
26 #include <libxml/tree.h>
27 #include <libxml/xinclude.h>
102 for(; el; el = el->
next)
116 struct _xmlAttr *attr;
129 for (attr = ptr->properties; attr; attr = attr->next)
131 if (!xmlStrcmp(attr->name, BAD_CAST
"syntax") &&
132 attr->children && attr->children->type == XML_TEXT_NODE)
137 (
const char *) attr->children->content,
142 " unknown attribute value syntax='%s'",
143 (
const char *) attr->children->content);
147 else if (!xmlStrcmp(attr->name, BAD_CAST
"identifier") &&
148 attr->children && attr->children->type == XML_TEXT_NODE)
151 else if (!xmlStrcmp(attr->name, BAD_CAST
"name") &&
152 attr->children && attr->children->type == XML_TEXT_NODE)
155 else if (!xmlStrcmp(attr->name, BAD_CAST
"split") &&
156 attr->children && attr->children->type == XML_TEXT_NODE)
162 " expected attributes 'syntax', identifier' or "
163 "'name', got '%s'", attr->name);
177 for (ptr = ptr->children; ptr; ptr = ptr->next)
179 if (ptr->type != XML_ELEMENT_NODE)
181 if (strcmp((
const char *) ptr->name,
"backend"))
184 " zero or one element <backend>, got <%s>",
185 (
const char *) ptr->name);
190 struct _xmlAttr *attr;
194 "only one <backend> allowed");
199 for (attr = ptr->properties; attr; attr = attr->next)
201 if (!xmlStrcmp(attr->name, BAD_CAST
"name")
203 && attr->children->type == XML_TEXT_NODE)
206 (
const char *) attr->children->content);
208 else if (!xmlStrcmp(attr->name, BAD_CAST
"syntax")
210 && attr->children->type == XML_TEXT_NODE)
216 (
const char *) attr->children->content,
221 "Element <backend syntax='%s'>: "
222 "attribute 'syntax' has invalid "
224 attr->children->content,
225 attr->children->content);
232 "attributes 'syntax' or 'name, got '%s'",
263 if (ptr && ptr->type == XML_ELEMENT_NODE &&
264 !strcmp((
const char *) ptr->name,
"retrievalinfo"))
266 for (ptr = ptr->children; ptr; ptr = ptr->next)
268 if (ptr->type != XML_ELEMENT_NODE)
270 if (!strcmp((
const char *) ptr->name,
"retrieval"))
278 "expected element <retrieval>, got <%s>",
298 const char *schema,
const Odr_oid *syntax,
299 const char **match_schema,
Odr_oid **match_syntax,
301 const char **backend_schema,
305 int syntax_matches = 0;
306 int schema_matches = 0;
313 for (; el; el = el->
next)
344 if (syntax_ok && schema_ok)
346 if (!el_best || schema_ok == 2)
353 *match_syntax = el->
syntax;
368 && (cp = strchr(schema, *el->
split)))
376 *backend_schema = schema;
389 if (!syntax_matches &&
syntax)
int yaz_match_glob2(const char *glob, const char *text, int case_insensitive)
matches a glob expression against text
void * nmem_malloc(NMEM n, size_t size)
allocates memory block on NMEM handle
Header for Nibble Memory functions.
char * nmem_strdup(NMEM mem, const char *src)
allocates string on NMEM handle (similar strdup)
ODR odr_createmem(int direction)
yaz_oid_db_t yaz_oid_std(void)
returns standard OID database
Odr_oid * yaz_string_to_oid_odr(yaz_oid_db_t oid_list, oid_class oclass, const char *name, ODR o)
creates ODR malloc'ed OID from string
int oid_oidcmp(const Odr_oid *o1, const Odr_oid *o2)
compares OIDs
char * oid_oid_to_dotstring(const Odr_oid *oid, char *oidbuf)
converts OID to string (dot notation)
Header for Z39.50 Protocol.
int yaz_record_conv_configure_t(yaz_record_conv_t p, const xmlNode *ptr, struct yaz_record_conv_type *types)
void yaz_record_conv_destroy(yaz_record_conv_t p)
const char * yaz_record_conv_get_error(yaz_record_conv_t p)
void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path)
yaz_record_conv_t yaz_record_conv_create()
static void yaz_retrieval_reset(yaz_retrieval_t p)
void yaz_retrieval_destroy(yaz_retrieval_t p)
int yaz_retrieval_configure(yaz_retrieval_t p, const xmlNode *ptr)
const char * yaz_retrieval_get_error(yaz_retrieval_t p)
int yaz_retrieval_configure_t(yaz_retrieval_t p, const xmlNode *ptr, struct yaz_record_conv_type *types)
int yaz_retrieval_request(yaz_retrieval_t p, const char *schema, const Odr_oid *syntax, const char **match_schema, Odr_oid **match_syntax, yaz_record_conv_t *rc, const char **backend_schema, Odr_oid **backend_syntax)
yaz_retrieval_t yaz_retrieval_create()
static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr, struct yaz_record_conv_type *types)
parse retrieval XML config
void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path)
struct yaz_retrieval_struct * yaz_retrieval_t
The internal structure for yaz_record_conv_t.
information per 'retrieval' construct
struct yaz_retrieval_elem * next
next element in list
const char * backend_name
backend name
Odr_oid * syntax
record syntax
const char * split
split name for some separator
yaz_record_conv_t record_conv
record conversion
const char * identifier
schema identifier
Odr_oid * backend_syntax
backend syntax
const char * name
schema name , short-hand such as "dc"
The internal structure for yaz_retrieval_t.
ODR odr
ODR memory for configuration.
struct yaz_retrieval_elem * list
retrieval list
WRBUF wr_error
string buffer for error messages
struct yaz_retrieval_elem ** list_p
last pointer in retrieval list
NMEM nmem
odr's NMEM memory (odr->mem)
char * path
path for opening files
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
WRBUF wrbuf_alloc(void)
construct WRBUF
void wrbuf_printf(WRBUF b, const char *fmt,...)
writes printf result to WRBUF
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
void wrbuf_write(WRBUF b, const char *buf, size_t size)
append constant size buffer to WRBUF
Header for WRBUF (growing buffer)
Header for memory handling functions.
#define xstrdup(s)
utility macro which calls xstrdup_f
#define xfree(x)
utility macro which calls xfree_f
#define xmalloc(x)
utility macro which calls malloc_f