From fb769aeaff23e79e4167823ef2923a7d61807718 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 4 Aug 2016 21:31:36 +0200 Subject: Add libcoopgamma_skip_message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile.in | 2 +- doc/man/libcoopgamma_skip_message.3 | 30 ++++++++++++++++++++++++++++++ doc/man/libcoopgamma_synchronise.3 | 1 + src/libcoopgamma.c | 13 +++++++++++++ src/libcoopgamma.h | 8 ++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 doc/man/libcoopgamma_skip_message.3 diff --git a/Makefile.in b/Makefile.in index 79feb2e..9ad73ba 100644 --- a/Makefile.in +++ b/Makefile.in @@ -56,7 +56,7 @@ _MAN_3 = $(foreach T,$(__TYPES),$(foreach F,destroy initialise marshal unmarshal $(foreach P,$(__PROTOCOLS),$(foreach F,recv send sync,libcoopgamma_$(P)_$(F))) \ libcoopgamma_connect libcoopgamma_flush libcoopgamma_get_method_and_site \ libcoopgamma_get_methods libcoopgamma_get_pid_file libcoopgamma_get_socket_file \ - libcoopgamma_set_nonblocking libcoopgamma_synchronise + libcoopgamma_set_nonblocking libcoopgamma_synchronise libcoopgamma_skip_message _MAN_7 = libcoopgamma # Used by mk/copy.mk diff --git a/doc/man/libcoopgamma_skip_message.3 b/doc/man/libcoopgamma_skip_message.3 new file mode 100644 index 0000000..13eb6cc --- /dev/null +++ b/doc/man/libcoopgamma_skip_message.3 @@ -0,0 +1,30 @@ +.TH LIBCOOPGAMMA_SKIP_MESSAGE 3 LIBCOOPGAMMA +.SH "NAME" +libcoopgamma_skip_message - Skip a received message +.SH "SYNOPSIS" +.nf +#include + +void libcoopgamma_skip_message(libcoopgamma_context_t *restrict \fIctx\fP); +.fi +.P +Link with +.IR -lcoopgamma . +.SH "DESCRIPTION" +The +.BR libcoopgamma_skip_message () +function is used to tell the library that you +are not interested in a message recieved for +.IR ctx . +This can be the case if +.BR libcoopgamma_synchronise (3) +selected an asynchronous call context that +is inactive. +.SH "SEE ALSO" +.BR libcoopgamma_flush (3), +.BR libcoopgamma_set_nonblocking (3), +.BR libcoopgamma_synchronise (3), +.BR libcoopgamma_get_crtcs_sync (3), +.BR libcoopgamma_get_gamma_info_sync (3), +.BR libcoopgamma_get_gamma_sync (3), +.BR libcoopgamma_set_gamma_sync (3) diff --git a/doc/man/libcoopgamma_synchronise.3 b/doc/man/libcoopgamma_synchronise.3 index d466778..70d2f63 100644 --- a/doc/man/libcoopgamma_synchronise.3 +++ b/doc/man/libcoopgamma_synchronise.3 @@ -87,6 +87,7 @@ first contexts in .SH "SEE ALSO" .BR libcoopgamma_flush (3), .BR libcoopgamma_set_nonblocking (3), +.BR libcoopgamma_skip_message (3), .BR libcoopgamma_get_crtcs_recv (3), .BR libcoopgamma_get_gamma_info_recv (3), .BR libcoopgamma_get_gamma_recv (3), diff --git a/src/libcoopgamma.c b/src/libcoopgamma.c index fbdef21..c4f13ab 100644 --- a/src/libcoopgamma.c +++ b/src/libcoopgamma.c @@ -1741,6 +1741,19 @@ static char* next_payload(libcoopgamma_context_t* restrict ctx, size_t* n) } +/** + * Tell the library that you will not be parsing a receive message + * + * @param ctx The state of the library, must be connected + */ +void libcoopgamma_skip_message(libcoopgamma_context_t* restrict ctx) +{ + size_t _n; + while (*next_header(ctx)); + (void) next_payload(ctx, &_n); +} + + /** * Check whether the server sent an error, if so copy it to `ctx` * diff --git a/src/libcoopgamma.h b/src/libcoopgamma.h index f670afa..1022f1e 100644 --- a/src/libcoopgamma.h +++ b/src/libcoopgamma.h @@ -1465,6 +1465,14 @@ LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__(1, 4), __leaf__))) int libcoopgamma_synchronise(libcoopgamma_context_t* restrict, libcoopgamma_async_context_t* restrict, size_t, size_t* restrict); +/** + * Tell the library that you will not be parsing a receive message + * + * @param ctx The state of the library, must be connected + */ +LIBCOOPGAMMA_GCC_ONLY(__attribute__((__nonnull__))) +void libcoopgamma_skip_message(libcoopgamma_context_t* restrict); + /** * List all available CRTC:s, send request part -- cgit v1.2.3-70-g09d2