Main Page Modules Compound List File List Compound Members File Members Related Pages

# dblib.h

    00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    00002  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004  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 #ifdef __cplusplus
    00024 extern "C"
    00025 {
    00026 #if 0
    00027 }
    00028 #endif
    00029 #endif
    00030
    00031 static const char rcsid_dblib_h[] = "$Id: dblib.h,v 1.21.2.2 2005/01/06 01:51:17 jklowden Exp $";
    00032 static const void *const no_unused_dblib_h_warn[] = { rcsid_dblib_h, no_unused_dblib_h_warn };
    00033
    00034 enum {
    00035           _DB_RES_INIT            = 0
    00036         , _DB_RES_RESULTSET_EMPTY = 1
    00037         , _DB_RES_RESULTSET_ROWS  = 2
    00038         , _DB_RES_NEXT_RESULT     = 3
    00039         , _DB_RES_NO_MORE_RESULTS = 4
    00040         , _DB_RES_SUCCEED         = 5
    00041 };
    00042
    00043 struct tds_dblib_loginrec
    00044 {
    00045         TDSLOGIN *tds_login;
    00046 };
    00047
    00048 typedef struct tag_DBPROC_ROWBUF
    00049 {
    00050         int buffering_on;       /* (boolean) is row buffering turned on?     */
    00051         int first_in_buf;       /* result set row number of first row in buf */
    00052         int next_row;           /* result set row number of next row         */
    00053         int newest;             /* index of most recent item in queue        */
    00054         int oldest;             /* index of least recent item in queue       */
    00055         int elcount;            /* max element count that buffer can hold    */
    00056         int element_size;       /* size in bytes of each element in queue    */
    00057         int rows_in_buf;        /* # of rows currently in buffer             */
    00058         void *rows;             /* pointer to the row storage                */
    00059 } DBPROC_ROWBUF;
    00060
    00061 typedef struct
    00062 {
    00063         int host_column;
    00064         int datatype;
    00065         int prefix_len;
    00066         DBINT column_len;
    00067         BYTE *terminator;
    00068         int term_len;
    00069         int tab_colnum;
    00070         int column_error;
    00071         BCPCOLDATA *bcp_column_data;
    00072 } BCP_HOSTCOLINFO;
    00073
    00074 typedef struct
    00075 {
    00076         TDS_CHAR *hostfile;
    00077         TDS_CHAR *errorfile;
    00078         FILE *bcp_errfileptr;
    00079         TDS_INT host_colcount;
    00080         BCP_HOSTCOLINFO **host_columns;
    00081         TDS_INT firstrow;
    00082         TDS_INT lastrow;
    00083         TDS_INT maxerrs;
    00084         TDS_INT batch;
    00085 } BCP_HOSTFILEINFO;
    00086
    00087 typedef struct
    00088 {
    00089         char *hint;
    00090         TDS_CHAR *tablename;
    00091         TDS_CHAR *insert_stmt;
    00092         TDS_INT direction;
    00093         TDS_INT queryout;
    00094         TDS_INT identity_insert_on;
    00095         TDS_INT xfer_init;
    00096         TDS_INT var_cols;
    00097         TDS_INT bind_count;
    00098         TDSRESULTINFO *bindinfo;
    00099 } DB_BCPINFO;
    00100 /* linked list of rpc parameters */
    00101
    00102 typedef struct _DBREMOTE_PROC_PARAM
    00103 {
    00104         struct _DBREMOTE_PROC_PARAM *next;
    00105
    00106         char *name;
    00107         BYTE status;
    00108         int type;
    00109         DBINT maxlen;
    00110         DBINT datalen;
    00111         BYTE *value;
    00112 } DBREMOTE_PROC_PARAM;
    00113
    00114 typedef struct _DBREMOTE_PROC
    00115 {
    00116         struct _DBREMOTE_PROC *next;
    00117
    00118         char *name;
    00119         DBSMALLINT options;
    00120         DBREMOTE_PROC_PARAM *param_list;
    00121 } DBREMOTE_PROC;
    00122
    00123 struct tds_dblib_dbprocess
    00124 {
    00125         TDSSOCKET *tds_socket;
    00126
    00127         TDS_INT row_type;
    00128         DBPROC_ROWBUF row_buf;
    00129
    00130         int noautofree;
    00131         int more_results;       /* boolean.  Are we expecting results? */
    00132         int dbresults_state;
    00133         int dbresults_retcode;
    00134         BYTE *user_data;        /* see dbsetuserdata() and dbgetuserdata() */
    00135         unsigned char *dbbuf;   /* is dynamic!                   */
    00136         int dbbufsz;
    00137         int command_state;
    00138         TDS_INT text_size;
    00139         TDS_INT text_sent;
    00140         DBTYPEINFO typeinfo;
    00141         unsigned char avail_flag;
    00142         DBOPTION *dbopts;
    00143         DBSTRING *dboptcmd;
    00144         BCP_HOSTFILEINFO *hostfileinfo;
    00145         DB_BCPINFO *bcpinfo;
    00146         DBREMOTE_PROC *rpc;
    00147         DBUSMALLINT envchange_rcv;
    00148         char dbcurdb[DBMAXNAME + 1];
    00149         char servcharset[DBMAXNAME + 1];
    00150         FILE *ftos;
    00151         DB_DBCHKINTR_FUNC dbchkintr;
    00152         DB_DBHNDLINTR_FUNC dbhndlintr;
    00153
    00155         int msdblib;
    00156 };
    00157
    00158 #define DBLIB_INFO_MSG_TYPE 0
    00159 #define DBLIB_ERROR_MSG_TYPE 1
    00160
    00161 /*
    00162 ** internal prototypes
    00163 */
    00164 int _dblib_handle_info_message(TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
    00165 int _dblib_handle_err_message(TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
    00166 int _dblib_client_msg(DBPROCESS * dbproc, int dberr, int severity, const char *dberrstr);
    00167 void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
    00168
    00169 DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
    00170 DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
    00171
    00172 RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
    00173 RETCODE _bcp_get_term_var(BYTE * dataptr, BYTE * term, int term_len);
    00174 RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
    00175 int _bcp_readfmt_colinfo(DBPROCESS * dbproc, char *buf, BCP_HOSTCOLINFO * ci);
    00176 RETCODE _bcp_read_hostfile(DBPROCESS * dbproc, FILE * hostfile, FILE * errfile, int *row_error);
    00177
    00178 extern MHANDLEFUNC _dblib_msg_handler;
    00179 extern EHANDLEFUNC _dblib_err_handler;
    00180
    00181 #ifdef __cplusplus
    00182 #if 0
    00183 {
    00184 #endif
    00185 }
    00186 #endif
    00187
    00188 #endif