diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp index 1a5121b44..e78c572d0 100644 --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -20,6 +20,11 @@ // Own #include "ProcessInfo.h" +// Unix +#include +#include +#include + // Qt #include #include @@ -468,16 +473,30 @@ QString SSHProcessInfo::command() const QString SSHProcessInfo::format(const QString& input) const { QString output(input); - + + // test whether host is an ip address + // in which case 'short host' and 'full host' + // markers in the input string are replaced with + // the full address + bool isIpAddress = false; + + struct in_addr address; + if ( inet_aton(_host.toLocal8Bit().constData(),&address) != 0 ) + isIpAddress = true; + else + isIpAddress = false; + // search for and replace known markers output.replace("%u",_user); - output.replace("%h",_host.left(_host.indexOf('.'))); + + if ( isIpAddress ) + output.replace("%h",_host); + else + output.replace("%h",_host.left(_host.indexOf('.'))); + output.replace("%H",_host); output.replace("%c",_command); - // remove any remaining %[LETTER] character sequences - // output.replace(QRegExp("%\\w"),QString::null); - return output; }