extern "C" int str_format_k(lua_State* L, int fmtArg, char* buf, size_t len) { if(!lua_isstring(L, fmtArg)) { luaL_argerror(L, fmtArg, "is not a format string"); return -1; } char nfmt[1024]; char nargs[1024]; va_arg_decl argDecls[256]; const char* fmt = lua_tostring(L, fmtArg); char fmt_2[1024]; if(localToCurrent(fmt, fmt_2, sizeof(fmt_2)) < 0) return 0; fmt = fmt_2; int n = scanFormatString(fmt, nfmt, argDecls); if(n > 0) { va_list newArgs; if(!arrange_va_list(L, fmtArg+1, argDecls, n, nargs)) return strcpy_k(buf, len, fmt); _init_va_list(&newArgs, &nargs); return vsnprintf(buf, len, nfmt, newArgs); } else return strcpy_k(buf, len, fmt); }
void KConsoleThread::processCommandQueue() { KConsoleThread::Command cmd; while(m_cmdQueue.pop(cmd)) { char buf[2048]; localToCurrent(cmd.c_str(), buf, sizeof(buf)); this->doString(buf); } }