bb_opt_complementaly '+'

Vladimir N. Oleynik dzo at simtreas.ru
Mon Aug 29 09:15:03 UTC 2005


Bernhard,

> What about adding the special character '+' to bb_opt_complementaly?
> 
>    "+"     A plus between two options, or between an option and a group
>            of options means that the options depend on each other. An
>            error will be forced if the options are not used together.
> 
>            For example:
>            The start-stop-daemon applet has the options "-m" and "-p".
>            Both options (makepid and pidfile) have to be given. If one
>            of the options are missing, bb_getopt_ulflags's return value
>            will have the error flag set (BB_GETOPT_ERROR).
> 
>            static char *pidfile = NULL;
>            static FILE *pidf = NULL;
>            bb_opt_complementaly = "m+p:p+m";
>            opt = bb_getopt_ulflags(argc, argv, "mp:", &pidfile);
>            if (opt & 1 && opt & 2) /* user wants _us_ to make the pidfile */
>              pidf = bb_xfopen(pidfile, "w");

Hmm.

before yet
	if ((opt & 3) != 3)

may be short size with your idea:

	bb_opt_complementaly = "m+p:p+m";
	if (opt & BB_GETOPT_ERROR)

and more add code for bb_getopt_ulflags()


--w
vodz



More information about the busybox mailing list