1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
INI LIBRARY
Header file for the value object.
Copyright (C) Dmitri Pal <dpal@redhat.com> 2010
INI Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
INI Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with INI Library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INI_VALUEOBJ_H
#define INI_VALUEOBJ_H
#include "ref_array.h"
#include "simplebuffer.h"
#include "ini_comment.h"
struct value_obj;
#define INI_VALUE_READ 0 /* Value is read from the file */
#define INI_VALUE_CREATED 1 /* Value is created in memory */
/*
* Create value from a referenced array.
*
* NOTE: arrays and comment are NOT treated as
* objects that keep reference count.
* They are created externally and passed in
* as separate parts that are glued together
* by the value object.
* The caller should not free it himself
* (only in case of failure) since
* after the call the arrays and comment
* are owned by the value object and will
* be freed when it is destroyed.
*/
int value_create_from_refarray(struct ref_array *raw_lines,
struct ref_array *raw_lengths,
uint32_t line,
uint32_t origin,
uint32_t key_len,
uint32_t boundary,
struct ini_comment *ic,
struct value_obj **vo);
/* Cleanup callback for lines array */
void value_lines_cleanup_cb(void *elem,
ref_array_del_enum type,
void *data);
/* Create a pair of arrays */
int value_create_arrays(struct ref_array **raw_lines,
struct ref_array **raw_lengths);
/* Add a raw read line to the arrays */
int value_add_to_arrays(const char *strvalue,
uint32_t len,
struct ref_array *raw_lines,
struct ref_array *raw_lengths);
/* Create a pair of arrays */
void value_destroy_arrays(struct ref_array *raw_lines,
struct ref_array *raw_lengths);
/* Create value object from string buffer.
* NOTE: see note above
* in the description of the
* value_create_from_refarray function.
*/
int value_create_new(const char *strvalue,
uint32_t length,
uint32_t origin,
uint32_t key_len,
uint32_t boundary,
struct ini_comment *ic,
struct value_obj **vo);
/* Destroy a value object */
void value_destroy(struct value_obj *vo);
/* Get concatenated value */
int value_get_concatenated(struct value_obj *vo,
const char **fullstr);
/* Get value's origin */
int value_get_origin(struct value_obj *vo,
uint32_t *origin);
/* Get value's line */
int value_get_line(struct value_obj *vo,
uint32_t *line);
/* Update key length */
int value_set_keylen(struct value_obj *vo,
uint32_t key_len);
/* Update value */
int value_update(struct value_obj *vo,
const char *value,
uint32_t length,
uint32_t origin,
uint32_t boundary);
/* Get comment from the value */
int value_extract_comment(struct value_obj *vo,
struct ini_comment **ic);
/* Set comment into the value */
int value_put_comment(struct value_obj *vo,
struct ini_comment *ic);
/* Serialize value */
int value_serialize(struct value_obj *vo,
const char *key,
struct simplebuffer **sbobj);
#endif
|