forked from ltworf/weborf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
127 lines (103 loc) · 3.99 KB
/
types.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
/*
Weborf
Copyright (C) 2010-2018 Salvo "LtWorf" Tomaselli
Weborf 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, either version 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
@author Salvo "LtWorf" Tomaselli <[email protected]>
*/
#ifndef WEBORF_TYPES_H
#define WEBORF_TYPES_H
#include "options.h"
#include <stdbool.h> //Adds boolean type
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <netinet/in.h>
#ifdef HAVE_LIBSSL
#include <openssl/ssl.h>
typedef struct {
int fd;
SSL *ssl;
} fd_t;
#else
typedef int fd_t;
#endif
typedef struct {
long int id; //ID of the thread
} thread_prop_t;
typedef struct {
ssize_t len; //length of the array
char *data[MAXINDEXCOUNT]; //Array containing pointers
int data_l[MAXINDEXCOUNT]; //Array containing len of strings
} array_ll;
typedef struct {
int num, size; //Filled positions in the queue, and its maximum size
int head, tail; //pointers to head and tail of the round queue
int *data; //Socket with client
#ifdef IPV6
struct sockaddr_in6 *addr; //Local and remote address
#else
struct sockaddr_in *addr;
#endif
pthread_mutex_t mutex; //mutex to modify the queue
pthread_cond_t for_space, for_data;
int n_wait_sp, n_wait_dt;
} syn_queue_t;
typedef struct {
fd_t sock; //File and ssl descriptor for the socket
#ifdef IPV6
char ip_addr[INET6_ADDRSTRLEN]; //ip address in string format
#else
char ip_addr[INET_ADDRSTRLEN];
#endif
bool keep_alive; //True if we are using pipelining
short int protocol_version; //See defines like HTTP_something
int method_id; //Index of the http method used (GET, POST)
char *method; //String version of the http method used
char *http_param; //Param string
char *page; //Requested URI
ssize_t page_len; //Lengh of the page string
char *get_params; //Params in the URI, after the ? char
char *strfile; //File on filesystem
ssize_t strfile_len; //Length of string strfile
struct stat strfile_stat; //Stat of strfile
int strfile_fd; //File descriptor for strfile
char *basedir; //Basedir for the host
unsigned int status_code; //HTTP status code
} connection_t;
typedef struct {
ssize_t len; //length of the string
char *data; //Pointer to string
} string_t;
typedef struct {
pthread_mutex_t mutex; //Mutex to access this struct
unsigned int free; //Free threads
unsigned int count; //thread count
} t_thread_info;
typedef struct {
char *basedir;
char* authsock; //Executable that will authenticate
#ifdef SEND_MIMETYPES
bool send_content_type; //True if we want to send the content type
#endif
bool is_inetd; //True if it expects to be executed by inetd
array_ll cgi_paths; //Paths to cgi binaries
bool virtual_host; //True if must check for virtual hosts
bool exec_script; //Enable CGI if false
char *ip; //IP addr with default value
char *port; //port with default value
char *indexes[MAXINDEXCOUNT];//List of pointers to index files
int indexes_l; //Count of the list
#ifdef HAVE_LIBSSL
SSL_CTX *sslctx; //SSL context
#endif
} weborf_configuration_t;
#endif