]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZRecvNot.c
Initial revision
[1ts-debian.git] / zephyr / lib / ZRecvNot.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for ZReceiveNotice function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id: ZRecvNot.c,v 1.15 1999/01/22 23:19:21 ghudson Exp $
7  *
8  *      Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
9  *      For copying and distribution information, see the file
10  *      "mit-copyright.h". 
11  */
12
13 #ifndef lint
14 static char rcsid_ZReceiveNotice_c[] = "$Id: ZRecvNot.c,v 1.15 1999/01/22 23:19:21 ghudson Exp $";
15 #endif
16
17 #include <internal.h>
18
19 Code_t ZReceiveNotice(notice, from)
20     ZNotice_t *notice;
21     struct sockaddr_in *from;
22 {
23     char *buffer;
24     struct _Z_InputQ *nextq;
25     int len, auth;
26     Code_t retval;
27
28     if ((retval = Z_WaitForComplete()) != ZERR_NONE)
29         return (retval);
30
31     nextq = Z_GetFirstComplete();
32
33     len = nextq->packet_len;
34     
35     if (!(buffer = (char *) malloc((unsigned) len)))
36         return (ENOMEM);
37
38     if (from)
39         *from = nextq->from;
40     
41     (void) memcpy(buffer, nextq->packet, len);
42
43     auth = nextq->auth;
44     Z_RemQueue(nextq);
45     
46     if ((retval = ZParseNotice(buffer, len, notice)) != ZERR_NONE)
47         return (retval);
48     notice->z_checked_auth = auth;
49     return ZERR_NONE;
50 }