Display env with kcgi
This commit is contained in:
parent
43a2f82f31
commit
7abf121bfb
43
vars_kcgi.c
Normal file
43
vars_kcgi.c
Normal file
@ -0,0 +1,43 @@
|
||||
#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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user