liuxiaolong
2021-09-08 2b1f534ea407a8ec0b94e0389a360f6cdff54598
include/usgcommon/usg_common.h
@@ -22,6 +22,7 @@
#include <sched.h>
#include <sys/time.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
@@ -43,6 +44,8 @@
 * define int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t
*/
#include <stdint.h>
#include <assert.h>
#ifdef __cplusplus
}
@@ -56,23 +59,35 @@
 
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <atomic>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <map>
#include <initializer_list>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <thread>
#endif
#include "usg_typedef.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Signal wrappers */
typedef void handler_t(int);
handler_t *Signal(int signum, handler_t *handler);
/* Our own error-handling functions */
@@ -83,19 +98,32 @@
char *rtrim(char *str, const char *seps);
char *trim(char *str, const char *seps);
/**
 * @ seperator 分割符
 */
char * str_join( const char *seperator, const char *first, ...);
/**
 * 把字符串以@delim分割为数组,数组的地址存放在@arr_addr
 */
int str_split(const char *str, const char *delim, char *** arr_addr);
char * array_join(char * const arr[], const char *seperator);
char * path_join(const char *path, ...);
// 反向查询
char *strstr_r(char *str,  char * needle);
// 递归创建文件夹
int mkdir_r(const char *pathname, mode_t mode);
int mkdiratfd_r(int dirfd, const char *pathname, mode_t mode);
int mkdirat_r(const char * dir, const char *pathname, mode_t mode);
static inline int 
itoa(int num, char *str)
strtoi(int num, char *str)
{
   return sprintf(str, "%d", num); 
}
static inline int
ftoa(float num, char *str)
{
    return sprintf(str, "%f", num);
}