feat: ports - libhubbub, libcss, libdom
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018Ae69wJS7sueQMUwNxV3nX
This commit is contained in:
@@ -18,7 +18,11 @@ PORT_NAME := porttest
|
||||
|
||||
include ../mk/port.mk
|
||||
|
||||
# Link order matters: dependents before their dependencies.
|
||||
SYSROOT_LIBS := \
|
||||
$(PORT_SYSROOT_LIB)/libdom.a \
|
||||
$(PORT_SYSROOT_LIB)/libcss.a \
|
||||
$(PORT_SYSROOT_LIB)/libhubbub.a \
|
||||
$(PORT_SYSROOT_LIB)/libparserutils.a \
|
||||
$(PORT_SYSROOT_LIB)/libwapcaplet.a \
|
||||
$(PORT_SYSROOT_LIB)/libz.a
|
||||
|
||||
@@ -2,9 +2,23 @@
|
||||
#include <parserutils/parserutils.h>
|
||||
#include <parserutils/charset/utf8.h>
|
||||
#include <parserutils/utils/buffer.h>
|
||||
#include <hubbub/hubbub.h>
|
||||
#include <hubbub/parser.h>
|
||||
#include <libcss/libcss.h>
|
||||
#include <dom/dom.h>
|
||||
#include <zlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/* libcss requires a URL resolver; relative resolution is not what is under
|
||||
test here, so just duplicate the reference. */
|
||||
static css_error pt_resolve_url(void *pw, const char *base,
|
||||
lwc_string *rel, lwc_string **abs)
|
||||
{
|
||||
(void) pw; (void) base;
|
||||
*abs = lwc_string_ref(rel);
|
||||
return CSS_OK;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
lwc_string *a = NULL, *b = NULL;
|
||||
bool same = false;
|
||||
@@ -55,6 +69,47 @@ int main(void) {
|
||||
printf("zlib %s: gzip roundtrip %lu->%lu %s\n",
|
||||
zlibVersion(), (unsigned long)strlen(s), (unsigned long)clen,
|
||||
gzok ? "PASS" : "FAIL");
|
||||
/* libhubbub / libcss / libdom: construct the real objects rather than
|
||||
just resolving symbols -- a stub-out or a broken static init would
|
||||
still link but fail here. */
|
||||
{
|
||||
hubbub_parser *hp = NULL;
|
||||
css_stylesheet *sheet = NULL;
|
||||
css_stylesheet_params sp;
|
||||
dom_document *doc = NULL;
|
||||
dom_exception de;
|
||||
hubbub_error he;
|
||||
|
||||
he = hubbub_parser_create("UTF-8", false, &hp);
|
||||
printf("libhubbub: parser_create %s\n",
|
||||
(he == HUBBUB_OK && hp != NULL) ? "PASS" : "FAIL");
|
||||
if (hp != NULL) hubbub_parser_destroy(hp);
|
||||
|
||||
memset(&sp, 0, sizeof(sp));
|
||||
sp.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
|
||||
sp.level = CSS_LEVEL_21;
|
||||
sp.charset = "UTF-8";
|
||||
sp.url = "http://montaukos.local/";
|
||||
sp.resolve = pt_resolve_url;
|
||||
if (css_stylesheet_create(&sp, &sheet) == CSS_OK && sheet != NULL) {
|
||||
const char data[] = "body { color: #123456; margin: 4px; }";
|
||||
css_error ce = css_stylesheet_append_data(sheet,
|
||||
(const uint8_t *) data, sizeof(data) - 1);
|
||||
if (ce == CSS_NEEDDATA) ce = CSS_OK;
|
||||
if (ce == CSS_OK) ce = css_stylesheet_data_done(sheet);
|
||||
printf("libcss: parse stylesheet %s\n", ce == CSS_OK ? "PASS" : "FAIL");
|
||||
css_stylesheet_destroy(sheet);
|
||||
} else {
|
||||
printf("libcss: stylesheet_create FAIL\n");
|
||||
}
|
||||
|
||||
de = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
|
||||
NULL, NULL, NULL, NULL, NULL, &doc);
|
||||
printf("libdom: create_document %s\n",
|
||||
(de == DOM_NO_ERR && doc != NULL) ? "PASS" : "FAIL");
|
||||
if (doc != NULL) dom_node_unref(doc);
|
||||
}
|
||||
|
||||
lwc_string_unref(a); lwc_string_unref(b);
|
||||
parserutils_buffer_destroy(buf);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user