GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
key_value4.c
Go to the documentation of this file.
1
16
#include <grass/gis.h>
17
#include <string.h>
18
31
int
G_update_key_value_file
(
const
char
*file,
const
char
*key,
32
const
char
*value)
33
{
34
struct
Key_Value *kv;
35
int
stat;
36
37
kv =
G_read_key_value_file
(file, &stat);
38
if
(stat != 0)
39
return
stat;
40
41
if
(!
G_set_key_value
(key, value, kv)) {
42
G_free_key_value
(kv);
43
return
-2;
44
}
45
46
G_write_key_value_file
(file, kv, &stat);
47
G_free_key_value
(kv);
48
49
return
stat;
50
}
51
64
int
G_lookup_key_value_from_file
(
const
char
*file,
65
const
char
*key,
char
value[],
int
n)
66
{
67
struct
Key_Value *kv;
68
int
stat;
69
char
*v;
70
71
*value = 0;
72
kv =
G_read_key_value_file
(file, &stat);
73
if
(stat != 0)
74
return
stat;
75
76
v =
G_find_key_value
(key, kv);
77
if
(v) {
78
strncpy(value, v, n);
79
value[n - 1] = 0;
80
stat = 1;
81
}
82
else
83
stat = 0;
84
G_free_key_value
(kv);
85
return
stat;
86
}
lib
gis
key_value4.c
Generated on Sun Mar 16 2014 05:07:46 for GRASS Programmer's Manual by
1.8.1.2