1 /*
2  *
3  *  C++ Portable Types Library (PTypes)
4  *  Version 2.1.1  Released 27-Jun-2007
5  *
6  *  Copyright (C) 2001-2007 Hovik Melikyan
7  *
8  *  http://www.melikyan.com/ptypes/
9  *
10  */
11 
12 #ifndef W_CONFIG_H
13 #define W_CONFIG_H
14 
15 
16 #include <ptypes.h>
17 
18 
19 USING_PTYPES
20 
21 
22 // things that can hardly change
23 
24 #define MAX_TOKEN               4096
25 #define MAX_REQUEST_URI         4096
26 #define FILE_BUF_SIZE		4096
27 #define SOCKET_BUF_SIZE         2048
28 #define DEF_HTTP_PORT           80
29 #define DEF_KEEP_ALIVE_TIMEOUT  15000
30 #define DEF_MAX_CLIENTS         30
31 
32 
33 // we no longer use strftime for HTTP time stamps, since it may
34 // depend on the system locale. now we build the time stamp
35 // `manually' instead
36 // #define HTTP_DATE_FMT           "%a, %d %b %Y %H:%M:%S GMT"
37 
38 
39 // built-in configuration
40 
41 extern const char*   SERVER_APP_NAME;   // "wshare/1.2 (system)"
42 extern const char*   DEF_MIME_TYPE;     // "text/plain" for files with no extension
43 // not implemented: extern const char*   DEF_BINARY_TYPE;   // "application/octet-stream" for unix binaries
44 extern const char*   STD_CSS;           // CSS for built-in responses, such like 404 Not found
45 
46 extern const char*   cfg_index_files[]; // index.html, Index.html and default.htm
47 extern const char*   mimetypes[];       // built-in MIME types and extensions (in mimetable.cxx)
48 
49 
50 // configurable parameters
51 
52 extern string  cfg_document_root;       // no default, must be specified through cmdline
53 extern string  cfg_server_name;         // default is my nodename
54 extern int     cfg_port;                // 80
55 extern bool    cfg_dir_indexes;         // allow directory indexes
56 extern bool    cfg_def_index_files;     // use default index files index.html, ...
57 extern string  cfg_log_file;            // access log file name
58 extern bool    cfg_log_referer;         // include referer in log
59 extern bool    cfg_file_mtime;          // send `last-modified' for html files
60 extern int     cfg_max_clients;         // max number of simultaneous connections, default 30
61 extern int     cfg_max_keep_alive;      // max keep-alive clients, currently 2/3 of max_clients
62 
63 extern bool    cfg_syslog;              // write the log to stderr or to Unix syslog
64 extern string  cfg_user;                // user name to run as on Unix
65 extern string  cfg_group;               // group name to run as on Unix
66 extern bool    cfg_daemonize;           // daemonize on Unix
67 
68 extern char*   myname;                  // "wshare", for syslog
69 
70 
71 void config_init(int argc, char* argv[]);
72 void config_done();
73 
74 
75 #ifdef _MSC_VER
76 // we don't want "conditional expression is constant" warning
77 #  pragma warning (disable: 4127)
78 #endif
79 
80 
81 #endif
82