[GRASS-SVN] r29670 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 11 15:45:31 EST 2008


Author: neteler
Date: 2008-01-11 15:45:31 -0500 (Fri, 11 Jan 2008)
New Revision: 29670

Modified:
   grass/trunk/lib/gis/ask.c
   grass/trunk/lib/gis/closecell.c
   grass/trunk/lib/gis/color_read.c
   grass/trunk/lib/gis/color_write.c
   grass/trunk/lib/gis/get_ellipse.c
   grass/trunk/lib/gis/get_projinfo.c
   grass/trunk/lib/gis/get_projname.c
   grass/trunk/lib/gis/get_window.c
   grass/trunk/lib/gis/make_loc.c
   grass/trunk/lib/gis/make_mapset.c
   grass/trunk/lib/gis/myname.c
   grass/trunk/lib/gis/open.c
   grass/trunk/lib/gis/opencell.c
   grass/trunk/lib/gis/remove.c
   grass/trunk/lib/gis/rename.c
Log:
changed to use GPATH_MAX, GMAPSET_MAX, GNAME_MAX

Modified: grass/trunk/lib/gis/ask.c
===================================================================
--- grass/trunk/lib/gis/ask.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/ask.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -349,8 +349,8 @@
     int (*lister)(),
     int type)
 {
-    char tmapset[256];
-    char xname[512], xmapset[512];
+    char tmapset[GMAPSET_MAX];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     int  name_is_qualified;
     int  ok;
     char tprompt[256];

Modified: grass/trunk/lib/gis/closecell.c
===================================================================
--- grass/trunk/lib/gis/closecell.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/closecell.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -162,7 +162,7 @@
     int stat;
     struct Categories cats;
     struct History hist;
-    char path[4096];
+    char path[GPATH_MAX];
     CELL cell_min, cell_max;
     int row, i, open_mode;
 

Modified: grass/trunk/lib/gis/color_read.c
===================================================================
--- grass/trunk/lib/gis/color_read.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/color_read.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -63,9 +63,9 @@
     struct Colors *colors )
 {
     int fp;
-    char buf[512];
+    char buf[GNAME_MAX];
     char *err;
-    char xname[512], xmapset[512];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     struct Range range;
     struct FPRange drange;
     CELL min, max;

Modified: grass/trunk/lib/gis/color_write.c
===================================================================
--- grass/trunk/lib/gis/color_write.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/color_write.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -76,7 +76,7 @@
 int G_write_colors (const char *name, const char *mapset, struct Colors *colors)
 {
     char element[512];
-    char xname[512], xmapset[512];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     FILE *fd;
     int stat;
 

Modified: grass/trunk/lib/gis/get_ellipse.c
===================================================================
--- grass/trunk/lib/gis/get_ellipse.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/get_ellipse.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -63,7 +63,7 @@
 G_get_ellipsoid_parameters (double *a, double *e2)
 {
     int in_stat;
-    char ipath[1024], *str, *str1;
+    char ipath[GPATH_MAX], *str, *str1;
     struct Key_Value *proj_keys;
     static char *PERMANENT = "PERMANENT";
 

Modified: grass/trunk/lib/gis/get_projinfo.c
===================================================================
--- grass/trunk/lib/gis/get_projinfo.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/get_projinfo.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -28,7 +28,7 @@
 {
 	int stat;
         struct Key_Value *in_units_keys;
-	char path[1024];
+	char path[GPATH_MAX];
 
          G__file_name (path, "", UNIT_FILE, PERMANENT);
          if (access(path,0) != 0)
@@ -59,7 +59,7 @@
 {
 	int stat;
         struct Key_Value *in_proj_keys;
-	char path[1024];
+	char path[GPATH_MAX];
 
          G__file_name (path, "", PROJECTION_FILE, PERMANENT);
          if (access(path,0) != 0)

Modified: grass/trunk/lib/gis/get_projname.c
===================================================================
--- grass/trunk/lib/gis/get_projname.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/get_projname.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  ****************************************************************************
  *
  * MODULE:       GRASS 5 gis library, get_projname.c
@@ -23,7 +21,7 @@
 int G_ask_proj_name (char *proj_id, char *proj_name)
 
 {
-	char path[1024], buff[1024], answer[50], *a;
+	char path[GPATH_MAX], buff[GPATH_MAX], answer[50], *a;
         struct Key_Value *in_proj_keys;
 	char  *Tmp_file;
         FILE  *Tmp_fd = NULL;
@@ -31,16 +29,10 @@
 
         sprintf(path,"%s/etc/projections",G_gisbase());
         while (access(path,0) !=0)
-        { 
-          sprintf(buff,_("%s not found"),path);
-          G_fatal_error(buff);
-        }
+          G_fatal_error(_("%s not found"),path);
         in_proj_keys = G_read_key_value_file(path,&in_stat);
         if (in_stat != 0)
-        {
-          sprintf(buff,_("ERROR in reading %s"),path);
-          G_fatal_error(buff);
-        }
+          G_fatal_error(_("ERROR in reading %s"),path);
         npr = in_proj_keys->nitems;
         Tmp_file = G_tempfile ();
         if (NULL == (Tmp_fd = fopen (Tmp_file, "w"))) {

Modified: grass/trunk/lib/gis/get_window.c
===================================================================
--- grass/trunk/lib/gis/get_window.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/get_window.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -1,24 +1,24 @@
 /*
- *************************************************************************
- * G_get_window (window)
- *     struct Cell_head *window
- *
- *      read the current mapset window
- *      dies if error
- *
- *************************************************************************
- * G_get_default_window (window)
- *     struct Cell_head *window
- *
- *      read the default window for the location
- *      dies if error
- *
- *************************************************************************
- * char *
- * G__get_window (window, element, name, mapset)
- *      read the window 'name' in 'element' in 'mapset'
- *      returns NULL if ok, error message if not
- ************************************************************************/
+*************************************************************************
+* G_get_window (window)
+*     struct Cell_head *window
+*
+*      read the current mapset window
+*      dies if error
+*
+*************************************************************************
+* G_get_default_window (window)
+*     struct Cell_head *window
+*
+*      read the default window for the location
+*      dies if error
+*
+*************************************************************************
+* char *
+* G__get_window (window, element, name, mapset)
+*      read the window 'name' in 'element' in 'mapset'
+*      returns NULL if ok, error message if not
+************************************************************************/
 
 #include <stdlib.h>
 #include "G.h"
@@ -27,119 +27,119 @@
 
 
 /*!
- * \brief read the database region
- *
- * Reads the database region as stored in the WIND file in the user's
- * current mapset <b>into region.</b>
- * 3D values are set to defaults if not available in WIND file.
- * An error message is printed and exit( ) is called if there is a problem reading
- * the region.
- * <b>Note.</b> GRASS applications that read or write raster maps should not
- * use this routine since its use implies that the active module region will not
- * be used. Programs that read or write raster map data (or vector data) can
- * query the active module region <i>using G_window_rows and
- * G_window_cols..</i>
- *
- *  \param region
- *  \return int
- */
+* \brief read the database region
+*
+* Reads the database region as stored in the WIND file in the user's
+* current mapset <b>into region.</b>
+* 3D values are set to defaults if not available in WIND file.
+* An error message is printed and exit( ) is called if there is a problem reading
+* the region.
+* <b>Note.</b> GRASS applications that read or write raster maps should not
+* use this routine since its use implies that the active module region will not
+* be used. Programs that read or write raster map data (or vector data) can
+* query the active module region <i>using G_window_rows and
+* G_window_cols..</i>
+*
+*  \param region
+*  \return int
+*/
 
 int G_get_window (struct Cell_head *window )
 {
-    static int first = 1;
-    static struct Cell_head dbwindow ;
-    char *regvar;
+static int first = 1;
+static struct Cell_head dbwindow ;
+char *regvar;
 
-    /* Optionaly read the region from enviroment variable */
-    regvar = getenv("GRASS_REGION");
+/* Optionaly read the region from enviroment variable */
+regvar = getenv("GRASS_REGION");
 
-    if ( regvar ) 
-    {
-        char **tokens, *delm = ";";
-	char *err;
-         
-        tokens = G_tokenize ( regvar, delm ); 
+if ( regvar ) 
+{
+    char **tokens, *delm = ";";
+    char *err;
+     
+    tokens = G_tokenize ( regvar, delm ); 
 
-        err = G__read_Cell_head_array ( tokens, window, 0);
-       
-        G_free_tokens ( tokens );
+    err = G__read_Cell_head_array ( tokens, window, 0);
+   
+    G_free_tokens ( tokens );
 
-	if (err)
-	{
-	    G_fatal_error (_("region for current mapset %s\nrun \"g.region\""), err);
-	    G_free (err);
-	}
-
-        return 1;
+    if (err)
+    {
+	G_fatal_error (_("region for current mapset %s\nrun \"g.region\""), err);
+	G_free (err);
     }
 
-    if (first)
-    {
-	char *wind, *err;
+    return 1;
+}
 
-	wind = getenv("WIND_OVERRIDE");
-	if (wind)
-	    err = G__get_window (&dbwindow,"windows",wind,G_mapset());
-	else
-	    err = G__get_window (&dbwindow,"","WIND",G_mapset());
+if (first)
+{
+    char *wind, *err;
 
-	if (err)
-	{
-	    G_fatal_error (_("region for current mapset %s\nrun \"g.region\""), err);
-	    G_free (err);
-	}
-    }
+    wind = getenv("WIND_OVERRIDE");
+    if (wind)
+	err = G__get_window (&dbwindow,"windows",wind,G_mapset());
+    else
+	err = G__get_window (&dbwindow,"","WIND",G_mapset());
 
-    first = 0;
-    G_copy (window, &dbwindow, sizeof(dbwindow) ) ;
-
-    if (!G__.window_set)
+    if (err)
     {
-	G__.window_set = 1;
-	G_copy(&G__.window, &dbwindow, sizeof(dbwindow) ) ;
+	G_fatal_error (_("region for current mapset %s\nrun \"g.region\""), err);
+	G_free (err);
     }
+}
 
-    return 1;
+first = 0;
+G_copy (window, &dbwindow, sizeof(dbwindow) ) ;
+
+if (!G__.window_set)
+{
+    G__.window_set = 1;
+    G_copy(&G__.window, &dbwindow, sizeof(dbwindow) ) ;
 }
 
+return 1;
+}
 
+
 /*!
- * \brief read the default region
- *
- * Reads the default region for the location into <b>region.</b>
- * 3D values are set to defaults if not available in WIND file.
- * An error message is printed and exit( ) is called if there is a problem
- * reading the default region.
- *
- *  \param region
- *  \return int
- */
+* \brief read the default region
+*
+* Reads the default region for the location into <b>region.</b>
+* 3D values are set to defaults if not available in WIND file.
+* An error message is printed and exit( ) is called if there is a problem
+* reading the default region.
+*
+*  \param region
+*  \return int
+*/
 
 int G_get_default_window ( struct Cell_head *window )
 {
-    char *err;
+char *err;
 
-    if ((err = G__get_window (window,"","DEFAULT_WIND","PERMANENT")))
-    {
-	G_fatal_error (_("default region %s"), err);
-	G_free (err);
-    }
-    return 1;
+if ((err = G__get_window (window,"","DEFAULT_WIND","PERMANENT")))
+{
+    G_fatal_error (_("default region %s"), err);
+    G_free (err);
 }
+return 1;
+}
 
 char *G__get_window ( struct Cell_head *window,
-       const char *element, const char *name, const char *mapset)
+   const char *element, const char *name, const char *mapset)
 {
-    FILE *fd ;
-    char *err;
+FILE *fd ;
+char *err;
 
-    G_zero ((char *) window, sizeof (struct Cell_head));
+G_zero ((char *) window, sizeof (struct Cell_head));
 
-    /* Read from file */
-    if (!(fd = G_fopen_old (element, name, mapset) ))
-    {
+/* Read from file */
+if (!(fd = G_fopen_old (element, name, mapset) ))
+{
 /*
-char path[1024];
+char path[GPATH_MAX];
 G__file_name (path,element,name,mapset);
 fprintf (stderr, "G__get_window(%s)\n",path);
 */

Modified: grass/trunk/lib/gis/make_loc.c
===================================================================
--- grass/trunk/lib/gis/make_loc.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/make_loc.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -48,7 +48,7 @@
     FILE *report_file )
 
 {
-    char	path[2048];
+    char	path[GPATH_MAX];
     int         out_stat;
 
     /* Try to create the location directory, under the gisdbase. */

Modified: grass/trunk/lib/gis/make_mapset.c
===================================================================
--- grass/trunk/lib/gis/make_mapset.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/make_mapset.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -40,7 +40,7 @@
 
 int G__make_mapset( const char *gisdbase_name, const char *location_name, const char *mapset_name )
 {
-    char	path[2048];
+    char	path[GPATH_MAX];
     struct Cell_head default_window;
 
     /* Get location */

Modified: grass/trunk/lib/gis/myname.c
===================================================================
--- grass/trunk/lib/gis/myname.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/myname.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -35,7 +35,7 @@
 G_myname(void)
 {
     static char name[GNAME_MAX];
-    char path[500];
+    char path[GPATH_MAX];
     FILE *fd;
     int ok;
 

Modified: grass/trunk/lib/gis/open.c
===================================================================
--- grass/trunk/lib/gis/open.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/open.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -89,8 +89,8 @@
     const char *mapset,
     int mode)
 {
-    char path[1024];
-    char xname[512], xmapset[512], *dummy;
+    char path[GPATH_MAX];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX], *dummy;
 
 
     G__check_gisinit();

Modified: grass/trunk/lib/gis/opencell.c
===================================================================
--- grass/trunk/lib/gis/opencell.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/opencell.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -363,7 +363,7 @@
 
 /* save name and mapset */
     {
-    char xname[512], xmapset[512];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     if (G__name_is_fully_qualified(name, xname, xmapset))
 	fcb->name   = G_store (xname);
     else

Modified: grass/trunk/lib/gis/remove.c
===================================================================
--- grass/trunk/lib/gis/remove.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/remove.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -92,7 +92,7 @@
 	DIR *dirp;
 	struct dirent *dp;
 	struct stat sb;
-	char path2[4096];
+	char path2[GPATH_MAX];
 
 	if(G_lstat(path, &sb))
 		return 1;

Modified: grass/trunk/lib/gis/rename.c
===================================================================
--- grass/trunk/lib/gis/rename.c	2008-01-11 20:44:30 UTC (rev 29669)
+++ grass/trunk/lib/gis/rename.c	2008-01-11 20:45:31 UTC (rev 29670)
@@ -65,7 +65,7 @@
     const char *oldname, const char *newname)
 {
     const char *mapset;
-    char xname[512], xmapset[512];
+    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
     char from[512], to[512];
 
     /* name in mapset legal only if mapset is current mapset */



More information about the grass-commit mailing list