author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/misc/coding/coding.h | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2 |
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/misc/coding/coding.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/misc/coding/coding.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gammu/emb/common/misc/coding/coding.h b/gammu/emb/common/misc/coding/coding.h index d0c334d..4cf0038 100644 --- a/gammu/emb/common/misc/coding/coding.h +++ b/gammu/emb/common/misc/coding/coding.h | |||
@@ -1,53 +1,60 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek and others */ | 1 | /* (c) 2002-2004 by Marcin Wiacek and others */ |
2 | 2 | ||
3 | #ifndef __coding_h | 3 | #ifndef __coding_h |
4 | #define __coding_h | 4 | #define __coding_h |
5 | 5 | ||
6 | #if defined(_MSC_VER) && defined(__cplusplus) | ||
7 | extern "C" { | ||
8 | #endif | ||
9 | |||
6 | #include <stdlib.h> | 10 | #include <stdlib.h> |
7 | 11 | ||
8 | #include "../misc.h" | 12 | #include "../misc.h" |
9 | 13 | ||
10 | #ifdef __OpenBSD__ | 14 | #ifdef __OpenBSD__ |
11 | typedef int wint_t; | 15 | typedef int wint_t; |
12 | #endif | 16 | #endif |
13 | 17 | ||
14 | /* ---------------------------- Unicode ------------------------------------ */ | 18 | /* ---------------------------- Unicode ------------------------------------ */ |
15 | bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num); | 19 | bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num); |
16 | unsigned char *mystrstr (unsigned const char *haystack, unsigned const char *needle); | 20 | unsigned char *mywstrstr (unsigned const char *haystack, unsigned const char *needle); |
17 | bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num); | 21 | bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num); |
18 | bool myiswspace (unsigned const char *src); | 22 | bool myiswspace (unsigned const char *src); |
19 | int mytowlower (wchar_t c); | 23 | int mytowlower (wchar_t c); |
20 | 24 | ||
21 | unsigned int EncodeWithUnicodeAlphabet(const unsigned char *value, wchar_t *dest); | 25 | unsigned int EncodeWithUnicodeAlphabet(const unsigned char *value, wchar_t *dest); |
22 | unsigned int DecodeWithUnicodeAlphabet(wchar_t value, unsigned char *dest); | 26 | unsigned int DecodeWithUnicodeAlphabet(wchar_t value, unsigned char *dest); |
23 | 27 | ||
24 | unsigned int UnicodeLength (const unsigned char *str); | 28 | unsigned int UnicodeLength (const unsigned char *str); |
25 | unsigned char *DecodeUnicodeString (const unsigned char *src); | 29 | unsigned char *DecodeUnicodeString (const unsigned char *src); |
26 | unsigned char *DecodeUnicodeConsole (const unsigned char *src); | 30 | unsigned char *DecodeUnicodeConsole (const unsigned char *src); |
27 | void DecodeUnicode (const unsigned char *src, unsigned char *dest); | 31 | void DecodeUnicode (const unsigned char *src, unsigned char *dest); |
28 | void EncodeUnicode (unsigned char *dest, const unsigned char *src, int len); | 32 | void EncodeUnicode (unsigned char *dest, const unsigned char *src, int len); |
29 | 33 | ||
30 | void CopyUnicodeString (unsigned char *Dest, unsigned char *Source); | 34 | void CopyUnicodeString (unsigned char *Dest, unsigned char *Source); |
31 | void ReverseUnicodeString (unsigned char *String); | 35 | void ReverseUnicodeString (unsigned char *String); |
32 | 36 | ||
33 | void ReadUnicodeFile (unsigned char *Dest, unsigned char *Source); | 37 | void ReadUnicodeFile (unsigned char *Dest, unsigned char *Source); |
34 | 38 | ||
35 | void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); | 39 | void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); |
36 | void EncodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); | 40 | void EncodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); |
37 | 41 | ||
42 | char *EncodeUnicodeSpecialChars(unsigned char *buffer); | ||
43 | char *DecodeUnicodeSpecialChars(unsigned char *buffer); | ||
44 | |||
38 | /* ------------------------------- BCD ------------------------------------- */ | 45 | /* ------------------------------- BCD ------------------------------------- */ |
39 | unsigned char EncodeWithBCDAlphabet (int value); | 46 | unsigned char EncodeWithBCDAlphabet (int value); |
40 | int DecodeWithBCDAlphabet (unsigned char value); | 47 | int DecodeWithBCDAlphabet (unsigned char value); |
41 | 48 | ||
42 | void DecodeBCD (unsigned char *dest, const unsigned char *src, int len); | 49 | void DecodeBCD (unsigned char *dest, const unsigned char *src, int len); |
43 | void EncodeBCD (unsigned char *dest, const unsigned char *src, int len, bool fill); | 50 | void EncodeBCD (unsigned char *dest, const unsigned char *src, int len, bool fill); |
44 | 51 | ||
45 | /* ------------------------------ UTF7 ------------------------------------- */ | 52 | /* ------------------------------ UTF7 ------------------------------------- */ |
46 | void DecodeUTF7 (unsigned char *dest, const unsigned char *src, int len); | 53 | void DecodeUTF7 (unsigned char *dest, const unsigned char *src, int len); |
47 | 54 | ||
48 | /* ------------------------------ UTF8 ------------------------------------- */ | 55 | /* ------------------------------ UTF8 ------------------------------------- */ |
49 | wchar_t DecodeWithUTF8Alphabet (unsigned char mychar3, unsigned char mychar4); | 56 | wchar_t DecodeWithUTF8Alphabet (unsigned char mychar3, unsigned char mychar4); |
50 | bool EncodeWithUTF8Alphabet (unsigned char mychar1, unsigned char mychar2, unsigned char *ret1, unsigned char *ret2); | 57 | bool EncodeWithUTF8Alphabet (unsigned char mychar1, unsigned char mychar2, unsigned char *ret1, unsigned char *ret2); |
51 | 58 | ||
52 | bool EncodeUTF8QuotedPrintable(unsigned char *dest, const unsigned char *src); | 59 | bool EncodeUTF8QuotedPrintable(unsigned char *dest, const unsigned char *src); |
53 | void DecodeUTF8QuotedPrintable(unsigned char *dest, const unsigned char *src, int len); | 60 | void DecodeUTF8QuotedPrintable(unsigned char *dest, const unsigned char *src, int len); |
@@ -73,61 +80,69 @@ void DecodeDefault (unsigned char *dest, const unsigned char *src, int len, b | |||
73 | void FindDefaultAlphabetLen (const unsigned char *src, int *srclen, int *smslen, int maxlen); | 80 | void FindDefaultAlphabetLen (const unsigned char *src, int *srclen, int *smslen, int maxlen); |
74 | 81 | ||
75 | int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output, int length); | 82 | int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output, int length); |
76 | int GSM_UnpackEightBitsToSeven(int offset, int in_length, int out_length, | 83 | int GSM_UnpackEightBitsToSeven(int offset, int in_length, int out_length, |
77 | unsigned char *input, unsigned char *output); | 84 | unsigned char *input, unsigned char *output); |
78 | 85 | ||
79 | /* ----------------- Phone numbers according to GSM specs ------------------ */ | 86 | /* ----------------- Phone numbers according to GSM specs ------------------ */ |
80 | 87 | ||
81 | /** | 88 | /** |
82 | * Enum to handle types of phones numbers like | 89 | * Enum to handle types of phones numbers like |
83 | * specified in GSM 03.40 section 9.1.2.5 | 90 | * specified in GSM 03.40 section 9.1.2.5 |
84 | */ | 91 | */ |
85 | typedef enum { | 92 | typedef enum { |
86 | /** | 93 | /** |
87 | * Unknown number type | 94 | * Unknown number type |
88 | */ | 95 | */ |
89 | NUMBER_UNKNOWN = 0x81, | 96 | NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN = 0x81, |
90 | /** | 97 | /** |
91 | * International number (full number with code of country) | 98 | * International number (full number with code of country) |
92 | */ | 99 | */ |
93 | NUMBER_INTERNATIONAL= 0x91, | 100 | NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN= 0x91, |
94 | /** | 101 | /** |
95 | * Alphanumeric number (with chars too) | 102 | * Alphanumeric number (with chars too) |
96 | */ | 103 | */ |
97 | NUMBER_ALPHANUMERIC= 0xD0 | 104 | NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN= 0xD0 |
98 | 105 | ||
99 | /* specification give also other values */ | 106 | /* specification give also other values */ |
100 | } GSM_NumberType; | 107 | } GSM_NumberType; |
101 | 108 | ||
102 | void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, bool semioctet); | 109 | void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, bool semioctet); |
103 | int GSM_PackSemiOctetNumber (unsigned char *Number, unsigned char *Output, bool semioctet); | 110 | int GSM_PackSemiOctetNumber (unsigned char *Number, unsigned char *Output, bool semioctet); |
104 | 111 | ||
105 | /* ---------------------------- Bits --------------------------------------- */ | 112 | /* ---------------------------- Bits --------------------------------------- */ |
106 | 113 | ||
107 | void BufferAlign (unsigned char *Destination, int *CurrentBit); | 114 | void BufferAlign (unsigned char *Destination, int *CurrentBit); |
108 | void BufferAlignNumber(int *CurrentBit); | 115 | void BufferAlignNumber(int *CurrentBit); |
109 | 116 | ||
110 | void AddBuffer (unsigned char *Destination, int *CurrentBit, unsigned char *Source, int BitsToProcess); | 117 | void AddBuffer (unsigned char *Destination, int *CurrentBit, unsigned char *Source, int BitsToProcess); |
111 | void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char Source, int BitsToProcess); | 118 | void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char Source, int BitsToProcess); |
112 | 119 | ||
113 | void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess); | 120 | void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess); |
114 | void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess); | 121 | void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess); |
115 | void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess); | 122 | void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess); |
116 | 123 | ||
117 | int GetBit (unsigned char *Buffer, int BitNum); | 124 | int GetBit (unsigned char *Buffer, int BitNum); |
118 | int SetBit (unsigned char *Buffer, int BitNum); | 125 | int SetBit (unsigned char *Buffer, int BitNum); |
119 | int ClearBit (unsigned char *Buffer, int BitNum); | 126 | int ClearBit (unsigned char *Buffer, int BitNum); |
120 | 127 | ||
121 | /* ---------------------------- Other -------------------------------------- */ | 128 | /* ---------------------------- Other -------------------------------------- */ |
122 | 129 | ||
123 | void StringToDouble(char *text, double *d); | 130 | void StringToDouble(char *text, double *d); |
124 | 131 | ||
125 | bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num); | 132 | bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num); |
133 | char *mystrcasestr (unsigned const char *a, unsigned const char *b); | ||
126 | 134 | ||
127 | void MyGetLine(unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen); | 135 | void MyGetLine (unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen); |
136 | |||
137 | char *EncodeSpecialChars(unsigned char *buffer); | ||
138 | char *DecodeSpecialChars(unsigned char *buffer); | ||
139 | |||
140 | #if defined(_MSC_VER) && defined(__cplusplus) | ||
141 | } | ||
142 | #endif | ||
128 | 143 | ||
129 | #endif | 144 | #endif |
130 | 145 | ||
131 | /* How should editor hadle tabs in this file? Add editor commands here. | 146 | /* How should editor hadle tabs in this file? Add editor commands here. |
132 | * vim: noexpandtab sw=8 ts=8 sts=8: | 147 | * vim: noexpandtab sw=8 ts=8 sts=8: |
133 | */ | 148 | */ |