From a3b7b22328617db1ffdb8118c661d3167905918e Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Fri, 12 Jan 2007 15:08:44 +0000 Subject: [PATCH] *** empty log message *** --- PROTOCOL | 4 +++- src/config.c | 23 +++++++++++++++++------ src/config.h | 30 ++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/PROTOCOL b/PROTOCOL index 2608c38..6db19d7 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -2,7 +2,9 @@ Webservice requests are any that refer to filename "search.pz2". Arguments are GET-style parameters. Argument 'command' is required and specifies command. Any request not recognized as a webservice request as described, -are forwarded to the HTTP server specified in option -p. +are forwarded to the HTTP server specified in configuration. This way, the webserver +can host the user interface (itself dynamic or static HTML), and AJAX-style +calls can be used from JS to interact with the search logic. Commands: diff --git a/src/config.c b/src/config.c index 5a1b31a..de47152 100644 --- a/src/config.c +++ b/src/config.c @@ -1,4 +1,4 @@ -/* $Id: config.c,v 1.9 2007-01-10 10:15:23 adam Exp $ */ +/* $Id: config.c,v 1.10 2007-01-12 15:08:44 quinn Exp $ */ #include @@ -30,16 +30,27 @@ static struct conf_service *parse_service(xmlNode *node) { xmlNode *n; struct conf_service *r = nmem_malloc(nmem, sizeof(struct conf_service)); - int num_metadata = 0; int md_node = 0; + r->num_sortkeys = r->num_metadata = 0; // Allocate array of conf metadata structs, if necessary for (n = node->children; n; n = n->next) if (n->type == XML_ELEMENT_NODE && !strcmp(n->name, "metadata")) - num_metadata++; - if (num_metadata) - r->metadata = nmem_malloc(nmem, sizeof(struct conf_metadata) * num_metadata); - r->num_metadata = num_metadata; + { + xmlChar *sortkey = xmlGetProp(n, "sortkey"); + r->num_metadata++; + if (sortkey && strcmp(sortkey, "no")) + r->num_sortkeys++; + xmlFree(sortkey); + } + if (r->num_metadata) + r->metadata = nmem_malloc(nmem, sizeof(struct conf_metadata) * r->num_metadata); + else + r->metadata = 0; + if (r->num_sortkeys) + r->sortkeys = nmem_malloc(nmem, sizeof(struct conf_sortkey) * r->num_sortkeys); + else + r->sortkeys = 0; for (n = node->children; n; n = n->next) { diff --git a/src/config.h b/src/config.h index 3077451..d25f87b 100644 --- a/src/config.h +++ b/src/config.h @@ -5,7 +5,19 @@ #include #include +enum conf_sortkey_types +{ + Metadata_sortkey_no, // This is not to be used as a sortkey + Metadata_sortkey_numeric, // Standard numerical sorting + Metadata_sortkey_range, // Range sorting (pick lowest or highest) + Metadata_sortkey_skiparticle, // Skip leading article when sorting + Metadata_sortkey_string +}; + // Describes known metadata elements and how they are to be manipulated +// An array of these structure provides a 'map' against which discovered metadata +// elements are matched. It also governs storage, to minimize number of cycles needed +// at various tages of processing struct conf_metadata { char *name; // The name of this element. Output by normalization stylesheet @@ -19,14 +31,7 @@ struct conf_metadata Metadata_type_integer, // Integer type Metadata_type_year // A year } type; - enum - { - Metadata_sortkey_no, // This is not to be used as a sortkey - Metadata_sortkey_numeric, // Standard numerical sorting - Metadata_sortkey_range, // Range sorting (pick lowest or highest) - Metadata_sortkey_skiparticle, // Skip leading article when sorting - Metadata_sortkey_string - } sortkey; + enum conf_sortkey_types sortkey; enum { Metadata_merge_no, // Don't merge @@ -37,10 +42,19 @@ struct conf_metadata } merge; }; +// Controls sorting +struct conf_sortkey +{ + char *name; + enum conf_sortkey_types type; +}; + struct conf_service { int num_metadata; struct conf_metadata *metadata; + int num_sortkeys; + struct conf_sortkey *sortkeys; }; struct conf_server -- 1.7.10.4