diff options
Diffstat (limited to 'common/utils.h')
-rw-r--r-- | common/utils.h | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/common/utils.h b/common/utils.h deleted file mode 100644 index ee79e48..0000000 --- a/common/utils.h +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | usbmuxd - iPhone/iPod Touch USB multiplex server daemon | ||
3 | |||
4 | Copyright (C) 2009 Hector Martin "marcan" <hector@marcansoft.com> | ||
5 | Copyright (C) 2009 Nikias Bassen <nikias@gmx.li> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 or version 3. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | |||
20 | */ | ||
21 | |||
22 | #ifndef __UTILS_H__ | ||
23 | #define __UTILS_H__ | ||
24 | |||
25 | #ifdef USBMUXD_DAEMON | ||
26 | #include <poll.h> | ||
27 | |||
28 | enum fdowner { | ||
29 | FD_LISTEN, | ||
30 | FD_CLIENT, | ||
31 | FD_USB | ||
32 | }; | ||
33 | |||
34 | struct fdlist { | ||
35 | int count; | ||
36 | int capacity; | ||
37 | enum fdowner *owners; | ||
38 | struct pollfd *fds; | ||
39 | }; | ||
40 | |||
41 | void fdlist_create(struct fdlist *list); | ||
42 | void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events); | ||
43 | void fdlist_free(struct fdlist *list); | ||
44 | void fdlist_reset(struct fdlist *list); | ||
45 | #endif | ||
46 | |||
47 | struct collection { | ||
48 | void **list; | ||
49 | int capacity; | ||
50 | }; | ||
51 | |||
52 | void collection_init(struct collection *col); | ||
53 | void collection_add(struct collection *col, void *element); | ||
54 | void collection_remove(struct collection *col, void *element); | ||
55 | int collection_count(struct collection *col); | ||
56 | void collection_free(struct collection *col); | ||
57 | |||
58 | #define FOREACH(var, col) \ | ||
59 | do { \ | ||
60 | int _iter; \ | ||
61 | for(_iter=0; _iter<(col)->capacity; _iter++) { \ | ||
62 | if(!(col)->list[_iter]) continue; \ | ||
63 | var = (col)->list[_iter]; | ||
64 | |||
65 | #define ENDFOREACH \ | ||
66 | } \ | ||
67 | } while(0); | ||
68 | |||
69 | #endif | ||