NCBI C++ ToolKit
Macros | Functions | Variables
Dynamic string functions

Handle dynamic string. More...

+ Collaboration diagram for Dynamic string functions:

Macros

#define DSTR_INITIALIZER   ((struct tds_dstr*) &tds_str_empty)
 Initializer, used to initialize string like in the following example. More...
 
#define tds_dstr_empty(s)    tds_dstr_free(s)
 Make a string empty. More...
 

Functions

static void tds_dstr_init (DSTR *s)
 init a string with empty More...
 
static int tds_dstr_isempty (DSTR *s)
 test if string is empty More...
 
static char * tds_dstr_buf (DSTR *s)
 Returns a buffer to edit the string. More...
 
static const char * tds_dstr_cstr (DSTR *s)
 Returns a C version (NUL terminated string) of dstr. More...
 
static size_t tds_dstr_len (DSTR *s)
 Returns the length of the string in bytes. More...
 
void tds_dstr_zero (DSTR *s)
 clear all string filling with zeroes (mainly for security reason) More...
 
void tds_dstr_free (DSTR *s)
 free string More...
 
DSTRtds_dstr_dup (DSTR *s, const DSTR *src)
 Duplicate a string from another dynamic string. More...
 
DSTRtds_dstr_copy (DSTR *s, const char *src)
 copy a string from another More...
 
DSTRtds_dstr_copyn (DSTR *s, const char *src, size_t length)
 Set string to a given buffer of characters. More...
 
DSTRtds_dstr_set (DSTR *s, char *src)
 set a string from another buffer. More...
 
DSTRtds_dstr_setlen (DSTR *s, size_t length)
 limit length of string, MUST be <= current length More...
 
DSTRtds_dstr_alloc (DSTR *s, size_t length)
 allocate space for length char More...
 

Variables

const struct tds_dstr tds_str_empty
 Internal representation for an empty string. More...
 

Detailed Description

Handle dynamic string.

In this string are always valid (you don't have NULL pointer, only empty strings)

Macro Definition Documentation

◆ DSTR_INITIALIZER

#define DSTR_INITIALIZER   ((struct tds_dstr*) &tds_str_empty)

Initializer, used to initialize string like in the following example.

#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition: string.h:37
Structure to hold a string.
Definition: tds.h:116

Definition at line 37 of file string.h.

◆ tds_dstr_empty

#define tds_dstr_empty (   s)     tds_dstr_free(s)

Make a string empty.

Definition at line 79 of file string.h.

Function Documentation

◆ tds_dstr_alloc()

DSTR * tds_dstr_alloc ( DSTR s,
size_t  length 
)

allocate space for length char

Parameters
sdynamic string
lengthnew length
Returns
string allocated or NULL on memory error

Definition at line 166 of file tdsstring.c.

References tds_dstr::dstr_s, tds_dstr::dstr_size, EMPTY, free(), malloc(), NULL, TDS_OFFSET, and TDS_UNLIKELY.

Referenced by odbc_stat_execute(), and tds_dstr_get().

◆ tds_dstr_buf()

static char* tds_dstr_buf ( DSTR s)
inlinestatic

Returns a buffer to edit the string.

Be careful to avoid buffer overflows and remember to set the correct length at the end of the editing if changed.

Definition at line 59 of file string.h.

Referenced by _SQLDriverConnect(), _SQLExecute(), dbcolname(), dbcolsource(), dbretname(), odbc_stat_execute(), odbc_upper_column_names(), prepare_call(), tds_dstr_get(), and to_native().

◆ tds_dstr_copy()

DSTR * tds_dstr_copy ( DSTR s,
const char *  src 
)

◆ tds_dstr_copyn()

DSTR * tds_dstr_copyn ( DSTR s,
const char *  src,
size_t  length 
)

Set string to a given buffer of characters.

Parameters
sdynamic string
srcsource buffer
lengthlength of source buffer
Returns
string copied or NULL on memory error

Definition at line 78 of file tdsstring.c.

References tds_dstr::dstr_s, tds_dstr::dstr_size, EMPTY, free(), malloc(), NULL, TDS_OFFSET, and TDS_UNLIKELY.

Referenced by blk_init(), change_database(), odbc_dstr_copy(), odbc_parse_connect_string(), odbc_stat_execute(), parse_server_name_for_port(), tds_dstr_copy(), and tds_dstr_dup().

◆ tds_dstr_cstr()

static const char* tds_dstr_cstr ( DSTR s)
inlinestatic

Returns a C version (NUL terminated string) of dstr.

Definition at line 66 of file string.h.

Referenced by _bcp_exec_out(), _blk_rowxfer_out(), _SQLConnect(), _SQLDescribeCol(), _SQLDriverConnect(), _SQLExecDirect(), _SQLExecute(), _SQLGetConnectAttr(), _SQLGetCursorName(), _SQLGetDescRec(), _SQLGetInfo(), _SQLGetStmtAttr(), _SQLNativeSql(), _SQLPrepare(), _SQLSetConnectAttr(), _SQLTables(), blk_describe(), ConfigDSN(), ct_con_props(), ct_describe(), ct_get_data(), dbcolinfo(), dbcoltablename(), dbperror(), dbprhead(), dbsprhead(), dbtablecolinfo(), DSNDlgProc(), LoginDlgProc(), main(), make_ntlm_v2_hash(), odbc_connect(), odbc_convert_char(), odbc_cursor_execute(), odbc_init_headers(), odbc_parse_connect_string(), odbc_populate_ird(), odbc_prepare(), odbc_quote_metadata(), odbc_sql2tds(), odbc_stat_execute(), paraminfoalloc(), parse_server_name_for_port(), reinit_results(), set_result_column(), tds5_process_dyn_result2(), tds5_process_result2(), tds71_do_login(), tds7_bcp_send_colmetadata(), tds7_build_bulk_insert_stmt(), tds7_build_param_def_from_params(), tds7_get_data_info(), tds7_process_result(), tds7_send_auth(), tds7_send_login(), tds_answer_challenge(), tds_answer_challenge_ntlmv2(), tds_bcp_init(), tds_bcp_start_insert_stmt(), tds_config_env_tdsdump(), tds_config_login(), tds_connect(), tds_cursor_update(), tds_ntlm_get_auth(), tds_parse_conf_section(), tds_process_info(), tds_process_param_result(), tds_put_data_info(), tds_read_conf_sections(), tds_read_config_info(), tds_send_emulated_rpc(), tds_send_login(), tdsdbopen(), test(), validate(), and write_all_strings().

◆ tds_dstr_dup()

DSTR * tds_dstr_dup ( DSTR s,
const DSTR src 
)

Duplicate a string from another dynamic string.

Parameters
soutput string
srcsource string to copy
Returns
string copied or NULL on memory error

Definition at line 135 of file tdsstring.c.

References tds_dstr::dstr_s, and tds_dstr_copyn().

Referenced by _SQLConnect(), _SQLDriverConnect(), odbc_build_update_params(), odbc_connect(), odbc_populate_ird(), odbc_stat_execute(), tds5_process_result2(), tds_bcp_init(), tds_config_login(), tds_read_conf_sections(), and tds_read_config_info().

◆ tds_dstr_free()

void tds_dstr_free ( DSTR s)

◆ tds_dstr_init()

static void tds_dstr_init ( DSTR s)
inlinestatic

init a string with empty

Definition at line 41 of file string.h.

References DSTR_INITIALIZER.

Referenced by _SQLAllocConnect(), _SQLAllocStmt(), alloc_dsninfo(), tds_alloc_bcpinfo(), tds_alloc_column(), and tds_alloc_login().

◆ tds_dstr_isempty()

static int tds_dstr_isempty ( DSTR s)
inlinestatic

◆ tds_dstr_len()

static size_t tds_dstr_len ( DSTR s)
inlinestatic

◆ tds_dstr_set()

DSTR * tds_dstr_set ( DSTR s,
char *  src 
)

set a string from another buffer.

The string will use the supplied buffer (it not copy the string), so it should be a pointer returned by malloc.

Parameters
sdynamic string
srcsource buffer
Returns
string copied or NULL on memory error

Definition at line 108 of file tdsstring.c.

References free(), NULL, tds_dstr_copy(), and TDS_LIKELY.

Referenced by _SQLAllocStmt(), _SQLTables(), and tds_config_env_tdsdump().

◆ tds_dstr_setlen()

DSTR * tds_dstr_setlen ( DSTR s,
size_t  length 
)

limit length of string, MUST be <= current length

Parameters
sdynamic string
lengthnew length

Definition at line 146 of file tdsstring.c.

References assert, and EMPTY.

Referenced by odbc_stat_execute(), prepare_call(), tds_dstr_get(), and to_native().

◆ tds_dstr_zero()

void tds_dstr_zero ( DSTR s)

clear all string filling with zeroes (mainly for security reason)

Definition at line 56 of file tdsstring.c.

Referenced by tds_config_login(), tds_free_login(), and tds_set_passwd().

Variable Documentation

◆ tds_str_empty

const struct tds_dstr tds_str_empty
extern

Internal representation for an empty string.

Definition at line 1 of file tdsstring.c.

Modified on Wed Feb 21 09:56:23 2024 by modify_doxy.py rev. 669887