Пример #1
0
tb_void_t tb_trace_tail(tb_char_t const* format, ...)
{
    // check
    tb_check_return(format);

    // enter
    tb_spinlock_enter_without_profiler(&g_lock);

    // done
    do
    {
        // check
        tb_check_break(g_mode);

        // init
        tb_va_list_t    l;
        tb_char_t*      p = g_line;
        tb_char_t*      e = g_line + sizeof(g_line);
        tb_va_start(l, format);

        // append format
        if (p < e) p += tb_vsnprintf(p, e - p, format, l);

        // append end
        if (p < e) *p = '\0';
        e[-1] = '\0';

        // print it
        if (g_mode & TB_TRACE_MODE_PRINT) tb_print(g_line);

        // print it to file
#ifndef TB_CONFIG_MICRO_ENABLE
        if ((g_mode & TB_TRACE_MODE_FILE) && g_file) 
        {
            // done
            tb_size_t size = p - g_line;
            tb_size_t writ = 0;
            while (writ < size)
            {
                // writ it
                tb_long_t real = tb_file_writ(g_file, (tb_byte_t const*)g_line + writ, size - writ);
                tb_check_break(real > 0);

                // save size
                writ += real;
            }
        }
#endif

        // exit
        tb_va_end(l);

    } while (0);

    // leave
    tb_spinlock_leave(&g_lock);
}
Пример #2
0
tb_void_t tb_trace_done(tb_char_t const* prefix, tb_char_t const* module, tb_char_t const* format, ...)
{
    // check
    tb_check_return(format);

    // init args
    tb_va_list_t args;
    tb_va_start(args, format);

    // done trace
    tb_trace_done_with_args(prefix, module, format, args);

    // exit args
    tb_va_end(args);
}
Пример #3
0
tb_bool_t tb_filter_ctrl(tb_filter_ref_t self, tb_size_t ctrl, ...)
{
    // check
    tb_filter_t* filter = (tb_filter_t*)self;
    tb_assert_and_check_return_val(filter && filter->ctrl && ctrl, tb_false);

    // init args
    tb_va_list_t args;
    tb_va_start(args, ctrl);

    // ctrl it
    tb_bool_t ok = filter->ctrl(filter, ctrl, args);

    // exit args
    tb_va_end(args);

    // ok?
    return ok;
}
Пример #4
0
tb_bool_t tb_async_transfer_ctrl_ostream(tb_async_transfer_ref_t transfer, tb_size_t ctrl, ...)
{
    // check
    tb_async_transfer_impl_t* impl = (tb_async_transfer_impl_t*)transfer;
    tb_assert_and_check_return_val(impl && impl->ostream, tb_false);

    // init args
    tb_va_list_t args;
    tb_va_start(args, ctrl);

    // ctrl it
    tb_bool_t ok = tb_async_stream_ctrl_with_args(impl->ostream, ctrl, args);

    // exit args
    tb_va_end(args);

    // ok?
    return ok;
}