First version, development moved to 5110-connected machine
[gnokii.git] / common / gsm-coding.c
index 7baaaa9..26c1e67 100644 (file)
@@ -8,6 +8,8 @@
 
 */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -24,6 +26,9 @@
 #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*/
-    unsigned char unicode_table[][3] =
+    static 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;
@@ -137,6 +146,11 @@ 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;
@@ -157,6 +171,9 @@ wchar_t EncodeWithUnicodeAlphabet(unsigned char value)
        return retval;
 }
 
+#ifdef UCLINUX
+static
+#endif /* UCLINUX */
 unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
 {
        unsigned char retval;
@@ -177,6 +194,8 @@ 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] =
   {
@@ -259,8 +278,12 @@ 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;
@@ -279,6 +302,8 @@ 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;
@@ -304,6 +329,9 @@ 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;
@@ -334,6 +362,8 @@ bool EncodeWithUTF8Alphabet(u8 mychar, u8 *ret1, u8 *ret2)
       return false;
 }
 
+#ifndef UCLINUX
+
 void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
 {
     u8 mychar1, mychar2;
@@ -356,6 +386,8 @@ void DecodeWithUTF8Alphabet(u8 mychar3, u8 mychar4, u8 *ret)
     j=-1;
 }
 
+#endif /* UCLINUX */
+
 void EncodeUTF8 (unsigned char* dest, const unsigned char* src, int len)
 {
        int i,j=0,z;
@@ -373,6 +405,8 @@ 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;
@@ -471,13 +505,12 @@ void EncodeBCD (unsigned char* dest, const unsigned char* src, int len, bool fil
 
 unsigned char EncodeWithBCDAlphabet(int value)
 {
-  div_t division;
-
-  division=div(value,10);
-  return ( ( (value-division.quot*10) & 0x0f) << 4) | (division.quot & 0xf);
+  return ((value%10) << 4) | ((value/10) & 0xf);
 }
 
 int DecodeWithBCDAlphabet(unsigned char value)
 {
        return 10*(value & 0x0f)+(value >> 4);
 }
+
+#endif /* UCLINUX */