/* * FISG - Helper functions for XML/HTML output modules * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2004 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ #include "out_xhtmlgen.h" #include "th_string.h" #include typedef struct { int entChar; char *entStr; } t_xmlentity; t_xmlentity xmlEntities[] = { { '<', "<" }, { '>', ">" }, { '&', "&" }, { '¡', "¡" }, { '¢', "¢" }, { '£', "£" }, { '¤', "¤" }, { '¥', "¥" }, { '¦', "¦" }, { '§', "§" }, { '¨', "¨" }, { '©', "©" }, { 'ª', "ª" }, { '«', "«" }, { '¬', "¬" }, { '­', "­" }, { '®', "®" }, { '¯', "¯" }, { '°', "°" }, { '±', "±" }, { '²', "²" }, { '³', "³" }, { '´', "´" }, { 'µ', "µ" }, { '¶', "¶" }, { '·', "·" }, { '¸', "¸" }, { '¹', "¹" }, { 'º', "º" }, { '»', "»" }, { '¼', "¼" }, { '½', "½" }, { '¾', "¾" }, { '¿', "¿" }, { 'À', "À" }, { 'Á', "Á" }, { 'Â', "Â" }, { 'Ã', "Ã" }, { 'Ä', "Ä" }, { 'Å', "Å" }, { 'Æ', "Æ" }, { 'Ç', "Ç" }, { 'È', "È" }, { 'É', "É" }, { 'Ê', "Ê" }, { 'Ë', "Ë" }, { 'Ì', "Ì" }, { 'Í', "Í" }, { 'Î', "Î" }, { 'Ï', "Ï" }, { 'Ð', "Ð" }, { 'Ñ', "Ñ" }, { 'Ò', "Ò" }, { 'Ó', "Ó" }, { 'Ô', "Ô" }, { 'Õ', "Õ" }, { 'Ö', "Ö" }, { '×', "×" }, { 'Ø', "Ø" }, { 'Ù', "Ù" }, { 'Ú', "Ú" }, { 'Û', "Û" }, { 'Ü', "Ü" }, { 'Ý', "Ý" }, { 'Þ', "Þ" }, { 'ß', "ß" }, { 'à', "à" }, { 'á', "á" }, { 'â', "â" }, { 'ã', "ã" }, { 'ä', "ä" }, { 'å', "å" }, { 'æ', "æ" }, { 'ç', "ç" }, { 'è', "è" }, { 'é', "é" }, { 'ê', "ê" }, { 'ë', "ë" }, { 'ì', "ì" }, { 'í', "í" }, { 'î', "î" }, { 'ï', "ï" }, { 'ð', "ð" }, { 'ñ', "ñ" }, { 'ò', "ò" }, { 'ó', "ó" }, { 'ô', "ô" }, { 'õ', "õ" }, { 'ö', "ö" }, { '÷', "÷" }, { 'ø', "ø" }, { 'ù', "ù" }, { 'ú', "ú" }, { 'û', "û" }, { 'ü', "ü" }, { 'ý', "ý" }, { 'þ', "þ" }, { 'ÿ', "ÿ" }, }; const t_uint nXMLEntities = (sizeof(xmlEntities) / sizeof(t_xmlentity)); int xml_fprintf_entitize(FILE *outFile, char *fmt) { BOOL isFound; int c; t_uint i; while ((c = *fmt)) { /* Check character for entities */ for (isFound = FALSE, i = 0; (i < nXMLEntities) && !isFound; i++) if (xmlEntities[i].entChar == c) { isFound = TRUE; break; } if (isFound) { if (fputs(xmlEntities[i].entStr, outFile) == EOF) return EOF; } else { if (fputc(c, outFile) == EOF) return EOF; } fmt++; } return 0; } int xml_fprintf_urlencode(FILE *outFile, char *fmt) { int c; while ((c = *fmt)) { if (th_isalnum(c) || th_ispunct(c)) { if (fputc(c, outFile) == EOF) return EOF; } else { fprintf(outFile, "%%%.2x", c & 0xff); } fmt++; } return 0; } t_xhtmlconfig xhtml_cfg; int output_xhtml_init(t_config *cfg) { th_config_add_str(cfg, "xhtml_image_path", NULL, &xhtml_cfg.dataPath, "."); th_config_add_str(cfg, "xhtml_css_path", NULL, &xhtml_cfg.cssPath, "style.css"); return 0; }