From 31b01bfc5e77f090135d7a66739b057052a1c845 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 12 Jul 2013 20:16:06 +0000 Subject: [PATCH] Add more infos to the 'info' command --- src/pazpar2_config.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 1 deletion(-) diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 167424d..e3f99b8 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "settings.h" #include "eventl.h" #include "http.h" +#include "session.h" struct conf_config { @@ -986,9 +987,148 @@ struct conf_service *locate_service(struct conf_server *server, return s; } +void info_service_metadata(struct conf_service *service, WRBUF w) +{ + int i; + struct conf_metadata *md; + + if (service->num_metadata) + { + for (i = 0; i < service->num_metadata; i++) + { + md = &(service->metadata[i]); + wrbuf_puts(w, " name) { + wrbuf_puts(w, " name=\""); + wrbuf_xmlputs(w, md->name); + wrbuf_puts(w, "\""); + } + if (md->brief) { + wrbuf_puts(w, " brief=\"yes\""); + } + if (md->termlist) { + wrbuf_puts(w, " termlist=\"yes\""); + } + if (md->rank) { + wrbuf_puts(w, " rank=\""); + wrbuf_xmlputs(w, md->rank); + wrbuf_puts(w, "\""); + } + if (md->sortkey_offset > 0) { + wrbuf_puts(w, " sortkey=\""); + switch (service->sortkeys[md->sortkey_offset].type) { + case Metadata_sortkey_relevance: + wrbuf_puts(w, "relevance"); + break; + case Metadata_sortkey_numeric: + wrbuf_puts(w, "numeric"); + break; + case Metadata_sortkey_skiparticle: + wrbuf_puts(w, "skiparticle"); + break; + case Metadata_sortkey_string: + wrbuf_puts(w, "string"); + break; + case Metadata_sortkey_position: + wrbuf_puts(w, "position"); + break; + } + wrbuf_puts(w, "\""); + } + + switch (md->type) { + case Metadata_type_generic: + break; + case Metadata_type_year: + wrbuf_puts(w, " type=\"year\""); + break; + case Metadata_type_date: + wrbuf_puts(w, " type=\"date\""); + break; + } + + switch (md->merge) { + case Metadata_merge_no: + break; + case Metadata_merge_unique: + wrbuf_puts(w, " merge=\"unique\""); + break; + case Metadata_merge_longest: + wrbuf_puts(w, " merge=\"longest\""); + break; + case Metadata_merge_range: + wrbuf_puts(w, " merge=\"range\""); + break; + case Metadata_merge_all: + wrbuf_puts(w, " merge=\"all\""); + break; + case Metadata_merge_first: + wrbuf_puts(w, " merge=\"first\""); + break; + } + + switch (md->mergekey) { + case Metadata_mergekey_no: + break; + case Metadata_mergekey_optional: + wrbuf_puts(w, " mergekey=\"optional\""); + break; + case Metadata_mergekey_required: + wrbuf_puts(w, " mergekey=\"required\""); + break; + } + wrbuf_puts(w, " />\n"); + } + } +} + +void info_service_databases(struct conf_service *service, WRBUF w) +{ + struct database *db; + struct setting *s; + int i; + + if (service->databases) + { + wrbuf_puts(w, " \n"); + for(db = service->databases; db; db = db->next) + { + wrbuf_puts(w, " id) { + wrbuf_puts(w, " id=\""); + wrbuf_printf(w, "%s", db->id); + wrbuf_puts(w, "\""); + } + wrbuf_puts(w, ">\n"); + for (i = 0; i < db->num_settings; i++) + { + s = db->settings[i]; + while (s != NULL) { + wrbuf_puts(w, " name); + wrbuf_puts(w, "\""); + wrbuf_puts(w, " value=\""); + wrbuf_xmlputs(w, s->value); + wrbuf_puts(w, "\""); + wrbuf_puts(w, " />\n"); + s = s->next; + } + } + wrbuf_puts(w, " \n"); + } + + wrbuf_puts(w, " \n"); + } +} + void info_services(struct conf_server *server, WRBUF w) { struct conf_service *s = server->service; + int i; + struct setting *S; + struct database *db; + wrbuf_puts(w, " \n"); for (; s; s = s->next) { @@ -999,7 +1139,35 @@ void info_services(struct conf_server *server, WRBUF w) wrbuf_xmlputs(w, s->id); wrbuf_puts(w, "\""); } - wrbuf_puts(w, "/>"); + wrbuf_puts(w, ">\n"); + if (s->settings) + { + for (i=0; isettings->num_settings; i++) + { + S = s->settings->settings[i]; + while (S != NULL) { + wrbuf_puts(w, " name); + wrbuf_puts(w, "\""); + wrbuf_puts(w, " value=\""); + wrbuf_xmlputs(w, S->value); + wrbuf_puts(w, "\""); + if (S->target) { + wrbuf_puts(w, " target=\""); + wrbuf_xmlputs(w, S->target); + wrbuf_puts(w, "\""); + } + + wrbuf_puts(w, " />\n"); + + S = S->next; + } + } + } + info_service_metadata(s, w); + info_service_databases(s, w); + wrbuf_puts(w, " "); wrbuf_puts(w, "\n"); } -- 1.7.10.4