projects
/
yazpp-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Get rid of a few warnings
[yazpp-moved-to-github.git]
/
src
/
yaz-proxy-config.cpp
diff --git
a/src/yaz-proxy-config.cpp
b/src/yaz-proxy-config.cpp
index
fbcc88d
..
7a3134b
100644
(file)
--- a/
src/yaz-proxy-config.cpp
+++ b/
src/yaz-proxy-config.cpp
@@
-1,8
+1,8
@@
/*
/*
- * Copyright (c) 1998-2003, Index Data.
+ * Copyright (c) 1998-2004, Index Data.
* See the file LICENSE for details.
*
* See the file LICENSE for details.
*
- * $Id: yaz-proxy-config.cpp,v 1.18 2004-01-05 09:31:09 adam Exp $
+ * $Id: yaz-proxy-config.cpp,v 1.23 2004-01-07 13:40:06 adam Exp $
*/
#include <ctype.h>
*/
#include <ctype.h>
@@
-345,7
+345,8
@@
int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query,
}
#if HAVE_XSLT
}
#if HAVE_XSLT
-int Yaz_ProxyConfig::check_esn(xmlNodePtr ptr, Z_RecordComposition *comp)
+int Yaz_ProxyConfig::check_schema(xmlNodePtr ptr, Z_RecordComposition *comp,
+ const char *schema_identifier)
{
char *esn = 0;
int default_match = 1;
{
char *esn = 0;
int default_match = 1;
@@
-354,31
+355,32
@@
int Yaz_ProxyConfig::check_esn(xmlNodePtr ptr, Z_RecordComposition *comp)
{
esn = comp->u.simple->u.generic;
}
{
esn = comp->u.simple->u.generic;
}
+ // if no ESN/schema was given accept..
if (!esn)
return 1;
if (!esn)
return 1;
+ // check if schema identifier match
+ if (schema_identifier && !strcmp(esn, schema_identifier))
+ return 1;
+ // Check each name element
for (; ptr; ptr = ptr->next)
{
for (; ptr; ptr = ptr->next)
{
- if (ptr->type == XML_TEXT_NODE)
+ if (ptr->type == XML_ELEMENT_NODE
+ && !strcmp((const char *) ptr->name, "name"))
{
{
+ xmlNodePtr tptr = ptr->children;
default_match = 0;
default_match = 0;
- xmlChar *t = ptr->content;
- while (*t)
- {
- while (*t && isspace(*t))
- t++;
- xmlChar *s = t;
- int i = 0;
- while (esn[i] && esn[i] == *s)
+ for (; tptr; tptr = tptr->next)
+ if (tptr->type == XML_TEXT_NODE && tptr->content)
{
{
- i++;
- s++;
+ xmlChar *t = tptr->content;
+ while (*t && isspace(*t))
+ t++;
+ int i = 0;
+ while (esn[i] && esn[i] == t[i])
+ i++;
+ if (!esn[i] && (!t[i] || isspace(t[i])))
+ return 1;
}
}
- if (!esn[i] && (!*s || isspace(*s)))
- return 1;
- while (*s && !isspace(*s))
- s++;
- t = s;
- }
}
}
return default_match;
}
}
return default_match;
@@
-388,14
+390,20
@@
int Yaz_ProxyConfig::check_esn(xmlNodePtr ptr, Z_RecordComposition *comp)
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
Odr_oid *syntax, Z_RecordComposition *comp,
char **addinfo,
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
Odr_oid *syntax, Z_RecordComposition *comp,
char **addinfo,
- char **stylesheet)
+ char **stylesheet, char **schema)
{
if (stylesheet)
{
xfree (*stylesheet);
*stylesheet = 0;
}
{
if (stylesheet)
{
xfree (*stylesheet);
*stylesheet = 0;
}
+ if (schema)
+ {
+ xfree (*schema);
+ *schema = 0;
+ }
#if HAVE_XSLT
#if HAVE_XSLT
+ int syntax_has_matched = 0;
xmlNodePtr ptr;
ptr = find_target_node(name, 0);
xmlNodePtr ptr;
ptr = find_target_node(name, 0);
@@
-411,6
+419,7
@@
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
const char *match_error = 0;
const char *match_marcxml = 0;
const char *match_stylesheet = 0;
const char *match_error = 0;
const char *match_marcxml = 0;
const char *match_stylesheet = 0;
+ const char *match_identifier = 0;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
{
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
{
@@
-426,6
+435,9
@@
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
if (!strcmp((const char *) attr->name, "stylesheet") &&
attr->children && attr->children->type == XML_TEXT_NODE)
match_stylesheet = (const char *) attr->children->content;
if (!strcmp((const char *) attr->name, "stylesheet") &&
attr->children && attr->children->type == XML_TEXT_NODE)
match_stylesheet = (const char *) attr->children->content;
+ if (!strcmp((const char *) attr->name, "identifier") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_identifier = (const char *) attr->children->content;
}
if (match_type)
{
}
if (match_type)
{
@@
-445,8
+457,10
@@
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
}
}
if (match)
}
}
if (match)
- match = check_esn(ptr->children, comp);
-
+ {
+ syntax_has_matched = 1;
+ match = check_schema(ptr->children, comp, match_identifier);
+ }
if (match)
{
if (stylesheet && match_stylesheet)
if (match)
{
if (stylesheet && match_stylesheet)
@@
-454,12
+468,19
@@
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
xfree(*stylesheet);
*stylesheet = xstrdup(match_stylesheet);
}
xfree(*stylesheet);
*stylesheet = xstrdup(match_stylesheet);
}
+ if (schema && match_identifier)
+ {
+ xfree(*schema);
+ *schema = xstrdup(match_identifier);
+ }
if (match_marcxml)
{
return -1;
}
if (match_error)
{
if (match_marcxml)
{
return -1;
}
if (match_error)
{
+ if (syntax_has_matched) // if syntax did match, schema/ESN was bad
+ return 25;
if (syntax)
{
char dotoid_str[100];
if (syntax)
{
char dotoid_str[100];
@@
-679,7
+700,6
@@
char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db,
xmlDocSetRootElement(doc, ptr2);
xmlChar *buf_out;
xmlDocSetRootElement(doc, ptr2);
xmlChar *buf_out;
- int len_out;
xmlDocDumpMemory(doc, &buf_out, len);
char *content = (char*) odr_malloc(odr, *len);
memcpy(content, buf_out, *len);
xmlDocDumpMemory(doc, &buf_out, len);
char *content = (char*) odr_malloc(odr, *len);
memcpy(content, buf_out, *len);