*/
-#include "config.h"
-
#include <stdlib.h>
#include <string.h>
#include "gsm-coding.h"
#ifdef WIN32
- #include <windows.h>
+ #include <windows.h>\r
#else
#include "devices/device.h"
-#endif
+#endif\r
/* 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 */
'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 <M.Kacer@sh.cvut.cz>
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},
};
#endif
-#ifndef UCLINUX
-
unsigned char EncodeWithDefaultAlphabet(unsigned char value)
{
unsigned char i;
return GSM_DefaultAlphabet[value];
}
-#endif /* UCLINUX */
-
-#ifdef UCLINUX
-static
-#endif /* UCLINUX */
wchar_t EncodeWithUnicodeAlphabet(unsigned char value)
{
wchar_t retval;
return retval;
}
-#ifdef UCLINUX
-static
-#endif /* UCLINUX */
unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
{
unsigned char retval;
#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] =
{
else return retval;
}
-#endif /* UCLINUX */
-
#endif
-#ifndef UCLINUX
-
void DecodeDefault (unsigned char* dest, const unsigned char* src, int len)
{
int i;
return;
}
-#endif /* UCLINUX */
-
void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len)
{
int i;
}
}
-#ifdef UCLINUX
-static
-#endif /* UCLINUX */
bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2)
{
u8 mychar1,mychar2,mychar3,mychar4;
- int j=0;
+ int j=0;\r
mychar1=((EncodeWithUnicodeAlphabet(mychar)>>8)&0xff);
mychar2=EncodeWithUnicodeAlphabet(mychar)&0xff;
while (true) {
if (mychar3==mychar1) {
if (mychar4+64>=mychar2) {
- *ret1=j+0xc2;
- *ret2=0x80+(mychar2-mychar4);
- return true;
+ *ret1=j+0xc2;\r
+ *ret2=0x80+(mychar2-mychar4);\r
+ return true;\r
}
}
if (mychar4==192) {
return false;
}
-#ifndef UCLINUX
-
void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
{
u8 mychar1, mychar2;
}
mychar2=mychar2+(mychar4-0x80);
wc = mychar2 | (mychar1 << 8);
- *ret=DecodeWithUnicodeAlphabet(wc);
+ *ret=DecodeWithUnicodeAlphabet(wc);\r
j=-1;
}
-#endif /* UCLINUX */
-
void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
{
int i,j=0,z;
dest[j++]=0;
}
-#ifndef UCLINUX
-
void DecodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
{
int i=0,j=0;
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 */