From 916a7851a6c24f58ea7c4c474e48959ad38a1ac4 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 10 Mar 2014 19:44:30 +0200 Subject: [PATCH] Fix implicit casts between SQLCHAR and char. Don't rely on -Wno-pointer-sign. --- configure.ac | 10 ----- connection.c | 16 +++---- convert.c | 54 +++++++++++------------ convert.h | 4 +- dlg_specific.c | 39 +++++++++-------- drvconn.c | 14 +++--- environ.c | 16 +++---- execute.c | 2 +- info.c | 114 +++++++++++++++++++++++++++--------------------- misc.c | 17 ++++---- misc.h | 8 ++-- multibyte.c | 16 ++++--- multibyte.h | 11 +++-- odbcapi30w.c | 4 +- odbcapiw.c | 115 +++++++++++++++++++++++++++++++------------------ parse.c | 7 ++- pgapi30.c | 6 +-- qresult.c | 10 ++--- qresult.h | 4 +- results.c | 38 ++++++++-------- win_unicode.c | 2 +- 21 files changed, 273 insertions(+), 234 deletions(-) diff --git a/configure.ac b/configure.ac index 532b4de..d714bfd 100644 --- a/configure.ac +++ b/configure.ac @@ -27,16 +27,6 @@ if test -n "$GCC" && test "$ac_test_CFLAGS" != set; then CFLAGS_ADD="${CFLAGS_ADD} -Wall"], [AC_MSG_RESULT(no)]) CFLAGS=${CFLAGS_save} - - AC_MSG_CHECKING(-Wno-pointer-sign is a valid compile option) - CFLAGS="${CFLAGS_save} -Wno-pointer-sign" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[#include ]], - [])], - [AC_MSG_RESULT(yes) - CFLAGS_ADD="${CFLAGS_ADD} -Wno-pointer-sign"], - [AC_MSG_RESULT(no)]) - CFLAGS="${CFLAGS_save} ${CFLAGS_ADD}" fi # diff --git a/connection.c b/connection.c index 1d58164..21321f0 100644 --- a/connection.c +++ b/connection.c @@ -2655,7 +2655,7 @@ mylog("CC_on_abort_partial in\n"); } static BOOL -is_setting_search_path(const UCHAR* query) +is_setting_search_path(const char *query) { for (query += 4; *query; query++) { @@ -3662,7 +3662,7 @@ CC_setenv(ConnectionClass *self) stmt->internal = TRUE; /* ensure no BEGIN/COMMIT/ABORT stuff */ /* Set the Datestyle to the format the driver expects it to be in */ - result = PGAPI_ExecDirect(hstmt, "set DateStyle to 'ISO'", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "set DateStyle to 'ISO'", SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3670,7 +3670,7 @@ CC_setenv(ConnectionClass *self) /* Disable genetic optimizer based on global flag */ if (ci->drivers.disable_optimizer) { - result = PGAPI_ExecDirect(hstmt, "set geqo to 'OFF'", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "set geqo to 'OFF'", SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3681,7 +3681,7 @@ CC_setenv(ConnectionClass *self) /* KSQO (not applicable to 7.1+ - DJP 21/06/2002) */ if (ci->drivers.ksqo && PG_VERSION_LT(self, 7.1)) { - result = PGAPI_ExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "set ksqo to 'ON'", SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3692,7 +3692,7 @@ CC_setenv(ConnectionClass *self) /* extra_float_digits (applicable since 7.4) */ if (PG_VERSION_GT(self, 7.3)) { - result = PGAPI_ExecDirect(hstmt, "set extra_float_digits to 2", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "set extra_float_digits to 2", SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3751,7 +3751,7 @@ CC_send_settings(ConnectionClass *self) #endif /* HAVE_STRTOK_R */ while (ptr) { - result = PGAPI_ExecDirect(hstmt, ptr, SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) ptr, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3782,7 +3782,7 @@ CC_send_settings(ConnectionClass *self) #endif /* HAVE_STRTOK_R */ while (ptr) { - result = PGAPI_ExecDirect(hstmt, ptr, SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) ptr, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) status = FALSE; @@ -3905,7 +3905,7 @@ CC_lookup_pg_version(ConnectionClass *self) return; /* get the server's version if possible */ - result = PGAPI_ExecDirect(hstmt, "select version()", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "select version()", SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { PGAPI_FreeStmt(hstmt, SQL_DROP); diff --git a/convert.c b/convert.c index d8b0304..354b298 100644 --- a/convert.c +++ b/convert.c @@ -142,10 +142,10 @@ char *mapFuncs[][2] = { }; static const char *mapFunction(const char *func, int param_count); -static int conv_from_octal(const UCHAR *s); -static SQLLEN pg_bin2hex(const UCHAR *src, UCHAR *dst, SQLLEN length); +static int conv_from_octal(const char *s); +static SQLLEN pg_bin2hex(const char *src, char *dst, SQLLEN length); #ifdef UNICODE_SUPPORT -static SQLLEN pg_bin2whex(const UCHAR *src, SQLWCHAR *dst, SQLLEN length); +static SQLLEN pg_bin2whex(const char *src, SQLWCHAR *dst, SQLLEN length); #endif /* UNICODE_SUPPORT */ /*--------- @@ -1600,7 +1600,7 @@ inolog("2stime fr=%d\n", std_time.fr); SQL_NUMERIC_STRUCT *ns; int i, nlen, bit, hval, tv, dig, sta, olen; char calv[SQL_MAX_NUMERIC_LEN * 3]; - const UCHAR *wv; + const char *wv; BOOL dot_exist; len = sizeof(SQL_NUMERIC_STRUCT); @@ -1931,7 +1931,7 @@ inolog("SQL_C_VARBOOKMARK value=%d\n", ival); #define FLGP_MULTIPLE_STATEMENT (1L << 5) #define FLGP_SELECT_FOR_READONLY (1L << 6) typedef struct _QueryParse { - const UCHAR *statement; + const char *statement; int statement_type; size_t opos; Int4 from_pos; /* PG comm length restriction */ @@ -1984,7 +1984,7 @@ QP_initialize(QueryParse *q, const StatementClass *stmt) #define FLGB_LITERAL_EXTENSION (1L << 10) #define FLGB_HEX_BIN_FORMAT (1L << 11) typedef struct _QueryBuild { - UCHAR *query_statement; + char *query_statement; size_t str_size_limit; size_t str_alsize; size_t npos; @@ -2197,7 +2197,7 @@ static int processParameters(QueryParse *qp, QueryBuild *qb, size_t *output_count, SQLLEN param_pos[][2]); static size_t -convert_to_pgbinary(const UCHAR *in, char *out, size_t len, QueryBuild *qb); +convert_to_pgbinary(const char *in, char *out, size_t len, QueryBuild *qb); static ssize_t enlarge_query_statement(QueryBuild *qb, size_t newsize) @@ -2881,7 +2881,7 @@ copy_statement_with_parameters(StatementClass *stmt, BOOL buildPrepareStatement) QueryParse query_org, *qp; QueryBuild query_crt, *qb; - UCHAR *new_statement; + char *new_statement; BOOL begin_first = FALSE, prepare_dummy_cursor = FALSE, bPrepConv; ConnectionClass *conn = SC_get_conn(stmt); @@ -3195,12 +3195,12 @@ Int4 findTag(const char *tag, char dollar_quote, int ccsc) } static -Int4 findIdentifier(const UCHAR *str, int ccsc, const UCHAR **nextdel) +Int4 findIdentifier(const char *str, int ccsc, const char **nextdel) { Int4 strlen = 0; encoded_str encstr; unsigned char tchar; - const UCHAR *sptr; + const char *sptr; BOOL dquote = FALSE; *nextdel = NULL; @@ -3543,7 +3543,7 @@ inner_process_tokens(QueryParse *qp, QueryBuild *qb) qb->dollar_number = 0; if (0 != (qp->flags & FLGP_USING_CURSOR)) { - const UCHAR *vp = &(qp->statement[qp->opos + 1]); + const char *vp = &(qp->statement[qp->opos + 1]); while (*vp && isspace(*vp)) vp++; @@ -5047,7 +5047,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb) if (stricmp(key, "call") == 0) { Int4 funclen; - const UCHAR *nextdel; + const char *nextdel; if (SQL_ERROR == QB_start_brace(qb)) { @@ -5193,7 +5193,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb) if (2 == param_count) { BOOL add_cast = FALSE, add_quote = FALSE; - const UCHAR *pptr; + const char *pptr; from = param_pos[0][0]; to = param_pos[0][1]; @@ -5258,7 +5258,7 @@ mylog("%d-%d num=%s SQL_BIT=%d\n", to, from, num, SQL_BIT); } else { - const UCHAR *mapptr; + const char *mapptr; SQLLEN paramlen; int pidx; @@ -5619,7 +5619,7 @@ convert_pgbinary_to_char(const char *value, char *rgbValue, ssize_t cbValueMax) static int -conv_from_octal(const UCHAR *s) +conv_from_octal(const char *s) { ssize_t i; int y = 0; @@ -5633,7 +5633,7 @@ conv_from_octal(const UCHAR *s) /* convert octal escapes to bytes */ size_t -convert_from_pgbinary(const UCHAR *value, UCHAR *rgbValue, SQLLEN cbValueMax) +convert_from_pgbinary(const char *value, char *rgbValue, SQLLEN cbValueMax) { size_t i, ilen = strlen(value); @@ -5731,7 +5731,7 @@ conv_to_octal2(UCHAR val, char *octal) /* convert non-ascii bytes to octal escape sequences */ static size_t -convert_to_pgbinary(const UCHAR *in, char *out, size_t len, QueryBuild *qb) +convert_to_pgbinary(const char *in, char *out, size_t len, QueryBuild *qb) { CSTR func = "convert_to_pgbinary"; UCHAR inc; @@ -5746,7 +5746,7 @@ convert_to_pgbinary(const UCHAR *in, char *out, size_t len, QueryBuild *qb) out[o++] = escape_in_literal; out[o++] = '\\'; out[o++] = 'x'; - o += pg_bin2hex(in, (UCHAR *) out + o, len); + o += pg_bin2hex(in, out + o, len); return o; } for (i = 0; i < len; i++) @@ -5778,21 +5778,21 @@ convert_to_pgbinary(const UCHAR *in, char *out, size_t len, QueryBuild *qb) static const char *hextbl = "0123456789ABCDEF"; #define def_bin2hex(type) \ - (const UCHAR *src, type *dst, SQLLEN length) \ + (const char *src, type *dst, SQLLEN length) \ { \ - const UCHAR *src_wk; \ + const char *src_wk; \ UCHAR chr; \ type *dst_wk; \ BOOL backwards; \ int i; \ \ backwards = FALSE; \ - if ((UCHAR *)dst < src) \ + if ((char *) dst < src) \ { \ - if ((UCHAR *) (dst + 2 * (length - 1)) > src + length - 1) \ + if ((char *) (dst + 2 * (length - 1)) > src + length - 1) \ return -1; \ } \ - else if ((UCHAR *) dst < src + length) \ + else if ((char *) dst < src + length) \ backwards = TRUE; \ if (backwards) \ { \ @@ -5821,14 +5821,14 @@ pg_bin2whex def_bin2hex(SQLWCHAR) #endif /* UNICODE_SUPPORT */ static SQLLEN -pg_bin2hex def_bin2hex(UCHAR) +pg_bin2hex def_bin2hex(char) SQLLEN -pg_hex2bin(const UCHAR *src, UCHAR *dst, SQLLEN length) +pg_hex2bin(const char *src, char *dst, SQLLEN length) { UCHAR chr; - const UCHAR *src_wk; - UCHAR *dst_wk; + const char *src_wk; + char *dst_wk; SQLLEN i; int val; BOOL HByte = TRUE; diff --git a/convert.h b/convert.h index 818b881..984eff5 100644 --- a/convert.h +++ b/convert.h @@ -52,8 +52,8 @@ size_t convert_linefeeds(const char *s, char *dst, size_t max, BOOL convlf, BOO size_t convert_special_chars(const char *si, char *dst, SQLLEN used, UInt4 flags,int ccsc, int escape_ch); int convert_pgbinary_to_char(const char *value, char *rgbValue, ssize_t cbValueMax); -size_t convert_from_pgbinary(const UCHAR *value, UCHAR *rgbValue, SQLLEN cbValueMax); -SQLLEN pg_hex2bin(const UCHAR *in, UCHAR *out, SQLLEN len); +size_t convert_from_pgbinary(const char *value, char *rgbValue, SQLLEN cbValueMax); +SQLLEN pg_hex2bin(const char *in, char *out, SQLLEN len); int convert_lo(StatementClass *stmt, const void *value, SQLSMALLINT fCType, PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue); Int4 findTag(const char *str, char dollar_quote, int ccsc); diff --git a/dlg_specific.c b/dlg_specific.c index 804df50..5cf9f7c 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -28,9 +28,9 @@ extern GLOBAL_VALUES globals; -static void encode(const pgNAME, UCHAR *out, int outlen); -static pgNAME decode(const UCHAR *in); -static pgNAME decode_or_remove_braces(const UCHAR *in); +static void encode(const pgNAME, char *out, int outlen); +static pgNAME decode(const char *in); +static pgNAME decode_or_remove_braces(const char *in); #define OVR_EXTRA_BITS (BIT_FORCEABBREVCONNSTR | BIT_FAKE_MSS | BIT_BDE_ENVIRONMENT | BIT_CVT_NULL_DATE | BIT_ACCESSIBLE_ONLY | BIT_IGNORE_ROUND_TRIP_TIME | BIT_DISABLE_KEEPALIVE) UInt4 getExtraOptions(const ConnInfo *ci) @@ -1500,10 +1500,10 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci) } static void -encode(const pgNAME in, UCHAR *out, int outlen) +encode(const pgNAME in, char *out, int outlen) { size_t i, ilen, o = 0; - UCHAR inc, *ins; + char inc, *ins; if (NAME_IS_NULL(in)) { @@ -1538,7 +1538,7 @@ encode(const pgNAME in, UCHAR *out, int outlen) } static unsigned int -conv_from_hex(const UCHAR *s) +conv_from_hex(const char *s) { int i, y = 0, @@ -1560,10 +1560,10 @@ conv_from_hex(const UCHAR *s) } static pgNAME -decode(const UCHAR *in) +decode(const char *in) { size_t i, ilen = strlen(in), o = 0; - UCHAR inc, *outs; + char inc, *outs; pgNAME out; INIT_NAME(out); @@ -1596,7 +1596,7 @@ decode(const UCHAR *in) * Othewise decode the input value. */ static pgNAME -decode_or_remove_braces(const UCHAR *in) +decode_or_remove_braces(const char *in) { if ('{' == in[0]) { @@ -1615,14 +1615,14 @@ decode_or_remove_braces(const UCHAR *in) char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comment) { - const UCHAR *cptr, *sptr = NULL; - UCHAR *rptr; + const char *cptr, *sptr = NULL; + char *rptr; BOOL allowed_cmd = TRUE, in_quote = FALSE, in_comment = FALSE; int step = 0, skiplen; size_t len = 0, attrlen = strlen(attr); - for (cptr = (UCHAR *) str; *cptr; cptr++) - { + for (cptr = str; *cptr; cptr++) + { if (in_quote) { if (LITERAL_QUOTE == *cptr) @@ -1672,7 +1672,7 @@ char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comm } if (!allowed_cmd) continue; - if (isspace(*cptr)) + if (isspace((unsigned char) *cptr)) { if (4 == step) { @@ -1742,14 +1742,15 @@ char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comm */ char *extract_extra_attribute_setting(const pgNAME setting, const char *attr) { - const UCHAR *cptr, *sptr = NULL, *str = GET_NAME(setting); - UCHAR *rptr; + const char *str = GET_NAME(setting); + const char *cptr, *sptr = NULL; + char *rptr; BOOL allowed_cmd = FALSE, in_quote = FALSE, in_comment = FALSE; int step = 0, step_last = 2; size_t len = 0, attrlen = strlen(attr); - for (cptr = (UCHAR *) str; *cptr; cptr++) - { + for (cptr = str; *cptr; cptr++) + { if (in_quote) { if (LITERAL_QUOTE == *cptr) @@ -1795,7 +1796,7 @@ char *extract_extra_attribute_setting(const pgNAME setting, const char *attr) } /* now in comment */ if (';' == *cptr || - isspace(*cptr)) + isspace((unsigned char) *cptr)) { if (step_last == step) len = cptr - sptr; diff --git a/drvconn.c b/drvconn.c index 73f0d8e..7ced3ab 100644 --- a/drvconn.c +++ b/drvconn.c @@ -62,8 +62,8 @@ static char * hide_password(const char *str) #endif /* prototypes */ -void dconn_get_connect_attributes(const SQLCHAR FAR * connect_string, ConnInfo *ci); -static void dconn_get_common_attributes(const SQLCHAR FAR * connect_string, ConnInfo *ci); +static void dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci); +static void dconn_get_common_attributes(const char *connect_string, ConnInfo *ci); #ifdef WIN32 LRESULT CALLBACK dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); @@ -275,7 +275,7 @@ inolog("before CC_connect\n"); * anyway. */ /*strncpy_null(szConnStrOut, connStrOut, cbConnStrOutMax);*/ - strncpy(szConnStrOut, connStrOut, cbConnStrOutMax); + strncpy((char *) szConnStrOut, connStrOut, cbConnStrOutMax); if (len >= cbConnStrOutMax) { @@ -425,7 +425,7 @@ dconn_FDriverConnectProc( typedef BOOL (*copyfunc)(ConnInfo *, const char *attribute, const char *value); static void -dconn_get_attributes(copyfunc func, const SQLCHAR FAR * connect_string, ConnInfo *ci) +dconn_get_attributes(copyfunc func, const char *connect_string, ConnInfo *ci) { char *our_connect_string; const char *pair, @@ -537,8 +537,8 @@ dconn_get_attributes(copyfunc func, const SQLCHAR FAR * connect_string, ConnInfo free(our_connect_string); } -void -dconn_get_connect_attributes(const SQLCHAR FAR * connect_string, ConnInfo *ci) +static void +dconn_get_connect_attributes(const char *connect_string, ConnInfo *ci) { CC_conninfo_init(ci, COPY_GLOBALS); @@ -546,7 +546,7 @@ dconn_get_connect_attributes(const SQLCHAR FAR * connect_string, ConnInfo *ci) } static void -dconn_get_common_attributes(const SQLCHAR FAR * connect_string, ConnInfo *ci) +dconn_get_common_attributes(const char *connect_string, ConnInfo *ci) { dconn_get_attributes(copyCommonAttributes, connect_string, ci); } diff --git a/environ.c b/environ.c index ef7e316..e749439 100644 --- a/environ.c +++ b/environ.c @@ -119,9 +119,9 @@ cleanup: static void -pg_sqlstate_set(const EnvironmentClass *env, UCHAR *szSqlState, const UCHAR *ver3str, const UCHAR *ver2str) +pg_sqlstate_set(const EnvironmentClass *env, UCHAR *szSqlState, const char *ver3str, const char *ver2str) { - strcpy(szSqlState, EN_is_odbc3(env) ? ver3str : ver2str); + strcpy((char *) szSqlState, EN_is_odbc3(env) ? ver3str : ver2str); } PG_ErrorInfo *ER_Constructor(SDWORD errnumber, const char *msg) @@ -254,7 +254,7 @@ ER_ReturnError(PG_ErrorInfo **pgerror, *pfNativeError = error->status; if (NULL != szSqlState) - strncpy_null(szSqlState, error->sqlstate, 6); + strncpy_null((char *) szSqlState, error->sqlstate, 6); mylog(" szSqlState = '%s',len=%d, szError='%s'\n", szSqlState, pcblen, szErrorMsg); if (clear_str) @@ -299,7 +299,7 @@ PGAPI_ConnectError( HDBC hdbc, { mylog("CC_Get_error returned nothing.\n"); if (NULL != szSqlState) - strcpy(szSqlState, "00000"); + strcpy((char *) szSqlState, "00000"); if (NULL != pcbErrorMsg) *pcbErrorMsg = 0; if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) @@ -319,14 +319,14 @@ PGAPI_ConnectError( HDBC hdbc, *pcbErrorMsg = cbErrorMsgMax - 1; } if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) - strncpy_null(szErrorMsg, msg, cbErrorMsgMax); + strncpy_null((char *) szErrorMsg, msg, cbErrorMsgMax); if (NULL != pfNativeError) *pfNativeError = status; if (NULL != szSqlState) { if (conn->sqlstate[0]) - strcpy(szSqlState, conn->sqlstate); + strcpy((char *) szSqlState, conn->sqlstate); else switch (status) { @@ -444,7 +444,7 @@ PGAPI_EnvError( HENV henv, if (NULL != pcbErrorMsg) *pcbErrorMsg = (SQLSMALLINT) strlen(msg); if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) - strncpy_null(szErrorMsg, msg, cbErrorMsgMax); + strncpy_null((char *) szErrorMsg, msg, cbErrorMsgMax); if (NULL != pfNativeError) *pfNativeError = status; @@ -498,7 +498,7 @@ PGAPI_Error( else { if (NULL != szSqlState) - strcpy(szSqlState, "00000"); + strcpy((char *) szSqlState, "00000"); if (NULL != pcbErrorMsg) *pcbErrorMsg = 0; if ((NULL != szErrorMsg) && (cbErrorMsgMax > 0)) diff --git a/execute.c b/execute.c index fc05317..39b3cdf 100644 --- a/execute.c +++ b/execute.c @@ -1385,7 +1385,7 @@ PGAPI_NativeSql( if (szSqlStr) { - strncpy_null(szSqlStr, ptr, cbSqlStrMax); + strncpy_null((char *) szSqlStr, ptr, cbSqlStrMax); if (len >= cbSqlStrMax) { diff --git a/info.c b/info.c index df533f5..7ebb6c2 100644 --- a/info.c +++ b/info.c @@ -50,9 +50,9 @@ /* extern GLOBAL_VALUES globals; */ -CSTR pubstr = "public"; -CSTR likeop = "like"; -CSTR eqop = "="; +static const SQLCHAR *pubstr = (SQLCHAR *) "public"; +static const char *likeop = "like"; +static const char *eqop = "="; RETCODE SQL_API PGAPI_GetInfo( @@ -1360,7 +1360,7 @@ PGAPI_GetFunctions( static char * -simpleCatalogEscape(const char *src, int srclen, int *result_len, const ConnectionClass *conn) +simpleCatalogEscape(const SQLCHAR *src, SQLLEN srclen, int *result_len, const ConnectionClass *conn) { int i, outlen; const char *in; @@ -1372,13 +1372,13 @@ simpleCatalogEscape(const char *src, int srclen, int *result_len, const Connecti if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) - srclen = (int) strlen(src); + srclen = (SQLLEN) strlen((char *) src); if (srclen <= 0) return dest; mylog("simple in=%s(%d)\n", src, srclen); - encoded_str_constr(&encstr, conn->ccsc, src); + encoded_str_constr(&encstr, conn->ccsc, (char *) src); dest = malloc(2 * srclen + 1); - for (i = 0, in = src, outlen = 0; i < srclen; i++, in++) + for (i = 0, in = (char *) src, outlen = 0; i < srclen; i++, in++) { encoded_nextchar(&encstr); if (ENCODE_STATUS(encstr) != 0) @@ -1402,7 +1402,7 @@ mylog("simple output=%s(%d)\n", dest, outlen); * PostgreSQL needs 2 '\\' to escape '_' and '%'. */ static char * -adjustLikePattern(const char *src, int srclen, char escape_ch, int *result_len, const ConnectionClass *conn) +adjustLikePattern(const SQLCHAR *src, int srclen, char escape_ch, int *result_len, const ConnectionClass *conn) { int i, outlen; const char *in; @@ -1415,14 +1415,14 @@ adjustLikePattern(const char *src, int srclen, char escape_ch, int *result_len, if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) - srclen = (int) strlen(src); + srclen = (int) strlen((char *) src); /* if (srclen <= 0) */ if (srclen < 0) return dest; mylog("adjust in=%.*s(%d)\n", srclen, src, srclen); - encoded_str_constr(&encstr, conn->ccsc, src); + encoded_str_constr(&encstr, conn->ccsc, (char *) src); dest = malloc(2 * srclen + 1); - for (i = 0, in = src, outlen = 0; i < srclen; i++, in++) + for (i = 0, in = (char *) src, outlen = 0; i < srclen; i++, in++) { encoded_nextchar(&encstr); if (ENCODE_STATUS(encstr) != 0) @@ -1496,7 +1496,7 @@ static const char *gen_opestr(const char *orig_opestr, const ConnectionClass * c * 'public', allowed to use the 'public' schema. */ static BOOL -allow_public_schema(ConnectionClass *conn, const char *szSchemaName, SQLSMALLINT cbSchemaName) +allow_public_schema(ConnectionClass *conn, const SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName) { const char *user = CC_get_username(conn); size_t userlen = strlen(user); @@ -1505,11 +1505,11 @@ allow_public_schema(ConnectionClass *conn, const char *szSchemaName, SQLSMALLINT return FALSE; if (SQL_NTS == cbSchemaName) - cbSchemaName = strlen(szSchemaName); + cbSchemaName = strlen((char *) szSchemaName); return (cbSchemaName == (SQLSMALLINT) userlen && - strnicmp(szSchemaName, user, userlen) == 0 && - stricmp(CC_get_current_schema(conn), pubstr) == 0); + strnicmp((char *) szSchemaName, user, userlen) == 0 && + stricmp(CC_get_current_schema(conn), (char *) pubstr) == 0); } RETCODE SQL_API @@ -1558,7 +1558,7 @@ PGAPI_Tables( int i; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const char *like_or_eq, *op_string; - const char *szSchemaName; + const SQLCHAR *szSchemaName; BOOL search_pattern; BOOL list_cat = FALSE, list_schemas = FALSE, list_table_types = FALSE, list_some = FALSE; SQLLEN cbRelname, cbRelkind, cbSchName; @@ -1790,7 +1790,7 @@ retry_public_schema: strcat(tables_query, " and usesysid = relowner order by relname"); } - result = PGAPI_ExecDirect(htbl_stmt, tables_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(htbl_stmt, (SQLCHAR *) tables_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, htbl_stmt, FALSE); @@ -2039,7 +2039,7 @@ PGAPI_Columns( ConnectionClass *conn; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; const char *like_or_eq = likeop, *op_string; - const char *szSchemaName; + const SQLCHAR *szSchemaName; BOOL setIdentity = FALSE; mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, szTableOwner, cbTableOwner); @@ -2173,7 +2173,7 @@ retry_public_schema: mylog("%s: hcol_stmt = %p, col_stmt = %p\n", func, hcol_stmt, col_stmt); col_stmt->internal = TRUE; - result = PGAPI_ExecDirect(hcol_stmt, columns_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(hcol_stmt, (SQLCHAR *) columns_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, col_stmt, FALSE); @@ -2775,7 +2775,8 @@ PGAPI_SpecialColumns( char relhasrules[MAX_INFO_STRING], relkind[8], relhasoids[8]; BOOL relisaview; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; - const char *szSchemaName, *eq_string; + const SQLCHAR *szSchemaName; + const char *eq_string; mylog("%s: entering...stmt=%p scnm=%p len=%d colType=%d scope=%d\n", func, stmt, szTableOwner, cbTableOwner, fColType, fScope); @@ -2844,7 +2845,7 @@ retry_public_schema: mylog("%s: hcol_stmt = %p, col_stmt = %p\n", func, hcol_stmt, col_stmt); - result = PGAPI_ExecDirect(hcol_stmt, columns_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(hcol_stmt, (SQLCHAR *) columns_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, col_stmt, FALSE); @@ -3047,7 +3048,8 @@ PGAPI_Statistics( ConnInfo *ci; char buf[256]; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName, field_number; - const char *szSchemaName, *eq_string; + const SQLCHAR *szSchemaName; + const char *eq_string; OID ioid; Int4 relhasoids; @@ -3130,8 +3132,12 @@ PGAPI_Statistics( /* * table_name parameter cannot contain a string search pattern. */ - result = PGAPI_Columns(hcol_stmt, NULL, 0, table_schemaname, SQL_NTS, - table_name, SQL_NTS, NULL, 0, PODBC_NOT_SEARCH_PATTERN | PODBC_SEARCH_PUBLIC_SCHEMA, 0, 0); + result = PGAPI_Columns(hcol_stmt, + NULL, 0, + (SQLCHAR *) table_schemaname, SQL_NTS, + (SQLCHAR *) table_name, SQL_NTS, + NULL, 0, + PODBC_NOT_SEARCH_PATTERN | PODBC_SEARCH_PUBLIC_SCHEMA, 0, 0); col_stmt->internal = FALSE; if (!SQL_SUCCEEDED(result)) @@ -3207,11 +3213,11 @@ PGAPI_Statistics( indx_stmt = (StatementClass *) hindx_stmt; /* TableName cannot contain a string search pattern */ - escTableName = simpleCatalogEscape(table_name, SQL_NTS, NULL, conn); + escTableName = simpleCatalogEscape((SQLCHAR *) table_name, SQL_NTS, NULL, conn); eq_string = gen_opestr(eqop, conn); if (conn->schema_support) { - escSchemaName = simpleCatalogEscape(table_schemaname, SQL_NTS, NULL, conn); + escSchemaName = simpleCatalogEscape((SQLCHAR *) table_schemaname, SQL_NTS, NULL, conn); snprintf(index_query, sizeof(index_query), "select c.relname, i.indkey, i.indisunique" ", i.indisclustered, a.amname, c.relhasrules, n.nspname" ", c.oid, %s, %s" @@ -3245,7 +3251,7 @@ PGAPI_Statistics( else strcat(index_query, " i.indisunique, c.relname"); - result = PGAPI_ExecDirect(hindx_stmt, index_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(hindx_stmt, (SQLCHAR *) index_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { /* @@ -3670,7 +3676,8 @@ PGAPI_PrimaryKeys( qstart, qend; SQLSMALLINT internal_asis_type = SQL_C_CHAR, cbSchemaName; - const char *szSchemaName, *eq_string; + const SQLCHAR *szSchemaName; + const char *eq_string; char *escSchemaName = NULL, *escTableName = NULL; mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, szTableOwner, cbTableOwner); @@ -3747,7 +3754,7 @@ retry_public_schema: free(escSchemaName); escSchemaName = simpleCatalogEscape(szSchemaName, cbSchemaName, NULL, conn); if (conn->schema_support) - schema_strcat(pkscm, "%.*s", escSchemaName, SQL_NTS, szTableName, cbTableName, conn); + schema_strcat(pkscm, "%.*s", (SQLCHAR *) escSchemaName, SQL_NTS, szTableName, cbTableName, conn); } result = PGAPI_BindCol(htbl_stmt, 1, internal_asis_type, @@ -3901,7 +3908,7 @@ retry_public_schema: } mylog("%s: tables_query='%s'\n", func, tables_query); - result = PGAPI_ExecDirect(htbl_stmt, tables_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(htbl_stmt, (SQLCHAR *) tables_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { SC_full_error_copy(stmt, tbl_stmt, FALSE); @@ -3998,11 +4005,11 @@ cleanup: * future version. The way is very forcible currently. */ static BOOL -isMultibyte(const UCHAR *str) +isMultibyte(const char *str) { for (; *str; str++) { - if (*str >= 0x80) + if ((unsigned char) *str >= 0x80) return TRUE; } return FALSE; @@ -4236,13 +4243,13 @@ PGAPI_ForeignKeys_old( if (fk_table_needed && fk_table_needed[0] != '\0') { mylog("%s: entering Foreign Key Case #2", func); - escFkTableName = simpleCatalogEscape(fk_table_needed, SQL_NTS, NULL, conn); + escFkTableName = simpleCatalogEscape((SQLCHAR *) fk_table_needed, SQL_NTS, NULL, conn); if (conn->schema_support) { char *escSchemaName; schema_strcat(schema_needed, "%.*s", szFkTableOwner, cbFkTableOwner, szFkTableName, cbFkTableName, conn); - escSchemaName = simpleCatalogEscape(schema_needed, SQL_NTS, NULL, conn); + escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, NULL, conn); snprintf(tables_query, sizeof(tables_query), "SELECT pt.tgargs, " " pt.tgnargs, " " pt.tgdeferrable, " @@ -4323,7 +4330,7 @@ PGAPI_ForeignKeys_old( "order by pt.tgconstrname", eq_string, escFkTableName); - result = PGAPI_ExecDirect(htbl_stmt, tables_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(htbl_stmt, (SQLCHAR *) tables_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { @@ -4466,7 +4473,10 @@ PGAPI_ForeignKeys_old( } got_pkname = FALSE; - keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, schema_fetched, SQL_NTS, pk_table_fetched, SQL_NTS, 0); + keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, + (SQLCHAR *) schema_fetched, SQL_NTS, + (SQLCHAR *) pk_table_fetched, SQL_NTS, + 0); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't get primary keys for PGAPI_ForeignKeys result.", func); @@ -4607,13 +4617,13 @@ PGAPI_ForeignKeys_old( */ else if (pk_table_needed[0] != '\0') { - escPkTableName = simpleCatalogEscape(pk_table_needed, SQL_NTS, NULL, conn); + escPkTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, NULL, conn); if (conn->schema_support) { char *escSchemaName; schema_strcat(schema_needed, "%.*s", szPkTableOwner, cbPkTableOwner, szPkTableName, cbPkTableName, conn); - escSchemaName = simpleCatalogEscape(schema_needed, SQL_NTS, NULL, conn); + escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, NULL, conn); snprintf(tables_query, sizeof(tables_query), "SELECT pt.tgargs, " " pt.tgnargs, " " pt.tgdeferrable, " @@ -4694,7 +4704,7 @@ PGAPI_ForeignKeys_old( " order by pt.tgconstrname", eq_string, escPkTableName); - result = PGAPI_ExecDirect(htbl_stmt, tables_query, SQL_NTS, 0); + result = PGAPI_ExecDirect(htbl_stmt, (SQLCHAR *) tables_query, SQL_NTS, 0); if (!SQL_SUCCEEDED(result)) { SC_error_copy(stmt, tbl_stmt, TRUE); @@ -4818,7 +4828,9 @@ PGAPI_ForeignKeys_old( SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't bindcol for primary keys for PGAPI_ForeignKeys result.", func); goto cleanup; } - keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, schema_needed, SQL_NTS, pk_table_needed, SQL_NTS, 0); + keyresult = PGAPI_PrimaryKeys(hpkey_stmt, NULL, 0, + (SQLCHAR *) schema_needed, SQL_NTS, + (SQLCHAR *) pk_table_needed, SQL_NTS, 0); if (keyresult != SQL_SUCCESS) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't get primary keys for PGAPI_ForeignKeys result.", func); @@ -5034,11 +5046,13 @@ PGAPI_ProcedureColumns( TupleField *tuple; char *schema_name, *procname; char *escSchemaName = NULL, *escProcName = NULL; - UCHAR *params, *proargnames, *proargmodes, *delim = NULL; + char *params, *proargnames; + char *proargmodes; + char *delim = NULL; char *atttypid, *attname, *column_name; QResultClass *res, *tres; SQLLEN tcount; - OID pgtype; + OID pgtype; Int4 paramcount, column_size, i, j; RETCODE result; BOOL search_pattern, bRetset; @@ -5277,14 +5291,14 @@ mylog("atttypid=%s\n", atttypid ? atttypid : "(null)"); pgtype = 0; if (params) { - while (isspace(*params) || ',' == *params) + while (isspace((unsigned char) *params) || ',' == *params) params++; if ('\0' == *params || '}' == *params) params = NULL; else { sscanf(params, "%u", &pgtype); - while (isdigit(*params)) + while (isdigit((unsigned char) *params)) params++; } } @@ -5311,7 +5325,7 @@ mylog("atttypid=%s\n", atttypid ? atttypid : "(null)"); } else { - for (delim = proargnames; *delim && !isspace(*delim) && ',' != *delim && '}' != *delim; delim++) + for (delim = proargnames; *delim && !isspace((unsigned char) *delim) && ',' != *delim && '}' != *delim; delim++) ; } if (proargnames && '\0' == *delim) /* discard the incomplete name */ @@ -5603,7 +5617,7 @@ PGAPI_TablePrivileges( const char *reln, *owner, *priv, *schnm = NULL; RETCODE result, ret = SQL_SUCCESS; const char *like_or_eq, *op_string; - const char *szSchemaName; + const SQLCHAR *szSchemaName; SQLSMALLINT cbSchemaName; char *escSchemaName = NULL, *escTableName = NULL; BOOL search_pattern; @@ -5922,7 +5936,7 @@ PGAPI_ForeignKeys_new( if (NULL != fk_table_needed) { mylog("%s: entering Foreign Key Case #2", func); - escTableName = simpleCatalogEscape(fk_table_needed, SQL_NTS, NULL, conn); + escTableName = simpleCatalogEscape((SQLCHAR *) fk_table_needed, SQL_NTS, NULL, conn); schema_strcat(schema_needed, "%.*s", szFkTableOwner, cbFkTableOwner, szFkTableName, cbFkTableName, conn); relqual = "\n and conrelid = c.oid"; } @@ -5933,7 +5947,7 @@ PGAPI_ForeignKeys_new( */ else if (NULL != pk_table_needed) { - escTableName = simpleCatalogEscape(pk_table_needed, SQL_NTS, NULL, conn); + escTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, NULL, conn); schema_strcat(schema_needed, "%.*s", szPkTableOwner, cbPkTableOwner, szPkTableName, cbPkTableName, conn); relqual = "\n and confrelid = c.oid"; } @@ -5953,7 +5967,7 @@ PGAPI_ForeignKeys_new( strcpy(catName, "NULL::name"); strcpy(scmName1, "n2.nspname"); strcpy(scmName2, "n1.nspname"); - escSchemaName = simpleCatalogEscape(schema_needed, SQL_NTS, NULL, conn); + escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, NULL, conn); snprintf(tables_query, sizeof(tables_query), "select" @@ -6051,7 +6065,7 @@ PGAPI_ForeignKeys_new( NULL != fk_table_needed) { free(escTableName); - escTableName = simpleCatalogEscape(pk_table_needed, SQL_NTS, NULL, conn); + escTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, NULL, conn); snprintf_add(tables_query, sizeof(tables_query), "\n where c2.relname %s'%s'", eq_string, escTableName); diff --git a/misc.c b/misc.c index b375b6f..fa8871d 100644 --- a/misc.c +++ b/misc.c @@ -111,7 +111,7 @@ strncpy_null(char *dst, const char *src, ssize_t len) *------ */ char * -make_string(const char *s, ssize_t len, char *buf, size_t bufsize) +make_string(const SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize) { size_t length; char *str; @@ -121,7 +121,7 @@ make_string(const char *s, ssize_t len, char *buf, size_t bufsize) if (len >= 0) length =len; else if (SQL_NTS == len) - length = strlen(s); + length = strlen((char *) s); else { mylog("make_string invalid length=%d\n", len); @@ -129,7 +129,7 @@ make_string(const char *s, ssize_t len, char *buf, size_t bufsize) } if (buf) { - strncpy_null(buf, s, bufsize > length ? length + 1 : bufsize); + strncpy_null(buf, (char *) s, bufsize > length ? length + 1 : bufsize); return buf; } @@ -139,7 +139,7 @@ inolog("str=%p\n", str); if (!str) return NULL; - strncpy_null(str, s, length + 1); + strncpy_null(str, (char *) s, length + 1); return str; } @@ -163,7 +163,7 @@ make_lstring_ifneeded(ConnectionClass *conn, const SQLCHAR *s, ssize_t len, BOOL encoded_str encstr; make_encoded_str(&encstr, conn, ccs); - for (i = 0, ptr = ccs; i < length; i++, ptr++) + for (i = 0, ptr = (const UCHAR *) ccs; i < length; i++, ptr++) { encoded_nextchar(&encstr); if (ENCODE_STATUS(encstr) != 0) @@ -206,7 +206,6 @@ my_strcat(char *buf, const char *fmt, const char *s, ssize_t len) if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) { size_t length = (len > 0) ? len : strlen(s); - size_t pos = strlen(buf); sprintf(&buf[pos], fmt, length, s); @@ -216,7 +215,7 @@ my_strcat(char *buf, const char *fmt, const char *s, ssize_t len) } char * -schema_strcat(char *buf, const char *fmt, const char *s, ssize_t len, const char *tbname, int tbnmlen, ConnectionClass *conn) +schema_strcat(char *buf, const char *fmt, const SQLCHAR *s, SQLLEN len, const SQLCHAR *tbname, SQLLEN tbnmlen, ConnectionClass *conn) { if (!s || 0 == len) { @@ -229,7 +228,7 @@ schema_strcat(char *buf, const char *fmt, const char *s, ssize_t len, const char return my_strcat(buf, fmt, CC_get_current_schema(conn), SQL_NTS); return NULL; } - return my_strcat(buf, fmt, s, len); + return my_strcat(buf, fmt, (char *) s, len); } @@ -286,7 +285,7 @@ my_strcat1(char *buf, const char *fmt, const char *s1, const char *s, ssize_t le } char * -schema_strcat1(char *buf, const char *fmt, const char *s1, const char *s, ssize_t len, const char *tbname, int tbnmlen, ConnectionClass *conn) +schema_strcat1(char *buf, const char *fmt, const char *s1, const char *s, ssize_t len, const SQLCHAR *tbname, int tbnmlen, ConnectionClass *conn) { if (!s || 0 == len) { diff --git a/misc.h b/misc.h index 254a9d4..a4ad777 100644 --- a/misc.h +++ b/misc.h @@ -24,13 +24,13 @@ char *strncpy_null(char *dst, const char *src, ssize_t len); size_t strlcat(char *, const char *, size_t); #endif /* HAVE_STRLCPY */ char *my_trim(char *string); -char *make_string(const char *s, ssize_t len, char *buf, size_t bufsize); +char *make_string(const SQLCHAR *s, SQLINTEGER len, char *buf, size_t bufsize); SQLCHAR *make_lstring_ifneeded(ConnectionClass *, const SQLCHAR *s, ssize_t len, BOOL); -char *schema_strcat(char *buf, const char *fmt, const char *s, ssize_t len, - const char *, int, ConnectionClass *conn); +char *schema_strcat(char *buf, const char *fmt, const SQLCHAR *s, SQLLEN len, + const SQLCHAR *, SQLLEN, ConnectionClass *conn); char *schema_strcat1(char *buf, const char *fmt, const char *s1, const char *s, ssize_t len, - const char *, int, ConnectionClass *conn); + const SQLCHAR *, int, ConnectionClass *conn); int snprintf_add(char *buf, size_t size, const char *format, ...); size_t snprintf_len(char *buf, size_t size, const char *format, ...); /* #define GET_SCHEMA_NAME(nspname) (stricmp(nspname, "public") ? nspname : "") */ diff --git a/multibyte.c b/multibyte.c index e532423..60ab587 100644 --- a/multibyte.c +++ b/multibyte.c @@ -79,7 +79,7 @@ static pg_CS CS_Alias[] = CSTR OTHER_STRING = "OTHER"; int -pg_CS_code(const UCHAR *characterset_string) +pg_CS_code(const char *characterset_string) { int i, c = -1; @@ -107,10 +107,11 @@ pg_CS_code(const UCHAR *characterset_string) return (c); } -UCHAR *check_client_encoding(const pgNAME conn_settings) +char * +check_client_encoding(const pgNAME conn_settings) { - const UCHAR *cptr, *sptr = NULL; - UCHAR *rptr; + const char *cptr, *sptr = NULL; + char *rptr; BOOL allowed_cmd = TRUE, in_quote = FALSE; int step = 0; size_t len = 0; @@ -465,12 +466,13 @@ CC_lookup_cs_old(ConnectionClass *self) if (!SQL_SUCCEEDED(result)) return encstr; - result = PGAPI_ExecDirect(hstmt, "Show Client_Encoding", SQL_NTS, 0); + result = PGAPI_ExecDirect(hstmt, (SQLCHAR *) "Show Client_Encoding", SQL_NTS, 0); if (result == SQL_SUCCESS_WITH_INFO) { - char sqlState[8], errormsg[128], enc[32]; + SQLCHAR sqlState[8]; + char errormsg[128], enc[32]; - if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, errormsg, + if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, (SQLCHAR *) errormsg, sizeof(errormsg), NULL) == SQL_SUCCESS && sscanf(errormsg, "%*s %*s %*s %*s %*s %s", enc) > 0) encstr = strdup(enc); diff --git a/multibyte.h b/multibyte.h index 882b20b..73fb3a8 100644 --- a/multibyte.h +++ b/multibyte.h @@ -57,11 +57,11 @@ enum { extern void CC_lookup_characterset(ConnectionClass *self); extern const char *get_environment_encoding(const ConnectionClass *conn, const char *setenc, const char *svrenc, BOOL bStartup); -extern int pg_CS_code(const UCHAR *stat_string); +extern int pg_CS_code(const char *stat_string); typedef struct pg_CS { - UCHAR *name; + char *name; int code; }pg_CS; extern size_t pg_mbslen(int ccsc, const UCHAR *string); @@ -71,7 +71,7 @@ extern UCHAR *pg_mbschr(int ccsc, const UCHAR *string, unsigned int character); typedef struct { int ccsc; - const UCHAR *encstr; + const char *encstr; ssize_t pos; int ccst; } encoded_str; @@ -82,7 +82,6 @@ void encoded_str_constr(encoded_str *encstr, int ccsc, const char *str); extern int encoded_nextchar(encoded_str *encstr); extern ssize_t encoded_position_shift(encoded_str *encstr, size_t shift); extern int encoded_byte_check(encoded_str *encstr, size_t abspos); -/* #define check_client_encoding(X) pg_CS_name(pg_CS_code(X)) -UCHAR *check_client_encoding(const UCHAR *sql_string); */ -UCHAR *check_client_encoding(const pgNAME sql_string); +/* #define check_client_encoding(X) pg_CS_name(pg_CS_code(X)) */ +char *check_client_encoding(const pgNAME sql_string); #endif /* __MULTIBUYTE_H__ */ diff --git a/odbcapi30w.c b/odbcapi30w.c index 5846978..9a48256 100644 --- a/odbcapi30w.c +++ b/odbcapi30w.c @@ -228,8 +228,8 @@ RETCODE SQL_API SQLGetDiagRecW(SQLSMALLINT fHandleType, buflen = cbErrorMsgMax; mtxt = malloc(buflen); } - ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qstr, - pfNativeError, mtxt, buflen, &tlen); + ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, (SQLCHAR *) qstr, + pfNativeError, (SQLCHAR *) mtxt, buflen, &tlen); if (SQL_SUCCEEDED(ret)) { if (qstr) diff --git a/odbcapiw.c b/odbcapiw.c index cea2d40..2c28d60 100644 --- a/odbcapiw.c +++ b/odbcapiw.c @@ -57,9 +57,12 @@ RETCODE SQL_API SQLColumnsW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_Columns(StatementHandle, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, - clName, (SQLSMALLINT) nmlen4, flag, 0, 0); + ret = PGAPI_Columns(StatementHandle, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, + flag, 0, 0); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -93,8 +96,10 @@ RETCODE SQL_API SQLConnectW(HDBC ConnectionHandle, svName = ucs2_to_utf8(ServerName, NameLength1, &nmlen1, FALSE); usName = ucs2_to_utf8(UserName, NameLength2, &nmlen2, FALSE); auth = ucs2_to_utf8(Authentication, NameLength3, &nmlen3, FALSE); - ret = PGAPI_Connect(ConnectionHandle, svName, (SQLSMALLINT) nmlen1, - usName, (SQLSMALLINT) nmlen2, auth, (SQLSMALLINT) nmlen3); + ret = PGAPI_Connect(ConnectionHandle, + (SQLCHAR *) svName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) usName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) auth, (SQLSMALLINT) nmlen3); LEAVE_CONN_CS(conn); if (svName) free(svName); @@ -139,8 +144,10 @@ RETCODE SQL_API SQLDriverConnectW(HDBC hdbc, } else if (pcbConnStrOut) pCSO = &olen; - ret = PGAPI_DriverConnect(hdbc, hwnd, szIn, (SQLSMALLINT) inlen, - szOut, maxlen, pCSO, fDriverCompletion); + ret = PGAPI_DriverConnect(hdbc, hwnd, + (SQLCHAR *) szIn, (SQLSMALLINT) inlen, + (SQLCHAR *) szOut, maxlen, + pCSO, fDriverCompletion); if (ret != SQL_ERROR && NULL != pCSO) { SQLLEN outlen = olen; @@ -192,8 +199,8 @@ RETCODE SQL_API SQLBrowseConnectW( szIn = ucs2_to_utf8(szConnStrIn, cbConnStrIn, &inlen, FALSE); obuflen = cbConnStrOutMax + 1; szOut = malloc(obuflen); - ret = PGAPI_BrowseConnect(hdbc, szIn, (SQLSMALLINT) inlen, - szOut, cbConnStrOutMax, &olen); + ret = PGAPI_BrowseConnect(hdbc, (SQLCHAR *) szIn, (SQLSMALLINT) inlen, + (SQLCHAR *) szOut, cbConnStrOutMax, &olen); LEAVE_CONN_CS(conn); if (ret != SQL_ERROR) { @@ -249,7 +256,8 @@ RETCODE SQL_API SQLDescribeColW(HSTMT StatementHandle, for (;; buflen = nmlen + 1, clName = realloc(clName, buflen)) { ret = PGAPI_DescribeCol(StatementHandle, ColumnNumber, - clName, buflen, &nmlen, DataType, ColumnSize, + (SQLCHAR *) clName, buflen, + &nmlen, DataType, ColumnSize, DecimalDigits, Nullable); if (SQL_SUCCESS_WITH_INFO != ret || nmlen < buflen) break; @@ -295,7 +303,8 @@ RETCODE SQL_API SQLExecDirectW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_ExecDirect(StatementHandle, stxt, (SQLINTEGER) slen, flag); + ret = PGAPI_ExecDirect(StatementHandle, + (SQLCHAR *) stxt, (SQLINTEGER) slen, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (stxt) @@ -324,7 +333,7 @@ RETCODE SQL_API SQLGetCursorNameW(HSTMT StatementHandle, StartRollbackState(stmt); for (;; buflen = clen + 1, crName = realloc(crName, buflen)) { - ret = PGAPI_GetCursorName(StatementHandle, crName, buflen, &clen); + ret = PGAPI_GetCursorName(StatementHandle, (SQLCHAR *) crName, buflen, &clen); if (SQL_SUCCESS_WITH_INFO != ret || clen < buflen) break; } @@ -402,7 +411,7 @@ RETCODE SQL_API SQLPrepareW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_Prepare(StatementHandle, stxt, (SQLINTEGER) slen); + ret = PGAPI_Prepare(StatementHandle, (SQLCHAR *) stxt, (SQLINTEGER) slen); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (stxt) @@ -424,7 +433,7 @@ RETCODE SQL_API SQLSetCursorNameW(HSTMT StatementHandle, ENTER_STMT_CS(stmt); SC_clear_error(stmt); StartRollbackState(stmt); - ret = PGAPI_SetCursorName(StatementHandle, crName, (SQLSMALLINT) nlen); + ret = PGAPI_SetCursorName(StatementHandle, (SQLCHAR *) crName, (SQLSMALLINT) nlen); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (crName) @@ -459,9 +468,11 @@ RETCODE SQL_API SQLSpecialColumnsW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName, - (SQLSMALLINT) nmlen1, scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, - Scope, Nullable); + ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + Scope, Nullable); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -499,9 +510,11 @@ RETCODE SQL_API SQLStatisticsW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_Statistics(StatementHandle, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, Unique, - Reserved); + ret = PGAPI_Statistics(StatementHandle, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + Unique, Reserved); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -545,9 +558,11 @@ RETCODE SQL_API SQLTablesW(HSTMT StatementHandle, if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_Tables(StatementHandle, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, - tbType, (SQLSMALLINT) nmlen4, flag); + ret = PGAPI_Tables(StatementHandle, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + (SQLCHAR *) tbType, (SQLSMALLINT) nmlen4, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -598,9 +613,12 @@ RETCODE SQL_API SQLColumnPrivilegesW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_ColumnPrivileges(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, - clName, (SQLSMALLINT) nmlen4, flag); + ret = PGAPI_ColumnPrivileges(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, + flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -652,10 +670,13 @@ RETCODE SQL_API SQLForeignKeysW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_ForeignKeys(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, - fkctName, (SQLSMALLINT) nmlen4, fkscName, (SQLSMALLINT) nmlen5, - fktbName, (SQLSMALLINT) nmlen6); + ret = PGAPI_ForeignKeys(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + (SQLCHAR *) fkctName, (SQLSMALLINT) nmlen4, + (SQLCHAR *) fkscName, (SQLSMALLINT) nmlen5, + (SQLCHAR *) fktbName, (SQLSMALLINT) nmlen6); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -699,8 +720,8 @@ RETCODE SQL_API SQLNativeSqlW( szOut = malloc(buflen); for (;; buflen = olen + 1, szOut = realloc(szOut, buflen)) { - ret = PGAPI_NativeSql(hdbc, szIn, (SQLINTEGER) slen, - szOut, buflen, &olen); + ret = PGAPI_NativeSql(hdbc, (SQLCHAR *) szIn, (SQLINTEGER) slen, + (SQLCHAR *) szOut, buflen, &olen); if (SQL_SUCCESS_WITH_INFO != ret || olen < buflen) break; } @@ -756,8 +777,10 @@ RETCODE SQL_API SQLPrimaryKeysW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_PrimaryKeys(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, 0); + ret = PGAPI_PrimaryKeys(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, 0); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -806,9 +829,12 @@ RETCODE SQL_API SQLProcedureColumnsW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_ProcedureColumns(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, prName, (SQLSMALLINT) nmlen3, - clName, (SQLSMALLINT) nmlen4, flag); + ret = PGAPI_ProcedureColumns(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) prName, (SQLSMALLINT) nmlen3, + (SQLCHAR *) clName, (SQLSMALLINT) nmlen4, + flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -856,9 +882,11 @@ RETCODE SQL_API SQLProceduresW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_Procedures(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, prName, - (SQLSMALLINT) nmlen3, flag); + ret = PGAPI_Procedures(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) prName, (SQLSMALLINT) nmlen3, + flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (ctName) @@ -904,8 +932,11 @@ RETCODE SQL_API SQLTablePrivilegesW( if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else - ret = PGAPI_TablePrivileges(hstmt, ctName, (SQLSMALLINT) nmlen1, - scName, (SQLSMALLINT) nmlen2, tbName, (SQLSMALLINT) nmlen3, flag); + ret = PGAPI_TablePrivileges(hstmt, + (SQLCHAR *) ctName, (SQLSMALLINT) nmlen1, + (SQLCHAR *) scName, (SQLSMALLINT) nmlen2, + (SQLCHAR *) tbName, (SQLSMALLINT) nmlen3, + flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS((StatementClass *) hstmt); if (ctName) diff --git a/parse.c b/parse.c index 7033487..b8ca674 100644 --- a/parse.c +++ b/parse.c @@ -817,8 +817,11 @@ getColumnsInfo(ConnectionClass *conn, TABLE_INFO *wti, OID greloid, StatementCla NULL, 0, NULL, 0, NULL, 0, PODBC_SEARCH_BY_IDS, greloid, 0); else - result = PGAPI_Columns(hcol_stmt, NULL, 0, SAFE_NAME(wti->schema_name), - SQL_NTS, SAFE_NAME(wti->table_name), SQL_NTS, NULL, 0, PODBC_NOT_SEARCH_PATTERN, 0, 0); + result = PGAPI_Columns(hcol_stmt, NULL, 0, + (SQLCHAR *) SAFE_NAME(wti->schema_name), SQL_NTS, + (SQLCHAR *) SAFE_NAME(wti->table_name), SQL_NTS, + NULL, 0, + PODBC_NOT_SEARCH_PATTERN, 0, 0); mylog(" Past PG_Columns\n"); res = SC_get_Curres(col_stmt); diff --git a/pgapi30.c b/pgapi30.c index 6e238c0..d87ae01 100644 --- a/pgapi30.c +++ b/pgapi30.c @@ -168,7 +168,7 @@ PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { - strncpy_null((SQLCHAR *) DiagInfoPtr, CC_get_DSN(conn), BufferLength); + strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else @@ -233,7 +233,7 @@ PGAPI_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { - strncpy_null((SQLCHAR *) DiagInfoPtr, CC_get_DSN(conn), BufferLength); + strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else @@ -337,7 +337,7 @@ inolog("rc=%d\n", rc); rtnlen = strlen(CC_get_DSN(conn)); if (DiagInfoPtr) { - strncpy_null((SQLCHAR *) DiagInfoPtr, CC_get_DSN(conn), BufferLength); + strncpy_null(DiagInfoPtr, CC_get_DSN(conn), BufferLength); ret = (BufferLength > rtnlen ? SQL_SUCCESS : SQL_SUCCESS_WITH_INFO); } else diff --git a/qresult.c b/qresult.c index 3423742..48feb36 100644 --- a/qresult.c +++ b/qresult.c @@ -1513,7 +1513,7 @@ inolog("will add %d added_tuples from %d and select the %dth added tuple\n", add { SQLLEN i, lf; SQLLEN lidx, hidx; - SQLULEN *deleted = self->deleted, *updated = self->updated; + SQLLEN *deleted = self->deleted, *updated = self->updated; num_backend_rows = QR_get_num_cached_tuples(self); /* For simplicty, use CURS_NEEDS_REREAD bit to mark the row */ @@ -1522,9 +1522,9 @@ inolog("will add %d added_tuples from %d and select the %dth added tuple\n", add hidx = RowIdx2GIdx(num_backend_rows, stmt); lidx = hidx - num_backend_rows; /* deleted info */ - for (i = 0; i < self->dl_count && hidx > (Int4)deleted[i]; i++) + for (i = 0; i < self->dl_count && hidx > deleted[i]; i++) { - if (lidx <= (Int4)deleted[i]) + if (lidx <= deleted[i]) { lf = num_backend_rows - hidx + deleted[i]; self->keyset[lf].status = self->deleted_keyset[i].status; @@ -1534,8 +1534,8 @@ inolog("will add %d added_tuples from %d and select the %dth added tuple\n", add } for (i = self->up_count - 1; i >= 0; i--) { - if (hidx > (Int4)updated[i] && - lidx <= (Int4)updated[i]) + if (hidx > updated[i] && + lidx <= updated[i]) { lf = num_backend_rows - hidx + updated[i]; /* in case the row is marked off */ diff --git a/qresult.h b/qresult.h index 0cb99ed..edeca98 100644 --- a/qresult.h +++ b/qresult.h @@ -105,11 +105,11 @@ struct QResultClass_ TupleField *added_tuples; /* added data by myself */ UInt2 dl_alloc; /* count of allocated deleted info */ UInt2 dl_count; /* count of deleted info */ - SQLULEN *deleted; /* deleted index info */ + SQLLEN *deleted; /* deleted index info */ KeySet *deleted_keyset; /* deleted keyset info */ UInt2 up_alloc; /* count of allocated updated info */ UInt2 up_count; /* count of updated info */ - SQLULEN *updated; /* updated index info */ + SQLLEN *updated; /* updated index info */ KeySet *updated_keyset; /* uddated keyset info */ TupleField *updated_tuples; /* uddated data by myself */ }; diff --git a/results.c b/results.c index dad6ea2..6a5ba22 100644 --- a/results.c +++ b/results.c @@ -375,7 +375,7 @@ inolog("answering bookmark info\n"); if (szColName && cbColNameMax > 0) { if (NULL != col_name) - strncpy_null(szColName, col_name, cbColNameMax); + strncpy_null((char *) szColName, col_name, cbColNameMax); else szColName[0] = '\0'; @@ -1247,10 +1247,10 @@ inolog("get %dth Valid data from %d to %s [dlt=%d]", nth, sta, orientation == SQ *nearest = sta - 1 + nth; if (SQL_FETCH_PRIOR == orientation) { - for (i = res->dl_count - 1; i >=0 && *nearest <= (SQLLEN) deleted[i]; i--) + for (i = res->dl_count - 1; i >=0 && *nearest <= deleted[i]; i--) { inolog("deleted[%d]=%d\n", i, deleted[i]); - if (sta >= (SQLLEN)deleted[i]) + if (sta >= deleted[i]) (*nearest)--; } inolog("nearest=%d\n", *nearest); @@ -1266,9 +1266,9 @@ inolog("nearest=%d\n", *nearest); { if (!QR_once_reached_eof(res)) num_tuples = INT_MAX; - for (i = 0; i < res->dl_count && *nearest >= (SQLLEN)deleted[i]; i++) + for (i = 0; i < res->dl_count && *nearest >= deleted[i]; i++) { - if (sta <= (SQLLEN)deleted[i]) + if (sta <= deleted[i]) (*nearest)++; } if (*nearest >= num_tuples) @@ -2243,7 +2243,7 @@ int AddDeleted(QResultClass *res, SQLULEN index, KeySet *keyset) { int i; Int2 dl_count, new_alloc; - SQLULEN *deleted; + SQLLEN *deleted; KeySet *deleted_keyset; UWORD status; Int2 num_fields = res->num_fields; @@ -2258,7 +2258,7 @@ inolog("AddDeleted %d\n", index); { dl_count = 0; new_alloc = 10; - QR_MALLOC_return_with_error(res->deleted, SQLULEN, sizeof(SQLULEN) * new_alloc, res, "Deleted index malloc error", FALSE); + QR_MALLOC_return_with_error(res->deleted, SQLLEN, sizeof(SQLLEN) * new_alloc, res, "Deleted index malloc error", FALSE); QR_MALLOC_return_with_error(res->deleted_keyset, KeySet, sizeof(KeySet) * new_alloc, res, "Deleted keyset malloc error", FALSE); deleted = res->deleted; deleted_keyset = res->deleted_keyset; @@ -2270,7 +2270,7 @@ inolog("AddDeleted %d\n", index); { new_alloc = res->dl_alloc * 2; res->dl_alloc = 0; - QR_REALLOC_return_with_error(res->deleted, SQLULEN, sizeof(SQLULEN) * new_alloc, res, "Deleted index realloc error", FALSE); + QR_REALLOC_return_with_error(res->deleted, SQLLEN, sizeof(SQLLEN) * new_alloc, res, "Deleted index realloc error", FALSE); deleted = res->deleted; QR_REALLOC_return_with_error(res->deleted_keyset, KeySet, sizeof(KeySet) * new_alloc, res, "Deleted KeySet realloc error", FALSE); deleted_keyset = res->deleted_keyset; @@ -2282,7 +2282,7 @@ inolog("AddDeleted %d\n", index); if (index < *deleted) break; } - memmove(deleted + 1, deleted, sizeof(SQLLEN) * (dl_count - i)); + memmove(deleted + 1, deleted, sizeof(SQLLEN) * (dl_count - i)); memmove(deleted_keyset + 1, deleted_keyset, sizeof(KeySet) * (dl_count - i)); } *deleted = index; @@ -2310,7 +2310,7 @@ static void RemoveDeleted(QResultClass *res, SQLLEN index) { int i, mv_count, rm_count = 0; SQLLEN pidx, midx; - SQLULEN *deleted, num_read = QR_get_num_total_read(res); + SQLLEN *deleted, num_read = QR_get_num_total_read(res); KeySet *deleted_keyset; mylog("RemoveDeleted index=%d\n", index); @@ -2337,7 +2337,7 @@ static void RemoveDeleted(QResultClass *res, SQLLEN index) { deleted = res->deleted + i; deleted_keyset = res->deleted_keyset + i; - memmove(deleted, deleted + 1, mv_count * sizeof(SQLULEN)); + memmove(deleted, deleted + 1, mv_count * sizeof(SQLLEN)); memmove(deleted_keyset, deleted_keyset + 1, mv_count * sizeof(KeySet)); } res->dl_count--; @@ -2350,7 +2350,7 @@ static void RemoveDeleted(QResultClass *res, SQLLEN index) static void CommitDeleted(QResultClass *res) { int i; - SQLULEN *deleted; + SQLLEN *deleted; KeySet *deleted_keyset; UWORD status; @@ -2398,7 +2398,7 @@ static BOOL enlargeUpdated(QResultClass *res, Int4 number, const StatementClass if (alloc <= res->up_alloc) return TRUE; - QR_REALLOC_return_with_error(res->updated, SQLULEN, sizeof(SQLULEN) * alloc, res, "enlargeUpdated failed", FALSE); + QR_REALLOC_return_with_error(res->updated, SQLLEN, sizeof(SQLLEN) * alloc, res, "enlargeUpdated failed", FALSE); QR_REALLOC_return_with_error(res->updated_keyset, KeySet, sizeof(KeySet) * alloc, res, "enlargeUpdated failed 2", FALSE); if (SQL_CURSOR_KEYSET_DRIVEN != stmt->options.cursor_type) QR_REALLOC_return_with_error(res->updated_tuples, TupleField, sizeof(TupleField) * res->num_fields * alloc, res, "enlargeUpdated failed 3", FALSE); @@ -2410,7 +2410,7 @@ static BOOL enlargeUpdated(QResultClass *res, Int4 number, const StatementClass static void AddUpdated(StatementClass *stmt, SQLLEN index) { QResultClass *res; - SQLULEN *updated; + SQLLEN *updated; KeySet *updated_keyset, *keyset; TupleField *updated_tuples = NULL, *tuple_updated, *tuple; SQLLEN kres_ridx; @@ -2521,7 +2521,7 @@ static void RemoveUpdated(QResultClass *res, SQLLEN index) static void RemoveUpdatedAfterTheKey(QResultClass *res, SQLLEN index, const KeySet *keyset) { - SQLULEN *updated, num_read = QR_get_num_total_read(res); + SQLLEN *updated, num_read = QR_get_num_total_read(res); KeySet *updated_keyset; TupleField *updated_tuples = NULL; SQLLEN pidx, midx, mv_count; @@ -2561,7 +2561,7 @@ static void RemoveUpdatedAfterTheKey(QResultClass *res, SQLLEN index, const KeyS mv_count = res->up_count - i -1; if (mv_count > 0) { - memmove(updated, updated + 1, sizeof(SQLULEN) * mv_count); + memmove(updated, updated + 1, sizeof(SQLLEN) * mv_count); memmove(updated_keyset, updated_keyset + 1, sizeof(KeySet) * mv_count); if (updated_tuples) memmove(updated_tuples, updated_tuples + num_fields, sizeof(TupleField) * num_fields * mv_count); @@ -3739,7 +3739,7 @@ SC_pos_update(StatementClass *stmt, } s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow; s.updyes = TRUE; - ret = PGAPI_ExecDirect(hstmt, updstr, SQL_NTS, 0); + ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) updstr, SQL_NTS, 0); if (ret == SQL_NEED_DATA) { pup_cdata *cbdata = (pup_cdata *) malloc(sizeof(pup_cdata)); @@ -4159,7 +4159,7 @@ SC_pos_add(StatementClass *stmt, mylog("addstr=%s\n", addstr); s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow; s.updyes = TRUE; - ret = PGAPI_ExecDirect(hstmt, addstr, SQL_NTS, 0); + ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) addstr, SQL_NTS, 0); if (ret == SQL_NEED_DATA) { padd_cdata *cbdata = (padd_cdata *) malloc(sizeof(padd_cdata)); @@ -4558,7 +4558,7 @@ PGAPI_GetCursorName( if (szCursor) { - strncpy_null(szCursor, SC_cursor_name(stmt), cbCursorMax); + strncpy_null((char *) szCursor, SC_cursor_name(stmt), cbCursorMax); if (len >= cbCursorMax) { diff --git a/win_unicode.c b/win_unicode.c index 7b13e9e..0b98614 100644 --- a/win_unicode.c +++ b/win_unicode.c @@ -197,7 +197,7 @@ utf8_to_ucs2_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, bufcount = 0; if (ilen < 0) ilen = strlen(utf8str); - for (i = 0, ocount = 0, str = utf8str; i < ilen && *str;) + for (i = 0, ocount = 0, str = (SQLCHAR *) utf8str; i < ilen && *str;) { /* if (iswascii(*str)) */ if (isascii(*str)) -- 2.39.5