Show
Ignore:
Timestamp:
11/18/09 04:40:30 (3 years ago)
Author:
mercyful
Message:

$ Build 438/Sql Alpha
+ Removed all SQLite Code and References.
+ Updated the SQL Wrapper, and all Automake files to now link in and also Detect MySql? in the configure scripts.
+ Added detection for OpenSSL, not in use yet, but will add encryption for passwords.

and anything else of intertest once everything is moved over to the SQL Backend.

This is still an interm develop update release, the MySql? backend
is still a WIP, and the Husky SMAPI Library will be removed shortly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/sql_Database.h

    r127 r129  
    1 /* 
     1/** 
    22 **     Database.h 
    33 ** 
    4  **     Published / author: 2005-08-12 / grymse@alhem.net 
     4 **     Published / author: 2001-02-15 / grymse@alhem.net 
    55 **/ 
    66 
    77/* 
    8 Copyright (C) 2001-2006  Anders Hedstrom 
     8Copyright (C) 2001  Anders Hedstrom 
    99 
    1010This program is made available under the terms of the GNU GPL. 
    1111 
    1212If you would like to use this program in a closed-source application, 
    13 a separate license agreement is available. For information about 
     13a separate license agreement is available. For information about  
    1414the closed-source license agreement for this program, please 
    1515visit http://www.alhem.net/sqlwrapped/license.html and/or 
     
    3131*/ 
    3232 
    33 #ifndef _DATABASE_H_SQLITE 
    34 #define _DATABASE_H_SQLITE 
     33#ifndef _DATABASE_H 
     34#define _DATABASE_H 
    3535 
    3636#ifdef _WIN32 
     
    4848#endif 
    4949 
    50 #include <sqlite3.h> 
    51 #include "sql_Database.h" 
    52  
    53 #ifdef SQLITEW_NAMESPACE 
    54 namespace SQLITEW_NAMESPACE { 
     50#ifdef MYSQLW_NAMESPACE 
     51namespace MYSQLW_NAMESPACE { 
    5552#endif 
    56  
    5753 
    5854class IError; 
     
    6157 
    6258 
    63 /** Connection information and pool. */ 
    64 class Database 
     59/** Connection information and pooling. */ 
     60class Database  
    6561{ 
     62        /** Mutex container class, used by Lock.  
     63                \ingroup threading */ 
    6664public: 
    67         /** Mutex container class, used by Lock. 
    68                 \ingroup threading */ 
    6965        class Mutex { 
    7066        public: 
     
    8076#endif 
    8177        }; 
     78        /** Mutex helper class. */ 
    8279private: 
    83         /** Mutex helper class. */ 
    8480        class Lock { 
    8581        public: 
     
    9490        struct OPENDB { 
    9591                OPENDB() : busy(false) {} 
    96                 sqlite3 *db; 
     92                MYSQL mysql; 
    9793                bool busy; 
    9894        }; 
    9995        typedef std::list<OPENDB *> opendb_v; 
     96         
     97        // Temp container for strip_escape 
     98        std::string d_tmpstr; 
    10099 
    101100public: 
    102         /** Use file */ 
     101        /** Use embedded libmysqld */ 
    103102        Database(const std::string& database, 
    104103                IError * = NULL); 
    105104 
    106         /** Use file + thread safe */ 
     105        /** Use embedded libmysqld + thread safe */ 
    107106        Database(Mutex& ,const std::string& database, 
    108107                IError * = NULL); 
    109108 
     109        /** Connect to a MySQL server */ 
     110        Database(const std::string& host, 
     111                const std::string& user, 
     112                const std::string& password = "", 
     113                const std::string& database = "", 
     114                IError * = NULL); 
     115 
     116        /** Connect to a MySQL server + thread safe */ 
     117        Database(Mutex& ,const std::string& host, 
     118                const std::string& user, 
     119                const std::string& password = "", 
     120                const std::string& database = "", 
     121                IError * = NULL); 
     122 
    110123        virtual ~Database(); 
     124 
     125        /** Callback after mysql_init */ 
     126        virtual void OnMyInit(OPENDB *); 
    111127 
    112128        /** try to establish connection with given host */ 
     
    115131        void RegErrHandler(IError *); 
    116132        void error(Query&,const char *format, ...); 
    117         void error(Query&,const std::string& ); 
    118133 
    119134        /** Request a database connection. 
     
    135150        void freedb(OPENDB *odb); 
    136151 
    137         /** Escape string - change all ' to ''. */ 
     152        // utility 
    138153        std::string safestr(const std::string& ); 
    139         /** Make string xml safe. */ 
     154        std::string unsafestr(const std::string& ); 
    140155        std::string xmlsafestr(const std::string& ); 
    141156 
    142         /** Convert string to 64-bit integer. */ 
    143157        int64_t a2bigint(const std::string& ); 
    144         /** Convert string to unsigned 64-bit integer. */ 
    145158        uint64_t a2ubigint(const std::string& ); 
     159         
     160        char *strip_escape(OPENDB *qodb, char* Oldstr); 
    146161 
    147162private: 
     
    150165        void error(const char *format, ...); 
    151166        // 
     167        std::string host; 
     168        std::string user; 
     169        std::string password; 
    152170        std::string database; 
    153171        opendb_v m_opendbs; 
     
    158176}; 
    159177 
    160  
    161 #ifdef SQLITEW_NAMESPACE 
    162 } // namespace SQLITEW_NAMESPACE { 
     178#ifdef MYSQLW_NAMESPACE 
     179} //namespace MYSQLW_NAMESPACE { 
    163180#endif 
    164181 
     182 
    165183#endif // _DATABASE_H