GRASS 8 Programmer's Manual 8.6.0dev(2026)-55de52a352
Loading...
Searching...
No Matches
key_value4.c
Go to the documentation of this file.
1/*!
2 \file lib/gis/key_value4.c
3
4 \brief Key_Value management.
5
6 SPDX-FileCopyrightText: 2001-2014 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author CERL
10 */
11
12#include <grass/gis.h>
13#include <string.h>
14
15/*!
16 \brief Update file, set up value for given key
17
18 \param[in] file filename to be updated
19 \param[in] key key value
20 \param[in] value value to be updated
21 */
22void G_update_key_value_file(const char *file, const char *key,
23 const char *value)
24{
25 struct Key_Value *kv;
26
31}
32
33/*!
34 \brief Look up for key in file
35
36 \param[in] file filename
37 \param[in] key key to be found in file
38 \param[out] value value for key
39 \param[in] n number of characters to be copied
40
41 \return 0 not found
42 \return 1 ok
43 */
44int G_lookup_key_value_from_file(const char *file, const char *key,
45 char value[], int n)
46{
47 struct Key_Value *kv;
48 const char *v;
49
50 *value = '\0';
52
54
55 if (v) {
56 strncpy(value, v, n);
57 value[n - 1] = '\0';
58 }
59
61
62 return v ? 1 : 0;
63}
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
Definition key_value1.c:102
void G_set_key_value(const char *, const char *, struct Key_Value *)
Set value for given key.
Definition key_value1.c:37
struct Key_Value * G_read_key_value_file(const char *)
Read key/values pairs from file.
Definition key_value3.c:53
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
Definition key_value1.c:83
void G_write_key_value_file(const char *, const struct Key_Value *)
Write key/value pairs to file.
Definition key_value3.c:26
int G_lookup_key_value_from_file(const char *file, const char *key, char value[], int n)
Look up for key in file.
Definition key_value4.c:44
void G_update_key_value_file(const char *file, const char *key, const char *value)
Update file, set up value for given key.
Definition key_value4.c:22
#define file
char ** value
Definition gis.h:535
char ** key
Definition gis.h:534