Mercurial > minori
annotate dep/animone/src/fd.cc @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 20 Jun 2024 05:56:06 -0400 |
parents | a7d4e5107531 |
children |
rev | line source |
---|---|
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
1 #include "animone/fd.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
2 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
3 #ifdef USE_WIN32 |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
4 # include "animone/fd/win32.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
5 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
6 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
7 #ifdef USE_LINUX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
8 # include "animone/fd/proc.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
9 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
10 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
11 #ifdef USE_MACOSX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
12 # include "animone/fd/xnu.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
13 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
14 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
15 #ifdef USE_BSD |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
16 # include "animone/fd/bsd.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
17 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
18 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
19 namespace animone::internal { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
20 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
21 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
22 bool success = false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
23 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
24 #ifdef USE_WIN32 |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
25 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
26 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
27 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
28 #ifdef USE_LINUX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
29 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
30 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
31 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
32 #ifdef USE_MACOSX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
33 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
34 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
35 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
36 #ifdef USE_BSD |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
37 success ^= bsd::EnumerateOpenFiles(pids, open_file_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
38 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
39 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
40 return success; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
41 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
42 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
43 bool EnumerateOpenProcesses(process_proc_t process_proc) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
44 bool success = false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
45 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
46 #ifdef USE_WIN32 |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
47 success ^= win32::EnumerateOpenProcesses(process_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
48 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
49 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
50 #ifdef USE_LINUX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
51 success ^= proc::EnumerateOpenProcesses(process_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
52 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
53 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
54 #ifdef USE_MACOSX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
55 success ^= xnu::EnumerateOpenProcesses(process_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
56 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
57 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
58 #ifdef USE_BSD |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
59 success ^= bsd::EnumerateOpenProcesses(process_proc); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
60 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
61 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
62 return success; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
63 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
64 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
65 bool GetProcessName(pid_t pid, std::string& name) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
66 bool success = false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
67 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
68 #ifdef USE_WIN32 |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
69 success ^= win32::GetProcessName(pid, name); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
70 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
71 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
72 #ifdef USE_LINUX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
73 success ^= proc::GetProcessName(pid, name); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
74 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
75 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
76 #ifdef USE_MACOSX |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
77 success ^= xnu::GetProcessName(pid, name); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
78 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
79 |
337
a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
80 #ifdef USE_BSD |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
81 success ^= bsd::GetProcessName(pid, name); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
82 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
83 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
84 return success; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
85 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
86 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
87 } // namespace animone::internal |