-
Notifications
You must be signed in to change notification settings - Fork 1
/
rub.h.in
126 lines (99 loc) · 2.96 KB
/
rub.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef __SPLIT__H
#define __SPLIT__H
#define _GNU_SOURCE
#include <stddef.h>
#include <event2/http.h>
#include <syslog.h>
#include <uv.h>
#include "http-parser/http_parser.h"
#include "bt.h"
#include "at.h"
#include "ut.h"
/* Response codes */
/* taken from libevent */
#define HTTP_OK 200 /**< request completed ok */
#define HTTP_NOCONTENT 204 /**< request does not have content */
#define HTTP_MOVEPERM 301 /**< the uri moved permanently */
#define HTTP_MOVETEMP 302 /**< the uri moved temporarily */
#define HTTP_NOTMODIFIED 304 /**< page was not modified from last */
#define HTTP_BADREQUEST 400 /**< invalid http request was made */
#define HTTP_NOTFOUND 404 /**< could not find content for uri */
#define HTTP_BADMETHOD 405 /**< method not allowed for this uri */
#define HTTP_ENTITYTOOLARGE 413 /**< */
#define HTTP_EXPECTATIONFAILED 417 /**< we can't handle this expectation */
#define HTTP_INTERNAL 500 /**< internal error */
#define HTTP_NOTIMPLEMENTED 501 /**< not implemented */
#define HTTP_SERVUNAVAIL 503 /**< the server is not available */
void route_request_cb( struct evhttp_request *req, void *arg );
int config_get_int( const char *name );
const char * config_get_str( const char *name );
char * source_file( const char *fpath );
const void * config_get_obj( const char *name );
struct kv_t {
char *key;
char *value;
struct kv_t *next;
};
struct client_t {
uv_tcp_t tcp;
http_parser parser;
uv_write_t write_req;
uv_buf_t resbuf;
int http_code;
char reason[32];
struct bt outs;
// Response data - don't touch, use functions!
uv_buf_t rheaders[100];
int rheader_count;
struct bt body;
// Public fields below
// Managed by rub.c
struct kv_t *headers;
char *url;
// Managed by route.c
char *query;
struct at get_fields;
struct at post_fields;
};
struct table_entry {
const char *extension;
const char *content_type;
};
struct config_t {
const char *doc_root;
const char *script_root;
const char *address;
unsigned short port;
int display_error;
int max_post_size;
};
struct client_t *rub_get_request();
void route_request( struct client_t *client, void *arg );
void add_header( struct client_t *client, const char * h);
const char * log_format( const char *fmt, struct evhttp_request *req,
int response_size );
#define dprintf(...) printf(__VA_ARGS__)
#define MAX_ENT 32
#define MAX_LINE 256
#define MAXNAME 16
struct line_t {
const char *line;
struct line_t *next;
};
struct entity_t {
const char *name;
struct entity_t *next;
struct line_t *line;
struct line_t *curr;
};
struct entity_t * first_entity();
void scpy( char *dst, const char *src, size_t dsize, int max );
/**
* Platform dependent impl to get source code for program
*/
char *readprog( const char *filepath );
struct entity_t * first_entity();
struct entity_t * new_entity();
struct line_t * new_line();
struct line_t * first_line();
#endif