color_remove.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. \file lib/raster/color_remove.c
  3. \brief Raster Library - remove color table of raster map
  4. (C) 2007 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Glynn Clements
  8. */
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <grass/gis.h>
  12. /*!
  13. \brief Remove color table of raster map
  14. \param name name of raster map
  15. \param mapset name of mapset
  16. \return -1 on error
  17. \return 0 color table not found
  18. \return 1 on success
  19. */
  20. int Rast_remove_colors(const char *name, const char *mapset)
  21. {
  22. char element[GMAPSET_MAX + 6];
  23. char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
  24. int stat;
  25. if (G_name_is_fully_qualified(name, xname, xmapset)) {
  26. if (strcmp(xmapset, mapset) != 0)
  27. return -1;
  28. name = xname;
  29. }
  30. /* get rid of existing colr2, if any */
  31. sprintf(element, "colr2/%s", mapset);
  32. stat = G_remove(element, name);
  33. if (strcmp(mapset, G_mapset()) == 0)
  34. stat = G_remove("colr", name);
  35. return stat;
  36. }