select.c 639 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <grass/gis.h>
  2. #include <grass/glocale.h>
  3. #include "proto.h"
  4. /* select monitor */
  5. int select_mon(const char *name)
  6. {
  7. const char *curr_mon;
  8. char **list;
  9. int i, n, found;
  10. curr_mon = G__getenv("MONITOR");
  11. if (G_strcasecmp(name, curr_mon) == 0) {
  12. G_warning(_("Monitor <%s> is already selected"), name);
  13. return 0;
  14. }
  15. list_mon(&list, &n);
  16. found = FALSE;
  17. for (i = 0; i < n; i++) {
  18. if (G_strcasecmp(list[i], name) == 0) {
  19. found = TRUE;
  20. break;
  21. }
  22. }
  23. if (found)
  24. G_setenv("MONITOR", name);
  25. else
  26. G_fatal_error(_("Monitor <%s> is not running"), name);
  27. return 0;
  28. }