summaryrefslogtreecommitdiff
path: root/libpipe/pq.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-27 15:32:39 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-04-27 15:32:39 +0200
commit980e2112cf7a987df40b3157a417ad0e3a831476 (patch)
treee447c8095073e225102360ccbfce8a42eda83f4d /libpipe/pq.h
parent69bd9b1d600debf7b758cc7f8353b747430259b4 (diff)
Add MSG_PEEK support to pflocal
* libpipe/pq.h (packet_peek): Declare new function. * libpipe/pq.c (packet_read): Move code to new `packet_fetch' function, call it with `remove' set to 1. (packet_fetch): New function with code from `packet_read', but do not remove data if `remove' is 0. (packet_peek): New function, calls `packet_fetch' with `remove' set to 0. * libpipe/dgram.c (dgram_read): When MSG_PEEK is in *flags, do not dequeue and only peek data. * libpipe/seqpack.c (seqpack_read): Likewise. * libpipe/stream.c (stream_read): Likewise. * pflocal/socket.c (S_socket_recv): Pass MSG_PEEK flag to libpipe.
Diffstat (limited to 'libpipe/pq.h')
-rw-r--r--libpipe/pq.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libpipe/pq.h b/libpipe/pq.h
index 0fffe254..4e500b6c 100644
--- a/libpipe/pq.h
+++ b/libpipe/pq.h
@@ -98,6 +98,13 @@ error_t packet_write (struct packet *packet,
error_t packet_read (struct packet *packet,
char **data, size_t *data_len, size_t amount);
+/* Peek up to AMOUNT bytes from the beginning of the data in PACKET, and
+ puts it into *DATA, and the amount read into DATA_LEN. If more than the
+ original *DATA_LEN bytes are available, new memory is vm_allocated, and
+ the address and length of this array put into DATA and DATA_LEN. */
+error_t packet_peek (struct packet *packet,
+ char **data, size_t *data_len, size_t amount);
+
/* Returns any ports in PACKET in PORTS and NUM_PORTS, and removes them from
PACKET. */
error_t packet_read_ports (struct packet *packet,