GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
other.c
Go to the documentation of this file.
1
#include <fcntl.h>
2
#include <sys/stat.h>
3
#include <sys/types.h>
4
#include <stdio.h>
5
#include <unistd.h>
6
#include <grass/gis.h>
7
#include "
local_proto.h
"
8
9
static
char
*filename(
const
char
*
name
,
const
char
*mapset)
10
{
11
static
char
path[GPATH_MAX];
12
13
G__file_name
(path,
""
, name, mapset);
14
return
path;
15
}
16
17
int
mapset_permissions
(
const
char
*mapset)
18
{
19
int
stat;
20
21
stat =
G__mapset_permissions
(mapset);
22
if
(stat == 1) {
23
if
(access(filename(
".lock"
, mapset), 0) == 0)
24
stat = 0;
25
}
26
return
stat;
27
}
28
29
int
mapset_message
(
const
char
*mapset)
30
{
31
if
(
printfile
(filename(
".message"
, mapset)))
32
hit_return
();
33
34
return
0;
35
}
36
37
int
mapset_question
(
const
char
*mapset)
38
{
39
if
(
printfile
(filename(
".question"
, mapset)))
40
return
G_yes
(
"Select this mapset? "
, -1);
41
return
1;
42
}
43
44
int
printfile
(
const
char
*
name
)
45
{
46
int
fd;
47
int
n;
48
char
buf[1024];
49
50
fd = open(name, 0);
51
if
(fd < 0)
52
return
0;
53
while
((n = read(fd, buf,
sizeof
buf)) > 0)
54
write(STDOUT_FILENO, buf, n);
55
close(fd);
56
return
1;
57
}
lib
init
other.c
Generated on Sat Oct 5 2013 12:11:09 for GRASS Programmer's Manual by
1.8.4