aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorng0 <ng0@infotropique.org>2017-09-05 12:10:12 +0000
committerng0 <ng0@infotropique.org>2017-09-05 12:10:12 +0000
commit0406fa6f2e3b6014f465c4d987759324065375df (patch)
tree4d683df45177924f1dd951cce645884399682ef3 /doc
parentdca832adb5eb0ad336b0baaebf8d826c9b5ed125 (diff)
downloadgnunet-0406fa6f2e3b6014f465c4d987759324065375df.tar.gz
gnunet-0406fa6f2e3b6014f465c4d987759324065375df.zip
doc: gnunet-c-tutorial: example 6.
Diffstat (limited to 'doc')
-rw-r--r--doc/gnunet-c-tutorial.texi36
-rw-r--r--doc/tutorial-examples/006.c31
2 files changed, 33 insertions, 34 deletions
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
693checked by the MQ-logic, and thus only need to provide the handler 693checked by the MQ-logic, and thus only need to provide the handler
694to process the message. Note that the prefixes {\tt check\_} 694to process the message. Note that the prefixes {\tt check\_}
695and {\tt handle\_} are mandatory. 695and {\tt handle\_} are mandatory.
696 696@example
697\lstset{language=c} 697@verbatiminclude tutorial-examples/006.c
698\begin{lstlisting}
699static void
700handle_fix (void *cls, const struct MyMessage *msg)
701{
702 // process 'msg'
703}
704
705static int
706check_var (void *cls, const struct MyVarMessage *msg)
707{
708 // check 'msg' is well-formed
709 return GNUNET_OK;
710}
711
712static void
713handle_var (void *cls, const struct MyVarMessage *msg)
714{
715 // process 'msg'
716}
717
718struct GNUNET_MQ_MessageHandler handlers[] = {
719 GNUNET_MQ_hd_fixed_size (fix,
720 GNUNET_MESSAGE_TYPE_MY_FIX,
721 struct MyMessage,
722 NULL),
723 GNUNET_MQ_hd_fixed_size (var,
724 GNUNET_MESSAGE_TYPE_MY_VAR,
725 struct MyVarMessage,
726 NULL),
727
728 GNUNET_MQ_handler_end ()
729};
730@end example 698@end example
731 699
732Exercise: Expand your helper function to receive a response message 700Exercise: 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 @@
1static void
2handle_fix (void *cls, const struct MyMessage *msg)
3{
4 // process 'msg'
5}
6
7static int
8check_var (void *cls, const struct MyVarMessage *msg)
9{
10 // check 'msg' is well-formed
11 return GNUNET_OK;
12}
13
14static void
15handle_var (void *cls, const struct MyVarMessage *msg)
16{
17 // process 'msg'
18}
19
20struct GNUNET_MQ_MessageHandler handlers[] = {
21 GNUNET_MQ_hd_fixed_size (fix,
22 GNUNET_MESSAGE_TYPE_MY_FIX,
23 struct MyMessage,
24 NULL),
25 GNUNET_MQ_hd_fixed_size (var,
26 GNUNET_MESSAGE_TYPE_MY_VAR,
27 struct MyVarMessage,
28 NULL),
29
30 GNUNET_MQ_handler_end ()
31};