-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheepwool.h
52 lines (44 loc) · 1.27 KB
/
sheepwool.h
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
#include <stdbool.h>
#include <stdint.h>
#include <kcgi.h>
#include <lua.h>
#include <sqlite3.h>
#define MAX_PARAMS 100
extern const int khttpd[KHTTP__MAX];
enum status { PUB, UNPUB, MOVED, GONE };
struct resource {
char *baseurl;
char *slug;
char *srcpath;
char *mime;
char *name;
enum status status;
char *content;
int size;
char *tmpl;
char *moved_to;
char *ctime;
char *mtime;
char **tags;
};
int sqlite_connect(sqlite3 **, char *, bool);
int sqlite_disconnect(sqlite3 *);
int prepare(sqlite3 *, sqlite3_stmt **, const char *, ...);
int execute(sqlite3 *, const char *, ...);
int fsbuild(char *dbpath, char *root);
int serve(char *dbpath);
bool match(lua_State *L, char *str, const char *pattern);
char *replace(lua_State *L, char *str, const char *pattern, const char *repl);
int load_resource(sqlite3 *db, struct resource *res, char *slug);
int render_resource(sqlite3 *db, struct resource *res, struct kreq *req,
enum khttp status);
void free_resource(struct resource *res);
struct bind_param {
int type;
int int_value;
double double_value;
char *char_value;
unsigned long size;
};
struct bind_param sqlite_bind(int type, int int_value, double double_value,
char *char_value, unsigned long size);