Mercurial > minori
comparison dep/animone/src/fd.cc @ 337:a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
1: animone now has its own syntax divergent from anisthesia,
making different platforms actually have their own sections
2: process names in animone are now called `comm' (this will
probably break things). this is what its called in bsd/linux
so I'm just going to use it everywhere
3: the X11 code now checks for the existence of a UTF-8 window title
and passes it if available
4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK!
I still actually need to test the bsd code. to be honest I'm probably
going to move all of the bsds into separate files because they're
all essentially different operating systems at this point
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 12:51:15 -0400 |
parents | b1f625b0227c |
children |
comparison
equal
deleted
inserted
replaced
336:d260549151d6 | 337:a7d4e5107531 |
---|---|
1 #include "animone/fd.h" | 1 #include "animone/fd.h" |
2 | 2 |
3 #ifdef WIN32 | 3 #ifdef USE_WIN32 |
4 # include "animone/fd/win32.h" | 4 # include "animone/fd/win32.h" |
5 #endif | 5 #endif |
6 | 6 |
7 #ifdef LINUX | 7 #ifdef USE_LINUX |
8 # include "animone/fd/proc.h" | 8 # include "animone/fd/proc.h" |
9 #endif | 9 #endif |
10 | 10 |
11 #ifdef MACOSX | 11 #ifdef USE_MACOSX |
12 # include "animone/fd/xnu.h" | 12 # include "animone/fd/xnu.h" |
13 #endif | 13 #endif |
14 | 14 |
15 #ifdef BSD | 15 #ifdef USE_BSD |
16 # include "animone/fd/bsd.h" | 16 # include "animone/fd/bsd.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace animone::internal { | 19 namespace animone::internal { |
20 | 20 |
21 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { | 21 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { |
22 bool success = false; | 22 bool success = false; |
23 | 23 |
24 #ifdef WIN32 | 24 #ifdef USE_WIN32 |
25 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); | 25 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); |
26 #endif | 26 #endif |
27 | 27 |
28 #ifdef LINUX | 28 #ifdef USE_LINUX |
29 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); | 29 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); |
30 #endif | 30 #endif |
31 | 31 |
32 #ifdef MACOSX | 32 #ifdef USE_MACOSX |
33 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); | 33 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); |
34 #endif | 34 #endif |
35 | 35 |
36 #ifdef BSD | 36 #ifdef USE_BSD |
37 success ^= bsd::EnumerateOpenFiles(pids, open_file_proc); | 37 success ^= bsd::EnumerateOpenFiles(pids, open_file_proc); |
38 #endif | 38 #endif |
39 | 39 |
40 return success; | 40 return success; |
41 } | 41 } |
42 | 42 |
43 bool EnumerateOpenProcesses(process_proc_t process_proc) { | 43 bool EnumerateOpenProcesses(process_proc_t process_proc) { |
44 bool success = false; | 44 bool success = false; |
45 | 45 |
46 #ifdef WIN32 | 46 #ifdef USE_WIN32 |
47 success ^= win32::EnumerateOpenProcesses(process_proc); | 47 success ^= win32::EnumerateOpenProcesses(process_proc); |
48 #endif | 48 #endif |
49 | 49 |
50 #ifdef LINUX | 50 #ifdef USE_LINUX |
51 success ^= proc::EnumerateOpenProcesses(process_proc); | 51 success ^= proc::EnumerateOpenProcesses(process_proc); |
52 #endif | 52 #endif |
53 | 53 |
54 #ifdef MACOSX | 54 #ifdef USE_MACOSX |
55 success ^= xnu::EnumerateOpenProcesses(process_proc); | 55 success ^= xnu::EnumerateOpenProcesses(process_proc); |
56 #endif | 56 #endif |
57 | 57 |
58 #ifdef BSD | 58 #ifdef USE_BSD |
59 success ^= bsd::EnumerateOpenProcesses(process_proc); | 59 success ^= bsd::EnumerateOpenProcesses(process_proc); |
60 #endif | 60 #endif |
61 | 61 |
62 return success; | 62 return success; |
63 } | 63 } |
64 | 64 |
65 bool GetProcessName(pid_t pid, std::string& name) { | 65 bool GetProcessName(pid_t pid, std::string& name) { |
66 bool success = false; | 66 bool success = false; |
67 | 67 |
68 #ifdef WIN32 | 68 #ifdef USE_WIN32 |
69 success ^= win32::GetProcessName(pid, name); | 69 success ^= win32::GetProcessName(pid, name); |
70 #endif | 70 #endif |
71 | 71 |
72 #ifdef LINUX | 72 #ifdef USE_LINUX |
73 success ^= proc::GetProcessName(pid, name); | 73 success ^= proc::GetProcessName(pid, name); |
74 #endif | 74 #endif |
75 | 75 |
76 #ifdef MACOSX | 76 #ifdef USE_MACOSX |
77 success ^= xnu::GetProcessName(pid, name); | 77 success ^= xnu::GetProcessName(pid, name); |
78 #endif | 78 #endif |
79 | 79 |
80 #ifdef BSD | 80 #ifdef USE_BSD |
81 success ^= bsd::GetProcessName(pid, name); | 81 success ^= bsd::GetProcessName(pid, name); |
82 #endif | 82 #endif |
83 | 83 |
84 return success; | 84 return success; |
85 } | 85 } |