mirror of
https://github.com/aria2/aria2.git
synced 2024-11-23 13:59:50 +00:00
2008-10-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use sqlite3_open if sqlite3_open_v2 is not available. * src/Sqlite3MozCookieParser.cc * src/Sqlite3MozCookieParser.h * m4/sqlite3.m4 * test/Sqlite3MozCookieParserTest.cc
This commit is contained in:
parent
9c946467c9
commit
a00c9ca392
@ -1,3 +1,11 @@
|
||||
2008-10-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Use sqlite3_open if sqlite3_open_v2 is not available.
|
||||
* src/Sqlite3MozCookieParser.cc
|
||||
* src/Sqlite3MozCookieParser.h
|
||||
* m4/sqlite3.m4
|
||||
* test/Sqlite3MozCookieParserTest.cc
|
||||
|
||||
2008-10-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Replaced '%zu' with '%lu' since mingw32 doesn't recognize '%zu'.
|
||||
|
@ -328,6 +328,9 @@
|
||||
/* Define to 1 if you have sqlite3. */
|
||||
#undef HAVE_SQLITE3
|
||||
|
||||
/* Define to 1 if you have the `sqlite3_open_v2' function. */
|
||||
#undef HAVE_SQLITE3_OPEN_V2
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
|
94
configure
vendored
94
configure
vendored
@ -6069,6 +6069,100 @@ fi
|
||||
fi
|
||||
if test "x$have_sqlite3" = "xyes"; then
|
||||
|
||||
for ac_func in sqlite3_open_v2
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
|
||||
if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
|
||||
For example, HP-UX 11i <limits.h> declares gettimeofday. */
|
||||
#define $ac_func innocuous_$ac_func
|
||||
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func (); below.
|
||||
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|
||||
<limits.h> exists even on freestanding compilers. */
|
||||
|
||||
#ifdef __STDC__
|
||||
# include <limits.h>
|
||||
#else
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#undef $ac_func
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char $ac_func ();
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined __stub_$ac_func || defined __stub___$ac_func
|
||||
choke me
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return $ac_func ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (ac_try="$ac_link"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_link") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && {
|
||||
test -z "$ac_cxx_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && test -s conftest$ac_exeext &&
|
||||
$as_test_x conftest$ac_exeext; then
|
||||
eval "$as_ac_var=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
eval "$as_ac_var=no"
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
ac_res=`eval echo '${'$as_ac_var'}'`
|
||||
{ echo "$as_me:$LINENO: result: $ac_res" >&5
|
||||
echo "${ECHO_T}$ac_res" >&6; }
|
||||
if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_SQLITE3 1
|
||||
_ACEOF
|
||||
|
@ -42,6 +42,7 @@ if test "x$have_sqlite3" != "xyes"; then
|
||||
fi
|
||||
fi
|
||||
if test "x$have_sqlite3" = "xyes"; then
|
||||
AC_CHECK_FUNCS([sqlite3_open_v2])
|
||||
AC_DEFINE([HAVE_SQLITE3], [1], [Define to 1 if you have sqlite3.])
|
||||
AC_SUBST(SQLITE3_LIBS)
|
||||
AC_SUBST(SQLITE3_CPPFLAGS)
|
||||
|
@ -33,12 +33,18 @@
|
||||
*/
|
||||
/* copyright --> */
|
||||
#include "Sqlite3MozCookieParser.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "RecoverableException.h"
|
||||
#include "Util.h"
|
||||
#include "StringFormat.h"
|
||||
#include "A2STR.h"
|
||||
#include <cstring>
|
||||
#include <sqlite3.h>
|
||||
#ifndef HAVE_SQLITE3_OPEN_V2
|
||||
# include "File.h"
|
||||
#endif // !HAVE_SQLITE3_OPEN_V2
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
@ -88,7 +94,16 @@ Sqlite3MozCookieParser::parse(const std::string& filename) const
|
||||
sqlite3* db = 0;
|
||||
|
||||
int ret;
|
||||
#ifdef HAVE_SQLITE3_OPEN_V2
|
||||
ret = sqlite3_open_v2(filename.c_str(), &db, SQLITE_OPEN_READONLY, 0);
|
||||
#else // !HAVE_SQLITE3_OPEN_V2
|
||||
if(!File(filename).isFile()) {
|
||||
throw RecoverableException
|
||||
(StringFormat("Failed to open SQLite3 database: %s",
|
||||
filename.c_str()).str());
|
||||
}
|
||||
ret = sqlite3_open(filename.c_str(), &db);
|
||||
#endif // !HAVE_SQLITE3_OPEN_V2
|
||||
if(SQLITE_OK != ret) {
|
||||
std::string errMsg = sqlite3_errmsg(db);
|
||||
sqlite3_close(db);
|
||||
|
@ -36,10 +36,12 @@
|
||||
#define _D_SQLITE3_MOZ_COOKIE_PARSER_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "Cookie.h"
|
||||
|
||||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
#include "Cookie.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class Sqlite3MozCookieParser {
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "Sqlite3MozCookieParser.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "RecoverableException.h"
|
||||
#include "Util.h"
|
||||
#include <iostream>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
@ -68,6 +71,8 @@ void Sqlite3MozCookieParserTest::testParse_fileNotFound()
|
||||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
} catch(RecoverableException& e) {
|
||||
// SUCCESS
|
||||
CPPUNIT_ASSERT(Util::startsWith(e.what(),
|
||||
"Failed to open SQLite3 database:"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user