add IS_HEX_CHAR macro define

pull/37/head
yuqing 2017-07-06 10:47:03 +08:00
parent 0aa66e2823
commit b3c89b2316
4 changed files with 6 additions and 9 deletions

View File

@ -116,6 +116,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
#endif #endif
#define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) #define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F'))
#define IS_HEX_CHAR(ch) (IS_UPPER_HEX(ch) || (ch >= 'a' && ch <= 'f'))
#define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error") #define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error")
#if defined(OS_LINUX) #if defined(OS_LINUX)

View File

@ -1379,14 +1379,14 @@ static unsigned int crc_table[256] = {
crc = crc_table[(crc ^ *pKey) & 0xFF] ^ (crc >> 8); \ crc = crc_table[(crc ^ *pKey) & 0xFF] ^ (crc >> 8); \
} \ } \
int CRC32(void *key, const int key_len) int CRC32(const void *key, const int key_len)
{ {
CRC32_BODY(CRC32_XINIT) CRC32_BODY(CRC32_XINIT)
return crc ^ CRC32_XOROT; return crc ^ CRC32_XOROT;
} }
int CRC32_ex(void *key, const int key_len, \ int CRC32_ex(const void *key, const int key_len, \
const int init_value) const int init_value)
{ {
CRC32_BODY(init_value) CRC32_BODY(init_value)

View File

@ -350,8 +350,8 @@ int simple_hash(const void* key, const int key_len);
int simple_hash_ex(const void* key, const int key_len, \ int simple_hash_ex(const void* key, const int key_len, \
const int init_value); const int init_value);
int CRC32(void *key, const int key_len); int CRC32(const void *key, const int key_len);
int CRC32_ex(void *key, const int key_len, \ int CRC32_ex(const void *key, const int key_len, \
const int init_value); const int init_value);
#define CRC32_FINAL(crc) (crc ^ CRC32_XOROT) #define CRC32_FINAL(crc) (crc ^ CRC32_XOROT)

View File

@ -2113,11 +2113,6 @@ char *urldecode(const char *src, const int src_len, char *dest, int *dest_len)
char *urldecode_ex(const char *src, const int src_len, char *dest, int *dest_len) char *urldecode_ex(const char *src, const int src_len, char *dest, int *dest_len)
{ {
#define IS_HEX_CHAR(ch) \
((ch >= '0' && ch <= '9') || \
(ch >= 'a' && ch <= 'f') || \
(ch >= 'A' && ch <= 'F'))
#define HEX_VALUE(ch, value) \ #define HEX_VALUE(ch, value) \
if (ch >= '0' && ch <= '9') \ if (ch >= '0' && ch <= '9') \
{ \ { \