From: ng0 Date: Tue, 5 Sep 2017 12:10:12 +0000 (+0000) Subject: doc: gnunet-c-tutorial: example 6. X-Git-Tag: gnunet-0.11.0rc0~127 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0406fa6f2e3b6014f465c4d987759324065375df;p=oweals%2Fgnunet.git doc: gnunet-c-tutorial: example 6. --- diff --git a/doc/gnunet-c-tutorial.texi b/doc/gnunet-c-tutorial.texi index a08888845..6b2c770f3 100644 --- a/doc/gnunet-c-tutorial.texi +++ b/doc/gnunet-c-tutorial.texi @@ -693,40 +693,8 @@ to actually process the message. Fixed size messages are fully checked by the MQ-logic, and thus only need to provide the handler to process the message. Note that the prefixes {\tt check\_} and {\tt handle\_} are mandatory. - -\lstset{language=c} -\begin{lstlisting} -static void -handle_fix (void *cls, const struct MyMessage *msg) -{ - // process 'msg' -} - -static int -check_var (void *cls, const struct MyVarMessage *msg) -{ - // check 'msg' is well-formed - return GNUNET_OK; -} - -static void -handle_var (void *cls, const struct MyVarMessage *msg) -{ - // process 'msg' -} - -struct GNUNET_MQ_MessageHandler handlers[] = { - GNUNET_MQ_hd_fixed_size (fix, - GNUNET_MESSAGE_TYPE_MY_FIX, - struct MyMessage, - NULL), - GNUNET_MQ_hd_fixed_size (var, - GNUNET_MESSAGE_TYPE_MY_VAR, - struct MyVarMessage, - NULL), - - GNUNET_MQ_handler_end () -}; +@example +@verbatiminclude tutorial-examples/006.c @end example Exercise: Expand your helper function to receive a response message diff --git a/doc/tutorial-examples/006.c b/doc/tutorial-examples/006.c new file mode 100644 index 000000000..944d2b18c --- /dev/null +++ b/doc/tutorial-examples/006.c @@ -0,0 +1,31 @@ +static void +handle_fix (void *cls, const struct MyMessage *msg) +{ + // process 'msg' +} + +static int +check_var (void *cls, const struct MyVarMessage *msg) +{ + // check 'msg' is well-formed + return GNUNET_OK; +} + +static void +handle_var (void *cls, const struct MyVarMessage *msg) +{ + // process 'msg' +} + +struct GNUNET_MQ_MessageHandler handlers[] = { + GNUNET_MQ_hd_fixed_size (fix, + GNUNET_MESSAGE_TYPE_MY_FIX, + struct MyMessage, + NULL), + GNUNET_MQ_hd_fixed_size (var, + GNUNET_MESSAGE_TYPE_MY_VAR, + struct MyVarMessage, + NULL), + + GNUNET_MQ_handler_end () +};