FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/gpf/misc/tools.c @ 903:312778104f54
lcdemu started, compiles and runs w/o actual functionality
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 07 Sep 2015 08:34:37 +0000 |
parents | 397b22c607c8 |
children |
rev | line source |
---|---|
320
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 | File: tools.c |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 | Copyright 2002 Texas Instruments Berlin, AG |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 | All rights reserved. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 | This file is confidential and a trade secret of Texas |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 | Instruments Berlin, AG |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 | The receipt of or possession of this file does not convey |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 | any rights to reproduce or disclose its contents or to |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 | manufacture, use, or sell anything it may describe, in |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 | whole, or in part, without the specific written consent of |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 | Texas Instruments Berlin, AG. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 +----------------------------------------------------------------------------- |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 | Purpose : This module implements some format conversion functions. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 +----------------------------------------------------------------------------- |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 #ifndef __TOOLS_C__ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #define __TOOLS_C__ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 #endif |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 /*==== INCLUDES ===================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 #include "typedefs.h" |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 #include <string.h> |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 #include <ctype.h> |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 #include "vsi.h" |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 #include "tools.h" |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 /*==== TYPES ======================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 /*==== CONSTANTS ==================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 /*==== EXTERNALS ==================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 /*==== VARIABLES ==================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 /*==== FUNCTIONS ==================================================*/ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #ifndef RUN_INT_RAM |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 | Function : GetNextToken |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 | Description : Exract text until next separator. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 | Parameters : source - where to search |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 | token - destination for text |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 | seperator - sperator |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 | Return : string length of token |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 unsigned int GetNextToken (char *source, char *token, char const *seperators) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 unsigned int i, j, k, sep_len, src_len; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 BOOL sepFound = FALSE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 sep_len = strlen (seperators); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 src_len = strlen (source); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 i = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 j = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 k = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 do |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 j = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 sepFound = FALSE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 while (j < sep_len) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 if (source[i] EQ seperators[j]) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 sepFound = TRUE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 j++; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 if (sepFound) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 i++; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 while (i < src_len AND sepFound); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 sepFound = FALSE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 while (!sepFound AND i < src_len) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 j = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 while (!sepFound AND j < sep_len) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 if (source[i] EQ seperators[j]) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 sepFound = TRUE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 else |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 j++; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 if (!sepFound) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 token[k++] = source[i++]; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 token[k] = '\0'; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 return strlen (token); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 #endif |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 #ifndef RUN_FLASH |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 | Function : HexToASCII |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 | Description : Convert hexadecimal value to ASCII string. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 | Parameters : value - value to be converted |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 | *ptr - destination for string |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 | num - number of characters |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 | Return : pointer behind the end of string |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 char *HexToASCII (ULONG value, char *ptr, int num) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 UBYTE i; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 char v; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 ptr += (num-1); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 for (i=0; i<num ;i++) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 v = (char)(value & 0x000000f); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 value >>= 4; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 if (v > 9) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 v += ('A'-10); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 else |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 v += '0'; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 *ptr-- = v; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 return(ptr+num+1); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 #endif |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 #ifndef RUN_INT_RAM |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 | Function : ASCIIToHex |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 | Description : Convert ASCII string to hexadecimal value. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 | Parameters : *ptr - string to be converted |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 | num - number of characters |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 | Return : value |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 unsigned int ASCIIToHex (char *ptr, int num) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 unsigned int i; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 unsigned int result = 0; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 unsigned int len; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 char c; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 len = strlen(ptr); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 if ( len < (unsigned int)num ) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 num = (int)len; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 ptr += (num-1); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 for (i=0; i < (unsigned int)num; i++) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 if (isxdigit (*ptr) ) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 if (*ptr > '9') |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 c = *ptr-- - 'A' + 10; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 else |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 c = *ptr-- - '0'; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 /*lint -e701 suppress Info -- shift left of signed quantity */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 result += (c << (i*4)); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 /*lint +e701 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 return result; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 #endif |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 #ifndef RUN_FLASH |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 | Function : InsertString |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 | Description : write a string into the buffer. If the string has less than |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 | 'num' characters, spaces are added. |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 | Parameters : *string - string to be written |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 | *ptr - pointer to destination |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 | num - number of characters to be filled |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 | Return : pointer to next character |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 char *InsertString (char *string, char *ptr, int num) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 UBYTE i; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 BYTE end_detected = FALSE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 for (i=0;i<num;i++) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 if (end_detected) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 *ptr++ = ' '; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 else |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 if (string [i] == 0) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 end_detected = TRUE; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 *ptr++ = ' '; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 else |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 *ptr++ = string [i]; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 return(ptr); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 #endif |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 #ifndef RUN_INT_RAM |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 | Function : rm_path |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 | Description : remove path name from file name |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 | Parameters : *file - file name |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 | Return : file name without path information |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 | |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 +------------------------------------------------------------------------------ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 char *rm_path ( const char *file ) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 { |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 char *end; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 /* |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 * to avoid crashes in case the passed parameter file is a pointer to |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 * anywhere it is checked if file begins with a character that is allowed |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 * at the beginning of file/path names (any alpanumeric character, '.', '/', |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 * and '\') |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 */ |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 if ( isalpha(*file) == 0 && *file != '.' && *file != '/' && *file != '\\' ) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 return ((char*)"NO VALID FILENAME"); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 end = (char*)file + strlen(file); |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 while ((*end != 0x2f) && (*end != 0x5c) && (end >= (char*)file)) |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 end--; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 return end + 1; |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 } |
397b22c607c8
gsm-fw/gpf/misc/*.c: import from Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 #endif |