diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-07-11 19:16:33 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-07-11 19:16:33 +0300 |
commit | 61295ae0e724c62ac016dfc374d6064c63270288 (patch) | |
tree | 8578f2bfb814260f8ffa5a83814d07803d7d5de7 | |
parent | f6b40b8d77c08636e90ae23b86dd01f7e70f080e (diff) | |
download | mailutils-61295ae0e724c62ac016dfc374d6064c63270288.tar.gz mailutils-61295ae0e724c62ac016dfc374d6064c63270288.tar.bz2 |
Improve internal variable handling in mail. Implement envelope and variable commands.
* NEWS: Update.
* doc/texinfo/programs.texi: Document new variables and commands.
* mail/envelope.c: New file.
* mail/mailvar.c: New file.
* mail/Makefile.am (mail_SOURCES): Add envelope.c and mailvar.c.
* mail/mail.h (EF_HIDDEN): New constant
(mail_env_data_t, mail_env_entry, mail_env_entry_is_set)
(mail_env_entry, util_getenv, util_printenv, util_setenv)
(var_iterator_t, var_iterate_next, var_iterate_first)
(var_iterate_end, var_compl): Removed.
(union mailvar_value, struct mailvar_variable
(mail_variable, mail_envelope, print_envelope)
(mailvar_find_variable, mailvar_get, mailvar_print)
(mailvar_variable_format, mailvar_set, mailvar_set_compl): Add prototypes.
(MOPTF_OVERWRITE, MOPTF_QUIET)
* mail/table.c: List new commands: envelope, setq, variable.
Implement completion for `set'.
* mail/testsuite/mail/if.exp: Use setq to set a read-only variable.
mail/alias.c, mail/decode.c, mail/delete.c, mail/escape.c
mail/file.c, mail/folders.c, mail/from.c, mail/if.c,
mail/mail.c, mail/mailline.c, mail/msgset.y, mail/pipe.c,
mail/print.c, mail/quit.c, mail/reply.c, mail/send.c,
mail/set.c, mail/shell.c, mail/top.c, mail/unset.c,
mail/util.c: Use mailvar functions.
-rw-r--r-- | NEWS | 40 | ||||
-rw-r--r-- | doc/texinfo/programs.texi | 198 | ||||
-rw-r--r-- | mail/Makefile.am | 2 | ||||
-rw-r--r-- | mail/alias.c | 2 | ||||
-rw-r--r-- | mail/decode.c | 10 | ||||
-rw-r--r-- | mail/delete.c | 2 | ||||
-rw-r--r-- | mail/envelope.c | 51 | ||||
-rw-r--r-- | mail/escape.c | 32 | ||||
-rw-r--r-- | mail/file.c | 2 | ||||
-rw-r--r-- | mail/folders.c | 2 | ||||
-rw-r--r-- | mail/from.c | 74 | ||||
-rw-r--r-- | mail/if.c | 2 | ||||
-rw-r--r-- | mail/mail.c | 40 | ||||
-rw-r--r-- | mail/mail.h | 79 | ||||
-rw-r--r-- | mail/mailline.c | 28 | ||||
-rw-r--r-- | mail/mailvar.c | 763 | ||||
-rw-r--r-- | mail/msgset.y | 4 | ||||
-rw-r--r-- | mail/pipe.c | 4 | ||||
-rw-r--r-- | mail/print.c | 7 | ||||
-rw-r--r-- | mail/quit.c | 6 | ||||
-rw-r--r-- | mail/reply.c | 4 | ||||
-rw-r--r-- | mail/send.c | 40 | ||||
-rw-r--r-- | mail/set.c | 12 | ||||
-rw-r--r-- | mail/shell.c | 7 | ||||
-rw-r--r-- | mail/table.c | 8 | ||||
-rw-r--r-- | mail/testsuite/mail/if.exp | 10 | ||||
-rw-r--r-- | mail/top.c | 2 | ||||
-rw-r--r-- | mail/unset.c | 2 | ||||
-rw-r--r-- | mail/util.c | 312 |
29 files changed, 1244 insertions, 501 deletions
@@ -1,4 +1,4 @@ -GNU mailutils NEWS -- history of user-visible changes. 2009-07-08 +GNU mailutils NEWS -- history of user-visible changes. 2009-07-11 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. See the end of file for copying conditions. @@ -27,6 +27,44 @@ exists in the destination mailbox. The `--verbose' command line option enables outputting additional information. +* Mail + +** envelope command + +The env[elope] command displays the SMTP envelopes of the messages +given as its arguments. + +** variable command + +The va[riable] command describes the known internal mail variables. +When used with arguments, only variables named in the command line are +described. + +For each variable, this command prints its name, data type, current +value and a short description. + +** showenvelope variable + +If the `showenvelope' variable is set, print command will include the +SMTP envelope in its output. + +** fromfield variable + +The `fromenvelope' boolean variable, if set, instructs mail to obtain +the sender address from the `From:' header. This is the default. +If unset, the sender address is obtained from the SMTP envelope. + +** variable-strict variable + +Setting this variable enables strict control over variable +settings. In this mode, mail prints warning if a user is trying to +set an unknown variable and refuses to set read-only variables. + +** variable-pretty-print variable + +If this variable is set, the `set' listing prints short +descriptions before each variable. + * API * Wicket/Ticket functions diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi index 15cad8ec6..1c21a5257 100644 --- a/doc/texinfo/programs.texi +++ b/doc/texinfo/programs.texi @@ -3282,11 +3282,12 @@ The @samp{echo} (@samp{ec}) command prints its arguments to stdout. The command @samp{source @var{filename}} reads commands from the named file. Its minimal abbreviation is @samp{so}. +@anchor{Setting and Unsetting the Variables} @subsubheading Setting and Unsetting the Variables @kyindex set, mail command @kyindex unset, mail command -The mail variables may be set using @samp{set} (@samp{se}) command. The +The mail variables are set using @samp{set} (@samp{se}) command. The command takes a list of assignments. The syntax of an assignment is @table @samp @@ -3322,6 +3323,58 @@ To undo the effect of the previous example, do: & unset askcc crt indentprefix @end smallexample +When used without arguments, both @command{set} or @command{unset} +list all currently defined variables. The form of this listing is +controlled by @code{variable-pretty-print} (@code{varpp}) variable. If +it is set, a description precedes each variable, e.g.: + +@smallexample +# prompt user for subject before composing the message +ask +# prompt user for cc before composing the message +askcc +# output character set for decoded header fields +charset="auto" +# number of columns on terminal screen +columns=80 +@end smallexample + +If @code{variable-pretty-print} is not set, only the settings are +shown, e.g.: + +@smallexample +ask +askcc +charset="auto" +columns=80 +@end smallexample + +@kyindex variable, mail command +A special command is provided to list all internal @command{mail} +variables: + +@smallexample +variable [@var{names...}] +@end smallexample + +If used without arguments, it prints all known internal variables. If +arguments are given, it displays only those internal variables that +are listed in command line. For each variable, this command prints its +name, data type, current value and a short description. For example: + +@smallexample +& variable ask datefield +ask, asksub +Type: boolean +Current value: yes +prompt user for subject before composing the message + +datefield +Type: boolean +Current value: [not set] +get date from the `Date:' header, instead of the envelope +@end smallexample + @subsubheading Setting and Unsetting Shell Environment Variables Shell environment may be modified using @samp{setenv} (@samp{sete}) @@ -3391,6 +3444,15 @@ set Following variables control the behavior of GNU @command{mail}: @table @code +@item append +@*Type: Boolean, Read-Only +@*Default: True +@vrindex append, mail variable + +Messages saved in mbox are appended to the end rather than prepended. +This is the default and cannot be changed. This variable exists only +for compatibility with other @command{mailx} implementations. + @item appenddeadletter @*Type: Boolean. @*Default: False. @@ -3447,16 +3509,19 @@ message, the next one will be typed automatically. When set, every occurrence of @code{!} in arguments to @code{!} command is replaced with the last executed command. +@anchor{datefield} @item datefield @*Type: Boolean. @*Default: False. @vrindex datefield, mail variable -By default the date in a header summary is taken from the SMTP +By default the date in a header summary is taken from the @acronym{SMTP} envelope of the message. Setting this variable tells @command{mail} to use the date from @code{Date:} header field, converted to local time. Notice, that for messages lacking this field @command{mail} -will fall back to using SMTP envelope. +will fall back to using @acronym{SMTP} envelope. + +@xref{fromfield}. @item charset @*Type: string @@ -3520,6 +3585,14 @@ Unprintable characters are represented by their octal codes. Printable ones are printed @samp{as is}. @end table +@item debug +@*Type: Boolean +@*Default: Unset +@vrindex debug, mail variable + +This variable is not used. It exists for compatibility with other +@command{mailx} implementations and for future use. + @item dot @*Type: Boolean. @*Default: False. @@ -3559,7 +3632,7 @@ denoting escapes. @*Default: Unset @vrindex flipr, mail variable -The variable @code{flipr} if set swaps the meanings of @code{reply} +If set, the variable @code{flipr} swaps the meanings of @code{reply} and @code{Reply} commands (@pxref{Replying}). @item folder @@ -3570,6 +3643,17 @@ and @code{Reply} commands (@pxref{Replying}). The name of the directory to use for storing folders of messages. If unset, @env{$HOME} is assumed. +@anchor{fromfield} +@item fromfield +@*Type: Boolean. +@*Default: True. + +By default the sender address is taken from the @samp{From} header. +Unsetting this variable tells @command{mail} to obtain it from the +@acronym{SMTP} envelope, instead. + +@xref{datefield}. + @item header @*Type: Boolean. @*Default: True, unless started with @option{--nosum} (@option{-N}) option. @@ -3621,6 +3705,15 @@ before entering send mode (@pxref{Composing Mail}). By default, the address header fields are left intact while composing, the alias expansion takes place immediately before sending message. +@item keep +@*Type: Boolean, Read-Only +@*Default: True +@vrindex append, mail variable + +Truncate the user's system mailbox when it is empty, instead of +removing it. This is the default and cannot be changed. This variable +exists only for compatibility with other @command{mailx} implementations. + @item keepsave @*Type: Boolean. @*Default: False. @@ -3702,11 +3795,33 @@ is removed from the expansion. Setting this option causes the sender to be included in the group. @item mode -@*Type: String. +@*Type: String, Read-Only @*Default: The name of current operation mode. @vrindex mode, mail variable -Setting this variable does not affect the operation mode of the program. +This variable keeps the name of the current operation mode. Its +possible values are: + +@table @asis +@item headers +The program is started with the @option{--headers} (@option{-H}) command +line option (@pxref{Invoking Mail}). + +@item exist +The program is started with the @option{--exist} (@option{-e}) command +line option (@pxref{Invoking Mail}). + +@item print +The program is started with the @option{--print} (@option{-p}) command +line option (@pxref{Invoking Mail}). + +@item read +The progran operates in read mode. This is the default. + +@item send +The program operates in send mode. This means it was given one or more +recipient addresses in the command line. +@end table @item nullbody @* Type: Boolean @@ -3732,6 +3847,13 @@ outputs something on its standard output or error: @end group @end smallexample +@item showenvelope +@*Type: Boolean +@*Default: Unset + +If this variable is set, the @code{print} command will include the +@acronym{STMP} envelope in its output. + @item nullbodymsg @*Type: String @*Default: Null message body; hope that's ok @@ -3743,6 +3865,14 @@ this text, in accordance with the current locale, is displayed. Unsetting this variable disables the warning. +@item onehop +@*Type: Boolean +@*Default: Unset +@vrindex onehop, mail variable + +This variable is not used. It exists for compatibility with other +@command{mailx} implementations and for future use. + @item outfolder @*Type: String. @*Default: Unset. @@ -3767,6 +3897,14 @@ character after printing each message. Contains the command prompt sequence. +@item quiet +@*Type: Boolean +@*Default: Unset +@vrindex quiet, mail variable + +This variable is not used. It exists for compatibility with other +@command{mailx} implementations and for future use. + @item quit @*Type: Boolean. @*Default: False, unless started with @option{--quit} (@option{-q}) option. @@ -3782,6 +3920,16 @@ When set, causes keyboard interrupts to terminate the program. When this variable is set, @command{mail} will read the system-wide configuration file upon startup. See @ref{Mail Configuration Files}. +@item readonly +@*Type: Boolean +@*Default: False +@vrindex readonly, mail variable + +When set, mailboxes are opened in readonly mode. In this mode, any +@command{mail} commands that alter the contents of the mailbox are +disabled. These commands include, but are not limited to: +@code{delete}, @code{save} and @code{mbox}. + @item record @*Type: String. @*Default: Unset. @@ -3853,7 +4001,23 @@ This variable contains the number of lines on terminal screen. @*Default: sendmail:/usr/lib/sendmail @vrindex sendmail, mail variable -Contains the URL of mail transport agent. +Contains URL of the mail transport agent. + +@item sendwait +@*Type: Boolean +@*Default: Unset +@vrindex sendwait, mail variable + +This variable is not used. It exists for compatibility with other +@command{mailx} implementations and for future use. + +@item showto +@*Type: Boolean +@*Default: False +@vrindex showto, mail variable + +If the message was sent by the user, print its recipient address in +the header summary. @item Sign @*Type: String. @@ -3897,6 +4061,26 @@ off. Number of lines to be displayed by @code{top} and @code{Top} commands. +@item variable-strict +@itemx varstrict +@*Type: Boolean. +@*Default: False. + +Setting this variable enables strict control over variable +settings. In this mode, @command{mail} refuses to set read-only +variables. Also, if the user is trying to set an unknown variable, +@command{mail} prints a warning. + +@xref{Setting and Unsetting the Variables}. + +@item variable-pretty-print +@itemx varpp +@*Type: Boolean. +@*Default: False. + +If this variable is set, the listing ouput by @command{set} contains short +descriptions before each variable. @xref{Setting and Unsetting the Variables}. + @item verbose @*Type: Boolean. @*Default: False. diff --git a/mail/Makefile.am b/mail/Makefile.am index 7b7682ce7..a47694bc5 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -49,6 +49,7 @@ mail_SOURCES = \ dp.c\ echo.c\ edit.c\ + envelope.c\ eq.c\ escape.c\ exit.c\ @@ -65,6 +66,7 @@ mail_SOURCES = \ mail.c\ mail.h\ mailline.c\ + mailvar.c\ mbox.c\ msgset.y\ next.c\ diff --git a/mail/alias.c b/mail/alias.c index 515f8904a..613c17ac8 100644 --- a/mail/alias.c +++ b/mail/alias.c @@ -152,7 +152,7 @@ alias_expand (const char *name) alias_t al; mu_list_t list; - if (util_getenv (NULL, "recursivealiases", Mail_env_boolean, 0) == 0) + if (mailvar_get (NULL, "recursivealiases", mailvar_type_boolean, 0) == 0) { char *s; mu_list_t origlist; diff --git a/mail/decode.c b/mail/decode.c index 159f4139e..369ed7626 100644 --- a/mail/decode.c +++ b/mail/decode.c @@ -182,7 +182,7 @@ display_message0 (mu_message_t mesg, const msgset_t *msgset, if (mu_message_unencapsulate (mesg, &submsg, NULL) == 0) display_message0 (submsg, msgset, select_hdr); } - else if (util_getenv (&tmp, "metamail", Mail_env_string, 0) == 0) + else if (mailvar_get (&tmp, "metamail", mailvar_type_string, 0) == 0) { /* If `metamail' is set to a string, treat it as command line of external metamail program. */ @@ -212,13 +212,13 @@ display_message0 (mu_message_t mesg, const msgset_t *msgset, /* If `metamail' is set to true, enable internal mailcap support */ - if (util_getenv (NULL, "metamail", Mail_env_boolean, 0) == 0) + if (mailvar_get (NULL, "metamail", mailvar_type_boolean, 0) == 0) { char *no_ask = NULL; int debug = 0; - util_getenv (&no_ask, "mimenoask", Mail_env_string, 0); - if (util_getenv (&debug, "verbose", Mail_env_boolean, 0) == 0 + mailvar_get (&no_ask, "mimenoask", mailvar_type_string, 0); + if (mailvar_get (&debug, "verbose", mailvar_type_boolean, 0) == 0 && debug) debug = 9; @@ -347,7 +347,7 @@ run_metamail (const char *mailcap_cmd, mu_message_t mesg) char *no_ask; setenv ("METAMAIL_PAGER", getenv ("PAGER"), 0); - if (util_getenv (&no_ask, "mimenoask", Mail_env_string, 0)) + if (mailvar_get (&no_ask, "mimenoask", mailvar_type_string, 0)) setenv ("MM_NOASK", no_ask, 1); status = mu_message_get_stream (mesg, &stream); diff --git a/mail/delete.c b/mail/delete.c index 07e853a9d..83dae90f2 100644 --- a/mail/delete.c +++ b/mail/delete.c @@ -40,7 +40,7 @@ mail_delete (int argc, char **argv) int rc = util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, mail_delete_msg, NULL); - if (util_getenv (NULL, "autoprint", Mail_env_boolean, 0) == 0) + if (mailvar_get (NULL, "autoprint", mailvar_type_boolean, 0) == 0) util_do_command("print"); return rc; diff --git a/mail/envelope.c b/mail/envelope.c new file mode 100644 index 000000000..24d93916c --- /dev/null +++ b/mail/envelope.c @@ -0,0 +1,51 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2009 Free Software Foundation, Inc. + + GNU Mailutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Mailutils is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ + +#include "mail.h" + +/* + * env[elope] [msglist] + */ + +int +print_envelope (msgset_t *mspec, mu_message_t msg, void *data) +{ + int status; + mu_envelope_t env = NULL; + const char *sender = NULL, *date = NULL; + + status = mu_message_get_envelope (msg, &env); + if (status) + { + mu_error (_("%d: Cannot get envelope"), mspec->msg_part[0]); + } + else + { + mu_envelope_sget_sender (env, &sender); + mu_envelope_sget_date (env, &date); + if (data) + fprintf (ofile, "%s ", (char*) data); + fprintf (ofile, "%s %s", sender, date); + } + return 0; +} + +int +mail_envelope (int argc, char **argv) +{ + return util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, + print_envelope, NULL); +} diff --git a/mail/escape.c b/mail/escape.c index a95528a3d..e44283e42 100644 --- a/mail/escape.c +++ b/mail/escape.c @@ -164,7 +164,7 @@ escape_check_args (int argc, char **argv) if (argc == 1) { char *escape = "~"; - util_getenv (&escape, "escape", Mail_env_string, 0); + mailvar_get (&escape, "escape", mailvar_type_string, 0); util_error (_("%c%s requires an argument"), escape[0], argv[0]); return 1; } @@ -234,8 +234,8 @@ escape_sign (int argc MU_ARG_UNUSED, char **argv, compose_env_t *env MU_ARG_UNUS { char *p; - if (util_getenv (&p, mu_isupper (argv[0][0]) ? "Sign" : "sign", - Mail_env_string, 1) == 0) + if (mailvar_get (&p, mu_isupper (argv[0][0]) ? "Sign" : "sign", + mailvar_type_string, 1) == 0) { fputs ("-- \n", ofile); if (mu_isupper (argv[0][0])) @@ -315,7 +315,7 @@ run_editor (char *ed, char *arg) static int escape_run_editor (char *ed, int argc, char **argv, compose_env_t *env) { - if (!util_getenv (NULL, "editheaders", Mail_env_boolean, 0)) + if (!mailvar_get (NULL, "editheaders", mailvar_type_boolean, 0)) { char *filename; int fd = mu_tempfile (NULL, &filename); @@ -413,29 +413,9 @@ escape_headers (int argc, char **argv, compose_env_t *env) int escape_insert (int argc, char **argv, compose_env_t *send_env MU_ARG_UNUSED) { - struct mail_env_entry *env; - if (escape_check_args (argc, argv)) return 1; - env = util_find_env (argv[1], 0); - if (env) - switch (env->type) - { - case Mail_env_string: - fprintf (ofile, "%s", env->value.string); - break; - - case Mail_env_number: - fprintf (ofile, "%d", env->value.number); - break; - - case Mail_env_boolean: - fprintf (ofile, "%s", env->set ? "yes" : "no"); - break; - - default: - break; - } + mailvar_variable_format (ofile, mailvar_find_variable (argv[1], 0), NULL); return 0; } @@ -455,7 +435,7 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) fprintf (stdout, _("Interpolating: %d\n"), mspec->msg_part[0]); - util_getenv (&prefix, "indentprefix", Mail_env_string, 0); + mailvar_get (&prefix, "indentprefix", mailvar_type_string, 0); if (*(int*)data) { diff --git a/mail/file.c b/mail/file.c index 2230438a0..803bb86ce 100644 --- a/mail/file.c +++ b/mail/file.c @@ -118,7 +118,7 @@ mail_file (int argc, char **argv) mbox = newbox; mu_mailbox_messages_count (mbox, &total); set_cursor (1); - if (util_getenv (NULL, "header", Mail_env_boolean, 0) == 0) + if (mailvar_get (NULL, "header", mailvar_type_boolean, 0) == 0) { util_do_command ("summary"); util_do_command ("z."); diff --git a/mail/folders.c b/mail/folders.c index 379bbfecd..1eaedf403 100644 --- a/mail/folders.c +++ b/mail/folders.c @@ -27,7 +27,7 @@ mail_folders (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED) { char *path; - if (util_getenv (&path, "folder", Mail_env_string, 1)) + if (mailvar_get (&path, "folder", mailvar_type_string, 1)) return 1; if (path[0] != '/' && path[0] != '~') diff --git a/mail/from.c b/mail/from.c index a148d3c66..383ae5617 100644 --- a/mail/from.c +++ b/mail/from.c @@ -36,48 +36,60 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) int cflag; size_t m_size = 0, m_lines = 0; - mu_message_get_header (msg, &hdr); - if (mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &from) == 0) - { - mu_address_t address = NULL; - if (mu_address_create (&address, from) == 0) + if (mailvar_get (NULL, "fromfield", mailvar_type_boolean, 0) == 0) + { + mu_message_get_header (msg, &hdr); + if (mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &from) == 0) { - char *name; - const char *email; - - if (mu_address_sget_email (address, 1, &email) == 0) + mu_address_t address = NULL; + if (mu_address_create (&address, from) == 0) { - if (util_getenv (NULL, "showto", Mail_env_boolean, 0) == 0 - && mail_is_my_name (email)) + char *name; + const char *email; + + if (mu_address_sget_email (address, 1, &email) == 0) { - char *tmp; - - if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, - &tmp) == 0) + if (mailvar_get (NULL, "showto", mailvar_type_boolean, 0) == 0 + && mail_is_my_name (email)) { - mu_address_t addr_to; - if (mu_address_create (&addr_to, tmp) == 0) + char *tmp; + + if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, + &tmp) == 0) { - mu_address_destroy (&address); - address = addr_to; + mu_address_t addr_to; + if (mu_address_create (&addr_to, tmp) == 0) + { + mu_address_destroy (&address); + address = addr_to; + } + free (tmp); } - free (tmp); } } - } - if ((mu_address_aget_personal (address, 1, &name) == 0 - && name) - || (mu_address_aget_email (address, 1, &name) == 0 - && name)) - { - free (from); - from = name; + if ((mu_address_aget_personal (address, 1, &name) == 0 + && name) + || (mu_address_aget_email (address, 1, &name) == 0 + && name)) + { + free (from); + from = name; + } + mu_address_destroy (&address); } - mu_address_destroy (&address); } + util_rfc2047_decode (&from); + } + else + { + mu_envelope_t env = NULL; + const char *sender = ""; + + if (mu_message_get_envelope (msg, &env) == 0) + mu_envelope_sget_sender (env, &sender); + from = strdup (sender); } - util_rfc2047_decode (&from); mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, &subj); util_rfc2047_decode (&subj); @@ -100,7 +112,7 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) cflag = ' '; date[0] = 0; - if (util_getenv (NULL, "datefield", Mail_env_boolean, 0) == 0 + if (mailvar_get (NULL, "datefield", mailvar_type_boolean, 0) == 0 && mu_header_get_value (hdr, MU_HEADER_DATE, date, sizeof (date), NULL) == 0) { time_t t; @@ -97,7 +97,7 @@ mail_if (int argc, char **argv) return 1; } - if (util_getenv (&mode, "mode", Mail_env_string, 1)) + if (mailvar_get (&mode, "mode", mailvar_type_string, 1)) exit (EXIT_FAILURE); if (if_cond() == 0) diff --git a/mail/mail.c b/mail/mail.c index 3ebf90b42..ff98d9cb5 100644 --- a/mail/mail.c +++ b/mail/mail.c @@ -77,7 +77,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'e': - util_cache_command (&command_list, "set mode=exist"); + util_cache_command (&command_list, "setq mode=exist"); break; case 'f': @@ -102,7 +102,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'p': case 'r': - util_cache_command (&command_list, "set mode=print"); + util_cache_command (&command_list, "setq mode=print"); break; case 'q': @@ -110,11 +110,11 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 't': - util_cache_command (&command_list, "set mode=send"); + util_cache_command (&command_list, "setq mode=send"); break; case 'H': - util_cache_command (&command_list, "set mode=headers"); + util_cache_command (&command_list, "setq mode=headers"); break; case 'i': @@ -144,7 +144,8 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'F': - util_cache_command (&command_list, "set byname"); + /* FIXME */ + util_cache_command (&command_list, "setq byname"); break; case ARGP_KEY_ARG: @@ -157,7 +158,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case ARGP_KEY_FINI: if (args->send_mode) - util_cache_command (&command_list, "set mode=send"); + util_cache_command (&command_list, "setq mode=send"); break; default: @@ -192,7 +193,7 @@ mail_cmdline (void *closure, int cont MU_ARG_UNUSED) while (1) { - if (util_getenv (NULL, "autoinc", Mail_env_boolean, 0) == 0 + if (mailvar_get (NULL, "autoinc", mailvar_type_boolean, 0) == 0 && !mu_mailbox_is_updated (mbox)) { mu_mailbox_messages_count (mbox, &total); @@ -208,7 +209,7 @@ mail_cmdline (void *closure, int cont MU_ARG_UNUSED) continue; } - if (!rc && util_getenv (NULL, "ignoreeof", Mail_env_boolean, 0) == 0) + if (!rc && mailvar_get (NULL, "ignoreeof", mailvar_type_boolean, 0) == 0) { util_error (_("Use \"quit\" to quit.")); continue; @@ -220,8 +221,8 @@ mail_cmdline (void *closure, int cont MU_ARG_UNUSED) } static char *default_setup[] = { - "set noallnet", - "set noappend", + /* "set noallnet", */ + "setq append", "set asksub", "set crt", "set noaskbcc", @@ -239,7 +240,7 @@ static char *default_setup[] = { "set noignore", "set noignoreeof", "set indentprefix=\"\t\"", - "set nokeep", + "setq keep", "set nokeepsave", "set nometoo", "set noonehop",< |