From 558b0bd9de90a9dc28f409d8f46679bf48c72ded Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 18 Mar 2007 15:08:54 +0100 Subject: [PATCH] push username, homedir and tmpdir in lua too. Signed-off-by: Pierre Habouzit --- account.c | 6 +++--- alias.c | 8 ++++---- attach.c | 6 +++--- browser.c | 2 +- commands.c | 2 +- globals.h | 3 --- handler.c | 2 +- headers.c | 2 +- help.c | 2 +- imap/imap.c | 2 +- imap/message.c | 4 ++-- init.c | 38 ++++++----------------------------- init.h | 8 -------- lib-crypt/crypt-gpgme.c | 22 ++++++++++----------- lib-crypt/crypt.c | 4 ++-- lib-crypt/pgp.c | 34 +++++++++++++++---------------- lib-crypt/pgpkey.c | 4 ++-- lib-crypt/pgpmicalg.c | 2 +- lib-crypt/smime.c | 44 ++++++++++++++++++++--------------------- lib-lua/lua-token.sh | 3 +++ lib-lua/madmutt.cpkg | 17 +++++++++++++++- lib-mime/rfc3676.c | 2 +- lib-mx/compress.c | 4 ++-- lib-mx/mbox.c | 4 ++-- lib-mx/mx.c | 2 +- lib-sys/mutt_ssl.c | 2 +- main.c | 2 +- muttlib.c | 10 +++++----- nntp/nntp.c | 4 ++-- pattern.c | 2 +- pop/pop.c | 4 ++-- postpone.c | 2 +- recvattach.c | 4 ++-- recvcmd.c | 6 +++--- send.c | 10 +++++----- sendlib.c | 12 +++++------ 36 files changed, 133 insertions(+), 152 deletions(-) diff --git a/account.c b/account.c index 17234fb..ea1806a 100644 --- a/account.c +++ b/account.c @@ -19,8 +19,8 @@ /* mutt_account_match: compare account info (host/port/user/login) */ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2) { - const char* user = NONULL (Username); - const char* login = NONULL (Username); + const char* user = NONULL(MCore.username); + const char* login = NONULL(MCore.username); if (a1->type != a2->type) return 0; @@ -140,7 +140,7 @@ int mutt_account_getuser (ACCOUNT * account) /* prompt (defaults to unix username), copy into account->user */ else { snprintf(prompt, sizeof(prompt), _("Username at %s: "), account->host); - m_strcpy(account->user, sizeof(account->user), NONULL(Username)); + m_strcpy(account->user, sizeof(account->user), NONULL(MCore.username)); if (mutt_get_field_unbuffered(prompt, account->user, sizeof(account->user), 0)) return -1; diff --git a/alias.c b/alias.c index f1021ef..03482c6 100644 --- a/alias.c +++ b/alias.c @@ -107,10 +107,10 @@ int mutt_addr_is_user(address_t *addr) if (!addr->mailbox) return 0; - if (!ascii_strcasecmp(addr->mailbox, Username) - || string_is_address(addr->mailbox, Username, Hostname) - || string_is_address(addr->mailbox, Username, mutt_fqdn(0)) - || string_is_address(addr->mailbox, Username, mutt_fqdn(1)) + if (!ascii_strcasecmp(addr->mailbox, MCore.username) + || string_is_address(addr->mailbox, MCore.username, Hostname) + || string_is_address(addr->mailbox, MCore.username, mutt_fqdn(0)) + || string_is_address(addr->mailbox, MCore.username, mutt_fqdn(1)) || (From && !ascii_strcasecmp(From->mailbox, addr->mailbox))) { return 1; diff --git a/attach.c b/attach.c index 648d6db..d42e47a 100644 --- a/attach.c +++ b/attach.c @@ -138,7 +138,7 @@ int mutt_compose_attachment (BODY * a) /* Remove headers by copying out data to another file, then * copying the file back */ fseeko (fp, b->offset, 0); - tfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!tfp) { mutt_perror (_("Failure to open file to strip headers.")); goto bailout; @@ -440,7 +440,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, if (use_pager) { /* recv case */ - pagerfd = m_tempfd(pagerfile, sizeof(pagerfile), NONULL(Tempdir), + pagerfd = m_tempfd(pagerfile, sizeof(pagerfile), NONULL(MCore.tmpdir), fp && !use_mailcap ? a->filename : NULL); } @@ -923,7 +923,7 @@ int mutt_print_attachment (FILE * fp, BODY * a) ifp = NULL; fpout = NULL; - newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(Tempdir), NULL); + newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(MCore.tmpdir), NULL); if (mutt_decode_save_attachment (fp, a, newfile_fd, M_PRINTING) == 0) { if ((ifp = fopen(newfile, "r")) == NULL) { diff --git a/browser.c b/browser.c index fba0ac3..4a927d9 100644 --- a/browser.c +++ b/browser.c @@ -926,7 +926,7 @@ void _mutt_select_file (char *f, ssize_t flen, int flags, char ***files, /* try to restore the old values */ m_strcpy(LastDir, sizeof(LastDir), OldLastDir); if (examine_directory (menu, &state, LastDir, prefix) == -1) { - m_strcpy(LastDir, sizeof(LastDir), NONULL(Homedir)); + m_strcpy(LastDir, sizeof(LastDir), NONULL(MCore.homedir)); goto bail; } } diff --git a/commands.c b/commands.c index 8b5444b..c7fc7a5 100644 --- a/commands.c +++ b/commands.c @@ -56,7 +56,7 @@ int mutt_display_message (HEADER * cur) mutt_parse_mime_message (Context, cur); mutt_message_hook (Context, cur, M_MESSAGEHOOK); - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fpout) { mutt_error _("Could not create temporary file!"); return 0; diff --git a/globals.h b/globals.h index cf27213..5e4aa18 100644 --- a/globals.h +++ b/globals.h @@ -40,7 +40,6 @@ WHERE char *FolderFormat; WHERE char *ForwFmt; WHERE char *Fqdn; WHERE char *HdrFmt; -WHERE char *Homedir; WHERE char *Hostname; WHERE char *ImapAuthenticators INITVAL (NULL); @@ -146,10 +145,8 @@ WHERE char *SslCACertFile INITVAL (NULL); #endif WHERE char *StChars; WHERE char *Status; -WHERE char *Tempdir; WHERE char *Tochars; WHERE char *TrashPath; -WHERE char *Username; WHERE char *XtermTitle; WHERE char *XtermLeave; WHERE char *XtermIcon; diff --git a/handler.c b/handler.c index c5c8301..0153bc3 100644 --- a/handler.c +++ b/handler.c @@ -1385,7 +1385,7 @@ int mutt_body_handler (BODY * b, STATE * s) if (!plaintext) { /* decode to a tempfile, saving the original destination */ fp = s->fpout; - s->fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + s->fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!s->fpout) { mutt_error _("Unable to open temporary file!"); goto bail; diff --git a/headers.c b/headers.c index bd4f77e..cd3362b 100644 --- a/headers.c +++ b/headers.c @@ -28,7 +28,7 @@ void mutt_edit_headers(const char *body, struct stat st; string_list_t *cur, **last = NULL, *tmp; - ofp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL); + ofp = m_tempfile(path, sizeof(path), NONULL(MCore.tmpdir), NULL); if (!ofp) { mutt_perror (path); return; diff --git a/help.c b/help.c index 1162b23..062f975 100644 --- a/help.c +++ b/help.c @@ -284,7 +284,7 @@ void mutt_help (int menu) desc = _(""); do { - f = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL); + f = m_tempfile(tmp, sizeof(tmp), NONULL(MCore.tmpdir), NULL); if (!f) { mutt_perror(tmp); return; diff --git a/imap/imap.c b/imap/imap.c index e54b81f..6a84d94 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1600,7 +1600,7 @@ static int imap_open_new_message (MESSAGE * msg, { char tmp[_POSIX_PATH_MAX]; - msg->fp = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL); + msg->fp = m_tempfile(tmp, sizeof(tmp), NONULL(MCore.tmpdir), NULL); if (!msg->fp) { mutt_perror(tmp); return -1; diff --git a/imap/message.c b/imap/message.c index a3225e4..3980496 100644 --- a/imap/message.c +++ b/imap/message.c @@ -83,7 +83,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) /* instead of downloading all headers and then parsing them, we parse them * as they come in. */ - fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fp) { mutt_error(_("Could not create temporary file")); mutt_sleep(2); @@ -376,7 +376,7 @@ int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) mutt_message _("Fetching message..."); cache->uid = HEADER_DATA (h)->uid; - msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL); + msg->fp = m_tempfile(path, sizeof(path), NONULL(MCore.tmpdir), NULL); if (!msg->fp) { return -1; } diff --git a/init.c b/init.c index 03065c2..96fcf0b 100644 --- a/init.c +++ b/init.c @@ -2209,37 +2209,13 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) snprintf (AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%ld\a", (long) time (NULL)); - /* on one of the systems I use, getcwd() does not return the same prefix - as is listed in the passwd file */ - if ((p = getenv ("HOME"))) - Homedir = m_strdup(p); - /* Get some information about the user */ if ((pw = getpwuid (getuid ()))) { char rnbuf[STRING]; - - Username = m_strdup(pw->pw_name); - if (!Homedir) - Homedir = m_strdup(pw->pw_dir); - mutt_gecos_name(rnbuf, sizeof(rnbuf), pw, GecosMask.rx); Realname = m_strdup(rnbuf); endpwent (); } - else { - if (!Homedir) { - mutt_endwin (NULL); - fputs (_("unable to determine home directory"), stderr); - exit (1); - } - if ((p = getenv ("USER"))) - Username = m_strdup(p); - else { - mutt_endwin (NULL); - fputs (_("unable to determine username"), stderr); - exit (1); - } - } /* And about the host... */ uname (&utsname); @@ -2289,9 +2265,9 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) Spoolfile = m_strdup(p); else { #ifdef HOMESPOOL - mutt_concat_path(buffer, sizeof(buffer), NONULL(Homedir), MAILPATH); + mutt_concat_path(buffer, sizeof(buffer), NONULL(MCore.homedir), MAILPATH); #else - mutt_concat_path(buffer, sizeof(buffer), MAILPATH, NONULL(Username)); + mutt_concat_path(buffer, sizeof(buffer), MAILPATH, NONULL(MCore.username)); #endif Spoolfile = m_strdup(buffer); } @@ -2305,8 +2281,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"); } - Tempdir = m_strdup((p = getenv ("TMPDIR")) ? p : "/tmp"); - if ((p = getenv ("REPLYTO")) != NULL) { BUFFER buf, token; @@ -2342,10 +2316,10 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) mutt_init_history (); if (!Muttrc) { - snprintf (buffer, sizeof(buffer), "%s/.madmuttrc", NONULL (Homedir)); + snprintf (buffer, sizeof(buffer), "%s/.madmuttrc", NONULL(MCore.homedir)); if (access (buffer, F_OK) == -1) snprintf (buffer, sizeof(buffer), "%s/.madmutt/madmuttrc", - NONULL (Homedir)); + NONULL(MCore.homedir)); default_rc = 1; Muttrc = m_strdup(buffer); @@ -2398,9 +2372,9 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) } /* LUA {{{ */ - snprintf(buffer, sizeof(buffer), "%s/.madmutt.lua", NONULL(Homedir)); + snprintf(buffer, sizeof(buffer), "%s/.madmutt.lua", NONULL(MCore.homedir)); if (access(buffer, F_OK) < 0) - snprintf(buffer, sizeof(buffer), "%s/.madmutt/cfg.lua", NONULL(Homedir)); + snprintf(buffer, sizeof(buffer), "%s/.madmutt/cfg.lua", NONULL(MCore.homedir)); if (!access(buffer, F_OK)) { need_pause = luaM_wrap(mutt_error, luaM_dofile(buffer)); } diff --git a/init.h b/init.h index fa5af82..1f706e6 100644 --- a/init.h +++ b/init.h @@ -3306,14 +3306,6 @@ struct option_t MuttVars[] = { ** checking for new mail. A value of zero or less will cause Madmutt ** to never time out. */ - {"tmpdir", DT_PATH, R_NONE, UL &Tempdir, "" }, - /* - ** .pp - ** This variable allows you to specify where Madmutt will place its - ** temporary files needed for displaying and composing messages. If - ** this variable is not set, the environment variable \fT$$$TMPDIR\fP is - ** used. If \fT$$$TMPDIR\fP is not set then "\fT/tmp\fP" is used. - */ {"to_chars", DT_STR, R_BOTH, UL &Tochars, " +TCFL"}, /* ** .pp diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index 445dc77..c0d4b7f 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -348,7 +348,7 @@ static gpgme_data_t body_to_data_object (BODY * a, int convert) int err = 0; gpgme_data_t data; - fptmp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fptmp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fptmp) { mutt_perror (_("Can't create temporary file")); return NULL; @@ -454,7 +454,7 @@ static char *data_object_to_tempfile (gpgme_data_t data, FILE ** ret_fp) FILE *fp; ssize_t nread = 0; - fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fp) { mutt_perror (_("Can't create temporary file")); return NULL; @@ -1467,7 +1467,7 @@ int pgp_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur) p_clear(&s, 1); s.fpin = fpin; - *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 -1; @@ -1512,7 +1512,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, p_clear(&s, 1); 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; @@ -1529,7 +1529,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, p_clear(&s, 1); 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")); return -1; @@ -1564,7 +1564,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, p_clear(&s, 1); s.fpin = *fpout; fseeko (s.fpin, bb->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; @@ -1582,7 +1582,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, p_clear(&s, 1); 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")); return -1; @@ -1625,7 +1625,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, if (tagged_only && !b->tagged) return 0; - tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (mutt_decode_save_attachment (fp, b, tempfd, 0) != 0) { unlink (tempfile); return 0; @@ -1994,7 +1994,7 @@ int pgp_gpgme_encrypted_handler (BODY * a, STATE * s) /* Move forward to the application/pgp-encrypted body. */ a = a->next; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fpout) { if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " @@ -2054,7 +2054,7 @@ int smime_gpgme_application_handler (BODY * a, STATE * s) int rc = 0; a->warnsig = 0; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fpout) { if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " @@ -2925,7 +2925,7 @@ static void verify_key (crypt_key_t * key) gpgme_key_t k = NULL; int maxdepth = 100; - fp = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fp = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fp) { mutt_perror (_("Can't create temporary file")); return; diff --git a/lib-crypt/crypt.c b/lib-crypt/crypt.c index 5f744ee..99728dc 100644 --- a/lib-crypt/crypt.c +++ b/lib-crypt/crypt.c @@ -328,7 +328,7 @@ void crypt_extract_keys_from_messages (HEADER * h) address_t *tmp = NULL; FILE *fpout; - fpout = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfname, sizeof(tempfname), NONULL(MCore.tmpdir), NULL); if (!fpout) { mutt_error(_("Could not create temporary file")); return; @@ -537,7 +537,7 @@ int mutt_signed_handler (BODY * a, STATE * s) crypt_fetch_signatures (&signatures, a->next, &sigcnt); if (sigcnt) { - tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!tempfp) { mutt_error(_("Could not create temporary file")); } else { diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index 297eb73..6b78ce4 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -266,7 +266,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) have_any_sigs = have_any_sigs || (clearsign && (s->flags & M_VERIFY)); /* Copy PGP material to temporary file */ - tmpfp = m_tempfile(tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL); + tmpfp = m_tempfile(tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL); if (tmpfp == NULL) { mutt_perror (tmpfname); return (-1); @@ -295,7 +295,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) /* Invoke PGP if needed */ if (!clearsign || (s->flags & M_VERIFY)) { - pgpout = m_tempfile(outfile, sizeof(outfile), NONULL(Tempdir), NULL); + pgpout = m_tempfile(outfile, sizeof(outfile), NONULL(MCore.tmpdir), NULL); if (pgpout == NULL) { mutt_perror (outfile); return (-1); @@ -466,7 +466,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, if (tagged_only && !b->tagged) return 0; - tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (mutt_decode_save_attachment (fp, b, tempfd, 0) != 0) { unlink (tempfile); return 0; @@ -548,7 +548,7 @@ int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) mutt_copy_bytes (s->fpin, fp, sigbdy->length); m_fclose(&fp); - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgperr == NULL) { mutt_perror (pgperrfile); unlink (sigfile); @@ -594,7 +594,7 @@ static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) FILE *tempfp; char tempfname[_POSIX_PATH_MAX]; - tempfp = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL); + tempfp = m_tempfile(tempfname, sizeof(tempfname), NONULL(MCore.tmpdir), NULL); if (tempfp == NULL) { mutt_perror (_("Can't create temporary file")); return; @@ -649,14 +649,14 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) pid_t thepid; int rv; - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (!pgperr) { mutt_perror (pgperrfile); return NULL; } unlink (pgperrfile); - pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(Tempdir), NULL); + pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(MCore.tmpdir), NULL); if (!pgptmp) { mutt_perror (pgptmpfile); m_fclose(&pgperr); @@ -757,7 +757,7 @@ int pgp_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur) p_clear(&s, 1); s.fpin = fpin; - *fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + *fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (*fpout == NULL) { mutt_perror (_("Can't create temporary file")); return (-1); @@ -798,7 +798,7 @@ int pgp_encrypted_handler (BODY * a, STATE * s) */ a = a->next; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (fpout == NULL) { if (s->flags & M_DISPLAY) state_attach_puts (_ @@ -868,12 +868,12 @@ BODY *pgp_sign_message (BODY * a) convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */ - fp = m_tempfile(sigfile, sizeof(sigfile), NONULL(Tempdir), NULL); + fp = m_tempfile(sigfile, sizeof(sigfile), NONULL(MCore.tmpdir), NULL); if (fp == NULL) { return (NULL); } - sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(Tempdir), NULL); + sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(MCore.tmpdir), NULL); if (sfp == NULL) { mutt_perror (signedfile); m_fclose(&fp); @@ -1112,13 +1112,13 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) int empty = 0; pid_t thepid; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (fpout == NULL) { mutt_perror (_("Can't create temporary file")); return (NULL); } - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgperr == NULL) { mutt_perror (pgperrfile); m_fclose(&fpout); @@ -1127,7 +1127,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) } unlink (pgperrfile); - fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(MCore.tmpdir), NULL); if (fptmp == NULL) { mutt_perror (pgpinfile); m_fclose(&fpout); @@ -1251,7 +1251,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) return NULL; } - pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(MCore.tmpdir), NULL); if (pgpin == NULL) { mutt_perror (pgpinfile); m_fclose(&fp); @@ -1292,8 +1292,8 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) m_fclose(&fp); m_fclose(&pgpin); - pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(Tempdir), NULL); - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(MCore.tmpdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgpout == NULL || pgperr == NULL) { mutt_perror (pgpout ? pgperrfile : pgpoutfile); m_fclose(&pgpin); diff --git a/lib-crypt/pgpkey.c b/lib-crypt/pgpkey.c index 77c5d26..96db58a 100644 --- a/lib-crypt/pgpkey.c +++ b/lib-crypt/pgpkey.c @@ -505,7 +505,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, address_t * p, const char *s) break; } - fp = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fp = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!fp) { m_fclose(&devnull); mutt_perror (_("Can't create temporary file")); @@ -682,7 +682,7 @@ BODY *pgp_make_key_attachment (char *tempf) pgp_free_key (&key); if (!tempf) { - tempfp = m_tempfile (tempfb, sizeof(tempfb), NONULL(Tempdir), NULL); + tempfp = m_tempfile (tempfb, sizeof(tempfb), NONULL(MCore.tmpdir), NULL); tempf = tempfb; } else { tempfp = safe_fopen(tempf, "a"); diff --git a/lib-crypt/pgpmicalg.c b/lib-crypt/pgpmicalg.c index ae16b11..0edbfea 100644 --- a/lib-crypt/pgpmicalg.c +++ b/lib-crypt/pgpmicalg.c @@ -137,7 +137,7 @@ static short pgp_find_hash (const char *fname) short rv = -1; - out = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + out = m_tempfile (tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!out) { mutt_perror (_("Can't create temporary file")); goto bye; diff --git a/lib-crypt/smime.c b/lib-crypt/smime.c index 7e5690d..374f9f3 100644 --- a/lib-crypt/smime.c +++ b/lib-crypt/smime.c @@ -771,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); @@ -857,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); @@ -906,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); @@ -960,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); @@ -1020,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); @@ -1078,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; @@ -1178,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); @@ -1193,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); @@ -1303,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); @@ -1492,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); @@ -1573,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); @@ -1587,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); @@ -1663,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); @@ -1760,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); @@ -1776,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; diff --git a/lib-lua/lua-token.sh b/lib-lua/lua-token.sh index ddc2847..e2f5ed3 100644 --- a/lib-lua/lua-token.sh +++ b/lib-lua/lua-token.sh @@ -119,8 +119,11 @@ exit 0 ## dsn_return ## editor ## hcache_backend +## homedir ## quit ## sendmail ## shell ## sysconfdir +## tmpdir +## username ## version diff --git a/lib-lua/madmutt.cpkg b/lib-lua/madmutt.cpkg index aefb74f..89ff6f2 100644 --- a/lib-lua/madmutt.cpkg +++ b/lib-lua/madmutt.cpkg @@ -31,6 +31,18 @@ static const char *madmutt_init_shell(void) return pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh"); } +static const char *madmutt_init_username(void) +{ + struct passwd *pw = getpwuid(getuid()); + return pw ? pw->pw_name : (getenv("USER") ?: "john_doe"); +} + +static const char *madmutt_init_homedir(void) +{ + struct passwd *pw = getpwuid(getuid()); + return pw ? pw->pw_dir : (getenv("HOME") ?: "/"); +} + static const char *madmutt_pwd(void) { char path[_POSIX_PATH_MAX]; @@ -87,6 +99,9 @@ static const char *luaM_path_post(const char *val) path_t dotlock = BINDIR "/mutt_dotlock"; path_t editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi"; path_t shell = madmutt_init_shell(); + path_t username = madmutt_init_username(); + path_t homedir = madmutt_init_homedir(); + path_t tmpdir = getenv("TMPDIR") ?: "/tmp"; quadopt_t quit = M_YES; bool beep = 1; @@ -96,7 +111,7 @@ static const char *luaM_path_post(const char *val) } MCore; @package MTransport { - path_t sendmail = SENDMAIL " -eom -oi"; + path_t sendmail = SENDMAIL " -eom -oi"; string_t dsn_notify = NULL; string_t dsn_return = NULL; diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index 42bf5ac..0ca9ff7 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -225,7 +225,7 @@ void rfc3676_space_stuff (HEADER* hdr) { if ((in = safe_fopen (hdr->content->filename, "r")) == NULL) return; - out = m_tempfile(tmpf, sizeof(tmpf), NONULL(Tempdir), NULL); + out = m_tempfile(tmpf, sizeof(tmpf), NONULL(MCore.tmpdir), NULL); if (!out) { m_fclose(&in); return; diff --git a/lib-mx/compress.c b/lib-mx/compress.c index df6c761..6e988ca 100644 --- a/lib-mx/compress.c +++ b/lib-mx/compress.c @@ -196,7 +196,7 @@ int mutt_open_read_compressed(CONTEXT * ctx) ctx->realpath = ctx->path; /* Uncompress to /tmp */ - tmpfd = m_tempfd(tmppath, sizeof(tmppath), NONULL(Tempdir), NULL); + tmpfd = m_tempfd(tmppath, sizeof(tmppath), NONULL(MCore.tmpdir), NULL); /* If we cannot open tempfile, that means the file already exists (!?) * or we are following a symlink, which is bad and insecure. */ @@ -289,7 +289,7 @@ int mutt_open_append_compressed (CONTEXT * ctx) ctx->realpath = ctx->path; /* Uncompress to /tmp */ - fh = m_tempfile(tmppath, sizeof(tmppath), NONULL(Tempdir), NULL); + fh = m_tempfile(tmppath, sizeof(tmppath), NONULL(MCore.tmpdir), NULL); m_fclose(&fh); ctx->path = p_dupstr(tmppath, m_strlen(tmppath)); diff --git a/lib-mx/mbox.c b/lib-mx/mbox.c index 7068742..60caf04 100644 --- a/lib-mx/mbox.c +++ b/lib-mx/mbox.c @@ -546,7 +546,7 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) return (-1); /* Create a temporary file to write the new version of the mailbox in. */ - fp = m_tempfile(tempfile, _POSIX_PATH_MAX, NONULL(Tempdir), NULL); + fp = m_tempfile(tempfile, _POSIX_PATH_MAX, NONULL(MCore.tmpdir), NULL); if (fp == NULL) { mutt_error _("Could not create temporary file!"); mutt_sleep (5); @@ -718,7 +718,7 @@ static int mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)) char savefile[_POSIX_PATH_MAX]; snprintf(savefile, sizeof (savefile), "%s/mutt.%s-%u", - NONULL(Tempdir), NONULL(Username), (unsigned int)getpid()); + NONULL(MCore.tmpdir), NONULL(MCore.username), (unsigned int)getpid()); rename (tempfile, savefile); mutt_unblock_signals (); mx_fastclose_mailbox (ctx); diff --git a/lib-mx/mx.c b/lib-mx/mx.c index 231d140..b6fcfc1 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -1080,7 +1080,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) p = hdr->env->from; } - fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL (Username), + fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(MCore.username), ctime (&msg->received)); } } diff --git a/lib-sys/mutt_ssl.c b/lib-sys/mutt_ssl.c index 99998bb..745141b 100644 --- a/lib-sys/mutt_ssl.c +++ b/lib-sys/mutt_ssl.c @@ -143,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 diff --git a/main.c b/main.c index da1b66d..e5dc968 100644 --- a/main.c +++ b/main.c @@ -724,7 +724,7 @@ int main (int argc, char **argv) /* is the following if still needed? */ - fout = m_tempfile(buf, sizeof(buf), NONULL(Tempdir), NULL); + fout = m_tempfile(buf, sizeof(buf), NONULL(MCore.tmpdir), NULL); tempfile = m_strdup(buf); if (tempfile) { diff --git a/muttlib.c b/muttlib.c index d8b94aa..48644d8 100644 --- a/muttlib.c +++ b/muttlib.c @@ -32,7 +32,7 @@ void mutt_adv_mktemp (const char* dir, char *s, ssize_t l) { int fd; - fd = m_tempfd(s, l, m_strisempty(dir) ? NONULL(Tempdir) : dir, s); + fd = m_tempfd(s, l, m_strisempty(dir) ? NONULL(MCore.tmpdir) : dir, s); if (fd < 0) { *s = '\0'; } else { @@ -43,7 +43,7 @@ void mutt_adv_mktemp (const char* dir, char *s, ssize_t l) void mutt_mktemp(char *s) { - int fd = m_tempfd(s, _POSIX_PATH_MAX, NONULL(Tempdir), NULL); + int fd = m_tempfd(s, _POSIX_PATH_MAX, NONULL(MCore.tmpdir), NULL); if (fd < 0) { *s = '\0'; } else { @@ -62,7 +62,7 @@ ssize_t _mutt_expand_path(char *buf, ssize_t len, const char *s, int rx) switch (*s) { case '~': if (s[1] == '/' || s[1] == '\0') { - m_strcpy(p, sizeof(p), Homedir); + m_strcpy(p, sizeof(p), MCore.homedir); tail = s + 1; } else { struct passwd *pw; @@ -199,8 +199,8 @@ void mutt_pretty_mailbox (char *s) *s++ = '='; memmove (s, s + len, m_strlen(s + len) + 1); } - else if (m_strncmp(s, Homedir, (len = m_strlen(Homedir))) == 0 && - s[len] == '/') { + else if (m_strncmp(s, MCore.homedir, (len = m_strlen(MCore.homedir))) == 0 + && s[len] == '/') { *s++ = '~'; memmove (s, s + len - 1, m_strlen(s + len - 1) + 1); } diff --git a/nntp/nntp.c b/nntp/nntp.c index c2f8002..b7d83ea 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -437,7 +437,7 @@ static int nntp_read_header (CONTEXT * ctx, const char *msgid, int ret; HEADER *h = ctx->hdrs[ctx->msgcount]; - f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + f = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!f) return -1; @@ -915,7 +915,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) p_delete(&cache->path); cache->index = ctx->hdrs[msgno]->index; - msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL); + msg->fp = m_tempfile(path, sizeof(path), NONULL(MCore.tmpdir), NULL); if (!msg->fp) { return -1; } diff --git a/pattern.c b/pattern.c index 594beda..eb58688 100644 --- a/pattern.c +++ b/pattern.c @@ -141,7 +141,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) p_clear(&s, 1); s.fpin = msg->fp; s.flags = M_CHARCONV; - s.fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + s.fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!s.fpout) { mutt_error(_("Could not create temporary file")); return (0); diff --git a/pop/pop.c b/pop/pop.c index 9b569aa..0db1cec 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -45,7 +45,7 @@ static pop_query_status pop_read_header (POP_DATA * pop_data, HEADER * h) char buf[LONG_STRING]; char tempfile[_POSIX_PATH_MAX]; - f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + f = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!f) { mutt_error(_("Could not create temporary file")); return PFD_FUNCT_ERROR; @@ -349,7 +349,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) bar.msg = _("Fetching message..."); mutt_progress_bar (&bar, 0); - msg->fp = m_tempfile(path, sizeof(path), NONULL(Tempdir), NULL); + msg->fp = m_tempfile(path, sizeof(path), NONULL(MCore.tmpdir), NULL); if (!msg->fp) { mutt_error(_("Could not create temporary file")); mutt_sleep(2); diff --git a/postpone.c b/postpone.c index a2e03b0..165438d 100644 --- a/postpone.c +++ b/postpone.c @@ -597,7 +597,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, parameter_delval(&b->parameter, "x-mutt-noconv"); } - s.fpout = m_tempfile(file, sizeof(file), NONULL(Tempdir), file); + s.fpout = m_tempfile(file, sizeof(file), NONULL(MCore.tmpdir), file); if (!s.fpout) goto bail; diff --git a/recvattach.c b/recvattach.c index b9db799..198bfa7 100644 --- a/recvattach.c +++ b/recvattach.c @@ -500,7 +500,7 @@ mutt_query_pipe_attachment(char *command, FILE * fp, BODY * body, int afilter) CLEARLINE (LINES - 1); return; } - tempfd = m_tempfd(tfile, sizeof(tfile), NONULL(Tempdir), NULL); + tempfd = m_tempfd(tfile, sizeof(tfile), NONULL(MCore.tmpdir), NULL); } if (mutt_pipe_attachment(fp, body, command, tempfd)) { @@ -634,7 +634,7 @@ static void print_attachment_list (FILE * fp, int tag, BODY * top, FILE *ifp; int newfile_fd; - newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(Tempdir), NULL); + newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(MCore.tmpdir), NULL); if (mutt_decode_save_attachment (fp, top, newfile_fd, M_PRINTING) == 0) { if ((ifp = fopen (newfile, "r")) != NULL) { mutt_copy_stream (ifp, state->fpout); diff --git a/recvcmd.c b/recvcmd.c index e4db1d8..4ab7a87 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -440,7 +440,7 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr, tmphdr->env = envelope_new(); mutt_make_forward_subject (tmphdr->env, Context, parent); - tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL); + tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(MCore.tmpdir), NULL); if (!tmpfp) { mutt_error(_("Could not create temporary file")); return; @@ -602,7 +602,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr __attribute__ ((unused) /* no MIME encapsulation */ - tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL); + tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(MCore.tmpdir), NULL); if (!tmpfp) { mutt_error(_("Could not create temporary file")); header_delete(&tmphdr); @@ -850,7 +850,7 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr, return; } - tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(Tempdir), NULL); + tmpfp = m_tempfile(tmpbody, sizeof(tmpbody), NONULL(MCore.tmpdir), NULL); if (!tmpfp) { mutt_error(_("Could not create temporary file")); header_delete(&tmphdr); diff --git a/send.c b/send.c index 2143f19..6ca6963 100644 --- a/send.c +++ b/send.c @@ -968,11 +968,11 @@ address_t *mutt_default_from (void) else if (option (OPTUSEDOMAIN)) { const char *fqdn = mutt_fqdn (1); adr = address_new(); - adr->mailbox = p_new(char, m_strlen(Username) + m_strlen(fqdn) + 2); - sprintf(adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn)); + adr->mailbox = p_new(char, m_strlen(MCore.username) + m_strlen(fqdn) + 2); + sprintf(adr->mailbox, "%s@%s", NONULL(MCore.username), NONULL(fqdn)); } else { adr = address_new (); - adr->mailbox = m_strdup(NONULL(Username)); + adr->mailbox = m_strdup(NONULL(MCore.username)); } return (adr); @@ -985,7 +985,7 @@ static int send_message (HEADER * msg) int i; /* Write out the message in MIME form. */ - tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!tempfp) return -1; @@ -1183,7 +1183,7 @@ int ci_send_message (int flags, /* send mode */ if (!tempfile) { char buffer[_POSIX_PATH_MAX]; - tempfp = m_tempfile(buffer, sizeof(buffer), NONULL(Tempdir), NULL); + tempfp = m_tempfile(buffer, sizeof(buffer), NONULL(MCore.tmpdir), NULL); msg->content->filename = m_strdup(buffer); } else { tempfp = safe_fopen(tempfile, "a+"); diff --git a/sendlib.c b/sendlib.c index cc456b3..666ccba 100644 --- a/sendlib.c +++ b/sendlib.c @@ -829,7 +829,7 @@ int mutt_lookup_mime_type (BODY * att, const char *path) */ switch (count) { case 0: - snprintf (buf, sizeof (buf), "%s/.mime.types", NONULL (Homedir)); + snprintf(buf, sizeof (buf), "%s/.mime.types", NONULL(MCore.homedir)); break; case 1: m_strcpy(buf, sizeof(buf), SYSCONFDIR "/madmutt-mime.types"); @@ -925,7 +925,7 @@ void mutt_message_to_7bit (BODY * a, FILE * fp) a->length = sb.st_size; } - fpout = m_tempfile(temp, sizeof(temp), NONULL(Tempdir), NULL); + fpout = m_tempfile(temp, sizeof(temp), NONULL(MCore.tmpdir), NULL); if (!fpout) { mutt_error(_("Could not create temporary file")); goto cleanup; @@ -990,7 +990,7 @@ static void transform_to_7bit (BODY * a, FILE * fpin) a->noconv = 1; a->force_charset = 1; - s.fpout = m_tempfile(buff, sizeof(buff), NONULL(Tempdir), NULL); + s.fpout = m_tempfile(buff, sizeof(buff), NONULL(MCore.tmpdir), NULL); if (!s.fpout) { mutt_error(_("Could not create temporary file")); return; @@ -1114,7 +1114,7 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) return (NULL); } - fp = m_tempfile(buffer, sizeof(buffer), NONULL(Tempdir), NULL); + fp = m_tempfile(buffer, sizeof(buffer), NONULL(MCore.tmpdir), NULL); if (!fp) return NULL; @@ -2038,7 +2038,7 @@ static int _mutt_bounce_message (FILE * fp, HEADER * h, address_t * to, if (!fp) fp = msg->fp; - f = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + f = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (f) { int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM; @@ -2128,7 +2128,7 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, * the message body begins with "From " */ if (f.magic == M_MMDF || f.magic == M_MBOX) { - tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + tempfp = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (!tempfp) { mutt_error(_("Could not create temporary file")); mx_close_mailbox (&f, NULL); -- 2.20.1