f3 icon indicating copy to clipboard operation
f3 copied to clipboard

Portable argument parsing

Open MartinHusemann opened this issue 4 years ago • 9 comments

Would a pull request that replaces the glibc specific argp functions with plain posix functions be accepted?

Alternatively, a pull request that #ifdefs them and provides alternatives for systems not implementing them (so Linux would use argp, but others getopt/strtol and what have you)?

The former would be a lot cleaner and not obfuscate the code as much.

MartinHusemann avatar Feb 03 '20 15:02 MartinHusemann

Which systems are you concerned about? Is argp the only issue to port F3 to these systems?

If we decide to go down this route, would there be any change in the way the parameters are used?

AltraMayor avatar Feb 03 '20 18:02 AltraMayor

I am using NetBSD and did not do a full port yet as I was trying to find out whats the minimal change and argp kills compilation right away. NetBSD should be close enough to FreeBSD and libusb is supported, so I don't expect many other obstacles.

Completly replacing argp basically means moving the code inside the parse_opt() callback into the caller of argp_parse(), which is replaced by a loop around getopt(3) or getopt_long(3).

MartinHusemann avatar Feb 03 '20 18:02 MartinHusemann

Are you trying to port only f3write and f3read? Or are you planning to port the other tools (e.g. f3probe)? I'm asking because f3write and f3read do not use libusb. The other tools are more demanding to port.

AltraMayor avatar Feb 03 '20 19:02 AltraMayor

Yeah, I'm aware the former two are easy and the others harder - was going to see how far I get, but definitively want to try f3probe too.

MartinHusemann avatar Feb 03 '20 20:02 MartinHusemann

If you want, we can try a pull request to patch only f3write and f3read. Thus, we leave the other tools for when you have a chance to get them working. This should also simplify the review of this first pull request. If you are going to write this pull request, please remember to update the documentation as needed.

AltraMayor avatar Feb 03 '20 20:02 AltraMayor

I'm also interested in this. On FreeBSD f3probe is not installed, but f3write and f3read are. It looks like f3probe uses linux/fs.h which is why.

ghost avatar Apr 07 '20 20:04 ghost