eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_extsrc.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4D_EXTSRC_H
47 #define __D4D_EXTSRC_H
48 
49 #if !defined(__MQX__) && !defined(D4D_OS_MQX)
50  // #include <stdlib.h>
51 #endif
52 
53 /******************************************************************************
54 * D4D External Resources constants
55 *
56 */
63 #ifndef D4D_IMG_WORK_PATH_DEFAULT
64  #define D4D_IMG_WORK_PATH_DEFAULT "a:\\"
65 #endif
66 
71 #ifndef D4D_FNT_WORK_PATH_DEFAULT
72  #define D4D_FNT_WORK_PATH_DEFAULT "a:\\"
73 #endif
74 
78 #ifndef D4D_DRIVE_MAX_STRLEN
79  #define D4D_DRIVE_MAX_STRLEN 8
80 #endif
81 
84 /******************************************************************************
85 * D4D External Resources types
86 *
87 */
91 /**************************************************************************/
98 typedef D4D_FILEPTR (*D4DFILE_FOPEN)(D4D_CHAR* filename, D4D_CHAR* mode);
99 
100 /**************************************************************************/
106 typedef int (*D4DFILE_FCLOSE)(D4D_FILEPTR p_file);
107 
108 /**************************************************************************/
116 typedef int (*D4DFILE_READ)(D4D_FILEPTR p_file, void* buffer, int size);
117 
118 /**************************************************************************/
126 typedef int (*D4DFILE_WRITE)(D4D_FILEPTR p_file, const void* buffer, int size);
127 
128 /**************************************************************************/
136 typedef int (*D4DFILE_FSEEK)(D4D_FILEPTR p_file, long offset, int origin);
137 
139 #define D4D_SEEK_SET 1
140 
141 #define D4D_SEEK_CUR 2
142 
143 #define D4D_SEEK_END 3
144 
145 /**************************************************************************/
151 typedef long (*D4DFILE_FTELL)(D4D_FILEPTR p_file);
152 
153 /**************************************************************************/
164 typedef int (*D4DLOCALE_TRANSLATE_STR)(const D4D_TCHAR* originTxt, D4D_TCHAR* newTxt, int offset, int size);
165 
166 /**************************************************************************/
174 typedef int (*D4DLOCALE_GET_TRANSLATE_STR_LEN)(const D4D_TCHAR* originTxt);
175 
177 typedef struct D4DFILE_FUNCTIONS_S
178 {
186 
188 typedef struct D4DLOCALE_FUNCTIONS_S
189 {
193 
196 /******************************************************************************
197 * Internal types
198 ******************************************************************************/
199 /******************************************************************************
200 * D4D External resources macros
201 *
202 */
206 /**************************************************************************/
213 #define D4D_DECLARE_LOCALE_FUNCTIONS(D4DLOCALE_TranslateStr, D4DLOCALE_GetTranslateStrLength) \
214  const D4DLOCALE_FUNCTIONS d4d_extsrcLocale = \
215  { \
216  D4DLOCALE_TranslateStr, /* Translate locale function pointer */ \
217  D4DLOCALE_GetTranslateStrLength /* Translate locale get str Length function pointer */ \
218  };
219 
220 /**************************************************************************/
230 #define D4D_DECLARE_FILE_FUNCTIONS(D4DFILE_fopen, D4DFILE_fclose, D4DFILE_read, D4DFILE_write, D4DFILE_fseek, D4DFILE_ftell) \
231  const D4DFILE_FUNCTIONS d4d_extsrcFile = \
232  { \
233  D4DFILE_fopen, /* D4D File - fopen */ \
234  D4DFILE_fclose, /* D4D File - fclose */ \
235  D4DFILE_read, /* D4D File - fread */ \
236  D4DFILE_write, /* D4D File - fwrite */ \
237  D4DFILE_fseek, /* D4D File - fseek */ \
238  D4DFILE_ftell /* D4D File - ftell */ \
239  };
240 
241 
242 
243 #if D4D_ENDIAN == D4D_ENDIAN_LITTLE
244 
245  #define D4D_READ8L(x) (x)
246 
247  #define D4D_READ16L(x) (x)
248 
249  #define D4D_READ32L(x) (x)
250 
252  #define D4D_READ8B(x) (x)
253 
254  #define D4D_READ16B(x) D4D_SwapWord((x))
255 
256  #define D4D_READ32B(x) D4D_SwapLong((x))
257 
259  #define D4D_WRITE8L(x) (x)
260 
261  #define D4D_WRITE16L(x) (x)
262 
263  #define D4D_WRITE32L(x) (x)
264 
266  #define D4D_WRITE8B(x) (x)
267 
268  #define D4D_WRITE16B(x) D4D_SwapWord((x))
269 
270  #define D4D_WRITE32B(x) D4D_SwapLong((x))
271 
272 
273 #else
274  #define D4D_READ8L(x) (x)
275  #define D4D_READ16L(x) D4D_SwapWord((x))
276  #define D4D_READ32L(x) D4D_SwapLong((x))
277 
278  #define D4D_READ8B(x) (x)
279  #define D4D_READ16B(x) (x)
280  #define D4D_READ32B(x) (x)
281 
282  #define D4D_WRITE8L(x) (x)
283  #define D4D_WRITE16L(x) D4D_SwapWord((x))
284  #define D4D_WRITE32L(x) D4D_SwapLong((x))
285 
286  #define D4D_WRITE8B(x) (x)
287  #define D4D_WRITE16B(x) (x)
288  #define D4D_WRITE32B(x) (x)
289 
290 #endif
291 
292 
293 
296 /******************************************************************************
297 * D4D External resources functions headers
298 *
299 */
303 #define D4D_FileOpen d4d_extsrcFile.D4DFILE_fopen
304 
305 #define D4D_FileClose d4d_extsrcFile.D4DFILE_fclose
306 
307 #define D4D_FileRead d4d_extsrcFile.D4DFILE_read
308 
309 #define D4D_FileWrite d4d_extsrcFile.D4DFILE_write
310 
311 #define D4D_FileSeek d4d_extsrcFile.D4DFILE_fseek
312 
313 #define D4D_FileTell d4d_extsrcFile.D4DFILE_ftell
314 
316 #ifndef D4D_MemAlloc
317  #if defined(__MQX__) || defined(D4D_OS_MQX)
318  #define D4D_MemAlloc(size) _mem_alloc(size)
319  #else
320  #define D4D_MemAlloc(size) malloc(size)
321  #endif
322 #endif
323 
325 #ifndef D4D_MemFree
326  #if defined(__MQX__) || defined(D4D_OS_MQX)
327  #define D4D_MemFree(pMem) _mem_free(pMem)
328  #else
329  #define D4D_MemFree(pMem) free(pMem)
330  #endif
331 #endif
332 
334 #ifndef D4D_MemCopy
335  #if defined(__MQX__) || defined(D4D_OS_MQX)
336  #define D4D_MemCopy(pDst, pSrc, size) _mem_copy(pSrc, pDst, size)
337  #else
338  #define D4D_MemCopy(pDst, pSrc, size) memcpy(pDst, pSrc, size)
339  #endif
340 #endif
341 
344 /******************************************************************************
345 * Global variables
346 ******************************************************************************/
347 
349 extern const D4DFILE_FUNCTIONS d4d_extsrcFile;
350 
351 /******************************************************************************
352 * Global functions
353 ******************************************************************************/
356 int D4D_StrLen(register const D4D_CHAR *s);
357 D4D_CHAR* D4D_StrCopy(register D4D_CHAR *sd, register const D4D_CHAR *ss);
358 D4D_WCHAR* D4D_StrCopyAscii2Unicode(register D4D_WCHAR *sd, register const D4D_CHAR *ss);
359 D4D_CHAR* D4D_StrCopyUnicode2Ascii(register D4D_CHAR *sd, register const D4D_WCHAR *ss);
360 D4D_CHAR* D4D_StrCat(register D4D_CHAR *sd, register const D4D_CHAR *ss);
361 D4D_WCHAR* D4D_StrCatUnicode(register D4D_WCHAR *sd, register const D4D_WCHAR *ss);
362 int D4D_CompareStrings(const D4D_CHAR* s1, const D4D_CHAR* s2);
363 int D4D_CompareStringsUnicode(const D4D_WCHAR* s1, const D4D_WCHAR* s2);
364 void D4D_ToUpper(D4D_CHAR* s);
367 
368 #ifdef D4D_UNICODE
369  #define D4D_CompareStringsUniversal(s1, s2) D4D_CompareStringsUnicode(s1, s2)
370 #else
371  #define D4D_CompareStringsUniversal(s1, s2) D4D_CompareStrings(s1, s2)
372 #endif
373 
374 #endif /* __D4D_EXTSRC_H */
struct D4DFILE_FUNCTIONS_S D4DFILE_FUNCTIONS
eGUI structure to store API for external files support
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
int(* D4DLOCALE_GET_TRANSLATE_STR_LEN)(const D4D_TCHAR *originTxt)
String translate string get lenght function for customized strings.
Definition: d4d_extsrc.h:174
D4D_WCHAR * D4D_StrCatUnicode(register D4D_WCHAR *sd, register const D4D_WCHAR *ss)
The function concatenate strings (terminated by zero) (UNICODE version)
Definition: d4d_extsrc.c:236
D4D_CHAR * D4D_StrCopy(register D4D_CHAR *sd, register const D4D_CHAR *ss)
The function copy string one string to other one (terminated by zero)
Definition: d4d_extsrc.c:154
D4D_FILEPTR(* D4DFILE_FOPEN)(D4D_CHAR *filename, D4D_CHAR *mode)
File open eGUI function type.
Definition: d4d_extsrc.h:98
D4DLOCALE_GET_TRANSLATE_STR_LEN D4DLOCALE_GetTranslateStrLength
Pointer to Get Translate String Length Function.
Definition: d4d_extsrc.h:191
D4DFILE_FSEEK D4DFILE_fseek
Pointer to File Seek Function.
Definition: d4d_extsrc.h:183
D4DFILE_READ D4DFILE_read
Pointer to File Read Function.
Definition: d4d_extsrc.h:181
eGUI structure to store API for external files support
Definition: d4d_extsrc.h:177
Word D4D_SwapWord(Word n)
The function swap bytes in Word.
Definition: d4d_extsrc.c:352
LWord D4D_SwapLong(LWord n)
The function swap bytes in Long.
Definition: d4d_extsrc.c:335
D4DFILE_FTELL D4DFILE_ftell
Pointer to File Tell Function.
Definition: d4d_extsrc.h:184
int(* D4DFILE_FCLOSE)(D4D_FILEPTR p_file)
File close eGUI function type.
Definition: d4d_extsrc.h:106
D4D_CHAR * D4D_GetFileExtension(D4D_CHAR *pFileName)
D4D_WCHAR * D4D_StrCopyAscii2Unicode(register D4D_WCHAR *sd, register const D4D_CHAR *ss)
The function copy string one string (STANDARD 8 bit) to other one (UNICODE)(terminated by zero) ...
Definition: d4d_extsrc.c:193
int D4D_CompareStringsUnicode(const D4D_WCHAR *s1, const D4D_WCHAR *s2)
The function copare two strings (terminated by zero) (UNICODE version)
Definition: d4d_extsrc.c:290
D4DFILE_FCLOSE D4DFILE_fclose
Pointer to File Close Function.
Definition: d4d_extsrc.h:180
struct D4DLOCALE_FUNCTIONS_S D4DLOCALE_FUNCTIONS
eGUI structure to store API for external strings (translated) support
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
eGUI structure to store API for external strings (translated) support
Definition: d4d_extsrc.h:188
long(* D4DFILE_FTELL)(D4D_FILEPTR p_file)
File tell eGUI function type.
Definition: d4d_extsrc.h:151
const D4DLOCALE_FUNCTIONS d4d_extsrcLocale
int(* D4DFILE_READ)(D4D_FILEPTR p_file, void *buffer, int size)
File read eGUI function type.
Definition: d4d_extsrc.h:116
D4D_CHAR * D4D_StrCat(register D4D_CHAR *sd, register const D4D_CHAR *ss)
The function concatenate strings (terminated by zero)
Definition: d4d_extsrc.c:211
D4D_WCHAR_TYPE D4D_WCHAR
Type definition of eGUI wide char.
Definition: d4d_types.h:277
int(* D4DFILE_WRITE)(D4D_FILEPTR p_file, const void *buffer, int size)
File write eGUI function type.
Definition: d4d_extsrc.h:126
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
char D4D_CHAR
Type definition of eGUI ASCII character.
Definition: d4d_types.h:280
void D4D_ToUpper(D4D_CHAR *s)
The function convert all small alpha characters to upper in string(terminated by zero) ...
Definition: d4d_extsrc.c:318
int(* D4DFILE_FSEEK)(D4D_FILEPTR p_file, long offset, int origin)
File seek eGUI function type.
Definition: d4d_extsrc.h:136
D4D_CHAR * D4D_StrCopyUnicode2Ascii(register D4D_CHAR *sd, register const D4D_WCHAR *ss)
The function copy string one string (UNICODE) to other one (STANDARD 8 bit)(terminated by zero) ...
Definition: d4d_extsrc.c:176
int D4D_CompareStrings(const D4D_CHAR *s1, const D4D_CHAR *s2)
The function copare two strings (terminated by zero)
Definition: d4d_extsrc.c:257
int(* D4DLOCALE_TRANSLATE_STR)(const D4D_TCHAR *originTxt, D4D_TCHAR *newTxt, int offset, int size)
String translate function for customizing strings.
Definition: d4d_extsrc.h:164
const D4DFILE_FUNCTIONS d4d_extsrcFile
D4DLOCALE_TRANSLATE_STR D4DLOCALE_TranslateStr
Pointer to Translate String Function.
Definition: d4d_extsrc.h:190
D4DFILE_FOPEN D4DFILE_fopen
Pointer to File Open Function.
Definition: d4d_extsrc.h:179
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4DFILE_WRITE D4DFILE_write
Pointer to File Write Function.
Definition: d4d_extsrc.h:182
D4D_BOOL D4D_FileIsAbsolutePath(D4D_CHAR *pFileName)
void * D4D_FILEPTR
Type definition of eGUI file pointer.
Definition: d4d_types.h:298
int D4D_StrLen(register const D4D_CHAR *s)
The function returns length of string terminated by zero.
Definition: d4d_extsrc.c:128