doc: gnunet-c-tutorial: example 6.
authorng0 <ng0@infotropique.org>
Tue, 5 Sep 2017 12:10:12 +0000 (12:10 +0000)
committerng0 <ng0@infotropique.org>
Tue, 5 Sep 2017 12:10:12 +0000 (12:10 +0000)
doc/gnunet-c-tutorial.texi
doc/tutorial-examples/006.c [new file with mode: 0644]

index a08888845403f722cb6a1f68e9aa158c80033c4a..6b2c770f3695443b5303d9847a23efb8c9778b70 100644 (file)
@@ -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 (file)
index 0000000..944d2b1
--- /dev/null
@@ -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 ()
+};