-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig_unit.hpp
149 lines (95 loc) · 2.99 KB
/
Config_unit.hpp
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef CONFIG_UNIT_H
#define CONFIG_UNIT_H
#include <string>
#include <map>
#include <list>
#include <cstring>
#include <sstream>
#include <iostream> //delete
struct listen_unit {
std::string str;
unsigned char digit[4];
char type;
int port;
listen_unit &operator=(listen_unit const &);
};
struct location_unit {
std::string _abs_path;
std::string _def_file;
std::list<std::string> _methods;
std::string _storage;
size_t _body_size;
int _autoindex;
std::pair<int, \
std::string> _redirect;
location_unit &operator=(location_unit const &);
};
class config_unit {
std::list<std::string> _name;
std::map<std::string, \
location_unit> _location;
std::list\
<listen_unit> _listen;
std::list<std::string> _methods;
int _error;
std::string _cgi_loc;
std::string _def_file;
std::string _storage;
size_t _max_client_body;
std::map<int,
std::string> _err_location;
int _autoindex;
int _workers;
bool _pathComp(char const *, char const *);
std::map<std::string, location_unit>::iterator _getLocation(std::string
const &);
std::string _python_path;
std::string _php_path;
public:
std::list<std::string> &setName(void);
std::map<std::string, \
location_unit> &setLocation(void);
std::list<listen_unit> &setListen(void);
std::list<std::string> &setMethods(void);
int &setError(void);
std::string &setCGI_loc(void);
std::string &setStorage_loc(void);
size_t &setMax_client_body(void);
std::map<int, std::string> &setErr_location(void);
int &setAutoindex(void);
config_unit &operator=(config_unit const &);
void setWorkers(int);
void resort(void);
void setDefaultFile(std::string const &);
void setFileStorage(std::string const &);
config_unit(void);
~config_unit(void);
std::list<std::string> const &getName(void) const;
std::map<std::string, \
location_unit> const &getLocation(void) const;
std::list<listen_unit> const &getListen(void) const;
std::list<std::string> const &getMethods(void) const;
int getError(void) const;
std::string const &getCGI_loc(void) const;
size_t getMax_client_body(std::string const &);
std::map<int, std::string> const &getErr_location(void) const;
int getAutoindex(void) const;
int getWorkers(void) const;
std::string const searchError_page(int);
bool checkMethod(std::string\
const &method, std::string const &path);
std::string const &getDefaultFile(void);
std::string getServerPath(std::string const &);
std::string getPathFromLocation(std::string const &);
int checkAutoindex(std::string const &);
bool checkRedirect(std::string const &);
std::pair<int, std::string> getRedirectPath(std::string\
const &);
std::string getCGI_Path(std::string const &);
std::string getUploadPath(std::string const &);
void setPythonExec(std::string const &str);
void setPHPexec(std::string const &str);
std::string const &getPythonExec(void);
std::string const &getPHPexec(void);
};
#endif