blob: 13d0d305805dfa203c3fccb2d25a30c8c65cb9da (
plain)
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
|
#include <sqlite3.h>
/***** Types *****/
enum method{
GET,
POST
};
struct att{
int id;
int post;
int bytes; /* Size of data. */
char *name;
char *desc;
char *mime;
char *data;
};
struct post{
int id;
int parent;
int user;
int created;
int edited;
char *subject;
char *text;
};
struct user{
int id;
int created;
char *name;
char *full;
char *hash;
};
struct query{
int method;
int length; /* Content length. */
char *string;
};
struct site{
char *name;
};
/***** Functions *****/
/* ctl.c */
void newatt(void);
void newpost(void);
void newuser(void);
void showatt(int);
void showfront(void);
void showpost(int);
void showuser(int);
/* db.c */
int addatt(struct att *);
int adduser(struct user *);
struct att *getatt(sqlite3_stmt *);
struct post *getpost(sqlite3_stmt *);
struct user *getuser(sqlite3_stmt *);
struct att *nextatt(sqlite3_stmt *);
struct post *nextpost(sqlite3_stmt *);
struct user *nextuser(sqlite3_stmt *);
sqlite3_stmt *selectbyint(char *, char *, int);
/* err.c */
void srverr(char *);
/* query.c */
char *nextparam(enum method, int *, int);
void setquery(void);
char *split(char *);
int urldecode(char *, int);
/***** Definitions *****/
#define TRUNCATED(s) s[-1]
/* Maximum allowed Content-Length for various forms. */
#define MAXATTDATA 4096
#define MAXUSERDATA 512
#define MAXPOSTDATA 4096
/* Maximum size of user information, incl. NUL. */
#define MAXUSERNAME 40
#define MAXUSERFULL 128
#define MAXUSERPASS 128
/***** Variables *****/
sqlite3 *db;
struct query query;
struct site site;
|