Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libconfig
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
libconfig
Commits
8acc6201
Commit
8acc6201
authored
Dec 14, 2019
by
Mark Lindner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefix all internal functions with 'libconfig_'
parent
a6b370e7
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
331 additions
and
311 deletions
+331
-311
examples/c++/example1.cpp
examples/c++/example1.cpp
+4
-0
lib/grammar.c
lib/grammar.c
+5
-5
lib/grammar.y
lib/grammar.y
+5
-5
lib/libconfig.c
lib/libconfig.c
+9
-8
lib/parsectx.h
lib/parsectx.h
+8
-8
lib/scanctx.c
lib/scanctx.c
+17
-16
lib/scanctx.h
lib/scanctx.h
+17
-14
lib/scanner.c
lib/scanner.c
+222
-212
lib/scanner.h
lib/scanner.h
+6
-5
lib/scanner.l
lib/scanner.l
+21
-21
lib/strbuf.c
lib/strbuf.c
+7
-7
lib/strbuf.h
lib/strbuf.h
+4
-4
lib/strvec.c
lib/strvec.c
+3
-3
lib/strvec.h
lib/strvec.h
+3
-3
No files found.
examples/c++/example1.cpp
View file @
8acc6201
...
...
@@ -52,6 +52,10 @@ int main(int argc, char **argv)
return
(
EXIT_FAILURE
);
}
string
tmp
;
cfg
.
lookupValue
(
"name"
,
tmp
);
std
::
cout
<<
"name: "
<<
tmp
<<
std
::
endl
;
// Get the store name.
try
{
...
...
lib/grammar.c
View file @
8acc6201
...
...
@@ -96,7 +96,7 @@ static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
config_setting_t
*
setting
)
{
setting
->
line
=
(
unsigned
int
)
libconfig_yyget_lineno
(
scanner
);
setting
->
file
=
scanctx_current_filename
(
scan_ctx
);
setting
->
file
=
libconfig_
scanctx_current_filename
(
scan_ctx
);
}
#define CAPTURE_PARSE_POS(S) \
...
...
@@ -1418,13 +1418,13 @@ yyreduce:
case
21
:
#line 186 "grammar.y"
/* yacc.c:1646 */
{
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
{
libconfig_
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
#line 1423 "grammar.c"
/* yacc.c:1646 */
break
;
case
22
:
#line 187 "grammar.y"
/* yacc.c:1646 */
{
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
{
libconfig_
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
#line 1429 "grammar.c"
/* yacc.c:1646 */
break
;
...
...
@@ -1583,7 +1583,7 @@ yyreduce:
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
const
char
*
s
=
parsectx_take_string
(
ctx
);
const
char
*
s
=
libconfig_
parsectx_take_string
(
ctx
);
config_setting_t
*
e
=
config_setting_set_string_elem
(
ctx
->
parent
,
-
1
,
s
);
__delete
(
s
);
...
...
@@ -1599,7 +1599,7 @@ yyreduce:
}
else
{
const
char
*
s
=
parsectx_take_string
(
ctx
);
const
char
*
s
=
libconfig_
parsectx_take_string
(
ctx
);
config_setting_set_string
(
ctx
->
setting
,
s
);
__delete
(
s
);
}
...
...
lib/grammar.y
View file @
8acc6201
...
...
@@ -56,7 +56,7 @@ static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
config_setting_t *setting)
{
setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
setting->file = scanctx_current_filename(scan_ctx);
setting->file =
libconfig_
scanctx_current_filename(scan_ctx);
}
#define CAPTURE_PARSE_POS(S) \
...
...
@@ -183,8 +183,8 @@ value:
;
string:
TOK_STRING { parsectx_append_string(ctx, $1); free($1); }
| string TOK_STRING { parsectx_append_string(ctx, $2); free($2); }
TOK_STRING {
libconfig_
parsectx_append_string(ctx, $1); free($1); }
| string TOK_STRING {
libconfig_
parsectx_append_string(ctx, $2); free($2); }
;
simple_value:
...
...
@@ -318,7 +318,7 @@ simple_value:
{
if(IN_ARRAY() || IN_LIST())
{
const char *s = parsectx_take_string(ctx);
const char *s =
libconfig_
parsectx_take_string(ctx);
config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
__delete(s);
...
...
@@ -334,7 +334,7 @@ simple_value:
}
else
{
const char *s = parsectx_take_string(ctx);
const char *s =
libconfig_
parsectx_take_string(ctx);
config_setting_set_string(ctx->setting, s);
__delete(s);
}
...
...
lib/libconfig.c
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -539,15 +539,15 @@ static int __config_read(config_t *config, FILE *stream, const char *filename,
config_clear
(
config
);
parsectx_init
(
&
parse_ctx
);
libconfig_
parsectx_init
(
&
parse_ctx
);
parse_ctx
.
config
=
config
;
parse_ctx
.
parent
=
config
->
root
;
parse_ctx
.
setting
=
config
->
root
;
__config_locale_override
();
scanctx_init
(
&
scan_ctx
,
filename
);
config
->
root
->
file
=
scanctx_current_filename
(
&
scan_ctx
);
libconfig_
scanctx_init
(
&
scan_ctx
,
filename
);
config
->
root
->
file
=
libconfig_
scanctx_current_filename
(
&
scan_ctx
);
scan_ctx
.
config
=
config
;
libconfig_yylex_init_extra
(
&
scan_ctx
,
&
scanner
);
...
...
@@ -563,17 +563,18 @@ static int __config_read(config_t *config, FILE *stream, const char *filename,
{
YY_BUFFER_STATE
buf
;
config
->
error_file
=
scanctx_current_filename
(
&
scan_ctx
);
config
->
error_file
=
libconfig_
scanctx_current_filename
(
&
scan_ctx
);
config
->
error_type
=
CONFIG_ERR_PARSE
;
/* Unwind the include stack, freeing the buffers and closing the files. */
while
((
buf
=
(
YY_BUFFER_STATE
)
scanctx_pop_include
(
&
scan_ctx
))
!=
NULL
)
while
((
buf
=
(
YY_BUFFER_STATE
)
libconfig_scanctx_pop_include
(
&
scan_ctx
))
!=
NULL
)
libconfig_yy_delete_buffer
(
buf
,
scanner
);
}
libconfig_yylex_destroy
(
scanner
);
config
->
filenames
=
scanctx_cleanup
(
&
scan_ctx
);
parsectx_cleanup
(
&
parse_ctx
);
config
->
filenames
=
libconfig_
scanctx_cleanup
(
&
scan_ctx
);
libconfig_
parsectx_cleanup
(
&
parse_ctx
);
__config_locale_restore
();
...
...
lib/parsectx.h
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -36,14 +36,14 @@ struct parse_context
strbuf_t
string
;
};
#define parsectx_init(C) \
#define
libconfig_
parsectx_init(C) \
__zero(C)
#define parsectx_cleanup(C) \
__delete(strbuf_release(&((C)->string)))
#define
libconfig_
parsectx_cleanup(C) \
__delete(
libconfig_
strbuf_release(&((C)->string)))
#define parsectx_append_string(C, S) \
strbuf_append_string(&((C)->string), (S))
#define parsectx_take_string(C) \
strbuf_release(&((C)->string))
#define
libconfig_
parsectx_append_string(C, S) \
libconfig_
strbuf_append_string(&((C)->string), (S))
#define
libconfig_
parsectx_take_string(C) \
libconfig_
strbuf_release(&((C)->string))
#endif
/* __libconfig_parsectx_h */
lib/scanctx.c
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -35,19 +35,19 @@ static const char *err_include_too_deep = "include file nesting too deep";
/* ------------------------------------------------------------------------- */
void
scanctx_init
(
struct
scan_context
*
ctx
,
const
char
*
top_filename
)
void
libconfig_
scanctx_init
(
struct
scan_context
*
ctx
,
const
char
*
top_filename
)
{
__zero
(
ctx
);
if
(
top_filename
)
{
ctx
->
top_filename
=
strdup
(
top_filename
);
strvec_append
(
&
(
ctx
->
filenames
),
ctx
->
top_filename
);
libconfig_
strvec_append
(
&
(
ctx
->
filenames
),
ctx
->
top_filename
);
}
}
/* ------------------------------------------------------------------------- */
const
char
**
scanctx_cleanup
(
struct
scan_context
*
ctx
)
const
char
**
libconfig_
scanctx_cleanup
(
struct
scan_context
*
ctx
)
{
int
i
;
...
...
@@ -61,15 +61,15 @@ const char **scanctx_cleanup(struct scan_context *ctx)
__delete
(
frame
->
files
);
}
__delete
(
strbuf_release
(
&
(
ctx
->
string
)));
__delete
(
libconfig_
strbuf_release
(
&
(
ctx
->
string
)));
return
(
strvec_release
(
&
(
ctx
->
filenames
)));
return
(
libconfig_
strvec_release
(
&
(
ctx
->
filenames
)));
}
/* ------------------------------------------------------------------------- */
FILE
*
scanctx_push_include
(
struct
scan_context
*
ctx
,
void
*
prev_buffer
,
const
char
*
path
,
const
char
**
error
)
FILE
*
libconfig_
scanctx_push_include
(
struct
scan_context
*
ctx
,
void
*
prev_buffer
,
const
char
*
path
,
const
char
**
error
)
{
struct
include_stack_frame
*
frame
;
const
char
**
files
=
NULL
,
**
f
;
...
...
@@ -102,7 +102,7 @@ FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer,
frame
=
&
(
ctx
->
include_stack
[
ctx
->
stack_depth
]);
for
(
f
=
files
;
*
f
;
++
f
)
strvec_append
(
&
(
ctx
->
filenames
),
*
f
);
libconfig_
strvec_append
(
&
(
ctx
->
filenames
),
*
f
);
frame
->
files
=
files
;
frame
->
current_file
=
NULL
;
...
...
@@ -110,16 +110,17 @@ FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer,
frame
->
parent_buffer
=
prev_buffer
;
++
(
ctx
->
stack_depth
);
fp
=
scanctx_next_include_file
(
ctx
,
error
);
fp
=
libconfig_
scanctx_next_include_file
(
ctx
,
error
);
if
(
!
fp
)
(
void
)
scanctx_pop_include
(
ctx
);
(
void
)
libconfig_
scanctx_pop_include
(
ctx
);
return
(
fp
);
}
/* ------------------------------------------------------------------------- */
FILE
*
scanctx_next_include_file
(
struct
scan_context
*
ctx
,
const
char
**
error
)
FILE
*
libconfig_scanctx_next_include_file
(
struct
scan_context
*
ctx
,
const
char
**
error
)
{
struct
include_stack_frame
*
include_frame
;
...
...
@@ -153,7 +154,7 @@ FILE *scanctx_next_include_file(struct scan_context *ctx, const char **error)
/* ------------------------------------------------------------------------- */
void
*
scanctx_pop_include
(
struct
scan_context
*
ctx
)
void
*
libconfig_
scanctx_pop_include
(
struct
scan_context
*
ctx
)
{
struct
include_stack_frame
*
frame
;
...
...
@@ -176,16 +177,16 @@ void *scanctx_pop_include(struct scan_context *ctx)
/* ------------------------------------------------------------------------- */
char
*
scanctx_take_string
(
struct
scan_context
*
ctx
)
char
*
libconfig_
scanctx_take_string
(
struct
scan_context
*
ctx
)
{
char
*
r
=
strbuf_release
(
&
(
ctx
->
string
));
char
*
r
=
libconfig_
strbuf_release
(
&
(
ctx
->
string
));
return
(
r
?
r
:
strdup
(
""
));
}
/* ------------------------------------------------------------------------- */
const
char
*
scanctx_current_filename
(
struct
scan_context
*
ctx
)
const
char
*
libconfig_
scanctx_current_filename
(
struct
scan_context
*
ctx
)
{
if
(
ctx
->
stack_depth
>
0
)
return
(
*
(
ctx
->
include_stack
[
ctx
->
stack_depth
-
1
].
current_file
));
...
...
lib/scanctx.h
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -55,8 +55,9 @@ struct scan_context
strvec_t
filenames
;
};
extern
void
scanctx_init
(
struct
scan_context
*
ctx
,
const
char
*
top_filename
);
extern
const
char
**
scanctx_cleanup
(
struct
scan_context
*
ctx
);
extern
void
libconfig_scanctx_init
(
struct
scan_context
*
ctx
,
const
char
*
top_filename
);
extern
const
char
**
libconfig_scanctx_cleanup
(
struct
scan_context
*
ctx
);
/*
* Pushes a new frame onto the include stack, and returns an open stream to the
...
...
@@ -76,8 +77,10 @@ extern const char **scanctx_cleanup(struct scan_context *ctx);
* *error is NULL, it means there are no files in the list. Otherwise, it
* points to an error and parsing should be aborted.
*/
extern
FILE
*
scanctx_push_include
(
struct
scan_context
*
ctx
,
void
*
prev_buffer
,
const
char
*
path
,
const
char
**
error
);
extern
FILE
*
libconfig_scanctx_push_include
(
struct
scan_context
*
ctx
,
void
*
prev_buffer
,
const
char
*
path
,
const
char
**
error
);
/*
* Returns the next include file in the current include stack frame.
...
...
@@ -85,22 +88,22 @@ extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer,
* Returns NULL on failure or if there are no more files left in the current
* frame. If there was an error, sets *error.
*/
extern
FILE
*
scanctx_next_include_file
(
struct
scan_context
*
ctx
,
const
char
**
error
);
extern
FILE
*
libconfig_
scanctx_next_include_file
(
struct
scan_context
*
ctx
,
const
char
**
error
);
/*
* Pops a frame off the include stack.
*/
extern
void
*
scanctx_pop_include
(
struct
scan_context
*
ctx
);
extern
void
*
libconfig_
scanctx_pop_include
(
struct
scan_context
*
ctx
);
#define scanctx_append_string(C, S) \
strbuf_append_string(&((C)->string), (S))
#define
libconfig_
scanctx_append_string(C, S) \
libconfig_
strbuf_append_string(&((C)->string), (S))
#define scanctx_append_char(C, X) \
strbuf_append_char(&((C)->string), (X))
#define
libconfig_
scanctx_append_char(C, X) \
libconfig_
strbuf_append_char(&((C)->string), (X))
extern
char
*
scanctx_take_string
(
struct
scan_context
*
ctx
);
extern
char
*
libconfig_
scanctx_take_string
(
struct
scan_context
*
ctx
);
extern
const
char
*
scanctx_current_filename
(
struct
scan_context
*
ctx
);
extern
const
char
*
libconfig_
scanctx_current_filename
(
struct
scan_context
*
ctx
);
#endif
/* __libconfig_scanctx_h */
lib/scanner.c
View file @
8acc6201
This diff is collapsed.
Click to expand it.
lib/scanner.h
View file @
8acc6201
...
...
@@ -443,9 +443,10 @@ void yyfree ( void * , yyscan_t yyscanner );
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define COMMENT 1
#define STRING 2
#define INCLUDE 3
#define SINGLE_LINE_COMMENT 1
#define MULTI_LINE_COMMENT 2
#define STRING 3
#define INCLUDE 4
#endif
...
...
@@ -711,8 +712,8 @@ extern int yylex \
#undef yyTABLES_NAME
#endif
#line
198
"scanner.l"
#line
200
"scanner.l"
#line 71
6
"scanner.h"
#line 71
7
"scanner.h"
#undef libconfig_yyIN_HEADER
#endif
/* libconfig_yyHEADER_H */
lib/scanner.l
View file @
8acc6201
/* -*- mode: C -*- */
/* --------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -79,33 +79,33 @@ include_open ^[ \t]*@include[ \t]+\"
<MULTI_LINE_COMMENT>\n { /* ignore */ }
\" { BEGIN STRING; }
<STRING>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
<STRING>\\n { scanctx_append_char(yyextra, '\n'); }
<STRING>\\r { scanctx_append_char(yyextra, '\r'); }
<STRING>\\t { scanctx_append_char(yyextra, '\t'); }
<STRING>\\f { scanctx_append_char(yyextra, '\f'); }
<STRING>\\\\ { scanctx_append_char(yyextra, '\\'); }
<STRING>\\\" { scanctx_append_char(yyextra, '\"'); }
<STRING>[^\"\\]+ {
libconfig_
scanctx_append_string(yyextra, yytext); }
<STRING>\\n {
libconfig_
scanctx_append_char(yyextra, '\n'); }
<STRING>\\r {
libconfig_
scanctx_append_char(yyextra, '\r'); }
<STRING>\\t {
libconfig_
scanctx_append_char(yyextra, '\t'); }
<STRING>\\f {
libconfig_
scanctx_append_char(yyextra, '\f'); }
<STRING>\\\\ {
libconfig_
scanctx_append_char(yyextra, '\\'); }
<STRING>\\\" {
libconfig_
scanctx_append_char(yyextra, '\"'); }
<STRING>{hexchar} {
char c = (char)(strtol(yytext + 2, NULL, 16) & 0xFF);
scanctx_append_char(yyextra, c);
libconfig_
scanctx_append_char(yyextra, c);
}
<STRING>\\ { scanctx_append_char(yyextra, '\\'); }
<STRING>\\ {
libconfig_
scanctx_append_char(yyextra, '\\'); }
<STRING>\" {
yylval->sval = scanctx_take_string(yyextra);
yylval->sval =
libconfig_
scanctx_take_string(yyextra);
BEGIN INITIAL;
return(TOK_STRING);
}
{include_open} { BEGIN INCLUDE; }
<INCLUDE>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
<INCLUDE>\\\\ { scanctx_append_char(yyextra, '\\'); }
<INCLUDE>\\\" { scanctx_append_char(yyextra, '\"'); }
<INCLUDE>[^\"\\]+ {
libconfig_
scanctx_append_string(yyextra, yytext); }
<INCLUDE>\\\\ {
libconfig_
scanctx_append_char(yyextra, '\\'); }
<INCLUDE>\\\" {
libconfig_
scanctx_append_char(yyextra, '\"'); }
<INCLUDE>\" {
const char *error = NULL;
const char *path = scanctx_take_string(yyextra);
FILE *fp =
scanctx_push_include(yyextra, (void *)YY_CURRENT_BUFFER, path
,
&error);
const char *path =
libconfig_
scanctx_take_string(yyextra);
FILE *fp =
libconfig_scanctx_push_include(yyextra, (void *)YY_CURRENT_BUFFER
,
path,
&error);
__delete(path);
if(fp)
...
...
@@ -117,7 +117,7 @@ include_open ^[ \t]*@include[ \t]+\"
else if(error)
{
yyextra->config->error_text = error;
yyextra->config->error_file = scanctx_current_filename(yyextra);
yyextra->config->error_file =
libconfig_
scanctx_current_filename(yyextra);
yyextra->config->error_line = libconfig_yyget_lineno(yyscanner);
return TOK_ERROR;
}
...
...
@@ -169,7 +169,7 @@ include_open ^[ \t]*@include[ \t]+\"
const char *error = NULL;
FILE *fp;
fp = scanctx_next_include_file(yyextra, &error);
fp =
libconfig_
scanctx_next_include_file(yyextra, &error);
if(fp)
{
yyin = fp;
...
...
@@ -180,14 +180,14 @@ include_open ^[ \t]*@include[ \t]+\"
else if(error)
{
yyextra->config->error_text = error;
yyextra->config->error_file = scanctx_current_filename(yyextra);
yyextra->config->error_file =
libconfig_
scanctx_current_filename(yyextra);
yyextra->config->error_line = libconfig_yyget_lineno(yyscanner);
return TOK_ERROR;
}
else
{
/* No more files in the current include list. */
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(yyextra);
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)
libconfig_
scanctx_pop_include(yyextra);
if(buf)
{
yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
...
...
lib/strbuf.c
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -30,7 +30,7 @@
/* ------------------------------------------------------------------------- */
void
strbuf_ensure_capacity
(
strbuf_t
*
buf
,
size_t
len
)
void
libconfig_
strbuf_ensure_capacity
(
strbuf_t
*
buf
,
size_t
len
)
{
static
const
size_t
mask
=
~
(
STRING_BLOCK_SIZE
-
1
);
...
...
@@ -44,7 +44,7 @@ void strbuf_ensure_capacity(strbuf_t *buf, size_t len)
/* ------------------------------------------------------------------------- */
char
*
strbuf_release
(
strbuf_t
*
buf
)
char
*
libconfig_
strbuf_release
(
strbuf_t
*
buf
)
{
char
*
r
=
buf
->
string
;
__zero
(
buf
);
...
...
@@ -53,19 +53,19 @@ char *strbuf_release(strbuf_t *buf)
/* ------------------------------------------------------------------------- */
void
strbuf_append_string
(
strbuf_t
*
buf
,
const
char
*
s
)
void
libconfig_
strbuf_append_string
(
strbuf_t
*
buf
,
const
char
*
s
)
{
size_t
len
=
strlen
(
s
);
strbuf_ensure_capacity
(
buf
,
len
);
libconfig_
strbuf_ensure_capacity
(
buf
,
len
);
strcpy
(
buf
->
string
+
buf
->
length
,
s
);
buf
->
length
+=
len
;
}
/* ------------------------------------------------------------------------- */
void
strbuf_append_char
(
strbuf_t
*
buf
,
char
c
)
void
libconfig_
strbuf_append_char
(
strbuf_t
*
buf
,
char
c
)
{
strbuf_ensure_capacity
(
buf
,
1
);
libconfig_
strbuf_ensure_capacity
(
buf
,
1
);
*
(
buf
->
string
+
buf
->
length
)
=
c
;
++
(
buf
->
length
);
*
(
buf
->
string
+
buf
->
length
)
=
'\0'
;
...
...
lib/strbuf.h
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -33,10 +33,10 @@ typedef struct
size_t
capacity
;
}
strbuf_t
;
void
strbuf_append_string
(
strbuf_t
*
buf
,
const
char
*
s
);
void
libconfig_
strbuf_append_string
(
strbuf_t
*
buf
,
const
char
*
s
);
void
strbuf_append_char
(
strbuf_t
*
buf
,
char
c
);
void
libconfig_
strbuf_append_char
(
strbuf_t
*
buf
,
char
c
);
char
*
strbuf_release
(
strbuf_t
*
buf
);
char
*
libconfig_
strbuf_release
(
strbuf_t
*
buf
);
#endif
/* __libconfig_strbuf_h */
lib/strvec.c
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -29,7 +29,7 @@
/* ------------------------------------------------------------------------- */
void
strvec_append
(
strvec_t
*
vec
,
const
char
*
s
)
void
libconfig_
strvec_append
(
strvec_t
*
vec
,
const
char
*
s
)
{
if
(
vec
->
length
==
vec
->
capacity
)
{
...
...
@@ -47,7 +47,7 @@ void strvec_append(strvec_t *vec, const char *s)
/* ------------------------------------------------------------------------- */
const
char
**
strvec_release
(
strvec_t
*
vec
)
const
char
**
libconfig_
strvec_release
(
strvec_t
*
vec
)
{
const
char
**
r
=
vec
->
strings
;
if
(
r
)
...
...
lib/strvec.h
View file @
8acc6201
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-20
18
Mark A Lindner
Copyright (C) 2005-20
20
Mark A Lindner
This file is part of libconfig.
...
...
@@ -34,8 +34,8 @@ typedef struct
size_t
capacity
;
}
strvec_t
;
void
strvec_append
(
strvec_t
*
vec
,
const
char
*
s
);
void
libconfig_
strvec_append
(
strvec_t
*
vec
,
const
char
*
s
);
const
char
**
strvec_release
(
strvec_t
*
vec
);
const
char
**
libconfig_
strvec_release
(
strvec_t
*
vec
);
#endif
/* __libconfig_strvec_h */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment