Changeset 129
- Timestamp:
- 11/18/09 04:40:30 (3 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 19 modified
-
ChangeLog (modified) (1 diff)
-
INSTALL (modified) (1 diff)
-
README (modified) (5 diffs)
-
configure.in (modified) (3 diffs)
-
enthral.kdevelop (modified) (4 diffs)
-
enthral.kdevelop.pcs (modified) (previous)
-
enthral.kdevses (modified) (1 diff)
-
file_id.diz (modified) (1 diff)
-
src/Makefile.am (modified) (2 diffs)
-
src/Makefile.in (modified) (7 diffs)
-
src/sql_Database.cpp (modified) (12 diffs)
-
src/sql_Database.h (modified) (10 diffs)
-
src/sql_IError.h (modified) (5 diffs)
-
src/sql_Query.cpp (modified) (11 diffs)
-
src/sql_Query.h (modified) (6 diffs)
-
src/sql_StderrLog.cpp (modified) (4 diffs)
-
src/sql_StderrLog.h (modified) (3 diffs)
-
src/sql_SysLog.cpp (modified) (5 diffs)
-
src/sql_SysLog.h (modified) (4 diffs)
-
src/sql_enum_t.cpp (added)
-
src/sql_enum_t.h (added)
-
src/sql_set_t.cpp (added)
-
src/sql_set_t.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r128 r129 1 2 /=/==================================================================================================== 3 $ Fixes and updates since Build 438/Sql Alpha 4 $ Build 438/Sql Alpha 5 + Removed all SQLite Code and References. 6 + Updated the SQL Wrapper, and all Automake files to now link in and also Detect MySql in the 7 configure scripts. 8 + Added detection for OpenSSL, not in use yet, but will add encryption for passwords. 9 and anything else of intertest once everything is moved over to the SQL Backend. 10 11 This is still an interm develop update release, the MySql backend is still a WIP, and Husky SMAPI 12 will be removed shortly. 1 13 /=/==================================================================================================== 2 14 $ Fixes and updates since Build 437/SQlite Alpha -
trunk/INSTALL
r92 r129 2 2 ================== 3 3 4 These are generic installation instructions. 4 You can run the install.pl script to install and compile the source in your current 5 Directoy. 5 6 6 The `configure' shell script attempts to guess correct values for 7 various system-dependent variables used during compilation. It uses 8 those values to create a `Makefile' in each directory of the package. 9 It may also create one or more `.h' files containing system-dependent 10 definitions. Finally, it creates a shell script `config.status' that 11 you can run in the future to recreate the current configuration, a file 12 `config.cache' that saves the results of its tests to speed up 13 reconfiguring, and a file `config.log' containing compiler output 14 (useful mainly for debugging `configure'). 7 Or you can manally run. 15 8 16 If you need to do unusual things to compile the package, please try 17 to figure out how `configure' could check whether to do them, and mail 18 diffs or instructions to the address given in the `README' so they can 19 be considered for the next release. If at some point `config.cache' 20 contains results you don't want to keep, you may remove or edit it. 9 $ ./autogen.sh (detects OS and Platform and generates configure script) 10 $ ./configure (run the configure script to setup make files) 11 $ gmake (gmake or make is fine) 21 12 22 The file `configure.in' is used to create `configure' by a program 23 called `autoconf'. You only need `configure.in' if you want to change24 i t or regenerate `configure' using a newer version of `autoconf'.13 Some dependencies exists, you should have Autotools installed beore running either method. 14 Some distro's don't have much installed, so you should check and verify the follow are 15 installed before trying to compile. 25 16 26 The simplest way to compile this package is: 17 g++ compiler (c++ compiler) 18 libc (standard library for c/c++) 19 sed (needed for scripts) 20 wget (downloads programs from the web) 21 automake (Development tools for ccompiling source code) 22 libtools (Used with automake to detect compiling settings) 23 Husky SMAPI Lib, (Install.pl will download and attempt to compile it) 24 xinetd / telnetd (Used for Answering and Handeling Telnet Connections) 25 mysql Database/Libs (New - Now Required, still WIP) 27 26 28 1. `cd' to the directory containing the package's source code and type 29 `./configure' to configure the package for your system. If you're 30 using `csh' on an old version of System V, you might need to type 31 `sh ./configure' instead to prevent `csh' from trying to execute 32 `configure' itself. 27 python (optional) 28 perl (optional) 29 OpenSSL (Optional) 33 30 34 Running `configure' takes a while. While running, it prints some35 messages telling which features it is checking for.36 31 37 2. Type `make' to compile the package. 32 I believe i have everything here, although it's easy to miss something accross different 33 linux/bsd/osx distro's. If i have, please let me know so we can keep track and make 34 getting everything setup easier on everyone. 38 35 39 3. Type `make install' to install the programs and any data files and40 documentation.41 42 4. You can remove the program binaries and object files from the43 source code directory by typing `make clean'.44 45 Compilers and Options46 =====================47 48 Some systems require unusual options for compilation or linking that49 the `configure' script does not know about. You can give `configure'50 initial values for variables by setting them in the environment. Using51 a Bourne-compatible shell, you can do that on the command line like52 this:53 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure54 55 Or on systems that have the `env' program, you can do it like this:56 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure57 58 Compiling For Multiple Architectures59 ====================================60 61 You can compile the package for more than one kind of computer at the62 same time, by placing the object files for each architecture in their63 own directory. To do this, you must use a version of `make' that64 supports the `VPATH' variable, such as GNU `make'. `cd' to the65 directory where you want the object files and executables to go and run66 the `configure' script. `configure' automatically checks for the67 source code in the directory that `configure' is in and in `..'.68 69 If you have to use a `make' that does not supports the `VPATH'70 variable, you have to compile the package for one architecture at a time71 in the source code directory. After you have installed the package for72 one architecture, use `make distclean' before reconfiguring for another73 architecture.74 75 Installation Names76 ==================77 78 By default, `make install' will install the package's files in79 `/usr/local/bin', `/usr/local/man', etc. You can specify an80 installation prefix other than `/usr/local' by giving `configure' the81 option `--prefix=PATH'.82 83 You can specify separate installation prefixes for84 architecture-specific files and architecture-independent files. If you85 give `configure' the option `--exec-prefix=PATH', the package will use86 PATH as the prefix for installing programs and libraries.87 Documentation and other data files will still use the regular prefix.88 89 If the package supports it, you can cause programs to be installed90 with an extra prefix or suffix on their names by giving `configure' the91 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.92 93 Optional Features94 =================95 96 Some packages pay attention to `--enable-FEATURE' options to97 `configure', where FEATURE indicates an optional part of the package.98 They may also pay attention to `--with-PACKAGE' options, where PACKAGE99 is something like `gnu-as' or `x' (for the X Window System). The100 `README' should mention any `--enable-' and `--with-' options that the101 package recognizes.102 103 For packages that use the X Window System, `configure' can usually104 find the X include and library files automatically, but if it doesn't,105 you can use the `configure' options `--x-includes=DIR' and106 `--x-libraries=DIR' to specify their locations.107 108 Specifying the System Type109 ==========================110 111 There may be some features `configure' can not figure out112 automatically, but needs to determine by the type of host the package113 will run on. Usually `configure' can figure that out, but if it prints114 a message saying it can not guess the host type, give it the115 `--host=TYPE' option. TYPE can either be a short name for the system116 type, such as `sun4', or a canonical name with three fields:117 CPU-COMPANY-SYSTEM118 119 See the file `config.sub' for the possible values of each field. If120 `config.sub' isn't included in this package, then this package doesn't121 need to know the host type.122 123 If you are building compiler tools for cross-compiling, you can also124 use the `--target=TYPE' option to select the type of system they will125 produce code for and the `--build=TYPE' option to select the type of126 system on which you are compiling the package.127 128 Sharing Defaults129 ================130 131 If you want to set default values for `configure' scripts to share,132 you can create a site shell script called `config.site' that gives133 default values for variables like `CC', `cache_file', and `prefix'.134 `configure' looks for `PREFIX/share/config.site' if it exists, then135 `PREFIX/etc/config.site' if it exists. Or, you can set the136 `CONFIG_SITE' environment variable to the location of the site script.137 A warning: not all `configure' scripts look for a site script.138 139 Operation Controls140 ==================141 142 `configure' recognizes the following options to control how it143 operates.144 145 `--cache-file=FILE'146 Use and save the results of the tests in FILE instead of147 `./config.cache'. Set FILE to `/dev/null' to disable caching, for148 debugging `configure'.149 150 `--help'151 Print a summary of the options to `configure', and exit.152 153 `--quiet'154 `--silent'155 `-q'156 Do not print messages saying which checks are being made.157 158 `--srcdir=DIR'159 Look for the package's source code in directory DIR. Usually160 `configure' can determine that directory automatically.161 162 `--version'163 Print the version of Autoconf used to generate the `configure'164 script, and exit.165 166 `configure' also accepts some other, not widely useful, options.167 -
trunk/README
r128 r129 1 1 /=/==================================================================================================== 2 2 3 Enthral BBS - 11/1 7/2009 Build 437/SQ Alpha.3 Enthral BBS - 11/18/2009 Build 438/SQ Alpha. 4 4 5 5 Interm Release, This release or code sync is just to get the code in development up to date … … 10 10 Extra Release Notes. 11 11 ############################################################## 12 Extra Release Notes, this temp version currently is linking SQLite, if you get any problems13 compiling this source, make sure you have the sqlite3 lib, this will be removed soon though14 a s we've changed to MySQL.12 Extra Release Notes, this temp version currently is linking MySql, if you get any problems 13 compiling this source, make sure you have the Mysql installed, the software is now moving 14 away from the Husky SAMPI (JAM Message Format) to a MySql Database. 15 15 16 16 … … 23 23 scripts that will update and compile your current Enthral install via 24 24 the svn. 25 26 Basic Installation - PreREQ and small overview. 27 ================== 28 29 You can run the install.pl script to install and compile the source in your current 30 Directoy. 31 32 Or you can manally run. 33 34 $ ./autogen.sh (detects OS and Platform and generates configure script) 35 $ ./configure (run the configure script to setup make files) 36 $ gmake (gmake or make is fine) 37 38 Some dependencies exists, you should have Autotools installed beore running either method. 39 Some distro's don't have much installed, so you should check and verify the follow are 40 installed before trying to compile. 41 42 g++ compiler (c++ compiler) 43 libc (standard library for c/c++) 44 sed (needed for scripts) 45 wget (downloads programs from the web) 46 automake (Development tools for ccompiling source code) 47 libtools (Used with automake to detect compiling settings) 48 Husky SMAPI Lib, (Install.pl will download and attempt to compile it) 49 xinetd / telnetd (Used for Answering and Handeling Telnet Connections) 50 mysql Database/Libs (New - Now Required, still WIP) 51 52 53 python (optional) 54 perl (optional) 55 OpenSSL (Optional) 56 57 I believe i have everything here, although it's easy to miss something accross different 58 linux/bsd/osx distro's. If i have, please let me know so we can keep track and make 59 getting everything setup easier on everyone. 60 61 MySQL instructions will be coming soon once it's more intergrated and used in the system. 25 62 26 63 /=/==================================================================================================== … … 35 72 36 73 You need to have perl installed on your system to use the install script. 74 Along with the PreREQ's mentioned above. 37 75 38 76 /=/==================================================================================================== … … 164 202 Netsurge, Esc, and even pook who have also setup the bbs for testing. 165 203 166 204 -=+[Team Enthral]+=- 167 205 Mike -Mercyful Fate 168 206 Frank -Netsurge -
trunk/configure.in
r117 r129 8 8 AC_LANG_CPLUSPLUS 9 9 AC_PROG_CXX 10 11 AC_PROG_LIBTOOL 12 AC_PROG_MAKE_SET 13 AC_PROG_CC 14 10 15 11 16 m4_pattern_allow([^AM_PROG_LIBTOOL$]) … … 28 33 AH_VERBATIM([USING_LINUX],[#undef USING_LINUX]) 29 34 AH_VERBATIM([OLD_PERL],[#undef OLD_PERL]) 35 36 37 dnl ********************************************************************* 38 dnl ** MYSql ************************************************************ 39 dnl ********************************************************************* 40 41 echo Detecting MySQL ... 42 43 # mysql autodetected. 44 45 # checking for mysql library. 46 AC_CHECK_HEADER([mysql/mysql.h]) 47 AC_PATH_PROG([mysql_config], [mysql_config]) 48 49 # checking for mysql environment. 50 if test "$ac_cv_header_mysql_mysql_h" = "yes" -a -n "$mysql_config"; then 51 MYSQL_CFLAGS="$(mysql_config --cflags)" 52 MYSQL_LDFLAGS="$(mysql_config --libs)" 53 AC_SUBST(MYSQL_CFLAGS) 54 AC_SUBST(MYSQL_LDFLAGS) 55 56 # define the mysql name and version. 57 AC_DEFINE_UNQUOTED(PLUGIN_NAME_MYSQL, "mysql", [Plugin name as Prefix.]) 58 AC_DEFINE_UNQUOTED(PLUGIN_VERSION_MYSQL, "$(mysql_config --version)", [Plugin version for MySQL.]) 59 fi 60 61 # define automake rule for compiling. 62 AM_CONDITIONAL([HAVE_MYSQL], [test "$ac_cv_header_mysql_mysql_h" = "yes"]) 63 64 65 # check if no database backends are available, that doesn't make sense for a sql plugin. :) 66 if test -z "$ac_cv_header_mysql_mysql_h"; then 67 AC_MSG_ERROR([*** no database backend found, install development and library files]) 68 fi 30 69 31 70 … … 143 182 AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes") 144 183 145 echo =[Python]======= 184 echo =[OpenSSL Detection]==================== 185 echo checking for OpenSSL for Encryption [Not Yet Implimented]. 186 # Checking openssl library. 187 AC_CHECK_HEADER([openssl/des.h], [], [AC_MSG_ERROR([*** des.h is required, install openssl header files])]) 188 AC_CHECK_HEADER([openssl/evp.h], [], [AC_MSG_ERROR([*** evp.h is required, install openssl header files])]) 189 AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_init], [], [AC_MSG_ERROR([*** EVP_CIPHER_CTX_init is required, install openssl library files])]) 190 AC_CHECK_LIB([crypto], [EVP_MD_CTX_init], [], [AC_MSG_ERROR([*** EVP_MD_CTX_init is required, install openssl library files])]) 191 AC_CHECK_LIB([crypto], [DES_crypt], [], [AC_MSG_ERROR([*** DES_crypt is required, install openssl library files])]) 192 echo =[OpenSSL Detection]==================== 193 echo 194 echo =[Plugin Detection]===================== 195 echo =[MySQL]================================ 196 echo PLUGINS: MySQL: $ac_cv_header_mysql_mysql_h 197 echo PLUGINS: MySQL: $MYSQL_CFLAGS 198 echo PLUGINS: MySQL: $MYSQL_LDFLAGS 199 echo 200 echo =[Python]=============================== 146 201 echo PLUGINS: Python: $python 147 202 echo PLUGINS: Python: $PY_VER 148 203 echo PLUGINS: Python: $PY_LIB 149 204 echo PLUGINS: Python: $PY_INC 150 echo =[Perl - WIP]=== 205 echo 206 echo =[Perl]================================= 151 207 echo PLUGINS: Perl: $perl 152 208 echo PLUGINS: Perl: $PERL_CFLAGS 153 209 echo PLUGINS: Perl: $PERL_LDFLAGS 154 echo =[Done]========= 155 210 echo =[Done]================================= 211 212 AC_SUBST(MYSQL_CFLAGS) 213 AC_SUBST(MYSQL_LDFLAGS) 156 214 157 215 AC_SUBST(PY_CFLAGS) -
trunk/enthral.kdevelop
r125 r129 14 14 <projectdirectory>file:///home/merc/enthral/trunk</projectdirectory> 15 15 <absoluteprojectpath>false</absoluteprojectpath> 16 <description />16 <description></description> 17 17 <secondaryLanguages/> 18 18 <versioncontrol>kdevsubversion</versioncontrol> 19 19 <projectname>enthral</projectname> 20 <defaultencoding />20 <defaultencoding></defaultencoding> 21 21 </general> 22 22 <kdevautoproject> … … 98 98 <f77compilerbinary/> 99 99 <cflags/> 100 <cxxflags >-m32</cxxflags>100 <cxxflags/> 101 101 <f77flags/> 102 102 </default> … … 236 236 <references/> 237 237 <creategettersetter> 238 <prefixGet />238 <prefixGet></prefixGet> 239 239 <prefixSet>set</prefixSet> 240 240 <prefixVariable>m_,_</prefixVariable> … … 262 262 <general> 263 263 <programargs/> 264 <gdbpath />264 <gdbpath></gdbpath> 265 265 <dbgshell>libtool</dbgshell> 266 <configGdbScript />267 <runShellScript />268 <runGdbScript />266 <configGdbScript></configGdbScript> 267 <runShellScript></runShellScript> 268 <runGdbScript></runGdbScript> 269 269 <breakonloadinglibs>true</breakonloadinglibs> 270 270 <separatetty>false</separatetty> -
trunk/enthral.kdevses
r118 r129 2 2 <!DOCTYPE KDevPrjSession> 3 3 <KDevPrjSession> 4 <DocsAndViews NumberOfDocuments="0" /> 4 <DocsAndViews NumberOfDocuments="2" > 5 <Doc0 NumberOfViews="1" URL="file:///home/merc/enthral_work/src/sql_set_t.cpp" > 6 <View0 Encoding="" Type="Source" /> 7 </Doc0> 8 <Doc1 NumberOfViews="1" URL="file:///home/merc/enthral_work/configure.in" > 9 <View0 Encoding="" line="29" Type="Source" /> 10 </Doc1> 11 </DocsAndViews> 5 12 <pluginList> 6 13 <kdevdebugger> -
trunk/file_id.diz
r128 r129 4 4 |_____|__|__||____|__|__|__| |___._||__| 5 5 +<:<-------------------------------->:>+ 6 ! build 43 7of the enthral bbs system |6 ! build 438 of the enthral bbs system | 7 7 + for *nix/bsd. For more info visit: : 8 8 : + -
trunk/src/Makefile.am
r127 r129 2 2 enthral_SOURCES = configbbs.cpp conio.cpp console.cpp data_areas.cpp dtfunc.cpp \ 3 3 enthral.cpp file_area.cpp file_edit.cpp file_list.cpp files.cpp history.cpp \ 4 language.cpp logon.cpp main_system.cpp menu_func.cpp msg_api.cpp \ 5 sql_Database.cpp sql_Query.cpp sql_StderrLog.cpp sql_SysLog.cpp msg_area.cpp \ 4 language.cpp logon.cpp main_system.cpp menu_func.cpp msg_api.cpp msg_area.cpp \ 6 5 msg_edit.cpp msg_email.cpp msg_fse.cpp msg_new.cpp msg_newscan.cpp msg_pack.cpp \ 7 6 msg_quote.cpp msg_read.cpp msg_readll.cpp msg_stats.cpp msg_title.cpp msgs.cpp \ 8 node.cpp plenthral.cpp pyenthral.cpp user_list.cpp users.cpp 7 node.cpp plenthral.cpp pyenthral.cpp sql_Database.cpp sql_Query.cpp \ 8 sql_StderrLog.cpp sql_SysLog.cpp sql_enum_t.cpp sql_set_t.cpp user_list.cpp users.cpp 9 9 10 10 # set the include path found by configure … … 16 16 17 17 18 enthral_LDADD = -lpthread -lsqlite3 libsmapilnx.a $(PY_LIBS)18 enthral_LDADD = $(PY_LIBS) -lpthread -lmysqlclient libsmapilnx.a 19 19 noinst_HEADERS = api_brow.h compiler.h configbbs.h conio.h console.h \ 20 20 data_areas.h dtfunc.h file_area.h file_edit.h file_list.h files.h history.h \ 21 language.h logon.h main_system.h menu_func.h msg_api.h \ 22 sql_Database.h sql_Query.h sql_StderrLog.h sql_SysLog.h sql_IError.h msg_email.h msg_fse.h \ 23 msg_email.h msg_fse.h \ 21 language.h logon.h main_system.h menu_func.h msg_api.h msg_email.h msg_fse.h \ 24 22 msg_new.h msg_pack.h msg_read.h msg_readll.h msg_stats.h msg_title.h msgapi.h \ 25 msgs.h node.h stamp.h struct.h typedefs.h user_list.h users.h 23 msgs.h node.h sql_Database.h sql_IError.h sql_Query.h sql_StderrLog.h \ 24 sql_SysLog.h sql_enum_t.h sql_set_t.h stamp.h struct.h typedefs.h user_list.h \ 25 users.h 26 26 27 27 -
trunk/src/Makefile.in
r127 r129 57 57 file_list.$(OBJEXT) files.$(OBJEXT) history.$(OBJEXT) \ 58 58 language.$(OBJEXT) logon.$(OBJEXT) main_system.$(OBJEXT) \ 59 menu_func.$(OBJEXT) msg_api.$(OBJEXT) sql_Database.$(OBJEXT) \ 60 sql_Query.$(OBJEXT) sql_StderrLog.$(OBJEXT) \ 61 sql_SysLog.$(OBJEXT) msg_area.$(OBJEXT) msg_edit.$(OBJEXT) \ 62 msg_email.$(OBJEXT) msg_fse.$(OBJEXT) msg_new.$(OBJEXT) \ 63 msg_newscan.$(OBJEXT) msg_pack.$(OBJEXT) msg_quote.$(OBJEXT) \ 64 msg_read.$(OBJEXT) msg_readll.$(OBJEXT) msg_stats.$(OBJEXT) \ 65 msg_title.$(OBJEXT) msgs.$(OBJEXT) node.$(OBJEXT) \ 66 plenthral.$(OBJEXT) pyenthral.$(OBJEXT) user_list.$(OBJEXT) \ 59 menu_func.$(OBJEXT) msg_api.$(OBJEXT) msg_area.$(OBJEXT) \ 60 msg_edit.$(OBJEXT) msg_email.$(OBJEXT) msg_fse.$(OBJEXT) \ 61 msg_new.$(OBJEXT) msg_newscan.$(OBJEXT) msg_pack.$(OBJEXT) \ 62 msg_quote.$(OBJEXT) msg_read.$(OBJEXT) msg_readll.$(OBJEXT) \ 63 msg_stats.$(OBJEXT) msg_title.$(OBJEXT) msgs.$(OBJEXT) \ 64 node.$(OBJEXT) plenthral.$(OBJEXT) pyenthral.$(OBJEXT) \ 65 sql_Database.$(OBJEXT) sql_Query.$(OBJEXT) \ 66 sql_StderrLog.$(OBJEXT) sql_SysLog.$(OBJEXT) \ 67 sql_enum_t.$(OBJEXT) sql_set_t.$(OBJEXT) user_list.$(OBJEXT) \ 67 68 users.$(OBJEXT) 68 69 enthral_OBJECTS = $(am_enthral_OBJECTS) 69 70 am__DEPENDENCIES_1 = 70 enthral_DEPENDENCIES = libsmapilnx.a $(am__DEPENDENCIES_1)71 enthral_DEPENDENCIES = $(am__DEPENDENCIES_1) libsmapilnx.a 71 72 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) 72 73 depcomp = $(SHELL) $(top_srcdir)/depcomp … … 120 121 FGREP = @FGREP@ 121 122 GREP = @GREP@ 123 HAVE_MYSQL_FALSE = @HAVE_MYSQL_FALSE@ 124 HAVE_MYSQL_TRUE = @HAVE_MYSQL_TRUE@ 122 125 INSTALL_DATA = @INSTALL_DATA@ 123 126 INSTALL_PROGRAM = @INSTALL_PROGRAM@ … … 133 136 LTLIBOBJS = @LTLIBOBJS@ 134 137 MAKEINFO = @MAKEINFO@ 138 MYSQL_CFLAGS = @MYSQL_CFLAGS@ 139 MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ 135 140 NM = @NM@ 136 141 NMEDIT = @NMEDIT@ … … 195 200 mandir = @mandir@ 196 201 mkdir_p = @mkdir_p@ 202 mysql_config = @mysql_config@ 197 203 oldincludedir = @oldincludedir@ 198 204 pdfdir = @pdfdir@ … … 209 215 enthral_SOURCES = configbbs.cpp conio.cpp console.cpp data_areas.cpp dtfunc.cpp \ 210 216 enthral.cpp file_area.cpp file_edit.cpp file_list.cpp files.cpp history.cpp \ 211 language.cpp logon.cpp main_system.cpp menu_func.cpp msg_api.cpp \ 212 sql_Database.cpp sql_Query.cpp sql_StderrLog.cpp sql_SysLog.cpp msg_area.cpp \ 217 language.cpp logon.cpp main_system.cpp menu_func.cpp msg_api.cpp msg_area.cpp \ 213 218 msg_edit.cpp msg_email.cpp msg_fse.cpp msg_new.cpp msg_newscan.cpp msg_pack.cpp \ 214 219 msg_quote.cpp msg_read.cpp msg_readll.cpp msg_stats.cpp msg_title.cpp msgs.cpp \ 215 node.cpp plenthral.cpp pyenthral.cpp user_list.cpp users.cpp 220 node.cpp plenthral.cpp pyenthral.cpp sql_Database.cpp sql_Query.cpp \ 221 sql_StderrLog.cpp sql_SysLog.cpp sql_enum_t.cpp sql_set_t.cpp user_list.cpp users.cpp 216 222 217 223 … … 221 227 # the library search path. 222 228 enthral_LDFLAGS = $(all_libraries) 223 enthral_LDADD = -lpthread -lsqlite3 libsmapilnx.a $(PY_LIBS)229 enthral_LDADD = $(PY_LIBS) -lpthread -lmysqlclient libsmapilnx.a 224 230 noinst_HEADERS = api_brow.h compiler.h configbbs.h conio.h console.h \ 225 231 data_areas.h dtfunc.h file_area.h file_edit.h file_list.h files.h history.h \ 226 language.h logon.h main_system.h menu_func.h msg_api.h \ 227 sql_Database.h sql_Query.h sql_StderrLog.h sql_SysLog.h sql_IError.h msg_email.h msg_fse.h \ 228 msg_email.h msg_fse.h \ 232 language.h logon.h main_system.h menu_func.h msg_api.h msg_email.h msg_fse.h \ 229 233 msg_new.h msg_pack.h msg_read.h msg_readll.h msg_stats.h msg_title.h msgapi.h \ 230 msgs.h node.h stamp.h struct.h typedefs.h user_list.h users.h 234 msgs.h node.h sql_Database.h sql_IError.h sql_Query.h sql_StderrLog.h \ 235 sql_SysLog.h sql_enum_t.h sql_set_t.h stamp.h struct.h typedefs.h user_list.h \ 236 users.h 231 237 232 238 _SOURCES = pyenthral.h plenthral.h … … 338 344 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql_StderrLog.Po@am__quote@ 339 345 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql_SysLog.Po@am__quote@ 346 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql_enum_t.Po@am__quote@ 347 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql_set_t.Po@am__quote@ 340 348 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_list.Po@am__quote@ 341 349 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/users.Po@am__quote@ -
trunk/src/sql_Database.cpp
r127 r129 1 /* 1 /** 2 2 ** Database.cpp 3 3 ** 4 ** Published / author: 200 5-08-12/ grymse@alhem.net4 ** Published / author: 2001-02-15 / grymse@alhem.net 5 5 **/ 6 6 7 7 /* 8 Copyright (C) 2001 -2006Anders Hedstrom8 Copyright (C) 2001 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. … … 37 37 #include <string> 38 38 #include <map> 39 #ifdef WIN32 40 #include <config-win.h> 41 #include <mysql.h> 42 #else 39 43 #include <stdio.h> 40 44 #include <stdlib.h> 41 45 #include <string.h> 42 #include < sqlite3.h>46 #include <mysql/mysql.h> 43 47 #include <stdarg.h> 48 #endif 44 49 45 50 #include "sql_IError.h" … … 47 52 48 53 49 #ifdef SQLITEW_NAMESPACE50 namespace SQLITEW_NAMESPACE {54 #ifdef MYSQLW_NAMESPACE 55 namespace MYSQLW_NAMESPACE { 51 56 #endif 52 57 … … 72 77 73 78 79 Database::Database(const std::string& h,const std::string& u,const std::string& p,const std::string& d,IError *e) 80 :host(h) 81 ,user(u) 82 ,password(p) 83 ,database(d) 84 ,m_errhandler(e) 85 ,m_embedded(false) 86 ,m_mutex(m_mutex) 87 ,m_b_use_mutex(false) 88 { 89 } 90 91 92 Database::Database(Mutex& m,const std::string& h,const std::string& u,const std::string& p,const std::string& d,IError *e) 93 :host(h) 94 ,user(u) 95 ,password(p) 96 ,database(d) 97 ,m_errhandler(e) 98 ,m_embedded(false) 99 ,m_mutex(m) 100 ,m_b_use_mutex(true) 101 { 102 } 103 104 74 105 Database::~Database() 75 106 { … … 77 108 { 78 109 OPENDB *p = *it; 79 sqlite3_close(p -> db);110 mysql_close(&p -> mysql); 80 111 } 81 112 while (m_opendbs.size()) … … 93 124 94 125 126 void Database::OnMyInit(OPENDB *odb) 127 { 128 // using embedded server (libmysqld) 129 if (m_embedded) 130 { 131 mysql_options(&odb -> mysql, MYSQL_READ_DEFAULT_GROUP, "test_libmysqld_CLIENT"); 132 } 133 } 134 135 95 136 void Database::RegErrHandler(IError *p) 96 137 { … … 124 165 return NULL; 125 166 } 126 int rc = sqlite3_open(database.c_str(), &odb -> db); 127 if (rc) 128 { 129 error("Can't open database: %s\n", sqlite3_errmsg(odb -> db)); 130 sqlite3_close(odb -> db); 167 if (!mysql_init(&odb -> mysql)) 168 { 169 error("mysql_init() failed - list size %d",m_opendbs.size()); 131 170 delete odb; 132 171 return NULL; 133 172 } 173 // use callback to set mysql_options() before connect, etc 174 this -> OnMyInit(odb); 175 if (m_embedded) 176 { 177 if (!mysql_real_connect(&odb -> mysql,NULL,NULL,NULL,database.c_str(),0,NULL,0) ) 178 { 179 error("mysql_real_connect(NULL,NULL,NULL,%s,0,NULL,0) failed - list size %d",database.c_str(),m_opendbs.size()); 180 delete odb; 181 return NULL; 182 } 183 } 184 else 185 { 186 if (!mysql_real_connect(&odb -> mysql,host.c_str(),user.c_str(),password.c_str(),database.c_str(),0,NULL,0) ) 187 { 188 error("mysql_real_connect(%s,%s,***,%s,0,NULL,0) failed - list size %d",host.c_str(),user.c_str(),database.c_str(),m_opendbs.size()); 189 delete odb; 190 return NULL; 191 } 192 } 134 193 odb -> busy = true; 135 194 m_opendbs.push_back(odb); … … 137 196 else 138 197 { 198 if (mysql_ping(&odb -> mysql)) 199 { 200 error("mysql_ping() failed when reusing an old connection from the connection pool"); 201 } 139 202 odb -> busy = true; 140 203 } … … 189 252 190 253 191 void Database::error(Query& q,const std::string& msg)192 {193 if (m_errhandler)194 {195 m_errhandler -> error(*this, q, msg);196 }197 }198 199 200 254 bool Database::Connected() 201 255 { … … 205 259 return false; 206 260 } 261 int ping_result = mysql_ping(&odb -> mysql); 262 if (ping_result) 263 { 264 error("mysql_ping() failed"); 265 } 207 266 freedb(odb); 208 return true;267 return ping_result ? false : true; 209 268 } 210 269 … … 279 338 case '\\': 280 339 case 34: 281 str2 += '\ '';340 str2 += '\\'; 282 341 default: 342 str2 += str[i]; 343 } 344 } 345 return str2; 346 } 347 348 349 std::string Database::unsafestr(const std::string& str) 350 { 351 std::string str2; 352 for (size_t i = 0; i < str.size(); i++) 353 { 354 if (str[i] == '\\') 355 { 356 i++; 357 } 358 if (i < str.size()) 359 { 283 360 str2 += str[i]; 284 361 } … … 346 423 } 347 424 348 349 #ifdef SQLITEW_NAMESPACE 350 } // namespace SQLITEW_NAMESPACE { 351 #endif 352 425 // Added Michael Griffin 11/15/09 426 // Custom for Inserting Clean Char * 427 char *Database::strip_escape(OPENDB *qodb, char* Oldstr) { 428 429 char* Newstr = NULL; 430 int ilen=0; 431 432 if(!Oldstr) 433 return NULL; 434 435 Newstr = new char[((2 * strlen(Oldstr))+1)]; 436 437 ilen=mysql_real_escape_string(&qodb -> mysql, 438 (char *)Newstr, 439 (char *)Oldstr, 440 (long unsigned int)strlen((char *)Oldstr)); 441 442 Newstr[ilen] = 0; 443 return (Newstr); 444 } 445 446 447 #ifdef MYSQLW_NAMESPACE 448 } // namespace MYSQLW_NAMESPACE { 449 #endif 450 -
trunk/src/sql_Database.h
r127 r129 1 /* 1 /** 2 2 ** Database.h 3 3 ** 4 ** Published / author: 200 5-08-12/ grymse@alhem.net4 ** Published / author: 2001-02-15 / grymse@alhem.net 5 5 **/ 6 6 7 7 /* 8 Copyright (C) 2001 -2006Anders Hedstrom8 Copyright (C) 2001 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. 11 11 12 12 If you would like to use this program in a closed-source application, 13 a separate license agreement is available. For information about 13 a separate license agreement is available. For information about 14 14 the closed-source license agreement for this program, please 15 15 visit http://www.alhem.net/sqlwrapped/license.html and/or … … 31 31 */ 32 32 33 #ifndef _DATABASE_H _SQLITE34 #define _DATABASE_H _SQLITE33 #ifndef _DATABASE_H 34 #define _DATABASE_H 35 35 36 36 #ifdef _WIN32 … … 48 48 #endif 49 49 50 #include <sqlite3.h> 51 #include "sql_Database.h" 52 53 #ifdef SQLITEW_NAMESPACE 54 namespace SQLITEW_NAMESPACE { 50 #ifdef MYSQLW_NAMESPACE 51 namespace MYSQLW_NAMESPACE { 55 52 #endif 56 57 53 58 54 class IError; … … 61 57 62 58 63 /** Connection information and pool . */64 class Database 59 /** Connection information and pooling. */ 60 class Database 65 61 { 62 /** Mutex container class, used by Lock. 63 \ingroup threading */ 66 64 public: 67 /** Mutex container class, used by Lock.68 \ingroup threading */69 65 class Mutex { 70 66 public: … … 80 76 #endif 81 77 }; 78 /** Mutex helper class. */ 82 79 private: 83 /** Mutex helper class. */84 80 class Lock { 85 81 public: … … 94 90 struct OPENDB { 95 91 OPENDB() : busy(false) {} 96 sqlite3 *db;92 MYSQL mysql; 97 93 bool busy; 98 94 }; 99 95 typedef std::list<OPENDB *> opendb_v; 96 97 // Temp container for strip_escape 98 std::string d_tmpstr; 100 99 101 100 public: 102 /** Use file*/101 /** Use embedded libmysqld */ 103 102 Database(const std::string& database, 104 103 IError * = NULL); 105 104 106 /** Use file+ thread safe */105 /** Use embedded libmysqld + thread safe */ 107 106 Database(Mutex& ,const std::string& database, 108 107 IError * = NULL); 109 108 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 110 123 virtual ~Database(); 124 125 /** Callback after mysql_init */ 126 virtual void OnMyInit(OPENDB *); 111 127 112 128 /** try to establish connection with given host */ … … 115 131 void RegErrHandler(IError *); 116 132 void error(Query&,const char *format, ...); 117 void error(Query&,const std::string& );118 133 119 134 /** Request a database connection. … … 135 150 void freedb(OPENDB *odb); 136 151 137 / ** Escape string - change all ' to ''. */152 // utility 138 153 std::string safestr(const std::string& ); 139 /** Make string xml safe. */154 std::string unsafestr(const std::string& ); 140 155 std::string xmlsafestr(const std::string& ); 141 156 142 /** Convert string to 64-bit integer. */143 157 int64_t a2bigint(const std::string& ); 144 /** Convert string to unsigned 64-bit integer. */145 158 uint64_t a2ubigint(const std::string& ); 159 160 char *strip_escape(OPENDB *qodb, char* Oldstr); 146 161 147 162 private: … … 150 165 void error(const char *format, ...); 151 166 // 167 std::string host; 168 std::string user; 169 std::string password; 152 170 std::string database; 153 171 opendb_v m_opendbs; … … 158 176 }; 159 177 160 161 #ifdef SQLITEW_NAMESPACE 162 } // namespace SQLITEW_NAMESPACE { 178 #ifdef MYSQLW_NAMESPACE 179 } //namespace MYSQLW_NAMESPACE { 163 180 #endif 164 181 182 165 183 #endif // _DATABASE_H -
trunk/src/sql_IError.h
r127 r129 1 /* 1 /** 2 2 ** IError.h 3 3 ** … … 6 6 7 7 /* 8 Copyright (C) 2004 ,2005,2006Anders Hedstrom8 Copyright (C) 2004 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. … … 31 31 */ 32 32 33 #ifndef _IERROR_H _SQLITE34 #define _IERROR_H _SQLITE33 #ifndef _IERROR_H 34 #define _IERROR_H 35 35 36 36 #include <string> 37 37 38 39 #ifdef SQLITEW_NAMESPACE 40 namespace SQLITEW_NAMESPACE { 38 #ifdef MYSQLW_NAMESPACE 39 namespace MYSQLW_NAMESPACE { 41 40 #endif 42 41 … … 44 43 class Database; 45 44 class Query; 46 47 45 48 46 /** Log class interface. */ … … 55 53 56 54 57 #ifdef SQLITEW_NAMESPACE58 } // namespace SQLITEW_NAMESPACE {55 #ifdef MYSQLW_NAMESPACE 56 } // namespace MYSQLW_NAMESPACE { 59 57 #endif 60 58 -
trunk/src/sql_Query.cpp
r127 r129 1 /* 1 /** 2 2 ** Query.cpp 3 3 ** 4 ** Published / author: 200 5-08-12/ grymse@alhem.net4 ** Published / author: 2001-02-15 / grymse@alhem.net 5 5 **/ 6 6 7 7 /* 8 Copyright (C) 2001 -2006Anders Hedstrom8 Copyright (C) 2001 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. … … 36 36 #include <string> 37 37 #include <map> 38 #ifdef WIN32 39 #include <config-win.h> 40 #include <mysql.h> 41 #else 38 42 #include <stdio.h> 39 43 #include <stdlib.h> 40 44 #include <string.h> 41 #include <sqlite3.h> 45 #include <mysql/mysql.h> 46 #endif 42 47 43 48 #include "sql_Database.h" … … 45 50 46 51 47 #ifdef SQLITEW_NAMESPACE48 namespace SQLITEW_NAMESPACE {52 #ifdef MYSQLW_NAMESPACE 53 namespace MYSQLW_NAMESPACE { 49 54 #endif 50 55 51 56 52 Query::Query(Database & dbin)53 : m_db(dbin)54 ,odb(dbin .grabdb())57 Query::Query(Database *dbin) 58 :m_db(*dbin) 59 ,odb(dbin ? dbin -> grabdb() : NULL) 55 60 ,res(NULL) 56 ,row(false) 57 ,cache_rc(0) 58 ,cache_rc_valid(false) 59 ,m_row_count(0) 61 ,row(NULL) 60 62 ,m_num_cols(0) 61 63 { … … 63 65 64 66 65 Query::Query(Database& dbin,const std::string& sql) 66 : m_db(dbin) 67 ,odb(dbin.grabdb()) 68 ,res(NULL) 69 ,row(false) 70 ,cache_rc(0) 71 ,cache_rc_valid(false) 72 ,m_row_count(0) 67 Query::Query(Database& dbin) : m_db(dbin),odb(dbin.grabdb()),res(NULL),row(NULL) 73 68 ,m_num_cols(0) 74 69 { 70 } 71 72 73 Query::Query(Database *dbin,const std::string& sql) : m_db(*dbin) 74 ,odb(dbin ? dbin -> grabdb() : NULL),res(NULL),row(NULL) 75 ,m_num_cols(0) 76 { 75 77 execute(sql); 76 78 } 77 79 78 80 81 Query::Query(Database& dbin,const std::string& sql) : m_db(dbin),odb(dbin.grabdb()),res(NULL),row(NULL) 82 ,m_num_cols(0) 83 { 84 execute(sql); // returns 0 if fail 85 } 86 87 79 88 Query::~Query() 80 89 { 81 90 if (res) 82 91 { 83 GetDatabase().error(*this, " sqlite3_finalizein destructor");84 sqlite3_finalize(res);92 GetDatabase().error(*this, "mysql_free_result in destructor"); 93 mysql_free_result(res); 85 94 } 86 95 if (odb) … … 97 106 98 107 99 /*100 The sqlite3_finalize() routine deallocates a prepared SQL statement.101 All prepared statements must be finalized before the database can be closed.102 */103 108 bool Query::execute(const std::string& sql) 104 { 105 // query, no result 109 { // query, no result 106 110 m_last_query = sql; 107 111 if (odb && res) … … 111 115 if (odb && !res) 112 116 { 113 const char *s = NULL; 114 int rc = sqlite3_prepare(odb -> db, sql.c_str(), sql.size(), &res, &s); 115 if (rc != SQLITE_OK) 116 { 117 GetDatabase().error(*this, "execute: prepare query failed"); 118 return false; 119 } 120 if (!res) 121 { 122 GetDatabase().error(*this, "execute: query failed"); 123 return false; 124 } 125 rc = sqlite3_step(res); // execute 126 sqlite3_finalize(res); // deallocate statement 117 if (mysql_query(&odb -> mysql,sql.c_str())) 118 { 119 GetDatabase().error(*this,"query failed"); 120 } 121 else 122 { 123 return true; 124 } 125 } 126 return false; 127 } 128 129 130 131 // methods using db specific api calls 132 133 MYSQL_RES *Query::get_result(const std::string& sql) 134 { // query, result 135 if (odb && res) 136 { 137 GetDatabase().error(*this, "get_result: query busy"); 138 } 139 if (odb && !res) 140 { 141 if (execute(sql)) 142 { 143 res = mysql_store_result(&odb -> mysql); 144 if (res) 145 { 146 MYSQL_FIELD *f = mysql_fetch_field(res); 147 int i = 1; 148 while (f) 149 { 150 if (f -> name) 151 m_nmap[f -> name] = i; 152 f = mysql_fetch_field(res); 153 i++; 154 } 155 m_num_cols = i - 1; 156 } 157 } 158 } 159 return res; 160 } 161 162 163 void Query::free_result() 164 { 165 if (odb && res) 166 { 167 mysql_free_result(res); 127 168 res = NULL; 128 switch (rc) 129 { 130 case SQLITE_BUSY: 131 GetDatabase().error(*this, "execute: database busy"); 132 return false; 133 case SQLITE_DONE: 134 case SQLITE_ROW: 135 return true; 136 case SQLITE_ERROR: 137 GetDatabase().error(*this, sqlite3_errmsg(odb -> db)); 138 return false; 139 case SQLITE_MISUSE: 140 GetDatabase().error(*this, "execute: database misuse"); 141 return false; 142 } 143 GetDatabase().error(*this, "execute: unknown result code"); 144 } 145 return false; 146 } 147 148 149 150 // methods using db specific api calls 151 152 sqlite3_stmt *Query::get_result(const std::string& sql) 153 { 154 // query, result 155 m_last_query = sql; 156 if (odb && res) 157 { 158 GetDatabase().error(*this, "get_result: query busy"); 159 } 160 if (odb && !res) 161 { 162 const char *s = NULL; 163 int rc = sqlite3_prepare(odb -> db, sql.c_str(), sql.size(), &res, &s); 164 if (rc != SQLITE_OK) 165 { 166 GetDatabase().error(*this, "get_result: prepare query failed"); 167 return NULL; 168 } 169 if (!res) 170 { 171 GetDatabase().error(*this, "get_result: query failed"); 172 return NULL; 173 } 174 // get column names from result 175 { 176 int i = 0; 177 do 178 { 179 const char *p = sqlite3_column_name(res, i); 180 if (!p) 181 break; 182 m_nmap[p] = ++i; 183 } while (true); 184 m_num_cols = i; 185 } 186 cache_rc = sqlite3_step(res); 187 cache_rc_valid = true; 188 m_row_count = (cache_rc == SQLITE_ROW) ? 1 : 0; 189 } 190 return res; 191 } 192 193 194 void Query::free_result() 195 { 196 if (odb && res) 197 { 198 sqlite3_finalize(res); 199 res = NULL; 200 row = false; 201 cache_rc_valid = false; 202 } 203 // clear column names 169 row = NULL; 170 } 204 171 while (m_nmap.size()) 205 172 { … … 207 174 m_nmap.erase(it); 208 175 } 209 } 210 211 212 bool Query::fetch_row() 176 m_num_cols = 0; 177 } 178 179 180 MYSQL_ROW Query::fetch_row() 213 181 { 214 182 rowcount = 0; 215 row = false; 216 if (odb && res) 217 { 218 int rc = cache_rc_valid ? cache_rc : sqlite3_step(res); // execute 219 cache_rc_valid = false; 220 switch (rc) 221 { 222 case SQLITE_BUSY: 223 GetDatabase().error(*this, "execute: database busy"); 224 return false; 225 case SQLITE_DONE: 226 return false; 227 case SQLITE_ROW: 228 row = true; 229 return true; 230 case SQLITE_ERROR: 231 GetDatabase().error(*this, sqlite3_errmsg(odb -> db)); 232 return false; 233 case SQLITE_MISUSE: 234 GetDatabase().error(*this, "execute: database misuse"); 235 return false; 236 } 237 GetDatabase().error(*this, "execute: unknown result code"); 238 } 183 return odb && res ? row = mysql_fetch_row(res) : NULL; 184 } 185 186 187 my_ulonglong Query::insert_id() 188 { 189 if (odb) 190 { 191 return mysql_insert_id(&odb -> mysql); 192 } 193 else 194 { 195 return 0; 196 } 197 } 198 199 200 long Query::num_rows() 201 { 202 return odb && res ? mysql_num_rows(res) : 0; 203 } 204 205 206 int Query::num_cols() 207 { 208 return m_num_cols; 209 } 210 211 212 bool Query::is_null(int x) 213 { 214 if (odb && res && row) 215 { 216 return row[x] ? false : true; 217 } 218 return false; // ... 219 } 220 221 222 bool Query::is_null(const std::string& x) 223 { 224 int index = m_nmap[x] - 1; 225 if (index >= 0) 226 return is_null(index); 227 error("Column name lookup failure: " + x); 239 228 return false; 240 229 } 241 230 242 231 243 sqlite_int64 Query::insert_id() 244 { 245 if (odb) 246 { 247 return sqlite3_last_insert_rowid(odb -> db); 248 } 249 else 250 { 251 return 0; 252 } 253 } 254 255 256 long Query::num_rows() 257 { 258 return odb && res ? m_row_count : 0; 259 } 260 261 262 int Query::num_cols() 263 { 264 return m_num_cols; 265 } 266 267 268 bool Query::is_null(int x) 232 bool Query::is_null() 233 { 234 return is_null(rowcount++); 235 } 236 237 238 const char *Query::getstr(const std::string& x) 239 { 240 int index = m_nmap[x] - 1; 241 if (index >= 0) 242 return getstr(index); 243 error("Column name lookup failure: " + x); 244 return NULL; 245 } 246 247 248 const char *Query::getstr(int x) 269 249 { 270 250 if (odb && res && row) 271 251 { 272 if (sqlite3_column_type(res, x) == SQLITE_NULL) 273 return true; 274 } 275 return false; // ... 276 } 277 278 279 const char *Query::getstr(const std::string& x) 280 { 281 int index = m_nmap[x] - 1; 282 if (index >= 0) 283 return getstr(index); 284 error("Column name lookup failure: " + x); 285 return ""; 286 } 287 288 289 const char *Query::getstr(int x) 290 { 291 if (odb && res && row && x < sqlite3_column_count(res) ) 292 { 293 const unsigned char *tmp = sqlite3_column_text(res, x); 294 return tmp ? (const char *)tmp : ""; 295 } 296 return ""; 252 return row[x] ? row[x] : ""; 253 } 254 return NULL; 297 255 } 298 256 … … 316 274 double Query::getnum(int x) 317 275 { 318 if (odb && res && row) 319 { 320 return sqlite3_column_double(res, x); 321 } 276 return odb && res && row && row[x] ? atof(row[x]) : 0; 277 } 278 279 280 long Query::getval(const std::string& x) 281 { 282 int index = m_nmap[x] - 1; 283 if (index >= 0) 284 return getval(index); 285 error("Column name lookup failure: " + x); 322 286 return 0; 323 287 } 324 288 325 289 326 long Query::getval(const std::string& x) 327 { 328 int index = m_nmap[x] - 1; 329 if (index >= 0) 330 return getval(index); 290 long Query::getval(int x) 291 { 292 return odb && res && row && row[x] ? atol(row[x]) : 0; 293 } 294 295 296 double Query::getnum() 297 { 298 return getnum(rowcount++); 299 } 300 301 302 long Query::getval() 303 { 304 return getval(rowcount++); 305 } 306 307 308 unsigned long Query::getuval(const std::string& x) 309 { 310 int index = m_nmap[x] - 1; 311 if (index >= 0) 312 return getuval(index); 331 313 error("Column name lookup failure: " + x); 332 314 return 0; … … 334 316 335 317 336 long Query::getval(int x) 337 { 338 if (odb && res && row) 339 { 340 return sqlite3_column_int(res, x); 341 } 318 unsigned long Query::getuval(int x) 319 { 320 unsigned long l = 0; 321 if (odb && res && row && row[x]) 322 { 323 l = m_db.a2ubigint(row[x]); 324 } 325 return l; 326 } 327 328 329 unsigned long Query::getuval() 330 { 331 return getuval(rowcount++); 332 } 333 334 335 int64_t Query::getbigint(const std::string& x) 336 { 337 int index = m_nmap[x] - 1; 338 if (index >= 0) 339 return getbigint(index); 340 error("Column name lookup failure: " + x); 342 341 return 0; 343 342 } 344 343 345 344 346 double Query::getnum()347 { 348 return getnum(rowcount++);349 } 350 351 352 long Query::getval()353 { 354 return get val(rowcount++);355 } 356 357 358 u nsigned long Query::getuval(const std::string& x)359 { 360 int index = m_nmap[x] - 1; 361 if (index >= 0) 362 return getu val(index);345 int64_t Query::getbigint(int x) 346 { 347 return odb && res && row && row[x] ? m_db.a2bigint(row[x]) : 0; 348 } 349 350 351 int64_t Query::getbigint() 352 { 353 return getbigint(rowcount++); 354 } 355 356 357 uint64_t Query::getubigint(const std::string& x) 358 { 359 int index = m_nmap[x] - 1; 360 if (index >= 0) 361 return getubigint(index); 363 362 error("Column name lookup failure: " + x); 364 363 return 0; … … 366 365 367 366 368 unsigned long Query::getuval(int x)369 {370 unsigned long l = 0;371 if (odb && res && row)372 {373 l = sqlite3_column_int(res, x);374 }375 return l;376 }377 378 379 unsigned long Query::getuval()380 {381 return getuval(rowcount++);382 }383 384 385 int64_t Query::getbigint(const std::string& x)386 {387 int index = m_nmap[x] - 1;388 if (index >= 0)389 return getbigint(index);390 error("Column name lookup failure: " + x);391 return 0;392 }393 394 395 int64_t Query::getbigint(int x)396 {397 if (odb && res && row)398 {399 return sqlite3_column_int64(res, x);400 }401 return 0;402 }403 404 405 int64_t Query::getbigint()406 {407 return getbigint(rowcount++);408 }409 410 411 uint64_t Query::getubigint(const std::string& x)412 {413 int index = m_nmap[x] - 1;414 if (index >= 0)415 return getubigint(index);416 error("Column name lookup failure: " + x);417 return 0;418 }419 420 421 367 uint64_t Query::getubigint(int x) 422 368 { 423 uint64_t l = 0; 424 if (odb && res && row) 425 { 426 l = sqlite3_column_int64(res, x); 427 } 428 return l; 369 return odb && res && row && row[x] ? m_db.a2ubigint(row[x]) : 0; 429 370 } 430 371 … … 489 430 std::string Query::GetError() 490 431 { 432 return odb ? mysql_error(&odb -> mysql) : ""; 433 } 434 435 436 int Query::GetErrno() 437 { 438 return odb ? mysql_errno(&odb -> mysql) : 0; 439 } 440 441 442 bool Query::Connected() 443 { 491 444 if (odb) 492 return sqlite3_errmsg(odb -> db); 493 return ""; 494 } 495 496 497 int Query::GetErrno() 498 { 499 if (odb) 500 return sqlite3_errcode(odb -> db); 501 return 0; 502 } 503 504 505 bool Query::Connected() 506 { 445 { 446 if (mysql_ping(&odb -> mysql)) 447 { 448 GetDatabase().error(*this, "mysql_ping() failed"); 449 return false; 450 } 451 } 507 452 return odb ? true : false; 508 453 } 509 454 510 455 511 512 513 void Query::ViewRes() 514 { 515 if (!res) 516 { 517 printf("no result stored\n"); 518 return; 519 } 520 printf("result column count = %d\n", sqlite3_column_count(res)); 521 for (int i = 0; i < sqlite3_column_count(res); i++) 522 { 523 printf(" %2d type %d name '%s'", i, sqlite3_column_type(res, i), sqlite3_column_name(res, i)); 524 printf(" / '%s'", (char *)sqlite3_column_text(res, i)); 525 printf(" / %d", sqlite3_column_int(res, i)); 526 printf(" / %f", sqlite3_column_double(res, i)); 527 printf("\n"); 528 } 529 } 530 531 532 void Query::error(const std::string& msg) 533 { 534 GetDatabase().error(*this, msg); 535 } 536 537 538 #ifdef SQLITEW_NAMESPACE 539 } // namespace SQLITEW_NAMESPACE { 456 void Query::error(const std::string& x) 457 { 458 m_db.error(*this, x.c_str()); 459 } 460 461 462 std::string Query::safestr(const std::string& x) 463 { 464 return m_db.safestr(x); 465 } 466 467 // Added Michael Griffin 11/15/09 468 // Custom 'mysql_real_escape_string()' 469 char *Query::strip(char* Oldstr) 470 { 471 return m_db.strip_escape(odb,Oldstr); 472 } 473 474 475 #ifdef MYSQLW_NAMESPACE 476 } // namespace MYSQLW_NAMESPACE { 540 477 #endif 541 478 -
trunk/src/sql_Query.h
r127 r129 5 5 ** Query.h 6 6 ** 7 ** Published / author: 200 5-08-12/ grymse@alhem.net7 ** Published / author: 2001-02-15 / grymse@alhem.net 8 8 **/ 9 9 10 10 /* 11 Copyright (C) 2001 -2006Anders Hedstrom11 Copyright (C) 2001 Anders Hedstrom 12 12 13 13 This program is made available under the terms of the GNU GPL. … … 34 34 */ 35 35 36 #ifndef _QUERY_H _SQLITE37 #define _QUERY_H _SQLITE36 #ifndef _QUERY_H 37 #define _QUERY_H 38 38 39 39 #include <string> … … 47 47 48 48 49 #ifdef SQLITEW_NAMESPACE50 namespace SQLITEW_NAMESPACE {49 #ifdef MYSQLW_NAMESPACE 50 namespace MYSQLW_NAMESPACE { 51 51 #endif 52 52 53 53 54 /** SQL Statement execute / result . */54 /** SQL Statement execute / result set helper class. */ 55 55 class Query 56 56 { … … 59 59 Query(Database& dbin); 60 60 /** Constructor accepting reference to database object 61 and query stringto execute. */61 and query to execute. */ 62 62 Query(Database& dbin,const std::string& sql); 63 63 ~Query(); 64 64 65 /** Check if database object is connectable. */65 /** Check to see if database object is connectable. */ 66 66 bool Connected(); 67 67 /** Return reference to database object. */ 68 68 Database& GetDatabase() const; 69 /** Return string containinglast query executed. */69 /** Return string of last query executed. */ 70 70 const std::string& GetLastQuery(); 71 71 72 72 /** execute() returns true if query is successful, 73 does not store result .*/73 does not store result */ 74 74 bool execute(const std::string& sql); 75 /** execute query and store result. */ 76 MYSQL_RES *get_result(const std::string& sql); 75 77 76 /** Execute query and store result. */ 77 sqlite3_stmt *get_result(const std::string& sql); 78 /** Free stored result, must be called after get_result() before calling 79 execute()/get_result() again. */ 78 /** free stored result, must be called after get_result() */ 80 79 void free_result(); 81 80 /** Fetch next result row. 82 81 \return false if there was no row to fetch (end of rows) */ 83 boolfetch_row();82 MYSQL_ROW fetch_row(); 84 83 /** Get id of last insert. */ 85 sqlite_int64insert_id();86 /** Returns 0 if there are no rows to fetch. */84 my_ulonglong insert_id(); 85 /** Returns number of rows returned by last select call. */ 87 86 long num_rows(); 88 87 /** Number of columns in current result. */ … … 94 93 95 94 /** Check if column x in current row is null. */ 95 bool is_null(const std::string& x); 96 96 bool is_null(int x); 97 bool is_null(); 97 98 98 99 /** Execute query and return first result as a string. */ … … 103 104 double get_num(const std::string& sql); 104 105 105 /** Return column named x as a string value. */106 106 const char *getstr(const std::string& x); 107 /** Return column x as a string value. */108 107 const char *getstr(int x); 109 /** Return next column as a string value - see rowcount. */110 108 const char *getstr(); 111 112 /** Return column named x as a long integer. */113 109 long getval(const std::string& x); 114 /** Return column x as a long integer. */115 110 long getval(int x); 116 /** Return next column as a long integer - see rowcount. */117 111 long getval(); 118 119 /** Return column named x as an unsigned long integer. */120 112 unsigned long getuval(const std::string& x); 121 /** Return column x as an unsigned long integer. */122 113 unsigned long getuval(int x); 123 /** Return next column as an unsigned long integer. */124 114 unsigned long getuval(); 125 126 /** Return column named x as a 64-bit integer value. */127 115 int64_t getbigint(const std::string& x); 128 /** Return column x as a 64-bit integer value. */129 116 int64_t getbigint(int x); 130 /** Return next column as a 64-bit integer value. */131 117 int64_t getbigint(); 132 133 /** Return column named x as an unsigned 64-bit integer value. */134 118 uint64_t getubigint(const std::string& x); 135 /** Return column x as an unsigned 64-bit integer value. */136 119 uint64_t getubigint(int x); 137 /** Return next column as an unsigned 64-bit integer value. */138 120 uint64_t getubigint(); 139 140 /** Return column named x as a double. */141 121 double getnum(const std::string& x); 142 /** Return column x as a double. */143 122 double getnum(int x); 144 /** Return next column as a double. */145 123 double getnum(); 146 124 125 std::string safestr(const std::string& x); 126 char *strip(char* Oldstr); 127 128 protected: 129 Query(Database *dbin); 130 Query(Database *dbin,const std::string& sql); 147 131 private: 148 /** Hide the copy constructor. */149 132 Query(const Query& q) : m_db(q.GetDatabase()) {} 150 /** Hide the assignment operator. */151 133 Query& operator=(const Query& ) { return *this; } 152 /** Print current result to stdout. */153 void ViewRes();154 /** Print error to debug class. */155 134 void error(const std::string& ); 156 Database& m_db; ///< Reference to database object 157 Database::OPENDB *odb; ///< Connection pool handle 158 sqlite3_stmt *res; ///< Stored result 159 bool row; ///< true if fetch_row succeeded 160 short rowcount; ///< Current column pointer in result 161 std::string m_tmpstr; ///< Used to store result in get_string() call 162 std::string m_last_query; ///< Last query executed 163 int cache_rc; ///< Cached result after call to get_result() 164 bool cache_rc_valid; ///< Indicates cache_rc is valid 165 int m_row_count; ///< 0 if get_result() returned no rows 166 // 167 std::map<std::string,int> m_nmap; ///< map translating column names to index 168 int m_num_cols; ///< number of columns in result 135 Database& m_db; 136 Database::OPENDB *odb; 137 MYSQL_RES *res; 138 MYSQL_ROW row; 139 short rowcount; 140 std::string m_tmpstr; 141 std::string m_last_query; 142 std::map<std::string,int> m_nmap; 143 int m_num_cols; 169 144 }; 170 145 171 146 172 #ifdef SQLITEW_NAMESPACE173 } // namespace SQLITEW_NAMESPACE {147 #ifdef MYSQLW_NAMESPACE 148 } // namespace MYSQLW_NAMESPACE { 174 149 #endif 175 150 -
trunk/src/sql_StderrLog.cpp
r127 r129 1 /* 1 /** 2 2 ** StderrLog.cpp 3 3 ** … … 6 6 7 7 /* 8 Copyright (C) 2004 ,2005,2006Anders Hedstrom8 Copyright (C) 2004 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. … … 37 37 #include <string> 38 38 #include <map> 39 #ifdef WIN32 40 #include <config-win.h> 41 #include <mysql.h> 39 42 #include <time.h> 40 #include <sqlite3.h> 43 #else 44 #include <mysql/mysql.h> 45 #endif 41 46 42 47 #include "sql_Database.h" 43 48 #include "sql_Query.h" 44 #include "sql_IError.h"49 //#include "sql_IError.h" 45 50 #include "sql_StderrLog.h" 46 51 47 52 48 #ifdef SQLITEW_NAMESPACE49 namespace SQLITEW_NAMESPACE {53 #ifdef MYSQLW_NAMESPACE 54 namespace MYSQLW_NAMESPACE { 50 55 #endif 51 56 … … 74 79 75 80 76 #ifdef SQLITEW_NAMESPACE77 } // namespace SQLITEW_NAMESPACE {81 #ifdef MYSQLW_NAMESPACE 82 } // namespace MYSQLW_NAMESPACE { 78 83 #endif 79 84 -
trunk/src/sql_StderrLog.h
r127 r129 6 6 7 7 /* 8 Copyright (C) 2004 ,2005,2006Anders Hedstrom8 Copyright (C) 2004 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. … … 30 30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 31 31 */ 32 #ifndef _STDERRLOG_H _SQLITE33 #define _STDERRLOG_H _SQLITE32 #ifndef _STDERRLOG_H 33 #define _STDERRLOG_H 34 34 35 36 #ifdef SQLITEW_NAMESPACE 37 namespace SQLITEW_NAMESPACE { 35 #ifdef MYSQLW_NAMESPACE 36 namespace MYSQLW_NAMESPACE { 38 37 #endif 39 38 39 #include "sql_Database.h" 40 #include "sql_IError.h" 40 41 41 /** Log class writing to st andard error. */42 /** Log class writing to stderr. */ 42 43 class StderrLog : public IError 43 44 { … … 50 51 51 52 52 #ifdef SQLITEW_NAMESPACE53 } // namespace SQLITEW_NAMESPACE {53 #ifdef MYSQLW_NAMESPACE 54 } // namespace MYSQLW_NAMESPACE { 54 55 #endif 55 56 57 56 58 #endif // _STDERRLOG_H -
trunk/src/sql_SysLog.cpp
r127 r129 1 /* 1 /** 2 2 ** SysLog.cpp 3 3 ** … … 6 6 7 7 /* 8 Copyright (C) 2004 ,2005,2006Anders Hedstrom8 Copyright (C) 2004 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. 11 11 12 12 If you would like to use this program in a closed-source application, 13 a separate license agreement is available. For information about 13 a separate license agreement is available. For information about 14 14 the closed-source license agreement for this program, please 15 15 visit http://www.alhem.net/sqlwrapped/license.html and/or … … 32 32 #ifndef WIN32 33 33 34 #include <cstring> 35 #include <sqlite3.h> 34 #include <mysql/mysql.h> 36 35 #include <syslog.h> 37 36 37 #include <cstdio> 38 #include <cstring> 38 39 #include "sql_Database.h" 39 40 #include "sql_Query.h" … … 42 43 43 44 44 #ifdef SQLITEW_NAMESPACE45 namespace SQLITEW_NAMESPACE {45 #ifdef MYSQLW_NAMESPACE 46 namespace MYSQLW_NAMESPACE { 46 47 #endif 47 48 … … 74 75 75 76 76 #ifdef SQLITEW_NAMESPACE77 } // namespace SQLITEW_NAMESPACE {77 #ifdef MYSQLW_NAMESPACE 78 } // namespace MYSQLW_NAMESPACE { 78 79 #endif 79 80 -
trunk/src/sql_SysLog.h
r127 r129 1 /* 1 /** 2 2 ** SysLog.h 3 3 ** … … 6 6 7 7 /* 8 Copyright (C) 2004 ,2005,2006Anders Hedstrom8 Copyright (C) 2004 Anders Hedstrom 9 9 10 10 This program is made available under the terms of the GNU GPL. 11 11 12 12 If you would like to use this program in a closed-source application, 13 a separate license agreement is available. For information about 13 a separate license agreement is available. For information about 14 14 the closed-source license agreement for this program, please 15 15 visit http://www.alhem.net/sqlwrapped/license.html and/or … … 30 30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 31 31 */ 32 #ifndef _SYSLOG_H _SQLITE33 #define _SYSLOG_H _SQLITE32 #ifndef _SYSLOG_H 33 #define _SYSLOG_H 34 34 #ifndef WIN32 35 35 36 #include <s ql_SysLog.h>36 #include <syslog.h> 37 37 38 39 #ifdef SQLITEW_NAMESPACE 40 namespace SQLITEW_NAMESPACE { 38 #ifdef MYSQLW_NAMESPACE 39 namespace MYSQLW_NAMESPACE { 41 40 #endif 42 41 … … 56 55 57 56 58 #ifdef SQLITEW_NAMESPACE59 } // namespace SQLITEW_NAMESPACE {57 #ifdef MYSQLW_NAMESPACE 58 } // namespace MYSQLW_NAMESPACE { 60 59 #endif 61 60
Enthral BBS Software for *nix/bsd/osx