Browse Source

db_set_login(): report message on failure

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59315 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
b54a5eb9fe
1 changed files with 10 additions and 6 deletions
  1. 10 6
      lib/db/dbmi_base/login.c

+ 10 - 6
lib/db/dbmi_base/login.c

@@ -3,7 +3,7 @@
   
   \brief DBMI Library (base) - login settings
   
-  (C) 1999-2009 by the GRASS Development Team
+  (C) 1999-2014 by the GRASS Development Team
   
   This program is free software under the GNU General Public
   License (>=v2). Read the file COPYING that comes with GRASS
@@ -87,7 +87,7 @@ static int read_file(LOGIN * login)
     login->n = 0;
     file = login_filename();
 
-    G_debug(3, "DB login file = <%s>", file);
+    G_debug(3, "read_file(): DB login file = <%s>", file);
 
     if (access(file, F_OK) != 0) {
 	G_debug(3, "login file does not exist");
@@ -95,8 +95,10 @@ static int read_file(LOGIN * login)
     }
 
     fd = fopen(file, "r");
-    if (fd == NULL)
+    if (fd == NULL) {
+        G_warning(_("Unable to read file '%s'"), file);
 	return -1;
+    }
 
     while (G_getl2(buf, 2000, fd)) {
 	G_chop(buf);
@@ -108,7 +110,7 @@ static int read_file(LOGIN * login)
 		ret, dr, db, usr, pwd);
 
 	if (ret < 2) {
-	    G_warning(_("Login file corrupted"));
+	    G_warning(_("Login file (%s) corrupted (line: %s)"), file, buf);
 	    continue;
 	}
 
@@ -133,11 +135,13 @@ static int write_file(LOGIN * login)
 
     file = login_filename();
 
-    G_debug(3, "DB login file = <%s>", file);
+    G_debug(3, "write_file(): DB login file = <%s>", file);
 
     fd = fopen(file, "w");
-    if (fd == NULL)
+    if (fd == NULL) {
+        G_warning(_("Unable to write file '%s'"), file);
 	return -1;
+    }
 
     /* fchmod is not available on Windows */
     /* fchmod ( fileno(fd), S_IRUSR | S_IWUSR ); */