[GRASS-SVN] r64467 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 4 13:08:59 PST 2015


Author: martinl
Date: 2015-02-04 13:08:59 -0800 (Wed, 04 Feb 2015)
New Revision: 64467

Modified:
   grass/trunk/display/d.mon/list.c
   grass/trunk/display/d.mon/main.c
   grass/trunk/display/d.mon/proto.h
Log:
d.mon: add -s flag to print support files (moved from d.mon)


Modified: grass/trunk/display/d.mon/list.c
===================================================================
--- grass/trunk/display/d.mon/list.c	2015-02-04 21:05:10 UTC (rev 64466)
+++ grass/trunk/display/d.mon/list.c	2015-02-04 21:08:59 UTC (rev 64467)
@@ -111,3 +111,38 @@
 
     G_free(mon_path);
 }
+
+void list_files(const char *name, FILE *fd_out)
+{
+    char *p;
+    char tmpdir[GPATH_MAX], mon_path[GPATH_MAX];
+    struct dirent *dp;
+    DIR *dirp;
+    
+    G_temp_element(tmpdir);
+    strcat(tmpdir, "/");
+    strcat(tmpdir, "MONITORS");
+    strcat(tmpdir, "/");
+    strcat(tmpdir, name);
+    
+    G_file_name(mon_path, tmpdir, NULL, G_mapset());
+    fprintf(fd_out, "path=%s\n", mon_path);
+    
+    dirp = opendir(mon_path);
+    if (!dirp)
+        G_fatal_error(_("No support files found for monitor <%s>"), name);
+
+    while ((dp = readdir(dirp)) != NULL) {
+        if (!dp->d_name || dp->d_type != DT_REG)
+            continue;
+        
+        p = strrchr(dp->d_name, '.');
+        if (!p)
+            p = dp->d_name;
+        else
+            p++; /* skip '.' */
+        
+        fprintf(fd_out, "%s=%s%c%s\n", p,
+                mon_path, HOST_DIRSEP, dp->d_name);
+    }
+}

Modified: grass/trunk/display/d.mon/main.c
===================================================================
--- grass/trunk/display/d.mon/main.c	2015-02-04 21:05:10 UTC (rev 64466)
+++ grass/trunk/display/d.mon/main.c	2015-02-04 21:08:59 UTC (rev 64467)
@@ -27,7 +27,7 @@
     struct Option *start_opt, *select_opt, *stop_opt, *output_opt,
         *width_opt, *height_opt, *bgcolor_opt, *res_opt;
     struct Flag *list_flag, *selected_flag, *select_flag, *release_flag, 
-        *cmd_flag, *truecolor_flag, *update_flag, *x_flag;
+        *cmd_flag, *truecolor_flag, *update_flag, *x_flag, *sfile_flag;
     
     int nopts, ret;
     const char *mon;
@@ -112,6 +112,11 @@
     cmd_flag->description = _("Print commands for currently selected monitor and exit");
     cmd_flag->guisection = _("Print");
 
+    sfile_flag = G_define_flag();
+    sfile_flag->key = 's';
+    sfile_flag->description =
+	_("Print path to support files of currently selected monitor and exit");
+
     select_flag = G_define_flag();
     select_flag->key = 's';
     select_flag->description = _("Do not automatically select when starting");
@@ -138,7 +143,7 @@
     x_flag->label = _("Launch light-weight wx monitor without toolbars and statusbar");
     x_flag->description = _("Requires 'start=wx0-7'");
     x_flag->guisection = _("Settings");
-    
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -146,7 +151,8 @@
         G_warning(_("Flag -%c has effect only for wx monitors (%s=wx0-7)"),
                   x_flag->key, start_opt->key);
             
-    if (selected_flag->answer || release_flag->answer || cmd_flag->answer) {
+    if (selected_flag->answer || release_flag->answer ||
+        cmd_flag->answer || sfile_flag->answer) {
 	if (list_flag->answer)
 	    G_warning(_("Flag -%c ignored"), list_flag->key);
 	mon = G_getenv_nofatal("MONITOR");
@@ -159,6 +165,9 @@
 		G_message(_("List of commands for monitor <%s>:"), mon);
 		list_cmd(mon, stdout);
 	    }
+            else if (sfile_flag->answer) {
+                list_files(mon, stdout);
+            }
 	    else if (mon) { /* release */
 		G_unsetenv("MONITOR");
 		G_verbose_message(_("Monitor <%s> released"), mon); 

Modified: grass/trunk/display/d.mon/proto.h
===================================================================
--- grass/trunk/display/d.mon/proto.h	2015-02-04 21:05:10 UTC (rev 64466)
+++ grass/trunk/display/d.mon/proto.h	2015-02-04 21:08:59 UTC (rev 64467)
@@ -14,3 +14,4 @@
 int check_mon(const char *);
 void list_cmd(const char *, FILE *);
 char *get_path(const char *, int);
+void list_files(const char *, FILE *);



More information about the grass-commit mailing list