summaryrefslogtreecommitdiff
path: root/louloulibs
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-02-27 18:01:20 +0100
committerlouiz’ <louiz@louiz.org>2017-02-27 18:01:20 +0100
commitd81cbc4a33ee2c28628ccb632af9ae1b27e84d03 (patch)
treee301669f22080be2241e082af34c6d8c8979f5ec /louloulibs
parent9f978cda943619c95a41e5da9047c3cc0dd31555 (diff)
downloadbiboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.gz
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.bz2
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.xz
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.zip
Use uname() instead of CMAKE_SYSTEM
fix #3235
Diffstat (limited to 'louloulibs')
-rw-r--r--louloulibs/louloulibs.h.cmake1
-rw-r--r--louloulibs/utils/system.cpp21
-rw-r--r--louloulibs/utils/system.hpp8
-rw-r--r--louloulibs/xmpp/xmpp_component.cpp3
4 files changed, 31 insertions, 2 deletions
diff --git a/louloulibs/louloulibs.h.cmake b/louloulibs/louloulibs.h.cmake
index ebb9b9a..e2b2e25 100644
--- a/louloulibs/louloulibs.h.cmake
+++ b/louloulibs/louloulibs.h.cmake
@@ -1,4 +1,3 @@
-#define SYSTEM_NAME "${CMAKE_SYSTEM}"
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
#cmakedefine LIBIDN_FOUND
#cmakedefine SYSTEMD_FOUND
diff --git a/louloulibs/utils/system.cpp b/louloulibs/utils/system.cpp
new file mode 100644
index 0000000..c0bee11
--- /dev/null
+++ b/louloulibs/utils/system.cpp
@@ -0,0 +1,21 @@
+#include <logger/logger.hpp>
+#include <utils/system.hpp>
+#include <sys/utsname.h>
+#include <cstring>
+
+using namespace std::string_literals;
+
+namespace utils
+{
+std::string get_system_name()
+{
+ struct utsname uts;
+ const int res = ::uname(&uts);
+ if (res == -1)
+ {
+ log_error("uname failed: ", std::strerror(errno));
+ return "Unknown";
+ }
+ return uts.sysname + " "s + uts.release;
+}
+} \ No newline at end of file
diff --git a/louloulibs/utils/system.hpp b/louloulibs/utils/system.hpp
new file mode 100644
index 0000000..7ea1677
--- /dev/null
+++ b/louloulibs/utils/system.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+#include <string>
+
+namespace utils
+{
+std::string get_system_name();
+} \ No newline at end of file
diff --git a/louloulibs/xmpp/xmpp_component.cpp b/louloulibs/xmpp/xmpp_component.cpp
index e1b6131..e40b1e4 100644
--- a/louloulibs/xmpp/xmpp_component.cpp
+++ b/louloulibs/xmpp/xmpp_component.cpp
@@ -5,6 +5,7 @@
#include <xmpp/xmpp_component.hpp>
#include <config/config.hpp>
+#include <utils/system.hpp>
#include <utils/time.hpp>
#include <xmpp/auth.hpp>
#include <xmpp/jid.hpp>
@@ -585,7 +586,7 @@ void XmppComponent::send_version(const std::string& id, const std::string& jid_t
}
{
XmlSubNode os(query, "os");
- os.set_inner(SYSTEM_NAME);
+ os.set_inner(utils::get_system_name());
}
}
else