diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2014-04-01 00:19:30 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2014-04-01 00:19:30 +0200 |
commit | 0df57225a5c7e475116cad33c9a9a92b907ade56 (patch) | |
tree | dd2f978a0eff295b0a721d646e92e1881b5b0f15 /sfeed_xmlenc.c | |
parent | 072e7e6b1fdf17d10fdb573adaecaed320718b90 (diff) |
fix crlf newlines, add fp arg to xmlparser_init
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat (limited to 'sfeed_xmlenc.c')
-rw-r--r-- | sfeed_xmlenc.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/sfeed_xmlenc.c b/sfeed_xmlenc.c index c5cd289..97c1c2b 100644 --- a/sfeed_xmlenc.c +++ b/sfeed_xmlenc.c @@ -1,45 +1,45 @@ -#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "xml.h"
-
-static int isxmlpi = 0, tags = 0;
-
-static void
-xmltagstart(XMLParser *p, const char *tag, size_t taglen) {
- if(tags > 3) /* optimization: try to find processing instruction at start */
- exit(EXIT_FAILURE);
- isxmlpi = (tag[0] == '?' && (!strncasecmp(tag, "?xml", taglen))) ? 1 : 0;
- tags++;
-}
-
-static void
-xmltagend(XMLParser *p, const char *tag, size_t taglen, int isshort) {
- isxmlpi = 0;
-}
-
-static void
-xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen) {
- if(isxmlpi && (!strncasecmp(name, "encoding", namelen))) {
- for(; *value; value++)
- putc(tolower((int)*value), stdout); /* output lowercase */
- exit(EXIT_SUCCESS);
- }
-}
-
-int
-main(int argc, char **argv) {
- XMLParser x;
-
- xmlparser_init(&x);
- x.xmltagstart = xmltagstart;
- x.xmltagend = xmltagend;
- x.xmlattr = xmlattr;
-
- xmlparser_parse(&x);
-
- return EXIT_FAILURE;
-}
+#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include <ctype.h> + +#include "xml.h" + +static int isxmlpi = 0, tags = 0; + +static void +xmltagstart(XMLParser *p, const char *tag, size_t taglen) { + if(tags > 3) /* optimization: try to find processing instruction at start */ + exit(EXIT_FAILURE); + isxmlpi = (tag[0] == '?' && (!strncasecmp(tag, "?xml", taglen))) ? 1 : 0; + tags++; +} + +static void +xmltagend(XMLParser *p, const char *tag, size_t taglen, int isshort) { + isxmlpi = 0; +} + +static void +xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen) { + if(isxmlpi && (!strncasecmp(name, "encoding", namelen))) { + for(; *value; value++) + putc(tolower((int)*value), stdout); /* output lowercase */ + exit(EXIT_SUCCESS); + } +} + +int +main(int argc, char **argv) { + XMLParser x; + + xmlparser_init(&x, stdin); + x.xmltagstart = xmltagstart; + x.xmltagend = xmltagend; + x.xmlattr = xmlattr; + + xmlparser_parse(&x); + + return EXIT_FAILURE; +} |