On Saturday 02 February 2008 21:06:52 Vladimir Dronnikov wrote:
> >
> > Hi,
> > maybe check the applet_name at startup and then
> >
> > if (applet_name[0] == 'f')
> >     getopt32(.............................);
> > else
> >     getopt32(.............................);
> >
> __________________
> Sure! But I meant the following:
> unsigned opts = getopt32(argv, common_options);
> ...
> if ( <sendmail> ) opts = getopt32(argv, sendmail_specific_options);
> else opts = getopt32(argv, fetchmail_specific_options);

I suspect this will cause evil results, i think it is better to isolate
the option parsing between fetchmail and sendmail.
Maybe it is possible to use a single getopt32 call tough....
char *opt_string;

if (sendmail) {
                opt_complementary = "f:t::b::a::";
                opt_string = "f:t:n::s:b:a:c:" 
USE_FEATURE_SENDMAIL_NETWORK("dw:h:p:U:P:");
} else {
                opt_complementary = "whatever";
                opt_string = "aqwerty";
}

        opts = getopt32(argv,
                opt_string,
                &from, &recipients, &notify, &subject, &bodies, &attachments, 
&charset
                USE_FEATURE_SENDMAIL_NETWORK(, &wsecs, &server, &port, 
&opt_user, &opt_pass)
        );

but only if there are similar options that take arguments.
IMHO the best solution is to use two independent getopt32 calls.

Ciao,
Tito

> You see, if we launch, say, sendmail then the first call to getopt32
> would fail [showing bb_usage()] on any fetchmail_specific_options and
> even on sendmail_specific_options, since it is not aware of these
> specific options!
> 
> So is there a way to tell getopt32 to not fail on unknown options?
> 
> Thank you for reply
> 
> --
> Vladimir
> 


_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to