GRASS 8 Programmer's Manual
8.5.0(2026)-8d6ceba290
Toggle main menu visibility
Loading...
Searching...
No Matches
do_remove.c
Go to the documentation of this file.
1
/*!
2
\file lib/manage/do_remove.c
3
4
\brief Manage Library - Remove elements
5
6
(C) 2001-2011 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 Original author CERL
12
*/
13
14
#include <stdio.h>
15
#include <string.h>
16
17
#include <grass/gis.h>
18
#include <grass/vector.h>
19
#include <grass/glocale.h>
20
#include <grass/raster3d.h>
21
22
#include "manage_local_proto.h"
23
24
/*!
25
\brief Remove elements from data base
26
27
\param n element id
28
\param old name of element to be removed
29
30
\return 0 on success
31
\return 1 on error
32
*/
33
int
M_do_remove
(
int
n,
const
char
*old)
34
{
35
int
i, ret;
36
const
char
*mapset;
37
int
result = 0;
38
int
removed = 0;
39
char
xname[GNAME_MAX], xmapset[GMAPSET_MAX];
40
41
G_message
(_(
"Removing %s <%s>"
),
list
[n].maindesc, old);
42
43
M__hold_signals
(1);
44
45
if
(
G_name_is_fully_qualified
(old, xname, xmapset)) {
46
if
(strcmp(xmapset,
G_mapset
()) != 0)
47
G_fatal_error
(
"%s is not in the current mapset (%s)"
, old,
48
G_mapset
());
49
old = xname;
50
}
51
52
if
(
G_strcasecmp
(
list
[n].alias,
"vector"
) == 0) {
53
if
((mapset =
G_find_vector2
(old,
""
)) ==
NULL
) {
54
G_warning
(_(
"Vector map <%s> not found"
), old);
55
}
56
else
{
57
ret = Vect_delete(old);
58
if
(ret != -1) {
59
removed = 1;
60
}
61
else
{
62
G_warning
(_(
"Unable to delete vector map"
));
63
result = 1;
64
}
65
}
66
}
67
else
{
68
if
(
G_strcasecmp
(
list
[n].alias,
"raster"
) == 0) {
69
if
((mapset =
G_find_raster2
(old,
""
)) ==
NULL
)
70
G_warning
(_(
"Raster map <%s> not found"
), old);
71
}
72
73
if
(
G_strcasecmp
(
list
[n].alias,
"raster_3d"
) == 0) {
74
if
((mapset =
G_find_raster3d
(old,
""
)) ==
NULL
)
75
G_warning
(_(
"3D raster map <%s> not found"
), old);
76
}
77
78
for
(i = 0; i <
list
[n].nelem; i++) {
79
80
switch
(
G_remove
(
list
[n].
element
[i], old)) {
81
case
-1:
82
G_warning
(_(
"Unable to remove %s element"
),
list
[n].desc[i]);
83
result = 1;
84
break
;
85
case
0:
86
G_verbose_message
(_(
"%s is missing"
),
list
[n].desc[i]);
87
break
;
88
case
1:
89
G_verbose_message
(_(
"%s removed"
),
list
[n].desc[i]);
90
removed = 1;
91
break
;
92
}
93
}
94
}
95
96
if
(
G_strcasecmp
(
list
[n].
element
[0],
"cell"
) == 0) {
97
char
colr2[6 + GMAPSET_MAX];
98
99
if
(snprintf(colr2, 6 + GMAPSET_MAX,
"colr2/%s"
,
G_mapset
()) >=
100
6 + GMAPSET_MAX)
101
G_warning
(_(
"String for secondary color table has been truncated"
));
102
switch
(
G_remove
(colr2, old)) {
103
case
-1:
104
G_warning
(_(
"Unable to remove %s"
), colr2);
105
result = 1;
106
break
;
107
case
0:
108
G_verbose_message
(_(
"%s is missing"
), colr2);
109
break
;
110
case
1:
111
G_verbose_message
(_(
"%s removed"
), colr2);
112
removed = 1;
113
break
;
114
}
115
}
116
117
M__hold_signals
(0);
118
119
if
(!removed)
120
G_warning
(_(
"<%s> nothing removed"
), old);
121
122
return
result;
123
}
NULL
#define NULL
Definition
ccmath.h:32
M_do_remove
int M_do_remove(int n, const char *old)
Remove elements from data base.
Definition
do_remove.c:33
G_find_raster3d
const char * G_find_raster3d(const char *name, const char *mapset)
Definition
find_rast3d.c:28
G_find_raster2
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don't touch).
Definition
find_rast.c:76
G_find_vector2
const char * G_find_vector2(const char *name, const char *mapset)
Find a vector map (look but don't touch).
Definition
find_vect.c:62
G_verbose_message
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
Definition
gis/error.c:108
G_fatal_error
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition
gis/error.c:159
G_message
void G_message(const char *msg,...)
Print a message to stderr.
Definition
gis/error.c:89
G_warning
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition
gis/error.c:203
G_mapset
const char * G_mapset(void)
Get current mapset name.
Definition
mapset.c:33
G_name_is_fully_qualified
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
list
struct list * list
Definition
read_list.c:24
G_remove
int G_remove(const char *element, const char *name)
Remove a database file.
Definition
remove.c:43
M__hold_signals
int M__hold_signals(int hold)
Hold signals.
Definition
sighold.c:24
G_strcasecmp
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower).
Definition
strings.c:47
element
Definition
lidar.h:85
manage
do_remove.c
Generated on
for GRASS 8 Programmer's Manual by
1.17.0