util
This commit is contained in:
parent
1398172370
commit
869d3c1742
|
@ -13,18 +13,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_UTIL_H
|
||||
#define _TD_UTIL_UTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef _TD_UTIL_UTIL_H_
|
||||
#define _TD_UTIL_UTIL_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tcrc32c.h"
|
||||
#include "tdef.h"
|
||||
#include "tmd5.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t strdequote(char *src);
|
||||
int32_t strndequote(char *dst, const char *z, int32_t len);
|
||||
int32_t strRmquote(char *z, int32_t len);
|
||||
|
@ -60,14 +60,14 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
|||
tMD5Update(&context, inBuf, (unsigned int)len);
|
||||
tMD5Final(&context);
|
||||
|
||||
sprintf(target, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1], context.digest[2],
|
||||
context.digest[3], context.digest[4], context.digest[5], context.digest[6], context.digest[7],
|
||||
context.digest[8], context.digest[9], context.digest[10], context.digest[11], context.digest[12],
|
||||
context.digest[13], context.digest[14], context.digest[15]);
|
||||
sprintf(target, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0],
|
||||
context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5],
|
||||
context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10],
|
||||
context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_UTIL_H*/
|
||||
#endif /*_TD_UTIL_UTIL_H_*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include "tdef.h"
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tutil.h"
|
||||
|
||||
int32_t strdequote(char *z) {
|
||||
if (z == NULL) {
|
||||
|
@ -168,11 +168,11 @@ char **strsplit(char *z, const char *delim, int32_t *num) {
|
|||
|
||||
char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote) {
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
|
||||
// skip the needle in quote, jump to the end of quoted string
|
||||
if (skipquote && (haystack[i] == '\'' || haystack[i] == '"')) {
|
||||
char quote = haystack[i++];
|
||||
while(i < len && haystack[i++] != quote);
|
||||
while (i < len && haystack[i++] != quote)
|
||||
;
|
||||
if (i >= len) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -405,7 +405,8 @@ char *taosIpStr(uint32_t ipInt) {
|
|||
static int32_t ipStrIndex = 0;
|
||||
|
||||
char *ipStr = ipStrArray[(ipStrIndex++) % 3];
|
||||
//sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
|
||||
// sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt
|
||||
// >> 24));
|
||||
sprintf(ipStr, "%u.%u.%u.%u", ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
|
||||
return ipStr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue