]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZPeekPkt.c
r4266@bucket (orig r256): kcr | 2008-01-20 22:39:30 -0500
[1ts-debian.git] / zephyr / lib / ZPeekPkt.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for ZPeekPacket function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id$
7  *
8  *      Copyright (c) 1987 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 const char rcsid_ZPeekPacket_c[] = "$Id$";
15 #endif
16
17 #include <internal.h>
18
19 Code_t
20 ZPeekPacket(char **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     
34     if (!(*buffer = (char *) malloc((unsigned) *ret_len)))
35         return (ENOMEM);
36
37     (void) memcpy(*buffer, nextq->packet, *ret_len);
38
39     if (from)
40         *from = nextq->from;
41         
42     return (ZERR_NONE);
43 }