Skip to content

Instantly share code, notes, and snippets.

@nielsdos
Created April 23, 2024 21:50
Show Gist options
  • Save nielsdos/fbbcfb404fdee92e6c814212de81d015 to your computer and use it in GitHub Desktop.
Save nielsdos/fbbcfb404fdee92e6c814212de81d015 to your computer and use it in GitHub Desktop.
#include "base.h"
int
main(int argc, const char *argv[])
{
if (argc != 2) {
FAILED("Usage: %s <file>", argv[0]);
}
lxb_status_t status;
lxb_html_document_t *document;
FILE *f = fopen(argv[1], "rb");
if (!f) {
FAILED("Failed to open file");
}
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
lxb_char_t *string = malloc(fsize);
fread(string, fsize, 1, f);
fclose(f);
for (int i = 0; i < 300; i++) {
document = lxb_html_document_create();
if (document == NULL) {
FAILED("Failed to create HTML Document");
}
status = lxb_html_document_parse(document, string, fsize);
if (status != LXB_STATUS_OK) {
FAILED("Failed to parse HTML");
}
lxb_html_document_destroy(document);
}
free(string);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment