int WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args) { int status = -1; if (message->Type == WLOG_MESSAGE_TEXT) { if (!strchr(message->FormatString, '%')) { message->TextString = (LPSTR) message->FormatString; status = WLog_Write(log, message); } else { char formattedLogMessage[WLOG_MAX_STRING_SIZE]; wvsnprintfx(formattedLogMessage, WLOG_MAX_STRING_SIZE - 1, message->FormatString, args); message->TextString = formattedLogMessage; status = WLog_Write(log, message); } } else if (message->Type == WLOG_MESSAGE_DATA) { message->Data = va_arg(args, void*); message->Length = va_arg(args, int); status = WLog_WriteData(log, message); }
BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, DWORD line, const char* file, const char* function, va_list args) { BOOL status = FALSE; wLogMessage message = { 0 }; message.Level = level; message.LineNumber = line; message.FileName = file; message.FunctionName = function; switch (type) { case WLOG_MESSAGE_TEXT: message.FormatString = va_arg(args, const char*); if (!strchr(message.FormatString, '%')) { message.TextString = (LPSTR) message.FormatString; status = WLog_Write(log, &message); } else { char formattedLogMessage[WLOG_MAX_STRING_SIZE]; if (wvsnprintfx(formattedLogMessage, WLOG_MAX_STRING_SIZE - 1, message.FormatString, args) < 0) return FALSE; message.TextString = formattedLogMessage; status = WLog_Write(log, &message); } break; case WLOG_MESSAGE_DATA: message.Data = va_arg(args, void*); message.Length = va_arg(args, int); status = WLog_WriteData(log, &message); break; case WLOG_MESSAGE_IMAGE: message.ImageData = va_arg(args, void*); message.ImageWidth = va_arg(args, int); message.ImageHeight = va_arg(args, int); message.ImageBpp = va_arg(args, int); status = WLog_WriteImage(log, &message); break; case WLOG_MESSAGE_PACKET: message.PacketData = va_arg(args, void*); message.PacketLength = va_arg(args, int); message.PacketFlags = va_arg(args, int); status = WLog_WritePacket(log, &message); break; default: break; } return status; }