[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/02: initial work on command line tool
From: |
gnunet |
Subject: |
[taler-anastasis] 02/02: initial work on command line tool |
Date: |
Sat, 16 May 2020 12:25:59 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 92edf5d83f11de6ffa0d24a7d2194848f082d384
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sat May 16 10:25:49 2020 +0000
initial work on command line tool
---
.gitignore | 5 +-
configure.ac | 1 +
src/Makefile.am | 2 +-
src/backend/anastasis-httpd.c | 2 +-
src/cli/Makefile.am | 35 +++++++++++
src/cli/anastasis-cli-splitter.c | 128 +++++++++++++++++++++++++++++++++++++++
src/cli/anastasis-cli.c | 25 --------
7 files changed, 170 insertions(+), 28 deletions(-)
diff --git a/.gitignore b/.gitignore
index 59e8fbb..d9271bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,4 +90,7 @@ src/statis/vgcore.*
src/lib/valgrind*.txt
src/stasis/valgrind*.txt
src/util/valgrind*.txt
-src/lib/test_anastasis
\ No newline at end of file
+src/lib/test_anastasis
+src/cli/anastasis-splitter
+src/cli/.deps/
+src/cli/.deps/anastasis-cli-splitter.Po
diff --git a/configure.ac b/configure.ac
index 1250b6d..6a8b94d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -305,5 +305,6 @@ src/stasis/Makefile
src/backend/Makefile
src/include/Makefile
src/lib/Makefile
+src/cli/Makefile
])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 4b30680..69a8be0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,3 @@
# This Makefile is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
-SUBDIRS = include util stasis backend lib
+SUBDIRS = include util stasis backend lib cli
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 857fe90..8c0ca14 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -670,7 +670,7 @@ main (int argc,
/* FIRST get the libtalerutil initialization out
of the way. Then throw that one away, and force
- the SYNC defaults to be used! */
+ the ANASTASIS defaults to be used! */
(void) TALER_project_data_default ();
GNUNET_OS_init (ANASTASIS_project_data_default ());
if (GNUNET_OK !=
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
new file mode 100644
index 0000000..cf68ace
--- /dev/null
+++ b/src/cli/Makefile.am
@@ -0,0 +1,35 @@
+# This Makefile.am is in the public domain
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+
+bin_PROGRAMS = \
+ anastasis-splitter
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIB = -lgcov
+endif
+
+anastasis_splitter_SOURCES = \
+ anastasis-cli-splitter.c
+anastasis_splitter_LDADD = \
+ -lanastasis \
+ -lanastasisutil \
+ -lanastasisrest \
+ -ltalermerchant \
+ -ltalerjson \
+ -ltalerutil \
+ -lgnunetjson \
+ -lgnunetcurl \
+ -lgnunetutil \
+ -ljansson \
+ -luuid \
+ $(XLIB)
+
+if HAVE_LIBCURL
+anastasis_splitter_LDADD += -lcurl
+else
+if HAVE_LIBGNURL
+anastasis_splitter_LDADD += -lgnurl
+endif
+endif
+
diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
new file mode 100644
index 0000000..f882e50
--- /dev/null
+++ b/src/cli/anastasis-cli-splitter.c
@@ -0,0 +1,128 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020 Taler Systems SA
+
+ Anastasis is free software; you can redistribute it and/or modify it under
the
+ terms of the GNU Lesser General Public License as published by the Free
Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis 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
+ Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
+*/
+/**
+ * @file cli/anastasis-cli-splitter.c
+ * @brief command line tool for anastasis
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ */
+#include "platform.h"
+#include "anastasis_service.h"
+#include "anastasis.h"
+
+
+/**
+ * Global option '-me' to import json containing details of user.
+ */
+static int import_id;
+
+/**
+ * Reference to the keyboard task
+ */
+static struct GNUNET_SCHEDULER_Task *keyboard_task;
+
+/**
+ * Curl context for communication with taler backend
+ */
+static struct GNUNET_CURL_Context *ctx;
+
+/**
+ * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+static struct GNUNET_CURL_RescheduleContext *rc;
+
+
+/**
+ * @brief Shutdown the application.
+ *
+ * @param cls closure
+ */
+static void
+shutdown_task (void *cls)
+{
+ (void) cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown initiated\n");
+
+ // FIXME shutdown routine here
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown complete (except for MDB)\n");
+}
+
+
+/**
+ * @brief Start the application
+ *
+ * @param cls closure
+ * @param args arguments left
+ * @param cfgfile config file name
+ * @param cfg handle for the configuration file
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ (void) cls;
+ (void) args;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Starting anastasis-splitter\n");
+
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_log_setup ("anastasis-splitter",
+ "WARNING",
+ NULL));
+
+ /* initialize HTTP client */
+ ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc);
+ rc = GNUNET_CURL_gnunet_rc_create (ctx);
+}
+
+int
+main (int argc,
+ char*const*argv)
+{
+ int ret;
+
+ /* the available command line options */
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('m',
+ "me",
+ "import json file containing details to create
user identifier",
+ &import_id),
+ GNUNET_GETOPT_OPTION_END
+ };
+
+ ret = GNUNET_PROGRAM_run (argc,
+ argv,
+ "anastasis-splitter",
+ "This is an application for using Anastasis to
split and share a secret.\n",
+ options,
+ &run,
+ NULL);
+
+ return (GNUNET_OK == ret) ? 0 : 1;
+}
+
+/* end of anastasis-cli-spliter.c */
\ No newline at end of file
diff --git a/src/cli/anastasis-cli.c b/src/cli/anastasis-cli.c
deleted file mode 100644
index 4d9ff81..0000000
--- a/src/cli/anastasis-cli.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
-
- Anastasis is free software; you can redistribute it and/or modify it under
the
- terms of the GNU Lesser General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- Anastasis 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
- Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file cli/anastasis-cli.c
- * @brief command line tool for anastasis
- * @author Christian Grothoff
- * @author Dennis Neufeld
- * @author Dominik Meister
- */
-
-
-/* end of anastasis-cli.c */
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.