/**
 * @file    sasstr.h
 * @brief   Some string functions.
 *
 * @version $Revision: 1.1 $
 * @date    $Date: 2018/11/24 06:54:50 $
 * @author  $Author: lizhongming $
 * @state   $State: Exp $
 *
 */

#ifndef _SASSTR_H_CJRONDELXCYKGFG_
#define _SASSTR_H_CJRONDELXCYKGFG_

#define STR_UINT32_BUFFER_SIZE  ( sizeof ( uint32_t ) * 3 + 2 )
#define STR_UINT64_BUFFER_SIZE  ( sizeof ( apr_time_t ) * 3 +2 )

typedef struct sas_strings sas_strings;
struct sas_strings{
	size_t len;
	char *content;
};

#ifdef __cplusplus
extern "C" {
#endif

//APR_DECLARE(apr_status_t) 
//sas_strsplit(char* str, sas_strings *content,char *delimeter, int *segment);
APR_DECLARE_NONSTD(apr_status_t) sas_strcat(char *buffer,size_t *buffer_len , ... );
APR_DECLARE_NONSTD(apr_status_t) sas_strcat_withenter(char *buffer,size_t * buffer_len ,...);

APR_DECLARE(char *) sas_apr_time_to_str(char *buffer ,apr_time_t  n);
APR_DECLARE(char *) sas_uint32_to_str(char *buffer ,uint32_t  n);
APR_DECLARE(apr_status_t) sas_strsplit (char* str, sas_strings *content,char *delimeter, int *segment);
APR_DECLARE(char*) sas_get_nextline(char *buff);
//mem_str可以为非0结束的字符串,dst缓冲区大最少要大于len+1(用户自行保证)
//返回生成的字符串的末尾后一个位置(也就是'\0'的位置)
APR_DECLARE(char*) sas_strmemcpy(char *dst,const char *mem_str,size_t len);

//拼接文件路径+文件名(考虑到了不同的平台环境)
APR_DECLARE(char*) sas_str_path_cat(const char *path,const char *filename );
//strcat,带缓冲区大小验证
APR_DECLARE(apr_status_t) sas_strcat_withcheck(char *dst,const char*src,size_t buffer_size);


//这个函数是用来释放由库申请的内存的,只所以增加这个库级函数是因为WINDOWS
//库内部的内存外部没法释放,不得已而为之.
//释放由public库申请的内存,如
APR_DECLARE(void) sas_publiclib_free(char *mem);

#ifdef __cplusplus
}
#endif

#endif//_IPCMONITOR_HEAD_
