tb_char_t const* tb_string_cstrfcat(tb_string_ref_t string, tb_char_t const* fmt, ...) { // check tb_assert_and_check_return_val(string && fmt, tb_null); // format data tb_char_t p[TB_SCOPED_STRING_FMTD_SIZE] = {0}; tb_long_t n = 0; tb_vsnprintf_format(p, TB_SCOPED_STRING_FMTD_SIZE, fmt, &n); tb_assert_and_check_return_val(n, tb_null); // done return tb_string_cstrncat(string, p, n); }
tb_long_t tb_printf(tb_char_t const* format, ...) { // check tb_check_return_val(format, 0); // format line tb_long_t size = 0; tb_char_t line[8192] = {0}; tb_vsnprintf_format(line, sizeof(line) - 1, format, &size); // print it tb_print(line); // ok? return size; }
tb_long_t tb_sprintf(tb_char_t* s, tb_char_t const* fmt, ...) { tb_long_t ret = 0; tb_vsnprintf_format(s, TB_MAXU32, fmt, &ret); return ret; }
tb_long_t tb_snprintf(tb_char_t* s, tb_size_t n, tb_char_t const* fmt, ...) { tb_long_t ret = 0; tb_vsnprintf_format(s, n, fmt, &ret); return ret; }