Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <assert.h>
  3.  
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <sys/fcntl.h>
  7. #include <sys/mman.h>
  8.  
  9. #include <libxml/HTMLparser.h>
  10. #include <libxml/parser.h>
  11. #include <libxml/tree.h>
  12.  
  13. int main(int argc, char **argv)
  14. {
  15.         htmlDocPtr doc;
  16.  
  17.         struct stat info;
  18.         int fd;
  19.         char *file;
  20.  
  21.         if (argc != 2) {
  22.                 printf("Usage: %s <file>\n", argv[0]);
  23.                 return 1;
  24.         }
  25.  
  26.         /* libxml hack */
  27.         LIBXML_TEST_VERSION
  28.  
  29.  
  30.         stat(argv[1], &info);
  31.         fd = open(argv[1], 0);
  32.         file = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0);
  33.  
  34.         doc = htmlReadMemory(file, info.st_size, NULL, NULL,
  35.                         HTML_PARSE_RECOVER | HTML_PARSE_NOERROR |
  36.                         HTML_PARSE_NOWARNING);
  37. #if 0
  38.         doc = htmlReadFile(argv[1], NULL, HTML_PARSE_RECOVER |
  39.                         HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
  40. #endif
  41.         if (!doc) {
  42.                 printf("FAIL\n");
  43.                 return 1;
  44.         }
  45.  
  46.         xmlFreeDoc(doc);
  47.  
  48.         xmlCleanupParser();
  49.  
  50.         return 0;
  51. }
  52.  
  53.