projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make packages for centos7
[pazpar2-moved-to-github.git]
/
src
/
pazpar2_config.c
diff --git
a/src/pazpar2_config.c
b/src/pazpar2_config.c
index
3b9d47a
..
39aff41
100644
(file)
--- a/
src/pazpar2_config.c
+++ b/
src/pazpar2_config.c
@@
-54,6
+54,7
@@
struct conf_config
int no_threads;
WRBUF confdir;
int no_threads;
WRBUF confdir;
+ char *path;
iochan_man_t iochan_man;
database_hosts_t database_hosts;
};
iochan_man_t iochan_man;
database_hosts_t database_hosts;
};
@@
-169,7
+170,8
@@
static struct conf_metadata* conf_service_add_metadata(
enum conf_metadata_mergekey mt,
const char *facetrule,
const char *limitmap,
enum conf_metadata_mergekey mt,
const char *facetrule,
const char *limitmap,
- const char *limitcluster
+ const char *limitcluster,
+ const char *icurule
)
{
struct conf_metadata * md = 0;
)
{
struct conf_metadata * md = 0;
@@
-201,6
+203,7
@@
static struct conf_metadata* conf_service_add_metadata(
md->facetrule = nmem_strdup_null(nmem, facetrule);
md->limitmap = nmem_strdup_null(nmem, limitmap);
md->limitcluster = nmem_strdup_null(nmem, limitcluster);
md->facetrule = nmem_strdup_null(nmem, facetrule);
md->limitmap = nmem_strdup_null(nmem, limitmap);
md->limitcluster = nmem_strdup_null(nmem, limitcluster);
+ md->icurule = nmem_strdup_null(nmem, icurule);
return md;
}
return md;
}
@@
-256,13
+259,20
@@
int conf_service_sortkey_field_id(struct conf_service *service,
static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src)
{
static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src)
{
- if (config->confdir && wrbuf_len(config->confdir) > 0 &&
- !yaz_is_abspath(src))
+ char full_path[1024];
+ if (yaz_filepath_resolve(src, config->path,
+ wrbuf_len(config->confdir) > 0 ?
+ wrbuf_cstr(config->confdir) : ".",
+ full_path))
{
{
- wrbuf_printf(w, "%s/%s", wrbuf_cstr(config->confdir), src);
+ wrbuf_puts(w, full_path);
}
else
}
else
+ {
+ yaz_log(YLOG_WARN, "File not found: fname=%s path=%s base=%s", src,
+ config->path, wrbuf_cstr(config->confdir));
wrbuf_puts(w, src);
wrbuf_puts(w, src);
+ }
}
void service_destroy(struct conf_service *service)
}
void service_destroy(struct conf_service *service)
@@
-307,6
+317,7
@@
static int parse_metadata(struct conf_service *service, xmlNode *n,
xmlChar *xml_limitmap = 0;
xmlChar *xml_limitcluster = 0;
xmlChar *xml_icu_chain = 0;
xmlChar *xml_limitmap = 0;
xmlChar *xml_limitcluster = 0;
xmlChar *xml_icu_chain = 0;
+ xmlChar *xml_icurule = 0;
struct _xmlAttr *attr;
struct _xmlAttr *attr;
@@
-350,6
+361,9
@@
static int parse_metadata(struct conf_service *service, xmlNode *n,
else if (!xmlStrcmp(attr->name, BAD_CAST "limitcluster") &&
attr->children && attr->children->type == XML_TEXT_NODE)
xml_limitcluster = attr->children->content;
else if (!xmlStrcmp(attr->name, BAD_CAST "limitcluster") &&
attr->children && attr->children->type == XML_TEXT_NODE)
xml_limitcluster = attr->children->content;
+ else if (!xmlStrcmp(attr->name, BAD_CAST "icurule") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ xml_icurule = attr->children->content;
else
{
yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name);
else
{
yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name);
@@
-507,13
+521,15
@@
static int parse_metadata(struct conf_service *service, xmlNode *n,
mergekey_type,
(const char *) xml_icu_chain,
(const char *) xml_limitmap,
mergekey_type,
(const char *) xml_icu_chain,
(const char *) xml_limitmap,
- (const char *) xml_limitcluster);
+ (const char *) xml_limitcluster,
+ (const char *) xml_icurule
+ );
(*md_node)++;
return 0;
}
(*md_node)++;
return 0;
}
-static void service_add_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys)
+static void count_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys)
{
xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
(*num_metadata)++;
{
xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
(*num_metadata)++;
@@
-549,11
+565,11
@@
static struct conf_service *service_create_static(struct conf_server *server,
{
if (m->type == XML_ELEMENT_NODE &&
!strcmp((const char *) m->name, "metadata"))
{
if (m->type == XML_ELEMENT_NODE &&
!strcmp((const char *) m->name, "metadata"))
- service_add_metadata(m, &num_metadata, &num_sortkeys);
+ count_metadata(m, &num_metadata, &num_sortkeys);
}
}
else // This is a metadata-element proper, count it right away.
}
}
else // This is a metadata-element proper, count it right away.
- service_add_metadata(n, &num_metadata, &num_sortkeys);
+ count_metadata(n, &num_metadata, &num_sortkeys);
}
service = service_init(server, num_metadata, num_sortkeys, service_id);
}
service = service_init(server, num_metadata, num_sortkeys, service_id);
@@
-641,8
+657,8
@@
static struct conf_service *service_create_static(struct conf_server *server,
{
if (!service->charsets)
service->charsets = pp2_charset_fact_create();
{
if (!service->charsets)
service->charsets = pp2_charset_fact_create();
- if (pp2_charset_fact_define(service->charsets,
- n->children, (const char *) n->name))
+ if (pp2_charset_fact_define(service->charsets, n,
+ (const char *) n->name))
{
yaz_log(YLOG_FATAL, "ICU chain definition error");
return 0;
{
yaz_log(YLOG_FATAL, "ICU chain definition error");
return 0;
@@
-680,7
+696,7
@@
static struct conf_service *service_create_static(struct conf_server *server,
service->rank_cluster = 1;
else if (!strcmp(rank_cluster, "no"))
service->rank_cluster = 0;
service->rank_cluster = 1;
else if (!strcmp(rank_cluster, "no"))
service->rank_cluster = 0;
- else
+ else
{
yaz_log(YLOG_FATAL, "service: rank@cluster boolean");
return 0;
{
yaz_log(YLOG_FATAL, "service: rank@cluster boolean");
return 0;
@@
-944,8
+960,8
@@
static struct conf_server *server_create(struct conf_config *config,
{
if (!server->charsets)
server->charsets = pp2_charset_fact_create();
{
if (!server->charsets)
server->charsets = pp2_charset_fact_create();
- if (pp2_charset_fact_define(server->charsets,
- n->children, (const char *) n->name))
+ if (pp2_charset_fact_define(server->charsets, n,
+ (const char *) n->name))
{
yaz_log(YLOG_FATAL, "ICU chain definition error");
return 0;
{
yaz_log(YLOG_FATAL, "ICU chain definition error");
return 0;
@@
-1067,6
+1083,9
@@
static void info_service_metadata(struct conf_service *service, WRBUF w)
case Metadata_type_position:
wrbuf_puts(w, "position");
break;
case Metadata_type_position:
wrbuf_puts(w, "position");
break;
+ case Metadata_type_retrieval:
+ wrbuf_puts(w, "retrieval");
+ break;
default:
wrbuf_puts(w, "yes");
break;
default:
wrbuf_puts(w, "yes");
break;
@@
-1244,6
+1263,15
@@
static int parse_config(struct conf_config *config, xmlNode *root)
xmlFree(number);
}
}
xmlFree(number);
}
}
+ else if (!strcmp((const char *) n->name, "file"))
+ {
+ xmlChar *path = xmlGetProp(n, (xmlChar *) "path");
+ if (path)
+ {
+ config->path = nmem_strdup(config->nmem, (const char *) path);
+ xmlFree(path);
+ }
+ }
else if (!strcmp((const char *) n->name, "targetprofiles"))
{
yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
else if (!strcmp((const char *) n->name, "targetprofiles"))
{
yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
@@
-1259,12
+1287,12
@@
static int parse_config(struct conf_config *config, xmlNode *root)
return 0;
}
return 0;
}
-struct conf_config *config_create(const char *fname, int verbose)
+struct conf_config *config_create(const char *fname)
{
xmlDoc *doc = xmlReadFile(fname,
NULL,
{
xmlDoc *doc = xmlReadFile(fname,
NULL,
- XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS
- + XML_PARSE_NSCLEAN + XML_PARSE_NONET );
+ XML_PARSE_XINCLUDE
+ + XML_PARSE_NSCLEAN + XML_PARSE_NONET);
xmlNode *n;
const char *p;
int r;
xmlNode *n;
const char *p;
int r;
@@
-1290,6
+1318,7
@@
struct conf_config *config_create(const char *fname, int verbose)
config->nmem = nmem;
config->servers = 0;
config->nmem = nmem;
config->servers = 0;
+ config->path = nmem_strdup(nmem, ".");
config->no_threads = 0;
config->iochan_man = 0;
config->database_hosts = database_hosts_create();
config->no_threads = 0;
config->iochan_man = 0;
config->database_hosts = database_hosts_create();
@@
-1312,16
+1341,13
@@
struct conf_config *config_create(const char *fname, int verbose)
r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir));
if (r == 0) /* OK */
{
r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir));
if (r == 0) /* OK */
{
- if (verbose)
- {
- yaz_log(YLOG_LOG, "Configuration %s after include processing",
- fname);
+ yaz_log(YLOG_LOG, "Configuration %s after include processing",
+ fname);
#if LIBXML_VERSION >= 20600
#if LIBXML_VERSION >= 20600
- xmlDocFormatDump(yaz_log_file(), doc, 0);
+ xmlDocFormatDump(yaz_log_file(), doc, 0);
#else
#else
- xmlDocDump(yaz_log_file(), doc);
+ xmlDocDump(yaz_log_file(), doc);
#endif
#endif
- }
r = parse_config(config, n);
}
xmlFreeDoc(doc);
r = parse_config(config, n);
}
xmlFreeDoc(doc);