]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZPeekPkt.c
Initial revision
[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: ZPeekPkt.c,v 1.13 1999/01/22 23:19:20 ghudson Exp $
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 char rcsid_ZPeekPacket_c[] = "$Id: ZPeekPkt.c,v 1.13 1999/01/22 23:19:20 ghudson Exp $";
15 #endif
16
17 #include <internal.h>
18
19 Code_t ZPeekPacket(buffer, ret_len, from)
20     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 }