$Revision: 1.8 $
Constants module (co) - this _should_ eventually get merged in with the
config module.
Status: NOT REVUED, NOT TESTED
- Online References:
-
Instructions for use:
To add a constant:
0. Add a default value for the constant. (string)
1. Add the constant declaration to the _Constants struct.
2. Add a CO_get_function()
3. Add initializing code to init_constants()
To access the constant:
use the CO_get<Constant>() function from your other code.
Included Files
Preprocessor definitions
Maximum number of constants.
#define MAX_CONSTS 100
Default values for constants.
#define DEFLT_MAX_THREADS "10"
#define DEFLT_WHOIS_PORT "0"
#define DEFLT_CONFIG_PORT "0"
#define DEFLT_MIRROR_PORT "0"
#define DEFLT_HOST "mysql.database.net"
#define DEFLT_USER "xxx"
#define DEFLT_PASSWORD "xxx"
#define DEFLT_DATABASE_PORT "3306"
#define DEFLT_DATABASE "RIPE"
#define DEFLT_QUERY "SHOW TABLES"
#define DEFLT_IN_QUERY "SELECT * FROM inetnum"
#define DEFLT_RT_QUERY "SELECT * FROM route"
#define DEFLT_AUTHENTICATE "0"
#define DEFLT_WHOIS_SUSPENDED "0"
#define DEFLT_WELCOME "Welcome to the whois R.I.P. server.\n"
#define DEFLT_PROMPT "whois R.I.P. config> "
#define DEFLT_CLEAR_SCREEN "0"
#define DEFLT_SLEEP_TIME "1"
#define DEFLT_ACCOUNTING "0"
#define DEFLT_QUERY_LOGGING "1"
#define DEFLT_QUERY_LOGFILE "stdout"
#define DEFLT_INSTR_LOGGING "1"
#define DEFLT_INSTR_LOGFILE "stdout"
#define DEFLT_COMND_LOGGING "1"
#define DEFLT_COMND_LOGFILE "stdout"
#define DEFLT_TESTS_LOGGING "1"
#define DEFLT_TESTS_LOGFILE "stdout"
#define DEFLT_THREAD_LOGGING "1"
#define DEFLT_THREAD_LOGFILE "stdout"
#define DEFLT_SOCKET_LOGGING "1"
#define DEFLT_SOCKET_LOGFILE "stdout"
#define DEFLT_CONFIG_LOGGING "1"
#define DEFLT_CONFIG_LOGFILE "stdout"
Each constant has a
struct _constant
struct _constant |
|
{ |
|
const char* token; | Token to be found in properties file.
|
const char* deflt; | Default value for the constant.
|
int (*set_func)(void*,char*); | Function to set the constant.
|
void* constant_ptr; | Pointer to the constant value
|
char* (*show_func)(void*); | Function to show the constant.
|
} |
|
The Constants array has a
typedef struct _Constants* Constants
struct _Constants |
|
{ |
|
int max_threads[1]; | Maximum number of server threads.
|
char whois_port[64]; | Port for whois clients to rendezvous with.
|
char config_port[64]; | Port for config clients to rendezvous with.
|
char mirror_port[64]; | Port for mirror clients to rendezvous with.
|
char host[64]; | Host for the database.
|
char user[64]; | User for the database.
|
char password[64]; | Password for the database.
|
int database_port[1]; | Port for the database.
|
char database[64]; | Database name.
|
char query[1024]; | Query for the database.
|
char in_query[1024]; | Query for the radix tree initialization.
|
char rt_query[1024]; | Query for the radix tree initialization.
|
int authenticate[1]; | Authenticate users.
|
int whois_suspended[1]; | Suspend the whois server.
|
char welcome[1024]; | Welcome for config protocol.
|
char prompt[1024]; | Prompt for config protocol.
|
int clear_screen[1]; | Clear screen after config commands.
|
int sleep_time[1]; | Sleep time (in sec) between config commands.
|
int accounting[1]; | Conduct accounting on whois queries.
|
int query_logging[1]; | Log the SQL queries.
|
char query_logfile[1024]; | Query logfile for the database.
|
int instr_logging[1]; | Log the whois instrucs.
|
char instr_logfile[1024]; | Query logfile for the whois instrucs.
|
int comnd_logging[1]; | Log the whois commands.
|
char comnd_logfile[1024]; | Query logfile for the whois commands.
|
int tests_logging[1]; | Log the whois tests.
|
char tests_logfile[1024]; | Query logfile for the whois tests.
|
int thread_logging[1]; | Log the whois threads.
|
char thread_logfile[1024]; | Query logfile for the whois threads.
|
int socket_logging[1]; | Log the socket.
|
char socket_logfile[1024]; | Logfile for the socket.
|
int config_logging[1]; | Log the config.
|
char config_logfile[1024]; | Logfile for the config.
|
} |
|
Local Variables
Global_constants
The array of Global Constants.
static Constants Global_constants
constant
* Contains the constant definitions for the Token, set_function, show_function.
* (See: _constant)
static struct _constant constant[100]
char* CO_const_to_string ( char* name )
int CO_get_accounting ( void )
int CO_get_authenticate ( void )
int CO_get_clear_screen ( void )
const char* CO_get_comnd_logfile ( void )
int CO_get_comnd_logging ( void )
const char* CO_get_config_logfile ( void )
int CO_get_config_logging ( void )
const char* CO_get_config_port ( void )
const char* CO_get_database ( void )
int CO_get_database_port ( void )
const char* CO_get_host ( void )
const char* CO_get_in_query ( void )
const char* CO_get_instr_logfile ( void )
int CO_get_instr_logging ( void )
int CO_get_max_threads ( void )
const char* CO_get_mirror_port ( void )
const char* CO_get_password ( void )
const char* CO_get_prompt ( void )
const char* CO_get_query ( void )
const char* CO_get_query_logfile ( void )
int CO_get_query_logging ( void )
const char* CO_get_rt_query ( void )
int CO_get_sleep_time ( void )
const char* CO_get_socket_logfile ( void )
int CO_get_socket_logging ( void )
const char* CO_get_tests_logfile ( void )
int CO_get_tests_logging ( void )
const char* CO_get_thread_logfile ( void )
int CO_get_thread_logging ( void )
const char* CO_get_user ( void )
const char* CO_get_welcome ( void )
const char* CO_get_whois_port ( void )
int CO_get_whois_suspended ( void )
Sets the constants from the properties module.
Returns the number of constants set.
More:
Authors:
ottrey
- Online References:
char* CO_set ( void )
Sets the value of one constant. Returns 0 if no error.
More:
Authors:
ottrey
- Online References:
int CO_set_const ( char* name, char* value )
Returns the constants as a string.
More:
Authors:
ottrey
- Online References:
char* CO_to_string ( void )
Initialize all the constants.
More:
Authors:
ottrey
- Online References:
static void init_constants ( void )
static int set_boolean ( void* constant, char* value )
static int set_int ( void* constant, char* value )
static int set_string ( void* constant, char* value )
static char* show_boolean ( void* constant )
static char* show_int ( void* constant )
static char* show_string ( void* constant )