]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZRecvPkt.c
r4254@bucket (orig r244): kcr | 2008-01-20 14:40:42 -0500
[1ts-debian.git] / zephyr / lib / ZRecvPkt.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for ZReceivePacket function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id$
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_ZReceivePacket_c[] = "$Id$";
15 #endif
16
17 #include <internal.h>
18
19 Code_t
20 ZReceivePacket(ZPacket_t buffer,
21                int *ret_len,
22                struct sockaddr_in *from)
23 {
24     Code_t retval;
25     struct _Z_InputQ *nextq;
26     
27     if ((retval = Z_WaitForComplete()) != ZERR_NONE)
28         return (retval);
29
30     nextq = Z_GetFirstComplete();
31
32     *ret_len = nextq->packet_len;
33     if (*ret_len > Z_MAXPKTLEN)
34         return (ZERR_PKTLEN);
35     
36     (void) memcpy(buffer, nextq->packet, *ret_len);
37
38     if (from)
39         *from = nextq->from;
40         
41     Z_RemQueue(nextq);
42
43     return (ZERR_NONE);
44 }