TDengine/include/util/tutil.h

60 lines
1.9 KiB
C
Raw Normal View History

2019-07-11 08:36:16 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2021-10-04 12:42:53 +00:00
#ifndef _TD_UTIL_UTIL_H
#define _TD_UTIL_UTIL_H
2019-07-11 08:36:16 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2019-11-07 10:12:26 +00:00
#include "os.h"
#include "tmd5.h"
2019-07-11 08:36:16 +00:00
#include "tcrc32c.h"
2021-10-04 12:42:53 +00:00
#include "tdef.h"
2019-07-11 08:36:16 +00:00
int32_t strdequote(char *src);
int32_t strndequote(char *dst, const char* z, int32_t len);
2021-06-04 08:21:25 +00:00
int32_t strRmquote(char *z, int32_t len);
2020-07-28 06:40:55 +00:00
size_t strtrim(char *src);
char * strnchr(char *haystack, char needle, int32_t len, bool skipquote);
char ** strsplit(char *src, const char *delim, int32_t *num);
char * strtolower(char *dst, const char *src);
char * strntolower(char *dst, const char *src, int32_t n);
char * strntolower_s(char *dst, const char *src, int32_t n);
2019-07-11 08:36:16 +00:00
int64_t strnatoi(char *num, int32_t len);
2020-07-28 06:40:55 +00:00
char * strbetween(char *string, char *begin, char *end);
char * paGetToken(char *src, char **token, int32_t *tokenLen);
2019-07-11 08:36:16 +00:00
int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]);
int32_t taosHexStrToByteArray(char hexstr[], char bytes[]);
2020-07-28 06:40:55 +00:00
char * taosIpStr(uint32_t ipInt);
uint32_t ip2uint(const char *const ip_addr);
2019-09-12 14:42:28 +00:00
2021-10-04 12:42:53 +00:00
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
MD5_CTX context;
MD5Init(&context);
2020-08-05 09:01:08 +00:00
MD5Update(&context, inBuf, (unsigned int)inLen);
MD5Final(&context);
2021-10-04 12:42:53 +00:00
memcpy(target, context.digest, TSDB_KEY_LEN);
}
2019-07-11 08:36:16 +00:00
#ifdef __cplusplus
}
#endif
2021-10-04 12:42:53 +00:00
#endif /*_TD_UTIL_UTIL_H*/