summaryrefslogtreecommitdiffstats
path: root/common/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/utils.h')
-rw-r--r--common/utils.h69
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
4Copyright (C) 2009 Hector Martin "marcan" <hector@marcansoft.com>
5Copyright (C) 2009 Nikias Bassen <nikias@gmx.li>
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 or version 3.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, 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
28enum fdowner {
29 FD_LISTEN,
30 FD_CLIENT,
31 FD_USB
32};
33
34struct fdlist {
35 int count;
36 int capacity;
37 enum fdowner *owners;
38 struct pollfd *fds;
39};
40
41void fdlist_create(struct fdlist *list);
42void fdlist_add(struct fdlist *list, enum fdowner owner, int fd, short events);
43void fdlist_free(struct fdlist *list);
44void fdlist_reset(struct fdlist *list);
45#endif
46
47struct collection {
48 void **list;
49 int capacity;
50};
51
52void collection_init(struct collection *col);
53void collection_add(struct collection *col, void *element);
54void collection_remove(struct collection *col, void *element);
55int collection_count(struct collection *col);
56void 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