static struct host *hosts = 0; // The hosts we know about
-#if 0
-static xmlDoc *get_explain_xml(const char *id)
+static xmlDoc *get_explain_xml(struct conf_targetprofiles *targetprofiles,
+ const char *id)
{
struct stat st;
char *dir;
char path[256];
char ide[256];
- if (!config || !config->targetprofiles)
- {
- yaz_log(YLOG_WARN, "Config must be loaded and specify targetprofiles");
- return 0;
- }
- if (config->targetprofiles->type != Targetprofiles_local)
+ if (targetprofiles->type != Targetprofiles_local)
{
yaz_log(YLOG_FATAL, "Only supports local type");
return 0;
}
- dir = config->targetprofiles->src;
+ dir = targetprofiles->src;
urlencode(id, ide);
sprintf(path, "%s/%s", dir, ide);
if (!stat(path, &st))
else
return 0;
}
-#endif
// Create a new host structure for hostport
static struct host *create_host(const char *hostport)
yaz_log(YLOG_LOG, "New database: %s", id);
-#if 0
- if (config && config->targetprofiles
- && (doc = get_explain_xml(id)))
+ if (service->targetprofiles
+ && (doc = get_explain_xml(service->targetprofiles, id)))
{
explain = zr_read_xml(service->nmem, xmlDocGetRootElement(doc));
if (!explain)
return 0;
}
-#endif
if (strlen(id) > 255)
return 0;
static char *parse_settings(NMEM nmem, xmlNode *node);
+static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem,
+ xmlNode *node);
+
static
struct conf_metadata * conf_metadata_assign(NMEM nmem,
struct conf_metadata * metadata,
service->next = 0;
service->settings = 0;
service->databases = 0;
+ service->targetprofiles = 0;
+
service->id = service_id ? nmem_strdup(nmem, service_id) : 0;
service->num_metadata = num_metadata;
if (!service->settings)
return 0;
}
+ else if (!strcmp((const char *) n->name, (const char *) "targetprofiles"))
+ {
+ if (service->targetprofiles)
+ {
+ yaz_log(YLOG_FATAL, "Can't repeat targetprofiles");
+ return 0;
+ }
+ if (!(service->targetprofiles =
+ parse_targetprofiles(service->nmem, n)))
+ return 0;
+ }
else if (!strcmp((const char *) n->name, (const char *) "metadata"))
{
xmlChar *xml_name = xmlGetProp(n, (xmlChar *) "name");
r->nmem = nmem;
r->servers = 0;
- r->targetprofiles = 0;
for (n = root->children; n; n = n->next)
{
}
else if (!strcmp((const char *) n->name, "targetprofiles"))
{
- // It would be fun to be able to fix this sometime
- if (r->targetprofiles)
- {
- yaz_log(YLOG_FATAL, "Can't repeat targetprofiles");
- return 0;
- }
- if (!(r->targetprofiles = parse_targetprofiles(nmem, n)))
- return 0;
+ yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
+ return 0;
+
}
else
{
pp2_charset_t sort_pct;
pp2_charset_t mergekey_pct;
-
struct database *databases;
+ struct conf_targetprofiles *targetprofiles;
};
struct conf_service * conf_service_create(int num_metadata, int num_sortkeys,
struct conf_config
{
- NMEM nmem;
+ NMEM nmem; /* for conf_config and servers memory */
struct conf_server *servers;
- struct conf_targetprofiles *targetprofiles;
};
struct conf_config *read_config(const char *fname);
for (i = 0; i < dictionary->num; i++)
if (!strcmp(dictionary->dict[i], set->name))
return;
- yaz_log(YLOG_WARN, "setting %s not configured as metadata", set->name);
+ yaz_log(YLOG_WARN, "Setting '%s' not configured as metadata", set->name);
}
// If we ever decide we need to be able to specify multiple settings directories,
<service>
<settings src="z3950_indexdata_com_marc.xml"/>
+ <targetprofiles type="local" src="../zeerex/records/"/>
<metadata name="url" merge="unique"/>
<metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6"/>
<metadata name="title-remainder" brief="yes" merge="longest" rank="5"/>
</server>
- <targetprofiles type="local" src="../zeerex/records/"/>
</pazpar2>
<!-- Keep this comment at the end of the file