NCBI C++ ToolKit
Classes | Macros | Functions | Variables
config.c File Reference
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <freetds/tds.h>
#include <freetds/configs.h>
#include <freetds/utils/string.h>
#include <freetds/utils.h>
#include <freetds/replacements.h>
+ Include dependency graph for config.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  tdsvername_t
 

Macros

#define TDS_ISSPACE(c)   isspace((unsigned char ) (c))
 
#define option   line
 
#define TDS_FIND(k, b, c)   tds_find(k, b, TDS_VECTOR_SIZE(b), sizeof(b[0]), c)
 

Functions

static bool tds_config_login (TDSLOGIN *connection, TDSLOGIN *login)
 
static bool tds_config_env_tdsdump (TDSLOGIN *login)
 
static void tds_config_env_tdsver (TDSLOGIN *login)
 
static void tds_config_env_tdsport (TDSLOGIN *login)
 
static bool tds_config_env_tdshost (TDSLOGIN *login)
 
static bool tds_read_conf_sections (FILE *in, const char *server, TDSLOGIN *login)
 
static bool tds_read_interfaces (const char *server, TDSLOGIN *login)
 Try to find the IP number and port for a (possibly) logical server name. More...
 
static bool parse_server_name_for_port (TDSLOGIN *connection, TDSLOGIN *login, bool update_server)
 Check the server name to find port info first Warning: connection-> & login-> are all modified when needed. More...
 
static int tds_lookup_port (const char *portname)
 Given a portname lookup the port. More...
 
static void tds_config_encryption (const char *value, TDSLOGIN *login)
 
TDSLOGINtds_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 bool 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...
 
int tds_parse_boolean (const char *value, int default_value)
 
int tds_config_boolean (const char *option, 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 const void * tds_find (const void *key, const void *base, size_t nelem, size_t width, int(*compar)(const void *, const void *))
 
static int tds_vername_cmp (const void *key, const void *pelem)
 
TDS_USMALLINTtds_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 addrinfotds_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 hexdigit (int c)
 
static int hex2num (char *hex)
 
static bool 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...
 
const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
 Return a structure capturing the compile-time settings provided to the configure script. More...
 

Variables

static char * interf_file = NULL
 
const char STD_DATETIME_FMT [] = "%Y-%m-%d %H:%M:%S.%z"
 
static const char pid_config_logpath [] = "/tmp/tdsconfig.log.%d"
 
static const char freetds_conf [] = "%s/etc/freetds.conf"
 
static const char location [] = "(from $FREETDS/etc)"
 
static const char pid_logpath [] = "/tmp/freetds.log.%d"
 
static const char interfaces_path [] = "/etc/freetds"
 
struct {
   char   value [7]
 
   unsigned char   to_return
 
boolean_values []
 

Macro Definition Documentation

◆ option

#define option   line

◆ TDS_ISSPACE

#define TDS_ISSPACE (   c)    isspace((unsigned char ) (c))

Definition at line 92 of file config.c.

Function Documentation

◆ hex2num()

static int hex2num ( char *  hex)
static

Definition at line 1056 of file config.c.

References hex(), and hexdigit().

Referenced by search_interface_file().

◆ hexdigit()

static int hexdigit ( int  c)
static

Definition at line 1044 of file config.c.

Referenced by hex2num().

◆ search_interface_file()

static bool search_interface_file ( TDSLOGIN login,
const char *  dir,
const char *  file,
const char *  host 
)
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'

Parameters
dirname of base directory for interface file
filename of the interface file
hostlogical host to search for
Returns
false if not fount true if found

Definition at line 1072 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().

◆ tds_config_encryption()

static void tds_config_encryption ( const char *  value,
TDSLOGIN login 
)
static

◆ tds_config_env_tdsdump()

static bool tds_config_env_tdsdump ( TDSLOGIN login)
static

◆ tds_config_env_tdshost()

static bool tds_config_env_tdshost ( TDSLOGIN login)
static

◆ tds_config_env_tdsport()

static void tds_config_env_tdsport ( TDSLOGIN login)
static

◆ tds_config_env_tdsver()

static void tds_config_env_tdsver ( TDSLOGIN login)
static

Definition at line 857 of file config.c.

References login, tds_config_verstr(), TDS_DBG_INFO1, and tdsdump_log.

Referenced by tds_fix_login().

◆ tds_config_login()

static bool tds_config_login ( TDSLOGIN connection,
TDSLOGIN login 
)
static

◆ tds_find()

static const void* tds_find ( const void *  key,
const void *  base,
size_t  nelem,
size_t  width,
int(*)(const void *, const void *)  compar 
)
static

Definition at line 897 of file config.c.

References ncbi::grid::netcache::search::fields::key, n, and NULL.

◆ tds_lookup_port()

static int tds_lookup_port ( const char *  portname)
static

Given a portname lookup the port.

If we can't determine the port number then return 0.

Definition at line 1034 of file config.c.

References tds_getservice.

Referenced by search_interface_file(), tds_config_env_tdsport(), and tds_read_interfaces().

◆ tds_read_conf_sections()

static bool tds_read_conf_sections ( FILE *  in,
const char *  server,
TDSLOGIN login 
)
static

◆ tds_read_interfaces()

static bool tds_read_interfaces ( const char *  server,
TDSLOGIN login 
)
static

Try to find the IP number and port for a (possibly) logical server name.

Note
This function uses only the interfaces file and is deprecated.

Definition at line 1195 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().

◆ tds_try_conf_file()

static bool tds_try_conf_file ( const char *  path,
const char *  how,
const char *  server,
TDSLOGIN login 
)
static

Definition at line 295 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().

Variable Documentation

◆ freetds_conf

const char freetds_conf[] = "%s/etc/freetds.conf"
static

Definition at line 98 of file config.c.

Referenced by tds_read_conf_file().

◆ interf_file

char* interf_file = NULL
static

Definition at line 90 of file config.c.

Referenced by tds_read_conf_file(), tds_read_interfaces(), and tds_set_interfaces_file_loc().

◆ interfaces_path

const char interfaces_path[] = "/etc/freetds"
static

Definition at line 101 of file config.c.

Referenced by tds_read_interfaces().

◆ location

const char location[] = "(from $FREETDS/etc)"
static

Definition at line 99 of file config.c.

Referenced by tds_read_conf_file().

◆ pid_config_logpath

const char pid_config_logpath[] = "/tmp/tdsconfig.log.%d"
static

Definition at line 97 of file config.c.

Referenced by tds_read_config_info().

◆ pid_logpath

const char pid_logpath[] = "/tmp/freetds.log.%d"
static

Definition at line 100 of file config.c.

Referenced by tds_config_env_tdsdump().

◆ STD_DATETIME_FMT

const char STD_DATETIME_FMT[] = "%Y-%m-%d %H:%M:%S.%z"

Definition at line 94 of file config.c.

◆ to_return

unsigned char to_return

Definition at line 437 of file config.c.

◆ value

char value[7]

Definition at line 436 of file config.c.

Modified on Tue May 28 05:53:09 2024 by modify_doxy.py rev. 669887