/[projet1]/public/pc/tools/osdk/main/common/includes/common.h
Defence Force logotype

Annotation of /public/pc/tools/osdk/main/common/includes/common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1075 - (hide annotations)
Sun Jan 12 20:13:41 2014 UTC (6 years ago) by dbug
File MIME type: text/plain
File size: 5117 byte(s)
PictConv 0.016
- New option to skip the conversion if the target file is more recent than the source file (-u)
- New option to enable/disable information about what happens (-v)

Ym2Mym 1.1
- The tool is now able to extract LHA compressed YM files directly, should make the process much easier :)
1 dbug 70
2     #ifndef _COMMON_H_
3     #define _COMMON_H_
4    
5     // Disable the warning C4706 -> assignment within conditional expression
6     // Allow us to use Warning level 4 instead of level 3
7     #pragma warning( disable : 4706)
8     #pragma warning( disable : 4786) // Debug symbols thing
9     #pragma warning( disable : 4996) // #define _CRT_SECURE_NO_WARNINGS
10     //#define _CRT_SECURE_NO_WARNINGS
11    
12    
13     #include <string>
14     #include <vector>
15    
16 mmu_man 872 #include <fcntl.h>
17 dbug 208
18 mmu_man 872 #ifndef O_BINARY
19     #define O_BINARY 0
20     #endif
21    
22 dbug 898 #ifdef _WIN32
23     #define strncasecmp _strnicmp
24     #include <io.h>
25     #else
26     #include <unistd.h>
27     #endif
28 mmu_man 872
29 dbug 898
30 dbug 70 //
31 dbug 208 // Debugging macros
32     //
33     #ifdef _DEBUG
34 dbug 974 #define _BREAK_ __asm { int 3 }
35 dbug 208 #define _BREAK_IF_(cond) if (cond) __asm { int 3 } else ((void)0)
36     #else
37 dbug 974 #define _BREAK_ ((void)0)
38 dbug 208 #define _BREAK_IF_(cond) ((void)0)
39     #endif
40    
41    
42     //
43 dbug 70 // Argument parsing, error handling
44     //
45     void SetApplicationParameters(const char* pcApplicationName,int nVersionMajor,int nVersionMinor,const char* pcUsageMessage);
46    
47 dbug 1013 void ShowError(const char *pcMessage,...);
48 dbug 70
49    
50     class ArgumentParser
51     {
52     public:
53 dbug 974 ArgumentParser(int argc,char *argv[]);
54     ~ArgumentParser() {}
55 dbug 70
56 dbug 974 const char* GetParameter(int nParameterIndex);
57     int GetParameterCount();
58 dbug 70
59 dbug 974 bool ProcessNextArgument();
60 dbug 70
61 dbug 974 bool IsSwitch(const char *ptr_switch);
62     bool IsParameter();
63 dbug 70
64 dbug 974 std::string GetStringValue();
65     int GetIntegerValue(int default_value);
66     bool GetBooleanValue(bool default_value);
67     bool GetSeparator(const char* ptr_separator_list);
68     const char* GetRemainingStuff();
69 dbug 70
70     private:
71 dbug 974 ArgumentParser();
72 dbug 70
73     private:
74 dbug 974 int m_argc;
75     char** m_argv;
76     long m_first_param;
77 dbug 70
78 dbug 974 int m_remaining_argc;
79     long m_nb_arg;
80     const char* m_ptr_arg;
81 dbug 70 };
82    
83     bool get_switch(const char *&ptr_arg,const char *ptr_switch);
84     int get_value(const char *&ptr_arg,long default_value);
85     std::string get_string(const char *&ptr_arg);
86    
87    
88     //
89     // File loading and saving
90     //
91     bool LoadFile(const char* pcFileName,void* &pcBuffer,size_t &cBufferSize);
92     bool SaveFile(const char* pcFileName,const void* pcBuffer,size_t cBufferSize);
93 dbug 406 bool DeleteFile(const char* pcFileName);
94 dbug 70
95     bool LoadText(const char* pcFileName,std::vector<std::string>& cTextData);
96    
97 dbug 1075 bool IsUpToDate(const char* sourceFile,const char* targetFile);
98     bool IsUpToDate(const std::string& sourceFile,const std::string& targetFile);
99    
100    
101 dbug 1035 //
102     // Compression (moved out FilePack)
103     //
104     long LZ77_Compress(void *buf_src,void *buf_dest,long size_buf_src);
105     void LZ77_UnCompress(void *buf_src,void *buf_dest,long size);
106     long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp);
107 dbug 1038 extern unsigned char gLZ77_XorMask;
108 dbug 70
109     //
110     // Preprocessing and filtering
111     //
112     int StringReplace(std::string& cMainString,const std::string& cSearchedString,const std::string& cReplaceString);
113 dbug 208 std::string StringTrim(const std::string& cInputString,const std::string& cFilteredOutCharacterList=" \t\f\v\n\r");
114 dbug 70 std::string StringFormat(const char* pFormatString,...);
115 dbug 1045 std::string StringMakeLabel(const std::string& sourceString);
116 dbug 70
117     int ConvertAdress(const char *ptr_value);
118    
119     class TextFileGenerator
120     {
121     public:
122 dbug 974 enum Language_e
123     {
124     _eLanguage_Undefined_,
125     eLanguage_C,
126     eLanguage_Assembler,
127     eLanguage_BASIC
128     };
129 dbug 70
130 dbug 974 enum Endianness_e
131     {
132     _eEndianness_Undefined_,
133     _eEndianness_Little,
134     _eEndianness_Big
135     };
136 dbug 70
137 dbug 974 enum NumericBase_e
138     {
139     _eNumericBase_Undefined_,
140     _eNumericBase_Hexadecimal,
141     _eNumericBase_Decimal
142     };
143 dbug 70
144     public:
145 dbug 974 TextFileGenerator();
146     ~TextFileGenerator();
147 dbug 70
148 dbug 974 void SetDataSize(int nDataSize) { m_nDataSize=nDataSize; }
149     void SetFileType(Language_e nFileType) { m_nFileType=nFileType; }
150     void SetEndianness(Endianness_e nEndianness) { m_nEndianness=nEndianness; }
151     void SetNumericBase(NumericBase_e nNumericBase) { m_nNumericBase=nNumericBase; }
152     void SetValuesPerLine(unsigned int nValuesPerLine) { m_nValuesPerLine=nValuesPerLine; }
153     void SetLabel(const std::string& cLabel) { m_cLabelName=cLabel; }
154     void SetLineNumber(int nLineNumber) { m_nFirstLineNumber=nLineNumber; }
155     void SetIncrementLineNumber(int nIncrementLineNumber) { m_nIncrementLineNumber=nIncrementLineNumber; }
156 dbug 70
157 dbug 974 int GetDataSize() { return m_nDataSize; }
158     Language_e GetFileType() { return m_nFileType; }
159     Endianness_e GetEndianness() { return m_nEndianness; }
160     NumericBase_e GetNumericBase() { return m_nNumericBase; }
161     unsigned int GetValuesPerLine() { return m_nValuesPerLine; }
162     const std::string& GetLabel() { return m_cLabelName; }
163     int GetLineNumber() { return m_nFirstLineNumber; }
164     int GetIncrementLineNumber() { return m_nIncrementLineNumber; }
165 dbug 70
166 dbug 974 std::string ConvertData(const void* pSourceData,size_t nFileSize);
167 dbug 70
168     private:
169 dbug 974 int m_nDataSize;
170     Language_e m_nFileType;
171     Endianness_e m_nEndianness;
172     NumericBase_e m_nNumericBase;
173     unsigned int m_nValuesPerLine;
174 dbug 70
175 dbug 974 bool m_bEnableLineNumber;
176     int m_nFirstLineNumber;
177     int m_nIncrementLineNumber;
178 dbug 70
179 dbug 974 std::string m_cLabelName;
180 dbug 70 };
181    
182    
183     #endif // _COMMON_H_

  ViewVC Help
Powered by ViewVC 1.1.26