void CommandLineParser::parse() { while ( hasNextArgument() ) { getNextOption(); if ( isOption( "c", "compiler" ) ) m_useCompiler = true; else if ( isOption( "x", "xml" ) ) { m_useXml = true; m_xmlFileName = getNextOptionalParameter(); } else if ( isOption( "s", "xsl" ) ) m_xsl = getNextParameter(); else if ( isOption( "e", "encoding" ) ) m_encoding = getNextParameter(); else if ( isOption( "b", "brief-progress" ) ) m_briefProgress = true; else if ( isOption( "n", "no-progress" ) ) m_noProgress = true; else if ( isOption( "t", "text" ) ) m_useText = true; else if ( isOption( "o", "cout" ) ) m_useCout = true; else if ( isOption( "w", "wait" ) ) m_waitBeforeExit = true; else if ( !m_option.empty() ) fail( "Unknown option" ); else if ( hasNextArgument() ) readNonOptionCommands(); } }
EXPORT int GetOptions( char *const *argv, optionT *table, unsigned flags, void *reserved ) { struct global data; int i=0; int fail=0; if( do_sanity(&data,argv,table,flags,reserved) <0 ) { report(flags,_("invalid arguments") ); return -1; } while( !fail && (i=getNextOption(&data)) >= 0 ) { if( process(table+i,data.arg) <0 ) { report(data.flags,_("format error in `%s'"), data.arg); fail=1; } } /*free_argv((char **)data.argv);*/ return (fail || i != RET_END) ? -1:data.i; }