Mercurial > minori
annotate dep/animia/src/fd.cc @ 233:0a5b6a088886
dep/animia: fix proc readlink
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 15 Jan 2024 08:10:58 -0500 |
parents | 71832ffe425a |
children |
rev | line source |
---|---|
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #include "animia/fd.h" |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
2 |
152
8700806c2cc2
dep/animia: awesome new breaking changes!
Paper <mrpapersonic@gmail.com>
parents:
150
diff
changeset
|
3 #ifdef WIN32 |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
4 # include "animia/fd/win32.h" |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
5 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
6 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
7 #ifdef LINUX |
166 | 8 # include "animia/fd/proc.h" |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
9 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
10 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
11 #ifdef MACOSX |
153
bd439dd6ffc5
*: make win stuff actually work, rename bsd.cc to xnu.cc
Paper <mrpapersonic@gmail.com>
parents:
152
diff
changeset
|
12 # include "animia/fd/xnu.h" |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
13 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
14 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
15 #ifdef LIBUTIL |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
16 # include "animia/fd/libutil.h" |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 #endif |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 |
202 | 19 #ifdef LIBKVM |
20 # include "animia/fd/kvm.h" | |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 #endif |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
22 |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
23 namespace animia::internal { |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
25 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
26 bool success = false; |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
27 |
152
8700806c2cc2
dep/animia: awesome new breaking changes!
Paper <mrpapersonic@gmail.com>
parents:
150
diff
changeset
|
28 #ifdef WIN32 |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
29 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
30 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
31 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
32 #ifdef LINUX |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
33 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
34 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
35 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
36 #ifdef MACOSX |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
37 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
38 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
39 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
40 #ifdef LIBUTIL |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
41 success ^= libutil::EnumerateOpenFiles(pids, open_file_proc); |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
42 #endif |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
43 |
202 | 44 #ifdef LIBKVM |
45 success ^= kvm::EnumerateOpenFiles(pids, open_file_proc); | |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
46 #endif |
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
48 return success; |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
49 } |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
50 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
51 bool EnumerateOpenProcesses(process_proc_t process_proc) { |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
52 bool success = false; |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
53 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
54 #ifdef WIN32 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
55 success ^= win32::EnumerateOpenProcesses(process_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
56 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
57 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
58 #ifdef LINUX |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
59 success ^= proc::EnumerateOpenProcesses(process_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
60 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
61 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
62 #ifdef MACOSX |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
63 success ^= xnu::EnumerateOpenProcesses(process_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
64 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
65 |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
66 #ifdef LIBUTIL |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
67 success ^= libutil::EnumerateOpenProcesses(process_proc); |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
68 #endif |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
69 |
202 | 70 #ifdef LIBKVM |
71 success ^= kvm::EnumerateOpenProcesses(process_proc); | |
72 #endif | |
73 | |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
74 return success; |
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
166
diff
changeset
|
75 } |
146
d8a61e7e2a36
dep/animia: move fd stuff to a new fd.cc, don't force the user
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
76 |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
153
diff
changeset
|
77 } // namespace animia::internal |