gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libfints] branch master updated: minor fixes.


From: gnunet
Subject: [GNUnet-SVN] [libfints] branch master updated: minor fixes.
Date: Fri, 12 Oct 2018 13:28:37 +0200

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

marcello pushed a commit to branch master
in repository libfints.

The following commit(s) were added to refs/heads/master by this push:
     new e052b39  minor fixes.
e052b39 is described below

commit e052b395e807d000b73594e0b4d71f9072938524
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Oct 12 13:28:20 2018 +0200

    minor fixes.
---
 src/libebics.c | 89 +++++++++++++++++++++++++++++++++++++++++++---------------
 src/tests.c    |  3 +-
 2 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/src/libebics.c b/src/libebics.c
index 90212ac..3055fad 100644
--- a/src/libebics.c
+++ b/src/libebics.c
@@ -397,6 +397,7 @@ init_keymaterial (struct EBICS_Key keyList[],
              " private at %s. GnuTLS Error: %s",
              filepath,
              gnutls_strerror (retv));
+             return EBICS_ERROR;
       }
       else
       {
@@ -411,12 +412,12 @@ init_keymaterial (struct EBICS_Key keyList[],
     else
     {
       LOG (EBICS_LOGLEVEL_ERROR,
-           "Could not import private key at %s. GnuTLS Error: %s",
+           "Could not import private key at %s,"
+           "trying importing public key: %s",
            filepath,
            gnutls_strerror (retv));
     }
 
-
     /**
      * The policy prioritizes public keys extracted from privs.
      * Therefore whenever a private key got detected in the current
@@ -442,6 +443,7 @@ init_keymaterial (struct EBICS_Key keyList[],
         LOG (EBICS_LOGLEVEL_ERROR,
         "Could not import publickey from file %s. GnuTLS Error: %s",
         gnutls_strerror (retv));
+        return EBICS_ERROR;
       }
     }
 
@@ -451,6 +453,8 @@ init_keymaterial (struct EBICS_Key keyList[],
 
     GNUNET_free (key_content);
   }
+
+  return EBICS_SUCCESS;
 }
 
 
@@ -495,44 +499,85 @@ init_genex_documents
    const char *genex_schemas_dir,
    const char *genexFiles[])
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing 'genex_documents'");
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Initializing 'genex_documents'");
 
   int result = EBICS_SUCCESS;
   
-  for (int i = 0; i < EBICS_GENEX_MAX_ENTRIES && genexFiles[i] != NULL; i++)
+  for (int i = 0;
+       i < EBICS_GENEX_MAX_ENTRIES && genexFiles[i] != NULL;
+       i++)
   {
-    size_t size = snprintf (NULL, 0,"%s/%s", genex_schemas_dir, genexFiles[i]) 
+ 1;
-    assert(0 != size);
+    size_t size;
+    struct EBICS_genex_document *genex;
+    xmlParserCtxtPtr parser;
+    xmlDocPtr doc;
+    xmlXPathContextPtr xpathCtxPtr;
+
+    size = snprintf (NULL,
+                     0,
+                     "%s/%s",
+                     genex_schemas_dir,
+                     genexFiles[i]);
+    size++;
+    GNUNET_assert (0 != size);
+
     char filepath[size];
-    size = snprintf (filepath, size,"%s/%s", genex_schemas_dir, genexFiles[i]);
-    assert(0 != size);
-    LOG (EBICS_LOGLEVEL_DEBUG, "Loading '%s' at position %d",filepath, i);
-    struct EBICS_genex_document *genex = &genexList[i];
+    size = snprintf (filepath,
+                     size,
+                     "%s/%s",
+                     genex_schemas_dir,
+                     genexFiles[i]);
+
+    GNUNET_assert (0 != size);
+    LOG (EBICS_LOGLEVEL_DEBUG,
+         "Loading '%s' at position %d",
+         filepath,
+         i);
+    genex = &genexList[i];
     genexList[i+1].document = NULL;
 
-    xmlParserCtxtPtr parser = xmlNewParserCtxt();
-    xmlDocPtr doc = xmlCtxtReadFile(parser, filepath, "utf-8", 
XML_PARSE_NOBLANKS);
+    parser = xmlNewParserCtxt ();
+    doc = xmlCtxtReadFile (parser,
+                           filepath,
+                           "utf-8",
+                           XML_PARSE_NOBLANKS);
     if (doc == NULL)
     {
-      LOG (EBICS_LOGLEVEL_ERROR, "Could not parse document: %s", filepath);
+      LOG (EBICS_LOGLEVEL_ERROR,
+           "Could not parse document: %s",
+           filepath);
       result = EBICS_ERROR;
     }
-    xmlXPathContextPtr xpathCtxPtr = xmlXPathNewContext(doc);
+    xpathCtxPtr = xmlXPathNewContext (doc);
     if (NULL == xpathCtxPtr)
     {
-      LOG (EBICS_LOGLEVEL_ERROR, "Could not create xmlXPathCtxPtr for 
document: %s", filepath);
+      LOG (EBICS_LOGLEVEL_ERROR,
+           "Could not create xmlXPathCtxPtr for document: %s",
+           filepath);
       result = EBICS_ERROR;
     }
-    xmlXPathRegisterNs(xpathCtxPtr, "ebics", "urn:org:ebics:H004");
-    xmlXPathRegisterNs(xpathCtxPtr, "esig", "http://www.ebics.org/S001";);
-    xmlXPathRegisterNs(xpathCtxPtr, "schema", 
"http://www.w3.org/2001/XMLSchema";);
-    xmlXPathRegisterNs(xpathCtxPtr, "ds", 
"http://www.w3.org/2000/09/xmldsig#";);
+    xmlXPathRegisterNs (xpathCtxPtr,
+                        "ebics",
+                        "urn:org:ebics:H004");
+    xmlXPathRegisterNs (xpathCtxPtr,
+                        "esig",
+                        "http://www.ebics.org/S001";);
+    xmlXPathRegisterNs (xpathCtxPtr,
+                        "schema",
+                        "http://www.w3.org/2001/XMLSchema";);
+    xmlXPathRegisterNs (xpathCtxPtr,
+                        "ds",
+                        "http://www.w3.org/2000/09/xmldsig#";);
 
     genex->document = doc;
     genex->parser = parser;
     genex->xpath = xpathCtxPtr;
-    strncpy (genex->name, genexFiles[i], EBICS_GENEX_MAX_NAME);
+    strncpy (genex->name,
+             genexFiles[i],
+             EBICS_GENEX_MAX_NAME);
   }
+  return result;
 }
 
 
@@ -626,13 +671,13 @@ EBICS_init_library (const char *key_dir,
   if (NULL == (data_dir = GNUNET_OS_installation_get_path
       (GNUNET_OS_IPK_DATADIR)))
     return EBICS_ERROR;
-
   if (EBICS_SUCCESS != init_genex_documents
       (genexList,
        data_dir,
        genexFilenames))
   {
-    GNUNET_break (0);
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "Could not initialize all the genex documents\n");
     return EBICS_ERROR;
   }
 
diff --git a/src/tests.c b/src/tests.c
index 64a63b5..4ff3259 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -69,8 +69,7 @@ main (int argc, char **argv)
   if (EBICS_SUCCESS != EBICS_init_library (KEYS_DIR,
                                            key_filenames)) 
   {
-    LOG (EBICS_FATAL,
-         "no init lib");
+    fprintf (stderr, "bad\n");
     return EBICS_ERROR;
   }
 

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



reply via email to

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