TS-E+ базовая библиотека.
libTSE+
 Указатель Классы Функции Переменные Определения типов
utils.h
1 /*
2  * utils.h
3  *
4  * Created on: 14 мая 2015 г.
5  * Author: nick
6  */
7 
8 #ifndef UTILS_H_
9 #define UTILS_H_
10 
11 #include <stdint.h>
12 #include <string.h>
13 
17 class Encoder {
18 public:
19  static void url_decode(char* parameter) {
20  char high_nibble;
21  char low_nibble;
22  while (parameter[0]!=0) {
23  if (parameter[0]=='+')
24  parameter[0]=' ';
25  else if (parameter[0]=='%') {
26  // convert the hexadecimal number that follows the "%" to char
27  if (parameter[1]<='9')
28  high_nibble=parameter[1]-'0';
29  else
30  high_nibble=parameter[1]-'A'+10;
31  if (parameter[2]<='9')
32  low_nibble=parameter[2]-'0';
33  else
34  low_nibble=parameter[2]-'A'+10;
35  char c=(high_nibble<<4)+low_nibble;
36  // replace the "%" char by the new character
37  parameter[0]=c;
38  //shift the remaining string 2 characters forward.
39  memmove(parameter+1,parameter+3,strlen(parameter+3)+1);
40  }
41  else if (parameter[0]=='&') {
42  parameter[0]=0;
43  break;
44  }
45  parameter++;
46  }
47  }
48 };
52 class Base64 {
53 private:
54  char *bufcoded;
55 public:
56  Base64(char *buf) : bufcoded(buf) {}
57  size_t endodedLen();
58  size_t encode(char *);
59  size_t decodedLen();
60  size_t decode(char *);
61 };
62 
66 class CRC {
67 public:
68  static uint8_t CRC8(void *,size_t);
69  static uint16_t CRC16(void *,size_t,const uint16_t);
70  static uint32_t CRC32(void *,size_t,const uint32_t);
71 };
72 
73 #endif /* UTILS_H_ */
Definition: utils.h:17
Definition: utils.h:66
Definition: utils.h:52