gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libfints] branch master updated: Style.


From: gnunet
Subject: [GNUnet-SVN] [libfints] branch master updated: Style.
Date: Wed, 10 Oct 2018 10:13:06 +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 8f453a8  Style.
8f453a8 is described below

commit 8f453a8aaea357f55732387d750e68391a943888
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Oct 10 10:12:52 2018 +0200

    Style.
---
 src/libebics.c | 164 +++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 108 insertions(+), 56 deletions(-)

diff --git a/src/libebics.c b/src/libebics.c
index 1ec6572..4cae228 100644
--- a/src/libebics.c
+++ b/src/libebics.c
@@ -29,10 +29,20 @@
 #define LOG(level,...) EBICS_util_log_from (__LINE__,__FILE__,__func__,level, 
"libebics",__VA_ARGS__)
 
 
+
+/**
+ * Utility log function.
+ *
+ * @param level log level
+ * @param msg log message
+ */
 static void
 gnutlslog (int level, const char *msg)
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "GNUTLS[%d]: %s", level, msg);
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "GNUTLS[%d]: %s",
+       level,
+       msg);
 }
 
 /**
@@ -43,42 +53,49 @@ gnutlslog (int level, const char *msg)
 static int
 init_libgnutls()
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing 'libgnutls'");
-  gnutls_global_init();
-  gnutls_global_set_log_function(&gnutlslog);
-  gnutls_global_set_log_level(99);
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Initializing 'libgnutls'\n");
+  gnutls_global_init ();
+  gnutls_global_set_log_function (&gnutlslog);
+  gnutls_global_set_log_level (99);
 }
 
-static int
+
+/**
+ * Shut GNUTLS down.
+ */
+static void
 free_libgnutls()
 {
+  /* NOTE: deprecated, see man page.  */
   gnutls_global_deinit();
 }
 
 /**
- * Initialize libgcrypt
+ * Initialize Libgcrypt
  *
  * @returns EBICS_SUCCESS on success, else EBICS_FATAL.
  */
 static int
-init_libgcrypt()
+init_libgcrypt ()
 {
   int rc;
   /* TODO: Manual advises to let the user init libgcrypt and 
-   * for the library to oly check the status 
-   * (and possibly init if not done properly by user
+   * for the library to only check the status 
+   * (and possibly init if not done properly by user)
    */
 
-  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing 'libgcrypt'");
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Initializing 'libgcrypt'\n");
   /* Version check should be the very first call because it
      makes sure that important subsystems are intialized. */
   if (!gcry_check_version (GCRYPT_VERSION))
   {
-    LOG (EBICS_LOGLEVEL_FATAL, "libgcrypt version mismatch");
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "libgcrypt version mismatch\n");
     return (EBICS_FATAL);
   }
   
-
   /* Disable secure memory.  */
   if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0)))
     LOG (EBICS_LOGLEVEL_ERROR,
@@ -88,104 +105,142 @@ init_libgcrypt()
 
   /* ... If required, other initialization goes here.  */
 
-  /* Tell Libgcrypt that initialization has completed. */
+  /* Tell Libgcrypt that initialization has completed.  */
   gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
   return (EBICS_SUCCESS);
-
 }
+
+/**
+ * deinit Libgcrypt.
+ *
+ * @return EBICS_SUCCESS if the operation succeeded,
+ * EBICS_ERROR otherwise.
+ */
 static int
-free_libgcrypt()
+free_libgcrypt ()
 {
+  /* TODO or not ? */
+  return EBICS_ERROR;
 }
 
 /**
- * Initialize libxmlsec.
+ * Initialize Libxmlsec.
  *
  * @returns EBICS_SUCCESS on success, else EBICS_ERROR.
  */
 static int
-init_libxmlsec()
+init_libxmlsec ()
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing 'libxmlsec'");
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Initializing 'libxmlsec'\n");
 
   /* Init libxml and libxslt libraries */
   LIBXML_TEST_VERSION;
   xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-  xmlSubstituteEntitiesDefault(1);
+  xmlSubstituteEntitiesDefault (1);
   xmlIndentTreeOutput = 1; 
 
   /* Init xmlsec library */
-  if(xmlSecInit() < 0) {
-    LOG (EBICS_LOGLEVEL_FATAL, "Error: xmlsec initialization failed.");
-    return(EBICS_FATAL);
+  if (xmlSecInit () < 0)
+  {
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "Error: xmlsec initialization failed.\n");
+    return (EBICS_FATAL);
   }
 
   /* Check loaded library version */
-  if(xmlSecCheckVersion() != 1) {
-    LOG (EBICS_LOGLEVEL_FATAL, "Error: loaded xmlsec library version is not 
compatible.");
-    return(EBICS_FATAL);
+  if (xmlSecCheckVersion() != 1)
+  {
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "Error: loaded xmlsec library version is not compatible.\n");
+    return (EBICS_FATAL);
   }
 
   /* Init crypto library */
-  if(xmlSecCryptoAppInit(NULL) < 0) {
-    LOG (EBICS_LOGLEVEL_FATAL, "Error: crypto initialization failed.");
-    return(EBICS_FATAL);
+  if (xmlSecCryptoAppInit(NULL) < 0)
+  {
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "Error: crypto initialization failed.\n");
+    return (EBICS_FATAL);
   }
 
   /* Init xmlsec-crypto library */
-  if(xmlSecCryptoInit() < 0) {
-    LOG (EBICS_LOGLEVEL_FATAL, "Error: xmlsec-crypto initialization failed.");
-    return(EBICS_FATAL);
+  if (xmlSecCryptoInit() < 0)
+  {
+    LOG (EBICS_LOGLEVEL_FATAL,
+         "Error: xmlsec-crypto initialization failed.\n");
+    return (EBICS_FATAL);
   }
-  return(EBICS_SUCCESS);
+
+  return (EBICS_SUCCESS);
 }
 
+
+/**
+ * Deinit Libxmlsec.
+ *
+ * @return EBICS_SUCCESS if the operation succeeds,
+ *         EBICS_ERROR otherwise.
+ */
 static int
-free_libxmlsec()
+free_libxmlsec ()
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "Cleaning libxmlsec!");
-  xmlSecGnuTLSShutdown();
-  xmlSecGnuTLSAppShutdown();
-  /* Shutdown xmlsec-crypto library */
-  xmlSecCryptoShutdown();
+  #define RETURNIFERROR(func) \
+    if(0!=func()) return EBICS_ERROR
 
-  /* Shutdown crypto library */
-  xmlSecCryptoAppShutdown();
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "Cleaning libxmlsec!\n");
 
-  /* Shutdown xmlsec library */
-  xmlSecShutdown();
+  RETURNIFERROR (xmlSecGnuTLSShutdown);
+  RETURNIFERROR (xmlSecGnuTLSAppShutdown);
+  RETURNIFERROR (xmlSecCryptoShutdown);
+  RETURNIFERROR (xmlSecGnuTLSCryptoAppShutdown);
+  RETURNIFERROR (xmlSecShutdown);
 
-  /* Shutdown libxslt/libxml */
 #ifndef XMLSEC_NO_XSLT
-  xsltCleanupGlobals();
-#endif /* XMLSEC_NO_XSLT */
+  xsltCleanupGlobals ();
+#endif
+
+  return EBICS_SUCCESS;
 }
 
 /**
- * Initialize zlib
+ * Init zlib.
  */
 static int
-init_zlib()
+init_zlib ()
 {
+  /* TODO or not? */
 }
 
+
+/**
+ * Free zlib.
+ */
 static int
-free_zlib()
+free_zlib ()
 {
+  /* TODO or not? */
 }
 
 
 /**
  * Load all keys.
  *
- * @returns EBICS_SUCCESS on success, EBICS_ERROR on non critical errors and 
EBICS_FATAL else.
+ * @param keyList
+ * @param keyDir
+ * @param keyFiles
+ *
+ * @returns EBICS_SUCCESS on success,
+ *          EBICS_ERROR on non critical errors
+ *          and EBICS_FATAL else.
  */
 int
 EBICS_init_keymaterial (struct EBICS_Key keyList[],
                         char *keyDir,
                         char *keyFiles[])
 {
-  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing key material");
+  LOG (EBICS_LOGLEVEL_DEBUG, "Initializing key material\n");
 
   int retv;
   int result = EBICS_SUCCESS;
@@ -386,14 +441,11 @@ EBICS_close_library ()
   if (retv)
     return (retv);
 
-  retv = free_libgnutls ();
-  if (retv)
-    return (retv);
-
   retv = free_zlib ();
   if (retv)
     return (retv);
-
+  
+  free_libgnutls ();
   xmlCleanupParser ();
   /* cleanup */
 }

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



reply via email to

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