# HG changeset patch # User Paper # Date 1699901578 18000 # Node ID d8a61e7e2a3608d80cc4ef1eaeacaef6aa32a236 # Parent 8e9b71970bda6d5fd7fa09d04ea459f416f3b083 dep/animia: move fd stuff to a new fd.cc, don't force the user to include windows.h diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/CMakeLists.txt --- a/dep/animia/CMakeLists.txt Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/CMakeLists.txt Mon Nov 13 13:52:58 2023 -0500 @@ -6,6 +6,7 @@ src/player.cc src/util.cc src/strategist.cc + src/fd.cc ) if(LINUX) diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/include/animia.h --- a/dep/animia/include/animia.h Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/include/animia.h Mon Nov 13 13:52:58 2023 -0500 @@ -7,8 +7,6 @@ namespace animia { -/* pid_t should be DWORD on windows, and defined by the system - anywhere else */ struct Process { internal::pid_t pid = 0; std::string name; @@ -23,7 +21,7 @@ struct Result { Player player; Process process; - //Window window; + Window window; // unused with file descriptors std::vector media; }; diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/include/animia/fd.h --- a/dep/animia/include/animia/fd.h Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/include/animia/fd.h Mon Nov 13 13:52:58 2023 -0500 @@ -18,7 +18,7 @@ virtual bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) { return false; } }; -extern BaseFdTools& fd; // defined in animia.cc +extern BaseFdTools& fd; // defined in fd.cc } diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/include/animia/types.h --- a/dep/animia/include/animia/types.h Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/include/animia/types.h Mon Nov 13 13:52:58 2023 -0500 @@ -1,18 +1,18 @@ #ifndef __animia__animia__types_h #define __animia__animia__types_h -#include "animia/os.h" - -#ifdef ANIMIA_ON_WIN32 -# include +/* define this as unsigned long (DWORD) on win32 so we + don't force the user to include or */ +#ifdef _WIN32 namespace animia::internal { - typedef DWORD pid_t; + typedef unsigned long pid_t; } #else +/* shouldn't be that big, right? */ # include namespace animia::internal { typedef ::pid_t pid_t; } #endif -#endif // __animia__animia__types_h \ No newline at end of file +#endif // __animia__animia__types_h diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/src/animia.cc --- a/dep/animia/src/animia.cc Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/src/animia.cc Mon Nov 13 13:52:58 2023 -0500 @@ -1,35 +1,11 @@ #include #include +#include #include "animia.h" #include "animia/strategies.h" #include "animia/types.h" - -#ifdef ANIMIA_ON_WIN32 -# include "animia/fd/win32.h" -#elif defined(ANIMIA_ON_LINUX) -# include "animia/fd/linux.h" -#elif defined(ANIMIA_ON_UNIX) -# include "animia/fd/bsd.h" -#endif - -namespace animia::internal { - -/* really stupid hack to get fd to point to the right - thing */ -#ifdef ANIMIA_ON_WIN32 -win32::Win32FdTools os_fd; -#elif defined(ANIMIA_ON_LINUX) -linux::LinuxFdTools os_fd; -#elif defined(ANIMIA_ON_UNIX) -unix::UnixFdTools os_fd; -#else -BaseFdTools os_fd; -#endif - -BaseFdTools& fd = os_fd; - -} +#include "animia/fd.h" namespace animia { diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/src/fd.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dep/animia/src/fd.cc Mon Nov 13 13:52:58 2023 -0500 @@ -0,0 +1,27 @@ +#include "animia/fd.h" + +#ifdef ANIMIA_ON_WIN32 +# include "animia/fd/win32.h" +#elif defined(ANIMIA_ON_LINUX) +# include "animia/fd/linux.h" +#elif defined(ANIMIA_ON_UNIX) +# include "animia/fd/bsd.h" +#endif + +namespace animia::internal { + +/* really stupid hack to get fd to point to the right + thing */ +#ifdef ANIMIA_ON_WIN32 +win32::Win32FdTools os_fd; +#elif defined(ANIMIA_ON_LINUX) +linux::LinuxFdTools os_fd; +#elif defined(ANIMIA_ON_UNIX) +unix::UnixFdTools os_fd; +#else +BaseFdTools os_fd; +#endif + +BaseFdTools& fd = os_fd; + +} diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/src/fd/bsd.cc --- a/dep/animia/src/fd/bsd.cc Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/src/fd/bsd.cc Mon Nov 13 13:52:58 2023 -0500 @@ -25,7 +25,9 @@ /* this is a cleaned up version of a function from... Apple? ...anyway, what it essentially does is gets the size and stuff from - sysctl() and reserves the space in a vector to store the PIDs */ + sysctl() and reserves the space in a vector to store the PIDs + + TODO: https://kaashif.co.uk/2015/06/18/how-to-get-a-list-of-processes-on-openbsd-in-c/ */ bool UnixFdTools::GetAllPids(std::set& pids) { struct kinfo_proc* result = NULL; size_t length = 0; diff -r 8e9b71970bda -r d8a61e7e2a36 dep/animia/src/player.cc --- a/dep/animia/src/player.cc Sun Nov 12 18:38:38 2023 -0500 +++ b/dep/animia/src/player.cc Mon Nov 13 13:52:58 2023 -0500 @@ -195,4 +195,4 @@ return ParsePlayersData(data, players); } -} // namespace anisthesia \ No newline at end of file +} // namespace animia