-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolkit.h
71 lines (58 loc) · 2.08 KB
/
toolkit.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
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License. For a copy,
* see http://www.gnu.org/licenses/gpl-2.0.html.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _TOOLKIT_H
#define _TOOLKIT_H
#include <stdbool.h>
#include <regex.h>
#include "liblist.h"
#define UT_ERROR -1
#define UT_RETURN 0
#define UT_EXIT 1
#define UT_REDIRECT 301
#define UT_DENY_ACCESS 403
#define IU_EXISTS 0
#define IU_ISFILE 1
#define IU_ISDIR 2
typedef enum { tc_none, tc_match, tc_requesturi, tc_usessl } t_toolkit_condition;
typedef enum { to_none, to_rewrite, to_sub, to_expire, to_skip, to_denyaccess, to_redirect, to_fastcgi, to_ban } t_toolkit_operation;
typedef enum { tf_continue, tf_return, tf_exit } t_toolkit_flow;
typedef struct type_toolkit_rule {
t_toolkit_condition condition;
t_toolkit_operation operation;
t_toolkit_flow flow;
regex_t pattern;
int match_loop;
char *parameter;
int value;
t_toolkit_flow conditional_flow;
struct type_toolkit_rule *next;
} t_toolkit_rule;
typedef struct type_url_toolkit {
char *toolkit_id;
struct type_toolkit_rule *toolkit_rule;
struct type_url_toolkit *next;
} t_url_toolkit;
typedef struct type_toolkit_options {
int sub_depth;
char *new_url;
char *website_root;
char *fastcgi_server;
int ban;
int expire;
bool use_ssl;
t_url_toolkit *url_toolkit;
} t_toolkit_options;
t_url_toolkit *find_toolkit(char *toolkit_id, t_url_toolkit *url_toolkit);
bool toolkit_setting(char *key, char *value, t_url_toolkit *toolkit);
bool toolkit_rules_oke(t_url_toolkit *url_toolkit);
void init_toolkit_options(t_toolkit_options *options, char *website_root, t_url_toolkit *toolkit, bool use_ssl);
int use_toolkit(char *url, char *toolkit_id, t_toolkit_options *options);
#endif