diff options
author | ng0 <ng0@infotropique.org> | 2017-09-05 12:10:12 +0000 |
---|---|---|
committer | ng0 <ng0@infotropique.org> | 2017-09-05 12:10:12 +0000 |
commit | 0406fa6f2e3b6014f465c4d987759324065375df (patch) | |
tree | 4d683df45177924f1dd951cce645884399682ef3 /doc | |
parent | dca832adb5eb0ad336b0baaebf8d826c9b5ed125 (diff) | |
download | gnunet-0406fa6f2e3b6014f465c4d987759324065375df.tar.gz gnunet-0406fa6f2e3b6014f465c4d987759324065375df.zip |
doc: gnunet-c-tutorial: example 6.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/gnunet-c-tutorial.texi | 36 | ||||
-rw-r--r-- | doc/tutorial-examples/006.c | 31 |
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 | |||
693 | checked by the MQ-logic, and thus only need to provide the handler | 693 | checked by the MQ-logic, and thus only need to provide the handler |
694 | to process the message. Note that the prefixes {\tt check\_} | 694 | to process the message. Note that the prefixes {\tt check\_} |
695 | and {\tt handle\_} are mandatory. | 695 | and {\tt handle\_} are mandatory. |
696 | 696 | @example | |
697 | \lstset{language=c} | 697 | @verbatiminclude tutorial-examples/006.c |
698 | \begin{lstlisting} | ||
699 | static void | ||
700 | handle_fix (void *cls, const struct MyMessage *msg) | ||
701 | { | ||
702 | // process 'msg' | ||
703 | } | ||
704 | |||
705 | static int | ||
706 | check_var (void *cls, const struct MyVarMessage *msg) | ||
707 | { | ||
708 | // check 'msg' is well-formed | ||
709 | return GNUNET_OK; | ||
710 | } | ||
711 | |||
712 | static void | ||
713 | handle_var (void *cls, const struct MyVarMessage *msg) | ||
714 | { | ||
715 | // process 'msg' | ||
716 | } | ||
717 | |||
718 | struct 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 | ||
732 | Exercise: Expand your helper function to receive a response message | 700 | 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 @@ | |||
1 | static void | ||
2 | handle_fix (void *cls, const struct MyMessage *msg) | ||
3 | { | ||
4 | // process 'msg' | ||
5 | } | ||
6 | |||
7 | static int | ||
8 | check_var (void *cls, const struct MyVarMessage *msg) | ||
9 | { | ||
10 | // check 'msg' is well-formed | ||
11 | return GNUNET_OK; | ||
12 | } | ||
13 | |||
14 | static void | ||
15 | handle_var (void *cls, const struct MyVarMessage *msg) | ||
16 | { | ||
17 | // process 'msg' | ||
18 | } | ||
19 | |||
20 | struct 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 | }; | ||