/* Package Name : twhttpd * File Name : config.h * Author : Sam NG * * This package is an secure HTTP application proxy writen by Sam Ng. * Copyright (C) 2001 SAM NG * * This program 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 2 * of the License, or 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #ifndef CONFIG_H #define CONFIG_H 1 /* default system config */ #define THIS_NAME "twhttpd" #define THIS_VERSION "1.01" #define CURRENT_DIR "./" #define DEFAULT_CACHE_DIR ".cache" #define DEFAULT_COOKIE_DIR ".cookie" #define DEFAULT_CONFIG_FILE "%%PREFIX%%/etc/twhttpd.cfg" #define SOCKET_TIMEOUT 45 /* socket timeout value */ #define CONNECT_TIMEOUT 15 /* connect timeout value */ #define LINGER_TIMEOUT 15 /* linger close timeout value */ #define SHUTDOWN_DELAY 15 /* delay close to receive tailing data */ /* extreme limits */ /* http header fields limits */ #define MAX_HEADER 8192 /* max size in each http request header */ #define MAX_HEADER_FIELDS 20 /* max no. of lines in a http request header */ #define MAX_HOST 64 /* max length for HOST name */ #define MAX_URL 256 /* max length for URL, does not include query string */ #define MAX_QUERY 512 /* max length for Query string */ #define MAX_SESSIONID 128 /* max length for SessionId in URL */ #define MAX_COOKIE 4096 /* max length for Cookie field, RFC standard */ #define MAX_AUTH 32 /* max length for WWW-Authentication */ #define MAX_ACCEPT 1024 /* max length for Accept* headers */ #define MAX_LINE 1024 /* max length for each line in http header */ #define MAX_STRING 256 /* max length for general string */ #define MAX_LOGURL 256 /* max lenght for URL in logging */ /* the different between MAX_LINE and MAX_STRNIG is * MAX_STRING is usually use on header fields with one or two words only * also noted no header fields other than COOKIE can be larger than MAX_LINE */ #if MAX_HOST - MAX_LINE > 0 || \ MAX_URL - MAX_LINE > 0 || \ MAX_QUERY - MAX_LINE > 0 || \ MAX_AUTH - MAX_LINE > 0 || \ MAX_ACCEPT - MAX_LINE > 0 || \ MAX_STRING - MAX_LINE > 0 #error MAX_STRING, MAX_URL, MAX_QUERY, MAX_AUTH, MAX_ACCEPT and MAX_STRING can not be larger than MAX_LINE #endif /* other string limits */ #define MAX_LINK 10 /* max file link for expand_link() */ #define MAX_FORK_FAIL 3 /* max fork fail count */ #define MAX_RAB 8192 /* read ahead buffer size */ #define MAX_LZB 1024 /* lazy write buffer size */ #define MAX_SC 256 /* max server config per each daemon */ /* buffer for error html */ #define MAX_ERROR 8192 /* only use in send_error */ /* not allowed meta chars */ #define PATH_META "|&<>%?;+#" /* these meta-chars are not allowed in URL path */ /* |&<> are shell program control, better not allow it */ /* % is hexcode keyword, you should not see this anyway */ /* ? is for query string */ /* ; is the sessionid */ /* + means space in query strnig */ /* # is the anchor part, but all anchor part has been removed in parse_get() */ /* *****************************************************************\ * if use agent does not issue if-mod-since, cache_timeout is used * * otherwise, cache_fast_timeout is used, even "pragam: no-cache" * * set DEFAULT_CACHE_FAST_TIMEOUT to 0 to disable this feature * \* *****************************************************************/ #define DEFAULT_CACHE_FAST_TIMEOUT (5*60) #define DEFAULT_CACHE_TIMEOUT (24*60*60) #if DEFAULT_CACHE_FAST_TIMEOUT - DEFAULT_CACHE_TIMEOUT > 0 #error DEFAULT_CACHE_FAST_TIMEOUT should be less than DEFAULT_CACHE_TIMEOUT #endif /* you seldom need to change these */ #define B64_CPL 19 /* Char per line in base64 en/decode */ #define HTTPS_PORT 443 /* only allow CONNECT on this port */ /* max and min functinos */ #define max(a, b) ( (a) > (b) ? (a) : (b) ) #define min(a, b) ( (a) < (b) ? (a) : (b) ) /* solaris 2.8 have inet_pton but not inet_aton, 2.6/2.7 dont have neither */ #if defined HAVE_INET_ATON # define str2addr(x, y) inet_aton(x, y) #elif defined HAVE_INET_PTON # define str2addr(x, y) inet_pton(AF_INET, x, y) #else int str2addr(char *x, struct in_addr *y) { y->s_addr = (in_addr_t)inet_addr(x); if ( (in_addr_t)-1 == y->s_addr ) return 0; else return 1; } #endif #endif /* CONFIG_H */