GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72735
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 }
#define GMAPSET_MAX
Definition: gis.h:149
Definition: lidar.h:89
int G_remove(const char *element, const char *name)
Remove a database file.
Definition: remove.c:44
#define GNAME_MAX
Definition: gis.h:148
int G_name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:36
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
const char * name
Definition: named_colr.c:7
int Rast_remove_colors(const char *name, const char *mapset)
Remove color table of raster map.