diff --git a/src/include/switch_odbc.h b/src/include/switch_odbc.h index 7b4c908cad..71977f3a2e 100644 --- a/src/include/switch_odbc.h +++ b/src/include/switch_odbc.h @@ -44,7 +44,9 @@ #endif #include -SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle; +SWITCH_BEGIN_EXTERN_C + +struct switch_odbc_handle; typedef enum { SWITCH_ODBC_STATE_INIT, @@ -59,7 +61,7 @@ typedef enum { SWITCH_ODBC_FAIL = -1 } switch_odbc_status_t; -SWITCH_DECLARE(switch_odbc_handle_t) * switch_odbc_handle_new(char *dsn, char *username, char *password); +SWITCH_DECLARE(switch_odbc_handle_t *) switch_odbc_handle_new(char *dsn, char *username, char *password); SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_disconnect(switch_odbc_handle_t *handle); SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_handle_t *handle); SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep); @@ -69,6 +71,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odb char *sql, switch_core_db_callback_func_t callback, void *pdata); SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt); SWITCH_END_EXTERN_C + #endif /* For Emacs: * Local Variables: diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 3f935bf27e..9585dc34b4 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -59,6 +59,12 @@ SWITCH_BEGIN_EXTERN_C */ #pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996) +#define SWITCH_HAVE_ODBC 1 + +#ifdef _MSC_VER +# pragma comment(lib, "odbc32.lib") +#endif + #pragma include_alias(, <../../libs/libteletone/src/libteletone.h>) #pragma include_alias(, <../../libs/libteletone/src/libteletone_generate.h>) #pragma include_alias(, <../../libs/libteletone/src/libteletone_detect.h>) diff --git a/src/switch_odbc.c b/src/switch_odbc.c index ff69f9d001..85245bb13e 100644 --- a/src/switch_odbc.c +++ b/src/switch_odbc.c @@ -28,6 +28,7 @@ * switch_odbc.c -- ODBC * */ +#include #include struct switch_odbc_handle { @@ -162,7 +163,6 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_hand return SWITCH_ODBC_SUCCESS; } - return SWITCH_ODBC_FAIL; } static int db_is_up(switch_odbc_handle_t *handle) @@ -227,7 +227,7 @@ static int db_is_up(switch_odbc_handle_t *handle) SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, char *sql, SQLHSTMT *rstmt) { - SQLHSTMT stmt; + SQLHSTMT stmt = NULL; int result; if (!db_is_up(handle)) { @@ -270,7 +270,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odbc_handle_t *handle, char *sql, switch_core_db_callback_func_t callback, void *pdata) { - SQLHSTMT stmt; + SQLHSTMT stmt = NULL; SQLSMALLINT c = 0, x = 0; SQLINTEGER m = 0; int result; @@ -320,7 +320,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odb names[y] = malloc(name_len); memset(names[y], 0, name_len); - SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable); + SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], (SQLSMALLINT)name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable); ColumnSize++; vals[y] = malloc(ColumnSize); diff --git a/w32/Library/FreeSwitchCore.vcproj b/w32/Library/FreeSwitchCore.vcproj index 7b78b1af93..e9db0e3a23 100644 --- a/w32/Library/FreeSwitchCore.vcproj +++ b/w32/Library/FreeSwitchCore.vcproj @@ -351,6 +351,10 @@ RelativePath="..\..\src\switch_log.c" > + + @@ -418,11 +422,11 @@ > + +