Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions include/cspublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,15 @@ CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx);
CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen,
CS_CHAR * formats, CS_INT formatlen, ...);
#undef cs_dt_crack
#ifndef cs_dt_crack_v2
# undef cs_dt_crack
#endif
CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
#define cs_dt_crack cs_dt_crack_v2
#ifndef _FREETDS_LIBRARY_SOURCE
# undef cs_dt_crack
# define cs_dt_crack cs_dt_crack_v2
#endif
Comment on lines -810 to +815
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the previous style. Shorter and does not require adding a new _FREETDS_LIBRARY_SOURCE definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, but it interacts poorly with mass renaming (e.g., tacking on _ftds14 suffixes across the board) that would otherwise allow coexistence with commercial MS/SAP libraries and/or other analogously patched FreeTDS versions. I'm obviously not proposing to push any such renaming, just the changes that make it fully possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the need for mass renaming. I don't think it's possible to use both proprietary library and FreeTDS without breaking ABI (Windows and ODBC excluded), the 2 libraries will clash.
Usually to allow this usually libraries use symbol prefixes instead of suffix (for instance adding ftds_ before all exported functions, I know libiconv is adding lib prefix to functions).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a special case -- the C++ Toolkit performs mass renaming for the FreeTDS versions it bundles, with each version's wrapper in a separate namespace but all wrappers implementing the same base classes.

Copy link
Contributor

@freddy77 freddy77 Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using dynamic linking (and loading) of different versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To accommodate binaries that link non-system libraries statically for ease of deployment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this and dbopen and cs_dt_crack. They are provided to keep ABI compatibility. But if you link statically code should not use them at all. So in case of static building they should not be compiled or even declared.
If I understood how this renaming is done you have a lot of different defines like

#define dbconvert dbconvert_ftds15
#define dbconvert_ps dbconvert_ps_ftds15
...

so you want to avoid the #undefs. Is that right?

CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr);
CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale);
CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen,
Expand Down
6 changes: 3 additions & 3 deletions include/ctlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ struct _cs_locale

/* internal defines for cursor processing */

#define _CS_CURS_TYPE_UNACTIONED 0
#define _CS_CURS_TYPE_REQUESTED 1
#define _CS_CURS_TYPE_SENT 2
#define _CS_CURS_TYPE_UNACTIONED TDS_CURSOR_STATE_UNACTIONED
#define _CS_CURS_TYPE_REQUESTED TDS_CURSOR_STATE_REQUESTED
#define _CS_CURS_TYPE_SENT TDS_CURSOR_STATE_SENT

typedef struct {
CS_CHAR name[132];
Expand Down
2 changes: 1 addition & 1 deletion include/dblib.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef struct dboption
typedef struct
{
const BYTE *bindval;
size_t len;
unsigned int len;
} NULLREP;

struct tds_dblib_dbprocess
Expand Down
3 changes: 2 additions & 1 deletion include/freetds/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ CONV_RESULT;
unsigned char tds_willconvert(int srctype, int desttype);

TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype);
TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
ptrdiff_t tds_char2hex(TDS_CHAR *dest, size_t destlen,
const TDS_CHAR * src, size_t srclen);
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const void *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr);

size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
Expand Down
29 changes: 18 additions & 11 deletions include/freetds/odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ typedef struct {

TDS_DESC *desc_alloc(SQLHANDLE parent, int desc_type, SQLSMALLINT alloc_type);
SQLRETURN desc_free(TDS_DESC * desc);
SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count);
SQLRETURN desc_alloc_records(TDS_DESC * desc, SQLSMALLINT count);
SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src);
SQLRETURN desc_free_records(TDS_DESC * desc);
TDS_DBC *desc_get_dbc(TDS_DESC *desc);
Expand Down Expand Up @@ -641,7 +641,8 @@ typedef union {
# define _WIDE
# define ODBC_CHAR SQLCHAR
#endif
SQLRETURN odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
SQLRETURN odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql,
ptrdiff_t sql_len _WIDE);
void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row);
void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row);

Expand All @@ -651,25 +652,29 @@ int odbc_sql_to_c_type_default(int sql_type);
TDS_SERVER_TYPE odbc_sql_to_server_type(TDSCONNECTION * conn, int sql_type, int sql_unsigned);
TDS_SERVER_TYPE odbc_c_to_server_type(int c_type);

unsigned int odbc_get_string_size(int size, const ODBC_CHAR * str _WIDE);
size_t odbc_get_string_size(ptrdiff_t size, const ODBC_CHAR * str _WIDE);
void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string);
SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd,
const TDS_DESC* axd, unsigned int n_row);
SQLLEN odbc_get_param_len(const struct _drecord *drec_axd,
const struct _drecord *drec_ixd,
const TDS_DESC* axd, SQLSETPOSIROW n_row);

#ifdef ENABLE_ODBC_WIDE
DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str, int flag);
DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, ptrdiff_t size,
const ODBC_CHAR * str, int flag);
#define odbc_dstr_copy(dbc, s, len, out) \
odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide)
#define odbc_dstr_copy_oct(dbc, s, len, out) \
odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20)
#else
DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str);
DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, ptrdiff_t size,
const ODBC_CHAR * str);
#define odbc_dstr_copy_oct odbc_dstr_copy
#endif


SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer,
const char *s, int len, int flag);
SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer,
SQLINTEGER cbBuffer, void FAR * pcbBuffer,
const char *s, ptrdiff_t len, int flag);
#ifdef ENABLE_ODBC_WIDE
#define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, \
Expand Down Expand Up @@ -709,8 +714,10 @@ const char *odbc_skip_rpc_name(const char *s);
/*
* sql2tds.c
*/
SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol,
bool compute_row, const TDS_DESC* axd, unsigned int n_row);
SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd,
const struct _drecord *drec_axd, TDSCOLUMN *curcol,
bool compute_row, const TDS_DESC* axd,
SQLSETPOSIROW n_row);
TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIMEALL * dta);

/*
Expand Down
45 changes: 29 additions & 16 deletions include/freetds/tds.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ extern const char *const tds_type_names[256];


#define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
#define is_blob_col(x) ((x)->column_varint_size > 2)
#define is_blob_col(x) (is_blob_type((x)->column_type) \
|| ((x)->column_varint_size == 8) \
|| ((x)->column_type == SYBVARIANT \
&& (x)->column_varint_size == 4))
/* large type means it has a two byte size field */
/* define is_large_type(x) (x>128) */
#define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
Expand Down Expand Up @@ -1348,7 +1351,7 @@ tds_release_cur_dyn(TDSSOCKET * tds)
}
void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn);
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn);
TDSSOCKET *tds_realloc_socket(TDSSOCKET * tds, size_t bufsize);
TDSSOCKET *tds_realloc_socket(TDSSOCKET * tds, unsigned int bufsize);
char *tds_alloc_client_sqlstate(int msgno);
char *tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno);
TDSLOGIN *tds_alloc_login(bool use_environment);
Expand All @@ -1358,7 +1361,8 @@ TDSLOGIN *tds_init_login(TDSLOGIN * login, TDSLOCALE * locale);
TDSLOCALE *tds_alloc_locale(void);
void *tds_alloc_param_data(TDSCOLUMN * curparam);
void tds_free_locale(TDSLOCALE * locale);
TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen);
TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, size_t namelen,
const char *query, size_t querylen);
void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row);
TDSSOCKET *tds_alloc_socket(TDSCONTEXT * context, unsigned int bufsize);
TDSSOCKET *tds_alloc_additional_socket(TDSCONNECTION *conn);
Expand Down Expand Up @@ -1415,13 +1419,17 @@ TDSRET tds_submit_begin_tran(TDSSOCKET *tds);
TDSRET tds_submit_rollback(TDSSOCKET *tds, bool cont);
TDSRET tds_submit_commit(TDSSOCKET *tds, bool cont);
TDSRET tds_disconnect(TDSSOCKET * tds);
size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen);
size_t tds_quote_id_rpc(TDSSOCKET * tds, char *buffer, const char *id, int idlen);
size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len);
size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id,
ptrdiff_t idlen);
size_t tds_quote_id_rpc(TDSSOCKET * tds, char *buffer, const char *id,
ptrdiff_t idlen);
size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str,
ptrdiff_t len);
const char *tds_skip_comment(const char *s);
const char *tds_skip_quoted(const char *s);
size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol);
const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv, const char *s, int len, size_t *out_len);
const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv,
const char *s, ptrdiff_t len, size_t *out_len);
void tds_convert_string_free(const char *original, const char *converted);
#if !ENABLE_EXTRA_CHECKS
#define tds_convert_string_free(original, converted) \
Expand Down Expand Up @@ -1519,10 +1527,12 @@ int tdsdump_isopen(void);
int tdsdump_open(const tds_dir_char *filename);
#include <freetds/pushvis.h>
void tdsdump_close(void);
void tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, const void *buf, size_t length);
void tdsdump_do_dump_buf(const char* file, unsigned int level_line,
const char *msg, const void *buf, size_t length);
void tdsdump_col(const TDSCOLUMN *col);
#undef tdsdump_log
void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...)
void tdsdump_do_log(const char* file, unsigned int level_line,
const char *fmt, ...)
Comment on lines -1525 to +1535
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is an ABI and must be exported with this name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought tds* were generally internal; I do see that libsybdb exposes tdsdump_open, but that function's not in play here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, usually yes. BTW, it's only tdsdump_open (and tdsdbopen) that are in ABI, so tdsdump_log can be changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you rename this function? I mean, specifically tdsdump_log -> tdsdump_do_log? The addition of _do_ seems odd to me, all functions do something. It looks like some kind of name clash avoidance. Maybe to avoid the same name macro and function? Maybe tdsdump_log_impl ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, tdsdump_log_impl is a better name; thanks for the suggestion!

#if defined(__GNUC__) && __GNUC__ >= 2
#if defined(__MINGW32__)
__attribute__ ((__format__ (ms_printf, 3, 4)))
Expand All @@ -1531,9 +1541,9 @@ void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...
#endif
#endif
;
#define TDSDUMP_LOG_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log
#define TDSDUMP_LOG_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_do_log
#define tdsdump_log TDSDUMP_LOG_FAST
#define TDSDUMP_BUF_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_dump_buf
#define TDSDUMP_BUF_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_do_dump_buf
#define tdsdump_dump_buf TDSDUMP_BUF_FAST

extern bool tds_write_dump;
Expand All @@ -1548,14 +1558,17 @@ int tds7_get_instance_ports(FILE *output, struct addrinfo *addr);
int tds7_get_instance_port(struct addrinfo *addr, const char *instance);
char *tds_prwsaerror(int erc);
void tds_prwsaerror_free(char *s);
int tds_connection_read(TDSSOCKET * tds, unsigned char *buf, int buflen);
int tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, int buflen, int final);
ptrdiff_t tds_connection_read(TDSSOCKET * tds, unsigned char *buf,
size_t buflen);
ptrdiff_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf,
size_t buflen, int final);
#define TDSSELREAD POLLIN
#define TDSSELWRITE POLLOUT
int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds);
void tds_connection_close(TDSCONNECTION *conn);
int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen);
int tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t buflen);
ptrdiff_t tds_goodread(TDSSOCKET * tds, unsigned char *buf, size_t buflen);
ptrdiff_t tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer,
size_t buflen);
void tds_socket_flush(TDS_SYS_SOCKET sock);
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock);
int tds_wakeup_init(TDSPOLLWAKEUP *wakeup);
Expand Down Expand Up @@ -1591,7 +1604,7 @@ typedef struct tds_freeze {
} TDSFREEZE;

void tds_freeze(TDSSOCKET *tds, TDSFREEZE *freeze, unsigned size_len);
size_t tds_freeze_written(TDSFREEZE *freeze);
unsigned int tds_freeze_written(TDSFREEZE *freeze);
TDSRET tds_freeze_abort(TDSFREEZE *freeze);
TDSRET tds_freeze_close(TDSFREEZE *freeze);
TDSRET tds_freeze_close_string(TDSFREEZE *freeze);
Expand Down
3 changes: 2 additions & 1 deletion include/freetds/utils/des.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void tds_des_encrypt(const DES_KEY * key, des_cblock block);
#endif

void tds_des_set_odd_parity(des_cblock key);
int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, uint8_t *output);
int tds_des_ecb_encrypt(const void *plaintext, size_t len, DES_KEY * akey,
uint8_t *output);

#include <freetds/popvis.h>

Expand Down
3 changes: 3 additions & 0 deletions include/sybdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,14 @@ RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, D

DBPIVOT_FUNC dbpivot_lookup_name( const char name[] );

#ifndef _FREETDS_LIBRARY_SOURCE
#undef dbopen
#ifdef MSDBLIB
#define dbopen(x,y) tdsdbopen((x),(y), 1)
#else
#define dbopen(x,y) tdsdbopen((x),(y), 0)
#endif
#endif

/* fix PHP problem */
#ifdef PHP_SYBASE_DBOPEN
Expand Down
4 changes: 2 additions & 2 deletions misc/types.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ SYBINT4;ALL;0;1;0;0;0;0;0;0;0;0;4;SYBINTN;11;0;1;
SYBINT8;MS;0;1;0;0;0;0;0;0;0;0;8;SYBINTN;20;0;1;
SYBINTERVAL;SYB;0;1;0;0;0;0;0;0;0;0;8;0;;0;0;
SYBINTN;ALL;1;0;1;0;0;0;0;0;0;0;-1;0;;0;1;
SYBLONGBINARY;SYB;5;0;1;1;1;0;0;Depend;Depend;0;-1;0;2*S;1;0;
SYBLONGCHAR;SYB;5;0;1;1;1;0;0;??;1;0;-1;0;S;0;0;
SYBLONGBINARY;SYB;4;0;1;1;1;0;0;Depend;Depend;0;-1;0;2*S;1;0;
SYBLONGCHAR;SYB;4;0;1;1;1;0;0;??;1;0;-1;0;S;0;0;
SYBMONEY;ALL;0;1;0;0;0;0;0;0;0;0;8;SYBMONEYN;21;0;1;
SYBMONEY4;ALL;0;1;0;0;0;0;0;0;0;0;4;SYBMONEYN;12;0;1;
SYBMONEYN;ALL;1;0;1;0;0;0;0;0;0;0;-1;0;;0;1;
Expand Down
2 changes: 2 additions & 0 deletions src/ctlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ add_library(ct SHARED
)

target_compile_definitions(ct PUBLIC DLL_EXPORT=1)
target_compile_definitions(ct PRIVATE _FREETDS_LIBRARY_SOURCE)
target_link_libraries(ct tds replacements tdsutils ${lib_NETWORK} ${lib_BASE})

add_library(ct-static STATIC
ct.c cs.c blk.c ctutil.c
)
target_compile_definitions(ct-static PRIVATE _FREETDS_LIBRARY_SOURCE)
# See http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
SET_TARGET_PROPERTIES(ct-static PROPERTIES OUTPUT_NAME ${static_lib_name})
SET_TARGET_PROPERTIES(ct PROPERTIES CLEAN_DIRECT_OUTPUT 1)
Expand Down
2 changes: 1 addition & 1 deletion src/ctlib/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SUBDIRS = . unittests
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_srcdir)/include -D_FREETDS_LIBRARY_SOURCE

lib_LTLIBRARIES = libct.la
libct_la_SOURCES= ct.c cs.c blk.c ctutil.c ct_small_checks.c ct_large_checks.c ct_checks.h
Expand Down
2 changes: 1 addition & 1 deletion src/ctlib/blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ blk_describe(CS_BLKDESC * blkdesc, CS_INT item, CS_DATAFMT * datafmt_arg)
curcol = blkdesc->bcpinfo.bindinfo->columns[item - 1];
/* name is always null terminated */
strlcpy(datafmt->name, tds_dstr_cstr(&curcol->column_name), sizeof(datafmt->name));
datafmt->namelen = strlen(datafmt->name);
datafmt->namelen = (CS_INT) strlen(datafmt->name);
/* need to turn the SYBxxx into a CS_xxx_TYPE */
datatype = _ct_get_client_type(curcol, true);
if (datatype == CS_ILLEGAL_TYPE)
Expand Down
19 changes: 11 additions & 8 deletions src/ctlib/cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#include "cspublic.h"
#include "ctlib.h"

#undef cs_dt_crack

static CS_INT cs_diag_storemsg(CS_CONTEXT *context, CS_CLIENTMSG *message);
static CS_INT cs_diag_clearmsg(CS_CONTEXT *context, CS_INT type);
static CS_INT cs_diag_getmsg(CS_CONTEXT *context, CS_INT idx, CS_CLIENTMSG *message);
Expand Down Expand Up @@ -1128,7 +1126,8 @@ cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_V

switch (type) {
case CS_SYB_CHARSET:
tlen = (locale->charset ? strlen(locale->charset) : 0) + 1;
tlen = (locale->charset ? (int) strlen(locale->charset)
: 0) + 1;
if (buflen < tlen)
{
if (outlen)
Expand All @@ -1143,7 +1142,8 @@ cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_V
break;

case CS_SYB_LANG:
tlen = (locale->language ? strlen(locale->language) : 0) + 1;
tlen = (locale->language ?
(int) strlen(locale->language) : 0) + 1;
if (buflen < tlen)
{
if (outlen)
Expand All @@ -1161,8 +1161,10 @@ cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_V
{
int clen;

tlen = (locale->language ? strlen(locale->language) : 0) + 1;
clen = (locale->charset ? strlen(locale->charset) : 0) + 1;
tlen = (locale->language ?
(int) strlen(locale->language) : 0) + 1;
clen = (locale->charset ?
(int) strlen(locale->charset) : 0) + 1;

if (buflen < (tlen + clen))
{
Expand All @@ -1176,15 +1178,16 @@ cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_V
((char *)buffer)[0] = '\0';
strcat((char *)buffer, ".");
if (locale->charset) {
tlen = strlen((char *)buffer);
tlen = (int) strlen((char *)buffer);
strcpy((char *)buffer + tlen, locale->charset);
}
code = CS_SUCCEED;
break;
}

case CS_SYB_SORTORDER:
tlen = (locale->collate ? strlen(locale->collate) : 0) + 1;
tlen = (locale->collate ? (int) strlen(locale->collate)
: 0) + 1;
if (buflen < tlen)
{
if (outlen)
Expand Down
Loading
Loading