list.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <grass/gis.h>
  4. #include <grass/glocale.h>
  5. #include "local_proto.h"
  6. void list_available_mapsets(const char **mapset_name, int nmapsets, const char* fs)
  7. {
  8. int n;
  9. G_message(_("Available mapsets:"));
  10. for (n = 0; n < nmapsets; n++) {
  11. fprintf(stdout, "%s", mapset_name[n]);
  12. if (n < nmapsets-1) {
  13. if (strcmp(fs, "newline") == 0)
  14. fprintf(stdout, "\n");
  15. else if (strcmp(fs, "space") == 0)
  16. fprintf(stdout, " ");
  17. else if (strcmp(fs, "comma") == 0)
  18. fprintf(stdout, ",");
  19. else if (strcmp(fs, "tab") == 0)
  20. fprintf(stdout, "\t");
  21. else
  22. fprintf(stdout, "%s", fs);
  23. }
  24. }
  25. fprintf(stdout, "\n");
  26. }
  27. void list_accessible_mapsets(const char* fs)
  28. {
  29. int n;
  30. const char *name;
  31. G_message(_("Accessible mapsets:"));
  32. for (n = 0; (name = G_get_mapset_name(n)); n++) {
  33. /* match each mapset to its numeric equivalent */
  34. fprintf(stdout, "%s", name);
  35. if (G_get_mapset_name(n+1)) {
  36. if (strcmp(fs, "newline") == 0)
  37. fprintf(stdout, "\n");
  38. else if (strcmp(fs, "space") == 0)
  39. fprintf(stdout, " ");
  40. else if (strcmp(fs, "comma") == 0)
  41. fprintf(stdout, ",");
  42. else if (strcmp(fs, "tab") == 0)
  43. fprintf(stdout, "\t");
  44. else
  45. fprintf(stdout, "%s", fs);
  46. }
  47. }
  48. fprintf(stdout, "\n");
  49. }