FreeTDS API
Loading...
Searching...
No Matches
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, TDS_VECTOR_SIZE(b), sizeof(b[0]), c)
 

Functions

static int hex2num (char *hex)
 
static int hexdigit (int c)
 
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.
 
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'.
 
int tds_config_boolean (const char *option, const char *value, TDSLOGIN *login)
 
static void tds_config_encryption (const char *value, TDSLOGIN *login)
 
static bool tds_config_env_tdsdump (TDSLOGIN *login)
 
static bool tds_config_env_tdshost (TDSLOGIN *login)
 
static void tds_config_env_tdsport (TDSLOGIN *login)
 
static void tds_config_env_tdsver (TDSLOGIN *login)
 
static bool tds_config_login (TDSLOGIN *connection, TDSLOGIN *login)
 
TDS_USMALLINT * tds_config_verstr (const char *tdsver, TDSLOGIN *login)
 Set TDS version from given string.
 
static const 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.
 
const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
 Return a structure capturing the compile-time settings provided to the configure script.
 
char * tds_get_home_file (const char *file)
 Return filename from HOME directory.
 
struct addrinfo * tds_lookup_host (const char *servername)
 Get the IP address for a hostname.
 
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.
 
int tds_parse_boolean (const char *value, int default_value)
 
void tds_parse_conf_section (const char *option, const char *value, void *param)
 
bool tds_read_conf_file (TDSLOGIN *login, const char *server)
 Read configuration info for given server return 0 on error.
 
bool tds_read_conf_section (FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param)
 Read a section of configuration file (INI style file)
 
static bool 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
 
static bool tds_read_interfaces (const char *server, TDSLOGIN *login)
 Try to find the IP number and port for a (possibly) logical server name.
 
TDSRET tds_set_interfaces_file_loc (const char *interf)
 Set the full name of interface file.
 
static bool tds_try_conf_file (const char *path, const char *how, const char *server, TDSLOGIN *login)
 
static int tds_vername_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

◆ parse_server_name_for_port()

static bool parse_server_name_for_port ( TDSLOGIN connection,
TDSLOGIN login,
bool  update_server 
)
static

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

Returns
true when found, else false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tds_config_verstr()

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 caller graph for this function:

◆ tds_fix_login()

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:

◆ tds_get_compiletime_settings()

const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings ( void  )

Return a structure capturing the compile-time settings provided to the configure script.


◆ tds_get_home_file()

char * tds_get_home_file ( const char *  file)

Return filename from HOME directory.

Returns
allocated string or NULL if error
Here is the caller graph for this function:

◆ tds_lookup_host()

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.

◆ 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.

Here is the caller graph for this function:

◆ tds_read_conf_file()

bool 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:

◆ tds_read_conf_section()

bool 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 caller graph for this function:

◆ tds_read_config_info()

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:

◆ 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tds_set_interfaces_file_loc()

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

◆ [struct]

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