push username, homedir and tmpdir in lua too.
[apps/madmutt.git] / lib-crypt / smime.c
index 218b442..374f9f3 100644 (file)
@@ -113,13 +113,13 @@ int smime_valid_passphrase (void)
 /* This is almost identical to ppgp's invoking interface. */
 
 static const char *
-_mutt_fmt_smime_command (char *dest, ssize_t destlen, char op,
-                         const char *src, const char *prefix,
-                         const char *ifstring, const char *elsestring,
-                         unsigned long data, format_flag flags)
+_mutt_fmt_smime_command (char *dest, ssize_t destlen,
+                         char op, const char *src, const char *prefix,
+                         const char *ifstr, const char *elstr,
+                         anytype data, format_flag flags)
 {
   char fmt[16];
-  struct smime_command_context *cctx = (struct smime_command_context *) data;
+  struct smime_command_context *cctx = data.ptr;
   int optional = (flags & M_FORMAT_OPTIONAL);
 
   switch (op) {
@@ -218,14 +218,11 @@ _mutt_fmt_smime_command (char *dest, ssize_t destlen, char op,
     break;
   }
 
-  if (optional)
-    mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_smime_command,
-                       data, 0);
-  else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_smime_command,
-                       data, 0);
+  if (flags & M_FORMAT_OPTIONAL)
+    m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
+                _mutt_fmt_smime_command, data, 0);
 
-  return (src);
+  return src;
 }
 
 
@@ -234,8 +231,7 @@ static void mutt_smime_command (char *d, ssize_t dlen,
                                 struct smime_command_context *cctx,
                                 const char *fmt)
 {
-  mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_smime_command,
-                     (unsigned long) cctx, 0);
+    m_strformat(d, dlen, 0, fmt, _mutt_fmt_smime_command, cctx, 0);
 }
 
 static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout,
@@ -404,12 +400,12 @@ char *smime_ask_for_key (char *prompt, char *mailbox __attribute__((unused)),
     /* Make Helpstring */
     helpstr[0] = 0;
     mutt_make_help (buf, sizeof (buf), _("Exit  "), MENU_SMIME, OP_EXIT);
-    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
+    m_strcat(helpstr, sizeof(helpstr), buf);
     mutt_make_help (buf, sizeof (buf), _("Select  "), MENU_SMIME,
                     OP_GENERIC_SELECT_ENTRY);
-    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
+    m_strcat(helpstr, sizeof(helpstr), buf);
     mutt_make_help (buf, sizeof (buf), _("Help"), MENU_SMIME, OP_HELP);
-    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
+    m_strcat(helpstr, sizeof(helpstr), buf);
 
     /* Create the menu */
     menu = mutt_new_menu ();
@@ -708,8 +704,6 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc)
   address_t *p, *q;
   int i;
 
-  const char *fqdn = mutt_fqdn (1);
-
   for (i = 0; i < 3; i++) {
     switch (i) {
     case 0:
@@ -730,8 +724,7 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc)
       last = &((*last)->next);
   }
 
-  if (fqdn)
-    rfc822_qualify (tmp, fqdn);
+  rfc822_qualify(tmp, mutt_fqdn(1));
 
   address_list_uniq(tmp);
 
@@ -754,7 +747,7 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc)
 
     keylist_size += m_strlen(keyID) + 2;
     p_realloc(&keylist, keylist_size);
-    sprintf (keylist + keylist_used, "%s\n", keyID);    /* __SPRINTF_CHECKED__ */
+    sprintf (keylist + keylist_used, "%s\n", keyID);
     keylist_used = m_strlen(keylist);
 
     address_list_wipe(&addr);
@@ -778,14 +771,14 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
   int ret = -1, count = 0;
   pid_t thepid;
 
-  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fperr) {
     mutt_perror (tmpfname);
     return 1;
   }
   mutt_unlink (tmpfname);
 
-  fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     m_fclose(&fperr);
     mutt_perror (tmpfname);
@@ -864,14 +857,14 @@ static char *smime_extract_certificate (char *infile)
   int empty;
 
 
-  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fperr) {
     mutt_perror (tmpfname);
     return NULL;
   }
   mutt_unlink (tmpfname);
 
-  fpout = m_tempfile (pk7out, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (pk7out, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     m_fclose(&fperr);
     mutt_perror (pk7out);
@@ -913,7 +906,7 @@ static char *smime_extract_certificate (char *infile)
     return NULL;
   }
 
-  fpout = m_tempfile (certfile, sizeof(certfile), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (certfile, sizeof(certfile), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     m_fclose(&fperr);
     mutt_unlink (pk7out);
@@ -967,14 +960,14 @@ static char *smime_extract_signer_certificate (char *infile)
   pid_t thepid;
   int empty;
 
-  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fperr) {
     mutt_perror (tmpfname);
     return NULL;
   }
   mutt_unlink (tmpfname);
 
-  m_tempfile (certfile, sizeof(certfile), NONULL(Tempdir), NULL);
+  m_tempfile (certfile, sizeof(certfile), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     m_fclose(&fperr);
     mutt_perror (certfile);
@@ -1027,14 +1020,14 @@ void smime_invoke_import (char *infile, char *mailbox __attribute__ ((unused)))
   FILE *smimein = NULL, *fpout = NULL, *fperr = NULL;
   pid_t thepid = -1;
 
- fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+ fperr = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fperr) {
     mutt_perror (tmpfname);
     return;
   }
   mutt_unlink (tmpfname);
 
-  fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     m_fclose(&fperr);
     mutt_perror (tmpfname);
@@ -1085,7 +1078,7 @@ int smime_verify_sender (HEADER * h)
   FILE *fpout;
   int retval = 1;
 
-  fpout = m_tempfile (tempfname, sizeof(tempfname), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (tempfname, sizeof(tempfname), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     mutt_perror (_("Can't create temporary file"));
     return 1;
@@ -1185,13 +1178,13 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist)
   int err = 0, empty;
   pid_t thepid;
 
-  fpout = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+  fpout = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
   if (!fpout) {
     mutt_perror (_("Can't create temporary file"));
     return NULL;
   }
 
-  smimeerr = m_tempfile (smimeerrfile, sizeof(smimeerrfile), NONULL(Tempdir), NULL);
+  smimeerr = m_tempfile (smimeerrfile, sizeof(smimeerrfile), NONULL(MCore.tmpdir), NULL);
   if (!smimeerr) {
     mutt_perror (smimeerrfile);
     m_fclose(&fpout);
@@ -1200,7 +1193,7 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist)
   }
   mutt_unlink (smimeerrfile);
 
-  fptmp = m_tempfile (smimeinfile, sizeof(smimeinfile), NONULL(Tempdir), NULL);
+  fptmp = m_tempfile (smimeinfile, sizeof(smimeinfile), NONULL(MCore.tmpdir), NULL);
   if (!fptmp) {
     mutt_perror (smimeinfile);
     mutt_unlink (tempfile);
@@ -1310,13 +1303,13 @@ BODY *smime_sign_message (BODY * a)
 
   convert_to_7bit (a);          /* Signed data _must_ be in 7-bit format. */
 
-  sfp = m_tempfile (filetosign, sizeof(filetosign), NONULL(Tempdir), NULL);
+  sfp = m_tempfile (filetosign, sizeof(filetosign), NONULL(MCore.tmpdir), NULL);
   if (!sfp) {
     mutt_perror (filetosign);
     return NULL;
   }
 
-  smimeout = m_tempfile (signedfile, sizeof(signedfile), NONULL(Tempdir), NULL);
+  smimeout = m_tempfile (signedfile, sizeof(signedfile), NONULL(MCore.tmpdir), NULL);
   if (!smimeout) {
     mutt_perror (signedfile);
     m_fclose(&sfp);
@@ -1499,7 +1492,7 @@ int smime_verify_one (BODY * sigbdy, STATE * s, const char *tempfile)
 
   sigbdy->type = origType;
 
-  smimeerr = m_tempfile(smimeerrfile, sizeof(smimeerrfile), NONULL(Tempdir), NULL);
+  smimeerr = m_tempfile(smimeerrfile, sizeof(smimeerrfile), NONULL(MCore.tmpdir), NULL);
   if (!smimeerr) {
     mutt_perror (smimeerrfile);
     mutt_unlink (signedfile);
@@ -1580,13 +1573,13 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile)
   if (!(type & APPLICATION_SMIME))
     return NULL;
 
-  smimeout = m_tempfile (outfile, sizeof(outfile), NONULL(Tempdir), NULL);
+  smimeout = m_tempfile (outfile, sizeof(outfile), NONULL(MCore.tmpdir), NULL);
   if (!smimeout) {
     mutt_perror (outfile);
     return NULL;
   }
 
-  smimeerr = m_tempfile(errfile, sizeof(errfile), NONULL(Tempdir), NULL);
+  smimeerr = m_tempfile(errfile, sizeof(errfile), NONULL(MCore.tmpdir), NULL);
   if (!smimeerr) {
     mutt_perror (errfile);
     m_fclose(&smimeout);
@@ -1594,7 +1587,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile)
   }
   mutt_unlink (errfile);
 
-  tmpfp = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
+  tmpfp = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL);
   if (!tmpfp) {
     mutt_perror (tmpfname);
     m_fclose(&smimeout);
@@ -1670,7 +1663,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile)
     if (outFile)
       fpout = outFile;
     else {
-      fpout = m_tempfile (tmptmpfname, sizeof(tmptmpfname), NONULL(Tempdir), NULL);
+      fpout = m_tempfile (tmptmpfname, sizeof(tmptmpfname), NONULL(MCore.tmpdir), NULL);
       if (!fpout) {
         mutt_perror (tmptmpfname);
         m_fclose(&smimeout);
@@ -1767,7 +1760,7 @@ int smime_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
   s.fpin = fpin;
   fseeko (s.fpin, b->offset, 0);
 
-  tmpfp = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+  tmpfp = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
   if (!tmpfp) {
     mutt_perror (_("Can't create temporary file"));
     return (-1);
@@ -1783,7 +1776,7 @@ int smime_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
   s.fpin = tmpfp;
   s.fpout = 0;
 
-  *fpout = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
+  *fpout = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL);
   if (!*fpout) {
     mutt_perror (_("Can't create temporary file"));
     rv = -1;
@@ -1912,10 +1905,6 @@ int smime_send_menu (HEADER * msg, int *redraw)
       /* probably need a different passphrase */
       crypt_smime_void_passphrase ();
     }
-#if 0
-    else
-      msg->security &= ~SIGN;
-#endif
 
     *redraw = REDRAW_FULL;
     break;