bchs_tuto/vars_kcgi.c

44 lines
877 B
C
Raw Normal View History

2016-12-11 19:32:03 +00:00
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <kcgi.h>
#include <kcgihtml.h>
int
main(int argc, char **argv, char** envp)
{
struct kreq r;
struct khtmlreq h;
const char *page = "index";
if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
return(EXIT_FAILURE);
khttp_head(&r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]);
khttp_head(&r, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[r.mime]);
khttp_body(&r);
khtml_open(&h, &r);
khtml_elem(&h, KELEM_HTML);
khtml_elem(&h, KELEM_BODY);
khtml_elem(&h, KELEM_H1);
khtml_puts(&h, "Env");
khtml_closeelem(&h, 1);
khtml_elem(&h, KELEM_UL);
char** env;
for (env = envp; *env != 0; env++)
{
khtml_elem(&h, KELEM_LI);
khtml_puts(&h, *env);
khtml_closeelem(&h, 1);
}
khtml_closeelem(&h, 1);
khtml_close(&h);
khttp_free(&r);
return(EXIT_SUCCESS);
}