MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / GetCmdParam

Function GetCmdParam

Libraries/unrar/strfn.cpp:399–430  ·  view source on GitHub ↗

Parse string containing parameters separated with spaces. Support quote marks. Param can be NULL to return the pointer to next parameter, which can be used to estimate the buffer size for Param.

Source from the content-addressed store, hash-verified

397// Support quote marks. Param can be NULL to return the pointer to next
398// parameter, which can be used to estimate the buffer size for Param.
399const wchar* GetCmdParam(const wchar *CmdLine,wchar *Param,size_t MaxSize)
400{
401 while (IsSpace(*CmdLine))
402 CmdLine++;
403 if (*CmdLine==0)
404 return NULL;
405
406 size_t ParamSize=0;
407 bool Quote=false;
408 while (*CmdLine!=0 && (Quote || !IsSpace(*CmdLine)))
409 {
410 if (*CmdLine=='\"')
411 {
412 if (CmdLine[1]=='\"')
413 {
414 // Insert the quote character instead of two adjoining quote characters.
415 if (Param!=NULL && ParamSize<MaxSize-1)
416 Param[ParamSize++]='\"';
417 CmdLine++;
418 }
419 else
420 Quote=!Quote;
421 }
422 else
423 if (Param!=NULL && ParamSize<MaxSize-1)
424 Param[ParamSize++]=*CmdLine;
425 CmdLine++;
426 }
427 if (Param!=NULL)
428 Param[ParamSize]=0;
429 return CmdLine;
430}
431
432
433#ifndef RARDLL

Callers 1

AllocCmdParamFunction · 0.85

Calls 1

IsSpaceFunction · 0.85

Tested by

no test coverage detected