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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-12-07 19:36:40 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-12-07 21:28:08 +0300
commit6a5e8096973f701363a36eb07a096ff8ca784342 (patch)
tree9beebb681abd93e080e8e98e9658a4576d951132 /source/blender/blenlib/intern/system.c
parentde491abf996281785391b18b3547d1bff305355f (diff)
Move static `get_hostname()` to `BLI_hostname()` in `system.c`
This makes the `#include <Windows.h>` use more localised and out of the `image.c` file. Reviewers: LazyDodo Reviewed by: LazyDodo Differential revision: https://developer.blender.org/D4049
Diffstat (limited to 'source/blender/blenlib/intern/system.c')
-rw-r--r--source/blender/blenlib/intern/system.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index fca168dce69..5ff1d4ed710 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -31,9 +31,10 @@
#include "MEM_guardedalloc.h"
-/* for backtrace */
+/* for backtrace and gethostname/GetComputerName */
#if defined(__linux__) || defined(__APPLE__)
# include <execinfo.h>
+# include <unistd.h>
#elif defined(WIN32)
# include <windows.h>
# include <dbghelp.h>
@@ -176,3 +177,19 @@ char *BLI_cpu_brand_string(void)
}
return NULL;
}
+
+void BLI_hostname_get(char *buffer, size_t bufsize)
+{
+#ifndef WIN32
+ if (gethostname(buffer, bufsize-1) < 0) {
+ BLI_strncpy(buffer, "-unknown-", bufsize);
+ }
+ /* When gethostname() truncates, it doesn't guarantee the trailing \0. */
+ buffer[bufsize - 1] = '\0';
+#else
+ DWORD bufsize_inout = bufsize;
+ if(!GetComputerName(buffer, &bufsize_inout)) {
+ strncpy(buffer, "-unknown-", bufsize);
+ }
+#endif
+}