Skip to content

Conversation

@jimklimov
Copy link
Member

@jimklimov jimklimov commented Jan 28, 2024

Follow-up to #2283 which aims to enable builds (and tests) of (lib)nutconf codebase by default (where C++11 is available, optionally CPPUNIT to test the results).

This iteration softens some rough edges for WIN32 codebase, and for (way too many) other complications it just disables parts of the originally POSIX-oriented implementation that would need to be remade for Windows (got quite a few precedents for named pipe use instead of Unix sockets and signals in other NUT programs).

Closes: #2295 along the way

By side effect (from making CI pass), this PR also fixes CI builds with standards other than C11/C++11 (requests were there... typos in scripting also...), and NUT Integration Tests (NIT) detection of available ports for upsd to listen on.

EmilienKia and others added 30 commits January 27, 2024 17:46
Just parse tokens.
Rename NutConfParser in NutParser.
Implement the abstract class NutConfParser based on NutParser for configuration file parsing.
Remove old C sample code.
Add stubs for the default configuration file parser.
Basic implementation will follow.
Add UT for GenericConfiguration (validate GenericConfigParser and all the stack).
Fix some errors found with UT.
Test pending.
A bug is pending: IPv6 format must be in quoted string because of ':'.
Add parsing option to NutParser.
Add a first option OPTION_IGNORE_COLON to parse ':' as a normal character and not as token.
Use it to allow parsing "::1" IPv6-like as string without having to quote them (upsd.conf).
nut::NutMemory (memory-based stream)
nut::NutFile (file-stream)
nut::NutSocket with nut::NutSocket::Address (UNIX domain, IPv4, IPv6)
Basic unit tests plus a few minor changes and updates to the code
General serialisers implemented
Several TBDs and TODOs left for review
tbc...
Getters/setters for all UPS config. attributes added
The getters/setters need further checking for type correctness
Generic support for the above implemented in GenericConfiguration class
The special serialiser is needed because of the [upsmon]::upsmon
directive (which doesn't use the standard = key/ value separator).
Also, serialisation of section entry value list was fixed (so that
multiple entries are produced rather than a list of values).
All existing NUT configuration classes now implement
Serialisable interface (parseFrom and writeTo methods).
Note that the parseFrom implementations are very naive
(they simply read whole source stream to memory and call
existing parseFromString method).  That's enough for now,
however, in future the parsres should directly use NutStream
interface.
UTs with focus on basic configuration settings and serialisation
were added for nut.conf, upsmon.conf, upsd.conf ups.conf and upsd.users.
Note that the tests are not exhaustive; they only parse configuration
files samples, change a few randomly selected parameters, serialise
the result back and check it.
A non-complete implementation of NUT IPC support module.
Certain functions are just outlined, for now.
Deals with signal handling and execution of external commands.
I commit this partial implementation because I'll be on holiday
for certain amount of time and it's IMO better to have the code
comitted.
@jimklimov jimklimov force-pushed the libconf-nutconf-enable-build branch from e616f15 to b833cc0 Compare February 14, 2024 10:03
…II char variants of Windows path related methods

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…nt to maybe call later

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…y default

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… both POSIX and WIN32 code

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…_dir and filename (if known) in theexception (so far WIN32 code path)

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

…ngw builds

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

… listen_sock.bind() a few times; freeze/thaw the writer PID

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…larly on WIN32

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…s writeable by WIN32 system methods (e.g. not mangled by mingw/msys)

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ch was problematic

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…T directly on Windows agents

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…nable-build

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…se of access() check

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…path concerns

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…WIN32 (absolute) path concerns

Copied from tests, but would hopefully evaporate there eventually
as that particular acute issue gets resolved.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…pe them!

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

…onfig file parsing tests

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

@jimklimov jimklimov merged commit 6abd95e into networkupstools:master Feb 15, 2024
@jimklimov jimklimov deleted the libconf-nutconf-enable-build branch February 15, 2024 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature nutconf NUT configuration library and tool portability We want NUT to build and run everywhere possible refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings Windows

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

Avoid tmpnam() in nutconf

5 participants