25 #include <freetds/time.h>
40 #include "replacements.h"
50 static char unknown[24];
77 sprintf(unknown,
"oops: %u ??", retcode);
89 return "cslib user api layer";
94 return "unrecognized layer";
104 return "external error";
107 return "internal CS-Library error";
110 return "common library error";
113 return "intl library error";
118 return "unrecognized origin";
128 return "Memory allocation failure.";
131 return "Conversion between %1! and %2! datatypes is not supported.";
134 return "The conversion/operation resulted in overflow.";
137 return "The conversion/operation was stopped due to a syntax error in the source field.";
140 return "Data is truncated during conversion.";
143 return "Data-conversion resulted in overflow.";
146 return "Unknown callback %1!.";
149 return "Unknown size %1! for SYBINTN.";
152 return "Unknown float size of %1!.";
155 return "Unknown money size of %1!.";
158 return "Unknown date size of %1!.";
161 return "Unknown type: %1!.";
164 return "Out of memory!";
169 return "unrecognized error";
177 tdsdump_log(
TDS_DBG_FUNC,
"_cs_get_msgstr(%s, %d, %d, %d, %d)\n", funcname, layer,
origin, severity,
number);
181 :
"unrecognized error") < 0) {
194 tdsdump_log(
TDS_DBG_FUNC,
"_csclient_msg(%p, %s, %d, %d, %d, %d, %s)\n",
ctx, funcname, layer,
origin, severity,
number, fmt);
200 cm.
msgnumber = (((layer << 24) & 0xFF000000)
201 | ((
origin << 16) & 0x00FF0000)
202 | ((severity << 8) & 0x0000FF00)
203 | ((
number) & 0x000000FF));
267 if (
orig->language) {
281 if (!new_locale->
time)
310 if (
orig->language) {
324 if (!new_locale->
time)
354 (*ctx)->tds_ctx = tds_ctx;
360 (*ctx)->login_timeout = -1;
361 (*ctx)->query_timeout = -1;
373 if (global_cs_ctx !=
NULL) {
374 *
ctx = global_cs_ctx;
380 global_cs_ctx = *
ctx;
404 tdsdump_log(
TDS_DBG_FUNC,
"cs_config(%p, %d, %d, %p, %d, %p)\n",
ctx, action, property,
buffer, buflen, outlen);
444 maxcp = strlen((
char*)
buffer) + 1;
506 int src_len, destlen,
len,
i = 0;
513 tdsdump_log(
TDS_DBG_FUNC,
"cs_convert(%p, %p, %p, %p, %p, %p)\n",
ctx, srcfmt, srcdata, destfmt, destdata, resultlen);
516 if (destdata ==
NULL) {
524 if (destfmt ==
NULL) {
531 if (resultlen ==
NULL)
535 if (srcdata ==
NULL) {
538 memset(destdata,
'\0', destfmt->
maxlength);
566 destlen =
sizeof(destvc->
str);
567 destdata = destvc->
str;
573 src_type, src_len, desttype, destlen);
579 dest = (
unsigned char *) destdata;
583 if (src_type == desttype) {
584 int minlen = src_len < destlen? src_len : destlen;
593 memcpy(dest, srcdata, minlen);
596 if (src_len > destlen) {
602 switch (destfmt->
format) {
604 memset(dest + src_len,
'\0', destlen - src_len);
605 *resultlen = destlen;
616 destvc->
len = minlen;
617 *resultlen =
sizeof(*destvc);
628 memcpy(dest, srcdata, minlen);
631 if (src_len > destlen) {
637 switch (destfmt->
format) {
639 if (src_len == destlen) {
640 *resultlen = src_len;
644 dest[src_len] =
'\0';
645 *resultlen = src_len + 1;
651 memset(dest + src_len,
' ', destlen - src_len);
652 *resultlen = destlen;
656 memset(dest + src_len,
'\0', destlen - src_len);
657 *resultlen = destlen;
670 destvc->
len = minlen;
671 *resultlen =
sizeof(*destvc);
695 memcpy(dest, srcdata, *resultlen);
704 memcpy(dest, srcdata, minlen);
707 if (src_len > destlen) {
728 assert(src_type != desttype);
747 _csclient_msg(
ctx,
"cs_convert", 2, 1, 1, 16,
"%d, %d", src_type, desttype);
783 if (handle ==
NULL) {
784 memcpy(dest, cres.
ib,
len);
794 *resultlen =
sizeof(*destvc);
796 for (
i =
len;
i < destlen;
i++)
822 memcpy(dest, &(cres.
ti), *resultlen);
828 memcpy(dest, &(cres.
n), src_len);
829 *resultlen = src_len;
837 memcpy(dest, &(cres.
dta), *resultlen);
851 switch (destfmt->
format) {
855 if (
len == destlen) {
859 if (handle ==
NULL) {
860 memcpy(dest, cres.
c,
len);
867 *resultlen =
len + 1;
874 if (handle ==
NULL) {
875 memcpy(dest, cres.
c,
len);
881 for (
i =
len;
i < destlen;
i++)
883 *resultlen = destlen;
889 if (handle ==
NULL) {
890 memcpy(dest, cres.
c,
len);
896 for (
i =
len;
i < destlen;
i++)
898 *resultlen = destlen;
902 if (handle ==
NULL) {
903 memcpy(dest, cres.
c,
len);
916 *resultlen =
sizeof(*destvc);
918 if (handle ==
NULL || *handle != cres.
c) {
935 bool extended =
false;
1007 *locptr = tds_csloc;
1028 tdsdump_log(
TDS_DBG_FUNC,
"cs_locale(%p, %d, %p, %d, %p, %d, %p)\n",
ctx, action,
locale,
type,
buffer, buflen, outlen);
1071 buflen = (
int)strlen(
b);
1075 for (
i = 0;
i < buflen; ++
i) {
1090 if (
i != (buflen - 1)) {
1116 else if (action ==
CS_GET)
1133 ((
char *)
buffer)[0] =
'\0';
1138 tlen = (
locale->language ?
1149 ((
char *)
buffer)[0] =
'\0';
1157 tlen = (
locale->language ?
1159 clen = (
locale->charset ?
1162 if (buflen < (tlen + clen))
1165 *outlen = tlen + clen;
1171 ((
char *)
buffer)[0] =
'\0';
1193 ((
char *)
buffer)[0] =
'\0';
1225 ctx,
buffer, buflen, resultlen,
text, textlen, formats, formatlen);
1227 va_start(ap, formatlen);
1238 tdsdump_log(
TDS_DBG_FUNC,
"cs_calc(%p, %d, %d, %p, %p, %p)\n",
ctx, op, datatype, var1, var2, dest);
1248 tdsdump_log(
TDS_DBG_FUNC,
"cs_cmp(%p, %d, %p, %p, %p)\n",
ctx, datatype, var1, var2,
result);
1267 tdsdump_log(
TDS_DBG_FUNC,
"cs_diag(%p, %d, %d, %d, %p)\n",
ctx,
operation,
type, idx,
buffer);
1327 tdsdump_log(
TDS_DBG_FUNC,
"cs_manage_convert(%p, %d, %d, %p, %d, %d, %p, %d, %p, %p)\n",
1328 ctx, action, srctype, srcname, srcnamelen, desttype, destname, destnamelen, conv_multiplier, func);
1348 tdsdump_log(
TDS_DBG_FUNC,
"cs_set_convert(%p, %d, %d, %d, %p)\n",
ctx, action, srctype, desttype, func);
1380 tdsdump_log(
TDS_DBG_FUNC,
"cs_time(%p, %p, %p, %d, %p, %p)\n",
ctx,
locale,
buffer, buflen, outlen, daterec);
1409 while (*curptr !=
NULL) {
1411 curptr = &((*curptr)->next);
1423 if (*curptr ==
NULL) {
1426 (*curptr)->next =
NULL;
1428 if ((*curptr)->msg ==
NULL) {
1442 CS_INT msg_count = 0, msg_found = 0;
1451 while (curptr !=
NULL) {
1453 if (msg_count == idx) {
1457 curptr = curptr->
next;
1477 while (curptr !=
NULL ) {
1479 curptr = freeptr->
next;
1496 while (curptr !=
NULL) {
1498 curptr = curptr->
next;
1531 if (convert_buffer) {
1536 *p_src = (
unsigned char *) convert_buffer;
#define CS_DATETIME4_TYPE
#define CS_BIGDATETIME_TYPE
CS_RETCODE(* CS_CSLIBMSG_FUNC)(CS_CONTEXT *, CS_CLIENTMSG *)
#define CS_SYB_LANG_CHARSET
#define CS_VARBINARY_TYPE
CS_RETCODE(* CS_CONV_FUNC)(CS_CONTEXT *context, CS_DATAFMT *srcfmt, CS_VOID *src, CS_DATAFMT *detsfmt, CS_VOID *dest, CS_INT *destlen)
#define CS_RET_HAFAILOVER
static void _cs_locale_free_contents(CS_LOCALE *locale)
CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT **ctx)
CS_RETCODE cs_dt_crack_v2(CS_CONTEXT *ctx, CS_INT datetype, CS_VOID *dateval, CS_DATEREC *daterec)
CS_LOCALE * _cs_locale_copy(CS_LOCALE *orig)
static const char * _cs_get_layer(int layer)
CS_RETCODE cs_dt_info(CS_CONTEXT *ctx, CS_INT action, CS_LOCALE *locale, CS_INT type, CS_INT item, CS_VOID *buffer, CS_INT buflen, CS_INT *outlen)
static CS_INT cs_diag_clearmsg(CS_CONTEXT *context, CS_INT type)
CS_RETCODE cs_strcmp(CS_CONTEXT *ctx, CS_LOCALE *locale, CS_INT type, CS_CHAR *str1, CS_INT len1, CS_CHAR *str2, CS_INT len2, CS_INT *result)
CS_RETCODE _cs_convert_ex(CS_CONTEXT *ctx, CS_DATAFMT *srcfmt, CS_VOID *srcdata, CS_DATAFMT *destfmt, CS_VOID *destdata, CS_INT *resultlen, TDS_SERVER_TYPE desttype, CS_VOID **handle)
CS_RETCODE cs_locale(CS_CONTEXT *ctx, CS_INT action, CS_LOCALE *locale, CS_INT type, CS_VOID *buffer, CS_INT buflen, CS_INT *outlen)
CS_RETCODE cs_dt_crack(CS_CONTEXT *ctx, CS_INT datetype, CS_VOID *dateval, CS_DATEREC *daterec)
CS_RETCODE cs_config(CS_CONTEXT *ctx, CS_INT action, CS_INT property, CS_VOID *buffer, CS_INT buflen, CS_INT *outlen)
static const char * _cs_get_origin(int origin)
CS_RETCODE cs_calc(CS_CONTEXT *ctx, CS_INT op, CS_INT datatype, CS_VOID *var1, CS_VOID *var2, CS_VOID *dest)
CS_RETCODE cs_set_convert(CS_CONTEXT *ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC *func)
CS_RETCODE cs_will_convert(CS_CONTEXT *ctx, CS_INT srctype, CS_INT desttype, CS_BOOL *result)
static const char * _cs_get_user_api_layer_error(int error)
CS_RETCODE cs_loc_alloc(CS_CONTEXT *ctx, CS_LOCALE **locptr)
void _cs_locale_free(CS_LOCALE *locale)
static CS_INT cs_diag_storemsg(CS_CONTEXT *context, CS_CLIENTMSG *message)
int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig)
CS_RETCODE cs_ctx_drop(CS_CONTEXT *ctx)
void _csclient_msg(CS_CONTEXT *ctx, const char *funcname, int layer, int origin, int severity, int number, const char *fmt,...)
CS_RETCODE cs_diag(CS_CONTEXT *ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID *buffer)
CS_RETCODE cs_conv_mult(CS_CONTEXT *ctx, CS_LOCALE *srcloc, CS_LOCALE *destloc, CS_INT *conv_multiplier)
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,...)
static CS_INT cs_diag_getmsg(CS_CONTEXT *context, CS_INT idx, CS_CLIENTMSG *message)
CS_RETCODE cs_objects(CS_CONTEXT *ctx, CS_INT action, CS_OBJNAME *objname, CS_OBJDATA *objdata)
int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src)
Try to convert to a type we can handle.
CS_RETCODE cs_time(CS_CONTEXT *ctx, CS_LOCALE *locale, CS_VOID *buffer, CS_INT buflen, CS_INT *outlen, CS_DATEREC *daterec)
CS_RETCODE cs_cmp(CS_CONTEXT *ctx, CS_INT datatype, CS_VOID *var1, CS_VOID *var2, CS_INT *result)
static CS_LOCALE * _cs_locale_alloc(void)
Allocate new CS_LOCALE and initialize it returns NULL on out of memory errors.
CS_RETCODE cs_setnull(CS_CONTEXT *ctx, CS_DATAFMT *datafmt, CS_VOID *buffer, CS_INT buflen)
CS_RETCODE cs_manage_convert(CS_CONTEXT *ctx, CS_INT action, CS_INT srctype, CS_CHAR *srcname, CS_INT srcnamelen, CS_INT desttype, CS_CHAR *destname, CS_INT destnamelen, CS_INT *conv_multiplier, CS_CONV_FUNC *func)
CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT **ctx)
static char * _cs_get_msgstr(const char *funcname, int layer, int origin, int severity, int number)
static CS_INT cs_diag_countmsg(CS_CONTEXT *context, CS_INT *count)
CS_RETCODE cs_loc_drop(CS_CONTEXT *ctx, CS_LOCALE *locale)
CS_RETCODE cs_convert(CS_CONTEXT *ctx, CS_DATAFMT *srcfmt, CS_VOID *srcdata, CS_DATAFMT *destfmt, CS_VOID *destdata, CS_INT *resultlen)
const char * cs_prretcode(int retcode)
TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype)
#define _CS_ERRHAND_INLINE
CS_INT _ct_diag_clearmsg(CS_CONTEXT *context, CS_INT type)
#define TDS_CONVERT_SYNTAX
#define TDS_CONVERT_OVERFLOW
#define TDS_CONVERT_NOMEM
#define TDS_CONVERT_NOAVAIL
struct tdsnumeric TDS_NUMERIC
#define is_numeric_type(x)
tds_sysdep_int32_type TDS_INT
#define tds_new0(type, n)
#define SYBMSDATETIMEOFFSET
#define tds_get_size_by_type
#define tds_numeric_bytes_per_prec
#define tds_alloc_context
unsigned int
A callback function used to compare two keys in a database.
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
static void text(MDB_val *v)
const string version
version string
static const GLdouble origin[]
static const char * locale
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
CS_CSLIBMSG_FUNC _cslibmsg_cb
struct cs_diag_msg * msgstore
struct cs_diag_msg * next
Metadata about columns in regular and compute rows.
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
static CS_CONTEXT * context