tinywebd
diff libtinyweb/src/genpage.c @ 16:2873d3ec8c78
starting page generator
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 20 Apr 2015 10:17:22 +0300 |
parents | |
children | 2874f61a43b1 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libtinyweb/src/genpage.c Mon Apr 20 10:17:22 2015 +0300 1.3 @@ -0,0 +1,50 @@ 1.4 +#include <string.h> 1.5 +#include <stdlib.h> 1.6 +#include <string.h> 1.7 +#include <stdarg.h> 1.8 +#include <errno.h> 1.9 +#include "genpage.h" 1.10 +#include "http.h" 1.11 +#include "logger.h" 1.12 + 1.13 +static char *footer; 1.14 + 1.15 +int set_gen_footer(const char *footer_fmt, ...) 1.16 +{ 1.17 + int len; 1.18 + char c; 1.19 + va_list ap; 1.20 + 1.21 + va_start(ap, footer_fmt); 1.22 + len = snprintf(&c, 0, footer_fmt, ap); 1.23 + va_end(ap); 1.24 + 1.25 + free(footer); 1.26 + if(!(footer = malloc(len + 1))) { 1.27 + logmsg("failed to set page generator footer: %s\n", strerror(errno)); 1.28 + return -1; 1.29 + } 1.30 + 1.31 + va_start(ap, footer_fmt); 1.32 + sprintf(footer, footer_fmt, ap); 1.33 + va_end(ap); 1.34 + 1.35 + return 0; 1.36 +} 1.37 + 1.38 +int gen_index(struct page *pg, const char *path) 1.39 +{ 1.40 +} 1.41 + 1.42 +int gen_error(struct page *pg, int errcode, const char *uri) 1.43 +{ 1.44 +} 1.45 + 1.46 +void destroy_page(struct page *pg) 1.47 +{ 1.48 + if(pg) { 1.49 + free(pg->text); 1.50 + pg->text = 0; 1.51 + pg->size = 0; 1.52 + } 1.53 +}