| 181 | static unsigned int Crc32Table[256] = {0}; |
| 182 | |
| 183 | static unsigned int getCrc32(uint8_t *data, uint32_t len) { |
| 184 | int i, j; |
| 185 | unsigned int Crc; |
| 186 | if (Crc32Table[0] == 0) { //create CRC32 table |
| 187 | for (i = 0; i < 256; i++) { |
| 188 | Crc = i; |
| 189 | for (j = 0; j < 8; j++) { |
| 190 | if (Crc & 1) |
| 191 | Crc = (Crc >> 1) ^ 0xEDB88320; |
| 192 | else |
| 193 | Crc >>= 1; |
| 194 | } |
| 195 | Crc32Table[i] = Crc; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | Crc = 0xffffffff; |
| 200 | for (uint32_t i = 0; i < len; i++) { |
| 201 | Crc = (Crc >> 8) ^ Crc32Table[(Crc & 0xFF) ^ (data[i])]; |
| 202 | } |
| 203 | |
| 204 | Crc ^= 0xFFFFFFFF; |
| 205 | return Crc; |
| 206 | } |
| 207 | |
| 208 | static char* getVersion(const char* str, const char* delims) { |
| 209 | if (str == NULL || delims == NULL) { |
no outgoing calls
no test coverage detected