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_value2.c
Go to the documentation of this file.
1
16
#include <grass/gis.h>
17
27
int
G_fwrite_key_value
(FILE * fd,
const
struct
Key_Value *kv)
28
{
29
int
n;
30
int
err
;
31
32
err = 0;
33
for
(n = 0; n < kv->nitems; n++)
34
if
(kv->value[n][0]) {
35
if
(EOF == fprintf(fd,
"%s: %s\n"
, kv->key[n], kv->value[n]))
36
err = -1;
37
}
38
return
err
;
39
}
40
51
struct
Key_Value *
G_fread_key_value
(FILE * fd)
52
{
53
struct
Key_Value *kv;
54
char
*key, *value;
55
char
buf[1024];
56
57
kv =
G_create_key_value
();
58
if
(kv ==
NULL
)
59
return
NULL
;
60
while
(
G_getl2
(buf,
sizeof
(buf) - 1, fd) != 0) {
61
key = value = buf;
62
while
(*value && *value !=
':'
)
63
value++;
64
if
(*value !=
':'
)
65
continue
;
66
*value++ = 0;
67
G_strip
(key);
68
G_strip
(value);
69
if
(!
G_set_key_value
(key, value, kv)) {
70
G_free_key_value
(kv);
71
return
NULL
;
72
}
73
}
74
return
kv;
75
}
lib
gis
key_value2.c
Generated on Sun Sep 9 2012 18:55:33 for GRASS Programmer's Manual by
1.8.1.2