Forráskód Böngészése

Add ini Configuration File

JDierkse 4 éve
szülő
commit
21dfbf1b34
4 módosított fájl, 14 hozzáadás és 4 törlés
  1. 10 1
      Application/VStarCamFinder.cc
  2. 1 0
      Libraries/inih
  3. 1 1
      Makefile.conf
  4. 2 2
      VStarCam/Finder.cpp

+ 10 - 1
Application/VStarCamFinder.cc

@@ -1,4 +1,5 @@
 #include "VStarCam/Finder.h"
+#include <INIReader.h>
 #include <Logging.h>
 #include <sstream>
 #include <string>
@@ -19,11 +20,19 @@ int main(int argc, char** argv)
 			return 1;
 		}
 
+		INIReader iniReader("VStarCamFinder.ini");
+		if (iniReader.ParseError() != 0)
+		{
+			Logging::Log(Logging::Severity::Error, "Can't read VStarCamFinder.ini");
+			return 1;
+		}
+
 		std::string ipAddress(argv[1]);
+		std::string listenAddress = iniReader.Get("VStarCamFinder", "ListenAddress", "0.0.0.0");
 
 		int port = 0;
 
-		VStarCam::Finder finder("192.168.101.100");
+		VStarCam::Finder finder(listenAddress);
 		port = finder.GetPort(ipAddress);
 
 		if (port != 0)

+ 1 - 0
Libraries/inih

@@ -0,0 +1 @@
+../../Libraries/inih

+ 1 - 1
Makefile.conf

@@ -8,6 +8,7 @@ LIBRARIES += Utilities
 
 CFLAGS += -I$(ROOTPATH)/Libraries/asio/asio/include
 CFLAGS += -I$(ROOTPATH)/Libraries/clipp
+CFLAGS += -I$(ROOTPATH)/Libraries/inih
 
 LFLAGS += -pthread
 
@@ -17,4 +18,3 @@ DEBUGDIR := .debug
 
 DEFAULTARCH := armv6-jessie
 TARGETS += VStarCamFinder
-

+ 2 - 2
VStarCam/Finder.cpp

@@ -25,7 +25,7 @@ int Finder::GetPort(const std::string& ipAddress)
 {
 	std::stringstream ss;
 	ss << "Retrieving port for " << ipAddress << std::endl;
-	Logging::Log(Logging::Severity::Info, ss.str());
+	Logging::Log(Logging::Severity::Debug, ss.str());
 
 	{
 		std::unique_lock<std::mutex> lock(m_mutex);
@@ -49,7 +49,7 @@ int Finder::GetPort(const std::string& ipAddress)
 
 	ss.str("");
 	ss << "New port for " << ipAddress << ": " << port << std::endl;
-	Logging::Log(Logging::Severity::Info, ss.str());
+	Logging::Log(Logging::Severity::Debug, ss.str());
 
 	return port;
 }