| 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 * Copyright (c) 1987 by the Massachusetts Institute of Technology. |
|
| 7 * For copying and distribution information, see the file |
|
| 8 * "mit-copyright.h". |
|
| 9 */ |
|
| 10 |
|
| 11 #include "internal.h" |
|
| 12 |
|
| 13 Code_t |
|
| 14 ZPeekPacket(char **buffer, int *ret_len, struct sockaddr_in *from) |
|
| 15 { |
|
| 16 Code_t retval; |
|
| 17 struct _Z_InputQ *nextq; |
|
| 18 |
|
| 19 if ((retval = Z_WaitForComplete()) != ZERR_NONE) |
|
| 20 return (retval); |
|
| 21 |
|
| 22 nextq =Z_GetFirstComplete(); |
|
| 23 |
|
| 24 *ret_len = nextq->packet_len; |
|
| 25 |
|
| 26 if (!(*buffer = (char *) malloc((unsigned) *ret_len))) |
|
| 27 return (ENOMEM); |
|
| 28 |
|
| 29 (void) memcpy(*buffer, nextq->packet, *ret_len); |
|
| 30 |
|
| 31 if (from) |
|
| 32 *from = nextq->from; |
|
| 33 |
|
| 34 return (ZERR_NONE); |
|
| 35 } |
|