mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
netsurf: remove wrapper C files
This commit is contained in:
@@ -151,13 +151,4 @@ fn linkNetSurf(step: *std.build.LibExeObjStep) void {
|
|||||||
step.addIncludePath(.{ .path = ns ++ lib ++ "/src" });
|
step.addIncludePath(.{ .path = ns ++ lib ++ "/src" });
|
||||||
}
|
}
|
||||||
step.addIncludePath(.{ .path = ns ++ "/include" });
|
step.addIncludePath(.{ .path = ns ++ "/include" });
|
||||||
|
|
||||||
// wrapper
|
|
||||||
const flags = [_][]const u8{};
|
|
||||||
const files: [1][]const u8 = .{ns ++ "wrapper/wrapper.c"};
|
|
||||||
step.addCSourceFiles(.{
|
|
||||||
.files = &files,
|
|
||||||
.flags = &flags,
|
|
||||||
});
|
|
||||||
step.addIncludePath(.{ .path = ns ++ "wrapper" });
|
|
||||||
}
|
}
|
||||||
|
|||||||
127
vendor/netsurf/wrapper/wrapper.c
vendored
127
vendor/netsurf/wrapper/wrapper.c
vendored
@@ -1,127 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <dom/dom.h>
|
|
||||||
#include <dom/bindings/hubbub/parser.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a LibDOM document DOM from an HTML string
|
|
||||||
*
|
|
||||||
* \param string The HTML string
|
|
||||||
* \return pointer to DOM document, or NULL on error
|
|
||||||
*/
|
|
||||||
dom_document *wr_create_doc_dom_from_string(const char *html)
|
|
||||||
{
|
|
||||||
dom_hubbub_parser *parser = NULL;
|
|
||||||
dom_hubbub_error error;
|
|
||||||
dom_hubbub_parser_params params;
|
|
||||||
dom_document *doc;
|
|
||||||
|
|
||||||
params.enc = NULL;
|
|
||||||
params.fix_enc = true;
|
|
||||||
params.enable_script = false;
|
|
||||||
params.msg = NULL;
|
|
||||||
params.script = NULL;
|
|
||||||
params.ctx = NULL;
|
|
||||||
params.daf = NULL;
|
|
||||||
|
|
||||||
/* Create Hubbub parser */
|
|
||||||
error = dom_hubbub_parser_create(¶ms, &parser, &doc);
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
printf("Can't create Hubbub Parser\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = dom_hubbub_parser_parse_chunk(parser, html, strlen(html));
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
printf("Parsing errors occur\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Done parsing file */
|
|
||||||
error = dom_hubbub_parser_completed(parser);
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
printf("Parsing error when construct DOM\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finished with parser */
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a LibDOM document DOM from an HTML file
|
|
||||||
*
|
|
||||||
* \param file The file path
|
|
||||||
* \return pointer to DOM document, or NULL on error
|
|
||||||
*/
|
|
||||||
dom_document *wr_create_doc_dom_from_file(const char *filename)
|
|
||||||
{
|
|
||||||
size_t buffer_size = 1024;
|
|
||||||
dom_hubbub_parser *parser = NULL;
|
|
||||||
FILE *handle;
|
|
||||||
int chunk_length;
|
|
||||||
dom_hubbub_error error;
|
|
||||||
dom_hubbub_parser_params params;
|
|
||||||
dom_document *doc;
|
|
||||||
unsigned char buffer[buffer_size];
|
|
||||||
|
|
||||||
params.enc = NULL;
|
|
||||||
params.fix_enc = true;
|
|
||||||
params.enable_script = false;
|
|
||||||
params.msg = NULL;
|
|
||||||
params.script = NULL;
|
|
||||||
params.ctx = NULL;
|
|
||||||
params.daf = NULL;
|
|
||||||
|
|
||||||
/* Create Hubbub parser */
|
|
||||||
error = dom_hubbub_parser_create(¶ms, &parser, &doc);
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
printf("Can't create Hubbub Parser\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open input file */
|
|
||||||
handle = fopen(filename, "rb");
|
|
||||||
if (handle == NULL) {
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
printf("Can't open test input file: %s\n", filename);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse input file in chunks */
|
|
||||||
chunk_length = buffer_size;
|
|
||||||
while (chunk_length == buffer_size) {
|
|
||||||
chunk_length = fread(buffer, 1, buffer_size, handle);
|
|
||||||
error = dom_hubbub_parser_parse_chunk(parser, buffer,
|
|
||||||
chunk_length);
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
printf("Parsing errors occur\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Done parsing file */
|
|
||||||
error = dom_hubbub_parser_completed(parser);
|
|
||||||
if (error != DOM_HUBBUB_OK) {
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
printf("Parsing error when construct DOM\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finished with parser */
|
|
||||||
dom_hubbub_parser_destroy(parser);
|
|
||||||
|
|
||||||
/* Close input file */
|
|
||||||
if (fclose(handle) != 0) {
|
|
||||||
printf("Can't close test input file: %s\n", filename);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
9
vendor/netsurf/wrapper/wrapper.h
vendored
9
vendor/netsurf/wrapper/wrapper.h
vendored
@@ -1,9 +0,0 @@
|
|||||||
#ifndef wrapper_dom_h_
|
|
||||||
#define wrapper_dom_h_
|
|
||||||
|
|
||||||
#include <dom/dom.h>
|
|
||||||
|
|
||||||
dom_document *wr_create_doc_dom_from_string(const char *html);
|
|
||||||
dom_document *wr_create_doc_dom_from_file(const char *filename);
|
|
||||||
|
|
||||||
#endif /* wrapper_dom_h_ */
|
|
||||||
Reference in New Issue
Block a user