NCBI C++ ToolKit
|
Handle reading of configuration. More...
Classes | |
struct | tdsvername_t |
Macros | |
#define | TDS_FIND(k, b, c) tds_find(k, b, sizeof(b)/sizeof(b[0]), sizeof(b[0]), c) |
Functions | |
TDSLOGIN * | tds_read_config_info (TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale) |
tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values More... | |
void | tds_fix_login (TDSLOGIN *login) |
Fix configuration after reading it. More... | |
static int | tds_try_conf_file (const char *path, const char *how, const char *server, TDSLOGIN *login) |
static char * | tds_get_home_file (const char *file) |
Return filename from HOME directory. More... | |
int | tds_read_conf_file (TDSLOGIN *login, const char *server) |
Read configuration info for given server return 0 on error. More... | |
static int | tds_read_conf_sections (FILE *in, const char *server, TDSLOGIN *login) |
int | tds_parse_boolean (const char *value, int default_value) |
int | tds_config_boolean (const char *option, const char *value, TDSLOGIN *login) |
static void | tds_config_encryption (const char *value, TDSLOGIN *login) |
int | tds_read_conf_section (FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param) |
Read a section of configuration file (INI style file) More... | |
void | tds_parse_conf_section (const char *option, const char *value, void *param) |
static int | tds_config_login (TDSLOGIN *connection, TDSLOGIN *login) |
static int | tds_config_env_tdsdump (TDSLOGIN *login) |
static void | tds_config_env_tdsport (TDSLOGIN *login) |
static void | tds_config_env_tdsver (TDSLOGIN *login) |
static int | tds_config_env_tdshost (TDSLOGIN *login) |
static void * | tds_find (const void *key, const void *base, size_t nelem, size_t width, int(*compar)(const void *, const void *)) |
static int | tds_vernanme_cmp (const void *key, const void *pelem) |
TDS_USMALLINT * | tds_config_verstr (const char *tdsver, TDSLOGIN *login) |
Set TDS version from given string. More... | |
TDSRET | tds_set_interfaces_file_loc (const char *interf) |
Set the full name of interface file. More... | |
struct addrinfo * | tds_lookup_host (const char *servername) |
Get the IP address for a hostname. More... | |
TDSRET | tds_lookup_host_set (const char *servername, struct addrinfo **addr) |
static int | tds_lookup_port (const char *portname) |
Given a portname lookup the port. More... | |
static int | hexdigit (int c) |
static int | hex2num (char *hex) |
static int | search_interface_file (TDSLOGIN *login, const char *dir, const char *file, const char *host) |
Open and read the file 'file' searching for a logical server by the name of 'host'. More... | |
static int | tds_read_interfaces (const char *server, TDSLOGIN *login) |
Try to find the IP number and port for a (possibly) logical server name. More... | |
static int | parse_server_name_for_port (TDSLOGIN *connection, TDSLOGIN *login) |
Check the server name to find port info first Warning: connection-> & login-> are all modified when needed. More... | |
const TDS_COMPILETIME_SETTINGS * | tds_get_compiletime_settings (void) |
Return a structure capturing the compile-time settings provided to the configure script. More... | |
Variables | |
struct { | |
char value [7] | |
unsigned char to_return | |
} | boolean_values [] |
Handle reading of configuration.
Definition at line 1021 of file config.c.
References hex(), and hexdigit().
Referenced by search_interface_file().
Check the server name to find port info first Warning: connection-> & login-> are all modified when needed.
Definition at line 1266 of file config.c.
References tds_login::instance_name, login, tds_login::port, tds_login::server_name, tds_dstr_copy(), tds_dstr_copyn(), tds_dstr_cstr(), and tds_dstr_empty.
Referenced by tds_read_config_info().
|
static |
Open and read the file 'file' searching for a logical server by the name of 'host'.
If one is found then lookup the IP address and port number and store them in 'login'
dir | name of base directory for interface file |
file | name of the interface file |
host | logical host to search for |
Definition at line 1037 of file config.c.
References addrinfo, file, free(), hex2num(), in(), tds_login::ip_addrs, login, NULL, tds_login::port, tds_login::server_host_name, strcat, util::strcmp(), strtok_r, tds_addrinfo2str, tds_config_verstr(), TDS_DBG_INFO1, TDS_DBG_WARN, tds_dstr_copy(), TDS_ISSPACE, tds_lookup_host_set(), tds_lookup_port(), tds_new, TDS_SDIR_SEPARATOR, TDS_SUCCEED, and tdsdump_log.
Referenced by tds_read_interfaces().
Definition at line 455 of file config.c.
References login, option, TDS_DBG_ERROR, tds_parse_boolean(), tdsdump_log, tds_login::valid_configuration, and value.
Referenced by tds_parse_conf_section().
Definition at line 468 of file config.c.
References tds_login::encryption_level, login, strcasecmp, TDS_DBG_ERROR, TDS_ENCRYPTION_OFF, TDS_ENCRYPTION_REQUEST, TDS_ENCRYPTION_REQUIRE, TDS_STR_ENCRYPTION, TDS_STR_ENCRYPTION_OFF, TDS_STR_ENCRYPTION_REQUEST, TDS_STR_ENCRYPTION_REQUIRE, tdsdump_log, tds_login::valid_configuration, and value.
Referenced by tds_parse_conf_section().
Definition at line 783 of file config.c.
References asprintf, tds_login::dump_file, free(), login, pid_logpath, TDS_DBG_INFO1, tds_dstr_copy(), tds_dstr_cstr(), tds_dstr_set(), and tdsdump_log.
Referenced by tds_fix_login().
Definition at line 833 of file config.c.
References addrinfo, tds_login::ip_addrs, login, NULL, tds_login::server_host_name, tds_addrinfo2str, TDS_DBG_INFO1, TDS_DBG_WARN, tds_dstr_copy(), TDS_FAILED, tds_lookup_host_set(), tdsdump_log, and tmp.
Referenced by tds_fix_login().
Definition at line 807 of file config.c.
References tds_login::instance_name, login, tds_login::port, TDS_DBG_INFO1, tds_dstr_empty, tds_lookup_port(), and tdsdump_log.
Referenced by tds_fix_login().
Definition at line 819 of file config.c.
References login, tds_config_verstr(), TDS_DBG_INFO1, and tdsdump_log.
Referenced by tds_fix_login().
Definition at line 694 of file config.c.
References tds_login::app_name, tds_login::block_size, tds_login::bulk_copy, tds_login::capabilities, tds_login::check_ssl_hostname, tds_login::client_charset, tds_login::client_host_name, tds_login::connect_timeout, tds_login::database, tds_login::db_filename, tds_login::encryption_level, tds_login::language, tds_login::library, login, tds_login::new_password, NULL, tds_login::openssl_ciphers, tds_login::password, tds_login::port, tds_login::query_timeout, tds_login::readonly_intent, tds_login::server_charset, tds_login::server_name, tds_login::suppress_language, TDS_DBG_INFO1, tds_dstr_cstr(), tds_dstr_dup(), tds_dstr_isempty(), tds_dstr_zero(), tds_login::tds_version, tdsdump_log, tds_login::use_new_password, tds_login::use_utf16, and tds_login::user_name.
Referenced by tds_read_config_info().
TDS_USMALLINT* tds_config_verstr | ( | const char * | tdsver, |
TDSLOGIN * | login | ||
) |
Set TDS version from given string.
tdsver | tds string version |
login | where to store information |
Definition at line 891 of file config.c.
References assert, login, NULL, TDS_DBG_INFO1, TDS_FIND, tds_vernanme_cmp(), tds_login::tds_version, tdsdump_log, and tdsvername_t::version.
Referenced by search_interface_file(), tds_config_env_tdsver(), and tds_parse_conf_section().
|
static |
Definition at line 859 of file config.c.
References i, ncbi::grid::netcache::search::fields::key, and NULL.
void tds_fix_login | ( | TDSLOGIN * | login | ) |
Fix configuration after reading it.
Currently this read some environment variables and replace some options.
Definition at line 280 of file config.c.
References login, tds_config_env_tdsdump(), tds_config_env_tdshost(), tds_config_env_tdsport(), and tds_config_env_tdsver().
Referenced by tds_read_config_info().
const TDS_COMPILETIME_SETTINGS* tds_get_compiletime_settings | ( | void | ) |
Return a structure capturing the compile-time settings provided to the configure script.
Definition at line 1310 of file config.c.
References assert, FREETDS_SYSCONFDIR, TDS_VERSION_NO, and tds_compiletime_settings::tdsver.
Return filename from HOME directory.
Definition at line 320 of file config.c.
References asprintf, file, free(), NULL, and tds_get_homedir.
Referenced by tds_read_conf_file(), and tds_read_interfaces().
Get the IP address for a hostname.
Store server's IP address in the string 'ip' in dotted-decimal notation. (The "hostname" might itself be a dotted-decimal address.
If we can't determine the IP address then 'ip' will be set to empty string.
Definition at line 960 of file config.c.
References addrinfo, assert, getaddrinfo, and NULL.
Referenced by tds_lookup_host_set().
Definition at line 979 of file config.c.
References addrinfo, assert, freeaddrinfo, NULL, TDS_FAIL, tds_lookup_host(), and TDS_SUCCESS.
Referenced by search_interface_file(), tds_config_env_tdshost(), tds_parse_conf_section(), tds_read_config_info(), and tds_read_interfaces().
Given a portname lookup the port.
If we can't determine the port number then return 0.
Definition at line 999 of file config.c.
References tds_getservice.
Referenced by search_interface_file(), tds_config_env_tdsport(), and tds_read_interfaces().
Definition at line 443 of file config.c.
References boolean_values, strcasecmp, TDS_VECTOR_SIZE, to_return, and value.
Referenced by tds_config_boolean().
Definition at line 588 of file config.c.
References addrinfo, tds_login::block_size, tds_login::cafile, tds_login::check_ssl_hostname, tds_login::client_charset, tds_login::connect_timeout, tds_login::crlfile, tds_login::database, tds_login::db_filename, tds_login::debug_flags, tds_login::dump_file, tds_login::emul_little_endian, flags, tds_login::gssapi_use_delegation, tds_login::instance_name, int, tds_login::ip_addrs, tds_login::language, login, NULL, tds_login::openssl_ciphers, option, tds_login::port, tds_login::query_timeout, tds_login::readonly_intent, tds_login::server_charset, tds_login::server_host_name, tds_login::server_name, tds_login::server_realm_name, tds_login::server_spn, util::strcmp(), tds_addrinfo2str, tds_config_boolean(), tds_config_encryption(), tds_config_verstr(), TDS_DBG_FUNC, TDS_DBG_INFO1, TDS_DBG_WARN, tds_dstr_copy(), tds_dstr_cstr(), TDS_FAILED, tds_g_append_mode, TDS_GSSAPI_DELEGATION, tds_lookup_host_set(), TDS_STR_APPENDMODE, TDS_STR_ASA_DATABASE, TDS_STR_BLKSZ, TDS_STR_CAFILE, TDS_STR_CHARSET, TDS_STR_CHECKSSLHOSTNAME, TDS_STR_CLCHARSET, TDS_STR_CONNTIMEOUT, TDS_STR_CRLFILE, TDS_STR_DATABASE, TDS_STR_DBFILENAME, TDS_STR_DEBUGFLAGS, TDS_STR_DUMPFILE, TDS_STR_EMUL_LE, TDS_STR_ENCRYPTION, TDS_STR_HOST, TDS_STR_INSTANCE, TDS_STR_LANGUAGE, TDS_STR_PORT, TDS_STR_QUERY_TIMEOUT, TDS_STR_READONLY_INTENT, TDS_STR_REALM, TDS_STR_SPN, TDS_STR_SWAPDT, TDS_STR_TEXTSZ, TDS_STR_TIMEOUT, TDS_STR_USE_UTF_16, TDS_STR_USELANMAN, TDS_STR_USENTLMV2, TDS_STR_VERSION, tdsdump_log, tds_login::text_size, TLS_STR_OPENSSL_CIPHERS, tmp, tds_login::use_lanman, tds_login::use_ntlmv2, tds_login::use_utf16, val, tds_login::valid_configuration, and value.
Referenced by tds_read_conf_sections().
Read configuration info for given server return 0 on error.
login | where to store configuration |
server | section of file configuration that hold configuration for a server |
Definition at line 341 of file config.c.
References asprintf, free(), freetds_conf, FREETDS_SYSCONFFILE, interf_file, location, login, NULL, TDS_DBG_INFO2, tds_get_home_file(), tds_try_conf_file(), and tdsdump_log.
Referenced by tds_read_config_info().
int tds_read_conf_section | ( | FILE * | in, |
const char * | section, | ||
TDSCONFPARSE | tds_conf_parse, | ||
void * | param | ||
) |
Read a section of configuration file (INI style file)
in | configuration file |
section | section to read |
tds_conf_parse | callback that receive every entry in section |
param | parameter to pass to callback function |
Definition at line 498 of file config.c.
References i, in(), option, strcasecmp, TDS_DBG_INFO1, TDS_ISSPACE, tdsdump_log, tolower(), and value.
Referenced by tds_read_conf_sections().
Definition at line 392 of file config.c.
References DSTR_INITIALIZER, in(), tds_login::instance_name, login, tds_login::port, TDS_DBG_ERROR, tds_dstr_cstr(), tds_dstr_dup(), tds_dstr_free(), tds_dstr_isempty(), tds_parse_conf_section(), tds_read_conf_section(), tdsdump_log, and tds_login::valid_configuration.
Referenced by tds_try_conf_file().
tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values
.tdsrc and freetds.conf have been added to make the package easier to integration with various Linux and *BSD distributions.
Definition at line 136 of file config.c.
References addrinfo, tds_login::app_name, asprintf, tds_login::block_size, tds_login::bulk_copy, tds_login::cafile, tds_login::check_ssl_hostname, tds_login::client_charset, tds_login::client_host_name, tds_login::connect_timeout, tds_login::crlfile, tds_login::database, tds_login::db_filename, tds_login::debug_flags, tds_login::dump_file, tds_login::emul_little_endian, tds_login::encryption_level, free(), tds_login::instance_name, tds_login::ip_addrs, tds_login::language, tds_login::library, locale, login, NULL, tds_login::openssl_ciphers, parse_server_name_for_port(), pid_config_logpath, tds_login::port, tds_login::query_timeout, tds_login::readonly_intent, tds_login::server_charset, tds_login::server_host_name, tds_login::server_name, tds_login::server_realm_name, tds_login::server_spn, tds_login::suppress_language, tds, tds_addrinfo2str, tds_alloc_login, tds_config_login(), TDS_DBG_INFO1, tds_debug_flags, tds_dstr_cstr(), tds_dstr_dup(), tds_dstr_isempty(), tds_fix_login(), tds_free_login, tds_get_ctx, tds_init_login, tds_lookup_host_set(), TDS_MAJOR, TDS_MINOR, tds_read_conf_file(), tds_read_interfaces(), TDS_SUCCEED, tdsdump_close, tdsdump_isopen, tdsdump_log, tdsdump_open, TDSEINTF, tdserror, tds_login::text_size, tmp, tds_login::use_utf16, and tds_login::user_name.
Try to find the IP number and port for a (possibly) logical server name.
Definition at line 1160 of file config.c.
References free(), interf_file, interfaces_path, tds_login::ip_addrs, login, NULL, tds_login::port, search_interface_file(), tds_login::server_host_name, TDS_DBG_INFO1, TDS_DEF_PORT, tds_dstr_copy(), tds_get_home_file(), tds_lookup_host_set(), tds_lookup_port(), TDS_SUCCEED, and tdsdump_log.
Referenced by tds_read_config_info().
Set the full name of interface file.
interf | file name |
Definition at line 934 of file config.c.
References interf_file, NULL, strdup, TDS_FAIL, TDS_SUCCESS, and TDS_ZERO_FREE.
|
static |
Definition at line 290 of file config.c.
References in(), login, NULL, TDS_DBG_INFO1, TDS_DBG_INFO2, tds_read_conf_sections(), and tdsdump_log.
Referenced by tds_read_conf_file().
Definition at line 879 of file config.c.
References ncbi::grid::netcache::search::fields::key, and util::strcmp().
Referenced by tds_config_verstr().
const { ... } boolean_values[] |
Referenced by tds_parse_boolean().