From 2a79930d731c6d85df0fc46e869a4466dbf1d1fd Mon Sep 17 00:00:00 2001 From: "Robert S. French" Date: Fri, 12 Jun 1987 12:58:47 +0000 Subject: First working library - safe checkin --- lib/ZCkIfNot.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/ZCkIfNot.c (limited to 'lib/ZCkIfNot.c') diff --git a/lib/ZCkIfNot.c b/lib/ZCkIfNot.c new file mode 100644 index 0000000..71622f2 --- /dev/null +++ b/lib/ZCkIfNot.c @@ -0,0 +1,55 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains source for the ZCheckIfNotice function. + * + * Created by: Robert French + * + * $Source$ + * $Author$ + * + * Copyright (c) 1987 by the Massachusetts Institute of Technology. + * For copying and distribution information, see the file + * "mit-copyright.h". + */ +/* $Header$ */ + +#include + +#include + +Code_t ZCheckIfNotice(buffer,buffer_len,notice,auth,predicate,args) + ZPacket_t buffer; + int buffer_len; + ZNotice_t *notice; + int *auth; + int (*predicate)(); + char *args; +{ + ZNotice_t tmpnotice; + int qcount,retval,tmpauth; + struct _Z_InputQ *qptr; + + if ((retval = Z_ReadEnqueue()) != ZERR_NONE) + return (retval); + + qptr = __Q_Head; + qcount = __Q_Length; + + for (;qcount;qcount--) { + if ((retval = ZParseNotice(qptr->packet,qptr->packet_len, + &tmpnotice,&tmpauth)) != ZERR_NONE) + return (retval); + if ((predicate)(&tmpnotice,args)) { + if (qptr->packet_len > buffer_len) + return (ZERR_PKTLEN); + bcopy(qptr->packet,buffer,qptr->packet_len); + if ((retval = ZParseNotice(buffer,qptr->packet_len, + notice,auth)) + != ZERR_NONE) + return (retval); + return (Z_RemQueue(qptr)); + } + qptr = qptr->next; + } + + return (ZERR_NONOTICE); +} -- cgit v1.2.3