testupnpreplyparse.c 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* $Id: testupnpreplyparse.c,v 1.2 2008/02/21 13:05:27 nanard Exp $ */
  2. /* MiniUPnP project
  3. * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
  4. * (c) 2006-2007 Thomas Bernard
  5. * This software is subject to the conditions detailed
  6. * in the LICENCE file provided within the distribution */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include "upnpreplyparse.h"
  10. void
  11. test_parsing(const char * buf, int len)
  12. {
  13. struct NameValueParserData pdata;
  14. ParseNameValue(buf, len, &pdata);
  15. ClearNameValueList(&pdata);
  16. }
  17. int main(int argc, char * * argv)
  18. {
  19. FILE * f;
  20. char buffer[4096];
  21. int l;
  22. if(argc<2)
  23. {
  24. fprintf(stderr, "Usage: %s file.xml\n", argv[0]);
  25. return 1;
  26. }
  27. f = fopen(argv[1], "r");
  28. if(!f)
  29. {
  30. fprintf(stderr, "Error : can not open file %s\n", argv[1]);
  31. return 2;
  32. }
  33. l = fread(buffer, 1, sizeof(buffer)-1, f);
  34. fclose(f);
  35. buffer[l] = '\0';
  36. #ifdef DEBUG
  37. DisplayNameValueList(buffer, l);
  38. #endif
  39. test_parsing(buffer, l);
  40. return 0;
  41. }