summaryrefslogtreecommitdiff
path: root/render/directory.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-09-23 02:19:50 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-09-23 02:19:50 +0000
commit163ad56fce1b8d83d43034620a8d5c847785edf7 (patch)
tree5e52e438bc5d90af5fd6977d7367fec15e25ba2e /render/directory.c
parent4fad8726a4ae82849f38ffc3ef087181d7f37e14 (diff)
downloadnetsurf-163ad56fce1b8d83d43034620a8d5c847785edf7.tar.gz
netsurf-163ad56fce1b8d83d43034620a8d5c847785edf7.tar.bz2
Rework html parser bindings to have a common API and reside in separate files for ease of reading.
Add error handling to hubbub binding. svn path=/trunk/netsurf/; revision=5404
Diffstat (limited to 'render/directory.c')
-rw-r--r--render/directory.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/render/directory.c b/render/directory.c
index 1363ad251..c2b343fbe 100644
--- a/render/directory.c
+++ b/render/directory.c
@@ -48,12 +48,10 @@ bool directory_create(struct content *c, const char *params[]) {
/* html_create() must have broadcast MSG_ERROR already, so we
* don't need to. */
return false;
-#ifndef WITH_HUBBUB
- htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0);
-#else
- hubbub_parser_parse_chunk(c->data.html.parser,
- (uint8_t *) header, sizeof(header) - 1);
-#endif
+
+ binding_parse_chunk(c->data.html.parser_binding,
+ (uint8_t *) header, sizeof(header) - 1);
+
return true;
}
@@ -100,12 +98,9 @@ bool directory_convert(struct content *c, int width, int height) {
"<body>\n<h1>\nIndex of %s</h1>\n<hr><pre>",
nice_path, nice_path);
free(nice_path);
-#ifndef WITH_HUBBUB
- htmlParseChunk(c->data.html.parser, buffer, strlen(buffer), 0);
-#else
- hubbub_parser_parse_chunk(c->data.html.parser,
+
+ binding_parse_chunk(c->data.html.parser_binding,
(uint8_t *) buffer, strlen(buffer));
-#endif
res = url_parent(c->url, &up);
if (res == URL_FUNC_OK) {
@@ -113,14 +108,9 @@ bool directory_convert(struct content *c, int width, int height) {
if ((res == URL_FUNC_OK) && !compare) {
snprintf(buffer, sizeof(buffer),
"<a href=\"..\">[..]</a>\n");
-#ifndef WITH_HUBBUB
- htmlParseChunk(c->data.html.parser, buffer,
- strlen(buffer), 0);
-#else
- hubbub_parser_parse_chunk(c->data.html.parser,
- (uint8_t *) buffer,
- strlen(buffer));
-#endif
+
+ binding_parse_chunk(c->data.html.parser_binding,
+ (uint8_t *) buffer, strlen(buffer));
}
free(up);
}
@@ -137,21 +127,15 @@ bool directory_convert(struct content *c, int width, int height) {
snprintf(buffer, sizeof(buffer), "<a href=\"%s/%s\">%s</a>\n",
c->url, entry->d_name, entry->d_name);
-#ifndef WITH_HUBBUB
- htmlParseChunk(c->data.html.parser, buffer, strlen(buffer), 0);
-#else
- hubbub_parser_parse_chunk(c->data.html.parser,
+
+ binding_parse_chunk(c->data.html.parser_binding,
(uint8_t *) buffer, strlen(buffer));
-#endif
}
closedir(parent);
-#ifndef WITH_HUBBUB
- htmlParseChunk(c->data.html.parser, footer, sizeof(footer) - 1, 0);
-#else
- hubbub_parser_parse_chunk(c->data.html.parser,
+ binding_parse_chunk(c->data.html.parser_binding,
(uint8_t *) footer, sizeof(footer) - 1);
-#endif
+
c->type = CONTENT_HTML;
return html_convert(c, width, height);
}