File co/constants.c

  $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"


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


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
   } 


Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/code/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/access_control.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

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 ( const char* name )
Prototyped in: /home/shane/code/RIP/include/constants.h
Calls: strcmp()
References Variables: constantco/constants.c

Global Function CO_get_accounting()

int CO_get_accounting ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_authenticate()

int CO_get_authenticate ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_clear_screen()

int CO_get_clear_screen ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_do_server()

int CO_get_do_server ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
Called by: AC_decay()ac/access_control.c
References Variables: Global_constantsco/constants.c

Global Function CO_get_do_update()

int CO_get_do_update ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_prompt()

char* CO_get_prompt ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_welcome()

char* CO_get_welcome ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/constants.c

Global Function CO_get_whois_suspended()

int CO_get_whois_suspended ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
References Variables: Global_constantsco/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 )
Prototyped in: /home/shane/code/RIP/include/constants.h
Calls: init_constants()co/constants.c
  PR_get_property(), UT_calloc_real(), UT_free_real(), sprintf(), strcpy(), strlen()
References Variables: Global_constantsco/constants.c
  constantco/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 ( const char* name, const char* value )
Prototyped in: /home/shane/code/RIP/include/constants.h
Calls: strcmp()
References Variables: constantco/constants.c

Global Function CO_to_string()

  Returns the constants as a string.

More:
  Authors:
        ottrey

Online References:
char* CO_to_string ( void )
Prototyped in: /home/shane/code/RIP/include/constants.h
Calls: UT_free_real(), UT_strdup_real(), g_string_append_c(), g_string_free(), g_string_new(), g_string_sprintfa()
References Variables: constantco/constants.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function init_constants()

  Initialize all the constants.

More:
  Authors:
        ottrey

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

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function set_boolean()

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

Local Function set_int()

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

Local Function set_string()

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

Local Function show_boolean()

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

Local Function show_int()

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

Local Function show_string()

static char* show_string ( const void* constant )
Calls: UT_strdup_real()
Used in: init_constants()co/constants.c

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()