Cross reference for modules/co/constants.c of index.

# File modules/co/constants.c

      $Revision: 1.15 $

      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

- `#include <stdio.h>`

- `#include <stdlib.h>`

- `#include <string.h>`

- `#include "include/memwrap.h"`
  - `#include <include/erroutines.h>`
  - `#include <glib.h>`

- `#include "include/properties.h"`

## Preprocessor definitions

`#define STR_XL 4095`

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_UPDATE_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_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_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"`

`#define DEFLT_NRTM_HOST "nrtm.nowhere.xx"`

`#define DEFLT_NRTM_VERSION "1"`

`#define DEFLT_NRTM_DELAY "600"`

`#define DEFLT_NRTM_CSERFILE "RIPE.CURRENTSERIAL"`

`#define DEFLT_NRTM_LOGFILE "nrtm.log"`

`#define DEFLT_UPDATE_MODE "0"`

## 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 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 update_port[64];` | Port for DBupdate 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.
`char nrtm_host[64];` | NRTM server
`char nrtm_port[64];` | Port of NRTM server when we are acting as a client
`int nrtm_version[1];` | NRTM protocol version
`int nrtm_delay[1];` | delay between syncs
`char nrtm_cserialfile[1024];` | name of the file containing current serial
`char nrtm_logfile[1024];` | NRTM logfile for failure reports
`int do_nrtm[1];` |
`int update_mode[1];` | protected/unprotected (==dummy_allowed)
`int do_update[1];` | switches on and off the updates
`int do_server[1];` | turns off execution of the all servers(threads)
`}` |

## Typedef source_info_t

Source database mirrors

`typedef struct {...} source_info_t`

`struct` |
`{` |
`char src[32];` |
`char db[32];` |
`}` |

## Global Variable Sources

`const source_info_t Sources[]`

Visible in: |  | modules/co/constants.c
Used in: | CO_get_source() | modules/co/constants.c
| CO_get_source_database() | modules/co/constants.c
| CO_sources_to_string() | modules/co/constants.c

## Global Variable Sources_vector

`char* const Sources_vector[]`

Visible in: |  | modules/co/constants.c
Used in: | CO_get_sources() | modules/co/constants.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_comnd_logfile()
| CO_get_comnd_logging()
| CO_get_config_logfile()
| CO_get_config_logging()
| CO_get_config_port()
| CO_get_database()
| CO_get_database_port()
| CO_get_do_nrtm()
| CO_get_do_server()
| CO_get_do_update()
| CO_get_host()
| CO_get_in_query()
| CO_get_instr_logfile()
| CO_get_instr_logging()
| CO_get_max_threads()
| CO_get_mirror_port()
| CO_get_nrtm_cserialfile()
| CO_get_nrtm_delay()
| CO_get_nrtm_host()
| CO_get_nrtm_logfile()
| CO_get_nrtm_port()
| CO_get_nrtm_version()
| CO_get_password()
| CO_get_prompt()
| CO_get_query()
| CO_get_query_logfile()
| CO_get_query_logging()
| CO_get_rt_query()
| CO_get_sleep_time()
| CO_get_socket_logfile()
| CO_get_socket_logging()
| CO_get_tests_logfile()
| CO_get_tests_logging()
| CO_get_thread_logfile()
| CO_get_thread_logging()
| CO_get_update_mode()
| CO_get_update_port()
| CO_get_user()
| CO_get_welcome()
| CO_get_whois_port()
| 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: | constant | modules/co/constants.c

## Global Function CO_get_accounting()

`int CO_get_accounting ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_authenticate()

`int CO_get_authenticate ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_clear_screen()

`int CO_get_clear_screen ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_comnd_logfile()

`char* CO_get_comnd_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_comnd_logging()

`int CO_get_comnd_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_config_logfile()

`char* CO_get_config_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_config_logging()

`int CO_get_config_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_config_port()

`char* CO_get_config_port ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_database()

`char* CO_get_database ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_database_port()

`int CO_get_database_port ( void )`

Called by: | AC_acc_load() | modules/ac/access_control.c
| AC_acl_sql() | modules/ac/access_control.c
References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_do_nrtm()

`int CO_get_do_nrtm ( void )`

References Variables: | Global_constants | modules/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_constants | modules/co/constants.c

## Global Function CO_get_do_update()

`int CO_get_do_update ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_host()

`char* CO_get_host ( void )`

Called by: | AC_acc_load() | modules/ac/access_control.c
| AC_acl_sql() | modules/ac/access_control.c
References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_in_query()

`char* CO_get_in_query ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_instr_logfile()

`char* CO_get_instr_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_instr_logging()

`int CO_get_instr_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_max_threads()

`int CO_get_max_threads ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_mirror_port()

`char* CO_get_mirror_port ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_cserialfile()

`char* CO_get_nrtm_cserialfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_delay()

`int CO_get_nrtm_delay ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_host()

     NRTM stuff

`char* CO_get_nrtm_host ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_logfile()

`char* CO_get_nrtm_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_port()

`char* CO_get_nrtm_port ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_nrtm_version()

`int CO_get_nrtm_version ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_password()

`char* CO_get_password ( void )`

Called by: | AC_acc_load() | modules/ac/access_control.c
| AC_acl_sql() | modules/ac/access_control.c
References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_prompt()

`char* CO_get_prompt ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_query()

`char* CO_get_query ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_query_logfile()

`char* CO_get_query_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_query_logging()

`int CO_get_query_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_rt_query()

`char* CO_get_rt_query ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_sleep_time()

`int CO_get_sleep_time ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_socket_logfile()

`char* CO_get_socket_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_socket_logging()

`int CO_get_socket_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_source()

`const char* CO_get_source ( int index )`

References Variables: | Sources | modules/co/constants.c

## Global Function CO_get_source_database()

`const char* CO_get_source_database ( int index )`

References Variables: | Sources | modules/co/constants.c

## Global Function CO_get_sources()

`char* const* CO_get_sources ( void )`

References Variables: | Sources_vector | modules/co/constants.c

## Global Function CO_get_tests_logfile()

`char* CO_get_tests_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_tests_logging()

`int CO_get_tests_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_thread_logfile()

`char* CO_get_thread_logfile ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_thread_logging()

`int CO_get_thread_logging ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_update_mode()

`int CO_get_update_mode ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_update_port()

`char* CO_get_update_port ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_user()

`char* CO_get_user ( void )`

Called by: | AC_acc_load() | modules/ac/access_control.c
| AC_acl_sql() | modules/ac/access_control.c
References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_welcome()

`char* CO_get_welcome ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_whois_port()

`char* CO_get_whois_port ( void )`

References Variables: | Global_constants | modules/co/constants.c

## Global Function CO_get_whois_suspended()

`int CO_get_whois_suspended ( void )`

References Variables: | Global_constants | modules/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:

      .properties

`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_constants | modules/co/constants.c
| constant | modules/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: | constant | modules/co/constants.c

## Global Function CO_sources_list_to_string()

      Creates a string from the sources in the GList.

      More:

      Authors:
            ottrey

    Online References:

`char* CO_sources_list_to_string ( GList* sources_list )`

`GList* sources_list`
  The GList of sources.

Calls: | fprintf(), g_list_foreach(), strcpy(), strlen(), wr_real_malloc()
References Functions: | source_foreach() | modules/co/constants.c

## Global Function CO_sources_to_string()

      Creates a string from Sources.

      More:

      Authors:
            ottrey

    Online References:

`char* CO_sources_to_string ( void )`

`char* CO_sources_to_string`
  Returns a string of the Sources.

Calls: | fprintf(), strcat(), strcpy(), strlen(), wr_real_malloc()
References Variables: | Sources | modules/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: | constant | modules/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_constants | modules/co/constants.c
| constant | modules/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

## Local Function source_foreach()

      Function to adds the source string to the created string from the Glist of sources.
      It is called via g_list_foreach().

      More:

      Authors:
            ottrey

    Online References:

`static void source_foreach ( void* element_data, void* result_buf_ptr )`

`void* element_data`
  The source name.
`void* result_buf_ptr`
  The string to be populated.

Calls: | strcat()
Used in: | CO_sources_list_to_string() | modules/co/constants.c