Sat, 19 May 2007 21:38:47 +0000
merge of '1442df274a24edc9a31194327bd00dfbcf478720'
and 'ce02548a6b6a545d97fb3f371506bcf1b5cc5131'
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZCheckIfNotice function. | |
| 3 | * | |
| 4 | * Created by: Robert French | |
| 5 | * | |
| 6 | * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. | |
| 7 | * For copying and distribution information, see the file | |
| 8 | * "mit-copyright.h". | |
| 9 | */ | |
| 10 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2086
diff
changeset
|
11 | #include "internal.h" |
| 2086 | 12 | |
| 13 | Code_t ZCheckIfNotice(notice, from, predicate, args) | |
| 14 | ZNotice_t *notice; | |
| 15 | struct sockaddr_in *from; | |
| 16 | register int (*predicate) __P((ZNotice_t *, void *)); | |
| 17 | void *args; | |
| 18 | { | |
| 19 | ZNotice_t tmpnotice; | |
| 20 | Code_t retval; | |
| 21 | register char *buffer; | |
| 22 | register struct _Z_InputQ *qptr; | |
| 23 | ||
| 24 | if ((retval = Z_ReadEnqueue()) != ZERR_NONE) | |
| 25 | return (retval); | |
| 26 | ||
| 27 | qptr = Z_GetFirstComplete(); | |
| 28 | ||
| 29 | while (qptr) { | |
| 30 | if ((retval = ZParseNotice(qptr->packet, qptr->packet_len, | |
| 31 | &tmpnotice)) != ZERR_NONE) | |
| 32 | return (retval); | |
| 33 | if ((*predicate)(&tmpnotice, args)) { | |
| 34 | if (!(buffer = (char *) malloc((unsigned) qptr->packet_len))) | |
| 35 | return (ENOMEM); | |
| 36 | (void) memcpy(buffer, qptr->packet, qptr->packet_len); | |
| 37 | if (from) | |
| 38 | *from = qptr->from; | |
| 39 | if ((retval = ZParseNotice(buffer, qptr->packet_len, | |
| 40 | notice)) != ZERR_NONE) { | |
| 41 | free(buffer); | |
| 42 | return (retval); | |
| 43 | } | |
| 44 | Z_RemQueue(qptr); | |
| 45 | return (ZERR_NONE); | |
| 46 | } | |
| 47 | qptr = Z_GetNextComplete(qptr); | |
| 48 | } | |
| 49 | ||
| 50 | return (ZERR_NONOTICE); | |
| 51 | } |