FreeTDS API: /home/jklowden/releases/freetds-0.91/include/dblib.h Source File

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

# /home/jklowden/releases/freetds-0.91/include/dblib.h

    00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    00002  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005  Brian Bruns
    00003  *
    00004  * This library is free software; you can redistribute it and/or
    00005  * modify it under the terms of the GNU Library General Public
    00006  * License as published by the Free Software Foundation; either
    00007  * version 2 of the License, or (at your option) any later version.
    00008  *
    00009  * This library is distributed in the hope that it will be useful,
    00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  * Library General Public License for more details.
    00013  *
    00014  * You should have received a copy of the GNU Library General Public
    00015  * License along with this library; if not, write to the
    00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  * Boston, MA 02111-1307, USA.
    00018  */
    00019
    00020 #ifndef _dblib_h_
    00021 #define _dblib_h_
    00022
    00023 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
    00024 #pragma GCC visibility push(hidden)
    00025 #endif
    00026
    00027 #ifdef __cplusplus
    00028 extern "C"
    00029 {
    00030 #if 0
    00031 }
    00032 #endif
    00033 #endif
    00034
    00035 /* $Id: dblib.h,v 1.46 2010/01/25 23:05:58 freddy77 Exp $ */
    00036
    00037 typedef enum tag_DB_RESULT_STATE {
    00038           _DB_RES_INIT
    00039         , _DB_RES_RESULTSET_EMPTY
    00040         , _DB_RES_RESULTSET_ROWS
    00041         , _DB_RES_NEXT_RESULT
    00042         , _DB_RES_NO_MORE_RESULTS
    00043         , _DB_RES_SUCCEED
    00044 } DB_RESULT_STATE;
    00045
    00046 struct tds_dblib_loginrec
    00047 {
    00048         TDSLOGIN *tds_login;
    00049 };
    00050
    00051 struct dblib_buffer_row;
    00052
    00053 typedef struct tag_DBPROC_ROWBUF
    00054 {
    00055         int received;           /* how many rows have been received for this result set */
    00056         int head;               /* queue insertion point */
    00057         int tail;               /* oldest item in queue */
    00058         int current;            /* dbnextrow() reads this row */
    00059         int capacity;           /* how many elements the queue can hold  */
    00060         struct dblib_buffer_row *rows;          /* pointer to the row storage */
    00061 } DBPROC_ROWBUF;
    00062
    00063 typedef struct
    00064 {
    00065         int host_column;
    00066         int datatype;
    00067         int prefix_len;
    00068         DBINT column_len;
    00069         BYTE *terminator;
    00070         int term_len;
    00071         int tab_colnum;
    00072         int column_error;
    00073         BCPCOLDATA *bcp_column_data;
    00074 } BCP_HOSTCOLINFO;
    00075
    00076 typedef struct
    00077 {
    00078         TDS_CHAR *hostfile;
    00079         TDS_CHAR *errorfile;
    00080         FILE *bcp_errfileptr;
    00081         TDS_INT host_colcount;
    00082         BCP_HOSTCOLINFO **host_columns;
    00083         TDS_INT firstrow;
    00084         TDS_INT lastrow;
    00085         TDS_INT maxerrs;
    00086         TDS_INT batch;
    00087 } BCP_HOSTFILEINFO;
    00088
    00089 /* linked list of rpc parameters */
    00090
    00091 typedef struct _DBREMOTE_PROC_PARAM
    00092 {
    00093         struct _DBREMOTE_PROC_PARAM *next;
    00094
    00095         char *name;
    00096         BYTE status;
    00097         int type;
    00098         DBINT maxlen;
    00099         DBINT datalen;
    00100         BYTE *value;
    00101 } DBREMOTE_PROC_PARAM;
    00102
    00103 typedef struct _DBREMOTE_PROC
    00104 {
    00105         struct _DBREMOTE_PROC *next;
    00106
    00107         char *name;
    00108         DBSMALLINT options;
    00109         DBREMOTE_PROC_PARAM *param_list;
    00110 } DBREMOTE_PROC;
    00111
    00112 #define MAXOPTTEXT    32
    00113
    00114 struct dboption
    00115 {
    00116         char text[MAXOPTTEXT];
    00117         DBSTRING *param;
    00118         DBBOOL factive;
    00119 };
    00120 typedef struct dboption DBOPTION;
    00121
    00122 typedef struct _null_representation
    00123 {
    00124         const BYTE *bindval;
    00125         size_t len;
    00126 } NULLREP;
    00127
    00128 struct tds_dblib_dbprocess
    00129 {
    00130         TDSSOCKET *tds_socket;
    00131
    00132         TDS_INT row_type;
    00133         DBPROC_ROWBUF row_buf;
    00134
    00135         int noautofree;
    00136         int more_results;       /* boolean.  Are we expecting results? */
    00137         DB_RESULT_STATE dbresults_state;
    00138         int dbresults_retcode;
    00139         BYTE *user_data;        /* see dbsetuserdata() and dbgetuserdata() */
    00140         unsigned char *dbbuf;   /* is dynamic!                   */
    00141         int dbbufsz;
    00142         int command_state;
    00143         TDS_INT text_size;
    00144         TDS_INT text_sent;
    00145         DBTYPEINFO typeinfo;
    00146         unsigned char avail_flag;
    00147         DBOPTION *dbopts;
    00148         DBSTRING *dboptcmd;
    00149         BCP_HOSTFILEINFO *hostfileinfo;
    00150         TDSBCPINFO *bcpinfo;
    00151         DBREMOTE_PROC *rpc;
    00152         DBUSMALLINT envchange_rcv;
    00153         char dbcurdb[DBMAXNAME + 1];
    00154         char servcharset[DBMAXNAME + 1];
    00155         FILE *ftos;
    00156         DB_DBCHKINTR_FUNC chkintr;
    00157         DB_DBHNDLINTR_FUNC hndlintr;
    00158
    00160         int msdblib;
    00161
    00162         int ntimeouts;
    00163
    00165         NULLREP         nullreps[MAXBINDTYPES];
    00166 };
    00167
    00168 /*
    00169  * internal prototypes
    00170  */
    00171 int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
    00172 int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
    00173 int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
    00174 int _dblib_check_and_handle_interrupt(void * vdbproc);
    00175
    00176 void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
    00177
    00178 DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
    00179 DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
    00180
    00181 RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
    00182 RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
    00183
    00184 extern MHANDLEFUNC _dblib_msg_handler;
    00185 extern EHANDLEFUNC _dblib_err_handler;
    00186
    00187 #define CHECK_PARAMETER(x, msg, ret)    if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
    00188 #define CHECK_DBPROC() CHECK_PARAMETER(dbproc, SYBENULL, FAIL)
    00189 #define CHECK_NULP(x, func, param_num, ret)     if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
    00190 #define CHECK_PARAMETER_NOPROC(x, msg)  if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
    00191 #define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
    00192 #define DBPERROR_RETURN3(x, msg, a, b, c)       if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
    00193
    00194
    00195 #ifdef __cplusplus
    00196 #if 0
    00197 {
    00198 #endif
    00199 }
    00200 #endif
    00201
    00202 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
    00203 #pragma GCC visibility pop
    00204 #endif
    00205
    00206 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines