File modules/co/constants.c

  $Revision: 1.18 $

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

#define STR_XL 4095

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"


Type struct _constant

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.
   } 


Typedef Constants

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
   } 


Local Variables

Global_constants
The array of Global Constants.

static Constants Global_constants
Used in: CO_get_accounting()
  CO_get_authenticate()
  CO_get_clear_screen()
  CO_get_do_server()
  CO_get_do_update()
  CO_get_prompt()
  CO_get_welcome()
  CO_get_whois_suspended()
  CO_set()
  init_constants()

constant
* Contains the constant definitions for the Token, set_function, show_function. * (See: _constant)

static struct _constant constant[100]
Used in: CO_const_to_string()
  CO_set()
  CO_set_const()
  CO_to_string()
  init_constants()


Global Function CO_const_to_string()

char* CO_const_to_string ( char* name )
Calls: strcmp()
References Variables: constantmodules/co/constants.c

Global Function CO_get_accounting()

int CO_get_accounting ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_authenticate()

int CO_get_authenticate ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_clear_screen()

int CO_get_clear_screen ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_do_server()

int CO_get_do_server ( void )
Called by: AC_decay()modules/ac/access_control.c
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_do_update()

int CO_get_do_update ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_prompt()

char* CO_get_prompt ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_welcome()

char* CO_get_welcome ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_get_whois_suspended()

int CO_get_whois_suspended ( void )
References Variables: Global_constantsmodules/co/constants.c

Global Function CO_set()

  Sets the constants from the properties module.
  Returns the number of constants set.

More:
  Authors:
        ottrey
Online References:
char* CO_set ( void )
Calls: init_constants()modules/co/constants.c
  PR_get_property(), fprintf(), sprintf(), strcpy(), strlen(), wr_real_calloc(), wr_real_free(), wr_real_malloc()
References Variables: Global_constantsmodules/co/constants.c
  constantmodules/co/constants.c

Global Function CO_set_const()

  Sets the value of one constant.  Returns 0 if no error.

More:
  Authors:
        ottrey

Online References:
int CO_set_const ( char* name, char* value )
Calls: strcmp()
References Variables: constantmodules/co/constants.c

Global Function CO_to_string()

  Returns the constants as a string.

More:
  Authors:
        ottrey

Online References:
char* CO_to_string ( void )
Calls: fprintf(), sprintf(), strcat(), strcpy(), strlen(), wr_real_free(), wr_real_malloc()
References Variables: constantmodules/co/constants.c

Local Function init_constants()

  Initialize all the constants.

More:
  Authors:
        ottrey

Online References:
static void init_constants ( void )
Called by: CO_set()modules/co/constants.c
References Functions: set_boolean()modules/co/constants.c
  set_int()modules/co/constants.c
  set_string()modules/co/constants.c
  show_boolean()modules/co/constants.c
  show_int()modules/co/constants.c
  show_string()modules/co/constants.c
References Variables: Global_constantsmodules/co/constants.c
  constantmodules/co/constants.c

Local Function set_boolean()

static int set_boolean ( void* constant, char* value )
Calls: atol()
Used in: init_constants()modules/co/constants.c

Local Function set_int()

static int set_int ( void* constant, char* value )
Calls: atol()
Used in: init_constants()modules/co/constants.c

Local Function set_string()

static int set_string ( void* constant, char* value )
Calls: strcpy()
Used in: init_constants()modules/co/constants.c

Local Function show_boolean()

static char* show_boolean ( void* constant )
Calls: fprintf(), sprintf(), wr_real_malloc()
Used in: init_constants()modules/co/constants.c

Local Function show_int()

static char* show_int ( void* constant )
Calls: fprintf(), sprintf(), wr_real_malloc()
Used in: init_constants()modules/co/constants.c

Local Function show_string()

static char* show_string ( void* constant )
Calls: fprintf(), strcpy(), strlen(), wr_real_malloc()
Used in: init_constants()modules/co/constants.c