On Saturday 02 February 2008 21:53:12 Vladimir Dronnikov wrote:
> I see. In fact all the options which depend on *_NETWORK are shared...

In this case maybe it is possible to use one call if you invert the order of 
options

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


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

I presume it will not be a problem if there are more &xxx args than "xyz" 
options as they will be unused.
Can't say if it is worth the effort tough. :-)

Ciao,
Tito


> So let it be 2 calls.
> 
> Thanx for discussion.
> 
> --
> Vladimir
> 
> 2008/2/2, Tito <[EMAIL PROTECTED]>:
> > 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