[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7843 - in GNUnet/src/applications: dstore_sqlite kvstore_s
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7843 - in GNUnet/src/applications: dstore_sqlite kvstore_sqlite sqstore_sqlite |
Date: |
Mon, 3 Nov 2008 12:06:56 -0700 (MST) |
Author: durner
Date: 2008-11-03 12:06:56 -0700 (Mon, 03 Nov 2008)
New Revision: 7843
Modified:
GNUnet/src/applications/dstore_sqlite/dstore.c
GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c
GNUnet/src/applications/sqstore_sqlite/sqlite.c
Log:
sqlite3_open() expects file name encoded in UTF-8 (Mantis #1419)
Modified: GNUnet/src/applications/dstore_sqlite/dstore.c
===================================================================
--- GNUnet/src/applications/dstore_sqlite/dstore.c 2008-11-03 19:00:03 UTC
(rev 7842)
+++ GNUnet/src/applications/dstore_sqlite/dstore.c 2008-11-03 19:06:56 UTC
(rev 7843)
@@ -54,6 +54,7 @@
* Filename of this database
*/
static char *fn;
+static char *fn_utf8;
static GNUNET_CoreAPIForPlugins *coreAPI;
@@ -135,6 +136,7 @@
{
UNLINK (fn);
GNUNET_free (fn);
+ GNUNET_free (fn_utf8);
}
payload = 0;
@@ -163,8 +165,20 @@
return GNUNET_SYSERR;
}
CLOSE (fd);
- if (SQLITE_OK != sqlite3_open (fn, &dbh))
- return GNUNET_SYSERR;
+ fn_utf8 = GNUNET_convert_string_to_utf8 (coreAPI->ectx, fn, strlen (fn),
+#ifdef ENABLE_NLS
+ nl_langinfo (CODESET)
+#else
+ "UTF-8" /* good luck */
+#endif
+ );
+ if (SQLITE_OK != sqlite3_open (fn_utf8, &dbh))
+ {
+ GNUNET_free (fn);
+ GNUNET_free (fn_utf8);
+ fn = NULL;
+ return GNUNET_SYSERR;
+ }
db_init (dbh);
sqlite3_close (dbh);
return GNUNET_OK;
@@ -305,7 +319,7 @@
return GNUNET_SYSERR;
GNUNET_hash (data, size, &vhash);
GNUNET_mutex_lock (lock);
- if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn, &dbh)))
+ if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn_utf8, &dbh)))
{
db_reset (dbh);
GNUNET_mutex_unlock (lock);
@@ -469,7 +483,7 @@
GNUNET_mutex_unlock (lock);
return 0;
}
- if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn, &dbh)))
+ if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn_utf8, &dbh)))
{
db_reset (dbh);
GNUNET_mutex_unlock (lock);
@@ -628,6 +642,7 @@
{
UNLINK (fn);
GNUNET_free (fn);
+ GNUNET_free (fn_utf8);
fn = NULL;
if (bloom != NULL)
{
Modified: GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c 2008-11-03 19:00:03 UTC
(rev 7842)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c 2008-11-03 19:06:56 UTC
(rev 7843)
@@ -247,6 +247,7 @@
unsigned int idx;
sqliteHandle *dbh;
sqliteDatabase *db;
+ char *utf8;
GNUNET_mutex_lock (lock);
db = getDB (name);
@@ -260,7 +261,14 @@
/* we haven't opened the DB for this thread yet */
dbh = GNUNET_malloc (sizeof (sqliteHandle));
dbh->tid = GNUNET_thread_get_self ();
- if (sqlite3_open (db->fn, &dbh->dbh) != SQLITE_OK)
+ utf8 = GNUNET_convert_string_to_utf8 (ectx, db->fn, strlen (db->fn),
+#ifdef ENABLE_NLS
+ nl_langinfo (CODESET)
+#else
+ "UTF-8" /* good luck */
+#endif
+ );
+ if (sqlite3_open (utf8, &dbh->dbh) != SQLITE_OK)
{
LOG_SQLITE (dbh->dbh, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
"sqlite3_open");
@@ -268,8 +276,10 @@
GNUNET_mutex_unlock (lock);
GNUNET_thread_release_self (dbh->tid);
GNUNET_free (dbh);
+ GNUNET_free (utf8);
return NULL;
}
+ GNUNET_free (utf8);
GNUNET_array_append (db->handles, db->handle_count, dbh);
sqlite3_exec (dbh->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL, NULL);
sqlite3_exec (dbh->dbh, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2008-11-03 19:00:03 UTC
(rev 7842)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2008-11-03 19:06:56 UTC
(rev 7843)
@@ -1437,7 +1437,14 @@
GNUNET_free (dir);
return NULL;
}
- fn = dir;
+ fn = GNUNET_convert_string_to_utf8 (ectx, dir, strlen (dir),
+#ifdef ENABLE_NLS
+ nl_langinfo (CODESET)
+#else
+ "UTF-8" /* good luck */
+#endif
+ );
+ GNUNET_free (dir);
dbh = getDBHandle ();
if (dbh == NULL)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7843 - in GNUnet/src/applications: dstore_sqlite kvstore_sqlite sqstore_sqlite,
gnunet <=