2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
2015-01-04 22:51:01 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD> C snprintf API <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>Ϊ '\0'
|
|
|
|
|
* @param buf {char*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param fmt {const char*} <EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD>ʽ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|
|
|
|
* 1) UNIX/LINUX ƽ̨<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2015-06-29 17:33:11 +08:00
|
|
|
|
* >= size<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫע<EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> _WIN32 <EFBFBD>µIJ<EFBFBD>ͬ
|
|
|
|
|
* 2) _WIN32 ƽ̨<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD> -1
|
2015-01-04 22:51:01 +08:00
|
|
|
|
*/
|
2017-07-11 09:04:20 +08:00
|
|
|
|
#if defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
2015-01-04 22:51:01 +08:00
|
|
|
|
ACL_CPP_API int ACL_CPP_PRINTF(3, 4) safe_snprintf(char *buf, size_t size,
|
|
|
|
|
const char *fmt, ...);
|
2017-07-11 09:04:20 +08:00
|
|
|
|
#else
|
|
|
|
|
ACL_CPP_API int safe_snprintf(char *buf, size_t size, const char *fmt, ...);
|
|
|
|
|
#endif
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-01-04 22:51:01 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD> C snprintf API <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>Ϊ '\0'
|
|
|
|
|
* @param buf {char*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param fmt {const char*} <EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD>ʽ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param ap {va_list} <EFBFBD><EFBFBD><EFBFBD>α<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|
|
|
|
* 1) UNIX/LINUX ƽ̨<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2015-06-29 17:33:11 +08:00
|
|
|
|
* >= size<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫע<EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> _WIN32 <EFBFBD>µIJ<EFBFBD>ͬ
|
|
|
|
|
* 2) _WIN32 ƽ̨<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD> -1
|
2015-01-04 22:51:01 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_CPP_API int safe_vsnprintf(char *buf, size_t size, const char *fmt, va_list ap);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-01-04 22:51:01 +08:00
|
|
|
|
} // namespace acl
|