void CommandData::PreprocessCommandLine(int argc, char *argv[]) { #ifdef CUSTOM_CMDLINE_PARSER // In Windows we may prefer to implement our own command line parser // to avoid replacing \" by " in standard parser. Such replacing corrupts // destination paths like "dest path\" in extraction commands. const wchar *CmdLine=GetCommandLine(); wchar *ParW; char *ParA; for (bool FirstParam=true;;FirstParam=false) { if ((CmdLine=AllocCmdParam(CmdLine,&ParW,&ParA))==NULL) break; bool Code=FirstParam ? true:PreprocessSwitch(ParA); free(ParW); free(ParA); if (!Code) break; } #else for (int I=1;I<argc;I++) if (!PreprocessSwitch(argv[I])) break; #endif }
void CommandData::ParseCommandLine(int argc, char *argv[]) { #ifdef CUSTOM_CMDLINE_PARSER // In Windows we may prefer to implement our own command line parser // to avoid replacing \" by " in standard parser. Such replacing corrupts // destination paths like "dest path\" in extraction commands. const wchar *CmdLine=GetCommandLine(); wchar *ParW; char *ParA; for (bool FirstParam=true;;FirstParam=false) { if ((CmdLine=AllocCmdParam(CmdLine,&ParW,&ParA))==NULL) break; if (!FirstParam) // First parameter is the executable name. ParseArg(ParA,ParW); free(ParW); free(ParA); } #else for (int I=1;I<argc;I++) ParseArg(argv[I],NULL); #endif ParseDone(); }
void CommandData::ProcessSwitchesString(const wchar *Str) { wchar *Par; while ((Str=AllocCmdParam(Str,&Par))!=NULL) { if (IsSwitch(*Par)) ProcessSwitch(Par+1); free(Par); } }
void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[]) { *Command=0; NoMoreSwitches=false; #ifdef CUSTOM_CMDLINE_PARSER // In Windows we may prefer to implement our own command line parser // to avoid replacing \" by " in standard parser. Such replacing corrupts // destination paths like "dest path\" in extraction commands. // Also our own parser is Unicode compatible. const wchar *CmdLine=GetCommandLine(); wchar *Par; for (bool FirstParam=true;;FirstParam=false) { if ((CmdLine=AllocCmdParam(CmdLine,&Par))==NULL) break; if (!FirstParam) // First parameter is the executable name. if (Preprocess) PreprocessArg(Par); else ParseArg(Par); free(Par); } #else Array<wchar> Arg; for (int I=1;I<argc;I++) { Arg.Alloc(strlen(argv[I])+1); CharToWide(argv[I],&Arg[0],Arg.Size()); if (Preprocess) PreprocessArg(&Arg[0]); else ParseArg(&Arg[0]); } #endif if (!Preprocess) ParseDone(); }