Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
7.9 KiB

  1. #ifndef __MAIN_H__
  2. #define __MAIN_H__
  3. #include <afx.h>
  4. #include <iodll.h>
  5. ///////////////////////////////////////////////////////////////////////////////
  6. // From RLMan
  7. // Token flag Masks
  8. #define ISPOPUP 0x0001
  9. #define ISCOR 0x0010
  10. #define ISDUP 0x0020
  11. #define ISCAP 0x0040
  12. #define ISDLGFONTCHARSET 0x0002
  13. #define ISDLGFONTNAME 0x0004
  14. #define ISDLGFONTSIZE 0x0008
  15. #define ISALIGN 0x0080
  16. #define ISEXTSTYLE 0x0200
  17. #define OLD_POPUP_ID 0x0100
  18. #define ISKEY 0x0010
  19. #define ISVAL 0x0020
  20. // status bits
  21. #define ST_TRANSLATED 4
  22. #define ST_READONLY 2
  23. #define ST_NEW 1
  24. #define ST_DIRTY 1
  25. #define ST_CHANGED 4
  26. #define MAX_STR_SIZE 8192 // Max Len of a string passed to WriteCon
  27. #define MAX_BUF_SIZE 8192 // Max ResItem Buffer size
  28. // Console flags
  29. #define CONOUT 0 // Used with WriteCon to send the message to stdout
  30. #define CONERR 1 // Used with WriteCon to send the message to stderr
  31. #define CONBOTH 2 // Used with WriteCon to send the message to stderr and stdout if not the same handle
  32. #define CONWRN 3 // Used with WriteCon to send the message to stderr only if WARNING enabled
  33. class CMainApp
  34. {
  35. public:
  36. // Error codes
  37. enum Error_Codes
  38. {
  39. ERR_NOERROR = 0x00000000, //
  40. ERR_COMMAND_LINE = 0x00000001, // Wrong command line
  41. ERR_TOKEN_MISMATCH = 0x00000002, // Token file don't match
  42. ERR_TOKEN_WRONGFORMAT = 0x00000004, // Token file are not in the right format
  43. ERR_FILE_OPEN = 0x00000100, // Cannot open the file
  44. ERR_FILE_COPY = 0x00000200, // Cannot copy the file
  45. ERR_FILE_CREATE = 0x00000400, // Cannot create the file
  46. ERR_FILE_NOTSUPP = 0x00000800, // This file type is not supported
  47. ERR_FILE_NOTFOUND = 0x00001000, // The file doesn't exist
  48. ERR_FILE_VERSTAMPONLY = 0x00002000, // The file has only version stamping
  49. ERR_HELP_CHOOSE = 0x00004000 // The user want to see the help file
  50. };
  51. // Options Flags
  52. enum Option_Codes
  53. {
  54. NO_OPTION = 0x00000000, // Initializer
  55. WARNING = 0x00000001, // -w (Show warning messages)
  56. HELP = 0x00000002, // -? or -h (Show more complete help using winhelp)
  57. APPEND = 0x00000004, // -a (Append resources in localized tokens)
  58. REPLACE = 0x00000008, // -r (Replace resources in localized tokens, no checking)
  59. EXTRACT = 0x00000010, // -t (Extract token file)
  60. BITMAPS = 0x00000020, // -b (Extract bitmaps and icons)
  61. SPLIT = 0x00000040, // -s (Split the message table)
  62. NOLOGO = 0x00000080, // -n (Nologo)
  63. UPDATE = 0x00000100, // -u (Update the resources in localized file)
  64. FONTS = 0x00000200, // -f (Font information for dialog)
  65. PIPED = 0x00001000, // We have being piped to a file
  66. INPUT_LANG = 0x00002000, // -i (Input language resources set)
  67. OUTPUT_LANG = 0x00004000, // -o (Output language resources set)
  68. LEANAPPEND = 0x00010000, // -l (Do not append redudant resources)
  69. ALIGNMENT = 0x00020000, // -y (Extract static control alignment style info)
  70. GIFHTMLINF = 0x00040000, // -c (Extract embedded gifs, htmls and infs)
  71. NOVERSION = 0x00080000 // -v (Do not generate selected version stamp information)
  72. };
  73. #if 0
  74. enum Return_Codes
  75. {
  76. RET_NOERROR = 0x00000000, //
  77. RET_ID_NOTFOUND = 0x00000001, // An Id was not found
  78. RET_CNTX_CHANGED = 0x00000002, // Contex changed
  79. RET_RESIZED = 0x00000004, // item resized
  80. RET_INVALID_TOKEN = 0x00000008, // The token file is not valid
  81. RET_TOKEN_REMOVED = 0x00000010, // some token were removed
  82. RET_TOKEN_MISMATCH = 0x00000020, // The token mismatch
  83. RET_IODLL_ERROR = 0x00000040, // There is an error in IO
  84. RET_IODLL_WARNING = 0x00000080, // There is an warning in IO
  85. RET_FILE_VERSTAMPONLY = 0x00000100, // File has only version stamping
  86. RET_FILE_NORESOURCE = 0x00000200, // File has no resource
  87. RET_FILE_MULTILANG = 0x00000400, // File has multiple language
  88. RET_IODLL_CHKMISMATCH = 0x00000800, // Symbool checksum mismatch
  89. RET_FILE_CUSTOMRES = 0x00001000, // Contains custom resource.
  90. RET_IODLL_NOSYMBOL = 0x00002000, // Symbol file not found
  91. RET_FILE_NOSYMPATH = 0x00004000 // Output symbol path not found.
  92. };
  93. #endif
  94. public:
  95. // Constructor
  96. CMainApp();
  97. ~CMainApp();
  98. // Operations
  99. Error_Codes ParseCommandLine(int argc, char ** argv);
  100. Error_Codes GenerateFile();
  101. void Banner();
  102. void Help();
  103. BOOL IsFlag(Option_Codes dwFlag)
  104. { return ((m_dwFlags & dwFlag)==dwFlag); }
  105. int __cdecl WriteCon(int iFlags, const char * lpstr, ...);
  106. void AddNotFound()
  107. { m_wIDNotFound++; SetReturn(ERROR_RET_ID_NOTFOUND); }
  108. void AddChanged()
  109. { m_wCntxChanged++; SetReturn(ERROR_RET_CNTX_CHANGED); }
  110. void AddResized()
  111. { m_wResized++; SetReturn(ERROR_RET_RESIZED); }
  112. int ReturnCode()
  113. { return m_dwReturn; }
  114. // Language support
  115. WORD GetOutLang()
  116. { return ( MAKELANGID(m_usOPriLangId, m_usOSubLangId) ); }
  117. int SetReturn(int rc);
  118. int IoDllError(int iError);
  119. UINT GetUICodePage()
  120. { return m_uiCodePage; }
  121. private:
  122. // Attributes
  123. Option_Codes m_dwFlags; // Command line parameters
  124. int m_dwReturn; // Return codes
  125. // Console Handles
  126. HANDLE m_StdOutput;
  127. HANDLE m_StdError;
  128. // String Buffers
  129. CString m_strBuffer1;
  130. CString m_strBuffer2;
  131. BYTE * m_pBuf;
  132. // File Names
  133. CString m_strInExe;
  134. CString m_strOutExe;
  135. CString m_strSrcTok;
  136. CString m_strTgtTok;
  137. // Symbol Path Name
  138. CString m_strSymPath;
  139. CString m_strOutputSymPath;
  140. SHORT m_usIPriLangId; // Primary language ID for the input file
  141. SHORT m_usISubLangId; // Secondary language ID for the input file
  142. SHORT m_usOPriLangId; // Primary language ID for the output file
  143. SHORT m_usOSubLangId; // Secondary language ID for the output file
  144. UINT m_uiCodePage; // Code page to use during conversion
  145. char m_unmappedChar; // Default for unmappable characters
  146. // report counters
  147. WORD m_wIDNotFound;
  148. WORD m_wCntxChanged;
  149. WORD m_wResized;
  150. // Helper operators
  151. CString CalcTab(CString str, int tablen, char ch);
  152. USHORT GetLangID(CString strNum);
  153. UINT GetCodePage(CString strNum);
  154. LPCSTR Format(CString strTmp);
  155. LPCSTR UnFormat(CString strTmp);
  156. // Member functions
  157. Error_Codes BinGen();
  158. Error_Codes TokGen();
  159. Error_Codes DelRes();
  160. };
  161. /////////////////////////////////////////////////////////////////////////
  162. // This is needed to make sure that the operator |= will work fine on the
  163. // enumerated type Option_Codes
  164. inline CMainApp::Option_Codes operator|=( CMainApp::Option_Codes &oc, int i )
  165. { return oc = (CMainApp::Option_Codes)(oc | i); }
  166. #if 0
  167. inline CMainApp::Error_Codes operator|=( CMainApp::Error_Codes &rc, int i )
  168. { return rc = (CMainApp::Return_Codes)(rc | i); }
  169. #endif
  170. #pragma pack(1)
  171. typedef struct iconHeader
  172. {
  173. WORD idReserved;
  174. WORD idType;
  175. WORD idCount;
  176. BYTE bWidth;
  177. BYTE bHeight;
  178. BYTE bColorCount;
  179. BYTE bReserved;
  180. WORD wPlanes;
  181. WORD wBitCount;
  182. DWORD dwBytesInRes;
  183. DWORD dwImageOffset;
  184. } ICONHEADER;
  185. #pragma pack(8)
  186. #endif // __MAIN_H__