From 3c6eaeaa0c865f7519111c3c7def46c42de01bac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juh=C3=A1sz=20B=C3=A1lint?= <juhasz.balint.bebe@gmail.com>
Date: Fri, 3 Apr 2015 20:45:44 +0200
Subject: [PATCH] process piping es default gateway hozzaadva

---
 pipe_test_with_routing.cpp | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 pipe_test_with_routing.cpp

diff --git a/pipe_test_with_routing.cpp b/pipe_test_with_routing.cpp
new file mode 100644
index 0000000..d4fc065
--- /dev/null
+++ b/pipe_test_with_routing.cpp
@@ -0,0 +1,34 @@
+#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();
+}
-- 
GitLab