[GRASS-SVN] r41521 - grass/trunk/raster/r.external.out
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 22 10:12:21 EDT 2010
Author: glynn
Date: 2010-03-22 10:12:19 -0400 (Mon, 22 Mar 2010)
New Revision: 41521
Modified:
grass/trunk/raster/r.external.out/main.c
Log:
Add -p flag (print current status)
Modified: grass/trunk/raster/r.external.out/main.c
===================================================================
--- grass/trunk/raster/r.external.out/main.c 2010-03-22 08:04:30 UTC (rev 41520)
+++ grass/trunk/raster/r.external.out/main.c 2010-03-22 14:12:19 UTC (rev 41521)
@@ -95,6 +95,38 @@
return buf;
}
+static void print_status(void)
+{
+ FILE *fp;
+ struct Key_Value *key_val;
+ const char *p;
+
+ if (!G_find_file2("", "GDAL", G_mapset())) {
+ fprintf(stdout, "Not using GDAL\n");
+ return;
+ }
+
+ fp = G_fopen_old("", "GDAL", G_mapset());
+ if (!fp)
+ G_fatal_error(_("Unable to open GDAL file"));
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ p = G_find_key_value("directory", key_val);
+ fprintf(stdout, "directory: %s\n", p ? p : "not set (default 'gdal')");
+
+ p = G_find_key_value("extension", key_val);
+ fprintf(stdout, "extension: %s\n", p ? p : "<none>");
+
+ p = G_find_key_value("format", key_val);
+ fprintf(stdout, "format: %s\n", p ? p : "not set (default GTiff)");
+
+ p = G_find_key_value("options", key_val);
+ fprintf(stdout, "options: %s\n", p ? p : "<none>");
+
+ G_free_key_value(key_val);
+}
+
static void check_format(const char *format)
{
GDALDriverH driver = GDALGetDriverByName(format);
@@ -172,7 +204,7 @@
struct {
struct Option *dir, *ext, *format, *opts;
} parm;
- struct Flag *flag_f, *flag_r;
+ struct Flag *flag_f, *flag_r, *flag_p;
G_gisinit(argv[0]);
@@ -219,9 +251,19 @@
flag_r->key = 'r';
flag_r->description = _("Cease using GDAL and revert to native output");
+ flag_p = G_define_flag();
+ flag_p->key = 'p';
+ flag_p->description = _("Print current status");
+ flag_p->guisection = _("Print");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (flag_p->answer) {
+ print_status();
+ exit(EXIT_SUCCESS);
+ }
+
if (flag_f->answer) {
list_formats();
exit(EXIT_SUCCESS);
More information about the grass-commit
mailing list