void IRCQuery::OutputFormatter(int Contents,int IRCCommandID) { char *FormatStr = GetOutputThemeFormatStr(m_pTheme->m_ThemeItems,IRCCommandID,THEME_QUERY); if (!FormatStr) return; char *FormatBuffer = (char *)malloc(FORMAT_BUFFER_SIZE); ReplaceVariables(FormatBuffer,FORMAT_BUFFER_SIZE,FormatStr,g_VariableIDNames,m_pServer->m_Variables,VID_LAST); m_pServer->m_Variables[VID_QUERYOUTPUT] = FormatBuffer; // log the output if (m_Logger.IsEnabled() && !m_Logger.IsFiltered(Contents)) { char LogFormatBuffer[1024]; char *LogFormatStr = STRINGPREF(PREF_sQueryLogFormat); ReplaceVariables(LogFormatBuffer,sizeof(LogFormatBuffer),LogFormatStr,g_VariableIDNames,m_pServer->m_Variables,VID_LAST); m_Logger.Log(LogFormatBuffer); } AddToOutputBuffer(Contents,FormatBuffer); }
/** Output some text to the output view * * NOTE: you must only send one line of text with each Put() * the function handles it ok, but we need to count the lines * of text in the buffer somehow... * ad we need to know what each line contains, so it can be filtered. */ void IRCCommon::Printf(const int Contents, const char *format, ...) { if (!format) return; va_list args; char *buf; buf = (char *)malloc(IRCCOMMON_PRINTF_BUFSIZE); if (buf) { ZeroMemory(buf, IRCCOMMON_PRINTF_BUFSIZE); va_start(args, format); _vsnprintf(buf, IRCCOMMON_PRINTF_BUFSIZE, format, args); va_end(args); buf[IRCCOMMON_PRINTF_BUFSIZE-1] = 0; AddToOutputBuffer(Contents, buf); // Note: buf is freed automatically later } }