-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
88 lines (66 loc) · 1.7 KB
/
config.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
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
//
// Created by 孙庆耀 on 2018/7/10.
//
#ifndef KERNOD_CONFIG_H
#define KERNOD_CONFIG_H
#include <sys/types.h> /* size_t, ssize_t */
#include <stdarg.h> /* va_list */
#include <stddef.h> /* NULL */
#include <stdint.h> /* int64_t */
#include <kcgi.h>
#include <sodium.h>
#include <stdbool.h>
#define KERNOD_REDIS_HOSTNAME "127.0.0.1"
#define KERNOD_REDIS_PORT 6379
#define KERNOD_PWHASH_OPSLIMIT crypto_pwhash_OPSLIMIT_MODERATE
#define KERNOD_PWHASH_MEMLIMIT crypto_pwhash_MEMLIMIT_MODERATE
/* Expiration time for sort-term session management cookies in seconds;
* DO NOT use a large value
*/
#define KERNOD_SESSION_EXPIRE_SECONDS 3600LLU
#define KERNOD_PAGINATION_PER_PAGE 20
enum page {
PAGE_INDEX,
PAGE_LOGIN,
PAGE_REGISTER,
PAGE_POSTS,
PAGE__MAX
};
static const char *const pages[PAGE__MAX] = {
"index",
"login",
"register",
"posts",
};
static const bool require_login[PAGE__MAX] = {
false,
false,
false,
false
};
enum key_and_cookie {
/* form inputs */
KEY_USERNAME,
KEY_EMAIL,
KEY_PASSWORD,
KEY_PASSWORD2,
KEY_REMEMBER_ME,
KEY_PAGE,
/* cookies */
COOKIE_SESSION_ID,
COOKIE_PER_PAGE,
KEY_AND_COOKIE__MAX
};
static const struct kvalid key_and_cookies[KEY_AND_COOKIE__MAX] = {
/* form inputs */
{kvalid_stringne, "username"},
{kvalid_email, "email"},
{kvalid_stringne, "password"},
{kvalid_stringne, "password2"},
{kvalid_stringne, "remember-me"},
{kvalid_uint, "page"},
/* cookies */
{kvalid_stringne, "session_id"},
{kvalid_uint, "per-page"},
};
#endif //KERNOD_CONFIG_H