unrarsrc  6.1.7
About: unrar extracts, views and tests the contents of archives created with the RAR archiver.
  Fossies Dox: unrarsrc-6.1.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cmddata.cpp
Go to the documentation of this file.
1#include "rar.hpp"
2
3#include "cmdfilter.cpp"
4#include "cmdmix.cpp"
5
7{
8 Init();
9}
10
11
13{
15
16 *Command=0;
17 *ArcName=0;
18 FileLists=false;
19 NoMoreSwitches=false;
20
22
23 BareOutput=false;
24
25
32}
33
34
35// Return the pointer to next position in the string and store dynamically
36// allocated command line parameter in Par.
37static const wchar *AllocCmdParam(const wchar *CmdLine,wchar **Par)
38{
39 const wchar *NextCmd=GetCmdParam(CmdLine,NULL,0);
40 if (NextCmd==NULL)
41 return NULL;
42 size_t ParSize=NextCmd-CmdLine+2; // Parameter size including the trailing zero.
43 *Par=(wchar *)malloc(ParSize*sizeof(wchar));
44 if (*Par==NULL)
45 return NULL;
46 return GetCmdParam(CmdLine,*Par,ParSize);
47}
48
49
50#if !defined(SFX_MODULE)
51void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
52{
53 *Command=0;
54 NoMoreSwitches=false;
55#ifdef CUSTOM_CMDLINE_PARSER
56 // In Windows we may prefer to implement our own command line parser
57 // to avoid replacing \" by " in standard parser. Such replacing corrupts
58 // destination paths like "dest path\" in extraction commands.
59 const wchar *CmdLine=GetCommandLine();
60
61 wchar *Par;
62 for (bool FirstParam=true;;FirstParam=false)
63 {
64 if ((CmdLine=AllocCmdParam(CmdLine,&Par))==NULL)
65 break;
66 if (!FirstParam) // First parameter is the executable name.
67 if (Preprocess)
68 PreprocessArg(Par);
69 else
70 ParseArg(Par);
71 free(Par);
72 }
73#else
74 Array<wchar> Arg;
75 for (int I=1;I<argc;I++)
76 {
77 Arg.Alloc(strlen(argv[I])+1);
78 CharToWide(argv[I],&Arg[0],Arg.Size());
79 if (Preprocess)
80 PreprocessArg(&Arg[0]);
81 else
82 ParseArg(&Arg[0]);
83 }
84#endif
85 if (!Preprocess)
86 ParseDone();
87}
88#endif
89
90
91#if !defined(SFX_MODULE)
93{
94 if (IsSwitch(*Arg) && !NoMoreSwitches)
95 if (Arg[1]=='-' && Arg[2]==0)
96 NoMoreSwitches=true;
97 else
98 ProcessSwitch(Arg+1);
99 else
100 if (*Command==0)
101 {
103
104
106 // 'I' and 'S' commands can contain case sensitive strings after
107 // the first character, so we must not modify their case.
108 // 'S' can contain SFX name, which case is important in Unix.
109 if (*Command!='I' && *Command!='S')
111 if (*Command=='P') // Enforce -idq for print command.
112 {
115 }
116 }
117 else
118 if (*ArcName==0)
120 else
121 {
122 // Check if last character is the path separator.
123 size_t Length=wcslen(Arg);
124 wchar EndChar=Length==0 ? 0:Arg[Length-1];
125 bool EndSeparator=IsDriveDiv(EndChar) || IsPathDiv(EndChar);
126
127 wchar CmdChar=toupperw(*Command);
128 bool Add=wcschr(L"AFUM",CmdChar)!=NULL;
129 bool Extract=CmdChar=='X' || CmdChar=='E';
130 bool Repair=CmdChar=='R' && Command[1]==0;
131 if (EndSeparator && !Add)
133 else
134 if ((Add || CmdChar=='T') && (*Arg!='@' || ListMode==RCLM_REJECT_LISTS))
135 FileArgs.AddString(Arg);
136 else
137 {
138 FindData FileData;
139 bool Found=FindFile::FastFind(Arg,&FileData);
140 if ((!Found || ListMode==RCLM_ACCEPT_LISTS) &&
141 ListMode!=RCLM_REJECT_LISTS && *Arg=='@' && !IsWildcard(Arg+1))
142 {
143 FileLists=true;
144
145 ReadTextFile(Arg+1,&FileArgs,false,true,FilelistCharset,true,true,true);
146
147 }
148 else // We use 'destpath\' when extracting and reparing.
149 if (Found && FileData.IsDir && (Extract || Repair) && *ExtrPath==0)
150 {
153 }
154 else
155 FileArgs.AddString(Arg);
156 }
157 }
158}
159#endif
160
161
163{
164 if (FileArgs.ItemsCount()==0 && !FileLists)
165 FileArgs.AddString(MASKALL);
166 wchar CmdChar=toupperw(Command[0]);
167 bool Extract=CmdChar=='X' || CmdChar=='E' || CmdChar=='P';
168 if (Test && Extract)
169 Test=false; // Switch '-t' is senseless for 'X', 'E', 'P' commands.
170
171 // Suppress the copyright message and final end of line for 'lb' and 'vb'.
172 if ((CmdChar=='L' || CmdChar=='V') && Command[1]=='B')
173 BareOutput=true;
174}
175
176
177#if !defined(SFX_MODULE)
179{
180 char *EnvStr=getenv("RAR");
181 if (EnvStr!=NULL)
182 {
183 Array<wchar> EnvStrW(strlen(EnvStr)+1);
184 CharToWide(EnvStr,&EnvStrW[0],EnvStrW.Size());
185 ProcessSwitchesString(&EnvStrW[0]);
186 }
187}
188#endif
189
190
191
192#if !defined(SFX_MODULE)
193// Preprocess those parameters, which must be processed before the rest of
194// command line. Return 'false' to stop further processing.
196{
197 if (IsSwitch(Arg[0]) && !NoMoreSwitches)
198 {
199 Arg++;
200 if (Arg[0]=='-' && Arg[1]==0) // Switch "--".
201 NoMoreSwitches=true;
202 if (wcsicomp(Arg,L"cfg-")==0)
203 ConfigDisabled=true;
204 if (wcsnicomp(Arg,L"ilog",4)==0)
205 {
206 // Ensure that correct log file name is already set
207 // if we need to report an error when processing the command line.
208 ProcessSwitch(Arg);
210 }
211 if (wcsnicomp(Arg,L"sc",2)==0)
212 {
213 // Process -sc before reading any file lists.
214 ProcessSwitch(Arg);
215 if (*LogName!=0)
217 }
218 }
219 else
220 if (*Command==0)
221 wcsncpy(Command,Arg,ASIZE(Command)); // Need for rar.ini.
222}
223#endif
224
225
226#if !defined(SFX_MODULE)
228{
229 StringList List;
230 if (ReadTextFile(DefConfigName,&List,true))
231 {
232 wchar *Str;
233 while ((Str=List.GetString())!=NULL)
234 {
235 while (IsSpace(*Str))
236 Str++;
237 if (wcsnicomp(Str,L"switches=",9)==0)
239 if (*Command!=0)
240 {
241 wchar Cmd[16];
242 wcsncpyz(Cmd,Command,ASIZE(Cmd));
243 wchar C0=toupperw(Cmd[0]);
244 wchar C1=toupperw(Cmd[1]);
245 if (C0=='I' || C0=='L' || C0=='M' || C0=='S' || C0=='V')
246 Cmd[1]=0;
247 if (C0=='R' && (C1=='R' || C1=='V'))
248 Cmd[2]=0;
249 wchar SwName[16+ASIZE(Cmd)];
250 swprintf(SwName,ASIZE(SwName),L"switches_%ls=",Cmd);
251 size_t Length=wcslen(SwName);
252 if (wcsnicomp(Str,SwName,Length)==0)
253 ProcessSwitchesString(Str+Length);
254 }
255 }
256 }
257}
258#endif
259
260
261#if !defined(SFX_MODULE)
263{
264 wchar *Par;
265 while ((Str=AllocCmdParam(Str,&Par))!=NULL)
266 {
267 if (IsSwitch(*Par))
268 ProcessSwitch(Par+1);
269 free(Par);
270 }
271}
272#endif
273
274
275#if !defined(SFX_MODULE)
277{
278
279 switch(toupperw(Switch[0]))
280 {
281 case '@':
283 break;
284 case 'A':
285 switch(toupperw(Switch[1]))
286 {
287 case 'C':
288 ClearArc=true;
289 break;
290 case 'D':
291 if (Switch[2]==0)
293 else
294 if (Switch[2]=='1')
296 else
297 if (Switch[2]=='2')
299 break;
300#ifndef SFX_MODULE
301 case 'G':
302 if (Switch[2]=='-' && Switch[3]==0)
304 else
305 if (toupperw(Switch[2])=='F')
307 else
308 {
309 GenerateArcName=true;
311 }
312 break;
313#endif
314 case 'I':
316 break;
317 case 'N': // Reserved for archive name.
318 break;
319 case 'O':
320 AddArcOnly=true;
321 break;
322 case 'P':
323 wcsncpyz(ArcPath,Switch+2,ASIZE(ArcPath));
324 break;
325 case 'S':
326 SyncFiles=true;
327 break;
328 default:
329 BadSwitch(Switch);
330 break;
331 }
332 break;
333 case 'C':
334 if (Switch[2]==0)
335 switch(toupperw(Switch[1]))
336 {
337 case '-':
338 DisableComment=true;
339 break;
340 case 'U':
342 break;
343 case 'L':
345 break;
346 }
347 break;
348 case 'D':
349 if (Switch[2]==0)
350 switch(toupperw(Switch[1]))
351 {
352 case 'S':
353 DisableSortSolid=true;
354 break;
355 case 'H':
356 OpenShared=true;
357 break;
358 case 'F':
359 DeleteFiles=true;
360 break;
361 }
362 break;
363 case 'E':
364 switch(toupperw(Switch[1]))
365 {
366 case 'P':
367 switch(Switch[2])
368 {
369 case 0:
371 break;
372 case '1':
374 break;
375 case '2':
377 break;
378 case '3':
380 break;
381 case '4':
383 break;
384 }
385 break;
386 default:
387 if (Switch[1]=='+')
388 {
390 InclAttrSet=true;
391 }
392 else
394 break;
395 }
396 break;
397 case 'F':
398 if (Switch[1]==0)
399 FreshFiles=true;
400 else
401 BadSwitch(Switch);
402 break;
403 case 'H':
404 switch (toupperw(Switch[1]))
405 {
406 case 'P':
407 EncryptHeaders=true;
408 if (Switch[2]!=0)
409 {
410 if (wcslen(Switch+2)>=MAXPASSWORD)
412 Password.Set(Switch+2);
413 cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
414 }
415 else
416 if (!Password.IsSet())
417 {
419 eprintf(L"\n");
420 }
421 break;
422 default :
423 BadSwitch(Switch);
424 break;
425 }
426 break;
427 case 'I':
428 if (wcsnicomp(Switch+1,L"LOG",3)==0)
429 {
430 wcsncpyz(LogName,Switch[4]!=0 ? Switch+4:DefLogName,ASIZE(LogName));
431 break;
432 }
433 if (wcsnicomp(Switch+1,L"SND",3)==0)
434 {
435 Sound=Switch[4]=='-' ? SOUND_NOTIFY_OFF : SOUND_NOTIFY_ON;
436 break;
437 }
438 if (wcsicomp(Switch+1,L"ERR")==0)
439 {
441 // Set it immediately when parsing the command line, so it also
442 // affects messages issued while parsing the command line.
444 break;
445 }
446 if (wcsnicomp(Switch+1,L"EML",3)==0)
447 {
448 wcsncpyz(EmailTo,Switch[4]!=0 ? Switch+4:L"@",ASIZE(EmailTo));
449 break;
450 }
451 if (wcsicomp(Switch+1,L"M")==0) // For compatibility with pre-WinRAR 6.0 -im syntax. Replaced with -idv.
452 {
453 VerboseOutput=true;
454 break;
455 }
456 if (wcsicomp(Switch+1,L"NUL")==0)
457 {
460 break;
461 }
462 if (toupperw(Switch[1])=='D')
463 {
464 for (uint I=2;Switch[I]!=0;I++)
465 switch(toupperw(Switch[I]))
466 {
467 case 'Q':
470 break;
471 case 'C':
472 DisableCopyright=true;
473 break;
474 case 'D':
475 DisableDone=true;
476 break;
477 case 'P':
479 break;
480 case 'N':
481 DisableNames=true;
482 break;
483 case 'V':
484 VerboseOutput=true;
485 break;
486 }
487 break;
488 }
489 if (wcsnicomp(Switch+1,L"OFF",3)==0)
490 {
491 switch(Switch[4])
492 {
493 case 0:
494 case '1':
496 break;
497 case '2':
499 break;
500 case '3':
502 break;
503 case '4':
505 break;
506 }
507 break;
508 }
509 if (wcsicomp(Switch+1,L"VER")==0)
510 {
511 PrintVersion=true;
512 break;
513 }
514 break;
515 case 'K':
516 switch(toupperw(Switch[1]))
517 {
518 case 'B':
519 KeepBroken=true;
520 break;
521 case 0:
522 Lock=true;
523 break;
524 }
525 break;
526 case 'M':
527 switch(toupperw(Switch[1]))
528 {
529 case 'C':
530 {
531 const wchar *Str=Switch+2;
532 if (*Str=='-')
533 for (uint I=0;I<ASIZE(FilterModes);I++)
535 else
536 while (*Str!=0)
537 {
538 int Param1=0,Param2=0;
541 if (IsDigit(*Str))
542 {
543 Param1=atoiw(Str);
544 while (IsDigit(*Str))
545 Str++;
546 }
547 if (*Str==':' && IsDigit(Str[1]))
548 {
549 Param2=atoiw(++Str);
550 while (IsDigit(*Str))
551 Str++;
552 }
553 switch(toupperw(*(Str++)))
554 {
555 case 'T': Type=FILTER_PPM; break;
556 case 'E': Type=FILTER_E8; break;
557 case 'D': Type=FILTER_DELTA; break;
558 case 'A': Type=FILTER_AUDIO; break;
559 case 'C': Type=FILTER_RGB; break;
560 case 'R': Type=FILTER_ARM; break;
561 }
562 if (*Str=='+' || *Str=='-')
563 State=*(Str++)=='+' ? FILTER_FORCE:FILTER_DISABLE;
564 FilterModes[Type].State=State;
565 FilterModes[Type].Param1=Param1;
566 FilterModes[Type].Param2=Param2;
567 }
568 }
569 break;
570 case 'M':
571 break;
572 case 'D':
573 break;
574 case 'E':
575 if (toupperw(Switch[2])=='S' && Switch[3]==0)
576 SkipEncrypted=true;
577 break;
578 case 'S':
579 {
580 wchar StoreNames[1024];
581 wcsncpyz(StoreNames,(Switch[2]==0 ? DefaultStoreList:Switch+2),ASIZE(StoreNames));
582 wchar *Names=StoreNames;
583 while (*Names!=0)
584 {
585 wchar *End=wcschr(Names,';');
586 if (End!=NULL)
587 *End=0;
588 if (*Names=='.')
589 Names++;
590 wchar Mask[NM];
591 if (wcspbrk(Names,L"*?.")==NULL)
592 swprintf(Mask,ASIZE(Mask),L"*.%ls",Names);
593 else
594 wcsncpyz(Mask,Names,ASIZE(Mask));
595 StoreArgs.AddString(Mask);
596 if (End==NULL)
597 break;
598 Names=End+1;
599 }
600 }
601 break;
602#ifdef RAR_SMP
603 case 'T':
604 Threads=atoiw(Switch+2);
606 BadSwitch(Switch);
607 else
608 {
609 }
610 break;
611#endif
612 default:
613 Method=Switch[1]-'0';
614 if (Method>5 || Method<0)
615 BadSwitch(Switch);
616 break;
617 }
618 break;
619 case 'N':
620 case 'X':
621 if (Switch[1]!=0)
622 {
623 StringList *Args=toupperw(Switch[0])=='N' ? &InclArgs:&ExclArgs;
624 if (Switch[1]=='@' && !IsWildcard(Switch))
625 ReadTextFile(Switch+2,Args,false,true,FilelistCharset,true,true,true);
626 else
627 Args->AddString(Switch+1);
628 }
629 break;
630 case 'O':
631 switch(toupperw(Switch[1]))
632 {
633 case '+':
635 break;
636 case '-':
638 break;
639 case 0:
641 break;
642#ifdef _WIN_ALL
643 case 'C':
645 break;
646#endif
647 case 'H':
648 SaveHardLinks=true;
649 break;
650
651
652#ifdef SAVE_LINKS
653 case 'L':
654 SaveSymLinks=true;
655 if (toupperw(Switch[2])=='A')
656 AbsoluteLinks=true;
657 break;
658#endif
659#ifdef _WIN_ALL
660 case 'N':
661 if (toupperw(Switch[2])=='I')
662 AllowIncompatNames=true;
663 break;
664#endif
665 case 'P':
666 wcsncpyz(ExtrPath,Switch+2,ASIZE(ExtrPath));
668 break;
669 case 'R':
671 break;
672#ifdef _WIN_ALL
673 case 'S':
674 SaveStreams=true;
675 break;
676#endif
677 case 'W':
678 ProcessOwners=true;
679 break;
680 default :
681 BadSwitch(Switch);
682 break;
683 }
684 break;
685 case 'P':
686 if (Switch[1]==0)
687 {
689 eprintf(L"\n");
690 }
691 else
692 {
693 if (wcslen(Switch+1)>=MAXPASSWORD)
695 Password.Set(Switch+1);
696 cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
697 }
698 break;
699#ifndef SFX_MODULE
700 case 'Q':
701 if (toupperw(Switch[1])=='O')
702 switch(toupperw(Switch[2]))
703 {
704 case 0:
705 QOpenMode=QOPEN_AUTO;
706 break;
707 case '-':
708 QOpenMode=QOPEN_NONE;
709 break;
710 case '+':
711 QOpenMode=QOPEN_ALWAYS;
712 break;
713 default:
714 BadSwitch(Switch);
715 break;
716 }
717 else
718 BadSwitch(Switch);
719 break;
720#endif
721 case 'R':
722 switch(toupperw(Switch[1]))
723 {
724 case 0:
726 break;
727 case '-':
729 break;
730 case '0':
732 break;
733 case 'I':
734 {
735 Priority=atoiw(Switch+2);
736 if (Priority<0 || Priority>15)
737 BadSwitch(Switch);
738 const wchar *ChPtr=wcschr(Switch+2,':');
739 if (ChPtr!=NULL)
740 {
741 SleepTime=atoiw(ChPtr+1);
742 if (SleepTime>1000)
743 BadSwitch(Switch);
745 }
747 }
748 break;
749 }
750 break;
751 case 'S':
752 if (IsDigit(Switch[1]))
753 {
755 SolidCount=atoiw(&Switch[1]);
756 }
757 else
758 switch(toupperw(Switch[1]))
759 {
760 case 0:
762 break;
763 case '-':
765 break;
766 case 'E':
768 break;
769 case 'V':
771 break;
772 case 'D':
774 break;
775 case 'I':
777 wcsncpyz(UseStdin,Switch[2] ? Switch+2:L"stdin",ASIZE(UseStdin));
778 break;
779 case 'L':
780 if (IsDigit(Switch[2]))
781 FileSizeLess=atoilw(Switch+2);
782 break;
783 case 'M':
784 if (IsDigit(Switch[2]))
785 FileSizeMore=atoilw(Switch+2);
786 break;
787 case 'C':
788 {
789 bool AlreadyBad=false; // Avoid reporting "bad switch" several times.
790
792 switch(toupperw(Switch[2]))
793 {
794 case 'A':
795 rch=RCH_ANSI;
796 break;
797 case 'O':
798 rch=RCH_OEM;
799 break;
800 case 'U':
801 rch=RCH_UNICODE;
802 break;
803 case 'F':
804 rch=RCH_UTF8;
805 break;
806 default :
807 BadSwitch(Switch);
808 AlreadyBad=true;
809 break;
810 };
811 if (!AlreadyBad)
812 if (Switch[3]==0)
814 else
815 for (uint I=3;Switch[I]!=0 && !AlreadyBad;I++)
816 switch(toupperw(Switch[I]))
817 {
818 case 'C':
819 CommentCharset=rch;
820 break;
821 case 'L':
822 FilelistCharset=rch;
823 break;
824 case 'R':
825 RedirectCharset=rch;
826 break;
827 default:
828 BadSwitch(Switch);
829 AlreadyBad=true;
830 break;
831 }
832 // Set it immediately when parsing the command line, so it also
833 // affects messages issued while parsing the command line.
835 }
836 break;
837
838 }
839 break;
840 case 'T':
841 switch(toupperw(Switch[1]))
842 {
843 case 'K':
845 break;
846 case 'L':
848 break;
849 case 'O':
850 SetTimeFilters(Switch+2,true,true);
851 break;
852 case 'N':
853 SetTimeFilters(Switch+2,false,true);
854 break;
855 case 'B':
856 SetTimeFilters(Switch+2,true,false);
857 break;
858 case 'A':
859 SetTimeFilters(Switch+2,false,false);
860 break;
861 case 'S':
862 SetStoreTimeMode(Switch+2);
863 break;
864 case '-':
865 Test=false;
866 break;
867 case 0:
868 Test=true;
869 break;
870 default:
871 BadSwitch(Switch);
872 break;
873 }
874 break;
875 case 'U':
876 if (Switch[1]==0)
877 UpdateFiles=true;
878 else
879 BadSwitch(Switch);
880 break;
881 case 'V':
882 switch(toupperw(Switch[1]))
883 {
884 case 'P':
885 VolumePause=true;
886 break;
887 case 'E':
888 if (toupperw(Switch[2])=='R')
889 VersionControl=atoiw(Switch+3)+1;
890 break;
891 case '-':
892 VolSize=0;
893 break;
894 default:
895 VolSize=VOLSIZE_AUTO; // UnRAR -v switch for list command.
896 break;
897 }
898 break;
899 case 'W':
900 wcsncpyz(TempPath,Switch+1,ASIZE(TempPath));
902 break;
903 case 'Y':
904 AllYes=true;
905 break;
906 case 'Z':
907 if (Switch[1]==0)
908 {
909 // If comment file is not specified, we read data from stdin.
911 }
912 else
914 break;
915 case '?' :
917 break;
918 default :
919 BadSwitch(Switch);
920 break;
921 }
922}
923#endif
924
925
926#if !defined(SFX_MODULE)
927void CommandData::BadSwitch(const wchar *Switch)
928{
929 mprintf(St(MUnknownOption),Switch);
931}
932#endif
933
934
936{
937#ifndef SFX_MODULE
938
939 const wchar *SingleCharCommands=L"FUADPXETK";
940 if (Command[0]!=0 && Command[1]!=0 && wcschr(SingleCharCommands,Command[0])!=NULL || *ArcName==0)
941 OutHelp(*Command==0 ? RARX_SUCCESS:RARX_USERERROR); // Return 'success' for 'rar' without parameters.
942
943 const wchar *ArcExt=GetExt(ArcName);
944#ifdef _UNIX
945 if (ArcExt==NULL && (!FileExist(ArcName) || IsDir(GetFileAttr(ArcName))))
946 wcsncatz(ArcName,L".rar",ASIZE(ArcName));
947#else
948 if (ArcExt==NULL)
949 wcsncatz(ArcName,L".rar",ASIZE(ArcName));
950#endif
951 // Treat arcname.part1 as arcname.part1.rar.
952 if (ArcExt!=NULL && wcsnicomp(ArcExt,L".part",5)==0 && IsDigit(ArcExt[5]) &&
954 {
955 wchar Name[NM];
956 wcsncpyz(Name,ArcName,ASIZE(Name));
957 wcsncatz(Name,L".rar",ASIZE(Name));
958 if (FileExist(Name))
960 }
961
962 if (wcschr(L"AFUMD",*Command)==NULL && *UseStdin==0)
963 {
964 if (GenerateArcName)
965 {
968 }
969
970 StringList ArcMasks;
971 ArcMasks.AddString(ArcName);
974 while (Scan.GetNext(&FindData)==SCAN_SUCCESS)
976 }
977 else
979#endif
980
981 switch(Command[0])
982 {
983 case 'P':
984 case 'X':
985 case 'E':
986 case 'T':
987 {
988 CmdExtract Extract(this);
989 Extract.DoExtract();
990 }
991 break;
992#ifndef SILENT
993 case 'V':
994 case 'L':
995 ListArchive(this);
996 break;
997 default:
999#endif
1000 }
1001 if (!BareOutput)
1002 mprintf(L"\n");
1003}
1004
1005
1007{
1008 ArcNames.AddString(Name);
1009}
1010
1011
1012bool CommandData::GetArcName(wchar *Name,int MaxSize)
1013{
1014 return ArcNames.GetString(Name,MaxSize);
1015}
1016
1017
1019{
1020#if defined(_WIN_ALL) || defined(_EMX)
1021 return Ch=='-' || Ch=='/';
1022#else
1023 return Ch=='-';
1024#endif
1025}
1026
1027
1028#ifndef SFX_MODULE
1030{
1031 if (IsDigit(*Str))
1032 return wcstol(Str,NULL,0);
1033
1034 uint Attr=0;
1035 while (*Str!=0)
1036 {
1037 switch(toupperw(*Str))
1038 {
1039 case 'D':
1040 Dir=true;
1041 break;
1042#ifdef _UNIX
1043 case 'V':
1044 Attr|=S_IFCHR;
1045 break;
1046#elif defined(_WIN_ALL) || defined(_EMX)
1047 case 'R':
1048 Attr|=0x1;
1049 break;
1050 case 'H':
1051 Attr|=0x2;
1052 break;
1053 case 'S':
1054 Attr|=0x4;
1055 break;
1056 case 'A':
1057 Attr|=0x20;
1058 break;
1059#endif
1060 }
1061 Str++;
1062 }
1063 return Attr;
1064}
1065#endif
1066
1067
1068
1069
1070#ifndef SFX_MODULE
1072{
1073 // Define 0x100000000 as macro to avoid troubles with older compilers.
1074 const uint64 MaxDictSize=INT32TO64(1,0);
1075 // Limit the dictionary size to 4 GB.
1076 for (uint64 I=0x10000;I<=MaxDictSize;I*=2)
1077 if (WinSize==I)
1078 return true;
1079 WinSize=0x400000;
1080 return false;
1081}
1082#endif
1083
1084
1085#ifndef SFX_MODULE
1087{
1088 if (Format==RARFMT15)
1089 {
1090 if (HashType!=HASH_CRC32)
1091 uiMsg(UIERROR_INCOMPATSWITCH,L"-ht",4);
1092#ifdef _WIN_ALL
1093 if (SaveSymLinks)
1094 uiMsg(UIERROR_INCOMPATSWITCH,L"-ol",4);
1095#endif
1096 if (SaveHardLinks)
1097 uiMsg(UIERROR_INCOMPATSWITCH,L"-oh",4);
1098
1099#ifdef _WIN_ALL
1100 // Do not report a wrong dictionary size here, because we are not sure
1101 // yet about archive format. We can switch to RAR5 mode later
1102 // if we update RAR5 archive.
1103
1104
1105#endif
1106 if (QOpenMode!=QOPEN_AUTO)
1107 uiMsg(UIERROR_INCOMPATSWITCH,L"-qo",4);
1108 }
1109 if (Format==RARFMT50)
1110 {
1111 }
1112}
1113#endif
RARFORMAT
Definition: archive.hpp:13
@ RARFMT50
Definition: archive.hpp:13
@ RARFMT15
Definition: archive.hpp:13
ErrorHandler ErrHandler
size_t Size()
Definition: array.hpp:94
void Reset()
Definition: array.hpp:148
void Alloc(size_t Items)
Definition: array.hpp:139
void DoExtract()
Definition: extract.cpp:25
void ReadConfig()
Definition: cmddata.cpp:227
bool BareOutput
Definition: cmddata.hpp:25
void SetStoreTimeMode(const wchar *S)
Definition: cmdfilter.cpp:314
void ParseArg(wchar *ArgW)
Definition: cmddata.cpp:92
uint GetExclAttr(const wchar *Str, bool &Dir)
Definition: cmddata.cpp:1029
void AddArcName(const wchar *Name)
Definition: cmddata.cpp:1006
void BadSwitch(const wchar *Switch)
Definition: cmddata.cpp:927
void SetTimeFilters(const wchar *Mod, bool Before, bool Age)
Definition: cmdfilter.cpp:127
StringList StoreArgs
Definition: cmddata.hpp:67
void ParseCommandLine(bool Preprocess, int argc, char *argv[])
Definition: cmddata.cpp:51
void OutHelp(RAR_EXIT ExitCode)
Definition: cmdmix.cpp:51
void PreprocessArg(const wchar *Arg)
Definition: cmddata.cpp:195
StringList InclArgs
Definition: cmddata.hpp:65
RAR_CMD_LIST_MODE ListMode
Definition: cmddata.hpp:24
StringList ExclArgs
Definition: cmddata.hpp:64
void ReportWrongSwitches(RARFORMAT Format)
Definition: cmddata.cpp:1086
bool CheckWinSize()
Definition: cmddata.cpp:1071
StringList ArcNames
Definition: cmddata.hpp:66
wchar Command[NM+16]
Definition: cmddata.hpp:59
bool NoMoreSwitches
Definition: cmddata.hpp:23
void ProcessSwitch(const wchar *Switch)
Definition: cmddata.cpp:276
StringList FileArgs
Definition: cmddata.hpp:63
bool FileLists
Definition: cmddata.hpp:22
bool IsSwitch(int Ch)
Definition: cmddata.cpp:1018
void ProcessSwitchesString(const wchar *Str)
Definition: cmddata.cpp:262
void ParseEnvVar()
Definition: cmddata.cpp:178
bool GetArcName(wchar *Name, int MaxSize)
Definition: cmddata.cpp:1012
void Init()
Definition: cmddata.cpp:12
void ParseDone()
Definition: cmddata.cpp:162
wchar ArcName[NM]
Definition: cmddata.hpp:61
void ProcessCommand()
Definition: cmddata.cpp:935
CommandData()
Definition: cmddata.cpp:6
void Exit(RAR_EXIT ExitCode)
Definition: errhnd.cpp:236
static bool FastFind(const wchar *FindMask, FindData *fd, bool GetSymLink=false)
Definition: find.cpp:108
bool AddArcOnly
Definition: options.hpp:143
bool EncryptHeaders
Definition: options.hpp:122
bool VolumePause
Definition: options.hpp:190
bool SetCompressedAttr
Definition: options.hpp:180
bool FreshFiles
Definition: options.hpp:145
wchar GenerateMask[128]
Definition: options.hpp:174
bool AbsoluteLinks
Definition: options.hpp:160
bool IgnoreGeneralAttr
Definition: options.hpp:181
bool InclDir
Definition: options.hpp:100
HASH_TYPE HashType
Definition: options.hpp:132
bool SaveHardLinks
Definition: options.hpp:159
bool PrintVersion
Definition: options.hpp:139
RAR_CHARSET CommentCharset
Definition: options.hpp:114
APPENDARCNAME_MODE AppendArcNameToPath
Definition: options.hpp:194
bool DisableNames
Definition: options.hpp:138
bool UpdateFiles
Definition: options.hpp:146
bool GenerateArcName
Definition: options.hpp:173
int Priority
Definition: options.hpp:161
RECURSE_MODE Recurse
Definition: options.hpp:148
bool AllYes
Definition: options.hpp:152
bool DisableSortSolid
Definition: options.hpp:154
bool KeepBroken
Definition: options.hpp:163
wchar ExtrPath[NM]
Definition: options.hpp:112
bool VerboseOutput
Definition: options.hpp:153
Array< int64 > NextVolSizes
Definition: options.hpp:150
RAR_CHARSET FilelistCharset
Definition: options.hpp:115
SecPassword Password
Definition: options.hpp:121
int SolidCount
Definition: options.hpp:141
wchar EmailTo[NM]
Definition: options.hpp:192
int64 VolSize
Definition: options.hpp:149
bool ExclDir
Definition: options.hpp:99
bool DisableCopyright
Definition: options.hpp:136
SOUND_NOTIFY_MODE Sound
Definition: options.hpp:129
bool ConfigDisabled
Definition: options.hpp:111
wchar UseStdin[NM]
Definition: options.hpp:204
wchar CommentFile[NM]
Definition: options.hpp:113
wchar ExclArcPath[NM]
Definition: options.hpp:120
size_t WinSize
Definition: options.hpp:103
bool SaveSymLinks
Definition: options.hpp:158
POWER_MODE Shutdown
Definition: options.hpp:195
PATH_EXCL_MODE ExclPath
Definition: options.hpp:147
bool ProcessOwners
Definition: options.hpp:157
int SleepTime
Definition: options.hpp:162
uint InclFileAttr
Definition: options.hpp:95
bool SyncFiles
Definition: options.hpp:177
wchar LogName[NM]
Definition: options.hpp:127
int ArcTime
Definition: options.hpp:155
bool SkipEncrypted
Definition: options.hpp:123
int Method
Definition: options.hpp:131
wchar TempPath[NM]
Definition: options.hpp:104
RAR_CHARSET RedirectCharset
Definition: options.hpp:117
bool ClearArc
Definition: options.hpp:142
bool DisableDone
Definition: options.hpp:137
bool SaveStreams
Definition: options.hpp:179
MESSAGE_TYPE MsgStream
Definition: options.hpp:128
uint ExclFileAttr
Definition: options.hpp:94
int ConvertNames
Definition: options.hpp:156
bool DisablePercentage
Definition: options.hpp:135
bool Lock
Definition: options.hpp:188
bool DisableComment
Definition: options.hpp:144
int64 FileSizeLess
Definition: options.hpp:186
uint VersionControl
Definition: options.hpp:193
bool Test
Definition: options.hpp:189
bool OpenShared
Definition: options.hpp:164
uint Threads
Definition: options.hpp:206
void Init()
Definition: options.cpp:17
bool InclAttrSet
Definition: options.hpp:102
int64 FileSizeMore
Definition: options.hpp:187
wchar ArcPath[NM]
Definition: options.hpp:119
OVERWRITE_MODE Overwrite
Definition: options.hpp:130
RAR_CHARSET ErrlogCharset
Definition: options.hpp:116
FilterMode FilterModes[16]
Definition: options.hpp:191
wchar DefGenerateMask[128]
Definition: options.hpp:175
bool DeleteFiles
Definition: options.hpp:165
SCAN_CODE GetNext(FindData *FindData)
Definition: scantree.cpp:33
void Set(const wchar *Psw)
bool IsSet()
Definition: secpassword.hpp:22
bool GetString(wchar *Str, size_t MaxLength)
Definition: strlist.cpp:49
void AddString(const wchar *Str)
Definition: strlist.cpp:26
size_t ItemsCount()
Definition: strlist.hpp:24
void Reset()
Definition: strlist.cpp:9
static const wchar * AllocCmdParam(const wchar *CmdLine, wchar **Par)
Definition: cmddata.cpp:37
@ RCLM_ACCEPT_LISTS
Definition: cmddata.hpp:7
@ RCLM_AUTO
Definition: cmddata.hpp:7
@ RCLM_REJECT_LISTS
Definition: cmddata.hpp:7
#define DefaultStoreList
Definition: cmddata.hpp:5
FilterType
Definition: compress.hpp:52
@ FILTER_E8
Definition: compress.hpp:55
@ FILTER_NONE
Definition: compress.hpp:56
@ FILTER_AUDIO
Definition: compress.hpp:56
@ FILTER_PPM
Definition: compress.hpp:56
@ FILTER_DELTA
Definition: compress.hpp:55
@ FILTER_RGB
Definition: compress.hpp:56
@ FILTER_ARM
Definition: compress.hpp:55
void eprintf(const wchar *fmt,...)
Definition: consio.cpp:135
void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset)
Definition: consio.cpp:59
void SetConsoleMsgStream(MESSAGE_TYPE MsgStream)
Definition: consio.cpp:53
void ProhibitConsoleInput()
Definition: consio.cpp:65
void mprintf(const wchar *fmt,...)
Definition: consio.cpp:118
@ RARX_SUCCESS
Definition: errhnd.hpp:6
@ RARX_USERERROR
Definition: errhnd.hpp:13
uint GetFileAttr(const wchar *Name)
Definition: filefn.cpp:280
bool IsDir(uint Attr)
Definition: filefn.cpp:218
bool FileExist(const wchar *Name)
Definition: filefn.cpp:190
bool ReadTextFile(const wchar *Name, StringList *List, bool Config, bool AbortOnError, RAR_CHARSET SrcCharset, bool Unquote, bool SkipComments, bool ExpandEnvStr)
Definition: filestr.cpp:3
@ HASH_CRC32
Definition: hash.hpp:4
void ListArchive(CommandData *Cmd)
Definition: list.cpp:9
#define MUnknownOption
Definition: loclang.hpp:330
void InitLogOptions(const wchar *LogFileName, RAR_CHARSET CSet)
Definition: log.cpp:7
@ NAMES_LOWERCASE
Definition: options.hpp:27
@ NAMES_UPPERCASE
Definition: options.hpp:27
@ POWERMODE_OFF
Definition: options.hpp:69
@ POWERMODE_HIBERNATE
Definition: options.hpp:69
@ POWERMODE_RESTART
Definition: options.hpp:70
@ POWERMODE_SLEEP
Definition: options.hpp:69
FilterState
Definition: options.hpp:54
@ FILTER_FORCE
Definition: options.hpp:54
@ FILTER_DISABLE
Definition: options.hpp:54
@ FILTER_AUTO
Definition: options.hpp:54
@ RECURSE_WILDCARDS
Definition: options.hpp:36
@ RECURSE_DISABLE
Definition: options.hpp:34
@ RECURSE_ALWAYS
Definition: options.hpp:35
RAR_CHARSET
Definition: options.hpp:51
@ RCH_UTF8
Definition: options.hpp:51
@ RCH_OEM
Definition: options.hpp:51
@ RCH_ANSI
Definition: options.hpp:51
@ RCH_DEFAULT
Definition: options.hpp:51
@ RCH_UNICODE
Definition: options.hpp:51
#define VOLSIZE_AUTO
Definition: options.hpp:8
@ OVERWRITE_NONE
Definition: options.hpp:43
@ OVERWRITE_FORCE_ASK
Definition: options.hpp:45
@ OVERWRITE_AUTORENAME
Definition: options.hpp:44
@ OVERWRITE_ALL
Definition: options.hpp:42
@ MSG_NULL
Definition: options.hpp:29
@ MSG_STDERR
Definition: options.hpp:29
@ MSG_ERRONLY
Definition: options.hpp:29
@ EXCL_SAVEFULLPATH
Definition: options.hpp:14
@ EXCL_ABSPATH
Definition: options.hpp:15
@ EXCL_SKIPWHOLEPATH
Definition: options.hpp:12
@ EXCL_BASEPATH
Definition: options.hpp:13
@ APPENDARCNAME_DESTPATH
Definition: options.hpp:64
@ APPENDARCNAME_OWNDIR
Definition: options.hpp:65
@ APPENDARCNAME_OWNSUBDIR
Definition: options.hpp:64
@ SOLID_COUNT
Definition: options.hpp:18
@ SOLID_FILEEXT
Definition: options.hpp:18
@ SOLID_VOLUME_DEPENDENT
Definition: options.hpp:19
@ SOLID_VOLUME_INDEPENDENT
Definition: options.hpp:19
@ SOLID_NONE
Definition: options.hpp:18
@ SOLID_NORMAL
Definition: options.hpp:18
@ ARCTIME_KEEP
Definition: options.hpp:21
@ ARCTIME_LATEST
Definition: options.hpp:21
@ SOUND_NOTIFY_OFF
Definition: options.hpp:75
@ SOUND_NOTIFY_ON
Definition: options.hpp:75
@ QOPEN_AUTO
Definition: options.hpp:49
@ QOPEN_NONE
Definition: options.hpp:49
@ QOPEN_ALWAYS
Definition: options.hpp:49
bool IsWildcard(const wchar *Str)
Definition: pathfn.cpp:121
bool IsPathDiv(int Ch)
Definition: pathfn.cpp:134
wchar * GetExt(const wchar *Name)
Definition: pathfn.cpp:107
void GenerateArchiveName(wchar *ArcName, size_t MaxSize, const wchar *GenerateMask, bool Archiving)
Definition: pathfn.cpp:869
void AddEndSlash(wchar *Path, size_t MaxLength)
Definition: pathfn.cpp:170
bool IsDriveDiv(int Ch)
Definition: pathfn.cpp:144
#define MAXPASSWORD
Definition: rardefs.hpp:14
#define ASIZE(x)
Definition: rardefs.hpp:10
wchar_t wchar
Definition: rartypes.hpp:13
unsigned int uint
Definition: rartypes.hpp:8
uint64_t uint64
Definition: rartypes.hpp:11
#define INT32TO64(high, low)
Definition: rartypes.hpp:19
const wchar * St(MSGID StringId)
Definition: resource.cpp:8
@ SCAN_SKIPDIRS
Definition: scantree.hpp:6
@ SCAN_SUCCESS
Definition: scantree.hpp:12
void cleandata(void *data, size_t size)
Definition: secpassword.cpp:80
#define Ch(x, y, z)
Definition: sha256.cpp:26
const wchar * GetCmdParam(const wchar *CmdLine, wchar *Param, size_t MaxSize)
Definition: strfn.cpp:377
bool IsSpace(int ch)
Definition: strfn.cpp:161
void wcsncpyz(wchar *dest, const wchar *src, size_t maxlen)
Definition: strfn.cpp:275
void wcsncatz(wchar *dest, const wchar *src, size_t maxlen)
Definition: strfn.cpp:300
bool IsDigit(int ch)
Definition: strfn.cpp:151
int Param1
Definition: options.hpp:80
FilterState State
Definition: options.hpp:79
int Param2
Definition: options.hpp:81
Definition: find.hpp:9
wchar Name[NM]
Definition: find.hpp:10
bool IsDir
Definition: find.hpp:13
void InitSystemOptions(int SleepTime)
Definition: system.cpp:5
void SetPriority(int Priority)
Definition: system.cpp:12
const uint MaxPoolThreads
Definition: threadpool.hpp:5
@ UIPASSWORD_GLOBAL
Definition: ui.hpp:90
bool uiGetPassword(UIPASSWORD_TYPE Type, const wchar *FileName, SecPassword *Password)
Definition: uiconsole.cpp:398
void uiMsg(UIMESSAGE_CODE Code)
Definition: ui.hpp:148
@ UIERROR_TRUNCPSW
Definition: ui.hpp:42
@ UIERROR_INCOMPATSWITCH
Definition: ui.hpp:37
int wcsicomp(const wchar *s1, const wchar *s2)
Definition: unicode.cpp:425
int64 atoilw(const wchar *s)
Definition: unicode.cpp:556
int atoiw(const wchar *s)
Definition: unicode.cpp:550
bool CharToWide(const char *Src, wchar *Dest, size_t DestSize)
Definition: unicode.cpp:85
int toupperw(int ch)
Definition: unicode.cpp:523
int wcsnicomp(const wchar *s1, const wchar *s2, size_t n)
Definition: unicode.cpp:446
wchar * wcsupper(wchar *s)
Definition: unicode.cpp:506