driver_manager_defs.h

00001 /* File: driver_manager_defs.h
00002 
00003 ** Author: Saikat Mukherjee
00004 
00005 ** Contact:   xsb-contact@cs.sunysb.edu
00006 
00007 ** 
00008 
00009 ** Copyright (C) The Research Foundation of SUNY, 2002-2006
00010 
00011 ** 
00012 
00013 ** XSB is free software; you can redistribute it and/or modify it under the
00014 
00015 ** terms of the GNU Library General Public License as published by the Free
00016 
00017 ** Software Foundation; either version 2 of the License, or (at your option)
00018 
00019 ** any later version.
00020 
00021 ** 
00022 
00023 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00024 
00025 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00026 
00027 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00028 
00029 ** more details.
00030 
00031 ** 
00032 
00033 ** You should have received a copy of the GNU Library General Public License
00034 
00035 ** along with XSB; if not, write to the Free Software Foundation,
00036 
00037 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00038 
00039 **
00040 
00041 */
00042 
00043 
00044 
00045 /*
00046 
00047 ** Data structures, function declarations for the driver_manager
00048 
00049 */
00050 
00051 
00052 
00053 #ifdef WIN_NT
00054 
00055 #include <windows.h>
00056 
00057 #endif
00058 
00059 
00060 
00061 #ifdef WIN_NT
00062 
00063 #define XSB_DLL
00064 
00065 #endif
00066 
00067 
00068 
00069 
00070 
00071 #define MAX_CONNECTIONS 25
00072 
00073 #define MAX_HANDLES 25
00074 
00075 #define MAX_DRIVERS 25
00076 
00077 #define MAX_QUERIES 100
00078 
00079 
00080 
00081 #define CONNECT 0 
00082 
00083 #define DISCONNECT 1
00084 
00085 #define QUERY 2
00086 
00087 #define PREPARE 3
00088 
00089 #define EXEC_PREPARE 4
00090 
00091 #define CLOSE_STMT 5
00092 
00093 #define ERROR_MESG 6
00094 
00095 
00096 
00097 #define INT_TYPE 1
00098 
00099 #define FLOAT_TYPE 2
00100 
00101 #define STRING_TYPE 3
00102 
00103 #define TERM_TYPE 4
00104 
00105 
00106 
00107 #define SUCCESS 0
00108 
00109 #define FAILURE -1
00110 
00111 
00112 
00113 #define QUERY_BEGIN 0
00114 
00115 #define QUERY_RETRIEVE 1
00116 
00117 
00118 
00119 #define QUERY_SIZE 10000
00120 
00121 #define ELEMENT_SIZE 1000
00122 
00123 
00124 
00125 #define TERM_CHAR '\255'
00126 
00127 
00128 
00129 // codes returned by bindReturnList
00130 
00131 #define RESULT_EMPTY_BUT_REQUESTED 0
00132 
00133 #define RESULT_NONEMPTY_OR_NOT_REQUESTED 1
00134 
00135 #define TOO_MANY_RETURN_COLS 2
00136 
00137 #define INVALID_RETURN_LIST 3
00138 
00139 #define TOO_FEW_RETURN_COLS 4
00140 
00141 
00142 
00143 // **** the database value data structures ****
00144 
00145 
00146 
00147 union xsb_value
00148 
00149 {
00150 
00151   int* i_val;
00152 
00153   double* f_val;
00154 
00155   char* str_val;
00156 
00157 };
00158 
00159 
00160 
00161 struct xsb_data
00162 
00163 {
00164 
00165   int type;
00166 
00167   int length;
00168 
00169   union xsb_value* val;
00170 
00171 };
00172 
00173 
00174 
00175 // **** the handle data structures ****
00176 
00177 
00178 
00179 struct xsb_connectionHandle
00180 
00181 {
00182 
00183   char* handle; //key
00184 
00185   char* server;
00186 
00187   char* user;
00188 
00189   char* database;
00190 
00191   char* password;
00192 
00193   char* dsn;
00194 
00195   char* driver;
00196 
00197 };
00198 
00199 
00200 
00201 struct xsb_queryHandle
00202 
00203 {
00204 
00205   struct xsb_connectionHandle* connHandle;
00206 
00207   char* handle;      /* key */
00208 
00209   char* query;
00210 
00211   int state;
00212 
00213   int numParams;     /* number of parameters to prepare statement */
00214 
00215   int numResultCols; /* number of columns in the result */
00216 
00217 };
00218 
00219 
00220 
00221 // **** the driver data structures ****
00222 
00223 
00224 
00225 
00226 
00227 struct driverFunction
00228 
00229 {
00230 
00231   int functionType;
00232 
00233   union functionPtrs* functionName;     
00234 
00235 };
00236 
00237 
00238 
00239 struct driver
00240 
00241 {
00242 
00243   char* driver;
00244 
00245   int numberFunctions;
00246 
00247   struct driverFunction** functions;
00248 
00249 };
00250 
00251 
00252 
00253 // **** the function ptrs and function declarations ****
00254 
00255 
00256 
00257 union functionPtrs
00258 
00259 {
00260 
00261   int (*connectDriver)(struct xsb_connectionHandle*);
00262 
00263   int (*disconnectDriver)(struct xsb_connectionHandle*);
00264 
00265   struct xsb_data** (*queryDriver)(struct xsb_queryHandle*);
00266 
00267   int (*prepareStmtDriver)(struct xsb_queryHandle*);
00268 
00269   struct xsb_data** (*executeStmtDriver)(struct xsb_data**, struct xsb_queryHandle*);
00270 
00271   int (*closeStmtDriver)(struct xsb_queryHandle*);
00272 
00273   char* (*errorMesgDriver)();
00274 
00275 };
00276 
00277 
00278 
00279 DllExport int call_conv registerXSBDriver(char* driver, int num);
00280 
00281 DllExport int call_conv registerXSBFunction(char* dr, int type, union functionPtrs* func);
00282 
00283 
00284 
00285 
00286 
00287 
00288 

Generated on Wed Jul 26 13:30:44 2006 for XSB by  doxygen 1.4.5