| 37 | } |
| 38 | |
| 39 | int main(void) |
| 40 | { |
| 41 | // WIN32 ����Ҫ���ô˺��������й� SOCKET �ij�ʼ�� |
| 42 | acl::acl_cpp_init(); |
| 43 | |
| 44 | // ������������־�������Ļ |
| 45 | acl::log::stdout_open(true); |
| 46 | |
| 47 | acl::string line; |
| 48 | acl::stdin_stream in; |
| 49 | acl::stdout_stream out; |
| 50 | |
| 51 | #if defined(_WIN32) || defined(_WIN64) |
| 52 | const char* libname = "libmysql.dll"; |
| 53 | #else |
| 54 | const char* libname = "libmysqlclient_r.so"; |
| 55 | #endif |
| 56 | |
| 57 | acl::string path; |
| 58 | |
| 59 | // ��Ϊ���ö�̬���صķ�ʽ��������ҪӦ�ø��� mysql �ͻ��˿����ڵ�·�� |
| 60 | out.format("Enter %s load path: ", libname); |
| 61 | if (in.gets(line) && !line.empty()) |
| 62 | #if defined(_WIN32) || defined(_WIN64) |
| 63 | path.format("%s\\%s", line.c_str(), libname); |
| 64 | #else |
| 65 | path.format("%s/%s", line.c_str(), libname); |
| 66 | #endif |
| 67 | else |
| 68 | path = libname; |
| 69 | |
| 70 | out.format("%s path: %s\r\n", libname, path.c_str()); |
| 71 | // ���ö�̬����ص�ȫ·�� |
| 72 | acl::db_handle::set_loadpath(path); |
| 73 | |
| 74 | const char* dbaddr = "127.0.0.1:16811"; |
| 75 | const char* dbname = "inc365_antispam_db"; |
| 76 | const char* dbuser = "root", *dbpass = ""; |
| 77 | acl::db_mysql db(dbaddr, dbname, dbuser, dbpass); |
| 78 | |
| 79 | |
| 80 | if (db.dbopen(NULL) == false) |
| 81 | { |
| 82 | printf("open db(%s) error\r\n", dbname); |
| 83 | getchar(); |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | printf("open db %s ok\r\n", dbname); |
| 88 | |
| 89 | int ret = tbl_select(db); |
| 90 | if (ret >= 0) |
| 91 | { |
| 92 | printf(">>select ok\r\n"); |
| 93 | } |
| 94 | else |
| 95 | printf(">>select error\r\n"); |
| 96 |
nothing calls this directly
no test coverage detected
searching dependent graphs…