1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
//getTime() returns a LPWSTR allocated with malloc
int _log(CLIENT* client, wchar_t* str, ...){//since it's a logging function I wont hold back on safety checks
if(!(str&&client))
return -1;
if(!(client->buf&&client->main&&client->edit))
return -1;
va_list va;
va_start(va, str);
LPWSTR tmp =(LPWSTR) malloc(sizeof(wchar_t)*2048);
LPWSTR time=getTime();
_vsnwprintf(tmp, 2048, str, va);
_snwprintf(client->buf, 65536, L"%s[%s] %s\r\n", client->buf, time, tmp);
free(time);
free(tmp);
SendMessage(client->edit, WM_SETTEXT, 0, (LPARAM)client->buf);
va_end(va);
return 0;
}
|