X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fgsm-coding.c;h=7baaaa929ad8d3422c6fe4b208251ec76f756b90;hp=52f0105919cef22f1483a8e72c94271511e8d672;hb=0484268a27be1ab830d087847d830bc0ec734016;hpb=43f66b7662ed5c83d1cfefb84b122499b08675c3 diff --git a/common/gsm-coding.c b/common/gsm-coding.c index 52f0105..7baaaa9 100644 --- a/common/gsm-coding.c +++ b/common/gsm-coding.c @@ -8,8 +8,6 @@ */ -#include "config.h" - #include #include @@ -17,18 +15,15 @@ #include "gsm-coding.h" #ifdef WIN32 - #include + #include #else #include "devices/device.h" -#endif +#endif /* Coding functions */ #define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128 #ifndef USE_NLS - -#ifndef UCLINUX - static unsigned char GSM_DefaultAlphabet[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS] = { /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */ @@ -58,15 +53,13 @@ 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0 }; -#endif /* UCLINUX */ - #ifndef WIN32 /*Simple UNICODE decoding and encoding from/to iso-8859-2 First version prepared by Martin Kacer Following table contains triplets: first unicode byte, second unicode byte, iso-8859-2 character*/ - static unsigned char unicode_table[][3] = + unsigned char unicode_table[][3] = { /* C< D< E< N< R< S< T< Uo Z< */ {0x01, 0x0C, 0xC8}, {0x01, 0x0E, 0xCF}, {0x01, 0x1A, 0xCC}, @@ -126,8 +119,6 @@ }; #endif -#ifndef UCLINUX - unsigned char EncodeWithDefaultAlphabet(unsigned char value) { unsigned char i; @@ -146,11 +137,6 @@ unsigned char DecodeWithDefaultAlphabet(unsigned char value) return GSM_DefaultAlphabet[value]; } -#endif /* UCLINUX */ - -#ifdef UCLINUX -static -#endif /* UCLINUX */ wchar_t EncodeWithUnicodeAlphabet(unsigned char value) { wchar_t retval; @@ -171,9 +157,6 @@ wchar_t EncodeWithUnicodeAlphabet(unsigned char value) return retval; } -#ifdef UCLINUX -static -#endif /* UCLINUX */ unsigned char DecodeWithUnicodeAlphabet(wchar_t value) { unsigned char retval; @@ -194,8 +177,6 @@ unsigned char DecodeWithUnicodeAlphabet(wchar_t value) #else -#ifndef UCLINUX - /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */ unsigned char GSM_DefaultAlphabetUnicode[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS+1][2] = { @@ -278,12 +259,8 @@ unsigned char DecodeWithUnicodeAlphabet(wchar_t value) else return retval; } -#endif /* UCLINUX */ - #endif -#ifndef UCLINUX - void DecodeDefault (unsigned char* dest, const unsigned char* src, int len) { int i; @@ -302,8 +279,6 @@ void EncodeDefault (unsigned char* dest, const unsigned char* src, int len) return; } -#endif /* UCLINUX */ - void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len) { int i; @@ -329,13 +304,10 @@ void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len) } } -#ifdef UCLINUX -static -#endif /* UCLINUX */ bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2) { u8 mychar1,mychar2,mychar3,mychar4; - int j=0; + int j=0; mychar1=((EncodeWithUnicodeAlphabet(mychar)>>8)&0xff); mychar2=EncodeWithUnicodeAlphabet(mychar)&0xff; @@ -345,9 +317,9 @@ bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2) while (true) { if (mychar3==mychar1) { if (mychar4+64>=mychar2) { - *ret1=j+0xc2; - *ret2=0x80+(mychar2-mychar4); - return true; + *ret1=j+0xc2; + *ret2=0x80+(mychar2-mychar4); + return true; } } if (mychar4==192) { @@ -362,8 +334,6 @@ bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2) return false; } -#ifndef UCLINUX - void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret) { u8 mychar1, mychar2; @@ -382,12 +352,10 @@ void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret) } mychar2=mychar2+(mychar4-0x80); wc = mychar2 | (mychar1 << 8); - *ret=DecodeWithUnicodeAlphabet(wc); + *ret=DecodeWithUnicodeAlphabet(wc); j=-1; } -#endif /* UCLINUX */ - void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len) { int i,j=0,z; @@ -405,8 +373,6 @@ void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len) dest[j++]=0; } -#ifndef UCLINUX - void DecodeUTF8 (unsigned char* dest, const unsigned char* src, int len) { int i=0,j=0; @@ -505,12 +471,13 @@ void EncodeBCD (unsigned char* dest, const unsigned char* src, int len, bool fil unsigned char EncodeWithBCDAlphabet(int value) { - return ((value%10) << 4) | ((value/10) & 0xf); + div_t division; + + division=div(value,10); + return ( ( (value-division.quot*10) & 0x0f) << 4) | (division.quot & 0xf); } int DecodeWithBCDAlphabet(unsigned char value) { return 10*(value & 0x0f)+(value >> 4); } - -#endif /* UCLINUX */