use m_strdup and m_strlen that are inlined for efficiency
[apps/madmutt.git] / smime.c
diff --git a/smime.c b/smime.c
index 88989f5..554f02e 100644 (file)
--- a/smime.c
+++ b/smime.c
@@ -14,6 +14,7 @@
 #endif
 
 #include <lib-lib/mem.h>
 #endif
 
 #include <lib-lib/mem.h>
+#include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 
 #include "mutt.h"
 #include <lib-lib/macros.h>
 
 #include "mutt.h"
@@ -25,7 +26,6 @@
 #include "mime.h"
 #include "copy.h"
 
 #include "mime.h"
 #include "copy.h"
 
-#include "lib/str.h"
 #include "lib/debug.h"
 
 #include <sys/wait.h>
 #include "lib/debug.h"
 
 #include <sys/wait.h>
@@ -489,8 +489,8 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public,
   if (!mailbox && !query)
     return (NULL);
 
   if (!mailbox && !query)
     return (NULL);
 
-  addr_len = mailbox ? str_len (mailbox) : 0;
-  query_len = query ? str_len (query) : 0;
+  addr_len = mailbox ? m_strlen(mailbox) : 0;
+  query_len = query ? m_strlen(query) : 0;
 
   *key = '\0';
 
 
   *key = '\0';
 
@@ -622,8 +622,8 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public,
 
   }
 
 
   }
 
-  /* Note: str_dup ("") returns NULL. */
-  return str_dup (key);
+  /* Note: m_strdup("") returns NULL. */
+  return m_strdup(key);
 }
 
 
 }
 
 
@@ -649,7 +649,7 @@ void _smime_getkeys (char *mailbox)
   if (k) {
     /* the key used last time. */
     if (*SmimeKeyToUse &&
   if (k) {
     /* the key used last time. */
     if (*SmimeKeyToUse &&
-        !str_casecmp (k, SmimeKeyToUse + str_len (SmimeKeys) + 1)) {
+        !str_casecmp (k, SmimeKeyToUse + m_strlen(SmimeKeys) + 1)) {
       p_delete(&k);
       return;
     }
       p_delete(&k);
       return;
     }
@@ -671,7 +671,7 @@ void _smime_getkeys (char *mailbox)
 
   if (*SmimeKeyToUse) {
     if (!str_casecmp (SmimeDefaultKey,
 
   if (*SmimeKeyToUse) {
     if (!str_casecmp (SmimeDefaultKey,
-                          SmimeKeyToUse + str_len (SmimeKeys) + 1))
+                          SmimeKeyToUse + m_strlen(SmimeKeys) + 1))
       return;
 
     smime_void_passphrase ();
       return;
 
     smime_void_passphrase ();
@@ -773,10 +773,10 @@ char *smime_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
       return NULL;
     }
 
       return NULL;
     }
 
-    keylist_size += str_len (keyID) + 2;
+    keylist_size += m_strlen(keyID) + 2;
     p_realloc(&keylist, keylist_size);
     sprintf (keylist + keylist_used, "%s\n", keyID);    /* __SPRINTF_CHECKED__ */
     p_realloc(&keylist, keylist_size);
     sprintf (keylist + keylist_used, "%s\n", keyID);    /* __SPRINTF_CHECKED__ */
-    keylist_used = str_len (keylist);
+    keylist_used = m_strlen(keylist);
 
     rfc822_free_address (&addr);
 
 
     rfc822_free_address (&addr);
 
@@ -833,8 +833,8 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
 
 
   while ((fgets (email, sizeof (email), fpout))) {
 
 
   while ((fgets (email, sizeof (email), fpout))) {
-    *(email + str_len (email) - 1) = '\0';
-    if (str_ncasecmp (email, mailbox, str_len (mailbox)) == 0)
+    *(email + m_strlen(email) - 1) = '\0';
+    if (str_ncasecmp (email, mailbox, m_strlen(mailbox)) == 0)
       ret = 1;
 
     ret = ret < 0 ? 0 : ret;
       ret = 1;
 
     ret = ret < 0 ? 0 : ret;
@@ -860,8 +860,8 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
 
     rewind (fpout);
     while ((fgets (email, sizeof (email), fpout))) {
 
     rewind (fpout);
     while ((fgets (email, sizeof (email), fpout))) {
-      *(email + str_len (email) - 1) = '\0';
-      (*buffer)[count] = p_dupstr(email, str_len(email));
+      *(email + m_strlen(email) - 1) = '\0';
+      (*buffer)[count] = p_dupstr(email, m_strlen(email));
       count++;
     }
   }
       count++;
     }
   }
@@ -977,7 +977,7 @@ static char *smime_extract_certificate (char *infile)
   fclose (fpout);
   fclose (fperr);
 
   fclose (fpout);
   fclose (fperr);
 
-  return str_dup (certfile);
+  return m_strdup(certfile);
 }
 
 static char *smime_extract_signer_certificate (char *infile)
 }
 
 static char *smime_extract_signer_certificate (char *infile)
@@ -1039,7 +1039,7 @@ static char *smime_extract_signer_certificate (char *infile)
   fclose (fpout);
   fclose (fperr);
 
   fclose (fpout);
   fclose (fperr);
 
-  return str_dup (certfile);
+  return m_strdup(certfile);
 }
 
 
 }
 
 
@@ -1241,7 +1241,7 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist)
 
   *certfile = '\0';
   while (1) {
 
   *certfile = '\0';
   while (1) {
-    int off = str_len (certfile);
+    int off = m_strlen(certfile);
 
     while (*++cert_end && *cert_end != '\n');
     if (!*cert_end)
 
     while (*++cert_end && *cert_end != '\n');
     if (!*cert_end)
@@ -1304,14 +1304,14 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist)
 
   t = mutt_new_body ();
   t->type = TYPEAPPLICATION;
 
   t = mutt_new_body ();
   t->type = TYPEAPPLICATION;
-  t->subtype = str_dup ("x-pkcs7-mime");
+  t->subtype = m_strdup("x-pkcs7-mime");
   mutt_set_parameter ("name", "smime.p7m", &t->parameter);
   mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
   t->encoding = ENCBASE64;      /* The output of OpenSSL SHOULD be binary */
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   mutt_set_parameter ("name", "smime.p7m", &t->parameter);
   mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
   t->encoding = ENCBASE64;      /* The output of OpenSSL SHOULD be binary */
   t->use_disp = 1;
   t->disposition = DISPATTACH;
-  t->d_filename = str_dup ("smime.p7m");
-  t->filename = str_dup (tempfile);
+  t->d_filename = m_strdup("smime.p7m");
+  t->filename = m_strdup(tempfile);
   t->unlink = 1;                /*delete after sending the message */
   t->parts = 0;
   t->next = 0;
   t->unlink = 1;                /*delete after sending the message */
   t->parts = 0;
   t->next = 0;
@@ -1420,7 +1420,7 @@ BODY *smime_sign_message (BODY * a)
 
   t = mutt_new_body ();
   t->type = TYPEMULTIPART;
 
   t = mutt_new_body ();
   t->type = TYPEMULTIPART;
-  t->subtype = str_dup ("signed");
+  t->subtype = m_strdup("signed");
   t->encoding = ENC7BIT;
   t->use_disp = 0;
   t->disposition = DISPINLINE;
   t->encoding = ENC7BIT;
   t->use_disp = 0;
   t->disposition = DISPINLINE;
@@ -1437,9 +1437,9 @@ BODY *smime_sign_message (BODY * a)
   t->parts->next = mutt_new_body ();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
   t->parts->next = mutt_new_body ();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
-  t->subtype = str_dup ("x-pkcs7-signature");
-  t->filename = str_dup (signedfile);
-  t->d_filename = str_dup ("smime.p7s");
+  t->subtype = m_strdup("x-pkcs7-signature");
+  t->filename = m_strdup(signedfile);
+  t->d_filename = m_strdup("smime.p7s");
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   t->encoding = ENCBASE64;
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   t->encoding = ENCBASE64;
@@ -1727,7 +1727,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile)
       }
     }
     while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL) {
       }
     }
     while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL) {
-      len = str_len (buf);
+      len = m_strlen(buf);
       if (len > 1 && buf[len - 2] == '\r') {
         buf[len - 2] = '\n';
         buf[len - 1] = '\0';
       if (len > 1 && buf[len - 2] == '\r') {
         buf[len - 2] = '\n';
         buf[len - 1] = '\0';