From 00ad7cdd3d05d09a43bda972c823fdc440feabb9 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 24 Mar 2022 02:06:28 +0000 Subject: Clean up gameinfo_init() and other random stuff - Just ask the engine for the game directory instead of doing the stupid argv sniffing hacks from the early days of trying to get the damn thing working. - Also add some other path variables, functions and whatnot, and do some other minor tidying up. - Also also, another damn copyright year, somebody please help me. Unfortunate negative effect off this change: con_init() no longer reports the game name, because it has to happen before gameinfo_init(). I've decided I don't really care, though. --- src/os-unix.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/os-unix.h') diff --git a/src/os-unix.h b/src/os-unix.h index 3b63bcc..6522029 100644 --- a/src/os-unix.h +++ b/src/os-unix.h @@ -35,6 +35,7 @@ typedef char os_char; #define os_access access #define os_stat stat #define os_getenv getenv +#define os_getcwd getcwd #define OS_DLSUFFIX ".so" @@ -42,6 +43,16 @@ typedef char os_char; #define os_dlsym dlsym +static inline bool os_dlfile(void *m, char *buf, int sz) { + // NOTE: this might be linux/glibc-specific (I haven't checked every + // implementation). this is fine as we don't use it in any build-time code, + // only in the plugin itself. just keep it in mind! + struct link_map *lm = m; + ssz len = strlen(lm->l_name) + 1; + if (ssz > sz) { errno = ENAMETOOLONG; return false; } + memcpy(buf, lm->l_name, ssz); return true; +} + // unix mprot flags are much nicer but cannot be defined in terms of the windows // ones, so we use the windows ones and define them in terms of the unix ones. // another victory for stupid! -- cgit v1.2.3