update source to use our brand new source generator. Update automakes.
[apps/madmutt.git] / lib-sys / mutt_ssl.c
index bfb09a8..745141b 100644 (file)
@@ -7,9 +7,7 @@
  * please see the file GPL in the top level source directory.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <lib-lib/lib-lib.h>
 
 #ifdef USE_SSL
 
 #include <openssl/err.h>
 #include <openssl/rand.h>
 
-#include <string.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
-
 #include <lib-ui/curses.h>
 #include <lib-ui/menu.h>
 
@@ -151,7 +143,7 @@ static int ssl_init (void)
     /* load entropy from egd sockets */
 #ifdef HAVE_RAND_EGD
     add_entropy (getenv ("EGDSOCKET"));
-    snprintf (path, sizeof (path), "%s/.entropy", NONULL (Homedir));
+    snprintf (path, sizeof (path), "%s/.entropy", NONULL(MCore.homedir));
     add_entropy (path);
     add_entropy ("/tmp/entropy");
 #endif
@@ -341,9 +333,6 @@ static int ssl_socket_close (CONNECTION * conn)
 
   if (data) {
     SSL_shutdown (data->ssl);
-#if 0
-    X509_free (data->cert);
-#endif
     SSL_free (data->ssl);
     SSL_CTX_free (data->ctx);
     p_delete(&conn->sockdata);
@@ -406,7 +395,7 @@ static int tls_close (CONNECTION * conn)
 
 static char *x509_get_part (char *line, const char *ndx)
 {
-  static char ret[SHORT_STRING];
+  static char ret[STRING];
   char *c, *c2;
 
   m_strcpy(ret, sizeof(ret), _("Unknown"));
@@ -518,7 +507,7 @@ static int check_certificate_by_digest (X509 * peercert)
     return 0;
 
   if (!X509_digest (peercert, EVP_sha1 (), peermd, &peermdlen)) {
-    fclose (fp);
+    m_fclose(&fp);
     return 0;
   }
 
@@ -528,7 +517,7 @@ static int check_certificate_by_digest (X509 * peercert)
       break;
   }
   X509_free (cert);
-  fclose (fp);
+  m_fclose(&fp);
 
   return pass;
 }
@@ -536,8 +525,8 @@ static int check_certificate_by_digest (X509 * peercert)
 static int ssl_check_certificate (sslsockdata * data)
 {
   char *part[] = { "/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C=" };
-  char helpstr[SHORT_STRING];
-  char buf[SHORT_STRING];
+  char helpstr[STRING];
+  char buf[STRING];
   MUTTMENU *menu;
   int done, row, i;
   FILE *fp;
@@ -562,42 +551,42 @@ static int ssl_check_certificate (sslsockdata * data)
   menu->max = 19;
   menu->dialog = p_new(char *, menu->max);
   for (i = 0; i < menu->max; i++)
-    menu->dialog[i] = p_new(char, SHORT_STRING);
+    menu->dialog[i] = p_new(char, STRING);
 
   row = 0;
-  m_strcpy(menu->dialog[row], SHORT_STRING,
+  m_strcpy(menu->dialog[row], STRING,
            _("This certificate belongs to:"));
   row++;
   name = X509_NAME_oneline (X509_get_subject_name (data->cert),
                             buf, sizeof (buf));
   for (i = 0; i < 5; i++) {
     c = x509_get_part (name, part[i]);
-    snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
+    snprintf (menu->dialog[row++], STRING, "   %s", c);
   }
 
   row++;
-  m_strcpy(menu->dialog[row], SHORT_STRING,
+  m_strcpy(menu->dialog[row], STRING,
            _("This certificate was issued by:"));
   row++;
   name = X509_NAME_oneline (X509_get_issuer_name (data->cert),
                             buf, sizeof (buf));
   for (i = 0; i < 5; i++) {
     c = x509_get_part (name, part[i]);
-    snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
+    snprintf (menu->dialog[row++], STRING, "   %s", c);
   }
 
   row++;
-  snprintf (menu->dialog[row++], SHORT_STRING, "%s",
+  snprintf (menu->dialog[row++], STRING, "%s",
             _("This certificate is valid"));
-  snprintf (menu->dialog[row++], SHORT_STRING, _("   from %s"),
+  snprintf (menu->dialog[row++], STRING, _("   from %s"),
             asn1time_to_string (X509_get_notBefore (data->cert)));
-  snprintf (menu->dialog[row++], SHORT_STRING, _("     to %s"),
+  snprintf (menu->dialog[row++], STRING, _("     to %s"),
             asn1time_to_string (X509_get_notAfter (data->cert)));
 
   row++;
   buf[0] = '\0';
   x509_fingerprint (buf, sizeof (buf), data->cert);
-  snprintf (menu->dialog[row++], SHORT_STRING, _("Fingerprint: %s"), buf);
+  snprintf (menu->dialog[row++], STRING, _("Fingerprint: %s"), buf);
 
   menu->title = _("SSL Certificate check");
 
@@ -632,7 +621,7 @@ static int ssl_check_certificate (sslsockdata * data)
       if ((fp = fopen (SslCertFile, "a"))) {
         if (PEM_write_X509 (fp, data->cert))
           done = 1;
-        fclose (fp);
+        m_fclose(&fp);
       }
       if (!done) {
         mutt_error (_("Warning: Couldn't save certificate"));