diff options
-rw-r--r-- | examples/elements.c | 13 | ||||
-rw-r--r-- | examples/outline.c | 22 |
2 files changed, 19 insertions, 16 deletions
diff --git a/examples/elements.c b/examples/elements.c index 9a20c34..42f0889 100644 --- a/examples/elements.c +++ b/examples/elements.c @@ -1,7 +1,8 @@ /* This is simple demonstration of how to use expat. This program -reads an XML document from standard input and writes a line with the -name of each element to standard output indenting child elements by -one tab stop more than their parent element. */ + reads an XML document from standard input and writes a line with + the name of each element to standard output indenting child + elements by one tab stop more than their parent element. +*/ #include <stdio.h> #include "expat.h" @@ -38,9 +39,9 @@ main(int argc, char *argv[]) done = len < sizeof(buf); if (!XML_Parse(parser, buf, len, done)) { fprintf(stderr, - "%s at line %d\n", - XML_ErrorString(XML_GetErrorCode(parser)), - XML_GetCurrentLineNumber(parser)); + "%s at line %d\n", + XML_ErrorString(XML_GetErrorCode(parser)), + XML_GetCurrentLineNumber(parser)); return 1; } } while (!done); diff --git a/examples/outline.c b/examples/outline.c index a296494..2eeca06 100644 --- a/examples/outline.c +++ b/examples/outline.c @@ -24,14 +24,15 @@ #include <stdio.h> #include <expat.h> -#define BUFFSIZE 8192 +#define BUFFSIZE 8192 char Buff[BUFFSIZE]; int Depth; static void -start(void *data, const char *el, const char **attr) { +start(void *data, const char *el, const char **attr) +{ int i; for (i = 0; i < Depth; i++) @@ -45,15 +46,17 @@ start(void *data, const char *el, const char **attr) { printf("\n"); Depth++; -} /* End of start handler */ +} static void -end(void *data, const char *el) { +end(void *data, const char *el) +{ Depth--; -} /* End of end handler */ +} int -main(int argc, char *argv[]) { +main(int argc, char *argv[]) +{ XML_Parser p = XML_ParserCreate(NULL); if (! p) { fprintf(stderr, "Couldn't allocate memory for parser\n"); @@ -75,8 +78,8 @@ main(int argc, char *argv[]) { if (! XML_Parse(p, Buff, len, done)) { fprintf(stderr, "Parse error at line %d:\n%s\n", - XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); + XML_GetCurrentLineNumber(p), + XML_ErrorString(XML_GetErrorCode(p))); exit(-1); } @@ -84,5 +87,4 @@ main(int argc, char *argv[]) { break; } return 0; -} /* End of main */ - +} |