[GRASS-SVN] r36712 -
grass/branches/releasebranch_6_4/general/g.mapsets
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 13 02:32:38 EDT 2009
Author: neteler
Date: 2009-04-13 02:32:36 -0400 (Mon, 13 Apr 2009)
New Revision: 36712
Added:
grass/branches/releasebranch_6_4/general/g.mapsets/main.c
Removed:
grass/branches/releasebranch_6_4/general/g.mapsets/get_path.c
grass/branches/releasebranch_6_4/general/g.mapsets/main_cmd.c
grass/branches/releasebranch_6_4/general/g.mapsets/main_inter.c
grass/branches/releasebranch_6_4/general/g.mapsets/scan_int.c
grass/branches/releasebranch_6_4/general/g.mapsets/set_path.c
Modified:
grass/branches/releasebranch_6_4/general/g.mapsets/Makefile
Log:
removed unused code; renamed main_cmd.c -> main.c
Modified: grass/branches/releasebranch_6_4/general/g.mapsets/Makefile
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/Makefile 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/Makefile 2009-04-13 06:32:36 UTC (rev 36712)
@@ -7,12 +7,6 @@
LIBES = $(GISLIB)
DEPENDENCIES= $(GISDEP)
-CMD_OBJS = \
- main_cmd.o \
- dsply_path.o \
- dsply_maps.o \
- get_maps.o
-
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd $(GUI)
Deleted: grass/branches/releasebranch_6_4/general/g.mapsets/get_path.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/get_path.c 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/get_path.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -1,118 +0,0 @@
-#include <string.h>
-#include "local_proto.h"
-#include <stdio.h>
-#include "externs.h"
-#include <grass/gis.h>
-int get_mapset_path(void)
-{
- static int first = 1;
- char buf[4096];
- char *b;
- char name[GMAPSET_MAX];
- int n;
- int action; /* defines action to be taken in set_path function */
-
- fprintf(stdout, "Hit RETURN to keep current list, or ");
- fprintf(stdout, "enter a new list of mapsets\n");
- if (first) {
- fprintf(stdout, "(enter the numbers before the mapset name, ");
- fprintf(stdout, "or the names themselves)\n");
- fprintf(stdout, " (to ADD to end of list, use + . . .)\n");
- fprintf(stdout, " (to DELETE from list, use - . . .)\n");
- first = 0;
- }
-
- nchoices = 0;
-
- fprintf(stdout, "\nnew list> ");
- if (!fgets(b = buf, 4096, stdin))
- goto same;
- while (isspace(*b))
- b++;
-
- switch (*b) {
- case '+': /* preload existing path into choice array */
- action = ADD;
- for (n = 0; n < ncurr_mapsets;
- choice[nchoices++] = curr_mapset[n++]) ;
- b++;
- break;
- case '-':
- action = DELETE;
- b++;
- break;
- default:
- action = REPLACE;
- }
-
- while (1) {
- if (sscanf(b, "%s", name) != 1) {
- if (action == DELETE)
- return delete_choices();
- return 1;
- }
-
- for (n = 0; n < nmapsets; n++)
- if (strcmp(name, mapset_name[n]) == 0) {
- choice[nchoices++] = n;
- goto next;
- }
-
- if (scan_int(name, &n)) {
- if (n > 0 && n <= nmapsets) {
- choice[nchoices++] = n - 1;
- goto next;
- }
- }
-
- fprintf(stdout, "\n<%s> not found\n\n", name);
- return -1;
-
- next:
- while (*b == ' ' || *b == '\t')
- b++;
- while (*b && *b != ' ' && *b != '\t')
- b++;
- }
- same:
- for (n = 0; b = G__mapset_name(n); n++) {
- int i;
-
- for (i = 0; i < nmapsets; i++)
- if (strcmp(b, mapset_name[i]) == 0) {
- choice[nchoices++] = i;
- break;
- }
- }
- return 1;
-}
-
-
-int delete_choices(void)
-{
- int i, n;
- int deletion; /* map number to be deleted */
-
- /* action is delete: modify previous mapset list and write to choice array */
-
- for (i = 0; i < nchoices; i++) {
- deletion = choice[i];
- for (n = 0; n < ncurr_mapsets; n++)
- if (curr_mapset[n] == deletion) { /* delete mapset from path */
- curr_mapset[n] = -1;
- break;
- }
- if (n == ncurr_mapsets) {
- fprintf(stdout, "\n<%s> not found in search list\n\n",
- mapset_name[deletion]);
- return -1;
- }
- }
-
- /* prepare choice array list for final processing */
- nchoices = 0;
- for (n = 0; n < ncurr_mapsets; n++)
- if (curr_mapset[n] >= 0) /* i.e., not deleted */
- choice[nchoices++] = curr_mapset[n];
- return 1;
-}
Copied: grass/branches/releasebranch_6_4/general/g.mapsets/main.c (from rev 36705, grass/branches/releasebranch_6_4/general/g.mapsets/main_cmd.c)
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/main.c (rev 0)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/main.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -0,0 +1,238 @@
+
+/****************************************************************************
+ *
+ * MODULE: g.mapsets
+ * AUTHOR(S): Michael Shapiro (CERL), Greg Koerper (ManTech Environmental
+ * Technology) (original contributors),
+ * Glynn Clements <glynn gclements.plus.com>
+ * Hamish Bowman <hamish_nospam yahoo.com>,
+ * Markus Neteler <neteler itc.it>,
+ * Moritz Lennert <mlennert club.worldonline.be>
+ * PURPOSE: set current mapset path
+ * COPYRIGHT: (C) 1994-2008 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ *****************************************************************************/
+
+#define MAIN
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <grass/gis.h>
+#include <grass/spawn.h>
+#include <grass/glocale.h>
+#include "local_proto.h"
+#include "externs.h"
+
+static char Path[GPATH_MAX];
+
+int main(int argc, char *argv[])
+{
+ int n;
+ int i;
+ int skip;
+ char *cur_mapset;
+ char **ptr;
+ char **tokens;
+ int no_tokens;
+ FILE *fp;
+ char path[GPATH_MAX];
+ struct GModule *module;
+ struct Option *opt1, *opt2, *opt3;
+ struct Flag *print;
+ struct Flag *list;
+ struct Flag *tcl;
+
+ G_gisinit(argv[0]);
+
+ module = G_define_module();
+ module->keywords = _("general, settings");
+ module->description =
+ _("Modifies the user's current mapset "
+ "search path, affecting the user's access to data existing "
+ "under the other GRASS mapsets in the current location.");
+
+ opt1 = G_define_option();
+ opt1->key = "mapset";
+ opt1->type = TYPE_STRING;
+ opt1->required = NO;
+ opt1->multiple = YES;
+ opt1->description = _("Name(s) of existing mapset(s)");
+
+ opt2 = G_define_option();
+ opt2->key = "addmapset";
+ opt2->type = TYPE_STRING;
+ opt2->required = NO;
+ opt2->multiple = YES;
+ opt2->description =
+ _("Name(s) of existing mapset(s) to add to search list");
+
+ opt3 = G_define_option();
+ opt3->key = "removemapset";
+ opt3->type = TYPE_STRING;
+ opt3->required = NO;
+ opt3->multiple = YES;
+ opt3->description =
+ _("Name(s) of existing mapset(s) to remove from search list");
+
+ list = G_define_flag();
+ list->key = 'l';
+ list->description = _("List all available mapsets");
+
+ print = G_define_flag();
+ print->key = 'p';
+ print->description = _("Print current mapset search path");
+
+ tcl = G_define_flag();
+ tcl->key = 's';
+ tcl->description = _("Show mapset selection dialog");
+
+ Path[0] = '\0';
+ nchoices = 0;
+
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ if (list->answer) {
+ get_available_mapsets();
+ display_available_mapsets(0);
+ }
+
+ if (tcl->answer) {
+ sprintf(path, "%s/etc/g.mapsets.tcl", G_gisbase());
+ G_spawn(path, "g.mapsets.tcl", NULL);
+ }
+
+ if (opt1->answer) {
+ for (ptr = opt1->answers; *ptr != NULL; ptr++) {
+ char *mapset;
+
+ mapset = *ptr;
+ if (G__mapset_permissions(mapset) < 0)
+ G_fatal_error(_("Mapset <%s> not found"), mapset);
+ nchoices++;
+ strcat(Path, mapset);
+ strcat(Path, " ");
+ }
+ }
+
+ /* add to existing search path */
+ if (opt2->answer) {
+ char *oldname;
+
+ Path[0] = '\0';
+
+ /* read existing mapsets from SEARCH_PATH */
+ for (n = 0; (oldname = G__mapset_name(n)); n++) {
+ strcat(Path, oldname);
+ strcat(Path, " ");
+ }
+
+ /* fetch and add new mapsets from param list */
+ for (ptr = opt2->answers; *ptr != NULL; ptr++) {
+ char *mapset;
+
+ mapset = *ptr;
+
+ if (G_is_mapset_in_search_path(mapset))
+ continue;
+
+ if (G__mapset_permissions(mapset) < 0)
+ G_fatal_error(_("Mapset <%s> not found"), mapset);
+ else
+ G_verbose_message(_("Mapset <%s> added to search path"),
+ mapset);
+
+ nchoices++;
+ strcat(Path, mapset);
+ strcat(Path, " ");
+ }
+ }
+
+ /* remove from existing search path */
+ if (opt3->answer) {
+ char *oldname;
+
+ Path[0] = '\0';
+
+ /* read existing mapsets from SEARCH_PATH */
+ for (n = 0; (oldname = G__mapset_name(n)); n++) {
+ int found = 0;
+
+ for (ptr = opt3->answers; *ptr; ptr++)
+ if (strcmp(oldname, *ptr) == 0)
+ found = 1;
+
+ if (found) {
+ G_verbose_message(_("Mapset <%s> removed from search path"),
+ oldname);
+ continue;
+ }
+
+ nchoices++;
+ strcat(Path, oldname);
+ strcat(Path, " ");
+ }
+ }
+
+ /* stuffem sets nchoices */
+
+ if (nchoices == 0) {
+ goto DISPLAY;
+ }
+
+ /* note I'm assuming that mapsets cannot have ' 's in them */
+ tokens = G_tokenize(Path, " ");
+
+ fp = G_fopen_new("", "SEARCH_PATH");
+ if (!fp)
+ G_fatal_error(_("Cannot open SEARCH_PATH for write"));
+
+ cur_mapset = G_mapset();
+
+ /*
+ * make sure current mapset is specified in the list
+ * if not add it to the head of the list
+ */
+
+ skip = 0;
+ for (n = 0; n < nchoices; n++)
+ if (strcmp(cur_mapset, tokens[n]) == 0) {
+ skip = 1;
+ break;
+ }
+ if (!skip) {
+ fprintf(fp, "%s\n", cur_mapset);
+ }
+
+ /*
+ * output the list, removing duplicates
+ */
+
+ no_tokens = G_number_of_tokens(tokens);
+
+ for (n = 0; n < no_tokens; n++) {
+ skip = 0;
+ for (i = n; i < no_tokens; i++) {
+ if (i != n) {
+ if (strcmp(tokens[i], tokens[n]) == 0)
+ skip = 1;
+ }
+ }
+
+ if (!skip)
+ fprintf(fp, "%s\n", tokens[n]);
+ }
+
+ fclose(fp);
+ G_free_tokens(tokens);
+
+ DISPLAY:
+ if (print->answer)
+ display_mapset_path(0);
+
+ exit(EXIT_SUCCESS);
+}
Property changes on: grass/branches/releasebranch_6_4/general/g.mapsets/main.c
___________________________________________________________________
Name: svn:mime-type
+ text/x-csrc
Name: svn:keywords
+ Author Date Id
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: grass/branches/releasebranch_6_4/general/g.mapsets/main_cmd.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/main_cmd.c 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/main_cmd.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -1,238 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE: g.mapsets
- * AUTHOR(S): Michael Shapiro (CERL), Greg Koerper (ManTech Environmental
- * Technology) (original contributors),
- * Glynn Clements <glynn gclements.plus.com>
- * Hamish Bowman <hamish_nospam yahoo.com>,
- * Markus Neteler <neteler itc.it>,
- * Moritz Lennert <mlennert club.worldonline.be>
- * PURPOSE: set current mapset path
- * COPYRIGHT: (C) 1994-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- *****************************************************************************/
-
-#define MAIN
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <grass/gis.h>
-#include <grass/spawn.h>
-#include <grass/glocale.h>
-#include "local_proto.h"
-#include "externs.h"
-
-static char Path[GPATH_MAX];
-
-int main(int argc, char *argv[])
-{
- int n;
- int i;
- int skip;
- char *cur_mapset;
- char **ptr;
- char **tokens;
- int no_tokens;
- FILE *fp;
- char path[GPATH_MAX];
- struct GModule *module;
- struct Option *opt1, *opt2, *opt3;
- struct Flag *print;
- struct Flag *list;
- struct Flag *tcl;
-
- G_gisinit(argv[0]);
-
- module = G_define_module();
- module->keywords = _("general, settings");
- module->description =
- _("Modifies the user's current mapset "
- "search path, affecting the user's access to data existing "
- "under the other GRASS mapsets in the current location.");
-
- opt1 = G_define_option();
- opt1->key = "mapset";
- opt1->type = TYPE_STRING;
- opt1->required = NO;
- opt1->multiple = YES;
- opt1->description = _("Name(s) of existing mapset(s)");
-
- opt2 = G_define_option();
- opt2->key = "addmapset";
- opt2->type = TYPE_STRING;
- opt2->required = NO;
- opt2->multiple = YES;
- opt2->description =
- _("Name(s) of existing mapset(s) to add to search list");
-
- opt3 = G_define_option();
- opt3->key = "removemapset";
- opt3->type = TYPE_STRING;
- opt3->required = NO;
- opt3->multiple = YES;
- opt3->description =
- _("Name(s) of existing mapset(s) to remove from search list");
-
- list = G_define_flag();
- list->key = 'l';
- list->description = _("List all available mapsets");
-
- print = G_define_flag();
- print->key = 'p';
- print->description = _("Print current mapset search path");
-
- tcl = G_define_flag();
- tcl->key = 's';
- tcl->description = _("Show mapset selection dialog");
-
- Path[0] = '\0';
- nchoices = 0;
-
- if (G_parser(argc, argv))
- exit(EXIT_FAILURE);
-
- if (list->answer) {
- get_available_mapsets();
- display_available_mapsets(0);
- }
-
- if (tcl->answer) {
- sprintf(path, "%s/etc/g.mapsets.tcl", G_gisbase());
- G_spawn(path, "g.mapsets.tcl", NULL);
- }
-
- if (opt1->answer) {
- for (ptr = opt1->answers; *ptr != NULL; ptr++) {
- char *mapset;
-
- mapset = *ptr;
- if (G__mapset_permissions(mapset) < 0)
- G_fatal_error(_("Mapset <%s> not found"), mapset);
- nchoices++;
- strcat(Path, mapset);
- strcat(Path, " ");
- }
- }
-
- /* add to existing search path */
- if (opt2->answer) {
- char *oldname;
-
- Path[0] = '\0';
-
- /* read existing mapsets from SEARCH_PATH */
- for (n = 0; (oldname = G__mapset_name(n)); n++) {
- strcat(Path, oldname);
- strcat(Path, " ");
- }
-
- /* fetch and add new mapsets from param list */
- for (ptr = opt2->answers; *ptr != NULL; ptr++) {
- char *mapset;
-
- mapset = *ptr;
-
- if (G_is_mapset_in_search_path(mapset))
- continue;
-
- if (G__mapset_permissions(mapset) < 0)
- G_fatal_error(_("Mapset <%s> not found"), mapset);
- else
- G_verbose_message(_("Mapset <%s> added to search path"),
- mapset);
-
- nchoices++;
- strcat(Path, mapset);
- strcat(Path, " ");
- }
- }
-
- /* remove from existing search path */
- if (opt3->answer) {
- char *oldname;
-
- Path[0] = '\0';
-
- /* read existing mapsets from SEARCH_PATH */
- for (n = 0; (oldname = G__mapset_name(n)); n++) {
- int found = 0;
-
- for (ptr = opt3->answers; *ptr; ptr++)
- if (strcmp(oldname, *ptr) == 0)
- found = 1;
-
- if (found) {
- G_verbose_message(_("Mapset <%s> removed from search path"),
- oldname);
- continue;
- }
-
- nchoices++;
- strcat(Path, oldname);
- strcat(Path, " ");
- }
- }
-
- /* stuffem sets nchoices */
-
- if (nchoices == 0) {
- goto DISPLAY;
- }
-
- /* note I'm assuming that mapsets cannot have ' 's in them */
- tokens = G_tokenize(Path, " ");
-
- fp = G_fopen_new("", "SEARCH_PATH");
- if (!fp)
- G_fatal_error(_("Cannot open SEARCH_PATH for write"));
-
- cur_mapset = G_mapset();
-
- /*
- * make sure current mapset is specified in the list
- * if not add it to the head of the list
- */
-
- skip = 0;
- for (n = 0; n < nchoices; n++)
- if (strcmp(cur_mapset, tokens[n]) == 0) {
- skip = 1;
- break;
- }
- if (!skip) {
- fprintf(fp, "%s\n", cur_mapset);
- }
-
- /*
- * output the list, removing duplicates
- */
-
- no_tokens = G_number_of_tokens(tokens);
-
- for (n = 0; n < no_tokens; n++) {
- skip = 0;
- for (i = n; i < no_tokens; i++) {
- if (i != n) {
- if (strcmp(tokens[i], tokens[n]) == 0)
- skip = 1;
- }
- }
-
- if (!skip)
- fprintf(fp, "%s\n", tokens[n]);
- }
-
- fclose(fp);
- G_free_tokens(tokens);
-
- DISPLAY:
- if (print->answer)
- display_mapset_path(0);
-
- exit(EXIT_SUCCESS);
-}
Deleted: grass/branches/releasebranch_6_4/general/g.mapsets/main_inter.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/main_inter.c 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/main_inter.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -1,41 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE: g.mapsets
- * AUTHOR(S): Michael Shapiro (CERL), Greg Koerper (ManTech Environmental
- * Technology) (original contributors),
- * Markus Neteler <neteler itc.it>
- * Glynn Clements <glynn gclements.plus.com>
- * PURPOSE: Allow user to select new mapset path
- * COPYRIGHT: (C) 1994-2006 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- *****************************************************************************/
-
-#define MAIN
-#include "externs.h"
-#include "local_proto.h"
-#include <grass/gis.h>
-int main(int argc, char **argv)
-{
- G_gisinit(argv[0]);
- G_clear_screen();
- fprintf(stdout, "MAPSET SEARCH LIST UTILITY");
- fprintf(stdout, " LOCATION: %s MAPSET: %s\n\n", G_location(),
- G_mapset());
-
- get_available_mapsets();
-
- do {
- display_mapset_path(1);
- display_available_mapsets(1);
- }
- while (get_mapset_path() < 0);
-
- set_mapset_path();
-
- return 0;
-}
Deleted: grass/branches/releasebranch_6_4/general/g.mapsets/scan_int.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/scan_int.c 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/scan_int.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -1,12 +0,0 @@
-#include "local_proto.h"
-#include <stdio.h>
-int scan_int(char *buf, int *n)
-{
- char dummy[2];
-
- *dummy = 0;
- if (sscanf(buf, "%d%1s", n, dummy) != 1)
- return 0;
-
- return (*dummy == 0 ? 1 : 0);
-}
Deleted: grass/branches/releasebranch_6_4/general/g.mapsets/set_path.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/set_path.c 2009-04-13 06:26:10 UTC (rev 36711)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/set_path.c 2009-04-13 06:32:36 UTC (rev 36712)
@@ -1,67 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-#include "externs.h"
-#include <grass/gis.h>
-
-int set_mapset_path(void)
-{
- char command[4096];
- int n;
- int i;
- int skip;
- int any;
- char *cur_mapset;
-
- if (nchoices == 0) /* they didn't choose any, exit w/out change */
- return 0;
-
- cur_mapset = G_mapset();
-
- /* build first part of command string */
- strcpy(command, "g.mapsets -p mapset=");
- any = 0;
-
- /*
- * make sure current mapset is specified in the list
- * if not add it to the head of the list
- */
-
- skip = 0;
- for (n = 0; n < nchoices; n++)
- if (strcmp(cur_mapset, mapset_name[choice[n]]) == 0) {
- skip = 1;
- break;
- }
- if (!skip) {
- if (any++)
- strcat(command, ",");
- strcat(command, cur_mapset);
- }
-
- /*
- * output the list, removing duplicates
- */
- for (n = 0; n < nchoices; n++) {
- skip = 0;
- for (i = 0; i < n; i++)
- if (strcmp(mapset_name[choice[i]], mapset_name[choice[n]]) == 0) {
- skip = 1;
- break;
- }
- if (!skip) {
- if (any++)
- strcat(command, ",");
- strcat(command, mapset_name[choice[n]]);
- }
- }
-
- fprintf(stdout, "\nMapset search list set to\n ");
- fflush(stdout);
- if (system(command) == 0) {
- return (0);
- }
- else {
- G_warning("call to g.mapsets failed");
- return (-1);
- }
-}
More information about the grass-commit
mailing list