gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libebics] 03/03: Includes schema refactoring.


From: gnunet
Subject: [GNUnet-SVN] [libebics] 03/03: Includes schema refactoring.
Date: Fri, 26 Oct 2018 11:51:05 +0200

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

marcello pushed a commit to branch master
in repository libebics.

commit b1db59719c57ab6dfbcfb021845ee4cfbd77108c
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Oct 26 11:42:39 2018 +0200

    Includes schema refactoring.
---
 src/Makefile.am     |   1 -
 src/libebics.h      | 196 ++++++++++++++++++++++++++++++++++++++++++++++++----
 src/sandbox_tests.c |  42 +++++++++++
 src/util.h          |  19 ++---
 src/xmlmessages.c   |  25 ++++---
 src/xmlmessages.h   |  79 +--------------------
 src/xmlproto.c      |   8 +--
 src/xmlproto.h      |  54 +++++----------
 8 files changed, 264 insertions(+), 160 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 0f9a72e..bb01775 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,6 @@ AM_TESTS_ENVIRONMENT = \
   export EBICS_PREFIX=$(prefix);
 
 check_PROGRAMS = \
-  dump_tests \
   sandbox_tests
 
 dump_tests_SOURCES = \
diff --git a/src/libebics.h b/src/libebics.h
index 23324f3..c1a70ed 100644
--- a/src/libebics.h
+++ b/src/libebics.h
@@ -1,23 +1,24 @@
 /*
   This file is part of libfints
 
-  libfints 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.
+  libfints 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.
 
-  libfints 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.
+  libfints 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
-  libfints; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/license>
+  You should have received a copy of the GNU General Public
+  License along with libfints; see the file COPYING.  If not,
+  see <http://www.gnu.org/license>
 */
 
 #ifndef EBICS_LIBEBICS_H
 #define EBICS_LIBEBICS_H
 
-#include "util.h"
-#include "xmlmessages.h"
 #include "libxml/xpointer.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/abstract.h>
@@ -30,9 +31,21 @@
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_curl_lib.h>
 
-#define DEBUG EBICS_LOGLEVEL_DEBUG
+/**
+ * Loglevels with different behaviour,
+ * formating and verbosity of log messages.
+ */
+#define EBICS_LOGLEVEL_NONE   -1
+#define EBICS_LOGLEVEL_FATAL   0
+#define EBICS_LOGLEVEL_ERROR   1 
+#define EBICS_LOGLEVEL_WARNING 2 
+#define EBICS_LOGLEVEL_INFO    3
+#define EBICS_LOGLEVEL_DEBUG   4
+
+
 
 #define EBICS_GENEX_MAX_ENTRIES 64
+#define EBICS_GENEX_MAX_NAME 128
 
 #define EBICS_USER_KEYS_NUMBER 3
 #define EBICS_KEY_MAX_ENTRIES 6
@@ -45,6 +58,11 @@
  */
 #define EBICS_REVISION 1 
 
+
+#define EBICS_ERROR 1
+#define EBICS_FATAL -1
+#define EBICS_SUCCESS 0
+
 /**
  * INI & HIA share the same schema.
  */
@@ -57,12 +75,68 @@
 #define EBICS_CAMT053_UNIQUE_TEMPLATE 0
 
 /**
+ * Date format in libebics. 
+ */
+struct EBICS_Date
+{
+  /**
+   * Day 1-31
+   */
+  uint8_t day;
+
+  /**
+   * Month 1-12
+   */
+  uint8_t month;
+
+  /**
+   * Year 0-2^16
+   */
+  uint16_t year;
+};
+
+
+/**
+ * In-memory (parsed) document.
+ */
+struct EBICS_genex_document
+{
+  /**
+   * Name of the document;
+   * tipically matches the name of the parsed file.
+   */
+  char name[EBICS_GENEX_MAX_NAME];
+
+  xmlDocPtr document;
+
+  xmlParserCtxtPtr parser;
+
+  xmlXPathContextPtr xpath;
+};
+
+/**
+ * Struct for "camt053" request
+ */
+struct EBICS_ARGS_build_content_camt053
+{
+  /**
+   *  Starting date
+   */
+  const struct EBICS_Date startdate;
+
+  /**
+   * End Date
+   */
+  const struct EBICS_Date enddate;
+};
+
+/**
  * This struct forces the system to assign the
  * indices (in the global array of keys) to the
  * filename used to import such key.
  */
-struct EBICS_UserKeyFiles {
-
+struct EBICS_UserKeyFiles
+{
   /**
    * Points to the (as per EBICS terminology) "bank-technical
    * public key".  This is the key used to produce "ES", namely
@@ -85,6 +159,96 @@ struct EBICS_UserKeyFiles {
 };
 
 /**
+ * Struct for all build_header_* subcommands
+ */
+struct EBICS_ARGS_build_header
+{
+  /**
+   * See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *hostID;
+
+  /**
+   * See your banks ebics login information
+   * (probably recieved via (snail) mail
+   */
+  const char *partnerID;
+
+  /**
+   * See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *userID;
+
+  /**
+   * Name of the product using the library.
+   */
+  const char *productName;
+
+  /**
+   * ISO-(TODO) 2-letter language code of the
+   * application using the library.
+   */
+  const char *languageCode;
+
+  /**
+   * Set to request the bank to sign the reply
+   * (not yet available in EBICS H004). */
+  uint8_t requestBankSignature;
+};
+
+/**
+ * Struct for build_content_hia subcommand.  This
+ * object could be unified with its INI counterpart;
+ * just keeping around for a while.
+ */
+struct EBICS_ARGS_build_content_hia
+{
+
+  /**
+   * Partner id. See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *partnerID;
+
+  /**
+   * User id. See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *userID;
+};
+
+/**
+ * Struct for build_content_ini subcommand.
+ */
+struct EBICS_ARGS_build_content_ini
+{
+  /**
+   * Document containing the "SignaturePubKeyOrderData"
+   * definition.
+   */
+  struct EBICS_genex_document *document;
+
+  /**
+   * Key containing the authentication key of the user.
+   */
+  const struct EBICS_Key *userAuthKey;
+
+  /**
+   * See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *partnerID;
+
+  /**
+   * See your banks ebics login information
+   * (probably recieved via (snail) mail.
+   */
+  const char *userID;
+};
+
+/**
  * Initializes Libebics.  Init all the dependencies,
  * as well as it allocates the "genex" templates to
  * be copied and instantiated during the library life.
@@ -114,7 +278,8 @@ EBICS_close_library ();
  *
  * @param header_args TODO
  * @param ini_args TODO
- * @return pointer to a freshly allocated document, NULL upon errors.
+ * @return pointer to a freshly allocated document,
+ *         NULL upon errors.
  */
 struct EBICS_genex_document *
 EBICS_generate_message_ini
@@ -126,7 +291,8 @@ EBICS_generate_message_ini
  *
  * @param header_args TODO
  * @param hia_args TODO
- * @return pointer to a freshly allocated document, NULL upon errors.
+ * @return pointer to a freshly allocated document,
+ *         NULL upon errors.
  */
 struct EBICS_genex_document *
 EBICS_generate_message_hia
diff --git a/src/sandbox_tests.c b/src/sandbox_tests.c
index d33e7dd..4f6685f 100644
--- a/src/sandbox_tests.c
+++ b/src/sandbox_tests.c
@@ -18,6 +18,7 @@
 
 
 #include "libebics.h"
+#include "util.h"
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet/gnunet_curl_lib.h>
@@ -81,6 +82,19 @@ struct EBICS_ARGS_build_content_hia hia_args = {
   .userID = PARTICIPANT_ID,
 };
 
+struct EBICS_ARGS_build_content_camt053 camt053_args = {
+  .startdate = {
+    .day = 0,
+    .month = 0,
+    .year = 0
+  },
+  .enddate = {
+    .day = 0,
+    .month = 0,
+    .year = 0
+  }
+};
+
 /**
  * Just deallocate the library
  */
@@ -237,6 +251,34 @@ run ()
   #endif
   GNUNET_free (msg);
 
+  /**
+   * CAMT.053
+   */
+  if (NULL == (msg = EBICS_generate_message_camt053
+      (&header_args,
+       &camt053_args)))
+  {
+    LOG (EBICS_LOGLEVEL_ERROR,
+        "Failed to instantiate HPB message\n");
+    return;
+  }
+
+  #ifdef ONLINE_SANDBOX
+  if (EBICS_SUCCESS != EBICS_send_message (msg,
+                                           BANK_URL,
+                                           cb))
+  {
+    LOG (EBICS_LOGLEVEL_ERROR,
+         "Could not POST the HIA message\n");
+    return;
+  }
+  #else
+  write_xml_file ("HPB.xml",
+                  msg);
+  #endif
+  GNUNET_free (msg);
+
+
   result = EBICS_SUCCESS;
 }
 
diff --git a/src/util.h b/src/util.h
index 030a0d4..bd88040 100644
--- a/src/util.h
+++ b/src/util.h
@@ -28,6 +28,7 @@
 #include <libxml/globals.h>
 #include <libxml/tree.h>
 
+#include "libebics.h"
 #include "xmlproto.h"
 
 /**
@@ -43,16 +44,6 @@
 #define NONCE_STR_SIZE 64
 
 /**
- * Loglevels with different behaviour, formating and verbosity of log messages.
- */
-#define EBICS_LOGLEVEL_NONE   -1
-#define EBICS_LOGLEVEL_FATAL   0
-#define EBICS_LOGLEVEL_ERROR   1 
-#define EBICS_LOGLEVEL_WARNING 2 
-#define EBICS_LOGLEVEL_INFO    3
-#define EBICS_LOGLEVEL_DEBUG   4
-
-/**
  * Central logging function
  */
 void EBICS_util_log_from (int32_t fileline,
@@ -104,10 +95,10 @@ void
 util_genex_free_document (struct EBICS_genex_document *document);
 
 xmlChar *
-util_test_xpath_value(const char *expression,
-                      xmlXPathContextPtr xpath);
+util_test_xpath_value (const char *expression,
+                       xmlXPathContextPtr xpath);
 
 char *
-util_generate_path(const char *basePath,
-                   const char *fileName);
+util_generate_path (const char *basePath,
+                    const char *fileName);
 #endif
diff --git a/src/xmlmessages.c b/src/xmlmessages.c
index 3003adf..f38f3db 100644
--- a/src/xmlmessages.c
+++ b/src/xmlmessages.c
@@ -1,20 +1,23 @@
 /*
   This file is part of libfints
 
-  libfints 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.
-
-  libfints 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
-  libfints; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/license>
+  libfints 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.
+
+  libfints 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 libfints; see the file COPYING.  If not,
+  see <http://www.gnu.org/license>
 */
 
-#include "xmlmessages.h"
 #include "libebics.h"
+#include "xmlmessages.h"
 #include "gnunet/platform.h"
 #include "gnunet/gnunet_util_lib.h"
 
diff --git a/src/xmlmessages.h b/src/xmlmessages.h
index 30191d8..5a83435 100644
--- a/src/xmlmessages.h
+++ b/src/xmlmessages.h
@@ -20,6 +20,7 @@
 #define EBICS_XML_MESSAGES_H
 
 #include "util.h"
+#include "libebics.h"
 #include "xmlproto.h"
 #include <xmlsec/xmlsec.h>
 #include <xmlsec/xmltree.h>
@@ -30,84 +31,6 @@
 #include <gcrypt.h>
 #include <zlib.h>
 
-/**
- * Struct for build_content_hia subcommand.  This
- * object could be unified with its INI counterpart;
- * just keeping around for a while.
- */
-struct EBICS_ARGS_build_content_hia
-{
-
-  /**
-   * Partner id. See your banks ebics login information
-   * (probably recieved via (snail) mail.
-   */
-  const char *partnerID;
-
-  /**
-   * User id. See your banks ebics login information
-   * (probably recieved via (snail) mail.
-   */
-  const char *userID;
-};
-
-/* Struct for build_content_ini subcommand.
- */
-struct EBICS_ARGS_build_content_ini
-{
-  /* Document containing the "SignaturePubKeyOrderData" definition. */
-  struct EBICS_genex_document *document;
-  /* Key containing the authentication key of the user. */
-  const struct EBICS_Key *userAuthKey;
-  /* partner id. See your banks ebics login information (probably recieved via 
(snail) mail. */
-  const char *partnerID;
-  /* user id. See your banks ebics login information (probably recieved via 
(snail) mail. */
-  const char *userID;
-};
-
-/* Struct for all build_header_* subcommands
- */
-struct EBICS_ARGS_build_header
-{
-  /* host id. See your banks ebics login information (probably recieved via 
(snail) mail.*/
-  const char *hostID;
-  /* partner id. See your banks ebics login information (probably recieved via 
(snail) mail.*/
-  const char *partnerID;
-  /* user id. See your banks ebics login information (probably recieved via 
(snail) mail.*/
-  const char *userID;
-  /* Name of the product using the library. */
-  const char *productName;
-  /* ISO-(TODO) 2-letter language code of the application using the library. */
-  const char *languageCode;
-  /* Set to request the bank to sign the reply (not yet available in EBICS 
H004). */
-  uint8_t requestBankSignature;
-};
-
-/**
- * Struct for "camt053" request
- */
-struct EBICS_ARGS_build_content_camt053
-{
-  /**
-   *  Starting date
-   */
-  const struct EBICS_Date startdate;
-
-  /**
-   * End Date
-   */
-  const struct EBICS_Date enddate;
-};
-
-/* Struct for all subcommands that need access to user or bank keys. */
-struct EBICS_ARGS_build_auth
-{
-  /**
-   * Authentication key(pair) from user
-   */
-  const struct EBICS_Key *userAuthentication;
-};
-
 /* Generate a "ebicsNoPubKeyDigestsRequest" style header.
  *
  * @param cls Pointer to a EBICS_ARGS_build_header struct.
diff --git a/src/xmlproto.c b/src/xmlproto.c
index 193bd7b..24f0f67 100644
--- a/src/xmlproto.c
+++ b/src/xmlproto.c
@@ -12,13 +12,13 @@
   You should have received a copy of the GNU General Public License along with
   libfints; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/license>
 */
-#define _GNU_SOURCE 
 
 #include <stdio.h>
 #include <stdint.h>
 #include <inttypes.h>
 #include <stdbool.h>
 #include <assert.h>
+#include <gnunet/platform.h>
 #include "xmlproto.h"
 #include "util.h"
 
@@ -470,7 +470,7 @@ process_choice (const struct EBICS_MSG_Spec *operation,
   xmlStrPrintf(choice, 32*sizeof(xmlChar), "/msg:address@hidden", 
operation->data.select_choice.choice);
   */
   char *choice;
-  assert( 0 < asprintf(&choice, "/schema:address@hidden", 
operation->data.select_choice.choice));
+  assert( 0 < GNUNET_asprintf(&choice, "/schema:address@hidden", 
operation->data.select_choice.choice));
   xmlChar *base = xmlStrdup(BAD_CAST operation->xpath);
   xmlChar *result = xmlStrcat(base, BAD_CAST choice);
   free(choice);
@@ -549,7 +549,7 @@ process_uint (const struct EBICS_MSG_Spec *operation,
               "nodeset: %p, nodeNr: %u", 
               operation->xpath, xpathObjPtr, 
               nodeset, nodeset->nodeNr);
-  assert(0 < asprintf(&content, "%" PRIu64, value));
+  assert(0 < GNUNET_asprintf(&content, "%" PRIu64, value));
   for (i = (nodeset->nodeNr); i > 0; i--)
   {
     LOG(EBICS_LOGLEVEL_INFO,"process_uint: setting value: %"PRIu64"",value);
@@ -584,7 +584,7 @@ process_int (const struct EBICS_MSG_Spec *operation,
               nodeset: %p, nodeNr: %u", 
               operation->xpath, xpathObjPtr, 
               nodeset, nodeset->nodeNr);
-  assert(0 < asprintf(&content, "%" PRId64, value));
+  assert(0 < GNUNET_asprintf(&content, "%" PRId64, value));
   for (i = (nodeset->nodeNr); i > 0; i--)
   {
     LOG(EBICS_LOGLEVEL_INFO,"process_int: setting value: %"PRId64"",value);
diff --git a/src/xmlproto.h b/src/xmlproto.h
index df045a9..6d0261a 100644
--- a/src/xmlproto.h
+++ b/src/xmlproto.h
@@ -1,16 +1,19 @@
 /*
   This file is part of libfints
 
-  libfints 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.
-
-  libfints 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
-  libfints; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/license>
+  libfints 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.
+
+  libfints 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 libfints; see the file COPYING.  If not,
+  see <http://www.gnu.org/license>
 */
 
 #ifndef EBICS_XML_PROTO_H
@@ -31,22 +34,10 @@
 
 #include <gnutls/abstract.h>
 
-#include "include/libfints_messages.h"
+#include "libebics.h"
 
 /** TODO! **/
 #define EBICS_GENEX_MAX_ENTRIES 64
-#define EBICS_GENEX_MAX_NAME 128
-#define EBICS_FATAL -1
-#define EBICS_ERROR 1
-#define EBICS_SUCCESS 0
-
-struct EBICS_genex_document
-{
-  char name[EBICS_GENEX_MAX_NAME];
-  xmlDocPtr document;
-  xmlParserCtxtPtr parser;
-  xmlXPathContextPtr xpath;
-};
 
 /**
  * Enum of available operations
@@ -110,22 +101,11 @@ struct EBICS_KeyList
 };
 
 /**
- * Date format in libebics. 
- */
-struct EBICS_Date
-{
-
-  uint8_t day;
-
-  uint8_t month;
-
-  uint16_t year;
-};
-
-/**
  * typedef for subcommand funtion pointer
  */
-typedef void (*EBICS_MSG_subcommand_fn)(void *cls, struct EBICS_genex_document 
*document);
+typedef void (*EBICS_MSG_subcommand_fn)
+  (void *cls,
+   struct EBICS_genex_document *document);
 
 struct EBICS_MSG_Spec
 {

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



reply via email to

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