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:
-/* $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 <string.h>
{
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)
{
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
+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
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
} 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