mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
finish openbsd support
This commit is contained in:
parent
2c8955c776
commit
c2c6ee8a6b
@ -90,6 +90,7 @@ const ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#elif defined CC_BUILD_OPENBSD
|
#elif defined CC_BUILD_OPENBSD
|
||||||
#define CC_BUILD_UNIX
|
#define CC_BUILD_UNIX
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#elif defined CC_BUILD_SOLARIS
|
#elif defined CC_BUILD_SOLARIS
|
||||||
#define CC_BUILD_UNIX
|
#define CC_BUILD_UNIX
|
||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
@ -1945,6 +1946,37 @@ ReturnCode Platform_GetExePath(String* path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_BUILD_OPENBSD
|
||||||
|
ReturnCode Platform_GetExePath(String* path) {
|
||||||
|
char tmp[600];
|
||||||
|
int mib[4];
|
||||||
|
size_t size;
|
||||||
|
char* argv[100];
|
||||||
|
char* str;
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC_ARGS;
|
||||||
|
mib[2] = getpid();
|
||||||
|
mib[3] = KERN_PROC_ARGV;
|
||||||
|
|
||||||
|
/* NOTE: OpenBSD doesn't seem to let us get executable's location, so fallback to argv[0] */
|
||||||
|
/* See OpenBSD sysctl manpage for why argv array is so large */
|
||||||
|
/*... The buffer pointed to by oldp is filled with an array of char pointers followed by the strings themselves... */
|
||||||
|
size = 100 * sizeof(char*);
|
||||||
|
if (sysctl(mib, 4, argv, &size, NULL, 0) == -1) return errno;
|
||||||
|
|
||||||
|
str = argv[0];
|
||||||
|
if (str[0] != '/') {
|
||||||
|
/* relative path */
|
||||||
|
if (!realpath(str, tmp)) return errno;
|
||||||
|
str = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = String_CalcLen(str, 600);
|
||||||
|
Convert_DecodeUtf8(path, str, size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef CC_BUILD_SOLARIS
|
#ifdef CC_BUILD_SOLARIS
|
||||||
ReturnCode Platform_GetExePath(String* path) {
|
ReturnCode Platform_GetExePath(String* path) {
|
||||||
char str[600];
|
char str[600];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user