doc: gnunet-c-tutorial: include example 4 and 5.
authorng0 <ng0@infotropique.org>
Tue, 5 Sep 2017 12:08:13 +0000 (12:08 +0000)
committerng0 <ng0@infotropique.org>
Tue, 5 Sep 2017 12:09:01 +0000 (12:09 +0000)
doc/gnunet-c-tutorial.texi
doc/tutorial-examples/004.c [new file with mode: 0644]
doc/tutorial-examples/005.c [new file with mode: 0644]

index 2973dd779bf891504f725e45bc142f2589991e9f..a08888845403f722cb6a1f68e9aa158c80033c4a 100644 (file)
@@ -657,28 +657,14 @@ there are errors communicating with the service.
 In GNUnet, messages are always sent beginning with a {\tt struct GNUNET\_MessageHeader}
 in big endian format. This header defines the size and the type of the
 message, the payload follows after this header.
-
-\lstset{language=C}
-\begin{lstlisting}
-struct GNUNET_MessageHeader
-{
-  uint16_t size GNUNET_PACKED;
-  uint16_t type GNUNET_PACKED;
-};
+@example
+@verbatiminclude tutorial-examples/004.c
 @end example
 
 Existing message types are defined in @file{gnunet\_protocols.h}\\
 A common way to create a message is with an envelope:
-
-\lstset{language=C}
-\begin{lstlisting}
-struct GNUNET_MQ_Envelope *env;
-struct GNUNET_MessageHeader *msg;
-
-env = GNUNET_MQ_msg_extra (msg, payload_size, GNUNET_MY_MESSAGE_TYPE);
-memcpy (&msg[1], &payload, payload_size);
-// Send message via message queue 'mq'
-GNUNET_mq_send (mq, env);
+@example
+@verbatiminclude tutorial-examples/005.c
 @end example
 
 Exercise: Define a message struct that includes a 32-bit
diff --git a/doc/tutorial-examples/004.c b/doc/tutorial-examples/004.c
new file mode 100644 (file)
index 0000000..0ef0079
--- /dev/null
@@ -0,0 +1,5 @@
+struct GNUNET_MessageHeader
+{
+  uint16_t size GNUNET_PACKED;
+  uint16_t type GNUNET_PACKED;
+};
diff --git a/doc/tutorial-examples/005.c b/doc/tutorial-examples/005.c
new file mode 100644 (file)
index 0000000..0c459f5
--- /dev/null
@@ -0,0 +1,8 @@
+struct GNUNET_MQ_Envelope *env;
+struct GNUNET_MessageHeader *msg;
+
+env = GNUNET_MQ_msg_extra (msg, payload_size, GNUNET_MY_MESSAGE_TYPE);
+memcpy (&msg[1], &payload, payload_size);
+// Send message via message queue 'mq'
+GNUNET_mq_send (mq, env);
+