From 99d21d5b62a54d64b95dc915a35fb35111bbc430 Mon Sep 17 00:00:00 2001 From: Byron Nikolaidis Date: Wed, 3 Jun 1998 20:33:45 +0000 Subject: Update odbc driver to current version V.0244 --- src/interfaces/odbc/misc.c | 67 ++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'src/interfaces/odbc/misc.c') diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c index 7ce83484d8d..382508d6730 100644 --- a/src/interfaces/odbc/misc.c +++ b/src/interfaces/odbc/misc.c @@ -1,28 +1,27 @@ - -/* Module: misc.c - * - * Description: This module contains miscellaneous routines - * such as for debugging/logging and string functions. - * - * Classes: n/a - * - * API functions: none - * - * Comments: See "notice.txt" for copyright and license information. - * - */ + +/* Module: misc.c + * + * Description: This module contains miscellaneous routines + * such as for debugging/logging and string functions. + * + * Classes: n/a + * + * API functions: none + * + * Comments: See "notice.txt" for copyright and license information. + * + */ #include -#include -#include +#include #include "psqlodbc.h" - + + extern GLOBAL_VALUES globals; #ifdef MY_LOG -#include void mylog(va_alist) @@ -52,7 +51,6 @@ static FILE *LOGFP = 0; #ifdef Q_LOG -#include void qlog(va_alist) va_dcl @@ -78,10 +76,17 @@ static FILE *LOGFP = 0; } #endif +/* Undefine these because windows.h will redefine and cause a warning */ +#undef va_start +#undef va_end + +#include +#include + /* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied (not including null term) */ int -my_strcpy(char *dst, size_t dst_len, char *src, size_t src_len) +my_strcpy(char *dst, int dst_len, char *src, int src_len) { if (dst_len <= 0) return STRCPY_FAIL; @@ -90,31 +95,23 @@ my_strcpy(char *dst, size_t dst_len, char *src, size_t src_len) dst[0] = '\0'; return STRCPY_NULL; } + else if (src_len == SQL_NTS) + src_len = strlen(src); - else if (src_len == SQL_NTS) { - if (src_len < dst_len) - strcpy(dst, src); - else { - memcpy(dst, src, dst_len-1); - dst[dst_len-1] = '\0'; /* truncated */ - return STRCPY_TRUNCATED; - } - } - - else if (src_len <= 0) + if (src_len <= 0) return STRCPY_FAIL; else { if (src_len < dst_len) { memcpy(dst, src, src_len); - dst[src_len] = '\0'; + dst[src_len] = '\0'; } else { memcpy(dst, src, dst_len-1); dst[dst_len-1] = '\0'; /* truncated */ return STRCPY_TRUNCATED; } - } + } return strlen(dst); } @@ -123,9 +120,9 @@ my_strcpy(char *dst, size_t dst_len, char *src, size_t src_len) // the destination string if src has len characters or more. // instead, I want it to copy up to len-1 characters and always // terminate the destination string. -char *strncpy_null(char *dst, const char *src, size_t len) +char *strncpy_null(char *dst, const char *src, int len) { -unsigned int i; +int i; if (NULL != dst) { @@ -138,7 +135,7 @@ unsigned int i; else if (len == SQL_NTS) len = strlen(src) + 1; - for(i = 0; src[i] && i < len - 1; i++) { + for(i = 0; src[i] && i < len - 1; i++) { dst[i] = src[i]; } -- cgit v1.2.3