-
-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import libconf/nutconf features #2283
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
…w specialized versions of config class.
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.
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…od arg name Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…hods Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ns" (weak-vtables) Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…tors with clang++ to not worry about "(static) const something" variables Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…nutconf... for CI farm)
…ns in parallel testing Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov
force-pushed
the
libconf-nutconf
branch
from
January 29, 2024 01:01
9338531
to
a83873b
Compare
Superseded by #2290 which (eventually) gets this codebase buildable without warnings. It becomes too tedious to keep applying same hotfixes for a warning here and there on systems whose agents claim support for |
This was referenced Jan 29, 2024
Effectively merged via #2290 |
34 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This codebase lingered in side branches of NUT since 2013, and used in forked projects, providing a neat C++ parser of NUT configuration files as a library and a front-end CLI tool to read, write and "understand" them. It was further used in an automated installer for NUT packages on some platforms (to be ported later).
This PR brings back the initial coding effort from the
libconf
branch (cherry-picked over NUT v2.6.5 because there was a lot of noise, and modernized with a series of tag merges), as well as further clean-ups done in theFTY
branch and recently in PR #2275.Part of the aim of this PR is to integrate the feature separately from many others that evolved in the forks, with minimal intrusion into the generally used NUT codebase up till now. It should also help iterate build nuances for the many platforms now covered by NUT CI, so that these recipes succeed everywhere (cursorily looking, POSIX-like headers available on Windows can be problematic).
At this moment, while the tool would be likely usable for the config syntax of 2013 vintage, it would need further updates for evolution since NUT v2.6.5 for both common options (master/primary, USB matching, etc.) and for various new driver toggles. Probably the augeas lens file evolution would help in the next steps.
Note that this PR does not actually enable builds of the codebase by default (support of C++11, optionally CPPUNIT), but only on some select CI agents that claim the ability. A more general support (notably MinGW implementation or pruning) would be the focus of a follow-up PR.