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
c3dc9043
Commit
c3dc9043
authored
Nov 15, 2017
by
Mark Lindner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new 'fsync' option.
parent
a6797196
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
131 additions
and
11 deletions
+131
-11
ChangeLog
ChangeLog
+7
-0
configure.ac
configure.ac
+1
-1
doc/libconfig.texi
doc/libconfig.texi
+13
-2
examples/c++/example2.cpp
examples/c++/example2.cpp
+5
-0
examples/c/example2.c
examples/c/example2.c
+5
-2
lib/Makefile.am
lib/Makefile.am
+3
-3
lib/libconfig++.vcproj
lib/libconfig++.vcproj
+4
-0
lib/libconfig++.vcxproj
lib/libconfig++.vcxproj
+2
-1
lib/libconfig.c
lib/libconfig.c
+17
-0
lib/libconfig.h
lib/libconfig.h
+1
-0
lib/libconfig.h++
lib/libconfig.h++
+2
-1
lib/libconfig.vcproj
lib/libconfig.vcproj
+4
-0
lib/libconfig.vcxproj
lib/libconfig.vcxproj
+2
-1
lib/wincompat.c
lib/wincompat.c
+61
-0
lib/wincompat.h
lib/wincompat.h
+4
-0
No files found.
ChangeLog
View file @
c3dc9043
2017-11-15 Mark Lindner <markl@avalon>
* lib/wincompat.c, lib/wincompat.h - added fsync() implementation for Windows
* lib/libconfig.c, lib/libconfig.h - added CONFIG_OPTION_FSYNC
* lib/libconfigcpp.c++, lib/libconfig.h++ - added Config::OptionFsync
* doc/libconfig.texi - Documentation updates
----- version 1.7 ------
2017-10-24 Mark Lindner <markl@avalon>
...
...
configure.ac
View file @
c3dc9043
dnl Process this file with autoconf to produce a configure script.
AC_INIT(libconfig, 1.7, hyperrealm@gmail.com, libconfig,
AC_INIT(libconfig, 1.7
.1
, hyperrealm@gmail.com, libconfig,
[https://hyperrealm.github.io/libconfig/])
AC_CONFIG_AUX_DIR([aux-build])
AC_CONFIG_MACRO_DIR([m4])
...
...
doc/libconfig.texi
View file @
c3dc9043
...
...
@@ -6,8 +6,8 @@
@setfilename libconfig.info
@settitle libconfig
@set edition 1.7
@set update-date
31 Oct
2017
@set edition 1.7
.1
@set update-date
?? Nov
2017
@set subtitle-text A Library For Processing Structured Configuration Files
@set author-text Mark A.@: Lindner
...
...
@@ -945,6 +945,11 @@ when writing floating point values (corresponding to @code{printf()}
@samp
{
%g} format) or should never be used (corresponding to @code{printf()}
@samp
{
%f} format). By default this option is turned off.
@item CONFIG
_
OPTION
_
FSYNC
(@b
{
Since @i
{
v1.7.1
}}
)
This option controls whether the @code
{
config
_
write
_
file()
}
function performs
an @i
{
fsync
}
operation after writing the configuration and before closing the
file. By default this option is turned off.
@end table
@end deftypefun
...
...
@@ -1580,6 +1585,12 @@ when writing floating point values (corresponding to @code{printf()}
@samp
{
%g} format) or should never be used (corresponding to @code{printf()}
@samp
{
%f} format). By default this option is turned off.
@item Config::OptionFsync
(@b
{
Since @i
{
v1.7.1
}}
)
This option controls whether the @code
{
writeFile()
}
method performs an @i
{
fsync
}
operation after writing the configuration and before closing the file. By
default this option is turned off.
@end table
@end deftypemethod
...
...
examples/c++/example2.cpp
View file @
c3dc9043
...
...
@@ -38,6 +38,11 @@ int main(int argc, char **argv)
Config
cfg
;
cfg
.
setOptions
(
Config
::
OptionFsync
|
Config
::
OptionSemicolonSeparators
|
Config
::
OptionColonAssignmentForGroups
|
Config
::
OptionOpenBraceOnSeparateLine
);
// Read the file. If there is an error, report it and exit.
try
{
...
...
examples/c/example2.c
View file @
c3dc9043
...
...
@@ -36,6 +36,11 @@ int main(int argc, char **argv)
config_setting_t
*
root
,
*
setting
,
*
movie
;
config_init
(
&
cfg
);
config_set_options
(
&
cfg
,
(
CONFIG_OPTION_FSYNC
|
CONFIG_OPTION_SEMICOLON_SEPARATORS
|
CONFIG_OPTION_COLON_ASSIGNMENT_FOR_GROUPS
|
CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE
));
/* Read the file. If there is an error, report it and exit. */
if
(
!
config_read_file
(
&
cfg
,
"example.cfg"
))
...
...
@@ -74,8 +79,6 @@ int main(int argc, char **argv)
setting
=
config_setting_add
(
movie
,
"qty"
,
CONFIG_TYPE_INT
);
config_setting_set_float
(
setting
,
20
);
config_set_options
(
&
cfg
,
0
);
/* Write out the updated configuration. */
if
(
!
config_write_file
(
&
cfg
,
output_file
))
{
...
...
lib/Makefile.am
View file @
c3dc9043
...
...
@@ -18,7 +18,7 @@
#
# For more info see section 6.3 of the GNU Libtool Manual.
VERINFO
=
-version-info
11:
0
:0
VERINFO
=
-version-info
11:
1
:0
## Flex
PARSER_PREFIX
=
libconfig_yy
...
...
@@ -28,8 +28,8 @@ AM_LFLAGS = --header-file=scanner.h --prefix=$(PARSER_PREFIX)
AM_YFLAGS
=
-d
-p
$(PARSER_PREFIX)
libsrc
=
libconfig.c scanner.l grammar.y parsectx.h wincompat.h
\
scanctx.c scanctx.h strbuf.c strbuf.h strvec.c strvec.h util.c util
.h
libsrc
=
grammar.y libconfig.c parsectx.h scanctx.c scanctx.h scanner.l
\
strbuf.c strbuf.h strvec.c strvec.h util.c util.h wincompat.c wincompat
.h
libinc
=
libconfig.h
libsrc_cpp
=
$(libsrc)
libconfigcpp.c++
...
...
lib/libconfig++.vcproj
View file @
c3dc9043
...
...
@@ -198,6 +198,10 @@
RelativePath=
".\util.c"
>
</File>
<File
RelativePath=
".\wincompat.c"
>
</File>
</Filter>
<Filter
Name=
"Header Files"
...
...
lib/libconfig++.vcxproj
View file @
c3dc9043
...
...
@@ -92,6 +92,7 @@
<ClCompile
Include=
"strbuf.c"
/>
<ClCompile
Include=
"strvec.c"
/>
<ClCompile
Include=
"util.c"
/>
<ClCompile
Include=
"wincompat.c"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\ac_config.h"
/>
...
...
@@ -112,4 +113,4 @@
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
lib/libconfig.c
View file @
c3dc9043
...
...
@@ -691,6 +691,23 @@ int config_write_file(config_t *config, const char *filename)
}
config_write
(
config
,
stream
);
if
(
config_get_option
(
config
,
CONFIG_OPTION_FSYNC
))
{
int
fd
=
fileno
(
stream
);
if
(
fd
>=
0
)
{
if
(
fsync
(
fd
)
!=
0
)
{
fclose
(
stream
);
config
->
error_text
=
__io_error
;
config
->
error_type
=
CONFIG_ERR_FILE_IO
;
return
(
CONFIG_FALSE
);
}
}
}
fclose
(
stream
);
config
->
error_type
=
CONFIG_ERR_NONE
;
return
(
CONFIG_TRUE
);
...
...
lib/libconfig.h
View file @
c3dc9043
...
...
@@ -64,6 +64,7 @@ extern "C" {
#define CONFIG_OPTION_COLON_ASSIGNMENT_FOR_NON_GROUPS 0x08
#define CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE 0x10
#define CONFIG_OPTION_ALLOW_SCIENTIFIC_NOTATION 0x20
#define CONFIG_OPTION_FSYNC 0x40
#define CONFIG_TRUE (1)
#define CONFIG_FALSE (0)
...
...
lib/libconfig.h++
View file @
c3dc9043
...
...
@@ -448,7 +448,8 @@ class LIBCONFIGXX_API Config
OptionColonAssignmentForGroups
=
0x04
,
OptionColonAssignmentForNonGroups
=
0x08
,
OptionOpenBraceOnSeparateLine
=
0x10
,
OptionAllowScientificNotation
=
0x20
OptionAllowScientificNotation
=
0x20
,
OptionFsync
=
0x40
};
Config
();
...
...
lib/libconfig.vcproj
View file @
c3dc9043
...
...
@@ -185,6 +185,10 @@
RelativePath=
".\util.c"
>
</File>
<File
RelativePath=
".\wincompat.c"
>
</File>
</Filter>
<Filter
Name=
"Header Files"
...
...
lib/libconfig.vcxproj
View file @
c3dc9043
...
...
@@ -81,6 +81,7 @@
<ClCompile
Include=
"strbuf.c"
/>
<ClCompile
Include=
"strvec.c"
/>
<ClCompile
Include=
"util.c"
/>
<ClCompile
Include=
"wincompat.c"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\ac_config.h"
/>
...
...
@@ -99,4 +100,4 @@
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
lib/wincompat.c
0 → 100644
View file @
c3dc9043
/* ----------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
Copyright (C) 2005-2018 Mark A Lindner
This file is part of libconfig.
This 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 2.1 of
the License, or (at your option) any later version.
This 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 Library General Public
License along with this library; if not, see
<http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
*/
#include "wincompat.h"
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
#include <errno.h>
#include <io.h>
int
fsync
(
int
fd
)
{
HANDLE
h
=
(
HANDLE
)
_get_osfhandle
(
fd
);
if
(
h
==
INVALID_HANDLE_VALUE
)
{
errno
=
EBADF
;
return
(
-
1
);
}
if
(
!
FlushFileBuffers
(
h
))
{
DWORD
err
=
GetLastError
();
switch
(
err
)
{
case
ERROR_ACCESS_DENIED
:
return
(
0
);
case
ERROR_INVALID_HANDLE
:
errno
=
EINVAL
;
break
;
default:
errno
=
EIO
;
}
return
(
-
1
);
}
return
(
0
);
}
#endif // WIN32 || WIN64
lib/wincompat.h
View file @
c3dc9043
...
...
@@ -101,6 +101,8 @@
#define IS_RELATIVE_PATH(P) \
(PathIsRelativeA(P))
extern
int
fsync
(
int
fd
);
#else
/* defined(WIN32/WIN64) && ! defined(__MINGW32__) */
#define INT64_CONST(I) (I ## LL)
...
...
@@ -109,6 +111,8 @@
#define IS_RELATIVE_PATH(P) \
((P)[0] != '/')
#include <unistd.h>
/* for fsync() */
#endif
/* defined(WIN32/WIN64) && ! defined(__MINGW32__) */
#endif
/* __wincompat_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