Open marenz2569 opened 6 years ago
I second that motion! (but @vifino still is the owner ^^)
But you already got arguments for output modules...?
-o udp:1.2.3.4:1234,16x8
out_sdl2
simply doesn't use those argstrings. It should, but it does not.
@vifino I know about the argstrings. But it would be simpler to use int init(int argc, char **argv), than parsing those argstrings in every output module.
I see. While I get your point, for me, having a rather universal way to handle arguments is more important.
You'd have to pass the remaining arguments to the output module, which isn't that helpful. It would also only make a difference if you'd plan to use spaces, which has it's whole other list of problems..
Well I tought of a conversion from argstring to argc/argv and pass this to the modules and then have a loop in the module to get the arguments from the argc/argv. This can be done easily with arg.h from 20h. Code would look like this:
#include "arg.h"
static int width = -1,
height = -1;
static void usage(void) {
eprintf("usage: -o \"sdl2:-w width -h height\"\n");
abort();
}
init init(int argc, char **argv) {
ARGBEGIN {
case 'w':
width = atoi(EARGF(usage());
break;
case 'h':
height = atoi(EARGF(usage());
break;
default:
usage();
return 2;
} ARGEND;
On error the parser will return: usage: -o "sdl2:-w width -h height"
Substituting width
and height
with integer values.
That's not too bad, but I think I still prefer something like -o sdl2:64x64
, as it's shorter and doesn't require quoting.
Arguments should be passed to output modules to get rid of the defines, i.e. in out_sdl2. When simply just -[any character] would be enough then 20h's arg.h could be used. I have some code ready to use if this adequate.