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