FreeTDS API

Classes | Macros | Functions | Variables
Configuration
LibTDS API

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_SETTINGS * | tds_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)
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...
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

## § parse_server_name_for_port()

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:

## § search_interface_file()

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

  dir | name of base directory for interface file
  file | name of the interface file
  host | logical host to search for

Returns
  0 if not fount 1 if found

Here is the call graph for this function:

## § tds_config_verstr()

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

Set TDS version from given string.

Parameters

  tdsver | tds string version
  login | where to store information

Returns
  as encoded hex value: high nybble major, low nybble minor.

## § tds_fix_login()

void tds_fix_login | ( | TDSLOGIN * | login | ) |

Fix configuration after reading it.

Currently this read some environment variables and replace some options.

## § tds_get_home_file()

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:

## § 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 call graph for this function:

## § tds_read_conf_file()

int tds_read_conf_file | ( | TDSLOGIN * | login,
|  | const char * | server
| ) |  |

Read configuration info for given server return 0 on error.

Parameters

  login | where to store configuration
  server | section of file configuration that hold configuration for a server

## § tds_read_conf_section()

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

  in | configuration file
  section | section to read
  tds_conf_parse | callback that receive every entry in section
  param | parameter to pass to callback 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.

## § tds_read_interfaces()

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:

## § tds_set_interfaces_file_loc()

TDSRET tds_set_interfaces_file_loc | ( | const char * | interf | ) |

Set the full name of interface file.

Parameters

  interf | file name

## Variable Documentation

## § boolean_values

const { ... } boolean_values[]

Initial value:
= {
{ "yes", 1 },
{ "no", 0 },
{ "on", 1 },
{ "off", 0 },
{ "true", 1 },
{ "false", 0 }
}