From 2077918805c175ecefeb25dd38f78d2d5b3a3ca2 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 9 Sep 2010 21:45:59 +0000 Subject: Merge branches/vince/netsurf-file-fetcher to trunk r=jmb svn path=/trunk/netsurf/; revision=10750 --- content/dirlist.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'content/dirlist.c') diff --git a/content/dirlist.c b/content/dirlist.c index bbe120296..1f58154e2 100644 --- a/content/dirlist.c +++ b/content/dirlist.c @@ -51,9 +51,10 @@ static char* dirlist_filesize_unit(unsigned long bytesize); * dirlist_generate_bottom() */ -const char* dirlist_generate_top(void) +bool dirlist_generate_top(char *buffer, int buffer_length) { - return "\n" + int error = snprintf(buffer, buffer_length, + "\n" "\n" "\n" "%s\n" "\n" @@ -245,7 +258,7 @@ bool dirlist_generate_headings(char *buffer, int buffer_length) * \param directory whether this row is for a directory (or a file) * \param url url for row entry * \param name name of row entry - * \param type MIME type of row entry + * \param mimetype MIME type of row entry * \param size size of row entry. If negative, size is left blank * \param date date row entry was last modified * \param time time row entry was last modified @@ -266,7 +279,7 @@ bool dirlist_generate_headings(char *buffer, int buffer_length) */ bool dirlist_generate_row(bool even, bool directory, char *url, char *name, - char *type, long long size, char *date, char *time, + const char *mimetype, long long size, char *date, char *time, char *buffer, int buffer_length) { const char *unit; @@ -292,7 +305,7 @@ bool dirlist_generate_row(bool even, bool directory, char *url, char *name, "%s\n", url, even ? "even" : "odd", directory ? "dir" : "file", - name, type, size_string, unit, date, time); + name, mimetype, size_string, unit, date, time); if (error < 0 || error >= buffer_length) /* Error or buffer too small */ return false; @@ -319,11 +332,18 @@ bool dirlist_generate_row(bool even, bool directory, char *url, char *name, * dirlist_generate_bottom() */ -const char* dirlist_generate_bottom(void) +bool dirlist_generate_bottom(char *buffer, int buffer_length) { - return "\n" - "\n" - "\n"; + int error = snprintf(buffer, buffer_length, + "\n" + "\n" + "\n"); + if (error < 0 || error >= buffer_length) + /* Error or buffer too small */ + return false; + else + /* OK */ + return true; } -- cgit v1.2.3