aboutsummaryrefslogtreecommitdiff
path: root/apps/apps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/apps.cpp')
-rw-r--r--apps/apps.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/apps.cpp b/apps/apps.cpp
index 2da8359..ca7cd81 100644
--- a/apps/apps.cpp
+++ b/apps/apps.cpp
@@ -1,6 +1,7 @@
#include "apps.h"
#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>
+#include <netdb.h>
namespace trygvis {
namespace apps {
@@ -59,6 +60,35 @@ int launch_app(int argc, char *argv[], app& app) {
return app.main(execution);
}
+
+std::string get_hostname() {
+ struct addrinfo hints, *info, *p;
+// int gai_result;
+
+ char hostname[1024];
+ hostname[1023] = '\0';
+ gethostname(hostname, 1023);
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
+ if (getaddrinfo(hostname, "http", &hints, &info)) {
+ return "uknown";
+ }
+
+ string s = "unknown";
+
+ if (info) {
+ s = string(info->ai_canonname);
+ }
+
+ freeaddrinfo(info);
+
+ return s;
+}
+
void app_execution::usage() {
cerr << desc << endl;
}