From 163ad56fce1b8d83d43034620a8d5c847785edf7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 23 Sep 2008 02:19:50 +0000 Subject: 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 --- render/directory.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'render/directory.c') 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) { "\n

\nIndex of %s

\n
",
 			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),
 				"[..]\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), "%s\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);
 }
-- 
cgit v1.2.3