gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libebics] branch master updated (0296a75 -> d771fd7)


From: gnunet
Subject: [GNUnet-SVN] [libebics] branch master updated (0296a75 -> d771fd7)
Date: Fri, 19 Oct 2018 11:24:12 +0200

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

marcello pushed a change to branch master
in repository libebics.

    from 0296a75  Submitting CURL jobs using custom XML parser.
     new b3f9e00  Put sandbox credentials.
     new 3661ff0  polish test
     new 2d8bd28  Memory and design fixes.
     new d771fd7  Fix hanging shutdown.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/Makefile.am     |   3 +-
 src/libebics.c      |  62 ++++++++++++-----------
 src/libebics.h      |   2 +-
 src/sandbox_tests.c | 138 +++++++++++++++++++++-------------------------------
 src/xmlproto.c      |   2 +-
 5 files changed, 94 insertions(+), 113 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index c2b6509..f4d7c6f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,7 +58,8 @@ sandbox_tests_SOURCES = \
 
 sandbox_tests_LDADD = \
   libebics.la \
-  -lgnunetutil
+  -lgnunetutil \
+  -lgnunetcurl
 
 sandbox_tests_CPPFLAGS = \
   $(XML_CPPFLAGS) \
diff --git a/src/libebics.c b/src/libebics.c
index 1e9da2c..c6b8881 100644
--- a/src/libebics.c
+++ b/src/libebics.c
@@ -618,6 +618,12 @@ free_genex_documents (struct EBICS_genex_document 
genexList[])
   }
 }
 
+static void
+clean_response (void *response)
+{
+  if (response)
+    GNUNET_free (response);
+}
 
 /**
  * Process the raw response that came from the bank.
@@ -746,20 +752,20 @@ EBICS_init_library (const char *key_dir,
     return EBICS_ERROR;
   }
 
-  reschedule_ctx = GNUNET_CURL_gnunet_rc_create_with_parser
-    (ctx,
-     &parse_response,
-     (GNUNET_CURL_ResponseCleaner) &xmlFree);
-
   if (NULL == (ctx = GNUNET_CURL_init
-      (GNUNET_CURL_gnunet_scheduler_reschedule,
-       reschedule_ctx)))
+      (&GNUNET_CURL_gnunet_scheduler_reschedule,
+       &reschedule_ctx)))
   {
     LOG (EBICS_LOGLEVEL_FATAL,
          "Could not init GNUnet CURL\n");
     return EBICS_ERROR;
   }
 
+  reschedule_ctx = GNUNET_CURL_gnunet_rc_create_with_parser
+    (ctx,
+     &parse_response,
+     &clean_response);
+
   GNUNET_free (data_dir);
   return EBICS_SUCCESS;
 }
@@ -793,8 +799,8 @@ EBICS_close_library ()
   free_genex_documents (genexList);
   free_keymaterial (keyList);
 
-  GNUNET_CURL_fini (ctx);
   GNUNET_CURL_gnunet_rc_destroy (reschedule_ctx);
+  GNUNET_CURL_fini (ctx);
 }
 
 /**
@@ -1016,9 +1022,9 @@ process_response (void *cls,
  * @param document the document to POST
  * @param URL url of the EBICS endpoint
  * @param cb callback to pass the response data
- * @return EBICS_SUCCESS / EBICS_ERROR
+ * @return the CURL job, or NULL upon errors.
  */
-int
+struct GNUNET_CURL_Job *
 EBICS_send_message (const struct EBICS_genex_document *document,
                     const char *url,
                     EBICS_ResponseCallback cb)
@@ -1027,6 +1033,7 @@ EBICS_send_message (const struct EBICS_genex_document 
*document,
   int size;
   xmlChar *buf;
   CURL *eh;
+  struct GNUNET_CURL_Job *job;
 
 #define SETOPT(eh,opt,par) \
   if (CURLE_OK != curl_easy_setopt (eh, opt, par)) \
@@ -1036,7 +1043,7 @@ EBICS_send_message (const struct EBICS_genex_document 
*document,
          __FILE__, \
          __LINE__); \
     curl_easy_cleanup (eh); \
-    return EBICS_ERROR; \
+    return NULL; \
   }
 
   xmlDocDumpFormatMemoryEnc (document->document,
@@ -1046,37 +1053,36 @@ EBICS_send_message (const struct EBICS_genex_document 
*document,
                              GNUNET_NO);
   eh = curl_easy_init (); 
 
+  GNUNET_assert
+    (GNUNET_OK == GNUNET_CURL_append_header
+      (ctx,
+       "Content-Type: text/xml"));
+
   SETOPT (eh,
           CURLOPT_URL,
           url);
 
   SETOPT (eh,
-          CURLOPT_POSTFIELDS,
-          buf);
+          CURLOPT_POSTFIELDSIZE,
+          size);
 
   SETOPT (eh,
-          CURLOPT_POSTFIELDS,
+          CURLOPT_COPYPOSTFIELDS,
           buf);
 
-  GNUNET_assert
-    (GNUNET_OK == GNUNET_CURL_append_header
-      (ctx,
-       "Content-Type: text/xml"));
+  xmlFree (buf);
 
-  if (NULL == GNUNET_CURL_job_add (ctx,
-                                   eh,
-                                   GNUNET_NO,
-                                   cb,
-                                   NULL))
+  if (NULL == (job = GNUNET_CURL_job_add (ctx,
+                                          eh,
+                                          GNUNET_NO,
+                                          cb,
+                                          NULL)))
   {
     LOG (EBICS_LOGLEVEL_ERROR,
          "Could not submit the CURL job\n");
     curl_easy_cleanup (eh);
-    xmlFree (buf);
-    return EBICS_ERROR;
+    return NULL;
   }
 
-  xmlFree (buf);
-
-  return EBICS_SUCCESS;
+  return job;
 }
diff --git a/src/libebics.h b/src/libebics.h
index 06370f9..83047ad 100644
--- a/src/libebics.h
+++ b/src/libebics.h
@@ -168,7 +168,7 @@ typedef void
  * @param cb callback to pass the response data
  * @return EBICS_SUCCESS / EBICS_ERROR
  */
-int
+struct GNUNET_CURL_Job *
 EBICS_send_message (const struct EBICS_genex_document *document,
                     const char *url,
                     EBICS_ResponseCallback cb);
diff --git a/src/sandbox_tests.c b/src/sandbox_tests.c
index 19bc9a5..6280821 100644
--- a/src/sandbox_tests.c
+++ b/src/sandbox_tests.c
@@ -30,7 +30,24 @@
                        "messagedump", \
                        __VA_ARGS__)
 
+
+#define KEYS_DIR "./test_keys"
 #define BANK_URL "http://localhost:9999/";
+// #define BANK_URL 
"https://server-ebics.webank.fr:28103/WbkPortalFileTransfert/EbicsProtocol";
+#define E001_DIGEST "9BF804AF2B121A5B94C82BFD8E406FFB18024D3D4BF9E"
+#define X001_DIGEST "9BF804AF2B121A5B94C82BFD8E406FFB18024D3D4BF9E"
+#define HOST_ID "EBIXQUAL"
+
+/**
+ * Final return code
+ */
+int result = EBICS_ERROR;
+
+/**
+ * Current CURL job
+ */
+struct GNUNET_CURL_Job *job;
+
 
 /**
  * Process responses from banks.
@@ -44,6 +61,10 @@ cb (void *cls,
     const void *response)
 {
   xmlDocPtr doc = (xmlDocPtr) response;
+
+  LOG (EBICS_LOGLEVEL_INFO,
+       "Bank responded (%d)\n",
+       response_code);
 }
 
 struct EBICS_ARGS_build_header header_args = {
@@ -66,22 +87,27 @@ struct EBICS_ARGS_build_content_hia hia_args = {
 };
 
 /**
- * This test merely instantiates documents
- * and checks them against their schemas.
- *
- * @return EBICS_ERROR on errors.
+ * Just deallocate the library
  */
-int
-main (int argc,
-      char **argv)
+void
+deinit ()
+{
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Shutting the test down\n");
+  EBICS_close_library ();
+}
+
+static void
+run ()
 {
-  #define KEYS_DIR "./test_keys"
 
   struct EBICS_genex_document *msg;
 
   unsetenv ("XDG_DATA_HOME");
   unsetenv ("XDG_CONFIG_HOME");
 
+  GNUNET_SCHEDULER_add_shutdown (&deinit,
+                                 NULL);
   struct EBICS_UserKeyFiles key_filenames = {
     .es_key = "testEsKey",
     .enc_key = "testEncKey",
@@ -92,8 +118,8 @@ main (int argc,
                                            &key_filenames)) 
   {
     LOG (EBICS_LOGLEVEL_ERROR,
-        "Lib not init\n");
-    return EBICS_ERROR;
+        "Lib not init\n");
+    return;
   }
 
 
@@ -106,86 +132,34 @@ main (int argc,
   {
     LOG (EBICS_LOGLEVEL_ERROR,
         "Failed to instantiate INI message\n");
-    return EBICS_ERROR;
+    return;
   }
 
-  if (EBICS_SUCCESS != EBICS_send_message (msg,
-                                           BANK_URL,
-                                           cb))
+  if (NULL == (job = EBICS_send_message (msg,
+                                         BANK_URL,
+                                         cb)))
   {
     LOG (EBICS_LOGLEVEL_ERROR,
          "Could not POST the INI message\n");
-    return EBICS_ERROR;
-  }
-
-  GNUNET_free (msg);
-  return EBICS_SUCCESS;
-
-  /**
-   * HIA
-   */
-  if (NULL == (msg = EBICS_generate_message_hia
-      (&header_args,
-       &hia_args)))
-  {
-    LOG (EBICS_LOGLEVEL_ERROR,
-              "Failed to instantiate HIA message\n");
-    return EBICS_ERROR;
+    return;
   }
-  
-  GNUNET_free (msg);
 
-  /**
-   * HPB
-   */
-  if (NULL == (msg = EBICS_generate_message_hpb
-      (&header_args)))
-  {
-    LOG (EBICS_LOGLEVEL_ERROR,
-              "Failed to instantiate HPB message\n");
-    return EBICS_ERROR;
-  }
-  
   GNUNET_free (msg);
+  result = EBICS_SUCCESS;
+}
 
-  /**
-   * CAMT.053
-   */
-  
-  struct EBICS_ARGS_build_content_camt053
-  camt053_args = {
-    
-    .startdate = {
-      .year = 1999,
-      .month = 12,
-      .day = 31 
-    },
-
-    .enddate = {
-      .year = 2000,
-      .month = 1,
-      .day = 1 
-    },
-  };
-
-  struct EBICS_Date range_start = {
-    
-    .year = 1999,
-    .month = 12,
-    .day = 31
-  };
-
-  if (NULL == (msg = EBICS_generate_message_camt053
-      (&header_args,
-       &camt053_args)))
-  {
-    LOG (EBICS_LOGLEVEL_ERROR,
-        "Failed to instantiate CAMT.053 message\n");
-    return EBICS_ERROR;
-  }
-
-  GNUNET_free (msg);
+/**
+ * This test merely instantiates documents
+ * and checks them against their schemas.
+ *
+ * @return EBICS_ERROR on errors.
+ */
+int
+main (int argc,
+      char **argv)
+{
 
-  EBICS_close_library ();
-  return EBICS_SUCCESS;
+  GNUNET_SCHEDULER_run (&run,
+                        NULL);
+  return result;
 }
diff --git a/src/xmlproto.c b/src/xmlproto.c
index 1d41ac7..193bd7b 100644
--- a/src/xmlproto.c
+++ b/src/xmlproto.c
@@ -1051,7 +1051,7 @@ EBICS_MSG_parse_spec (const struct EBICS_MSG_Spec *ops,
         break;
       case EBICS_MSG_OP_SUBCOMMAND:
         LOG (EBICS_LOGLEVEL_INFO,
-             "parse_spec: executing 'subcommand'");
+             "parse_spec: executing 'subcommand'\n");
         process_subcommand (op, document);
         break;
       case EBICS_MSG_OP_CLEAN:

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



reply via email to

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