Watt-32 tcp/ip  2.2 dev-rel.10
Enumerations | Functions | Variables
pcconfig.c File Reference

Go to the source code of this file.

Enumerations

enum  ParseMode {
  ModeKeyword = 0,
  ModeValue,
  ModeComment
}
 

Functions

static void deprecated_key (const char *old_key, const char *new_key)
 
static void W32_CALL keyword_not_found (const char *key, const char *value)
 This function eventually gets called if no keyword was matched. More...
 
 void (W32_CALL *usr_post_init)(void) = NULL
 Hook to a function called after we're initialised.
 
static const char * type_name (int type)
 
 FUNC_TO_W32CALL (ReadHostsFile)
 
static void set_ethip (const char *value)
 Add an "ether, IPv4-address" pair to the static ARP-cache. More...
 
void _add_server (WORD *counter, DWORD *array, int array_dim, DWORD value)
 
const char * expand_var_str (const char *str)
 Return a string with a environment variable expanded (only one). More...
 
const char * _w32_ExpandVarStr (const char *str)
 
static BOOL set_value (BOOL is_hex, const char *value, void *arg, int size)
 Parse and store ARG_ATOX_B, ARG_ATOX_W or ARG_ATOI value. More...
 
int W32_CALL parse_config_table (const struct config_table *tab, const char *section, const char *name, const char *value)
 Parse the config-table and if a match is found for ('section'+'. More...
 
static void set_my_ip (const char *value)
 
static void set_hostname (const char *value)
 
static void set_gateway (const char *value)
 
static void set_nameserv (const char *value)
 
static void set_cookie (const char *value)
 
static void set_eaddr (const char *value)
 Set new ether-address from "ether" value.
 
static void set_domain (const char *value)
 
static void depr_set_domain1 (const char *value)
 
static void depr_set_domain2 (const char *value)
 
static void do_print (const char *str)
 
static void depr_dns_timeout1 (const char *value)
 
static void depr_dns_timeout2 (const char *value)
 
static void depr_dns_recurse (const char *value)
 
static long do_include_file (const char *value, int len)
 Open and parse an include file. More...
 
const char * get_argv0 (void)
 Return argv[0] as passed to main().
 
static void set_recv_win (const char *value)
 
void W32_CALL tcp_set_debug_state (WORD val)
 Old comptibility function. More...
 
static void tcp_inject_config_direct (const struct config_table *cfg, const char *key, const char *value)
 Called from config-file parser after "key = value" is found. More...
 
void W32_CALL tcp_inject_config (const struct config_table *cfg, const char *key, const char *value)
 Callable from a user application to inject config values before the normal WATTCP.CFG is loaded and parsed. More...
 
long tcp_parse_file (WFILE f, const struct config_table *cfg)
 
int W32_CALL tcp_config_name (char *name, int max)
 
long W32_CALL tcp_config (const char *path)
 
int netdb_init (void)
 Called from most <netdb.h> functions in case watt_sock_init() wasn't called first to initialise things.
 
void netdb_warn (const char *fname)
 
static void W32_CALL not_found2 (const char *key, const char *value)
 
static long my_injector (int pass, const struct config_table *cfg)
 
void Usage (void)
 
static long filelength (int fd)
 
int main (int argc, char **argv)
 

Variables

int debug_on = 0
 
int ctrace_on = 0
 
int sock_delay = 30
 
int sock_inactive = 0
 
int sock_data_timeout = 0
 
WORD multihomes = 0
 
BOOL dynamic_host = 0
 
int stkwalk_details = 1
 
int fortify_fail_rate = 0
 
DWORD cookies [MAX_COOKIES]
 
WORD last_cookie = 0
 
static char * config_name = (char*) "WATTCP.CFG"
 
static char * current_file = NULL
 
static UINT current_line = 0
 
static BOOL got_eol = FALSE
 
static const char * environ_names []
 
static const struct config_table normal_cfg []
 
const struct config_tablewatt_init_cfg = normal_cfg
 
const char * cfg_file
 

Detailed Description

Watt-32 config file handling.

Definition in file pcconfig.c.

Function Documentation

static long do_include_file ( const char *  value,
int  len 
)
static

Open and parse an include file.

Syntax: "include = [?]<file>". If '?' prefix is used, the parser will not warn if the file isn't found.

Definition at line 613 of file pcconfig.c.

const char* expand_var_str ( const char *  str)

Return a string with a environment variable expanded (only one).

Never returns NULL.

E.g. if environment variable ETC is "c:\network\watt\bin", "$(ETC)\hosts" becomes "c:\network\watt\bin\hosts" If ETC isn't defined, "$(ETC)\hosts" becomes "\hosts".

Todo:
support several in one line and malloc the result.

Definition at line 231 of file pcconfig.c.

static void W32_CALL keyword_not_found ( const char *  key,
const char *  value 
)
static

This function eventually gets called if no keyword was matched.

Prints a warning (file+line) in debug-mode >= 2.

Definition at line 273 of file pcconfig.c.

int W32_CALL parse_config_table ( const struct config_table tab,
const char *  section,
const char *  name,
const char *  value 
)

Parse the config-table and if a match is found for ('section'+'.

'+)'name' either store variable to 'value' or call function with 'value'.

Definition at line 379 of file pcconfig.c.

References _strlcpy(), ARG_ATOB, ARG_ATOI, ARG_ATOIP, ARG_ATOW, ARG_ATOX_B, ARG_ATOX_D, ARG_ATOX_W, ARG_FUNC, ARG_RESOLVE, ARG_STRCPY, ARG_STRDUP, aton(), isaddr(), resolve(), set_value(), and void().

static void set_ethip ( const char *  value)
static

Add an "ether, IPv4-address" pair to the static ARP-cache.

Add an "ether, IPv6-address" pair to the static ND-cache.

Definition at line 170 of file pcconfig.c.

References _arp_cache_add(), _eth_real_addr, _inet6_addr(), _inet_addr(), and _inet_atoeth().

static BOOL set_value ( BOOL  is_hex,
const char *  value,
void arg,
int  size 
)
static

Parse and store ARG_ATOX_B, ARG_ATOX_W or ARG_ATOI value.

Accept "0x" or "x" prefix for ATOX types only. Accept ATOX values without a prefix too.

Definition at line 285 of file pcconfig.c.

References atox().

void W32_CALL tcp_inject_config ( const struct config_table cfg,
const char *  key,
const char *  value 
)

Callable from a user application to inject config values before the normal WATTCP.CFG is loaded and parsed.

See '_watt_user_config' in sock_ini.c.

Definition at line 893 of file pcconfig.c.

References strntrimcpy(), and tcp_inject_config_direct().

static void tcp_inject_config_direct ( const struct config_table cfg,
const char *  key,
const char *  value 
)
static

Called from config-file parser after "key = value" is found.

Take 'value' and possibly expand any in it. Pass key/value to config_table parser.

Definition at line 864 of file pcconfig.c.

References expand_var_str(), and parse_config_table().

void W32_CALL tcp_set_debug_state ( WORD  val)

Old comptibility function.

Callable from apps using Watt-32 only. Only allow apps to set a higher level than specified in cfg-file. Default: 'debug_on == 0'.

Definition at line 853 of file pcconfig.c.

Variable Documentation

const char* environ_names[]
static
Initial value:
= {
"WATTCP.CFG",
"WATTCP_CFG"
}

Definition at line 92 of file pcconfig.c.