1
/** **************************************************************************
4
* Copyright 2008 Bryan Ischo <bryan@ischo.com>
6
* This file is part of libs3.
8
* libs3 is free software: you can redistribute it and/or modify it under the
9
* terms of the GNU General Public License as published by the Free Software
10
* Foundation, version 3 of the License.
12
* In addition, as a special exception, the copyright holders give
13
* permission to link the code of this library and its programs with the
14
* OpenSSL library, and distribute linked combinations including the two.
16
* libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
17
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21
* You should have received a copy of the GNU General Public License version 3
22
* along with libs3, in a file named COPYING. If not, see
23
* <http://www.gnu.org/licenses/>.
25
************************************************************************** **/
31
#include "simplexml.h"
33
static S3Status simpleXmlCallback(const char *elementPath, const char *data,
34
int dataLen, void *callbackData)
38
printf("[%s]: [%.*s]\n", elementPath, dataLen, data);
44
// The only argument allowed is a specification of the random seed to use
45
int main(int argc, char **argv)
52
seed += (*arg++ - '0');
63
simplexml_initialize(&simpleXml, &simpleXmlCallback, 0);
65
// Read chunks of 10K from stdin, and then feed them in random chunks
70
while ((amt_read = fread(inbuf, 1, sizeof(inbuf), stdin)) > 0) {
73
int amt = (rand() % amt_read) + 1;
74
S3Status status = simplexml_add(&simpleXml, buf, amt);
75
if (status != S3StatusOK) {
76
fprintf(stderr, "ERROR: Parse failure: %d\n", status);
77
simplexml_deinitialize(&simpleXml);
80
buf += amt, amt_read -= amt;
84
simplexml_deinitialize(&simpleXml);