提交 f6eefa99 编写于 作者: F freemine

1. remove obsolete codes in tests/main.c

2. linux port of todbcinst
上级 cc496e12
...@@ -497,13 +497,6 @@ int main(int argc, char *argv[]) { ...@@ -497,13 +497,6 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
if (argc==2 && strcmp(argv[1], "uninstall")==0) {
DWORD usage = 0;
BOOL ok = SQLRemoveDriver("TAOS ODBC", TRUE, &usage);
D("ok/usage: %d/%d", ok, usage);
return ok ? 0 : 1;
}
const char *dsn = (argc>1) ? argv[1] : NULL; const char *dsn = (argc>1) ? argv[1] : NULL;
const char *uid = (argc>2) ? argv[2] : NULL; const char *uid = (argc>2) ? argv[2] : NULL;
const char *pwd = (argc>3) ? argv[3] : NULL; const char *pwd = (argc>3) ? argv[3] : NULL;
......
...@@ -2,7 +2,7 @@ PROJECT(TDengine) ...@@ -2,7 +2,7 @@ PROJECT(TDengine)
IF (TD_LINUX) IF (TD_LINUX)
ADD_EXECUTABLE(todbcinst main.c) ADD_EXECUTABLE(todbcinst main.c)
TARGET_LINK_LIBRARIES(todbcinst odbc) TARGET_LINK_LIBRARIES(todbcinst odbc odbcinst)
ENDIF () ENDIF ()
IF (TD_WINDOWS_64) IF (TD_WINDOWS_64)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#endif #endif
#include <odbcinst.h> #include <odbcinst.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -36,14 +37,17 @@ int main(int argc, char *argv[]) { ...@@ -36,14 +37,17 @@ int main(int argc, char *argv[]) {
} }
static void usage(const char *arg0) { static void usage(const char *arg0) {
fprintf(stderr, "%s -h | -i -n [TaosDriverName] -p [TaosDriverPath] | -u [-f] [TaosDriverName]\n", arg0); fprintf(stderr, "%s -h | -i -n [TaosDriverName] -p [TaosDriverPath] | -u [-f] -n [TaosDriverName]\n", arg0);
return; return;
} }
static int do_install(int i, int argc, char *argv[]) { static int do_install(int i, int argc, char *argv[]) {
int forceful = 0;
const char* driverName = NULL; const char* driverName = NULL;
#ifdef _MSC_VER
const char* driverFile = "todbc.dll"; const char* driverFile = "todbc.dll";
#else
const char* driverFile = "libtodbc.so";
#endif
const char* driverPath = NULL; const char* driverPath = NULL;
for (; i < argc; ++i) { for (; i < argc; ++i) {
const char *arg = argv[i]; const char *arg = argv[i];
...@@ -82,7 +86,7 @@ static int do_install(int i, int argc, char *argv[]) { ...@@ -82,7 +86,7 @@ static int do_install(int i, int argc, char *argv[]) {
char buf[8192]; char buf[8192];
snprintf(buf, sizeof(buf), "%s%cDriver=%s%cFileUage=0%cConnectFunctions=YYN%c", snprintf(buf, sizeof(buf), "%s%cDriver=%s%cFileUage=0%cConnectFunctions=YYN%c",
driverName, 0, driverFile, 0, 0, 0); driverName, 0, driverFile, 0, 0, 0);
BOOL ok = TRUE; BOOL ok = 1;
DWORD usageCount = 1; DWORD usageCount = 1;
char installed[PATH_MAX + 1]; char installed[PATH_MAX + 1];
WORD len = 0; WORD len = 0;
...@@ -91,7 +95,13 @@ static int do_install(int i, int argc, char *argv[]) { ...@@ -91,7 +95,13 @@ static int do_install(int i, int argc, char *argv[]) {
fprintf(stderr, "failed to query TaosDriverName: [%s]\n", driverName); fprintf(stderr, "failed to query TaosDriverName: [%s]\n", driverName);
return -1; return -1;
} }
if (stricmp(driverPath, installed)) { int r = 0;
#ifdef _MSC_VER
r = stricmp(driverPath, installed);
#else
r = strcasecmp(driverPath, installed);
#endif
if (r) {
fprintf(stderr, "previously installed TaosDriver [%s] has different target path [%s]\n" fprintf(stderr, "previously installed TaosDriver [%s] has different target path [%s]\n"
"it shall be uninstalled before you can install it to different path [%s]\n", "it shall be uninstalled before you can install it to different path [%s]\n",
driverName, installed, driverPath); driverName, installed, driverPath);
...@@ -134,10 +144,10 @@ static int do_uninstall(int i, int argc, char *argv[]) { ...@@ -134,10 +144,10 @@ static int do_uninstall(int i, int argc, char *argv[]) {
fprintf(stderr, "TaosDriverName not specified\n"); fprintf(stderr, "TaosDriverName not specified\n");
return -1; return -1;
} }
BOOL ok = TRUE; BOOL ok = 1;
DWORD usageCount = 1; DWORD usageCount = 1;
do { do {
ok = SQLRemoveDriver(driverName, FALSE, &usageCount); ok = SQLRemoveDriver(driverName, 0, &usageCount);
if (!ok) { if (!ok) {
fprintf(stderr, "failed to remove driver [%s]\n", driverName); fprintf(stderr, "failed to remove driver [%s]\n", driverName);
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册