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

Handle dynamic string. More...

+ Collaboration diagram for Dynamic string functions:

Classes

struct  tds_dstr
 Structure to hold a string. More...
 

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

Typedefs

typedef struct tds_dstrDSTR
 Structure to hold a string. 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...
 
static int tds_dstr_isempty (const DSTR *s)
 test if string is empty More...
 
static const char * tds_dstr_cstr (const DSTR *s)
 Returns a C version (NUL terminated string) of dstr. More...
 
static size_t tds_dstr_len (const DSTR *s)
 Returns the length of the string in bytes. More...
 

Variables

const struct tds_dstr tds_str_empty
 Internal representation for an empty string. More...
 
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 [1/2]

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

◆ DSTR_INITIALIZER [2/2]

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

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

Definition at line 49 of file string.h.

◆ tds_dstr_empty [1/2]

#define tds_dstr_empty (   s)     tds_dstr_free(s)

Make a string empty.

Definition at line 79 of file string.h.

◆ tds_dstr_empty [2/2]

#define tds_dstr_empty (   s)     tds_dstr_free(s)

Make a string empty.

Definition at line 91 of file string.h.

Typedef Documentation

◆ DSTR

typedef struct tds_dstr * DSTR

Structure to hold a string.

Use tds_dstr_* functions/macros, do not access members directly. There should be always a buffer.

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(), parse_value(), 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(), parse_value(), 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(), parse_value(), tds_dstr_copy(), and tds_dstr_dup().

◆ tds_dstr_cstr() [1/2]

static const char* tds_dstr_cstr ( const DSTR s)
inlinestatic

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

Definition at line 78 of file string.h.

◆ tds_dstr_cstr() [2/2]

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(), assert_equal_dstr(), blk_describe(), ConfigDSN(), ct_con_props(), ct_describe(), ct_get_data(), dbacolname(), dbcolinfo(), dbcoltablename(), dbperror(), dbprhead(), dbsprhead(), dbtablecolinfo(), DSNDlgProc(), LoginDlgProc(), main(), make_ntlm_v2_hash(), odbc_connect(), odbc_convert_char(), odbc_convert_table(), 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(), prepared_rpc(), reinit_results(), set_result_column(), tds4_send_emulated_rpc(), tds5_bcp_add_fixed_columns(), tds5_process_dyn_result2(), tds5_process_insert_bulk_reply(), 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(), tds7_write_param_def_from_params(), 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_parse_login_results(), 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(), tds_setup_connection(), tdsdbopen(), test(), test0(), 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(), tds_alloc_login(), and tvp_alloc().

◆ tds_dstr_isempty() [1/2]

static int tds_dstr_isempty ( const DSTR s)
inlinestatic

test if string is empty

Definition at line 60 of file string.h.

◆ tds_dstr_isempty() [2/2]

static int tds_dstr_isempty ( DSTR s)
inlinestatic

◆ tds_dstr_len() [1/2]

static size_t tds_dstr_len ( const DSTR s)
inlinestatic

Returns the length of the string in bytes.

Definition at line 85 of file string.h.

◆ tds_dstr_len() [2/2]

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(), tds_config_env_tdsdump(), and tds_connect().

◆ 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(), parse_value(), 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 [1/2]

const struct tds_dstr tds_str_empty
extern

Internal representation for an empty string.

Definition at line 1 of file tdsstring.c.

◆ tds_str_empty [2/2]

const struct tds_dstr tds_str_empty
extern

Internal representation for an empty string.

Definition at line 1 of file tdsstring.c.

Modified on Mon Jun 17 05:08:05 2024 by modify_doxy.py rev. 669887