gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 01/06: doc: gnunet-c-tutorial: move example code t


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 01/06: doc: gnunet-c-tutorial: move example code to separate files.
Date: Tue, 05 Sep 2017 14:23:52 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnunet.

commit d4f04e4d62663a108cf3100d9168c962a95b56c3
Author: ng0 <address@hidden>
AuthorDate: Tue Sep 5 12:03:16 2017 +0000

    doc: gnunet-c-tutorial: move example code to separate files.
---
 doc/gnunet-c-tutorial.texi  | 66 +++++----------------------------------------
 doc/tutorial-examples/001.c | 29 ++++++++++++++++++++
 doc/tutorial-examples/002.c | 17 ++++++++++++
 doc/tutorial-examples/003.c |  7 +++++
 4 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/doc/gnunet-c-tutorial.texi b/doc/gnunet-c-tutorial.texi
index ba443e674..12348801a 100644
--- a/doc/gnunet-c-tutorial.texi
+++ b/doc/gnunet-c-tutorial.texi
@@ -579,37 +579,8 @@ function.  This function will parse command-line options, 
setup the scheduler
 and then invoke the @code{run} function (with the remaining non-option 
arguments)
 and a handle to the parsed configuration (and the configuration file name that 
was
 used, which is typically not needed):
-
-\lstset{language=C}
-\begin{lstlisting}
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-static int ret;
-
-static void
-run (void *cls,
-     char *const *args,
-     const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  // main code here
-  ret = 0;
-}
-
-int
-main (int argc, char *const *argv)
-{
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  return (GNUNET_OK ==
-          GNUNET_PROGRAM_run (argc,
-                              argv,
-                              "binary-name",
-                              gettext_noop ("binary description text"),
-                              options, &run, NULL)) ? ret : 1;
-}
address@hidden
address@hidden tutorial-examples/001.c
 @end example
 
 @subsection Handling command-line options}
@@ -618,25 +589,8 @@ Options can then be added easily by adding global 
variables and
 expanding the {\tt options} array.  For example, the following would
 add a string-option and a binary flag (defaulting to @code{NULL} and
 @code{GNUNET\_NO} respectively):
-
-\lstset{language=C}
-\begin{lstlisting}
-static char *string_option;
-static int a_flag;
-
-// ...
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_string ('s', "name", "SOMESTRING",
-     gettext_noop ("text describing the string_option NAME"),
-     &string_option},
-    GNUNET_GETOPT_option_flag ('f', "flag",
-     gettext_noop ("text describing the flag option"), 
-     &a_flag),
-    GNUNET_GETOPT_OPTION_END
-  };
-  string_option = NULL;
-  a_flag = GNUNET_SYSERR;
-// ...
address@hidden
address@hidden tutorial-examples/002.c
 @end example
 
 Issues such as displaying some helpful text describing options using
@@ -683,16 +637,8 @@ file).
 
 Before a client library can implement the application-specific protocol
 with the service, a connection must be created:
-
-\lstset{language=C}
-\begin{lstlisting}
-  struct GNUNET_MQ_MessageHandlers handlers[] = {
-    // ...
-    GNUNET_MQ_handler_end ()
-  };
-  struct GNUNET_MQ_Handle *mq;
-
-  mq = GNUNET_CLIENT_connect (cfg, "service-name", handlers, &error_cb, NULL);
address@hidden
address@hidden tutorial-examples/003.c
 @end example
 
 As a result a {\tt GNUNET\_MQ\_Handle} is returned
diff --git a/doc/tutorial-examples/001.c b/doc/tutorial-examples/001.c
new file mode 100644
index 000000000..7f6699dd2
--- /dev/null
+++ b/doc/tutorial-examples/001.c
@@ -0,0 +1,29 @@
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+
+static int ret;
+
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  // main code here
+  ret = 0;
+}
+
+int
+main (int argc, char *const *argv)
+{
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  return (GNUNET_OK ==
+          GNUNET_PROGRAM_run (argc,
+                              argv,
+                              "binary-name",
+                              gettext_noop ("binary description text"),
+                              options, &run, NULL)) ? ret : 1;
+}
+
diff --git a/doc/tutorial-examples/002.c b/doc/tutorial-examples/002.c
new file mode 100644
index 000000000..02233fd61
--- /dev/null
+++ b/doc/tutorial-examples/002.c
@@ -0,0 +1,17 @@
+static char *string_option;
+static int a_flag;
+
+// ...
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_option_string ('s', "name", "SOMESTRING",
+     gettext_noop ("text describing the string_option NAME"),
+     &string_option},
+    GNUNET_GETOPT_option_flag ('f', "flag",
+     gettext_noop ("text describing the flag option"), 
+     &a_flag),
+    GNUNET_GETOPT_OPTION_END
+  };
+  string_option = NULL;
+  a_flag = GNUNET_SYSERR;
+// ...
+
diff --git a/doc/tutorial-examples/003.c b/doc/tutorial-examples/003.c
new file mode 100644
index 000000000..d13681ca6
--- /dev/null
+++ b/doc/tutorial-examples/003.c
@@ -0,0 +1,7 @@
+  struct GNUNET_MQ_MessageHandlers handlers[] = {
+    // ...
+    GNUNET_MQ_handler_end ()
+  };
+  struct GNUNET_MQ_Handle *mq;
+
+  mq = GNUNET_CLIENT_connect (cfg, "service-name", handlers, &error_cb, NULL);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]