~ubuntu-branches/ubuntu/natty/expat/natty

« back to all changes in this revision

Viewing changes to examples/outline.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2008-06-09 20:48:30 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080609204830-25qbpwdhrov7tuyc
Tags: 2.0.1-4
debian/libexpat1-dev.install: Install the libtool .la files again and drop
them after Lenny (closes: #485460).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *
19
19
 * Read an XML document from standard input and print an element
20
20
 * outline on standard output.
 
21
 * Must be used with Expat compiled for UTF-8 output.
21
22
 */
22
23
 
23
24
 
24
25
#include <stdio.h>
25
26
#include <expat.h>
26
27
 
 
28
#if defined(__amigaos__) && defined(__USE_INLINE__)
 
29
#include <proto/expat.h>
 
30
#endif
 
31
 
 
32
#ifdef XML_LARGE_SIZE
 
33
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
 
34
#define XML_FMT_INT_MOD "I64"
 
35
#else
 
36
#define XML_FMT_INT_MOD "ll"
 
37
#endif
 
38
#else
 
39
#define XML_FMT_INT_MOD "l"
 
40
#endif
 
41
 
27
42
#define BUFFSIZE        8192
28
43
 
29
44
char Buff[BUFFSIZE];
69
84
    int done;
70
85
    int len;
71
86
 
72
 
    len = fread(Buff, 1, BUFFSIZE, stdin);
 
87
    len = (int)fread(Buff, 1, BUFFSIZE, stdin);
73
88
    if (ferror(stdin)) {
74
89
      fprintf(stderr, "Read error\n");
75
90
      exit(-1);
77
92
    done = feof(stdin);
78
93
 
79
94
    if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) {
80
 
      fprintf(stderr, "Parse error at line %d:\n%s\n",
 
95
      fprintf(stderr, "Parse error at line %" XML_FMT_INT_MOD "u:\n%s\n",
81
96
              XML_GetCurrentLineNumber(p),
82
97
              XML_ErrorString(XML_GetErrorCode(p)));
83
98
      exit(-1);
86
101
    if (done)
87
102
      break;
88
103
  }
 
104
  XML_ParserFree(p);
89
105
  return 0;
90
106
}