/*
 * webkernel.h
 *
 * A small embeddable web server.
 *
 * Header file.
 *
 * History:
 *      21/01/2014 Creation.
 *	 2/04/2014 wk_fdinit()/_fdcheck().
 *
 * Author: Dario Rodriguez dario@softhome.net
 * This library is licensed on the terms of the GNU LGPL v2+
 */

#ifndef WEBKERNEL_H
#define WEBKERNEL_H
#include <sys/select.h>
#include "iobuf.h"

typedef void wk;

wk *wk_init(int port);
void wk_free(wk *web);
int wk_fdsetinit(wk *web, int *n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); /* n, readfds, writefds and execptfds must be already initialized to 0 */
int wk_fdsetcheck(wk *web, fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
int wk_select(wk *web, int timemoutms,...);
int wk_httpaccept(wk *web, int *httpnum);
int wk_httpisrequest(char *line);
int wk_httpfromdisk(wk *web, int httpnum,char *firstline);
int wk_httpreset(wk *web, int httpnum);
int wk_httpclose(wk *web, int httpnum);

siobuf *wk_iobufget(wk *web);
wk_iobuffree(wk *web, int iobufnum);

#endif