43 lines
872 B
C
43 lines
872 B
C
|
#ifndef _HTTPD_H_
|
||
|
#define _HTTPD_H_
|
||
|
|
||
|
#include <netinet/in.h>
|
||
|
|
||
|
#include "event.h"
|
||
|
#include "list.h"
|
||
|
|
||
|
struct httpd_con {
|
||
|
struct sockaddr_in addr;
|
||
|
struct event_fd *event;
|
||
|
|
||
|
int fd;
|
||
|
|
||
|
char *req_data;
|
||
|
unsigned int req_size;
|
||
|
|
||
|
char **req_headers;
|
||
|
unsigned int req_header_cnt;
|
||
|
|
||
|
char **req_args;
|
||
|
unsigned int req_arg_cnt;
|
||
|
};
|
||
|
|
||
|
struct httpd_callback {
|
||
|
struct list_head list;
|
||
|
char *name;
|
||
|
int wildcard;
|
||
|
|
||
|
int (* callback)(struct httpd_con *con, void *privdata);
|
||
|
void *privdata;
|
||
|
};
|
||
|
|
||
|
int httpd_send_header(struct httpd_con *con, char *code, char *type);
|
||
|
int httpd_send_error(struct httpd_con *con, char *code, char *msg);
|
||
|
|
||
|
struct httpd_callback * httpd_add_cb(const char *name, int flags, int (* cb)(struct httpd_con *con, void *privdata), void *privdata);
|
||
|
int httpd_remove_cb(struct httpd_callback *cb);
|
||
|
|
||
|
int httpd_accept_handler(int fd, void *privdata);
|
||
|
|
||
|
#endif // _HTTP_H_
|