[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 03/06: doc: gnunet-c-tutorial: include example 4 a
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 03/06: doc: gnunet-c-tutorial: include example 4 and 5. |
Date: |
Tue, 05 Sep 2017 14:23:54 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnunet.
commit dca832adb5eb0ad336b0baaebf8d826c9b5ed125
Author: ng0 <address@hidden>
AuthorDate: Tue Sep 5 12:08:13 2017 +0000
doc: gnunet-c-tutorial: include example 4 and 5.
---
doc/gnunet-c-tutorial.texi | 22 ++++------------------
doc/tutorial-examples/004.c | 5 +++++
doc/tutorial-examples/005.c | 8 ++++++++
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/doc/gnunet-c-tutorial.texi b/doc/gnunet-c-tutorial.texi
index 2973dd779..a08888845 100644
--- a/doc/gnunet-c-tutorial.texi
+++ b/doc/gnunet-c-tutorial.texi
@@ -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;
-};
address@hidden
address@hidden 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);
address@hidden
address@hidden 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
index 000000000..0ef007907
--- /dev/null
+++ b/doc/tutorial-examples/004.c
@@ -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
index 000000000..0c459f509
--- /dev/null
+++ b/doc/tutorial-examples/005.c
@@ -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);
+
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (c1a9bb5df -> 2efea52ad), gnunet, 2017/09/05
- [GNUnet-SVN] [gnunet] 02/06: doc: gnunet-c-tutorial: include testbed_test.c, gnunet, 2017/09/05
- [GNUnet-SVN] [gnunet] 01/06: doc: gnunet-c-tutorial: move example code to separate files., gnunet, 2017/09/05
- [GNUnet-SVN] [gnunet] 03/06: doc: gnunet-c-tutorial: include example 4 and 5.,
gnunet <=
- [GNUnet-SVN] [gnunet] 04/06: doc: gnunet-c-tutorial: example 6., gnunet, 2017/09/05
- [GNUnet-SVN] [gnunet] 06/06: Merge branch 'master' of gnunet.org:gnunet, gnunet, 2017/09/05
- [GNUnet-SVN] [gnunet] 05/06: doc: gnunet-c-tutorial: more includes of examples., gnunet, 2017/09/05