summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/directory.c57
-rw-r--r--render/directory.h1
2 files changed, 36 insertions, 22 deletions
diff --git a/render/directory.c b/render/directory.c
index c64d05a77..e4b5b800d 100644
--- a/render/directory.c
+++ b/render/directory.c
@@ -34,8 +34,8 @@ 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;
- htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0);
- return true;
+ htmlParseChunk(c->data.html.parser, header, sizeof(header) - 1, 0);
+ return true;
}
bool directory_convert(struct content *c, int width, int height) {
@@ -59,22 +59,22 @@ bool directory_convert(struct content *c, int width, int height) {
if (!nice_path) {
msg_data.error = messages_get("MiscErr");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return false;
}
for (cnv = nice_path, tmp = path; *tmp != '\0'; *tmp++) {
- if (*tmp == '<') {
- *cnv++ = '&';
- *cnv++ = 'l';
- *cnv++ = 't';
- *cnv++ = ';';
- } else if (*tmp == '>') {
- *cnv++ = '&';
- *cnv++ = 'g';
- *cnv++ = 't';
- *cnv++ = ';';
- } else {
- *cnv++ = *tmp;
- }
+ if (*tmp == '<') {
+ *cnv++ = '&';
+ *cnv++ = 'l';
+ *cnv++ = 't';
+ *cnv++ = ';';
+ } else if (*tmp == '>') {
+ *cnv++ = '&';
+ *cnv++ = 'g';
+ *cnv++ = 't';
+ *cnv++ = ';';
+ } else {
+ *cnv++ = *tmp;
+ }
}
*cnv++ = '\0';
snprintf(buffer, sizeof(buffer), "Index of %s</title>\n</head>\n"
@@ -85,20 +85,20 @@ bool directory_convert(struct content *c, int width, int height) {
res = url_parent(c->url, &up);
if (res == URL_FUNC_OK) {
- res = url_compare(c->url, up, &compare);
- if (!compare) {
+ res = url_compare(c->url, up, &compare);
+ if (!compare) {
snprintf(buffer, sizeof(buffer),
"<a href=\"..\">[..]</a>\n");
htmlParseChunk(c->data.html.parser, buffer,
strlen(buffer), 0);
- }
- free(up);
- }
+ }
+ free(up);
+ }
if ((parent = opendir(path)) == NULL) {
msg_data.error = messages_get("EmptyErr");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return false;
}
while ((entry = readdir(parent)) != NULL) {
if (!strcmp(entry->d_name, ".") ||
@@ -115,3 +115,16 @@ bool directory_convert(struct content *c, int width, int height) {
c->type = CONTENT_HTML;
return html_convert(c, width, height);
}
+
+void directory_destroy(struct content *c)
+{
+ /* This will only get called if the content is destroyed before
+ * content_convert() is called. Simply force the type to HTML and
+ * delegate the cleanup to html_destroy() */
+
+ c->type = CONTENT_HTML;
+
+ html_destroy(c);
+
+ return;
+}
diff --git a/render/directory.h b/render/directory.h
index ce1b212c3..67fb5c1c0 100644
--- a/render/directory.h
+++ b/render/directory.h
@@ -20,5 +20,6 @@
bool directory_create(struct content *c, const char *params[]);
bool directory_convert(struct content *c, int width, int height);
+void directory_destroy(struct content *c);
#endif