src/test/util.c
author Tero Marttila <terom@fixme.fi>
Wed, 20 May 2009 22:53:05 +0300
branchlua-threads
changeset 203 ffdf53fd0337
parent 168 a58ad50911fc
permissions -rw-r--r--
implement lua_threads, nexus:sleep test func, and basic support in console/lua_console... doesn't actually work yet
#include "util.h"
#include "../str.h"

const char *dump_strn (const char *str, ssize_t len)
{
    static char dump_buf[DUMP_STR_COUNT][DUMP_STR_BUF];
    static size_t dump_idx = 0;
    
    // pick a buffer to use
    char *buf = dump_buf[dump_idx++];
    
    // cycle
    if (dump_idx >= DUMP_STR_COUNT)
        dump_idx = 0;
    
    // write the quoted string into the selected buf
    str_quote(buf, DUMP_STR_BUF, str, len);

    // ok
    return buf;
}

const char *dump_str (const char *str) 
{
    return dump_strn(str, -1);
}