diff --git a/HISTORY b/HISTORY index 9c2489e..2192ec8 100644 --- a/HISTORY +++ b/HISTORY @@ -1,11 +1,12 @@ -Version 1.40 2018-08-27 +Version 1.40 2018-09-27 * add function conn_pool_parse_server_info and conn_pool_load_server_info * support directive: #@add_annotation, for example: #@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf * add function fc_split_string and fc_match_delim * add json_parser.[hc] for parse json array and map * add function fc_strdup + * add function fc_memmem Version 1.39 2018-07-31 * add #@function REPLACE_VARS diff --git a/src/common_define.h b/src/common_define.h index e825bdd..cf11583 100644 --- a/src/common_define.h +++ b/src/common_define.h @@ -81,15 +81,15 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind); #define USE_SENDFILE #endif -#define MAX_PATH_SIZE 256 +#define MAX_PATH_SIZE 256 #define LOG_FILE_DIR "logs" #define CONF_FILE_DIR "conf" #define DEFAULT_CONNECT_TIMEOUT 30 #define DEFAULT_NETWORK_TIMEOUT 30 -#define DEFAULT_MAX_CONNECTONS 256 -#define DEFAULT_WORK_THREADS 4 -#define SYNC_LOG_BUFF_DEF_INTERVAL 10 -#define TIME_NONE -1 +#define DEFAULT_MAX_CONNECTONS 1024 +#define DEFAULT_WORK_THREADS 4 +#define SYNC_LOG_BUFF_DEF_INTERVAL 10 +#define TIME_NONE -1 #define IP_ADDRESS_SIZE 16 #define INFINITE_FILE_SIZE (256 * 1024LL * 1024 * 1024 * 1024 * 1024LL) @@ -232,6 +232,12 @@ typedef void* (*MallocFunc)(size_t size); (dest).len = strlen(src); \ } while (0) +#define FC_SET_STRING_EX(dest, src, len) \ + do { \ + (dest).str = src; \ + (dest).len = len; \ + } while (0) + #define FC_SET_STRING_NULL(dest) \ do { \ (dest).str = NULL; \ diff --git a/src/shared_func.c b/src/shared_func.c index 10e7eb5..4defaee 100644 --- a/src/shared_func.c +++ b/src/shared_func.c @@ -2781,3 +2781,33 @@ char *fc_strdup(const char *str, const int len) *(output + len) = '\0'; return output; } + +const char *fc_memmem(const string_t *str, const string_t *needle) +{ + const char *ps; + const char *last; + const char *pn; + const char *nend; + int loop; + int i; + + loop = str->len - needle->len; + if (loop < 0) { + return NULL; + } + + last = str->str + loop; + nend = needle->str + needle->len; + for (ps=str->str; ps<=last; ps++) { + for (pn=needle->str,i=0; pn