TDengine/include/os/osString.h

55 lines
1.7 KiB
C
Raw Normal View History

2020-07-31 06:18:23 +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-09-30 09:10:36 +00:00
#ifndef _TD_OS_STRING_H_
#define _TD_OS_STRING_H_
2020-07-31 06:18:23 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-05-08 06:58:57 +00:00
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#define tstrdup(str) _strdup(str)
#define tstrndup(str, size) _strndup(str, size)
int32_t tgetline(char **lineptr, size_t *n, FILE *stream);
int32_t twcslen(const wchar_t *wcs);
#else
#define tstrdup(str) strdup(str)
#define tstrndup(str, size) strndup(str, size)
2021-05-08 07:19:15 +00:00
#define tgetline(lineptr, n, stream) getline(lineptr, n, stream)
2020-07-31 06:18:23 +00:00
#define twcslen wcslen
2021-05-08 06:58:57 +00:00
#endif
2020-07-31 06:18:23 +00:00
2021-05-08 06:58:57 +00:00
#define tstrncpy(dst, src, size) \
do { \
strncpy((dst), (src), (size)); \
(dst)[(size)-1] = 0; \
} while (0)
2020-07-31 06:18:23 +00:00
2021-05-08 06:58:57 +00:00
int64_t taosStr2int64(char *str);
2020-07-31 06:18:23 +00:00
// USE_LIBICONV
int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
2021-05-08 06:58:57 +00:00
bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, int32_t *len);
2021-09-30 13:21:51 +00:00
int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize);
2020-07-31 06:18:23 +00:00
bool taosValidateEncodec(const char *encodec);
char * taosCharsetReplace(char *charsetstr);
#ifdef __cplusplus
}
#endif
2021-09-30 09:10:36 +00:00
#endif /*_TD_OS_STRING_H_*/