summaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-17 11:30:01 +0200
committerGravatar Nikias Bassen2013-09-17 11:30:01 +0200
commitf4758e8b15cd30fe3f7f18de42e2ea20bc5696f0 (patch)
tree671e85e639b689b0b888a0f51c7dd5e15d408930 /src/utils.h
parent10939f3ad5755d1117f20df2b97c0cbbd83bbcbe (diff)
downloadusbmuxd-f4758e8b15cd30fe3f7f18de42e2ea20bc5696f0.tar.gz
usbmuxd-f4758e8b15cd30fe3f7f18de42e2ea20bc5696f0.tar.bz2
remove libusbmuxd sources and adapt source tree to use autotools
libusbmuxd has been split off and is now managed in a separate repository. By the time of this commit, the repository is: git clone http://git.sukimashita.com/libusbmuxd.git
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..5aa2915
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,68 @@
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 library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as
9published by the Free Software Foundation, either version 2.1 of the
10License, or (at your option) any later version.
11
12This library is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public
18License along with this program; if not, write to the Free Software
19Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21*/
22
23#ifndef __UTILS_H__
24#define __UTILS_H__
25
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
46struct collection {
47 void **list;
48 int capacity;
49};
50
51void collection_init(struct collection *col);
52void collection_add(struct collection *col, void *element);
53void collection_remove(struct collection *col, void *element);
54int collection_count(struct collection *col);
55void collection_free(struct collection *col);
56
57#define FOREACH(var, col) \
58 do { \
59 int _iter; \
60 for(_iter=0; _iter<(col)->capacity; _iter++) { \
61 if(!(col)->list[_iter]) continue; \
62 var = (col)->list[_iter];
63
64#define ENDFOREACH \
65 } \
66 } while(0);
67
68#endif