GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
raster/color_remove.c
Go to the documentation of this file.
1 /*!
2  \file lib/raster/color_remove.c
3 
4  \brief Raster Library - remove color table of raster map
5 
6  (C) 2007 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Glynn Clements
12 */
13 
14 #include <string.h>
15 #include <stdio.h>
16 #include <grass/gis.h>
17 
18 /*!
19  \brief Remove color table of raster map
20 
21  \param name name of raster map
22  \param mapset name of mapset
23 
24  \return -1 on error
25  \return 0 color table not found
26  \return 1 on success
27 */
28 int Rast_remove_colors(const char *name, const char *mapset)
29 {
30  char element[GMAPSET_MAX + 6];
31  char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
32  int stat;
33 
34  if (G_name_is_fully_qualified(name, xname, xmapset)) {
35  if (strcmp(xmapset, mapset) != 0)
36  return -1;
37  name = xname;
38  }
39 
40  /* get rid of existing colr2, if any */
41  sprintf(element, "colr2/%s", mapset);
42  stat = G_remove(element, name);
43 
44  if (strcmp(mapset, G_mapset()) == 0)
45  stat = G_remove("colr", name);
46 
47  return stat;
48 }
int G_remove(const char *, const char *)
Remove a database file.
Definition: remove.c:44
#define GMAPSET_MAX
Definition: gis.h:178
Definition: lidar.h:86
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
#define GNAME_MAX
Definition: gis.h:177
const char * name
Definition: named_colr.c:7
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:36
int Rast_remove_colors(const char *name, const char *mapset)
Remove color table of raster map.