Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

dbapi.h

Go to the documentation of this file.
00001 
00023 /* GtkSQL -- an interactive graphical query tool for PostgreSQL and MySQL.
00024  * Copyright (C) 1998-2003  Lionel ULMER, Darryl Luff.
00025  *
00026  * This program is free software; you can redistribute it and/or modify
00027  * it under the terms of the GNU General Public License as published by
00028  * the Free Software Foundation; either version 2 of tdo_he License, or
00029  * (at your option) any later version.
00030  *
00031  * This program is distributed in the hope that it will be useful,
00032  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00033  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00034  * GNU General Public License for more details.
00035  *
00036  * You should have received a copy of the GNU General Public License
00037  * along with this program; if not, write to the Free Software
00038  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00039  */
00040 
00041 #ifndef _DBAPI_H
00042 #define _DBAPI_H
00043 
00044 #include "forms.h"
00045 
00047 enum QueryStatus {
00048     DB_QUERY_ERROR = 0,
00049     DB_QUERY_EMPTY = 1,
00050     DB_QUERY_COMMAND_OK = 2,
00051     DB_QUERY_RECORDS_OK = 3,
00052     DB_QUERY_OTHER = 4
00053 };
00054 
00056 enum ConnectStatus {
00057     CONNECT_DISCONNECTED = 0,
00058     CONNECT_ERROR,
00059     CONNECT_OK
00060 };
00061 
00063 typedef struct _dbconnector DBConnector;
00064 
00066 typedef struct _keyword {
00067     char *key;              
00068     int type;               
00069     struct _keyword *next;  
00070 } Keyword;
00071 
00073 typedef struct {
00074     char *name;     
00075     char *type;     
00076     char *length;   
00077 } DBFieldDef;
00078 
00080 typedef struct {
00081     char *name;             
00082     int field_num;          
00083     DBFieldDef *field_def;  
00084 } DBTableDef;
00085 
00089 struct db_conn {
00090     DBConnector *connector; 
00091     int connectionStatus;   
00093     /* Low-level SQL functions */
00094     /* Connection and status functions. */
00095     int (*DBdisconnect) (struct db_conn *); 
00097     /* Information functions. */
00098     char *(*DBget_error_message) (struct db_conn *);    
00099     char *(*DBget_db_name) (struct db_conn *);          
00101     /* Queries functions */
00102     void *(*DBexecute_query) (struct db_conn *, char *);    
00103     int (*DBget_query_status) (struct db_conn *, void *);   
00104     int (*DBget_record_number) (struct db_conn *, void *);  
00105     int (*DBget_field_number) (struct db_conn *, void *);   
00106     char *(*DBget_field_name) (struct db_conn *, void *, int field);    
00107     char *(*DBget_field_value) (struct db_conn *, void *, int record, int field);   
00108     void (*DBclear_result) (struct db_conn *, void *);  
00110     Keyword *keylist;   
00112     /* Tables functions (definitions, ...) */
00113     int (*DBget_table_def) (struct db_conn *);          
00114     void (*DBfree_table_def) (struct db_conn *);        
00115     int (*DBget_table_num) (struct db_conn *);          
00116     DBTableDef *(*DBget_table) (struct db_conn *, int); 
00118     /* Connection parameters    */
00119     char *server;   
00120     char *user;     
00121     char *pass;     
00123     void *pvt;  
00124     int pvtlen; 
00125 };
00126 
00128 typedef struct db_conn DBConnection;
00129 
00135 struct _dbconnector {
00136     char *dbtype;   
00139     int (*db_connect_callback) (DBConnector *, DBConnection **);
00140     void (*url_to_form) (Form *, char *);   
00141     char *(*form_to_url) (Form *);  
00143     Form *db_frm;   
00147     void (*app_error_dialog) (char *, char *);
00148 };
00149 
00150 extern DBConnector **connectorTable;
00151 
00153 typedef DBConnector *(*db_register_func) (void (*error_dialog) (char *, char *));
00154 
00156 DBConnection *db_connect(DBConnector *dbc);
00157 
00159 DBConnection *db_connect_url(char *url);
00160 
00162 void db_disconnect(DBConnection *conn, void(*display_error) (char *, char *));
00163 
00165 DBConnector *dbconnector_new(void);
00167 #endif

Generated on Sun May 9 19:19:16 2004 for GtkSQL by doxygen1.2.18