Sat, 25 Jun 2005 17:58:42 +0000
[gaim-migrate @ 12905]
I use
CFLAGS="-g3 -D_FORTIFY_SOURCE=2 -Werror-implicit-function-declaration -Wno-pointer-sign -Wdeclaration-after-statement"
... shouldn't I be using Gentoo ?
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains the ZCheckIfNotice/select loop used for waiting for | |
| 3 | * a notice, with a timeout. | |
| 4 | * | |
| 5 | * Created by: <Joe Random Hacker> | |
| 6 | * | |
| 7 | * $Source$ | |
| 10867 | 8 | * $Author: thekingant $ |
| 2086 | 9 | * |
| 10 | * Copyright (c) 1991 by the Massachusetts Institute of Technology. | |
| 11 | * For copying and distribution information, see the file | |
| 12 | * "mit-copyright.h". | |
| 13 | */ | |
| 14 | ||
| 15 | #include "mit-copyright.h" | |
| 16 | ||
| 17 | #ifndef lint | |
| 18 | static char rcsid_ZWaitForNotice_c[] = "$Zephyr$"; | |
| 19 | #endif | |
| 20 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
21 | #include "internal.h" |
| 10867 | 22 | |
| 23 | #ifdef WIN32 | |
| 24 | #include <winsock2.h> | |
| 25 | ||
| 26 | #ifndef ZEPHYR_USES_KERBEROS | |
| 27 | static int gettimeofday(struct timeval* tv, struct timezone* tz){ | |
| 28 | union { | |
| 29 | long long ns100; /*time since 1 Jan 1601 in 100ns units */ | |
| 30 | FILETIME ft; | |
| 31 | } _now; | |
| 32 | ||
| 33 | GetSystemTimeAsFileTime( &(_now.ft) ); | |
| 34 | tv->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL ); | |
| 35 | tv->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL); | |
| 36 | return 0; | |
| 37 | } | |
| 38 | #endif | |
| 39 | ||
| 40 | #else | |
| 2086 | 41 | #include <sys/socket.h> |
| 10867 | 42 | #endif |
| 2086 | 43 | |
| 44 | Code_t Z_WaitForNotice (notice, pred, arg, timeout) | |
| 45 | ZNotice_t *notice; | |
| 46 | int (*pred) __P((ZNotice_t *, void *)); | |
| 47 | void *arg; | |
| 48 | int timeout; | |
| 49 | { | |
| 50 | Code_t retval; | |
| 51 | struct timeval tv, t0; | |
| 52 | fd_set fdmask; | |
| 53 | int i, fd; | |
| 54 | ||
| 55 | retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred, | |
| 56 | (char *) arg); | |
| 57 | if (retval == ZERR_NONE) | |
| 58 | return ZERR_NONE; | |
| 59 | if (retval != ZERR_NONOTICE) | |
| 60 | return retval; | |
| 61 | ||
| 62 | fd = ZGetFD (); | |
| 63 | FD_ZERO (&fdmask); | |
| 64 | tv.tv_sec = timeout; | |
| 65 | tv.tv_usec = 0; | |
| 10867 | 66 | gettimeofday (&t0, (struct timezone *)NULL); |
| 2086 | 67 | t0.tv_sec += timeout; |
| 68 | while (1) { | |
| 69 | FD_SET (fd, &fdmask); | |
| 70 | i = select (fd + 1, &fdmask, (fd_set *) 0, (fd_set *) 0, &tv); | |
| 71 | if (i == 0) | |
| 72 | return ETIMEDOUT; | |
| 73 | if (i < 0 && errno != EINTR) | |
| 74 | return errno; | |
| 75 | if (i > 0) { | |
| 76 | retval = ZCheckIfNotice (notice, (struct sockaddr_in *) 0, pred, | |
| 77 | (char *) arg); | |
| 78 | if (retval != ZERR_NONOTICE) /* includes ZERR_NONE */ | |
| 79 | return retval; | |
| 80 | } | |
| 10867 | 81 | gettimeofday (&tv, (struct timezone *) NULL); |
| 2086 | 82 | tv.tv_usec = t0.tv_usec - tv.tv_usec; |
| 83 | if (tv.tv_usec < 0) { | |
| 84 | tv.tv_usec += 1000000; | |
| 85 | tv.tv_sec = t0.tv_sec - tv.tv_sec - 1; | |
| 86 | } | |
| 87 | else | |
| 88 | tv.tv_sec = t0.tv_sec - tv.tv_sec; | |
| 89 | } | |
| 90 | /*NOTREACHED*/ | |
| 91 | } |