-
Notifications
You must be signed in to change notification settings - Fork 4
/
common.h
165 lines (135 loc) · 3.84 KB
/
common.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef ALAYA_COMMON_H
#define ALAYA_COMMON_H
#include "libUseful/libUseful.h"
#include "Settings.h"
#include <glob.h>
#include <sys/wait.h>
#include <pwd.h>
#include <fnmatch.h>
//Flag values for Session->Flags
#define SESSION_ENCODE_GZIP 1
#define SESSION_ENCODE_XGZIP 2
#define SESSION_OVERWRITE 8
#define SESSION_KEEPALIVE 16
#define SESSION_REUSE 32
#define SESSION_AUTHENTICATED 64
#define SESSION_SSL 128
#define SESSION_ICECAST 256
#define SESSION_ERR_BADURL 4096
#define SESSION_ALLOW_UPLOAD 8192
#define SESSION_UPLOAD_DONE 16384
#define ERR_OKAY 0
#define ERR_FILE 1
#define ERR_LOG 2
#define ERR_PRINT 4
#define ERR_EXIT 8
#define LOGGED_IN 1
#define LOGGED_OUT 2
#define LOGIN_FAIL 4
#define LOGIN_CHANGE 8
#define LOGIN_CHECK_ALLOWED 16
//Flag Values for Settings->DirListFlags
#define DIR_REJECT -1
#define DIR_SHOWFILES 1
#define DIR_INDEX_FILES 2
#define DIR_FANCY 4
#define DIR_INTERACTIVE 8
#define DIR_MIMEICONS 16
#define DIR_CENTER 32 //only used by FormatFancyIem
#define DIR_MEDIA_EXT 4096
#define DIR_IMAGE_EXT 8192
#define DIR_UPLOAD 65536
#define DIR_HASMEDIA 131072
#define DIR_SHOW_VPATHS 262144
#define DIR_TARBALLS 524288
//Flag values for the DropCapabilities function
#define CAPS_LEVEL_STARTUP 1
#define CAPS_LEVEL_NETBOUND 2
#define CAPS_LEVEL_CHROOTED 3
#define CAPS_LEVEL_SESSION 4
typedef enum {PATHTYPE_NONE, PATHTYPE_LOCAL, PATHTYPE_EXTFILE, PATHTYPE_CGI, PATHTYPE_WEBSOCKET, PATHTYPE_STREAM, PATHTYPE_LOGOUT, PATHTYPE_PROXY, PATHTYPE_REDIRECT, PATHTYPE_CALENDAR, PATHTYPE_MIMEICONS, PATHTYPE_FILETYPE, PATHTYPE_USERADMIN, PATHTYPE_URL, PATHTYPE_FILE, PATHTYPE_DIR} TPathTypes;
#define PATHITEM_EXEC 1
#define PATHITEM_READONLY 2
#define PATHITEM_NOAUTH 4
#define PATHITEM_COMPRESS 16
#define PATHITEM_NO_COMPRESS 32
typedef struct
{
int Type;
int Flags;
char *URL;
char *Path;
char *Name;
char *ContentType;
off_t Size;
unsigned int CacheTime;
char *User;
char *Password;
char *Group;
time_t Mtime;
char *OnUpload;
} TPathItem;
typedef struct
{
int Flags;
int AuthFlags;
char *Protocol;
char *Method;
int MethodID;
char *ResponseCode;
char *OriginalURL;
char *URL;
char *Path;
char *Arguments;
char *Cipher;
char *Destination;
char *ContentType;
char *ContentBoundary;
char *Cookies;
char *AuthDetails;
char *RemoteAuthenticate; //Used in proxy server mode
char *UserName;
char *Password;
char *AuthenticatedUser;
char *RealUser;
int RealUserUID;
char *Group;
gid_t GroupID;
char *StartDir;
char *HomeDir;
char *Host;
char *ClientIP;
char *ClientHost;
char *ClientMAC;
char *ClientReferrer;
char *UserAgent;
char *ServerName;
char *UserSettings;
char *SearchPath;
unsigned int ServerPort;
unsigned int ContentSize;
unsigned int CacheTime;
unsigned int Depth;
time_t LastModified;
time_t IfModifiedSince;
ListNode *Headers;
STREAM *S;
} HTTPSession;
extern char *Version;
HTTPSession *HTTPSessionCreate();
void HTTPSessionClear(void *);
void HTTPSessionDestroy(void *);
HTTPSession *HTTPSessionClone(HTTPSession *Src);
HTTPSession *HTTPSessionResponse(HTTPSession *Src);
char *HTTPSessionGetArg(char *RetStr, HTTPSession *Session, const char *Arg);
void SetTimezoneEnv();
void HandleError(int Flags, const char *FmtStr, ...);
TPathItem *PathItemCreate(int Type, const char *URL, const char *Path);
void PathItemDestroy(void *pi_ptr);
char *FormatURL(char *Buff, HTTPSession *Session, const char *ItemPath);
char *ParentDirectory(char *RetBuff, const char *Path);
char *SessionGetArgument(char *RetBuff, HTTPSession *Session, const char *ReqName);
int CopyURL(HTTPSession *Session, char *From, char *To);
char *FindScriptHandlerForScript(char *RetStr, const char *ScriptPath);
void DropCapabilities(int Level);
#endif