-
Notifications
You must be signed in to change notification settings - Fork 696
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
Add early command line parsing #2543
base: develop
Are you sure you want to change the base?
Conversation
@tdesmet do you think this PR and adding the following to some compilation unit in your software would work for your use case from #755?
|
240fd94
to
19de545
Compare
Hi! This was my mistake, very sorry about it, re-opening this PR now. What happened is the following: I was switching the base branch for this repository https://github.com/wittra/contiki-ng from develop to wittra. But accidentally, I made the change on the wrong repo (this repo) and instead of switching the base branch I renamed it. And somehow github deleted develop and closed all PRs... Many apologies for this mishap 🙏; I haven't contributed in a while.. but now at least everybody got some notification from me :p |
19de545
to
9b422fb
Compare
The ordering guarantees for the priority to |
9b422fb
to
4153837
Compare
This adds code for letting each compilation unit add some command line option, independently of other modules. The parsing uses getopt_long_only, which is available on Linux, macOS, FreeBSD/NetBSD/OpenBSD, and the widely used C libraries musl, newlib and picolibc. The functionality is currently disconnected, the next commit will convert native-border-router to use the functionality and enable this code.
This enables the modular command line parsing, and converts rpl-border-router to use it. This allows rpl-border-router to exit when detecting bad parameter combinations, and report which parameter that was bad. The commit also adds some validation of the return values of atoi().
4153837
to
1bd974f
Compare
This is a different approach for the infrastructure parts of #755.
This pull request allows each compilation unit to specify their own command line options, and switches the border-router to use the new API.
The compilation units add their options before
main
is run, and parsing command line options is the first thing that happen insidemain
, so command line options can be used to configure things before processes are started.The code uses
getopt_long_only
so legacy parameters (-v0
..-v5
) still work. Thegetopt_long_only
function is widely available, but if the SDK for some platform does not provide that function, users can put in the code from newlib/picolibc or one of the BSDs and things should work.This PR is already quite a few lines so there is no conflict detection, I'm sure calling
getopt_long
with two options that have the same name will give "interesting" results.