[GRASS-SVN] r60471 - in grass/trunk: include/defs lib/db/dbmi_base

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 25 01:54:54 PDT 2014


Author: martinl
Date: 2014-05-25 01:54:54 -0700 (Sun, 25 May 2014)
New Revision: 60471

Modified:
   grass/trunk/include/defs/dbmi.h
   grass/trunk/lib/db/dbmi_base/login.c
Log:
libdbmi: db_get_login_dump() added


Modified: grass/trunk/include/defs/dbmi.h
===================================================================
--- grass/trunk/include/defs/dbmi.h	2014-05-25 08:44:05 UTC (rev 60470)
+++ grass/trunk/include/defs/dbmi.h	2014-05-25 08:54:54 UTC (rev 60471)
@@ -411,5 +411,6 @@
 unsigned int db_sizeof_string(const dbString *);
 int db_set_login(const char *, const char *, const char *, const char *);
 int db_get_login(const char *, const char *, const char **, const char **);
+int db_get_login_dump(FILE *);
 
 #endif

Modified: grass/trunk/lib/db/dbmi_base/login.c
===================================================================
--- grass/trunk/lib/db/dbmi_base/login.c	2014-05-25 08:44:05 UTC (rev 60470)
+++ grass/trunk/lib/db/dbmi_base/login.c	2014-05-25 08:54:54 UTC (rev 60471)
@@ -171,8 +171,8 @@
   \param user user name
   \param password password string
   
-  \return DB_OK
-  \return DB_FAILED
+  \return DB_OK on success
+  \return DB_FAILED on failure
  */
 int db_set_login(const char *driver, const char *database, const char *user,
 		 const char *password)
@@ -225,8 +225,8 @@
   \param[out] user name
   \param[out] password string
   
-  \return DB_OK
-  \return DB_FAILED
+  \return DB_OK on success
+  \return DB_FAILED on failure
 */
 int db_get_login(const char *driver, const char *database, const char **user,
 		 const char **password)
@@ -263,3 +263,33 @@
 
     return DB_OK;
 }
+
+/*!  
+  \brief Print all connection settings to file
+  
+  \param fd file where to print settings
+  
+  \return DB_OK on success
+  \return DB_FAILED on failure
+*/
+int db_get_login_dump(FILE *fd)
+{
+    int i;
+    LOGIN login;
+    
+    G_debug(3, "db_get_login_dump()");
+    
+    init_login(&login);
+    if (read_file(&login) == -1)
+	return DB_FAILED;
+    
+    for (i = 0; i < login.n; i++) {
+        fprintf(fd, "%s|%s|%s|%s\n",
+                login.data[i].driver,
+                login.data[i].database,
+                login.data[i].user,
+                login.data[i].password);
+    }
+    
+    return DB_OK;
+}



More information about the grass-commit mailing list