[Greater-commits] r214 - trunk/GREAT-ER-DB/trunk/impl/postgresql

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jun 20 14:57:04 CEST 2011


Author: bricks
Date: 2011-06-20 14:57:04 +0200 (Mon, 20 Jun 2011)
New Revision: 214

Modified:
   trunk/GREAT-ER-DB/trunk/impl/postgresql/gdagreater_pg.pgc
Log:
Fix indentation and whitespace
Use strncpy instead of strcpy in db_connect function


Modified: trunk/GREAT-ER-DB/trunk/impl/postgresql/gdagreater_pg.pgc
===================================================================
--- trunk/GREAT-ER-DB/trunk/impl/postgresql/gdagreater_pg.pgc	2011-06-20 12:42:35 UTC (rev 213)
+++ trunk/GREAT-ER-DB/trunk/impl/postgresql/gdagreater_pg.pgc	2011-06-20 12:57:04 UTC (rev 214)
@@ -3877,7 +3877,7 @@
 *
 * Globals  : errln
 *            vg_db_user_info
-* 
+*
 * Changes  :
 * [DD-MON-YYYY] - [ Name ] - [ Action ]
 *********************************************************************/
@@ -3888,7 +3888,7 @@
     \li vp_errinfo Error info in case error occured
 
     \author H.Korte - Intevation
-  
+
     \date 09-SEP-2003  
 
     \param vp_userid user-id of database user
@@ -3897,10 +3897,10 @@
 
     \return Database connection (DB_con*) or NULL.
 */
-DB_con* gda_db_connect(char         *vp_userid,        
-                       char         *vp_passwd, 
-                       char         *vp_connect_descr, 
-		       DA_T_errinfo *vp_errinfo)
+DB_con* gda_db_connect(char         *vp_userid,
+                       char         *vp_passwd,
+                       char         *vp_connect_descr,
+                       DA_T_errinfo *vp_errinfo)
 {
   DA_T_MODULE_NAME  v_module   = "gda_db_connect";
   DA_T_errinfo     *v_errinfo2 = NULL;
@@ -3908,21 +3908,21 @@
 
   EXEC SQL BEGIN DECLARE SECTION;
       long   h_group_id;
-      char   h_dbname	   [ 31];
-      char   h_user_id     [ 31];
-      char   h_con_name    [ 31];	
-      char   h_usrid_passwd[240];
+      char   h_dbname      [ 255];
+      char   h_user_id     [ 255];
+      char   h_con_name    [ 255];
+      char   h_usrid_passwd[ 255];
 
       short int h_ind_user_id;
   EXEC SQL END   DECLARE SECTION;
 
   db_con = malloc(sizeof(DB_con));
-  if(!db_con)	
-  	return NULL;
- 
-  lgda_set_connection_values(db_con, vp_connect_descr, 
-  			     vp_userid, vp_passwd, vp_errinfo);
+  if(!db_con)
+    return NULL;
 
+  lgda_set_connection_values(db_con, vp_connect_descr,
+                             vp_userid, vp_passwd, vp_errinfo);
+
   /* ------------------ *
    * Start of function
    * ------------------ */
@@ -3938,17 +3938,17 @@
   errln = 0;
   EXEC SQL WHENEVER SQLERROR GOTO not_a_valid_db_user; 
 
-  strcpy(h_user_id, db_con->user_id);
-  strcpy(h_usrid_passwd, db_con->user_passwd); 
-  strcpy(h_con_name, db_con->con_name);
-  strcpy(h_dbname, db_con->connection_target);
+  strncpy(h_user_id, db_con->user_id, 255);
+  strncpy(h_usrid_passwd, db_con->user_passwd, 255); 
+  strncpy(h_con_name, db_con->con_name, 255);
+  strncpy(h_dbname, db_con->connection_target, 255);
 
   errln = 10;
   EXEC SQL CONNECT TO :h_dbname AS :h_con_name USER :h_user_id USING :h_usrid_passwd;
   
   if (!ECPGstatus(__LINE__, db_con->con_name))
   {
-	return(NULL);
+    return(NULL);
   }
 
   /* check if connected user is a valid GREAT-ER user and in case
@@ -3963,20 +3963,20 @@
   errln = 30;  
   EXEC SQL SELECT :h_user_id 
              INTO :h_user_id INDICATOR :h_ind_user_id;
- 
+
   errln = 40; 
   EXEC SQL SELECT GROUP_ID
              INTO :h_group_id
              FROM USER_TAB
             WHERE USER_ID = :h_user_id;
- 
-  strcpy(vg_db_user_info.user_id, h_user_id);
-  vg_db_user_info.group_id =      h_group_id;
+
+  strncpy(vg_db_user_info.user_id, h_user_id, 255);
+  vg_db_user_info.group_id = h_group_id;
   vg_db_user_info.admin = 0;
 
   if(NULL){
     not_a_valid_greater_user:
-	/* 
+        /*
          * ERROR: no valid greater user
          */
         vp_errinfo->err_type = DA_ERRTYP_INT;
@@ -3987,7 +3987,7 @@
         gda_db_disconnect(db_con, v_errinfo2);
 
         /* set return value */
-    	return(NULL);
+        return(NULL);
     }
 
   /* success fully connected to database */
@@ -3995,18 +3995,18 @@
 
   if(NULL){
     not_a_valid_db_user:
-  	/* set error information into return parameter */
-   	lgda_set_db_errinfo( v_module, vp_errinfo);
-	db_con = NULL;
-	return(db_con);
+    /* set error information into return parameter */
+    lgda_set_db_errinfo( v_module, vp_errinfo);
+    db_con = NULL;
+    return(db_con);
   }
   if(NULL){
     sql_error:
-   	lgda_set_db_errinfo( v_module, vp_errinfo);
+    lgda_set_db_errinfo( v_module, vp_errinfo);
         gda_db_disconnect(db_con, v_errinfo2);
-	return(NULL);
-  }	
-}  
+    return(NULL);
+  }
+}
 
 
 /*********************************************************************



More information about the Greater-commits mailing list