1
0

cmdmix.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. void CommandData::OutTitle()
  2. {
  3. if (BareOutput || DisableCopyright)
  4. return;
  5. #if defined(__GNUC__) && defined(SFX_MODULE)
  6. mprintf(St(MCopyrightS));
  7. #else
  8. #ifndef SILENT
  9. static bool TitleShown=false;
  10. if (TitleShown)
  11. return;
  12. TitleShown=true;
  13. wchar Version[80];
  14. if (RARVER_BETA!=0)
  15. swprintf(Version,ASIZE(Version),L"%d.%02d %ls %d",RARVER_MAJOR,RARVER_MINOR,St(MBeta),RARVER_BETA);
  16. else
  17. swprintf(Version,ASIZE(Version),L"%d.%02d",RARVER_MAJOR,RARVER_MINOR);
  18. #if defined(_WIN_32) || defined(_WIN_64)
  19. wcsncatz(Version,L" ",ASIZE(Version));
  20. #endif
  21. #ifdef _WIN_32
  22. wcsncatz(Version,St(Mx86),ASIZE(Version));
  23. #endif
  24. #ifdef _WIN_64
  25. wcsncatz(Version,St(Mx64),ASIZE(Version));
  26. #endif
  27. if (PrintVersion)
  28. {
  29. mprintf(L"%s",Version);
  30. exit(0);
  31. }
  32. mprintf(St(MUCopyright),Version,RARVER_YEAR);
  33. #endif
  34. #endif
  35. }
  36. inline bool CmpMSGID(MSGID i1,MSGID i2)
  37. {
  38. #ifdef MSGID_INT
  39. return i1==i2;
  40. #else
  41. // If MSGID is const char*, we cannot compare pointers only.
  42. // Pointers to different instances of same string can differ,
  43. // so we need to compare complete strings.
  44. return wcscmp(i1,i2)==0;
  45. #endif
  46. }
  47. void CommandData::OutHelp(RAR_EXIT ExitCode)
  48. {
  49. #if !defined(SILENT)
  50. OutTitle();
  51. static MSGID Help[]={
  52. #ifdef SFX_MODULE
  53. // Console SFX switches definition.
  54. MCHelpCmd,MSHelpCmdE,MSHelpCmdT,MSHelpCmdV
  55. #else
  56. // UnRAR switches definition.
  57. MUNRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdE,MCHelpCmdL,
  58. MCHelpCmdP,MCHelpCmdT,MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm,
  59. MCHelpSwAT,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,MCHelpSwAI,MCHelpSwAP,
  60. MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,MCHelpSwDH,MCHelpSwEP,
  61. MCHelpSwEP3,MCHelpSwEP4,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
  62. MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwME,MCHelpSwN,MCHelpSwNa,
  63. MCHelpSwNal,MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOP,MCHelpSwOR,
  64. MCHelpSwOW,MCHelpSwP,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSI,
  65. MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,
  66. MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,
  67. MCHelpSwXa,MCHelpSwXal,MCHelpSwY
  68. #endif
  69. };
  70. for (uint I=0;I<ASIZE(Help);I++)
  71. {
  72. #ifndef SFX_MODULE
  73. if (CmpMSGID(Help[I],MCHelpSwV))
  74. continue;
  75. #ifndef _WIN_ALL
  76. static MSGID Win32Only[]={
  77. MCHelpSwIEML,MCHelpSwVD,MCHelpSwAO,MCHelpSwOS,MCHelpSwIOFF,
  78. MCHelpSwEP2,MCHelpSwOC,MCHelpSwONI,MCHelpSwDR,MCHelpSwRI
  79. };
  80. bool Found=false;
  81. for (uint J=0;J<ASIZE(Win32Only);J++)
  82. if (CmpMSGID(Help[I],Win32Only[J]))
  83. {
  84. Found=true;
  85. break;
  86. }
  87. if (Found)
  88. continue;
  89. #endif
  90. #if !defined(_UNIX) && !defined(_WIN_ALL)
  91. if (CmpMSGID(Help[I],MCHelpSwOW))
  92. continue;
  93. #endif
  94. #if !defined(_WIN_ALL) && !defined(_EMX)
  95. if (CmpMSGID(Help[I],MCHelpSwAC))
  96. continue;
  97. #endif
  98. #ifndef SAVE_LINKS
  99. if (CmpMSGID(Help[I],MCHelpSwOL))
  100. continue;
  101. #endif
  102. #ifndef RAR_SMP
  103. if (CmpMSGID(Help[I],MCHelpSwMT))
  104. continue;
  105. #endif
  106. #endif
  107. mprintf(St(Help[I]));
  108. }
  109. mprintf(L"\n");
  110. ErrHandler.Exit(ExitCode);
  111. #endif
  112. }