tinywebd

view 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 source
1 #include <string.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdarg.h>
5 #include <errno.h>
6 #include "genpage.h"
7 #include "http.h"
8 #include "logger.h"
10 static char *footer;
12 int set_gen_footer(const char *footer_fmt, ...)
13 {
14 int len;
15 char c;
16 va_list ap;
18 va_start(ap, footer_fmt);
19 len = snprintf(&c, 0, footer_fmt, ap);
20 va_end(ap);
22 free(footer);
23 if(!(footer = malloc(len + 1))) {
24 logmsg("failed to set page generator footer: %s\n", strerror(errno));
25 return -1;
26 }
28 va_start(ap, footer_fmt);
29 sprintf(footer, footer_fmt, ap);
30 va_end(ap);
32 return 0;
33 }
35 int gen_index(struct page *pg, const char *path)
36 {
37 }
39 int gen_error(struct page *pg, int errcode, const char *uri)
40 {
41 }
43 void destroy_page(struct page *pg)
44 {
45 if(pg) {
46 free(pg->text);
47 pg->text = 0;
48 pg->size = 0;
49 }
50 }