arg-parser-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Arg-parser-bug] Option to return non option char pointer in arg_par


From: Javier López
Subject: Re: [Arg-parser-bug] Option to return non option char pointer in arg_parser?
Date: Tue, 15 Dec 2015 11:40:22 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Antonio,

I should had read better, indeed using either ap_argument(&parser, 1)
or testing for 'code' and getting the ap_argument when it doesn't
match the defined short options I can get the strings who aren't
options.

Thank you.

> You can already obtain a pointer to "extra_arg" with "ap_argument(
> parser, 1 )":
> 
> ------------------------------------------------------------------------
> http://www.nongnu.org/arg-parser/manual/arg_parser_manual.html#C-version
> -- Function: const char * ap_argument ( const struct Arg_parser *
> const ap, const int i )
> 
>     This function returns the argument at position i. It may be the
> argument of an option or a non-option argument, depending on the
> value returned by ap_code(i). Valid values for i range from 0 to
> ap_arguments() - 1.
> ------------------------------------------------------------------------
> 
> See the file 'cmain.c' in the Arg_parser distribution for an example of use:
> 
>   for( argind = 0; argind < ap_arguments( &parser ); ++argind )
>     {
>     const int code = ap_code( &parser, argind );
>     const char * const arg = ap_argument( &parser, argind );
>     if( code )  /* option */
>     [...]
>     else        /* non-option */
>       printf( "non-option argument '%s'", arg );
>     printf( "\n" );
>     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]