Skip to content
Snippets Groups Projects
Commit 3c6eaeaa authored by Juhász Bálint's avatar Juhász Bálint
Browse files

process piping es default gateway hozzaadva

parent 8c6d995e
No related branches found
No related tags found
No related merge requests found
#include <QCoreApplication>
#include <QTextStream>
#include <QRegExp>
#include <cstdio>
#define cout QTextStream(stdout)
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
FILE *cmdHandle;
#if defined( Q_OS_WIN )
// original command: route print -4 | findstr /r "[^0-9]0\.0\.0\.0"
cmdHandle = popen(
"route print -4 | findstr /r \"[^0-9]0\\.0\\.0\\.0\" ", "r"
);
#elif defined ( Q_OS_LINUX )
#else
#error "We do not support this version."
#endif
constexpr int BUFFSIZE = 256;
char buffer[BUFFSIZE];
fgets(buffer, BUFFSIZE-1, cmdHandle);
QRegExp regx("^(?:\\s*(?:0\\.0\\.0\\.0)){2}\\s*([^\\s]+)");
regx.indexIn(buffer);
QString ipAddr = regx.capturedTexts()[1];
cout << ipAddr;
fclose(cmdHandle);
return a.exec();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment