/* 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;
/* 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;
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;
/* 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;
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);
}
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) {
/* 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;
}
}
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;
WHERE char *ForwFmt;
WHERE char *Fqdn;
WHERE char *HdrFmt;
-WHERE char *Homedir;
WHERE char *Hostname;
WHERE char *ImapAuthenticators 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;
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;
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;
desc = _("<UNKNOWN>");
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;
{
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;
/* 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);
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;
}
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);
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);
}
"/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;
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);
}
/* 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));
}
** 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
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;
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;
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;
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;
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;
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;
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;
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;
/* 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! "
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! "
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;
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;
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 {
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);
/* 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);
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;
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);
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;
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);
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);
*/
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 (_
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);
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);
}
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);
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);
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);
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"));
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");
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;
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);
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);
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);
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);
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);
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;
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);
}
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);
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);
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);
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);
}
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);
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);
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);
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;
## dsn_return
## editor
## hcache_backend
+## homedir
## quit
## sendmail
## shell
## sysconfdir
+## tmpdir
+## username
## version
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];
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;
} 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;
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;
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.
*/
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));
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);
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);
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));
}
}
/* 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
/* 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) {
{
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 {
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 {
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;
*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);
}
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;
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;
}
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);
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;
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);
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;
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)) {
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);
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;
/* 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);
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);
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);
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;
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+");
*/
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");
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;
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;
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;
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;
* 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);