Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <git@davidebeatrici.dev>2020-10-16 07:31:53 +0300
committerDavide Beatrici <git@davidebeatrici.dev>2020-10-28 01:18:21 +0300
commit5debd105e33835d5e7f8681cecae5ccf225c19a7 (patch)
treec5b03c8160e8c7b00359ac603dfad0fe859babce /plugins/mumble_plugin_linux.h
parent755a8092c085317f0779865bf2a2f13f27dab988 (diff)
FEAT/REFAC(plugins): Add utf8ToUtf16(), move and rename readAll()
The new function is going to be used in a later commit. readAll() is moved to mumble_plugin_utils.h and is renamed to readFile(), to make its purpose clearer. This commit also moves the <math.h> include to mumble_plugin_utils.h, because that's where it's required. Also, it's now included as <cmath>, as recommended for C++.
Diffstat (limited to 'plugins/mumble_plugin_linux.h')
-rw-r--r--plugins/mumble_plugin_linux.h24
1 files changed, 3 insertions, 21 deletions
diff --git a/plugins/mumble_plugin_linux.h b/plugins/mumble_plugin_linux.h
index e4f3b2316..6cdb1b2e8 100644
--- a/plugins/mumble_plugin_linux.h
+++ b/plugins/mumble_plugin_linux.h
@@ -10,35 +10,17 @@
# error "Include mumble_plugin_main.h instead of mumble_plugin_linux.h"
#endif
+#include "mumble_plugin_utils.h"
+
#include <cstring>
#include <elf.h>
-#include <fstream>
#include <iostream>
-#include <math.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/uio.h>
-static inline std::string readAll(const std::string &fn) {
- std::ifstream ifs;
- ifs.open(fn.c_str(), std::ifstream::binary);
-
- std::string content;
-
- char buf[256];
- while (ifs.good()) {
- ifs.read(&buf[0], sizeof(buf));
- size_t nread = ifs.gcount();
- if (nread > 0) {
- content.append(&buf[0], nread);
- }
- }
-
- return content;
-}
-
// This function returns:
// -1 in case of failure.
// 0 if the process is 32-bit.
@@ -100,7 +82,7 @@ static inline procptr_t getModuleAddr(const procid_t &pid, const wchar_t *modnam
ss << static_cast< unsigned long >(pid);
ss << std::string("/maps");
std::string mapsFn = ss.str();
- std::string maps = readAll(mapsFn);
+ std::string maps = readFile(mapsFn);
if (maps.size() == 0) {
return 0;