[GRASS-SVN] r38766 - grass/trunk/raster/r.li/r.li.daemon

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 17 02:56:51 EDT 2009


Author: hamish
Date: 2009-08-17 02:56:51 -0400 (Mon, 17 Aug 2009)
New Revision: 38766

Modified:
   grass/trunk/raster/r.li/r.li.daemon/daemon.c
Log:
minor cleanup (merge from devbr6)

Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c	2009-08-17 06:53:55 UTC (rev 38765)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c	2009-08-17 06:56:51 UTC (rev 38766)
@@ -305,42 +305,50 @@
     int sf_x, sf_y, sf_rl, sf_cl;
     int size;
 
+    /* TODO: if present, strip away G_home()/.r.li/history/ path from string */
+    /*  ? if(strncmp(G_rc_path(), path, strlen(G_rc_path()) ) == 0)
+	?     path += strlen(G_rc_path());
+	? */
     if (stat(path, &s) != 0)
-	G_fatal_error(_("Cannot make stat of %s configuration file"), path);
+	G_fatal_error(_("Cannot find configuration file <%s>"), path);
+
     size = s.st_size * sizeof(char);
     buf = G_malloc(size);
+
     setup = open(path, O_RDONLY, 0755);
     if (setup == -1)
 	G_fatal_error(_("Cannot read setup file"));
+
     letti = read(setup, buf, s.st_size);
     if (letti < s.st_size)
 	G_fatal_error(_("Cannot read setup file"));
 
-
     token = strtok(buf, " ");
     if (strcmp("SAMPLINGFRAME", token) != 0)
-	G_fatal_error(_("Illegal configuration file"));
+	G_fatal_error(_("Unable to parse configuration file"));
+
     rel_x = atof(strtok(NULL, "|"));
     rel_y = atof(strtok(NULL, "|"));
     rel_rl = atof(strtok(NULL, "|"));
     rel_cl = atof(strtok(NULL, "\n"));
 
-    /*finding raster map */
+    /* find raster map */
     if (Rast_get_cellhd(raster, "", &cellhd) == -1)
 	G_fatal_error(_("Cannot read raster header file"));
-    /*calculating absolute sampling frame definition */
+
+    /* calculate absolute sampling frame definition */
     sf_x = (int)rint(cellhd.cols * rel_x);
     sf_y = (int)rint(cellhd.rows * rel_y);
     sf_rl = (int)rint(cellhd.rows * rel_rl);
     sf_cl = (int)rint(cellhd.cols * rel_cl);
 
-    /*calculating sample frame boundaries */
+    /* calculate sample frame boundaries */
     sf_n = cellhd.north - (cellhd.ns_res * sf_y);
     sf_s = sf_n - (cellhd.ns_res * sf_rl);
     sf_w = cellhd.west + (cellhd.ew_res * sf_x);
     sf_e = sf_w + (cellhd.ew_res * sf_cl);
 
-    /* parsing configuration file */
+    /* parse configuration file */
     token = strtok(NULL, " ");
 
     if (strcmp("SAMPLEAREA", token) == 0) {
@@ -386,10 +394,12 @@
 		aid++;
 		insertNode(l, m);
 	    }
-	}
-	while ((token = strtok(NULL, " ")) != NULL &&
+
+	} while ((token = strtok(NULL, " ")) != NULL &&
 	       strcmp(token, "SAMPLEAREA") == 0);
+
 	close(setup);
+
 	return toReturn;
     }
     else if (strcmp("MASKEDSAMPLEAREA", token) == 0) {



More information about the grass-commit mailing list