color_remove.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /****************************************************************************
  2. *
  3. * MODULE: gis library
  4. * AUTHOR(S): Glynn Clements <glynn@gclements.plus.com>
  5. * COPYRIGHT: (C) 2007 Glynn Clements
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. *****************************************************************************/
  18. #include <string.h>
  19. #include <stdio.h>
  20. #include <grass/gis.h>
  21. int Rast_remove_colors(const char *name, const char *mapset)
  22. {
  23. char element[GMAPSET_MAX + 6];
  24. char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
  25. int stat;
  26. if (G_name_is_fully_qualified(name, xname, xmapset)) {
  27. if (strcmp(xmapset, mapset) != 0)
  28. return -1;
  29. name = xname;
  30. }
  31. /* get rid of existing colr2, if any */
  32. sprintf(element, "colr2/%s", mapset);
  33. stat = G_remove(element, name);
  34. if (strcmp(mapset, G_mapset()) == 0)
  35. stat = G_remove("colr", name);
  36. return stat;
  37. }