1 /***************************************************************************/
2 /*    This code is part of WWW grabber called pavuk                        */
3 /*    Copyright (c) 1997 - 2001 Stefan Ondrejicka                          */
4 /*    Distributed under GPL 2 or later                                     */
5 /***************************************************************************/
6 
7 #ifndef _config_h_
8 #define _config_h_
9 
10 #include "../ac-config.h"
11 typedef DLLISTTYPE dllist_t;
12 
13 #define NeedFunctionPrototypes 1
14 
15 #ifdef NEED_DECLARE_H_ERRNO
16 extern int h_errno;
17 #endif
18 
19 #if !defined(HAVE_LONG_FILE_NAMES) && defined(__GNUC__)
20 #warning "This program can't run successfuly on machine without long filenames support"
21 #endif
22 
23 #include <time.h>
24 #include <fcntl.h>
25 #include <sys/types.h>
26 #include <netinet/in.h>
27 
28 #include <sys/time.h>
29 #include <unistd.h>
30 
31 #include "mode.h"
32 
33 #if defined(I_FACE) && !defined(HAVE_MT)
34 #define _Xt_Serve       gui_loop_serve()
35 #define _Xt_EscLoop     gui_loop_escape()
36 #define _Xt_ServeLoop   gui_loop_do()
37 #else
38 #define _Xt_Serve
39 #define _Xt_EscLoop
40 #define _Xt_ServeLoop
41 #endif
42 
43 #ifndef O_BINARY
44 #define O_BINARY 0
45 #endif
46 
47 #include <limits.h>
48 #ifndef PATH_MAX
49 #ifdef FILENAME_MAX
50 #define PATH_MAX FILENAME_MAX
51 #else
52 #define PATH_MAX        2048
53 #endif
54 #endif
55 
56 #ifndef NAME_MAX
57 #ifdef MAXNAMLEN
58 #define NAME_MAX MAXNAMLEN
59 #else
60 #define NAME_MAX 256
61 #endif
62 #endif
63 
64 /********************************************************/
65 /* the folowing is to workaround systems which defines  */
66 /* unreal limits on filenames                           */
67 /********************************************************/
68 #if defined(HAVE_LONG_FILE_NAMES) && NAME_MAX < 16
69 #undef NAME_MAX
70 #define NAME_MAX 256
71 #endif
72 
73 #if defined(HAVE_LONG_FILE_NAMES) && NAME_MAX < 1024
74 #undef PATH_MAX
75 #define PATH_MAX 2048
76 #endif
77 
78 #ifndef INT_MAX
79 #define INT_MAX         2147483647
80 #endif
81 #ifndef USHRT_MAX
82 #define USHRT_MAX       65535
83 #endif
84 
85 #ifdef HAVE_SOCKS_H
86 #include <socks.h>
87 #elif defined(SOCKS)
88 int SOCKSinit (char *);
89 #define connect         Rconnect
90 int Rconnect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
91 #define bind            Rbind
92 int Rbind(int  sockfd, struct sockaddr *my_addr, socklen_t addrlen);
93 #define accept          Raccept
94 int Raccept(int s, struct sockaddr *addr, socklen_t *addrlen);
95 #define listen          Rlisten
96 int Rlisten(int s, int backlog);
97 #define select          Rselect
98 int  Rselect(int  n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
99 #define gethostbyname   Rgethostbyname
100 struct hostent *Rgethostbyname(const char *name);
101 #define getsockname     Rgetsockname
102 int Rgetsockname(int s, struct sockaddr  *name, socklen_t *namelen);
103 #endif /* SOCKS */
104 
105 #include "mt.h"
106 #include "debugl.h"
107 #include "condition.h"
108 #include "nls.h"
109 #include "dllist.h"
110 #include "dlhash.h"
111 #include "http.h"
112 #include "dns.h"
113 
114 #define HASH_TBL_SIZE   233
115 
116 typedef enum
117 {
118   SSTRAT_DO_SIRKY,
119   SSTRAT_DO_SIRKY_I,
120   SSTRAT_DO_HLBKY,
121   SSTRAT_DO_HLBKY_I,
122   SSTRAT_LAST
123 } strategie;
124 
125 typedef struct
126 {
127 /*** CMDline parameters ***/
128   char *default_prefix;         /*** default prefix used in filename_to_url when nondefault tree layout is used ***/
129   char *info_dir;               /*** directory where are info files stored instead of regulary to -cdir ***/
130   char *urls_file;              /*** urls will be read from this file ***/
131   char *cookie_file;            /*** cookie file in NS format ***/
132   char *auth_file;              /*** file for authentification informations ***/
133   char *save_scn;               /*** name for scenario saving ***/
134   char *scndir;                 /*** directory where scenarios are stored ***/
135   char *scenario;               /*** scenario file to load ***/
136   char *subdir;                 /*** subdirectory of cache_dir to focus  ***/
137   char *cache_dir;              /*** dir where your local tree is located ***/
138   char *logfile;                /*** logging file ***/
139   char *short_logfile;          /*** newstyle log file name ***/
140   char *time_logfile;           /*** time log file name ***/
141   bool_t sdemo_mode;            /*** sdemo compaible output ***/
142   bool_t noencode;              /*** don't do RFC 2396 character escaping ***/
143   char *time_relative;          /*** what timings are relative to ***/
144   http_proxy *transparent_proxy;     /*** list of transparent proxy servers ***/
145   http_proxy *transparent_ssl_proxy; /*** list of transparent SSL proxy servers ***/
146   char *remind_cmd;             /*** command for reminding changed URLS ***/
147   char *sched_cmd;              /*** scheduling command ***/
148   char *post_cmd;               /*** command for post downloading processing of files ***/
149   char *stats_file;             /*** status file ***/
150 
151   long dumpfd;                  /*** number of filedescriptor for dumping documents ***/
152   long dump_urlfd;              /*** number of filedescriptor for dumping all URLs ***/
153   long hash_size;               /*** hash tables size ***/
154   long trans_quota;             /*** transfer quota ***/
155   long file_quota;              /*** file size quota ***/
156   long fs_quota;                /*** filesystem quota ***/
157   long bufsize;                 /*** size of read buffer ***/
158   long base_level;              /*** base tree level from which is built local file tree ***/
159   long nretry;                  /*** number of retries on error ***/
160   long nreget;                  /*** number of regets ***/
161   long nredir;                  /*** max number of redirections ***/
162   long ddays;                   /*** delay in days for document reload ***/
163   long rollback;                /*** size to go back when reget-ing ***/
164   long sleep;                   /*** sleeptime between transfers ***/
165   long cookies_max;             /*** maximal number of cookies ***/
166   long reschedh;                /*** number of hours for rescheduling ***/
167   double max_time;              /*** maximal time for run ***/
168   pavuk_mode mode;              /*** working mode ***/
169   struct tm *time;              /*** when to schedule execution time ***/
170   time_t schtime;               /*** cmdln param for scheduling time ***/
171   strategie scheduling_strategie;
172                                 /*** url downloading scheduling strategie ***/
173 
174   char *ftp_proxy_pass;         /*** password for access to FTP proxy ***/
175   char *ftp_proxy_user;         /*** username for access to FTP proxy ***/
176   char *http_proxy_pass;        /*** password for access to HTTP proxy ***/
177   char *http_proxy_user;        /*** username for access to HTTP proxy ***/
178   long proxy_auth_scheme;       /*** authorization scheme for proxy ***/
179   char *ftp_proxy;              /*** FTP proxy server ***/
180   long ftp_proxy_port;
181   bool_t ftp_via_http;          /*** gatewaying FTP through HTTP proxy ***/
182   bool_t ftp_dirtyp;            /*** dirty FTP proxying via CONNECT request to HTTP proxy ***/
183   long active_ftp_min_port;     /*** minimum port for active ftp ***/
184   long active_ftp_max_port;     /*** minimum port for active ftp ***/
185 
186   char *gopher_proxy;           /*** Gopher proxy ***/
187   long gopher_proxy_port;
188   bool_t gopher_via_http;       /*** gatewaying Gopher trough HTTP proxy ***/
189   char *name_auth;              /*** meno pouzivatela pri HTTP autentifikacii ***/
190   char *passwd_auth;            /*** password for HTTP authorization ***/
191   long auth_scheme;              /*** authorization scheme 1- user, 2- Basic, 3- Digest ***/
192 
193   bool_t rsleep;                /*** randomize sleep period up to -sleep ***/
194   bool_t hack_add_index;        /*** add also directories of all files to queue ***/
195   bool_t post_update;           /*** update in parent documents only curently downloaded URLs ***/
196   bool_t fix_wuftpd;            /*** use STAT -d to test existence of directory
197                                      when using LIST, because wuftpd does not raise
198                                      error when listing non existing directory ***/
199   bool_t retrieve_slink;        /*** retrieve symliks like regular files ***/
200   bool_t dump_resp;             /*** when -dumpfd is used, dump also HTTP response header ***/
201   bool_t dump_after;            /*** when -dumpfd is used, dump document just
202                                      after successfull download and after
203                                      processing of HTML documents ***/
204   bool_t xi_face;               /*** requested GUI interface ***/
205   bool_t singlepage;            /*** download single HTML page with all inline objecs ***/
206   bool_t unique_doc;            /*** always try to generate unique names for documents ***/
207   bool_t del_after;             /*** delete transfered files after successfull transfer ***/
208   bool_t use_http11;            /*** enable using of HTTP/1.1 protocol version ***/
209   bool_t gen_logname;           /*** generate nummbered log names when original locked ***/
210   bool_t send_if_range;         /*** send If-Range: header in HTTP request ***/
211   bool_t auto_referer;          /*** send own URL as referer with starting URLs ***/
212   bool_t referer;               /*** referer field for requests ***/
213   bool_t all_to_remote;         /*** change all links to remote and don't do any further changes to it ***/
214   bool_t sel_to_local;          /*** change links, which acomplish limits, to local immediately ***/
215   bool_t all_to_local;          /*** change all links to local immediately ***/
216   bool_t enable_info;           /*** enable using and creating info files ***/
217   bool_t enable_js;             /*** enable javascript ***/
218   bool_t bgmode;                /*** run at background ***/
219   bool_t store_index;           /*** store directory URLS as index files ***/
220   bool_t send_from;             /*** send From: header in request ***/
221   bool_t check_size;            /*** some broken HTTP servers send wrong Content-Length: header ***/
222   bool_t htdig;                 /*** to dump HTTP response - used by htDig ***/
223   bool_t send_cookies;          /*** send available cookies in HTTP request ***/
224   bool_t recv_cookies;          /*** receive cookie infos ***/
225   bool_t update_cookies;        /*** update cookie file ***/
226   bool_t cookie_check_domain;   /*** check if server sets cookie for own domain ***/
227   bool_t preserve_time;         /*** preserve time of remote document ***/
228   bool_t preserve_perm;         /*** preserve permisions of remote document ***/
229   bool_t preserve_links;        /*** preserve absolute symlinks ***/
230   bool_t quiet;                 /*** ? output messages ***/
231   bool_t auth_reuse_nonce;      /*** reuse HTTP Digest authorization nonce ***/
232   bool_t auth_reuse_proxy_nonce;/*** reuse HTTP proxy Digest authorization nonce ***/
233   bool_t show_time;             /*** show start and end time of download ? */
234   bool_t remove_old;            /*** remove old documents (when not occurrs on remote site) ***/
235   bool_t remove_before_store;   /*** pro: remove document before storing it ***/
236   bool_t always_mdtm;           /*** always use MDTM: no cached values ***/
237   bool_t progres;               /*** show retrieving progres , when on console ***/
238   bool_t ftp_activec;           /*** use active FTP data connection instead of passive ***/
239   bool_t ftp_list;              /*** retrieve FTP directory with LIST cmd insted of NLST ***/
240   bool_t ftp_html;              /*** process HTML files downloaded over FTP protocol ***/
241   bool_t cache;                 /*** disallow caching of HTTP documents (on proxy cache) ***/
242   bool_t rewrite_links;         /*** indikacia ci ma maju byt odkazy v HTML dokumentoch prepisovane ***/
243   bool_t freget;                /*** force reget whole file when server doesn't support reget ***/
244   bool_t use_enc;               /*** indikacia ci sa ma pouzivat gzip/compress kodovanie pri prenose ***/
245   bool_t read_css;              /*** fetch objects refed in css ***/
246   char *ftp_list_options;       /*** aditional options to FTP LIST/NLST commands ***/
247   char *auth_ntlm_domain;       /*** domain name for NTLM authorization ***/
248   char *auth_proxy_ntlm_domain; /*** domain name for NTLM proxy authorization ***/
249   char *local_ip;               /*** address for local network interface ***/
250   char *index_name;             /*** name of directory index file instead of _._.html ***/
251   char *store_name;             /*** filename of document transfered with -mode singlepage ***/
252   char *from;                   /*** HTTP request field From: or anonymous FTP password ***/
253   char *identity;               /*** User-agent: field contents ***/
254   char **accept_lang;           /*** list of preffered languages ***/
255   char **accept_chars;          /*** list of preffered character sets ***/
256   char **cookies_disabled_domains;
257                                 /*** domains from which cookies are not acceptable ***/
258   char **dont_touch_url_pattern;/*** to allow preserve some URLs in the original form ***/
259 
260   cond condition;               /*** structure which contains all limiting conditions ***/
261   dllist *request;              /*** list of urls entered by user ***/
262   dllist *formdata;             /*** data for forms found during document tree traversing ***/
263   dllist *lfnames;              /*** list of filename conversion rules ***/
264   dllist *http_headers;         /*** list of additional HTTP headers ***/
265   dllist *http_proxy;           /*** list of HTTP proxy servers ***/
266   dllist *ftp_login_hs;         /*** list for -ftp_login_handshake ***/
267 
268   char *tr_del_chr;             /*** set of characters to delete while doing name transformation ***/
269   char *tr_str_s1;              /*** strfrom in transformation ***/
270   char *tr_str_s2;              /*** strto in transformation ***/
271   char *tr_chr_s1;              /*** setfrom in transformation ***/
272   char *tr_chr_s2;              /*** setto in transformation ***/
273 
274   double maxrate;               /*** maximal transfer rate ***/
275   double minrate;               /*** minimal transfer rate ***/
276   double ctimeout;              /*** timeout for network communication ***/
277 
278 #ifdef HAVE_MOZJS
279   char *js_script_file;         /*** file which contains JavaScript script with functions declarations ***/
280 #endif
281 
282 #ifdef HAVE_BDB_18x
283   char *ns_cache_dir;           /*** directory for Netscape cache ***/
284 #endif
285   char *moz_cache_dir;          /*** directory for Mozilla cache ***/
286 
287 #ifdef HAVE_MT
288   long nthr;                    /*** configured number of running threads ***/
289   bool_t immessages;            /*** print messages immediatly when produced not just when it is safe ***/
290 #endif
291 
292 #ifdef __CYGWIN__
293   bool_t ie_cache;              /*** possibily load files from MSIE cache directory */
294   bool_t wait_on_exit;          /*** this option is for WIN32 CLI version ***/
295 #endif
296 
297 #ifdef HAVE_TERMIOS
298   bool_t tccheck;               /*** checking of we are at foreground ***/
299 #endif
300 
301 #ifdef HAVE_REGEX
302   dllist *js_patterns;          /*** matching patterns for JS URLs ***/
303   dllist *js_transform;         /*** matching patterns for JS with transform **/
304   dllist *advert_res;           /*** list of RE-s for advertisement banners ***/
305   bool_t remove_adv;            /*** enable / disable advertisement banners ***/
306 
307   dllist *dont_touch_url_rpattern;
308   dllist *dont_touch_tag_rpattern;
309                                 /*** to allow preserve some URLs in the original form ***/
310 #endif
311 
312 #ifdef DEBUG
313   bool_t debug;                 /*** debug mode on/off ***/
314   long debug_level;             /*** debug level ***/
315 #endif
316 
317 #ifdef USE_SSL
318   long ssl_version;             /*** ssl2/ssl3/ssl23/tls1 version of ssl_client_method() ***/
319   char *ssl_proxy;              /*** SSL tuneling proxy ***/
320   long ssl_proxy_port;
321   char *ssl_cipher_list;
322   char *ssl_cert_passwd;
323   bool_t unique_sslid;          /*** use unique SSL IDs with each SSL connection ***/
324 #ifdef USE_SSL_IMPL_OPENSSL
325   char *ssl_cert_file;
326   char *ssl_key_file;
327   char *egd_socket;             /*** path to EGD socket ***/
328 #endif
329 #ifdef USE_SSL_IMPL_NSS
330   char *nss_cert_dir;           /*** certDir for Netscape NSS ***/
331   bool_t nss_accept_unknown_cert;        /*** don't care much about certificates ***/
332   bool_t nss_domestic_policy;
333 #endif
334 #endif
335 
336   char *language;               /*** language for LC_MESSAGES ***/
337 
338 #ifdef GETTEXT_NLS
339   char *msgcatd;                /*** explicit message catalog directory ***/
340 #endif
341 
342 #ifdef I_FACE
343   char *fontname;               /*** default font used in interface ***/
344   long xlogsize;                /*** max number of lines in LOG widget ***/
345   bool_t log_autoscroll;        /*** autoscroll of log window ***/
346   bool_t run_iface;             /*** if immediately run download after start of pavuk in GUI interface ***/
347   bool_t use_prefs;             /*** store & load prefernces from ~/.pavuk_prefs file ***/
348 
349                                 /*** alternative icons for GUI ***/
350   char *bt_icon_cfg;
351   char *bt_icon_cfg_s;
352   char *bt_icon_lim;
353   char *bt_icon_lim_s;
354   char *bt_icon_gobg;
355   char *bt_icon_gobg_s;
356   char *bt_icon_rest;
357   char *bt_icon_rest_s;
358   char *bt_icon_cont;
359   char *bt_icon_cont_s;
360   char *bt_icon_stop;
361   char *bt_icon_stop_s;
362   char *bt_icon_brk;
363   char *bt_icon_brk_s;
364   char *bt_icon_exit;
365   char *bt_icon_exit_s;
366   char *bt_icon_mtb;
367   char *bt_icon_mtb_s;
368 
369 #ifdef WITH_TREE
370   char *browser;                /*** command to execute your preffered browser ***/
371 #endif
372 #endif
373 
374 /*** GLOBALdata ***/
375   abs_addr local_ip_addr;       /*** numeric address for local network interface ***/
376   time_t start_time;            /*** start time of downloading ***/
377   struct timeval hr_start_time; /*** high-resolution start time of downloading ***/
378   long trans_size;              /*** transfered size in session ***/
379   char *path_to_home;
380   char *local_host;             /*** hostname of local machine ***/
381   long fail_cnt;                /*** counter for failed transfers ---> return code of pavuk ***/
382   char *prg_path;               /*** path to pavuk executable == argv[0] ***/
383   char *install_path;           /*** pavuk install path especialy used in win32 version ***/
384   long total_cnt;               /*** total number of URLs in queue  ***/
385   long process_cnt;             /*** number of already processed documents ***/
386   long reject_cnt;              /*** number of rejected URLs ***/
387   pavuk_mode prev_mode;         /*** previous active mode ***/
388   bool_t mode_started;          /*** mode startup finisched ***/
389   bool_t rbreak;                /*** immediately stop transfer ***/
390   bool_t stop;                  /*** stop after this document will be processed ***/
391 
392   dllist *urlstack;             /*** list of URLs in processing queue ***/
393   dllist *urls_in_dir;          /*** list of URLs extracted from mirroring
394                                      directory, for checking for nonexistent
395                                      document removal ***/
396   dlhash *url_hash_tbl;         /*** hash table for better performance URL lookup ***/
397   dlhash *fn_hash_tbl;          /*** hash table for better performance filename lookup ***/
398   dllist *last_used_proxy_node; /*** pointer to last used proxy node ***/
399   long docnr;                   /*** current number of document ***/
400 
401 #ifdef HAVE_MT
402   time_t timestamp;
403   time_t cfg_changed;           /*** timestamp for cfg struct last change ***/
404   pthread_key_t currdoc_key;
405   pthread_key_t herrno_key;
406   pthread_key_t thrnr_key;
407   pthread_key_t privcfg_key;
408   mt_semaphore nrunning_sem;
409   mt_semaphore urlstack_sem;
410   pthread_t mainthread;
411   pthread_t *allthreads;
412   long allthreadsnr;
413 #endif
414 
415 #ifdef I_FACE
416   bool_t done;                  /*** was done startup ? ***/
417   bool_t processing;            /*** some URL is actualy in processing ***/
418 #endif
419 } _config_struct_t;
420 
421 extern _config_struct_t cfg;
422 
423 #if defined(HAVE_MT) && defined(I_FACE)
424 
425 #if 0
426 /********************************************************************/
427 /* this structure contains corresponding field form _config_struct  */
428 /* structure. when I don't want to use mutex(es) for locking of     */
429 /* config structure when running multiple downloading threads, I    */
430 /* I have to make copy of dynamicaly created config parameters to   */
431 /* prevent segfaults when changing configuration from GUI           */
432 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
433 /* !!!!!!!!!! Not realy used, only to know which fields !!!!!!!!!!! */
434 /* !!!!!!!!!! are used from private copy                !!!!!!!!!!! */
435 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
436 /********************************************************************/
437 typedef struct
438 {
439   time_t timestamp;
440   char *default_prefix;
441   char *info_dir;
442   char *subdir;
443   char *cache_dir;
444   char *post_cmd;
445   char *http_proxy_pass;
446   char *http_proxy_user;
447   char *ftp_proxy_pass;
448   char *ftp_proxy_user;
449   char *ftp_proxy;
450   char *gopher_proxy;
451   char *name_auth;
452   char *passwd_auth;
453   char *index_name;
454   char *store_name;
455   char *from;
456   char *identity;
457   char *auth_ntlm_domain;
458   char *auth_proxy_ntlm_domain;
459   char *ftp_list_options;
460 
461   char **accept_lang;
462   char **accept_chars;
463   char **cookies_disabled_domains;
464   char **dont_touch_url_pattern;
465 
466   cond condition;
467   dllist *formdata;
468   dllist *lfnames;
469   dllist *http_headers;
470   dllist *js_patterns;
471   dllist *js_transform;
472   dllist *ftp_login_hs;
473 
474   char *tr_del_chr;
475   char *tr_str_s1;
476   char *tr_str_s2;
477   char *tr_chr_s1;
478   char *tr_chr_s2;
479 
480 #ifdef HAVE_REGEX
481   dllist *advert_res;
482   dllist *js_patterns;
483   dllist *js_transform;
484   dllist *dont_touch_url_rpattern;
485   dllist *dont_touch_tag_rpattern;
486 #endif
487 
488 #ifdef HAVE_MOZJS
489   char *js_script_file;
490 #endif
491 
492 #ifdef HAVE_BDB_18x
493   char *ns_cache_dir;
494   char *moz_cache_dir;
495 #endif
496 
497 #ifdef USE_SSL
498   char *ssl_proxy;
499   char *ssl_cipher_list;
500   char *ssl_cert_file;
501   char *ssl_key_file;
502   char *ssl_cert_passwd;
503   char *egd_socket;
504 #endif
505 } _config_struct_priv_t;
506 #endif /* 0 */
507 
508 #define _config_struct_priv_t _config_struct_t
509 
510 extern void privcfg_make_copy(_config_struct_priv_t *);
511 extern void privcfg_free(_config_struct_priv_t *);
512 
513 #define priv_cfg (*((_config_struct_priv_t *)pthread_getspecific(cfg.privcfg_key)))
514 #define _MT_CFGSTAMP    cfg.cfg_changed = time(NULL)
515 #else
516 #define priv_cfg cfg
517 #define _MT_CFGSTAMP
518 #endif
519 
520 typedef enum
521 {
522   PARAM_NUM,                    /* integer number                       */
523   PARAM_PBOOL,                  /* positive bool_tean                   */
524   PARAM_NBOOL,                  /* negative bool_tean                   */
525   PARAM_STR,                    /* single string                        */
526   PARAM_PASS,                   /* password string                      */
527   PARAM_STRLIST,                /* comma separated list of strings      */
528   PARAM_CONN,                   /* connection - host[:port]             */
529   PARAM_AUTHSCH,                /* authorization scheme - 1/2/3         */
530   PARAM_MODE,                   /* operation mode - mode.c              */
531   PARAM_PATH,                   /* file/dir path                        */
532   PARAM_TIME,                   /* time string - YYYY.MM.DD.HH:mm       */
533   PARAM_HTMLTAG,                /* HTML tags specification              */
534   PARAM_TWO_QSTR,               /* two quoted strings                   */
535   PARAM_DOUBLE,                 /* double number                        */
536   PARAM_LFNAME,                 /* for -fnrules option                  */
537   PARAM_RE,                     /* list of regular expressions          */
538   PARAM_USTRAT,                 /* url strategie - -strategie           */
539   PARAM_SSLVER,                 /* ssl version - ssl23/ssl2/ssl3/tls1   */
540   PARAM_HTTPHDR,                /* additional HTTP header               */
541   PARAM_DEBUGL,                 /* debug level - debugl.c               */
542   PARAM_REQUEST,                /* extended request specification       */
543   PARAM_PROXY,                  /* proxy specification - host:port      */
544   PARAM_TRANSPARENT,            /* proxy specification - host:port      */
545   PARAM_FUNC,                   /* exec function for this param type    */
546   PARAM_JSTRANS,                /* for -js_transform option             */
547   PARAM_NUMLIST,                /* list of integer numbers -[ad]port    */
548   PARAM_FTPHS,                  /* for FTP -ftp_login_handshake         */
549   PARAM_TAGPAT,                 /* for HTML tag patterns                */
550   PARAM_PORT_RANGE              /* for TCP/IP port ranges               */
551 } par_type_t;
552 
553 /* this is to support parameters of foreign libraries (like gtk) */
554 #define PARAM_FOREIGN           (1 << 29)
555 
556 /* this is for marking option as unsupported in current compile time    */
557 /* configuration. This will allow to accept unsupported option on       */
558 /* commandline just throwing warning insted of trowing error and exit.  */
559 #define PARAM_UNSUPPORTED       (1 << 30)
560 
561 
562 typedef struct _cfg_param
563 {
564   char *short_cmd;
565   char *long_cmd;
566   char *par_entry;
567   par_type_t type;
568   void *default_val;
569   void *val_adr;
570   void *mdefault_val;
571   void *mval_adr;
572   char *help;
573 } cfg_param_t;
574 
575 extern char *get_strategie_label(strategie);
576 extern void usage(void);
577 extern void usage_short(void);
578 extern void cfg_setup_default(void);
579 extern void cfg_set_all_to_default(void);
580 extern void cfg_setup_cmdln(int, char **);
581 extern int cfg_load(const char *);
582 extern void cfg_load_setup(void);
583 extern int cfg_dump(const char *);
584 extern int cfg_dump_cmd(const char *);
585 extern int cfg_dump_cmd_fd(int);
586 extern void cfg_free_params(void);
587 extern int cfg_dump_pref(void);
588 extern int cfg_load_pref(void);
589 extern int cfg_get_num_params(cfg_param_t *);
590 
591 extern void pavuk_do_at_exit(void);
592 
593 #define PAVUK_EXIT_OK           0       /* everything goes as expected  */
594 #define PAVUK_EXIT_CFG_ERR      1       /* configuration error          */
595 #define PAVUK_EXIT_DOC_ERR      2       /* some of documents failed     */
596 
597 #endif
598