summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/euroconverter.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/plugins/euroconverter.c b/apps/plugins/euroconverter.c
index f98fc27db8..0a01f3a1d6 100644
--- a/apps/plugins/euroconverter.c
+++ b/apps/plugins/euroconverter.c
@@ -48,6 +48,9 @@ static const char cfg_filename[] = "euroconverter.cfg";
48#define CFGFILE_VERSION 0 /* Current config file version */ 48#define CFGFILE_VERSION 0 /* Current config file version */
49#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */ 49#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
50 50
51/* typedef for simplifying usage of long long type */
52typedef long long int longlong_t;
53
51/*Pattern for the converter*/ 54/*Pattern for the converter*/
52static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */ 55static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */
53static unsigned char pattern_home[]={0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11, 0x1F}; /* Home icon*/ 56static unsigned char pattern_home[]={0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11, 0x1F}; /* Home icon*/
@@ -85,7 +88,7 @@ static int nb_digit[12]={
85 }; 88 };
86 89
87/* max euro to have home currency */ 90/* max euro to have home currency */
88static long long max_euro[12]={ 91static longlong_t max_euro[12]={
89 99999999000LL, /*FRF France 999 999.99 */ 92 99999999000LL, /*FRF France 999 999.99 */
90 99999999000LL, /*DEM Germany 999 999.99 */ 93 99999999000LL, /*DEM Germany 999 999.99 */
91 99999999000LL, /*ATS Austria 999 999.99 */ 94 99999999000LL, /*ATS Austria 999 999.99 */
@@ -102,7 +105,7 @@ static long long max_euro[12]={
102 105
103/* max home to have euro currency */ 106/* max home to have euro currency */
104/* 92233720300000 Limitation due to the max capacity of long long (2^63)*/ 107/* 92233720300000 Limitation due to the max capacity of long long (2^63)*/
105static long long max_curr[12]={ 108static longlong_t max_curr[12]={
106 99999999000LL, /*FRF France 152449.02 */ 109 99999999000LL, /*FRF France 152449.02 */
107 99999999000LL, /*DEM Germany 511291.88 */ 110 99999999000LL, /*DEM Germany 511291.88 */
108 99999999000LL, /*ATS Austria 72672.83 */ 111 99999999000LL, /*ATS Austria 72672.83 */
@@ -152,9 +155,10 @@ static char *currency_str[12] = {
152 "Greece" 155 "Greece"
153}; 156};
154 157
158
155static int country; /*Country selected*/ 159static int country; /*Country selected*/
156static int cur_pos; /*Cursor position*/ 160static int cur_pos; /*Cursor position*/
157static long long inc; 161static longlong_t inc;
158 162
159/* Persistent settings */ 163/* Persistent settings */
160static struct configdata config[] = { 164static struct configdata config[] = {
@@ -163,23 +167,23 @@ static struct configdata config[] = {
163 167
164 168
165/* 64bits*64 bits with 5 digits after the . */ 169/* 64bits*64 bits with 5 digits after the . */
166static long long mul(long long a, long long b) 170static longlong_t mymul(longlong_t a, longlong_t b)
167{ 171{
168 return((a*b)/100000); 172 return((a*b)/100000LL);
169} 173}
170 174
171 175
172/* 64bits/64 bits with 5 digits after the . */ 176/* 64bits/64 bits with 5 digits after the . */
173static long long mydiv(long long a, long long b) 177static longlong_t mydiv(longlong_t a, longlong_t b)
174{ 178{
175 return((a*100000)/b); 179 return((a*100000LL)/b);
176} 180}
177 181
178 182
179/* 123.45=12345000 split => i=123 f=45000*/ 183/* 123.45=12345000 split => i=123 f=45000*/
180static void split(long long v, long long* i, long long* f) 184static void split(longlong_t v, longlong_t* i, longlong_t* f)
181{ 185{
182 long long t; 186 longlong_t t;
183 187
184 t=v/100000LL; 188 t=v/100000LL;
185 (*i)=t; 189 (*i)=t;
@@ -188,10 +192,10 @@ static void split(long long v, long long* i, long long* f)
188 192
189 193
190/* result=10^n */ 194/* result=10^n */
191static long long pow10(int n) 195static longlong_t pow10(int n)
192{ 196{
193 int i; 197 int i;
194 long long r; 198 longlong_t r;
195 199
196 r=1; 200 r=1;
197 for (i=0;i<n;i++) 201 for (i=0;i<n;i++)
@@ -201,10 +205,10 @@ static long long pow10(int n)
201 205
202 206
203/* round the i.f at n digit after the . */ 207/* round the i.f at n digit after the . */
204static void round(long long* i, long long* f, int n) 208static void round(longlong_t* i, longlong_t* f, int n)
205{ 209{
206 210
207 long long m; 211 longlong_t m;
208 int add=0; 212 int add=0;
209 213
210 m=(int)pow10(5-n-1); 214 m=(int)pow10(5-n-1);
@@ -231,10 +235,10 @@ static void round(long long* i, long long* f, int n)
231 pos: false : first line 235 pos: false : first line
232 : true : second line 236 : true : second line
233*/ 237*/
234static void display(long long euro, long long home, bool pos) 238static void display(longlong_t euro, longlong_t home, bool pos)
235{ 239{
236 char c1,c2; 240 char c1,c2;
237 long long i,f; 241 longlong_t i,f;
238 unsigned char str[20]; 242 unsigned char str[20];
239 unsigned char s1[20]; 243 unsigned char s1[20];
240 unsigned char s2[20]; 244 unsigned char s2[20];
@@ -398,7 +402,7 @@ static void euro_exit(void *parameter)
398enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 402enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
399{ 403{
400 bool end, pos; 404 bool end, pos;
401 long long e,h,old_e,old_h; 405 longlong_t e,h,old_e,old_h;
402 int button; 406 int button;
403 407
404 /* this macro should be called as the first thing you do in the plugin. 408 /* this macro should be called as the first thing you do in the plugin.
@@ -598,7 +602,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
598 } 602 }
599 /*Display*/ 603 /*Display*/
600 if (!pos) /*Euro>home*/ 604 if (!pos) /*Euro>home*/
601 h=mul(e,currency[country]); 605 h=mymul(e,currency[country]);
602 else /*Home>euro*/ 606 else /*Home>euro*/
603 e=mydiv(h,currency[country]); 607 e=mydiv(h,currency[country]);
604 display(e,h,pos); 608 display(e,h,pos);