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
find_etc.c
Go to the documentation of this file.
1
#include <stdlib.h>
2
#include <string.h>
3
#include <unistd.h>
4
#include <grass/gis.h>
5
6
static
char
*G__find_etc(
const
char
*
name
)
7
{
8
char
path[GPATH_MAX];
9
const
char
*pathlist =
getenv
(
"GRASS_ADDON_ETC"
);
10
11
/*
12
* reject illegal names
13
*/
14
if
(*name == 0 || *name ==
'.'
)
15
return
NULL
;
16
17
/*
18
* search paths
19
*/
20
if
(pathlist) {
21
char
**dirs =
G_tokenize
(pathlist,
":"
);
22
char
*result =
NULL
;
23
int
i;
24
25
for
(i = 0; dirs[i]; i++) {
26
sprintf(path,
"%s/%s"
, dirs[i], name);
27
28
if
(access(path, 0) == 0) {
29
result =
G_store
(path);
30
break
;
31
}
32
}
33
34
G_free_tokens
(dirs);
35
36
if
(result)
37
return
result;
38
}
39
40
/*
41
* check application etc dir
42
*/
43
sprintf(path,
"%s/etc/%s"
,
G_gisbase
(), name);
44
if
(access(path, 0) == 0)
45
return
G_store
(path);
46
47
return
NULL
;
48
}
49
50
63
char
*
G_find_etc
(
const
char
*name)
64
{
65
return
G__find_etc(name);
66
}
lib
gis
find_etc.c
Generated on Sat Oct 5 2013 12:11:06 for GRASS Programmer's Manual by
1.8.4