common.h

Go to the documentation of this file.
00001 #ifndef DB_FREETDS_COMMON_SUPPORT
00002 #define DB_FREETDS_COMMON_SUPPORT
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : common support for db apps.                                       *
00007 *  Author : Chris Koeritz                                                     *
00008 *  Author : freetds team for some tidbits                                     *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 2008-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
00017 \*****************************************************************************/
00018 
00019 #include "db_freetds_dll.h"
00020 
00021 #if HAVE_CONFIG_H
00022   #include <config.h>
00023 #endif /* HAVE_CONFIG_H */
00024 
00025 #include <stdarg.h>
00026 #include <stdio.h>
00027 
00028 #if HAVE_STDLIB_H
00029   #include <stdlib.h>
00030 #endif /* HAVE_STDLIB_H */
00031 
00032 #if HAVE_STRING_H
00033   #include <string.h>
00034 #endif /* HAVE_STRING_H */
00035 
00036 #ifdef DBNTWIN32
00037   #include <windows.h>
00038 #endif
00039 
00040 #include <sqlfront.h>
00041 #include <sqldb.h>
00042 
00043 // forward.
00044 class istring;
00045 
00046 #ifdef DBNTWIN32
00047   /*
00048    * Define Sybase's symbols in terms of Microsoft's. 
00049    * This allows these tests to be run using Microsoft's include
00050    * files and library (libsybdb.lib).
00051    */
00052   #define MSDBLIB 1
00053   #define MICROSOFT_DBLIB 1
00054   #define dbloginfree(l) dbfreelogin(l)
00055 
00056   #define SYBESMSG    SQLESMSG
00057   #define SYBECOFL    SQLECOFL
00058 
00059   #define SYBAOPSUM   SQLAOPSUM
00060   #define SYBAOPMAX   SQLAOPMAX
00061 
00062   #define SYBINT4     SQLINT4
00063   #define SYBDATETIME SQLDATETIME
00064   #define SYBCHAR     SQLCHAR
00065   #define SYBVARCHAR  SQLVARCHAR
00066   #define SYBTEXT     SQLTEXT
00067   #define SYBBINARY   SQLBINARY
00068   #define SYBIMAGE    SQLIMAGE
00069 
00070   #define dberrhandle(h) dberrhandle((DBERRHANDLE_PROC) h)
00071   #define dbmsghandle(h) dbmsghandle((DBMSGHANDLE_PROC) h)
00072 #endif
00073 
00075 
00076 const char DB_FREETDS_SQL_ESCAPE_CHARACTER = '\\';
00077   // we use a backslash to escape special characters in queries.
00078 
00079 class DB_FREETDS_CLASS_STYLE common_database_support
00080 {
00081 public:
00082   static bool _error_was_seen;
00084 
00087 
00088   static int syb_msg_handler(DBPROCESS *dbproc, DBINT msgno,
00089      int msgstate, int severity, char *msgtext, char *srvname, char *procname,
00090      int line);
00091   // error handler that we hook into the db mechanism to catch failures.
00092   static int syb_err_handler(DBPROCESS *dbproc, int severity, int dberr,
00093      int oserr, char *dberrstr, char *oserrstr);
00094 
00096 
00099   static void nerf_special_characters(istring &to_nerf, char escape_char);
00100 
00101 };
00102 
00103 #endif  // outer guard.
00104 

Generated on Fri Nov 28 04:29:13 2008 for HOOPLE Libraries by  doxygen 1.5.1