00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MY_CON_H
00033 #define MY_CON_H
00034
00035 #include "../../lib/srdb1/db_pool.h"
00036 #include "../../lib/srdb1/db_id.h"
00037
00038 #include <time.h>
00039 #include <stdio.h>
00040 #include <string.h>
00041 #include <sql.h>
00042 #include <sqlext.h>
00043 #include <sqlucode.h>
00044
00045
00046 #define STRN_LEN 1024
00047
00048 typedef struct strn
00049 {
00050 char s[STRN_LEN];
00051 } strn;
00052
00053
00054 struct my_con
00055 {
00056 struct db_id* id;
00057 unsigned int ref;
00058 struct pool_con* next;
00059 SQLHENV env;
00060 SQLHSTMT stmt_handle;
00061 SQLHDBC dbc;
00062 char** row;
00063 time_t timestamp;
00064 };
00065
00066
00067
00068
00069 #define CON_RESULT(db_con) (((struct my_con*)((db_con)->tail))->stmt_handle)
00070 #define CON_CONNECTION(db_con) (((struct my_con*)((db_con)->tail))->dbc)
00071 #define CON_ROW(db_con) (((struct my_con*)((db_con)->tail))->row)
00072 #define CON_TIMESTAMP(db_con) (((struct my_con*)((db_con)->tail))->timestamp)
00073 #define CON_ID(db_con) (((struct my_con*)((db_con)->tail))->id)
00074 #define CON_ENV(db_con) (((struct my_con*)((db_con)->tail))->env)
00075
00076 #define MAX_CONN_STR_LEN 2048
00077
00078
00079
00080
00081
00082 struct my_con* db_unixodbc_new_connection(struct db_id* id);
00083
00084
00085
00086
00087 void db_unixodbc_free_connection(struct my_con* con);
00088
00089 char *db_unixodbc_build_conn_str(const struct db_id* id, char *buf);
00090
00091 void db_unixodbc_extract_error(const char *fn, const SQLHANDLE handle, const SQLSMALLINT type, char* stret);
00092
00093 #endif