summaryrefslogtreecommitdiff
path: root/src/interfaces/odbc/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/odbc/misc.c')
-rw-r--r--src/interfaces/odbc/misc.c67
1 files changed, 32 insertions, 35 deletions
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 <stdio.h>
-#include <windows.h>
-#include <sql.h>
+#include <varargs.h>
#include "psqlodbc.h"
-
+
+
extern GLOBAL_VALUES globals;
#ifdef MY_LOG
-#include <varargs.h>
void
mylog(va_alist)
@@ -52,7 +51,6 @@ static FILE *LOGFP = 0;
#ifdef Q_LOG
-#include <varargs.h>
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 <windows.h>
+#include <sql.h>
+
/* 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];
}