NCBI C++ ToolKit
Classes | Macros | Functions
connectparams.c File Reference
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
#include <freetds/odbc.h>
#include "replacements.h"
+ Include dependency graph for connectparams.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  ProfileParam
 

Macros

#define ODBC_PARAM(p)   static const char odbc_param_##p[] = #p;
 
#define SYS_ODBC_INI   "/etc/odbc.ini"
 
#define CHK_PARAM(p)   (strcasecmp(option, odbc_param_##p) == 0 && (num_param=ODBC_PARAM_##p) >= 0)
 

Functions

static FILE * tdoGetIniFileName (void)
 Call this to get the INI file containing Data Source Names. More...
 
static int SQLGetPrivateProfileString (LPCSTR pszSection, LPCSTR pszEntry, LPCSTR pszDefault, LPSTR pRetBuffer, int nRetBuffer, LPCSTR pszFileName)
 SQLGetPrivateProfileString. More...
 
static int parse_server (TDS_ERRS *errs, char *server, TDSLOGIN *login)
 
static int myGetPrivateProfileString (const char *DSN, const char *key, char *buf)
 
int odbc_get_dsn_info (TDS_ERRS *errs, const char *DSN, TDSLOGIN *login)
 Read connection information from given DSN. More...
 
static void odbc_dstr_swap (DSTR *a, DSTR *b)
 Swap two DSTR. More...
 
int odbc_parse_connect_string (TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSLOGIN *login, TDS_PARSED_PARAM *parsed_params)
 Parse connection string and fill login according. More...
 
static void tdoParseProfile (const char *option, const char *value, void *param)
 

Macro Definition Documentation

◆ CHK_PARAM

#define CHK_PARAM (   p)    (strcasecmp(option, odbc_param_##p) == 0 && (num_param=ODBC_PARAM_##p) >= 0)

◆ ODBC_PARAM

#define ODBC_PARAM (   p)    static const char odbc_param_##p[] = #p;

Definition at line 34 of file connectparams.c.

◆ SYS_ODBC_INI

#define SYS_ODBC_INI   "/etc/odbc.ini"

Definition at line 53 of file connectparams.c.

Function Documentation

◆ myGetPrivateProfileString()

static int myGetPrivateProfileString ( const char *  DSN,
const char *  key,
char *  buf 
)
static

◆ odbc_dstr_swap()

static void odbc_dstr_swap ( DSTR a,
DSTR b 
)
static

Swap two DSTR.

Definition at line 260 of file connectparams.c.

References a, b, and tmp.

Referenced by odbc_parse_connect_string().

◆ odbc_get_dsn_info()

int odbc_get_dsn_info ( TDS_ERRS errs,
const char *  DSN,
TDSLOGIN login 
)

◆ odbc_parse_connect_string()

int odbc_parse_connect_string ( TDS_ERRS errs,
const char *  connect_string,
const char *  connect_string_end,
TDSLOGIN login,
TDS_PARSED_PARAM parsed_params 
)

◆ parse_server()

static int parse_server ( TDS_ERRS errs,
char *  server,
TDSLOGIN login 
)
static

◆ SQLGetPrivateProfileString()

static int SQLGetPrivateProfileString ( LPCSTR  pszSection,
LPCSTR  pszEntry,
LPCSTR  pszDefault,
LPSTR  pRetBuffer,
int  nRetBuffer,
LPCSTR  pszFileName 
)
static

SQLGetPrivateProfileString.

PURPOSE

This is an implementation of a common MS API call. This implementation should only be used if the ODBC sub-system/SDK does not have it. For example; unixODBC has its own so those using unixODBC should NOT be using this implementation because unixODBC;

  • provides caching of ODBC config data
  • provides consistent interpretation of ODBC config data (i.e, location)

ARGS

see ODBC documentation

RETURNS

see ODBC documentation

NOTES:

  • the spec is not entirely implemented... consider this a lite version
  • rules for determining the location of ODBC config may be different then what you expect see tdoGetIniFileName().

Definition at line 542 of file connectparams.c.

References ProfileParam::buffer, ProfileParam::buffer_len, ProfileParam::entry, ProfileParam::found, int, NULL, ProfileParam::ret_val, strlcpy, tdoGetIniFileName(), tdoParseProfile(), TDS_DBG_ERROR, TDS_DBG_FUNC, TDS_DBG_WARN, tds_read_conf_section, and tdsdump_log.

Referenced by myGetPrivateProfileString().

◆ tdoGetIniFileName()

static FILE * tdoGetIniFileName ( void  )
static

Call this to get the INI file containing Data Source Names.

Note
rules for determining the location of ODBC config may be different then what you expect - at this time they differ from unixODBC
Returns
file opened or NULL if error
Return values
1worked

Definition at line 596 of file connectparams.c.

References asprintf, free(), NULL, SYS_ODBC_INI, and tds_get_homedir.

Referenced by SQLGetPrivateProfileString().

◆ tdoParseProfile()

static void tdoParseProfile ( const char *  option,
const char *  value,
void *  param 
)
static
Modified on Thu Feb 29 12:16:52 2024 by modify_doxy.py rev. 669887