1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZIfNotice function.
4 * Created by: Robert French
6 * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, see the file
13 Code_t
ZIfNotice(notice
, from
, predicate
, args
)
15 struct sockaddr_in
*from
;
16 int (*predicate
)(ZNotice_t
*, void *);
22 struct _Z_InputQ
*qptr
;
24 if ((retval
= Z_WaitForComplete()) != ZERR_NONE
)
27 qptr
= Z_GetFirstComplete();
31 if ((retval
= ZParseNotice(qptr
->packet
, qptr
->packet_len
,
32 &tmpnotice
)) != ZERR_NONE
)
34 if ((*predicate
)(&tmpnotice
, args
)) {
35 if (!(buffer
= (char *) malloc((unsigned) qptr
->packet_len
)))
37 (void) memcpy(buffer
, qptr
->packet
, qptr
->packet_len
);
40 if ((retval
= ZParseNotice(buffer
, qptr
->packet_len
,
41 notice
)) != ZERR_NONE
) {
48 qptr
= Z_GetNextComplete(qptr
);
50 if ((retval
= Z_ReadWait()) != ZERR_NONE
)
52 qptr
= Z_GetFirstComplete(); /* need to look over all of
53 the queued messages, in case
54 a fragment has been reassembled */