[GRASS-SVN] r38765 -
grass/branches/develbranch_6/raster/r.li/r.li.daemon
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 17 02:53:55 EDT 2009
Author: hamish
Date: 2009-08-17 02:53:55 -0400 (Mon, 17 Aug 2009)
New Revision: 38765
Modified:
grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c
Log:
minor clean
Modified: grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c 2009-08-17 05:52:05 UTC (rev 38764)
+++ grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c 2009-08-17 06:53:55 UTC (rev 38765)
@@ -102,7 +102,7 @@
/* TODO: check if this path is portable */
sprintf(pathSetup, "%s/.r.li/history/%s", G_home(), file);
- G_debug(1, "r.li.daemon pathSetup: %s", pathSetup);
+ G_debug(1, "r.li.daemon pathSetup: [%s]", pathSetup);
parsed = parseSetup(pathSetup, l, g, raster);
/*########################################################
@@ -294,43 +294,51 @@
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 */
mapset = G_find_cell(raster, "");
if (G_get_cellhd(raster, mapset, &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) {
@@ -376,10 +384,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