diff --git a/src/protocol/file/file.c b/src/protocol/file/file.c index b085a943..84bc9506 100644 --- a/src/protocol/file/file.c +++ b/src/protocol/file/file.c @@ -25,6 +25,7 @@ #include "intl/gettext/libintl.h" #include "main/module.h" #include "network/connection.h" +#include "protocol/common.h" #include "protocol/file/cgi.h" #include "protocol/file/file.h" #include "protocol/uri.h" @@ -186,12 +187,12 @@ add_dir_entries(struct directory_entry *entries, unsigned char *dirpath, * @dirpath. */ /* Returns a connection state. S_OK if all is well. */ static inline enum connection_state -list_directory(unsigned char *dirpath, struct string *page) +list_directory(struct connection *conn, unsigned char *dirpath, + struct string *page) { int show_hidden_files = get_opt_bool("protocol.file.show_hidden_files"); - unsigned char *slash = dirpath; - unsigned char *pslash = ++slash; struct directory_entry *entries; + enum connection_state state; errno = 0; entries = get_directory_entries(dirpath, show_hidden_files); @@ -200,30 +201,17 @@ list_directory(unsigned char *dirpath, struct string *page) return S_OUT_OF_MEM; } - if (!init_string(page)) return S_OUT_OF_MEM; + state = init_directory_listing(page, conn->uri); + if (state != S_OK) + return S_OUT_OF_MEM; - add_to_string(page, "\n
"); - add_dir_entries(entries, dirpath, page); - add_to_string(page, "\n