tinywebd

changeset 17:2874f61a43b1 tip

implementing the directory index generation
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Apr 2015 04:33:02 +0300
parents 2873d3ec8c78
children
files libtinyweb/src/genpage.c
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/libtinyweb/src/genpage.c	Mon Apr 20 10:17:22 2015 +0300
     1.2 +++ b/libtinyweb/src/genpage.c	Tue Apr 21 04:33:02 2015 +0300
     1.3 @@ -34,10 +34,25 @@
     1.4  
     1.5  int gen_index(struct page *pg, const char *path)
     1.6  {
     1.7 +	DIR *dir;
     1.8 +	struct dirent *dent;
     1.9 +	static char pathbuf[256];
    1.10 +
    1.11 +	if(!(dir = opendir(path))) {
    1.12 +		logmsg("failed to generate index page for %s, opendir failed: %s\n", path, strerror(errno));
    1.13 +		return -1;
    1.14 +	}
    1.15 +
    1.16 +	while((dent = readdir(dir))) {
    1.17 +	}
    1.18 +
    1.19 +	closedir(dir);
    1.20 +	return 0;
    1.21  }
    1.22  
    1.23  int gen_error(struct page *pg, int errcode, const char *uri)
    1.24  {
    1.25 +	return 0;	/* TODO */
    1.26  }
    1.27  
    1.28  void destroy_page(struct page *pg)