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-19


From: Jan Derfinak
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-199-g01cf473
Date: Sat, 26 Feb 2011 21:30:45 +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  01cf473ad2c34efbf06b476f9feb82452bc9a345 (commit)
       via  c72339cf0bcc3eb07cc494d8ab49545422a8ea52 (commit)
       via  237ec84e89516430634c76ba6dcc84fcc1005859 (commit)
      from  18f12b85354a83c0278b57beee4ad75febe7c1d4 (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=01cf473ad2c34efbf06b476f9feb82452bc9a345


commit 01cf473ad2c34efbf06b476f9feb82452bc9a345
Author: Jan Derfinak <address@hidden>
Date:   Sat Feb 26 22:28:20 2011 +0100

    Simplify DB_Connect functions in pq and mysql modules by moving shared code 
to the separate function.

diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index cd422e7..bf095ea 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,8 @@
+* Sun 20 Feb 2011 Jan Derfinak
+- Simplify DB_Connect functions in pq and mysql modules by moving shared
+  code to the separate function. (Pawel Kot)
+
+
 * Sat 19 Feb 2011 Jan Derfinak
 - Version changed to 1.5.0
 - Added support for concatenated messages to pq module.
@@ -5,7 +10,7 @@
   new db from new schema and load data from backup.
 - Fixed bug #31222: smsd crashes in mysql module if a concatenated sms
   full of escapable characters is received.
- 
+
 
 * Tue 15 Feb 2011 Jan Derfinak
 - Version changed to 1.4.6
diff --git a/smsd/mysql.c b/smsd/mysql.c
index 2e06fc4..8ca5156 100644
--- a/smsd/mysql.c
+++ b/smsd/mysql.c
@@ -47,26 +47,26 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, MYSQL *mysql)
 {
 #if MYSQL_VERSION_ID >= 50013
   my_bool reconnect = 1;
 #endif
 
-  mysql_init (&mysqlIn);
+  mysql_init (mysql);
   
   if (connect.clientEncoding[0] != '\0')
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
 #if MYSQL_VERSION_ID >= 50500
   else
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
 #endif
 
 #if MYSQL_VERSION_ID >= 50013
-  mysql_options (&mysqlIn, MYSQL_OPT_RECONNECT, &reconnect);
+  mysql_options (mysql, MYSQL_OPT_RECONNECT, &reconnect);
 #endif
 
-  if (!mysql_real_connect (&mysqlIn,
+  if (!mysql_real_connect (mysql,
                            connect.host[0] != '\0' ? connect.host : NULL,
                            connect.user[0] != '\0' ? connect.user : NULL,
                            connect.password[0] != '\0' ? connect.password : 
NULL,
@@ -74,7 +74,7 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
   {
      g_print (_("Connection to database '%s' on host '%s' failed.\n"),
               connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlIn));
+     g_print (_("Error: %s\n"), mysql_error (mysql));
      return (SMSD_NOK);
   }
 
@@ -82,38 +82,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-#if MYSQL_VERSION_ID >= 50013
-  my_bool reconnect = 1;
-#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
+  return (Connect (connect, &mysqlIn));
+}
 
-  if (!mysql_real_connect (&mysqlOut,
-                           connect.host[0] != '\0' ? connect.host : NULL,
-                           connect.user[0] != '\0' ? connect.user : NULL,
-                           connect.password[0] != '\0' ? connect.password : 
NULL,
-                           connect.db, 0, NULL, 0))
-  {
-     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-              connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlOut));
-     return (SMSD_NOK);
-  }
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &mysqlOut));
 }
 
 
diff --git a/smsd/pq.c b/smsd/pq.c
index 41e16ce..68e9d49 100644
--- a/smsd/pq.c
+++ b/smsd/pq.c
@@ -51,9 +51,9 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, PGconn **conn)
 {
-  connIn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
+  *conn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
                          NULL,
                          NULL,
                          NULL,
@@ -61,20 +61,20 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
                          connect.user[0] != '\0' ? connect.user : NULL,
                          connect.password[0] != '\0' ? connect.password : 
NULL);
   
-  if (PQstatus (connIn) == CONNECTION_BAD)
+  if (PQstatus (*conn) == CONNECTION_BAD)
   {
     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
              connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connIn));
+    g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     return (SMSD_NOK);
   }
 
   if (connect.clientEncoding[0] != '\0')
-    if (PQsetClientEncoding (connIn, connect.clientEncoding))
+    if (PQsetClientEncoding (*conn, 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));
+      g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     }
     
   if (schema == NULL)
@@ -84,36 +84,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-  connOut = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
-                          NULL,
-                          NULL,
-                          NULL,
-                          connect.db,
-                          connect.user[0] != '\0' ? connect.user : NULL,
-                          connect.password[0] != '\0' ? connect.password : 
NULL);
-
-  if (PQstatus (connOut) == CONNECTION_BAD)
-  {
-    g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-             connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connOut));
-    return (SMSD_NOK);
-  }
-
-  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));
-    }
+  return (Connect (connect, &connIn));
+}
 
-  if (schema == NULL)
-    schema = g_strdup (connect.schema);
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &connOut));
 }
 
 

http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=c72339cf0bcc3eb07cc494d8ab49545422a8ea52


commit 01cf473ad2c34efbf06b476f9feb82452bc9a345
Author: Jan Derfinak <address@hidden>
Date:   Sat Feb 26 22:28:20 2011 +0100

    Simplify DB_Connect functions in pq and mysql modules by moving shared code 
to the separate function.

diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index cd422e7..bf095ea 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,8 @@
+* Sun 20 Feb 2011 Jan Derfinak
+- Simplify DB_Connect functions in pq and mysql modules by moving shared
+  code to the separate function. (Pawel Kot)
+
+
 * Sat 19 Feb 2011 Jan Derfinak
 - Version changed to 1.5.0
 - Added support for concatenated messages to pq module.
@@ -5,7 +10,7 @@
   new db from new schema and load data from backup.
 - Fixed bug #31222: smsd crashes in mysql module if a concatenated sms
   full of escapable characters is received.
- 
+
 
 * Tue 15 Feb 2011 Jan Derfinak
 - Version changed to 1.4.6
diff --git a/smsd/mysql.c b/smsd/mysql.c
index 2e06fc4..8ca5156 100644
--- a/smsd/mysql.c
+++ b/smsd/mysql.c
@@ -47,26 +47,26 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, MYSQL *mysql)
 {
 #if MYSQL_VERSION_ID >= 50013
   my_bool reconnect = 1;
 #endif
 
-  mysql_init (&mysqlIn);
+  mysql_init (mysql);
   
   if (connect.clientEncoding[0] != '\0')
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
 #if MYSQL_VERSION_ID >= 50500
   else
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
 #endif
 
 #if MYSQL_VERSION_ID >= 50013
-  mysql_options (&mysqlIn, MYSQL_OPT_RECONNECT, &reconnect);
+  mysql_options (mysql, MYSQL_OPT_RECONNECT, &reconnect);
 #endif
 
-  if (!mysql_real_connect (&mysqlIn,
+  if (!mysql_real_connect (mysql,
                            connect.host[0] != '\0' ? connect.host : NULL,
                            connect.user[0] != '\0' ? connect.user : NULL,
                            connect.password[0] != '\0' ? connect.password : 
NULL,
@@ -74,7 +74,7 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
   {
      g_print (_("Connection to database '%s' on host '%s' failed.\n"),
               connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlIn));
+     g_print (_("Error: %s\n"), mysql_error (mysql));
      return (SMSD_NOK);
   }
 
@@ -82,38 +82,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-#if MYSQL_VERSION_ID >= 50013
-  my_bool reconnect = 1;
-#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
+  return (Connect (connect, &mysqlIn));
+}
 
-  if (!mysql_real_connect (&mysqlOut,
-                           connect.host[0] != '\0' ? connect.host : NULL,
-                           connect.user[0] != '\0' ? connect.user : NULL,
-                           connect.password[0] != '\0' ? connect.password : 
NULL,
-                           connect.db, 0, NULL, 0))
-  {
-     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-              connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlOut));
-     return (SMSD_NOK);
-  }
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &mysqlOut));
 }
 
 
diff --git a/smsd/pq.c b/smsd/pq.c
index 41e16ce..68e9d49 100644
--- a/smsd/pq.c
+++ b/smsd/pq.c
@@ -51,9 +51,9 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, PGconn **conn)
 {
-  connIn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
+  *conn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
                          NULL,
                          NULL,
                          NULL,
@@ -61,20 +61,20 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
                          connect.user[0] != '\0' ? connect.user : NULL,
                          connect.password[0] != '\0' ? connect.password : 
NULL);
   
-  if (PQstatus (connIn) == CONNECTION_BAD)
+  if (PQstatus (*conn) == CONNECTION_BAD)
   {
     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
              connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connIn));
+    g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     return (SMSD_NOK);
   }
 
   if (connect.clientEncoding[0] != '\0')
-    if (PQsetClientEncoding (connIn, connect.clientEncoding))
+    if (PQsetClientEncoding (*conn, 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));
+      g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     }
     
   if (schema == NULL)
@@ -84,36 +84,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-  connOut = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
-                          NULL,
-                          NULL,
-                          NULL,
-                          connect.db,
-                          connect.user[0] != '\0' ? connect.user : NULL,
-                          connect.password[0] != '\0' ? connect.password : 
NULL);
-
-  if (PQstatus (connOut) == CONNECTION_BAD)
-  {
-    g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-             connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connOut));
-    return (SMSD_NOK);
-  }
-
-  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));
-    }
+  return (Connect (connect, &connIn));
+}
 
-  if (schema == NULL)
-    schema = g_strdup (connect.schema);
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &connOut));
 }
 
 

http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=237ec84e89516430634c76ba6dcc84fcc1005859


commit 01cf473ad2c34efbf06b476f9feb82452bc9a345
Author: Jan Derfinak <address@hidden>
Date:   Sat Feb 26 22:28:20 2011 +0100

    Simplify DB_Connect functions in pq and mysql modules by moving shared code 
to the separate function.

diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index cd422e7..bf095ea 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,8 @@
+* Sun 20 Feb 2011 Jan Derfinak
+- Simplify DB_Connect functions in pq and mysql modules by moving shared
+  code to the separate function. (Pawel Kot)
+
+
 * Sat 19 Feb 2011 Jan Derfinak
 - Version changed to 1.5.0
 - Added support for concatenated messages to pq module.
@@ -5,7 +10,7 @@
   new db from new schema and load data from backup.
 - Fixed bug #31222: smsd crashes in mysql module if a concatenated sms
   full of escapable characters is received.
- 
+
 
 * Tue 15 Feb 2011 Jan Derfinak
 - Version changed to 1.4.6
diff --git a/smsd/mysql.c b/smsd/mysql.c
index 2e06fc4..8ca5156 100644
--- a/smsd/mysql.c
+++ b/smsd/mysql.c
@@ -47,26 +47,26 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, MYSQL *mysql)
 {
 #if MYSQL_VERSION_ID >= 50013
   my_bool reconnect = 1;
 #endif
 
-  mysql_init (&mysqlIn);
+  mysql_init (mysql);
   
   if (connect.clientEncoding[0] != '\0')
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, connect.clientEncoding);
 #if MYSQL_VERSION_ID >= 50500
   else
-    mysql_options (&mysqlIn, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
+    mysql_options (mysql, MYSQL_SET_CHARSET_NAME, 
MYSQL_AUTODETECT_CHARSET_NAME);
 #endif
 
 #if MYSQL_VERSION_ID >= 50013
-  mysql_options (&mysqlIn, MYSQL_OPT_RECONNECT, &reconnect);
+  mysql_options (mysql, MYSQL_OPT_RECONNECT, &reconnect);
 #endif
 
-  if (!mysql_real_connect (&mysqlIn,
+  if (!mysql_real_connect (mysql,
                            connect.host[0] != '\0' ? connect.host : NULL,
                            connect.user[0] != '\0' ? connect.user : NULL,
                            connect.password[0] != '\0' ? connect.password : 
NULL,
@@ -74,7 +74,7 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
   {
      g_print (_("Connection to database '%s' on host '%s' failed.\n"),
               connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlIn));
+     g_print (_("Error: %s\n"), mysql_error (mysql));
      return (SMSD_NOK);
   }
 
@@ -82,38 +82,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-#if MYSQL_VERSION_ID >= 50013
-  my_bool reconnect = 1;
-#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
+  return (Connect (connect, &mysqlIn));
+}
 
-  if (!mysql_real_connect (&mysqlOut,
-                           connect.host[0] != '\0' ? connect.host : NULL,
-                           connect.user[0] != '\0' ? connect.user : NULL,
-                           connect.password[0] != '\0' ? connect.password : 
NULL,
-                           connect.db, 0, NULL, 0))
-  {
-     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-              connect.db, connect.host);
-     g_print (_("Error: %s\n"), mysql_error (&mysqlOut));
-     return (SMSD_NOK);
-  }
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &mysqlOut));
 }
 
 
diff --git a/smsd/pq.c b/smsd/pq.c
index 41e16ce..68e9d49 100644
--- a/smsd/pq.c
+++ b/smsd/pq.c
@@ -51,9 +51,9 @@ GNOKII_API void DB_Bye (void)
 }
 
 
-GNOKII_API gint DB_ConnectInbox (DBConfig connect)
+static gint Connect (const DBConfig connect, PGconn **conn)
 {
-  connIn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
+  *conn = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
                          NULL,
                          NULL,
                          NULL,
@@ -61,20 +61,20 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
                          connect.user[0] != '\0' ? connect.user : NULL,
                          connect.password[0] != '\0' ? connect.password : 
NULL);
   
-  if (PQstatus (connIn) == CONNECTION_BAD)
+  if (PQstatus (*conn) == CONNECTION_BAD)
   {
     g_print (_("Connection to database '%s' on host '%s' failed.\n"),
              connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connIn));
+    g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     return (SMSD_NOK);
   }
 
   if (connect.clientEncoding[0] != '\0')
-    if (PQsetClientEncoding (connIn, connect.clientEncoding))
+    if (PQsetClientEncoding (*conn, 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));
+      g_print (_("Error: %s\n"), PQerrorMessage (*conn));
     }
     
   if (schema == NULL)
@@ -84,36 +84,15 @@ GNOKII_API gint DB_ConnectInbox (DBConfig connect)
 }
 
 
-GNOKII_API gint DB_ConnectOutbox (DBConfig connect)
+GNOKII_API gint DB_ConnectInbox (const DBConfig connect)
 {
-  connOut = PQsetdbLogin (connect.host[0] != '\0' ? connect.host : NULL,
-                          NULL,
-                          NULL,
-                          NULL,
-                          connect.db,
-                          connect.user[0] != '\0' ? connect.user : NULL,
-                          connect.password[0] != '\0' ? connect.password : 
NULL);
-
-  if (PQstatus (connOut) == CONNECTION_BAD)
-  {
-    g_print (_("Connection to database '%s' on host '%s' failed.\n"),
-             connect.db, connect.host);
-    g_print (_("Error: %s\n"), PQerrorMessage (connOut));
-    return (SMSD_NOK);
-  }
-
-  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));
-    }
+  return (Connect (connect, &connIn));
+}
 
-  if (schema == NULL)
-    schema = g_strdup (connect.schema);
 
-  return (SMSD_OK);
+GNOKII_API gint DB_ConnectOutbox (const DBConfig connect)
+{
+  return (Connect (connect, &connOut));
 }
 
 

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

Summary of changes:
 configure.in              |    2 +-
 smsd/ChangeLog            |   14 +++
 smsd/README               |    7 +-
 smsd/db.h                 |    4 +-
 smsd/file.c               |    4 +-
 smsd/lowlevel.c           |    6 +-
 smsd/lowlevel.h           |    4 +-
 smsd/mysql.c              |  226 +++++++++++++++++--------------------
 smsd/pq.c                 |  276 ++++++++++++++++++++++++++++++++++++---------
 smsd/sms.tables.mysql.sql |    6 +-
 smsd/sms.tables.pq.sql    |   16 +++-
 smsd/smsd.c               |    4 +-
 smsd/smsd.h               |    4 +-
 smsd/utils.c              |    4 +-
 smsd/utils.h              |    4 +-
 15 files changed, 374 insertions(+), 207 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

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