bool osDoMultiArgs(pvoid handler, int nMultiArgs, pfnDoMultiArgsCB pFunc) { osAssert(handler && pFunc); CSimpleOpt * pArgs = ((CmdOptHandle *)handler)->pArgs; TCHAR ** rgpszArg = NULL; // get the number of arguments if necessary if (nMultiArgs == -1) { // first arg is a count of how many we have rgpszArg = pArgs->MultiArg(1); if (!rgpszArg) { osPrintf( _T("%s: '%s' (use --help to get command line help)\n"), GetLastErrorText(pArgs->LastError()), pArgs->OptionText()); return false; } nMultiArgs = _ttoi(rgpszArg[0]); } // get the arguments to follow rgpszArg = pArgs->MultiArg(nMultiArgs); if (!rgpszArg) { osPrintf( _T("%s: '%s' (use --help to get command line help)\n"), GetLastErrorText(pArgs->LastError()), pArgs->OptionText()); return false; } for (int n = 0; n < nMultiArgs; ++n) { pFunc(pArgs->OptionId(), pArgs->OptionText(), n, rgpszArg[n]); } return true; }
static void DoMultiArgs( CSimpleOpt & args, int nMultiArgs ) { TCHAR ** rgpszArg = NULL; // get the number of arguments if necessary if (nMultiArgs == -1) { // first arg is a count of how many we have rgpszArg = args.MultiArg(1); if (!rgpszArg) { _tprintf( _T("%s: '%s' (use --help to get command line help)\n"), GetLastErrorText(args.LastError()), args.OptionText()); return; } nMultiArgs = _ttoi(rgpszArg[0]); } _tprintf(_T("%s: expecting %d args\n"), args.OptionText(), nMultiArgs); // get the arguments to follow rgpszArg = args.MultiArg(nMultiArgs); if (!rgpszArg) { _tprintf( _T("%s: '%s' (use --help to get command line help)\n"), GetLastErrorText(args.LastError()), args.OptionText()); return; } for (int n = 0; n < nMultiArgs; ++n) { _tprintf(_T("MultiArg %d: %s\n"), n, rgpszArg[n]); } }