Added the CSC Ontological Webalizer
This commit is contained in:
parent
b458d371f0
commit
998376c47b
|
@ -0,0 +1,10 @@
|
|||
MAIN = cow
|
||||
CFLAGS = -I/usr/include/libxml2
|
||||
LDFLAGS = $(CFLAGS) -lxml2 -lxslt
|
||||
SOURCES = $(wildcard *.c)
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: $(MAIN)
|
||||
|
||||
$(MAIN): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS)
|
|
@ -0,0 +1,79 @@
|
|||
#include <stdio.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/debugXML.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/DOCBparser.h>
|
||||
#include <libxml/xinclude.h>
|
||||
#include <libxml/catalog.h>
|
||||
#include <libxslt/xslt.h>
|
||||
#include <libxslt/xsltInternals.h>
|
||||
#include <libxslt/transform.h>
|
||||
#include <libxslt/xsltutils.h>
|
||||
|
||||
extern int xmlLoadExtDtdDefaultValue;
|
||||
|
||||
// output usage message. progname is the name of the executable.
|
||||
static void usage(const char* progname)
|
||||
{
|
||||
printf("Usage: %s [options] stylesheet input\n", progname);
|
||||
printf(" --param name value : pass a parameter to the stylesheet\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int argNum;
|
||||
const char **params = 0;
|
||||
int maxparams = 0;
|
||||
int nbparams = 0;
|
||||
xsltStylesheetPtr cur = NULL;
|
||||
xmlDocPtr doc, res;
|
||||
|
||||
maxparams = 16;
|
||||
params = (const char**)malloc(sizeof(char*) * maxparams * 2);
|
||||
|
||||
if (argc <= 1) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (argNum = 1; argNum < argc; argNum++) {
|
||||
if (argv[argNum][0] != '-')
|
||||
break;
|
||||
if ((!strcmp(argv[argNum], "-param")) ||
|
||||
(!strcmp(argv[argNum], "--param"))) {
|
||||
argNum++;
|
||||
params[nbparams++] = argv[argNum++];
|
||||
params[nbparams++] = argv[argNum];
|
||||
if (nbparams >= maxparams * 2) {
|
||||
maxparams *= 2;
|
||||
params = realloc(params, sizeof(char*) * maxparams * 2);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Unknown option %s\n", argv[argNum]);
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (argNum == argc) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
params[nbparams] = NULL;
|
||||
xmlSubstituteEntitiesDefault(1);
|
||||
xmlLoadExtDtdDefaultValue = 1;
|
||||
cur = xsltParseStylesheetFile((const xmlChar *)argv[argNum]);
|
||||
argNum++;
|
||||
doc = xmlParseFile(argv[argNum]);
|
||||
res = xsltApplyStylesheet(cur, doc, params);
|
||||
xsltSaveResultToFile(stdout, res, cur);
|
||||
|
||||
xsltFreeStylesheet(cur);
|
||||
xmlFreeDoc(res);
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
xsltCleanupGlobals();
|
||||
xmlCleanupParser();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue