Merge branch 'special-tokens'

This commit is contained in:
enWILLYado 2018-02-27 00:18:10 +01:00
commit a7337c12cd
3 changed files with 6 additions and 5 deletions

View file

@ -24,6 +24,7 @@
#ifndef __ICONSOLELISTENER_H__ #ifndef __ICONSOLELISTENER_H__
#define __ICONSOLELISTENER_H__ #define __ICONSOLELISTENER_H__
#include "interfaces/interface.h"
class IConsoleListener class IConsoleListener
{ {

View file

@ -43,7 +43,7 @@ void SysLog::text(const std::string & txt)
void SysLog::message(Level level, const std::string & txt) void SysLog::message(Level level, const std::string & txt)
{ {
syslog(level == INFO ? LOG_INFO : LOG_NOTICE, "%s", txt); syslog(level == INFO ? LOG_INFO : LOG_NOTICE, "%s", txt.c_str());
} }
#endif #endif

View file

@ -236,7 +236,7 @@ void Url::applyExceptions()
} }
static std::string & replace(std::string & str, const std::string & what, const std::string & other) static std::string & Replace(std::string & str, const std::string & what, const std::string & other)
{ {
if(str.empty() || what.empty() || what == other) if(str.empty() || what.empty() || what == other)
{ {
@ -256,7 +256,7 @@ static std::string & replace(std::string & str, const std::string & what, const
static std::string replaceWithTokens(const std::string & value) static std::string replaceWithTokens(const std::string & value)
{ {
char hostname[1024] = {'\0'}; char hostname[1024] = {'\0'};
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname) - 1);
struct hostent* hostentry = gethostbyname(hostname); struct hostent* hostentry = gethostbyname(hostname);
// get ip // get ip
@ -284,8 +284,8 @@ static std::string replaceWithTokens(const std::string & value)
// set user replacing tokens // set user replacing tokens
std::string ret = value; std::string ret = value;
ret = replace(ret, "%HOST_NAME%", hostname); ret = Replace(ret, "%HOST_NAME%", hostname);
ret = replace(ret, "%IP_ADD%", ipbuf == NULL ? "" : ipbuf); ret = Replace(ret, "%IP_ADD%", ipbuf == NULL ? "" : ipbuf);
return ret; return ret;
} }