gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] branch master updated: add taler-twister co


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] branch master updated: add taler-twister command-line tool
Date: Sat, 20 Jan 2018 15:13:21 +0100

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

grothoff pushed a commit to branch master
in repository twister.

The following commit(s) were added to refs/heads/master by this push:
     new 23c4e69  add taler-twister command-line tool
23c4e69 is described below

commit 23c4e697f14c6f9a3a870679fb3732983753bf49
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Jan 20 15:13:18 2018 +0100

    add taler-twister command-line tool
---
 .gitignore                          |   1 +
 src/include/taler_twister_service.h |   2 +
 src/twister/Makefile.am             |   9 ++-
 src/twister/taler-twister.c         | 157 ++++++++++++++++++++++++++++++++++++
 4 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index cf07346..2b38e50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@ src/include/Makefile.in
 src/twister/Makefile
 src/twister/Makefile.in
 src/twister/taler-twister-service
+src/twister/taler-twister
 stamp-h1
 test-driver
 twister_config.h
diff --git a/src/include/taler_twister_service.h 
b/src/include/taler_twister_service.h
index cb43bf6..281822b 100644
--- a/src/include/taler_twister_service.h
+++ b/src/include/taler_twister_service.h
@@ -34,6 +34,8 @@ extern "C"
 #endif
 #endif
 
+#include <gnunet/gnunet_util_lib.h>
+
 /**
  * Version of the twister API.
  */
diff --git a/src/twister/Makefile.am b/src/twister/Makefile.am
index ceedf0a..e1b74cd 100644
--- a/src/twister/Makefile.am
+++ b/src/twister/Makefile.am
@@ -7,7 +7,8 @@ if USE_COVERAGE
 endif
 
 bin_PROGRAMS = \
-  taler-twister-service
+  taler-twister-service \
+  taler-twister
 
 taler_twister_service_SOURCES = \
   taler-twister-service.c
@@ -18,6 +19,12 @@ taler_twister_service_LDADD = \
   -ljansson \
   -lgnunetutil
 
+taler_twister_SOURCES = taler-twister.c
+taler_twister_LDADD = \
+  libtalertwister.la \
+  -lgnunetutil \
+  $(XLIB) $(GN_LIBINTL)
+
 
 lib_LTLIBRARIES = libtalertwister.la
 
diff --git a/src/twister/taler-twister.c b/src/twister/taler-twister.c
new file mode 100644
index 0000000..f8aaf95
--- /dev/null
+++ b/src/twister/taler-twister.c
@@ -0,0 +1,157 @@
+/*
+      This file is part of Taler
+      Copyright (C) 2008--2014, 2016 GNUnet e.V.
+      Copyright (C) 2018 Taler Systems SA
+
+      Taler is free software; you can redistribute it and/or modify
+      it under the terms of the GNU General Public License as published
+      by the Free Software Foundation; either version 3, or (at your
+      option) any later version.
+
+      Taler is distributed in the hope that it will be useful, but
+      WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+      General Public License for more details.
+
+      You should have received a copy of the GNU General Public License
+      along with Taler; see the file COPYING.  If not, write to the
+      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+      Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file taler-twister.c
+ * @brief
+ * @author
+ */
+
+#include "platform.h"
+#include "taler_twister_service.h"
+
+/**
+ * The handle to the Twister service
+ */
+static struct TALER_TWISTER_Handle *tth;
+
+/**
+ * The program status; 0 for success.
+ */
+static int status;
+
+/**
+ * What response code value should twister hack into the connection?
+ * 0 for no change.
+ */
+static unsigned int hack_response_code;
+
+/**
+ * Number of operations we launched.
+ */
+static unsigned int num_ops;
+
+
+/**
+ * Task to shutdown and clean up all state
+ *
+ * @param cls NULL
+ */
+static void
+do_shutdown (void *cls)
+{
+  if (NULL != tth)
+  {
+    TALER_TWISTER_disconnect (tth);
+    tth = NULL;
+  }
+}
+
+
+/**
+ * Callback to call when operation is complete
+ *
+ * @param cls NULL
+ */
+static void
+handle_acknowledgement (void *cls)
+{
+  num_ops--;
+  if (0 != num_ops)
+    return;
+  status = 0;
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
+ * Actual main function that runs the emulation.
+ *
+ * @param cls unused
+ * @param args remaining args, unused
+ * @param cfgfile name of the configuration
+ * @param cfg configuration handle
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  tth = TALER_TWISTER_connect (cfg);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                NULL);
+  if (NULL == tth)
+  {
+    GNUNET_break (0);
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  if ( (0 != hack_response_code) &&
+       (NULL !=
+        TALER_TWISTER_change_response_code (tth,
+                                            hack_response_code,
+                                            &handle_acknowledgement,
+                                            NULL)) )
+    num_ops++;
+
+  /* TODO: add other operations here */
+
+  if (0 == num_ops)
+  {
+    fprintf (stderr,
+             "No valid hacks specified!\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+}
+
+
+/**
+ * Main function.
+ *
+ * @return 0 on success
+ */
+int
+main (int argc,
+      char *const *argv)
+{
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_option_uint ('r',
+                               "responsecode",
+                               "STATUS",
+                               gettext_noop ("set the next response code to 
STATUS"),
+                               &hack_response_code),
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  status = 1;
+  if (GNUNET_OK !=
+      GNUNET_PROGRAM_run (argc,
+                         argv,
+                         "taler-twister",
+                         gettext_noop
+                         ("Control taler-twister service."),
+                         options,
+                         &run, NULL))
+    return 2;
+  return status;
+}

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



reply via email to

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