gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-18


From: Jan Derfinak
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-184-g73ea988
Date: Thu, 17 Feb 2011 21:58:55 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  73ea988688afd4ca1ca7259bae9ccdc6dce15a46 (commit)
      from  c0d111b1a11135ad6401fa3b5a3c332dace80416 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=73ea988688afd4ca1ca7259bae9ccdc6dce15a46


commit 73ea988688afd4ca1ca7259bae9ccdc6dce15a46
Author: Jan Derfinak <address@hidden>
Date:   Thu Feb 17 22:56:00 2011 +0100

    New option -e, --encoding enables to specify client encoding for database 
connection.

diff --git a/configure.in b/configure.in
index 6bb88d3..fa902ee 100644
--- a/configure.in
+++ b/configure.in
@@ -35,7 +35,7 @@ dnl xgnokii version
 XVERSION=1.0
 
 dnl smsd version
-SVERSION=1.4.5
+SVERSION=1.4.6
 
 AC_CANONICAL_SYSTEM
 AC_GNU_SOURCE
diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index 3d4dd43..fff850b 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,9 @@
+* Tue 15 Feb 2011 Jan Derfinak
+- Version changed to 1.4.6
+- New option -e, --encoding enables to specify client encoding for
+  database connection. Based on idea from Daniel Müller.
+
+
 * Thu 25 Sep 2010 Daniele Forsi
 - Add even more information to man page
 
diff --git a/smsd/README b/smsd/README
index 4055631..26a1f47 100644
--- a/smsd/README
+++ b/smsd/README
@@ -121,6 +121,9 @@ Options:
 -s, --schema db_schema
        Specify database schema.
 
+-e, --encoding client_encoding
+       Specify client encoding for database connection.
+
 -m, --module db_module
        Specify which module to use for connection to DB server.
        Currently supported are pq for PostgreSQL, mysql for MySQL, sqlite for 
diff --git a/smsd/man/smsd.8 b/smsd/man/smsd.8
index 0e0bfb3..e426bb9 100644
--- a/smsd/man/smsd.8
+++ b/smsd/man/smsd.8
@@ -174,6 +174,10 @@ Specify database server host name.
 Specify database schema used by the PostgreSQL module (defaults to 'public').
 
 .TP
+.BR -e,\ --encoding\ client_encoding
+Specify client encoding for database connection.
+
+.TP
 .BR -m,\ --module\ db_module
 Specify which module to use for connection to DB server. Currently supported 
values are 'pq' for PostgreSQL, 'mysql' for MySQL, 'sqlite' for SQLite3 and 
'file'. File module is not supported in Windows.
 
diff --git a/smsd/mysql.c b/smsd/mysql.c
index 900902d..732684d 100644
--- a/smsd/mysql.c
+++ b/smsd/mysql.c
@@ -54,9 +54,18 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 #endif
 
   mysql_init (&mysqlIn);
+  
+  if (connect.clientEncoding[0] != '\0')
+    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
+#if MYSQL_VERSION_ID >= 50500
+  else
+    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
+#endif
+
 #if MYSQL_VERSION_ID >= 50013
   mysql_options (&mysqlIn, MYSQL_OPT_RECONNECT, &reconnect);
 #endif
+
   if (!mysql_real_connect (&mysqlIn,
                            connect.host[0] != '\0' ? connect.host : NULL,
                            connect.user[0] != '\0' ? connect.user : NULL,
@@ -80,9 +89,18 @@ GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
 #endif
 
   mysql_init (&mysqlOut);
+
+  if (connect.clientEncoding[0] != '\0')
+    mysql_options (&mysqlOut, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
+#if MYSQL_VERSION_ID >= 50500
+  else
+    mysql_options (&mysqlOut, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
+#endif
+
 #if MYSQL_VERSION_ID >= 50013
   mysql_options (&mysqlOut, MYSQL_OPT_RECONNECT, &reconnect);
 #endif
+
   if (!mysql_real_connect (&mysqlOut,
                            connect.host[0] != '\0' ? connect.host : NULL,
                            connect.user[0] != '\0' ? connect.user : NULL,
diff --git a/smsd/pq.c b/smsd/pq.c
index 84bdea1..c2ad030 100644
--- a/smsd/pq.c
+++ b/smsd/pq.c
@@ -71,6 +71,14 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
     return (1);
   }
 
+  if (connect.clientEncoding[0] != '\0')
+    if (PQsetClientEncoding (connIn, connect.clientEncoding))
+    {
+      g_print (_("Setting client charset '%s' for database '%s' on host '%s' 
failed.\n"),
+               connect.clientEncoding, connect.db, connect.host);
+      g_print (_("Error: %s\n"), PQerrorMessage (connIn));
+    }
+    
   if (schema == NULL)
     schema = g_strdup (connect.schema);
 
@@ -96,6 +104,14 @@ GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
     return (1);
   }
 
+  if (connect.clientEncoding[0] != '\0')
+    if (PQsetClientEncoding (connOut, connect.clientEncoding))
+    {
+      g_print (_("Setting client charset '%s' for database '%s' on host '%s' 
failed.\n"),
+               connect.clientEncoding, connect.db, connect.host);
+      g_print (_("Error: %s\n"), PQerrorMessage (connOut));
+    }
+
   if (schema == NULL)
     schema = g_strdup (connect.schema);
 
diff --git a/smsd/smsd.c b/smsd/smsd.c
index 1eeff7c..47fd3d7 100644
--- a/smsd/smsd.c
+++ b/smsd/smsd.c
@@ -154,6 +154,7 @@ static void Usage (gchar *p)
              "            -d, --db db_name\n"
              "            -c, --host db_hostname OR spool directory if -m 
file\n"
              "            -s, --schema db_schema\n"
+             "            -e, --encoding client_encoding\n"
              "            -m, --module db_module (pq, mysql, file)\n"
              "            -l, --libdir path_to_db_module\n"
              "            -f, --logfile file\n"
@@ -207,6 +208,7 @@ static void ReadConfig (gint argc, gchar *argv[])
   connection.db = g_strdup ("sms");
   connection.host = g_strdup ("");
   connection.schema = g_strdup ("public");
+  connection.clientEncoding = g_strdup ("");
   smsdConfig.dbMod = g_strdup ("file");
   smsdConfig.libDir = g_strdup (MODULES_DIR);
   smsdConfig.logFile = NULL;
@@ -228,6 +230,7 @@ static void ReadConfig (gint argc, gchar *argv[])
       {"db", 1, 0, 'd'},
       {"host", 1, 0, 'c'},
       {"schema", 1, 0, 's'},
+      {"encoding", 1, 0, 'e'},
       {"module", 1, 0, 'm'},
       {"libdir", 1, 0, 'l'},
       {"logfile", 1, 0, 'f'},
@@ -241,7 +244,7 @@ static void ReadConfig (gint argc, gchar *argv[])
       {0, 0, 0, 0}
     };
     
-    c = getopt_long (argc, argv, "u:p:d:c:s:m:l:f:t:vi:S:b:0h", longOptions, 
&optionIndex);
+    c = getopt_long (argc, argv, "u:p:d:c:s:e:m:l:f:t:vi:S:b:0h", longOptions, 
&optionIndex);
     if (c == EOF)
       break;
     switch (c)
@@ -275,6 +278,12 @@ static void ReadConfig (gint argc, gchar *argv[])
         connection.schema = g_strdup (optarg);
         memset (optarg, 'x', strlen (optarg));
         break;
+
+      case 'e':
+        g_free (connection.clientEncoding);
+        connection.clientEncoding = g_strdup (optarg);
+        memset (optarg, 'x', strlen (optarg));
+        break;
         
       case 'm':
         g_free (smsdConfig.dbMod);
diff --git a/smsd/smsd.h b/smsd/smsd.h
index 63cf43b..bb0f3e0 100644
--- a/smsd/smsd.h
+++ b/smsd/smsd.h
@@ -66,6 +66,7 @@ typedef struct {
   gchar *db;
   gchar *host;
   gchar *schema;
+  gchar *clientEncoding;
 } DBConfig;
 
 extern SmsdConfig smsdConfig;

-----------------------------------------------------------------------

Summary of changes:
 configure.in    |    2 +-
 smsd/ChangeLog  |    6 ++++++
 smsd/README     |    3 +++
 smsd/man/smsd.8 |    4 ++++
 smsd/mysql.c    |   18 ++++++++++++++++++
 smsd/pq.c       |   16 ++++++++++++++++
 smsd/smsd.c     |   11 ++++++++++-
 smsd/smsd.h     |    1 +
 8 files changed, 59 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]