1 #ifndef TYPES_H
2 #define TYPES_H
3 
4 #include <sys/types.h>
5 
6 struct unlink_list {
7 	struct unlink_list *next;
8 	char *path;
9 };
10 
11 typedef struct {
12 	int code;
13 	char *type;
14 	unsigned int size, realsize;
15 	char *data;
16 } FILEBUF;
17 
18 struct HASH_LIST {
19 	struct HASH_LIST *next;
20 	time_t age;
21 	char *ref;
22 	void *data;
23 	int flags;
24 };
25 
26 typedef struct {
27 	int hit;
28 	int miss;
29 	int size;
30 	struct HASH_LIST **hash_list;
31 } HASH_TABLE;
32 
33 struct htmlstream_tag_property {
34 	struct htmlstream_tag_property *next, *prev;
35 	char *name;
36 	char *value;
37 };
38 
39 struct htmlstream_tag {
40 	char *name;
41 	struct htmlstream_tag_property *properties;
42 };
43 
44 struct htmlstream_node {
45 	struct htmlstream_node *down, *prev, *next, *up;
46 	int level;
47 	char *text;
48 	struct htmlstream_tag *tag;
49 };
50 
51 typedef struct {
52 	HASH_TABLE *callbacks;
53 	struct htmlstream_node *tree;
54 	struct htmlstream_node *tail;
55 	int startpos, incomment;
56 	FILEBUF *buffer;
57 } HTMLSTREAM;
58 
59 struct htmlstream_callback {
60 	void (*func)(HTMLSTREAM *, struct htmlstream_node *, void *);
61 	void *arg;
62 };
63 
64 typedef struct {
65 	int fd, frozen;
66 	int inbuf_len, outbuf_len;
67 	int inbuf_reallen, outbuf_reallen;
68 	void *inbuf, *outbuf;
69 } SOCKET;
70 
71 typedef struct {
72 	char *username;
73 	char *password;
74 	char *proto;
75 	char *host;
76 	char *file;
77 	int port;
78 } URL;
79 
80 struct url_command_t {
81 	char *command;
82 	char *options;
83 };
84 
85 typedef struct {
86 	pcre *pattern;
87 	pcre_extra *extra;
88 } regex_sub_t;
89 
90 typedef struct {
91 	int rm_so, rm_eo, subcount;
92 	const char **substrings;
93 } regmatch_sub_t;
94 
95 typedef struct XML_LIST_T {
96 	struct XML_LIST_T *prev, *next;
97 	int type;
98 	char *item;
99 } XML_LIST;
100 
101 typedef struct STACK_T {
102 	struct STACK_T *next, *prev;
103 	char *data;
104 } STACK;
105 
106 struct HTTP_HEADER_LIST {
107 	struct HTTP_HEADER_LIST *next, *prev;
108 	int send;
109 	char *type;
110 	char *value;
111 };
112 
113 struct LOGBUFFER_LIST {
114 	struct LOGBUFFER_LIST *next, *prev;
115 	char *msg;
116 };
117 
118 typedef struct {
119 	pthread_rwlock_t lock;
120 	int entries, size;
121 	struct LOGBUFFER_LIST *head, *tail;
122 } LOGBUFFER;
123 
124 typedef struct {
125 	char *raw;
126 	int type;
127 	int version;
128 	int port;
129 	int code;
130 	int content_length;
131 	int chunked;
132 	int keepalive;
133 	int proxy_keepalive;
134 	char *username;
135 	char *password;
136 	char *method;
137 	char *proto;
138 	char *host;
139 	char *file;
140 	char *referer;
141 	char *location;
142 	char *content_type;
143 	char *content_encoding;
144 	char *accept_encoding;
145 	char *authorization;
146 	char *range;
147 	char *proxy_authenticate;
148 	char *proxy_authorization;
149 	char *host_header;
150 	char *cache_control;
151 	char *expires;
152 	char *if_modified_since;
153 	char *last_modified;
154 	char *warning;
155 	char *age;
156 	char *x_cache;
157 	struct HTTP_HEADER_LIST *header;
158 	struct HTTP_HEADER_LIST *header_filtered;
159 	int flags;
160 } HEADER;
161 
162 struct cache_store {
163 	struct cache_store *prev, *next;
164 	int id, enabled;
165 	char *path, *comment;
166 	int journalfd, journalentries, diskentries;
167 	size_t disksize, maxdisksize, diskextra;
168 	char **profiles;
169 };
170 
171 typedef struct {
172 	pthread_cond_t writecompletecond;
173 	int id, fd;
174         char *key;
175         void *data;
176         int refcount;
177         size_t size, realsize;
178 	size_t offset;
179 	int flags;
180 	HEADER *header;
181 	struct cache_store *store;
182 	time_t atime, mtime, etime, ftime, lmtime;
183 } CACHEMAP;
184 
185 struct CACHEMAPLIST_T {
186         struct CACHEMAPLIST_T *prev, *next;
187         CACHEMAP *cachemap;
188 };
189 
190 typedef struct {
191 	pthread_mutex_t lock;
192 	int enabled, id;
193 	int violaterfc;
194 	int hashsize;
195 	int sbalancemethod;
196         unsigned int memsize;
197 	unsigned int maxmemsize;
198 	unsigned int memextra;
199 	unsigned int maxsize, minsize;
200 	unsigned int maxwaitsize;
201 	int maxage, minage;
202 	int validate;
203 	int lmfactor;
204 	int mementries;
205 	int hit, miss;
206 	int prefetchwindow;
207 	time_t lastclean;
208 	int icpport, icptimeout;
209 	struct cache_store *stores;
210         struct CACHEMAPLIST_T **cachemap;
211 } CACHE;
212 
213 
214 typedef struct {
215 	int status;
216 	int fd;
217 	int port;
218 	char *ip;
219 } SOCKLIST;
220 
221 typedef struct {
222 	int thread;
223 	int flags;
224 	SOCKET *client, *server;
225 	int depth;
226 	char *ip;
227 	int port;
228 	char *interface;
229 	int request;
230 	int keepalive_client, keepalive_server;
231 	int authenticate;
232 	size_t transferred, transferlimit;
233 	char *proxy_auth;
234 	char *proxy_host;
235 	int proxy_port;
236 	int proxy_type;
237 	char *proxy_username;
238 	char *proxy_password;
239 	char *proxy_domain;
240 	int access;
241 	int bypass;
242 	struct url_command_t **url_command;
243 	char **profiles;
244 	CACHEMAP *cachemap;
245 	HEADER *header, *rheader;
246 	HTMLSTREAM *htmlstream;
247 } CONNECTION;
248 
249 struct COOKIE_LIST_LIST {
250 	struct COOKIE_LIST_LIST *prev, *next;
251 	int id, enabled;
252 	int direction;
253 	char *comment;
254 	char **profiles;
255 };
256 
257 typedef struct {
258 	pthread_rwlock_t lock;
259 	int id, enabled;
260 	int policy;
261 	struct COOKIE_LIST_LIST *allow, *deny;
262 } COOKIE_LIST;
263 
264 struct FILTER_LIST_LIST {
265 	struct FILTER_LIST_LIST *prev, *next;
266 	int id, enabled;
267 	char *comment, *template, *host, *file;
268 	char **profiles;
269 	regex_t *he, *fe;
270 };
271 
272 typedef struct {
273 	pthread_rwlock_t lock;
274 	int id, enabled;
275 	int policy;
276 	char *dtemplate;
277 	struct FILTER_LIST_LIST *allow, *deny, *empty;
278 } FILTER_LIST;
279 
280 struct KEYWORD_LIST_LIST {
281 	struct KEYWORD_LIST_LIST *prev, *next;
282 	int id, enabled;
283 	int score;
284 	int size;
285 	char *comment, *mime, *keyword;
286 	regex_t *me, *ke;
287 	char **profiles;
288 };
289 
290 typedef struct {
291 	pthread_rwlock_t lock;
292 	int id, enabled;
293 	int threshold;
294 	char *template;
295 	struct KEYWORD_LIST_LIST *keyword_list;
296 } KEYWORD_LIST;
297 
298 struct REDIRECT_LIST_LIST {
299 	struct REDIRECT_LIST_LIST *prev, *next;
300 	int id, enabled;
301 	int which, port, send302, options;
302 	regex_sub_t *up;
303 	char *comment, *redirect, *url;
304 	char **profiles;
305 };
306 
307 typedef struct {
308 	pthread_rwlock_t lock;
309 	int id, enabled;
310 	struct REDIRECT_LIST_LIST *redirect_list;
311 } REDIRECT_LIST;
312 
313 struct FORWARD_LIST_LIST {
314 	struct FORWARD_LIST_LIST *prev, *next;
315 	int id, enabled;
316 	int which, port, type, icpport, icptype;
317 	char *comment, *proxy, *username, *password, *domain;
318 	char **profiles;
319 };
320 
321 typedef struct {
322 	pthread_rwlock_t lock;
323 	int id, enabled;
324 	struct FORWARD_LIST_LIST *forward_list;
325 } FORWARD_LIST;
326 
327 struct MIME_LIST_LIST {
328 	struct MIME_LIST_LIST *prev, *next;
329 	int id, enabled;
330 	char *comment, *template, *mime, *host, *file;
331 	char **profiles;
332 	regex_t *me, *he, *fe;
333 };
334 
335 typedef struct {
336 	pthread_rwlock_t lock;
337 	int id, enabled;
338 	int policy;
339 	char *dtemplate;
340 	struct MIME_LIST_LIST *allow, *deny, *empty;
341 } MIME_LIST;
342 
343 struct HEADER_LIST_LIST {
344 	struct HEADER_LIST_LIST *prev, *next;
345 	int id, enabled;
346 	char *comment, *type, *value;
347 	char **profiles;
348 	int which;
349 	regex_t *te, *ve;
350 };
351 
352 typedef struct {
353 	pthread_rwlock_t lock;
354 	int id, enabled;
355 	int policy;
356 	struct HEADER_LIST_LIST *allow, *deny, *insert;
357 } HEADER_LIST;
358 
359 struct ACCESS_LIST_LIST {
360 	struct ACCESS_LIST_LIST *prev, *next;
361 	int id, enabled;
362 	int pamauth;
363 	int access, bypass;
364 	char *comment, *ip, *username, *password;
365 	char **profiles;
366 	regex_t *ie, *ue;
367 };
368 
369 typedef struct {
370 	pthread_rwlock_t lock;
371 	int id;
372 	int policy;
373 	struct ACCESS_LIST_LIST *allow, *deny, *empty;
374 } ACCESS_LIST;
375 
376 typedef struct {
377 	pthread_rwlock_t lock;
378 	int id;
379 	struct LISTEN_LIST *listen_list;
380 } NETWORK;
381 
382 struct LISTEN_LIST {
383 	struct LISTEN_LIST *prev, *next;
384 	int id, enabled;
385 	int port;
386 	char *comment, *ip;
387 };
388 
389 struct TEMPLATE_LIST {
390 	struct TEMPLATE_LIST *prev, *next;
391 	int id, enabled;
392 	int type, code, parsable;
393 	char *comment, *name, *file, *mime;
394 	char **profiles;
395 };
396 
397 typedef struct {
398 	pthread_rwlock_t lock;
399 	int id;
400 	char *path;
401 	struct TEMPLATE_LIST *template_list;
402 } TEMPLATES;
403 
404 struct EXTERNAL_LIST_LIST {
405 	struct EXTERNAL_LIST_LIST *prev, *next;
406 	int id, enabled;
407 	regex_t *me;
408 	int type;
409 	int size;
410 	char *comment, *exec, *newmime, *mime;
411 	char **profiles;
412 };
413 
414 typedef struct {
415 	pthread_rwlock_t lock;
416 	int id, enabled;
417 	struct EXTERNAL_LIST_LIST *external_list;
418 } EXTERNAL;
419 
420 struct REWRITE_LIST_LIST {
421 	struct REWRITE_LIST_LIST *prev, *next;
422 	int id, enabled;
423 	int which;
424 	int size;
425 	regex_t *me;
426 	regex_sub_t *pe;
427 	char *comment, *pattern, *replace, *mime;
428 	char **profiles;
429 };
430 
431 typedef struct {
432 	pthread_rwlock_t lock;
433 	int id, enabled;
434 	struct REWRITE_LIST_LIST *rewrite;
435 } REWRITE_LIST;
436 
437 struct PROFILES_LIST_LIST {
438 	struct PROFILES_LIST_LIST *prev, *next;
439 	int id, enabled;
440 	regex_t *he, *fe;
441 	char *comment, *host, *file, *portrange;
442 	char **profiles, **addprofiles, **removeprofiles, **urlcommand;
443 };
444 
445 typedef struct {
446 	pthread_rwlock_t lock;
447 	int id;
448 	struct PROFILES_LIST_LIST *profiles;
449 } PROFILES_LIST;
450 
451 struct LIMITS_LIST_LIST {
452 	struct LIMITS_LIST_LIST *prev, *next;
453 	int action, id, enabled, flags;
454 	char **profiles;
455 	char *comment, *template;
456 	struct tm *from, *to;
457 	unsigned int maxrequests;
458 	size_t maxbytes;
459 	unsigned int n_requests;
460 	size_t n_bytes;
461 };
462 
463 typedef struct {
464 	pthread_rwlock_t lock;
465 	int id, enabled;
466 	struct LIMITS_LIST_LIST *limits_list;
467 } LIMITS_LIST;
468 
469 typedef struct {
470 	struct in_addr *addr;
471 	int len;
472 } HOSTENT;
473 
474 typedef struct {
475 	pthread_mutex_t lock;
476 	pthread_cond_t cond;
477 	void *arg;
478 	int flags, pid;
479 	int requests;
480 	char *ip, *host, *file, *method;
481 	int port;
482 } THREADLIST;
483 
484 struct cgi_args_t {
485 	struct cgi_args_t *next;
486 	char *name;
487 	char *value;
488 };
489 
490 typedef struct {
491 	pthread_rwlock_t lock;
492 	int ctimeout, timeout;
493 	int keeptimeout;
494 	int poolsize, pooltimeout;
495 	char *tempdir;
496 	int maxbuffer;
497 	int linelength;
498 	char *cportrange;
499 	int compressout, compressin;
500 	char *encodemime;
501 	regex_t *emp;
502 } GENERAL;
503 
504 typedef struct {
505 	pthread_rwlock_t lock;
506 	int pasv, timeout, sortorder, sortfield;
507 	char *anonlogin;
508 	char *anonpass;
509 } FTP;
510 
511 struct pool_t {
512 	struct pool_t *next, *prev;
513 	SOCKET *sock;
514 	time_t age;
515 	char *proto;
516 	char *host;
517 	char *username, *password;
518 	int port;
519 };
520 
521 typedef struct {
522 	int entries;
523 	pthread_mutex_t lock;
524 	struct pool_t *pool_list;
525 } POOL;
526 
527 typedef struct {
528 	pthread_rwlock_t lock;
529 	int enabled;
530 	char *template;
531 	char *domain;
532 	char **badips;
533 } DNSBL;
534 
535 struct TIMERS_LIST {
536 	struct TIMERS_LIST *prev, *next;
537 	int tid;
538 	int interval;
539 	time_t etime;
540 	int flags;
541 	void (*callback)(void *);
542 	void *arg;
543 };
544 
545 typedef struct {
546 	pthread_mutex_t lock;
547 	int tid;
548 	struct TIMERS_LIST *timers;
549 } TIMERS;
550 
551 struct PREFETCH_QUEUE {
552 	struct PREFETCH_QUEUE *next;
553 	int depth;
554 	URL *url;
555 };
556 
557 typedef struct {
558 	int enabled;
559 	pthread_mutex_t lock;
560 	pthread_cond_t cond;
561 	int threads, queuesize, entries, maxdepth;
562 	char **tags;
563 	struct PREFETCH_QUEUE *queue;
564 } PREFETCH;
565 
566 typedef struct {
567 	GENERAL *general;
568 	FTP *ftp;
569 	CACHE *cache;
570 	LOGBUFFER *logbuffer;
571 	HASH_TABLE *dns_cache;
572 	POOL *pool;
573 	TIMERS *timers;
574 	DNSBL *dnsbl;
575 	PREFETCH *prefetch;
576 	struct unlink_list *unlink_head, *unlink_tail;
577 	pthread_mutex_t unlink_lock;
578 	pthread_cond_t unlink_cond;
579 	pthread_mutex_t dns_cache_lock;
580 } GLOBAL;
581 
582 struct dir_t {
583 	struct dir_t *next, *prev;
584 	int isdir;
585 	mode_t mode;
586 	char *user;
587 	char *group;
588 	size_t size;
589 	struct tm time;
590 	time_t t;
591 	char *name;
592 };
593 
594 struct icp_packet {
595         unsigned char opcode;
596         unsigned char version;
597         uint16_t mlen;
598         uint32_t rnum;
599         uint32_t options;
600         uint32_t optiondata;
601         uint32_t hostaddr;
602         unsigned char payload[ICP_MESSAGE_MAX];
603 };
604 
605 struct proxy_candidate {
606 	struct proxy_candidate *prev, *next;
607 	unsigned int reqnum;
608 	struct icp_packet icppacket;
609 	struct FORWARD_LIST_LIST *proxy;
610 };
611 
612 #endif				/* TYPES_H */
613