summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/misc/coding/coding.h
Unidiff
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.h27
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,61 +1,68 @@
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);
54 61
55 bool EncodeUTF8 (unsigned char *dest, const unsigned char *src); 62 bool EncodeUTF8 (unsigned char *dest, const unsigned char *src);
56 void DecodeUTF8 (unsigned char *dest, const unsigned char *src, int len); 63 void DecodeUTF8 (unsigned char *dest, const unsigned char *src, int len);
57 64
58/* ------------------------------- BASE64 ---------------------------------- */ 65/* ------------------------------- BASE64 ---------------------------------- */
59 void EncodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length); 66 void EncodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length);
60 int DecodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length); 67 int DecodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length);
61 68
@@ -65,69 +72,77 @@ void EncodeHexBin (unsigned char *dest, const unsigned char *src, int len);
65 72
66/* ----------------------------- HexUnicode -------------------------------- */ 73/* ----------------------------- HexUnicode -------------------------------- */
67 void DecodeHexUnicode (unsigned char *dest, const unsigned char *src, int len); 74 void DecodeHexUnicode (unsigned char *dest, const unsigned char *src, int len);
68 void EncodeHexUnicode (unsigned char *dest, const unsigned char *src, int len); 75 void EncodeHexUnicode (unsigned char *dest, const unsigned char *src, int len);
69 76
70/* ---------------------- DefaultAlphabet for SMS -------------------------- */ 77/* ---------------------- DefaultAlphabet for SMS -------------------------- */
71 void EncodeDefault (unsigned char *dest, const unsigned char *src, int *len, bool UseExtensions, unsigned char *ExtraAlphabet); 78 void EncodeDefault (unsigned char *dest, const unsigned char *src, int *len, bool UseExtensions, unsigned char *ExtraAlphabet);
72 void DecodeDefault (unsigned char *dest, const unsigned char *src, int len, bool UseExtensions, unsigned char *ExtraAlphabet); 79 void DecodeDefault (unsigned char *dest, const unsigned char *src, int len, bool UseExtensions, unsigned char *ExtraAlphabet);
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 */
85typedef enum { 92typedef 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
107void BufferAlign (unsigned char *Destination, int *CurrentBit); 114void BufferAlign (unsigned char *Destination, int *CurrentBit);
108void BufferAlignNumber(int *CurrentBit); 115void 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);
111void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char Source, int BitsToProcess); 118void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char Source, int BitsToProcess);
112 119
113void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess); 120void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess);
114void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess); 121void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess);
115void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess); 122void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess);
116 123
117int GetBit (unsigned char *Buffer, int BitNum); 124int GetBit (unsigned char *Buffer, int BitNum);
118int SetBit (unsigned char *Buffer, int BitNum); 125int SetBit (unsigned char *Buffer, int BitNum);
119int ClearBit (unsigned char *Buffer, int BitNum); 126int 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
125bool 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
127void 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
137char *EncodeSpecialChars(unsigned char *buffer);
138char *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 */