Annotation of embedaddon/miniupnpc/testminixml.c, revision 1.1
1.1 ! misho 1: /* $Id: testminixml.c,v 1.6 2006/11/19 22:32:35 nanard Exp $
! 2: * testminixml.c
! 3: * test program for the "minixml" functions.
! 4: * Author : Thomas Bernard.
! 5: */
! 6: #include <stdlib.h>
! 7: #include <stdio.h>
! 8: #include <string.h>
! 9: #include "minixml.h"
! 10: #include "igd_desc_parse.h"
! 11:
! 12: #ifdef WIN32
! 13: #define NO_BZERO
! 14: #endif
! 15:
! 16: #ifdef NO_BZERO
! 17: #define bzero(p, n) memset(p, 0, n)
! 18: #endif
! 19:
! 20: /* ---------------------------------------------------------------------- */
! 21: void printeltname1(void * d, const char * name, int l)
! 22: {
! 23: int i;
! 24: printf("element ");
! 25: for(i=0;i<l;i++)
! 26: putchar(name[i]);
! 27: }
! 28: void printeltname2(void * d, const char * name, int l)
! 29: {
! 30: int i;
! 31: putchar('/');
! 32: for(i=0;i<l;i++)
! 33: putchar(name[i]);
! 34: putchar('\n');
! 35: }
! 36: void printdata(void *d, const char * data, int l)
! 37: {
! 38: int i;
! 39: printf("data : ");
! 40: for(i=0;i<l;i++)
! 41: putchar(data[i]);
! 42: putchar('\n');
! 43: }
! 44:
! 45: void burptest(const char * buffer, int bufsize)
! 46: {
! 47: struct IGDdatas data;
! 48: struct xmlparser parser;
! 49: /*objet IGDdatas */
! 50: bzero(&data, sizeof(struct IGDdatas));
! 51: /* objet xmlparser */
! 52: parser.xmlstart = buffer;
! 53: parser.xmlsize = bufsize;
! 54: parser.data = &data;
! 55: /*parser.starteltfunc = printeltname1;
! 56: parser.endeltfunc = printeltname2;
! 57: parser.datafunc = printdata; */
! 58: parser.starteltfunc = IGDstartelt;
! 59: parser.endeltfunc = IGDendelt;
! 60: parser.datafunc = IGDdata;
! 61: parsexml(&parser);
! 62: printIGD(&data);
! 63: }
! 64:
! 65: /* ----- main ---- */
! 66: #define XML_MAX_SIZE (8192)
! 67: int main(int argc, char * * argv)
! 68: {
! 69: FILE * f;
! 70: char buffer[XML_MAX_SIZE];
! 71: int bufsize;
! 72: if(argc<2)
! 73: {
! 74: printf("usage:\t%s file.xml\n", argv[0]);
! 75: return 1;
! 76: }
! 77: f = fopen(argv[1], "r");
! 78: if(!f)
! 79: {
! 80: printf("cannot open file %s\n", argv[1]);
! 81: return 1;
! 82: }
! 83: bufsize = (int)fread(buffer, 1, XML_MAX_SIZE, f);
! 84: fclose(f);
! 85: burptest(buffer, bufsize);
! 86: return 0;
! 87: }
! 88:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>