FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Classes | Macros | Functions | Variables
Configuration

Handle reading of configuration. More...

Collaboration diagram for Configuration:

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

static int hex2num (char *hex)
 
static int hexdigit (int c)
 
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...
 
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...
 
int tds_config_boolean (const char *option, const char *value, TDSLOGIN *login)
 
static void tds_config_encryption (const char *value, TDSLOGIN *login)
 
static int tds_config_env_tdsdump (TDSLOGIN *login)
 
static int tds_config_env_tdshost (TDSLOGIN *login)
 
static void tds_config_env_tdsport (TDSLOGIN *login)
 
static void tds_config_env_tdsver (TDSLOGIN *login)
 
static int tds_config_login (TDSLOGIN *connection, TDSLOGIN *login)
 
TDS_USMALLINT * tds_config_verstr (const char *tdsver, TDSLOGIN *login)
 Set TDS version from given string. More...
 
static void * tds_find (const void *key, const void *base, size_t nelem, size_t width, int(*compar)(const void *, const void *))
 
void tds_fix_login (TDSLOGIN *login)
 Fix configuration after reading it. More...
 
const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
 Return a structure capturing the compile-time settings provided to the configure script.
 
static char * tds_get_home_file (const char *file)
 Return filename from HOME directory. 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...
 
int tds_parse_boolean (const char *value, int default_value)
 
void tds_parse_conf_section (const char *option, const char *value, void *param)
 
int tds_read_conf_file (TDSLOGIN *login, const char *server)
 Read configuration info for given server return 0 on error. More...
 
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...
 
static int tds_read_conf_sections (FILE *in, const char *server, 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...
 
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...
 
TDSRET tds_set_interfaces_file_loc (const char *interf)
 Set the full name of interface file. More...
 
static int tds_try_conf_file (const char *path, const char *how, const char *server, TDSLOGIN *login)
 
static int tds_vernanme_cmp (const void *key, const void *pelem)
 

Variables

struct {
   unsigned char   to_return
 
   char   value [7]
 
boolean_values []
 

Detailed Description

Handle reading of configuration.

Function Documentation

static int parse_server_name_for_port ( TDSLOGIN connection,
TDSLOGIN login 
)
static

Check the server name to find port info first Warning: connection-> & login-> are all modified when needed.

Returns
1 when found, else 0

Here is the call graph for this function:

Here is the caller graph for this function:

static int 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
0 if not fount 1 if found

Here is the call graph for this function:

Here is the caller graph for this function:

TDS_USMALLINT* tds_config_verstr ( const char *  tdsver,
TDSLOGIN login 
)

Set TDS version from given string.

Parameters
tdsvertds string version
loginwhere to store information
Returns
as encoded hex value: high nybble major, low nybble minor.

Here is the call graph for this function:

Here is the caller graph for this function:

void tds_fix_login ( TDSLOGIN login)

Fix configuration after reading it.

Currently this read some environment variables and replace some options.

Here is the caller graph for this function:

static char* tds_get_home_file ( const char *  file)
static

Return filename from HOME directory.

Returns
allocated string or NULL if error

Here is the call graph for this function:

Here is the caller graph for this function:

struct addrinfo* tds_lookup_host ( const char *  servername)

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.

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.

Here is the call graph for this function:

Here is the caller graph for this function:

int tds_read_conf_file ( TDSLOGIN login,
const char *  server 
)

Read configuration info for given server return 0 on error.

Parameters
loginwhere to store configuration
serversection of file configuration that hold configuration for a server

Here is the call graph for this function:

Here is the caller graph for this function:

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)

Parameters
inconfiguration file
sectionsection to read
tds_conf_parsecallback that receive every entry in section
paramparameter to pass to callback function

Here is the call graph for this function:

Here is the caller graph for this function:

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

.tdsrc and freetds.conf have been added to make the package easier to integration with various Linux and *BSD distributions.

Here is the call graph for this function:

Here is the caller graph for this function:

static int 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.

Here is the call graph for this function:

Here is the caller graph for this function:

TDSRET tds_set_interfaces_file_loc ( const char *  interf)

Set the full name of interface file.

Parameters
interffile name

Here is the caller graph for this function:

Variable Documentation

const { ... } boolean_values[]
Initial value:
= {
{ "yes", 1 },
{ "no", 0 },
{ "on", 1 },
{ "off", 0 },
{ "true", 1 },
{ "false", 0 }
}