2 #include <libxslt/extensions.h>
3 #include <libxml/xpath.h>
4 #include <libxml/xpathInternals.h>
6 #define COW_URI ((const xmlChar *)"http://www.csclub.uwaterloo.ca/cow")
8 /* return the term ({Winter,Summer,Fall} YYYY) for a date in
11 void extension_cow_term(xmlXPathParserContextPtr ctxt,
18 xmlXPathSetArityError(ctxt);
20 str = xmlXPathPopString(ctxt);
22 month = (str[5] - '0')*10 + (str[6] - '0');
24 ret = xmlUTF8Strndup((const xmlChar*)(month < 9 ? (month < 5 ? "Winter " : "Spring ") : "Fall "), 7);
25 ret = xmlStrcat(ret, xmlUTF8Strsub(str, 0, 4));
27 xmlXPathReturnString(ctxt, ret);
31 void *extension_init_func(xsltTransformContextPtr ctxt,
37 void extension_shutdown_func(xsltTransformContextPtr ctxt,
43 void init_extensions()
45 xsltRegisterExtModule(COW_URI,
46 extension_init_func, extension_shutdown_func);
47 xsltRegisterExtModuleFunction((const xmlChar*)"term", COW_URI,