eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_extsrc.c
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 #include "d4d.h"
49 
50 #ifdef D4D_STD_STRING_H_INCLUDE
51  #include D4D_STD_STRING_H_INCLUDE
52 #endif
53 
54 #if (D4D_EXTSRC_TEXT_ENABLE != D4D_FALSE) || (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE)
56 #endif
57 
58 #if (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE)
59 
60 /******************************************************************************
61 * D4D External resources functions headers
62 *
63 */
67 /**************************************************************************/
74 {
75  int i;
76 
77  if(pFileName == NULL)
78  return NULL;
79 
80 
81  i = D4D_StrLen(pFileName);
82 
83  if(i == 0)
84  return NULL;
85 
86  i--; // decrement index to point on last char
87 
88  while((pFileName[i] >= ' ') && (pFileName[i] != '.'))
89  {
90  i--;
91  };
92 
93  if(pFileName[i] == '.')
94  return &pFileName[i+1];
95  else
96  return NULL;
97 }
98 
99 /**************************************************************************/
106 {
107  Byte i;
108 
109  if(!pFileName || !pFileName[0])
110  return D4D_FALSE;
111 
112  for(i=1; i<=D4D_DRIVE_MAX_STRLEN; ++i) {
113  if(pFileName[i] == ':')
114  return D4D_TRUE;
115  }
116 
117  return D4D_FALSE;
118 }
119 #endif
120 
121 /**************************************************************************/
128 int D4D_StrLen(register const D4D_CHAR *s)
129 {
130 #ifndef D4D_STD_STRING_H_INCLUDE
131  register int n;
132 
133  if(!s)
134  return 0;
135 
136  n = 0;
137  while (*s++)
138  n++;
139  return(n);
140 #else
141  // Standard system implementation
142  return strlen(s);
143 #endif
144 }
145 
146 /**************************************************************************/
154 D4D_CHAR* D4D_StrCopy(register D4D_CHAR *sd, register const D4D_CHAR *ss)
155 {
156 #ifndef D4D_STD_STRING_H_INCLUDE
157  register D4D_CHAR *s = sd;
158 
159  while (*sd++ = *ss++)
160  ;
161 
162  return s;
163 #else
164  // Standard system implementation
165  return strcpy(sd, ss);
166 #endif
167 }
168 
169 /**************************************************************************/
176 D4D_CHAR* D4D_StrCopyUnicode2Ascii(register D4D_CHAR *sd, register const D4D_WCHAR *ss)
177 {
178  register D4D_CHAR *s = sd;
179 
180  while (*sd++ = (D4D_CHAR)*ss++)
181  ;
182 
183  return s;
184 }
185 
186 /**************************************************************************/
193 D4D_WCHAR* D4D_StrCopyAscii2Unicode(register D4D_WCHAR *sd, register const D4D_CHAR *ss)
194 {
195  register D4D_WCHAR *s = sd;
196 
197  while (*sd++ = (D4D_WCHAR)*ss++)
198  ;
199 
200  return s;
201 }
202 
203 /**************************************************************************/
211 D4D_CHAR* D4D_StrCat(register D4D_CHAR *sd, register const D4D_CHAR *ss)
212 {
213 #ifndef D4D_STD_STRING_H_INCLUDE
214  register D4D_CHAR *s = sd;
215 
216  while (*sd)
217  sd++;
218 
219  while ((*sd++ = *ss++))
220  ;
221 
222  return s;
223 #else
224  // Standard system implementation
225  return strcat(sd, ss);
226 #endif
227 }
228 
229 /**************************************************************************/
236 D4D_WCHAR* D4D_StrCatUnicode(register D4D_WCHAR *sd, register const D4D_WCHAR *ss)
237 {
238  register D4D_WCHAR *s = sd;
239 
240  while (*sd)
241  sd++;
242 
243  while (*sd++ = *ss++)
244  ;
245 
246  return s;
247 }
248 
249 /**************************************************************************/
257 int D4D_CompareStrings(const D4D_CHAR* s1, const D4D_CHAR* s2)
258 {
259 #ifndef D4D_STD_STRING_H_INCLUDE
260  D4D_CHAR val2 = *s2++;
261  while(val2)
262  {
263  if (*s1++ != val2)
264  {
265  if (s1[-1] < val2)
266  return -1;
267 
268  return 1;
269  }
270  val2 = *s2++;
271  }
272 
273  if (*s1) // if we get to here, then s2 terminated
274  return 1; // s1 is still going
275 
276  return 0; // they both terminated
277 #else
278  // Standard system implementation
279  return strcmp(s1, s2);
280 #endif
281 }
282 
283 /**************************************************************************/
291 {
292  D4D_WCHAR val2 = *s2++;
293 
294  while(val2)
295  {
296  if (*s1++ != val2)
297  {
298  if (s1[-1] < val2)
299  return -1;
300 
301  return 1;
302  }
303  val2 = *s2++;
304  }
305 
306  if (*s1) // if we get to here, then s2 terminated
307  return 1; // s1 is still going
308 
309  return 0; // they both terminated
310 }
311 
312 /**************************************************************************/
319 {
320  while(s && *s)
321  {
322  if((*s >= 'a') && (*s <= 'z'))
323  *s -= 'a' - 'A';
324 
325  s++;
326  }
327 }
328 
329 /**************************************************************************/
336 {
337  Byte temp[4];
338 
339  temp[3] = *((Byte *)&n);
340  temp[2] = ((Byte *)&n)[1];
341  temp[1] = ((Byte *)&n)[2];
342  temp[0] = ((Byte *)&n)[3];
343  return (*(LWord *)temp);
344 }
345 
346 /**************************************************************************/
353 {
354  Byte temp[2];
355 
356  temp[1] = *((Byte *)&n);
357  temp[0] = ((Byte *)&n)[1];
358  return (*(Word *)temp);
359 }
360 
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
#define D4D_FALSE
This is definition of boolean operation value in eGUI - FALSE.
Definition: d4d_types.h:104
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
#define D4D_TRUE
This is definition of boolean operation value in eGUI - TRUE.
Definition: d4d_types.h:106
D4D Driver main header file.
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
D4D Driver private header file.
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
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
#define D4D_EXTSRC_BUFF_SIZE
This macro is used to specify size of buffer that is using when external file support is enabled...
Definition: d4d_base.h:167
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
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
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
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
#define D4D_DRIVE_MAX_STRLEN
D4D_DRIVE_MAX_STRLEN constant default declaration (8)
Definition: d4d_extsrc.h:79
Byte d4d_extsrcBuffer[D4D_EXTSRC_BUFF_SIZE]
D4D driver - resistive touch screen driver function header file.
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4D_BOOL D4D_FileIsAbsolutePath(D4D_CHAR *pFileName)
int D4D_StrLen(register const D4D_CHAR *s)
The function returns length of string terminated by zero.
Definition: d4d_extsrc.c:128