NCBI C++ ToolKit
Classes | Macros | Enumerations | Functions | Variables
common.c File Reference
#include "common.h"
#include <ctype.h>
#include <freetds/sysdep_private.h>
#include <freetds/odbc.h>
#include <common/test_assert.h>
+ Include dependency graph for common.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

union  long_sockaddr
 

Macros

#define FOR_ALL_SOCKETS(i)   for (i = 3; i < 1024; ++i)
 

Enumerations

enum  { NUM_FDS = 4096*4 }
 

Functions

static int check_lib (char *path, const char *file)
 
void odbc_setenv (const char *name, const char *value, int overwrite)
 
int odbc_read_login_info (void)
 
void odbc_report_error (const char *errmsg, int line, const char *file)
 
static void ReportODBCError (const char *errmsg, SQLSMALLINT handletype, SQLHANDLE handle, SQLRETURN rc, int line, const char *file)
 
int odbc_connect (void)
 
int odbc_disconnect (void)
 
SQLRETURN odbc_command_with_result (HSTMT stmt, const char *command)
 
int odbc_db_is_microsoft (void)
 
int odbc_driver_is_freetds (void)
 
static int odbc_tds_version_long (void)
 
int odbc_tds_version (void)
 
const char * odbc_db_version (void)
 
unsigned int odbc_db_version_int (void)
 
void odbc_check_cols (int n, int line, const char *file)
 
void odbc_check_rows (int n, int line, const char *file)
 
void odbc_reset_statement_proc (SQLHSTMT *stmt, const char *file, int line)
 
void odbc_test_skipped (void)
 
void odbc_check_cursor (void)
 
SQLRETURN odbc_check_res (const char *file, int line, SQLRETURN rc, SQLSMALLINT handle_type, SQLHANDLE handle, const char *func, const char *res)
 
SQLSMALLINT odbc_alloc_handle_err_type (SQLSMALLINT type)
 
SQLRETURN odbc_command_proc (HSTMT stmt, const char *command, const char *file, int line, const char *res)
 
void odbc_read_error (void)
 
SQLINTEGER odbc_to_sqlwchar (SQLWCHAR *dst, const char *src, SQLINTEGER n)
 
SQLINTEGER odbc_from_sqlwchar (char *dst, const SQLWCHAR *src, SQLINTEGER n)
 
void * odbc_buf_get (ODBC_BUF **buf, size_t s)
 
void odbc_buf_free (ODBC_BUF **buf)
 
SQLWCHARodbc_get_sqlwchar (ODBC_BUF **buf, const char *s)
 
char * odbc_get_sqlchar (ODBC_BUF **buf, SQLWCHAR *s)
 
static int fd_is_socket (int fd)
 
static int mark_fd (int fd)
 
void odbc_mark_sockets_opened (void)
 
TDS_SYS_SOCKET odbc_find_last_socket (void)
 
void odbc_check_no_row (const char *query)
 

Variables

HENV odbc_env
 
HDBC odbc_conn
 
HSTMT odbc_stmt
 
int odbc_use_version3 = 0
 
void(* odbc_set_conn_attr )(void) = NULL
 
char odbc_user [512]
 
char odbc_server [512]
 
char odbc_password [512]
 
char odbc_database [512]
 
char odbc_driver [1024]
 
static const char *const search_driver []
 
static int ms_db = -1
 
static int freetds_driver = -1
 
static char db_str_version [32]
 
char odbc_err [512]
 
char odbc_sqlstate [6]
 
ODBC_BUFodbc_buf = NULL
 
static unsigned char fd_bitmask [NUM_FDS/8]
 

Macro Definition Documentation

◆ FOR_ALL_SOCKETS

#define FOR_ALL_SOCKETS (   i)    for (i = 3; i < 1024; ++i)

Definition at line 786 of file common.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NUM_FDS 

Definition at line 764 of file common.c.

Function Documentation

◆ check_lib()

static int check_lib ( char *  path,
const char *  file 
)
static

Definition at line 44 of file common.c.

References f(), file, len, and strcat.

Referenced by odbc_read_login_info().

◆ fd_is_socket()

static int fd_is_socket ( int  fd)
static

Definition at line 739 of file common.c.

References long_sockaddr::sa, tds_getpeername, and tds_getsockname.

Referenced by odbc_find_last_socket(), and odbc_mark_sockets_opened().

◆ mark_fd()

static int mark_fd ( int  fd)
static

Definition at line 768 of file common.c.

References fd_bitmask, mask, and NUM_FDS.

Referenced by odbc_find_last_socket(), and odbc_mark_sockets_opened().

◆ odbc_alloc_handle_err_type()

SQLSMALLINT odbc_alloc_handle_err_type ( SQLSMALLINT  type)

Definition at line 609 of file common.c.

References SQL_HANDLE_DBC, SQL_HANDLE_DESC, SQL_HANDLE_ENV, and SQL_HANDLE_STMT.

◆ odbc_buf_free()

void odbc_buf_free ( ODBC_BUF **  buf)

Definition at line 693 of file common.c.

References buf, odbc_buf::buf, free(), next(), odbc_buf::next, and NULL.

◆ odbc_buf_get()

void* odbc_buf_get ( ODBC_BUF **  buf,
size_t  s 
)

Definition at line 681 of file common.c.

References assert, buf, odbc_buf::buf, calloc(), malloc(), and odbc_buf::next.

Referenced by odbc_get_sqlchar(), and odbc_get_sqlwchar().

◆ odbc_check_cols()

void odbc_check_cols ( int  n,
int  line,
const char *  file 
)

Definition at line 496 of file common.c.

References CHKNumResultCols, exit(), file, n, and odbc_disconnect().

◆ odbc_check_cursor()

void odbc_check_cursor ( void  )

◆ odbc_check_no_row()

void odbc_check_no_row ( const char *  query)

◆ odbc_check_res()

SQLRETURN odbc_check_res ( const char *  file,
int  line,
SQLRETURN  rc,
SQLSMALLINT  handle_type,
SQLHANDLE  handle,
const char *  func,
const char *  res 
)

◆ odbc_check_rows()

void odbc_check_rows ( int  n,
int  line,
const char *  file 
)

Definition at line 513 of file common.c.

References CHKRowCount, exit(), file, n, odbc_disconnect(), and SQLLEN.

◆ odbc_command_proc()

SQLRETURN odbc_command_proc ( HSTMT  stmt,
const char *  command,
const char *  file,
int  line,
const char *  res 
)

Definition at line 623 of file common.c.

References command, file, NULL, odbc_check_res(), ODBC_FREE, SQL_HANDLE_STMT, SQL_NTS, SQLExecDirect(), stmt, and T.

◆ odbc_command_with_result()

SQLRETURN odbc_command_with_result ( HSTMT  stmt,
const char *  command 
)

Definition at line 312 of file common.c.

References command, NULL, ODBC_FREE, SQL_NTS, SQLExecDirect(), stmt, and T.

Referenced by DoTest(), main(), query_test(), Test(), and TestRawODBCGuid().

◆ odbc_connect()

int odbc_connect ( void  )

◆ odbc_db_is_microsoft()

int odbc_db_is_microsoft ( void  )

◆ odbc_db_version()

const char* odbc_db_version ( void  )

Definition at line 468 of file common.c.

References buf, C, CHKR, db_str_version, NULL, odbc_conn, ODBC_FREE, SQL_DBMS_VER, and SQLGetInfo().

Referenced by AllTests(), DoTest(), and odbc_db_version_int().

◆ odbc_db_version_int()

unsigned int odbc_db_version_int ( void  )

Definition at line 483 of file common.c.

References exit(), odbc_db_version(), and odbc_disconnect().

Referenced by AllTests(), DoTest(), and main().

◆ odbc_disconnect()

int odbc_disconnect ( void  )

◆ odbc_driver_is_freetds()

int odbc_driver_is_freetds ( void  )

◆ odbc_find_last_socket()

TDS_SYS_SOCKET odbc_find_last_socket ( void  )

◆ odbc_from_sqlwchar()

SQLINTEGER odbc_from_sqlwchar ( char *  dst,
const SQLWCHAR src,
SQLINTEGER  n 
)

Definition at line 663 of file common.c.

References assert, i, n, and SQLLEN.

Referenced by odbc_get_sqlchar(), and readBlobAsChar().

◆ odbc_get_sqlchar()

char* odbc_get_sqlchar ( ODBC_BUF **  buf,
SQLWCHAR s 
)

Definition at line 719 of file common.c.

References buf, n, odbc_buf_get(), odbc_from_sqlwchar(), and out().

Referenced by extract_error().

◆ odbc_get_sqlwchar()

SQLWCHAR* odbc_get_sqlwchar ( ODBC_BUF **  buf,
const char *  s 
)

Definition at line 706 of file common.c.

References buf, buffer, NULL, odbc_buf_get(), and odbc_to_sqlwchar().

Referenced by main().

◆ odbc_mark_sockets_opened()

void odbc_mark_sockets_opened ( void  )

Definition at line 790 of file common.c.

References fd_bitmask, fd_is_socket(), FOR_ALL_SOCKETS, i, and mark_fd().

◆ odbc_read_error()

void odbc_read_error ( void  )

Definition at line 638 of file common.c.

References C, CHKGetDiagRec, NULL, odbc_err, ODBC_FREE, ODBC_GET, odbc_sqlstate, odbc_stmt, and SQL_HANDLE_STMT.

Referenced by main(), query_test(), test(), and test_err().

◆ odbc_read_login_info()

int odbc_read_login_info ( void  )

◆ odbc_report_error()

void odbc_report_error ( const char *  errmsg,
int  line,
const char *  file 
)

◆ odbc_reset_statement_proc()

void odbc_reset_statement_proc ( SQLHSTMT stmt,
const char *  file,
int  line 
)

◆ odbc_setenv()

void odbc_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 62 of file common.c.

References buf, putenv, and value.

◆ odbc_tds_version()

int odbc_tds_version ( void  )

◆ odbc_tds_version_long()

static int odbc_tds_version_long ( void  )
static

◆ odbc_test_skipped()

void odbc_test_skipped ( void  )

Definition at line 539 of file common.c.

References exit().

Referenced by main(), and odbc_check_cursor().

◆ odbc_to_sqlwchar()

SQLINTEGER odbc_to_sqlwchar ( SQLWCHAR dst,
const char *  src,
SQLINTEGER  n 
)

Definition at line 654 of file common.c.

References i, n, and SQLLEN.

Referenced by main(), and odbc_get_sqlwchar().

◆ ReportODBCError()

static void ReportODBCError ( const char *  errmsg,
SQLSMALLINT  handletype,
SQLHANDLE  handle,
SQLRETURN  rc,
int  line,
const char *  file 
)
static

Variable Documentation

◆ db_str_version

char db_str_version[32]
static

Definition at line 466 of file common.c.

Referenced by odbc_db_version().

◆ fd_bitmask

unsigned char fd_bitmask[NUM_FDS/8]
static

Definition at line 765 of file common.c.

Referenced by mark_fd(), and odbc_mark_sockets_opened().

◆ freetds_driver

int freetds_driver = -1
static

Definition at line 343 of file common.c.

Referenced by odbc_driver_is_freetds().

◆ ms_db

int ms_db = -1
static

Definition at line 323 of file common.c.

Referenced by odbc_db_is_microsoft().

◆ odbc_buf

Definition at line 678 of file common.c.

◆ odbc_conn

HDBC odbc_conn

◆ odbc_database

char odbc_database[512]

Definition at line 40 of file common.c.

Referenced by main(), odbc_connect(), and odbc_read_login_info().

◆ odbc_driver

char odbc_driver[1024]

Definition at line 41 of file common.c.

Referenced by main(), and odbc_read_login_info().

◆ odbc_env

HENV odbc_env

◆ odbc_err

char odbc_err[512]

Definition at line 634 of file common.c.

Referenced by main(), odbc_read_error(), query_test(), ReadErrorConn(), and test().

◆ odbc_password

char odbc_password[512]

Definition at line 39 of file common.c.

Referenced by main(), my_attrs(), normal_connect(), odbc_connect(), and odbc_read_login_info().

◆ odbc_server

char odbc_server[512]

Definition at line 38 of file common.c.

Referenced by main(), normal_connect(), odbc_connect(), and odbc_read_login_info().

◆ odbc_set_conn_attr

void(* odbc_set_conn_attr) (void) ( void  ) = NULL

Definition at line 35 of file common.c.

Referenced by ConnectWithTxn(), main(), and odbc_connect().

◆ odbc_sqlstate

char odbc_sqlstate[6]

Definition at line 635 of file common.c.

Referenced by main(), odbc_read_error(), query_test(), ReadErrorConn(), and test_err().

◆ odbc_stmt

HSTMT odbc_stmt

◆ odbc_use_version3

int odbc_use_version3 = 0

Definition at line 34 of file common.c.

Referenced by DoTest(), main(), odbc_connect(), test(), and Test().

◆ odbc_user

char odbc_user[512]

Definition at line 37 of file common.c.

Referenced by main(), normal_connect(), odbc_connect(), and odbc_read_login_info().

◆ search_driver

const char* const search_driver[]
static
Initial value:
= {
".libs/libtdsodbc.so",
".libs/libtdsodbc.sl",
".libs/libtdsodbc.dylib",
".libs/libtdsodbc.dll",
"_libs/libtdsodbc.dll",
"debug/tdsodbc.dll",
"release/tdsodbc.dll",
"libtdsodbc.so",
"tdsodbc.dll",
}
#define NULL
Definition: ncbistd.hpp:225

Definition at line 74 of file common.c.

Referenced by odbc_read_login_info().

Modified on Sat Mar 02 10:56:24 2024 by modify_doxy.py rev. 669887