$Revision: 1.21 $
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_AUTHENTICATE "0"
#define DEFLT_WHOIS_SUSPENDED "0"
#define DEFLT_DO_SERVER "1"
#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_ACCOUNTING "0"
#define DEFLT_CONFIG_FILE "rip.config"
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*,const char*); | Function to set the constant.
|
void* constant_ptr; | Pointer to the constant value
|
char* (*show_func)(const void*); | Function to show the constant.
|
} |
|
The Constants array has a
typedef struct _Constants* Constants
struct _Constants |
|
{ |
|
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 accounting[1]; | Conduct accounting on whois queries.
|
int do_server[1]; | turns off execution of the all servers(threads)
|
int do_update[1]; | switches on and off the updates
|
} |
|
pthread_mutex_t Lock
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 ( const char* name )
int CO_get_accounting ( void )
int CO_get_authenticate ( void )
int CO_get_clear_screen ( void )
int CO_get_do_server ( void )
int CO_get_do_update ( void )
char* CO_get_prompt ( void )
char* CO_get_welcome ( 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 ( const char* name, const char* value )
Returns the constants as a string.
More:
Authors:
ottrey
- Online References:
char* CO_to_string ( void )
static char* asctime_r ( const struct tm* __tm, char* __buf )
static char* ctime_r ( const time_t* __time, char* __buf )
static int getlogin_r ( char* __name, int __len )
Initialize all the constants.
More:
Authors:
ottrey
- Online References:
static void init_constants ( void )
static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
static int set_boolean ( void* constant, const char* value )
static int set_int ( void* constant, const char* value )
static int set_string ( void* constant, const char* value )
static char* show_boolean ( const void* constant )
static char* show_int ( const void* constant )
static char* show_string ( const void* constant )
static int sigwait ( const sigset_t* __setp, int* __signo )
static int ttyname_r ( int __fildes, char* __buf, size_t __size )