/* standard format (filter) files */
char *mhlformat = "mhl.format"; /* show */
char *mhlreply = "mhl.reply"; /* repl */
+char *scanformat = "scan.default"; /* scan/inc */
/*
dnl Check location of modf
AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
-termcap_curses_order="termcap curses ncurses"
+termcap_curses_order="termcap curses ncurses tinfo"
for lib in $termcap_curses_order; do
AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
done
* Write different function to read configuration files, instead
of using m_getfld.c
* convert calls from sprintf/vsprintf to snprintf/vsnprintf
-* convert calls from getcpy to strdup
* modularize access to context/profile list.
* add command printm to print messages
* finish changing to macros for msgstats and msgflags
mhl.reply rcvdistcomps rcvdistcomps.outbox \
replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD \
scan.nmh scan.mailx scan.nomime scan.size scan.time \
- scan.timely scan.unseen scan.meillo mhn.defaults
+ scan.timely scan.unseen scan.meillo scan.default \
+ mhn.defaults
# ========= DEPENDENCIES FOR BUILDING ==========
overflowtext="***",overflowoffset=5
leftadjust,compwidth=9
Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>"
-From:decode
-To:decode
-Cc:decode
-Subject:decode
+From:formatfield="%(putstr(trim(decode{text})))"
+To:formatfield="%(putstr(trim(decode{text})))"
+Cc:formatfield="%(putstr(trim(decode{text})))"
+Subject:formatfield="%(putstr(trim(decode{text})))"
:
%(lit)%(formataddr{addresses})\
-%<(nonnull)%(void(width))%(putaddr Resent-To: )\n%>
+%<(nonnull)%(void(width))%(void(decode))%(putaddr Resent-To: )\n%>
%(formataddr{prev-resent-to})\
%(formataddr{x-to})\
%(formataddr{apparently-to})\
-%(void(width))%(putaddr To: )
+%(void(width))%(void(decode))%(putaddr To: )
%(lit)%(formataddr{to})\
%(formataddr{cc})\
%(formataddr{x-cc})\
%(formataddr{resent-cc})\
%(formataddr{prev-resent-cc})\
%(formataddr(me))\
-%(void(width))%(putaddr Cc: )
+%(void(width))%(void(decode))%(putaddr Cc: )
Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
%;
%; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
%; personal address
%;
%(lit)%(formataddr{mail-followup-to})\
-%<(nonnull)%(void(width))%(putaddr To: )\n\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n\
%|\
%(lit)%(formataddr %<{mail-reply-to}%?{reply-to}%?{from}%?{sender}%?{return-path}%>)\
-%<(nonnull)%(void(width))%(putaddr To: )\n%>\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n%>\
%(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\
-%<(nonnull)%(void(width))%(putaddr Cc: )\n%>%>\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>%>\
%;
Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
%;
%; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
--- /dev/null
+%;
+%; default scan/inc listing format
+%;
+%4(msg)%<(cur)+%| %>%<{replied}-%| %>\
+%4(year{date})-%02(mon{date})-%02(mday{date}) \
+%02(hour{date}):%02(min{date}) \
+%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
+%<(zero)%17(decode(friendly{from}))%> \
+%(putstr(trim(decode{subject})))
%(void(size))%4(divide 1024)\
%<{mime-version} %|~%>\
\
-%(decode{subject})
+%(putstr(trim(decode{subject})))
extern char *rcvdistcomps;
extern char *replcomps;
extern char *replgroupcomps;
+extern char *scanformat;
extern char *sendmail;
extern char *seq_all;
extern char *seq_beyond;
int getanswer(char *);
char **getarguments(char *, int, char **, int);
char *get_charset();
-char *getcpy(char *);
char *getcurfol(void);
char *getdeffol(void);
int lkclose(int, char*);
#define SCNNUM (-2) /* number out of range */
#define SCNFAT (-3) /* fatal error */
-/*
-** default format for `scan' and `inc'
-*/
-# define FORMAT \
-"=%4(msg)%<(cur)+%| %>%<{replied}-%| %>\
-%4(year{date})-%02(mon{date})-%02(mday{date}) %02(hour{date}):%02(min{date}) \
-%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
-%<(zero)%17(decode(friendly{from}))%> %(decode{subject})\n"
-
#define WIDTH 78
#define SCN_MBOX (-1)
** utils.h -- utility prototypes
*/
-void *mh_xmalloc(size_t);
void *mh_xrealloc(void *, size_t);
void *mh_xcalloc(size_t, size_t);
+void mh_free0(void *);
char *pwd(void);
char *add(char *, char *);
void create_folder(char *, int, void (*)(int));
int num_digits(int);
+char *mh_xstrdup(char *);
struct msgs_array {
int max, size;
is a program that parses addresses according to the ARPA
Internet standard. It also understands many non\-standard formats.
It is useful for seeing how
-.B nmh
+.B mmh
will interpret an address.
.PP
The
such as those produced by TOPS\-20 sites and some UNIX sites using
.BR ctime (3).
It is useful for seeing how
-.B nmh
+.B mmh
will interpret a date.
.PP
The
.\"
.TH FMTDUMP %manext8% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-fmtdump \- decode nmh format files
+fmtdump \- decode mh format files
.SH SYNOPSIS
.HP 5
.na
.SH DESCRIPTION
.B Fmtdump
is a program that parses an
-.B nmh
+.B mh
format file and produces a pseudo-language listing of the how
-.B nmh
+.B mmh
interprets the file. This is useful when debugging a complicated format file.
.PP
The
.ad
.SH DESCRIPTION
Since the
-.B nmh
+.B mmh
environment is the shell, it is easy to lose track
of the current folder from day to day. When
.B folder
.I ucom
has files which
aren't messages. These files may either be sub\-folders, or files that
-don't belong under the nmh file naming scheme.
+don't belong under the mh file naming scheme.
.PP
The folder and message totals are output if either a
.B \-all
.B \-volume
.I number
switches implement a digest facility for
-.BR nmh .
+.BR mmh .
Specifying these switches enables and/or overloads the following escapes:
.PP
.RS 5
.B Inc
incorporates mail from the user's incoming mail drop into
an
-.B nmh
+.B mh
folder.
.PP
You may specify which folder to use with
entry, it
will be used as the protection on the newly created messages, otherwise
the
-.B nmh
+.B mmh
default of 0644 will be used. For all subsequent operations
on these messages, this initially assigned protection will be preserved.
.PP
.PP
.B Inc
will incorporate even improperly formatted messages into the
-user's nmh folder, inserting a blank line prior to the offending component
+user's mh folder, inserting a blank line prior to the offending component
and printing a comment identifying the bad message.
.PP
In all cases, the user's mail drop will be zeroed, unless the
.RI ` MailDrop '
for this information. If the value found is
not absolute, then it is interpreted relative to the user's
-.B nmh
+.B mh
directory. If the value is not found, then
.B inc
will look in the standard system location for the user's maildrop.
indicates
that the sequences should be made `public'. These sequences
will then be readable by all
-.B nmh
+.B mmh
users with permission to read the relevant folders. In contrast, the
.B \-nopublic
switch indicates that the
.\"
.TH MH-ALIAS %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mh-alias \- alias file for nmh message system
+mh-alias \- alias file for mh message system
.SH DESCRIPTION
This describes
-.B nmh
+.B mh
personal alias files.
It does
.B not
output instead. If `alias' is terminated with a `;' instead of
a `:', then both the `alias' and the address are output in the
correct format. (This makes replies possible since personal
-.B nmh
+.B mh
aliases are unknown to the mail transport system.)
.RE
.PP
`news.<anything>' are defined to be `news'.
.PP
The key thing to understand about aliasing in
-.B nmh
+.B mh
is that aliases in
-.B nmh
+.B mh
alias files are expanded into the headers of messages posted.
This aliasing occurs first, at posting time, without the knowledge of the
message transport system. In contrast, once the message transport system
.SH "HELPFUL HINTS"
To use aliasing in
-.B nmh
+.B mmh
quickly, do the following:
.PP
.RS 2
.\"
.TH MH-DRAFT %manext7% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mh-draft \- draft folder facility for nmh message system
+mh-draft \- draft folder facility for mh message system
.SH DESCRIPTION
There are a number of interesting advanced facilities for the composition of
outgoing mail.
.PP
The user can send off whatever drafts desired from the shell using the
standard
-.B nmh
+.B mmh
`msgs' convention to the
.B send
command..
.PP
.RS 5
.nf
-comp -use
+comp \-use
.fi
.RE
.PP
.PP
.RS 5
.nf
-comp -use `pick +drafts -to nmh-workers`
+comp \-use `pick +drafts \-to nmh-workers`
.fi
.RE
.PP
.PP
.RS 5
.nf
-send `pick +drafts -to nmh-workers`
+send `pick +drafts \-to nmh-workers`
.fi
.RE
.PP
doesn't mind sending more than one draft at a time.
.PP
It is important to realize that
-.B nmh
+.B mmh
treats the draft folder like a standard
-.B nmh
+.B mh
folder in nearly all respects. There is one exception:
Although conceptually
.B send
.\"
.TH MH-FORMAT %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mh-format \- format file for nmh message system
+mh-format \- format file for mh message system
.SH DESCRIPTION
Several
-.B nmh
+.B mmh
commands utilize either a
.I format
string or a
uses a format file which directs it
how to generate the reply to a message, and so on.
.PP
-There are a few alternate scan listing formats available
-in
-.IR nmh/etc/scan.time ,
-.IR nmh/etc/scan.size ,
+There are a few alternate scan listing formats available, e.g.
+.IR scan.nmh ,
+.IR scan.mailx ,
and
-.IR nmh/etc/scan.timely .
+.IR scan.timely .
Look in
-.I nmh/etc
+.I %etcdir%
for other
.B scan
and
.B repl
-format files which may have been written at your site.
+format files.
.PP
-It suffices to have your local
-.B nmh
-expert actually write new format
-commands or modify existing ones. This manual section explains how to
-do that. Note: familiarity with the C
+This manual section explains how to write and modify format commands.
+Note: familiarity with the C
.B printf
routine is assumed.
.PP
.SS SYNTAX
Format strings are built around
.IR "escape sequences" .
-There are three types of escape sequences: header
-.IR components ,
-built-in
-.IR functions ,
-and flow
-.IR control .
-Comments may be inserted in most places where a function argument is
-not expected. A comment begins with `%;' and ends with a (non-escaped)
+There are four types of escape sequences:
+.PP
+.RS 5
+.nf
+.ta +\w'name of escape class xxxxxxx'u
+.RI "1) header components %{" component }
+.RI "2) built-in functions %(" "function arg" )
+.RI "3) flow control %< ... %? ... %| ... %>
+.RI "4) comments %; ...
+.fi
+.RE
+.PP
+Comments may be inserted in most places where no function argument is
+expected. A comment begins with `%;' and ends with a (non-escaped)
newline.
.PP
A
or a control escape. When the argument is a function or a
component, they are listed without a leading `%'. When control escapes
are used as function arguments, they written as normally, with
-a leading `%';
+a leading `%'.
.SS "Control escapes"
.PP
.fi
.RE
.PP
-Extra white space is shown here only for clarity. These
+(Extra white space is shown here only for clarity.) These
constructs may be nested without ambiguity. They form a general
.B if\-elseif\-else\-endif
block where only one of the
a non-empty string, and false for an empty string.
.PP
-The `%?' control escape is optional, and may there may be more
+The `%?' control escape is optional, and there may be more
than one `%?' control escape in a conditional block.
The `%|' control escape
is also optional, but may be included at most once.
.I str
is used as the argument: which register is
used depends on the function, as listed below.
+.\" What is the difference between these two lines:
+.\" %(void{comp})%(trim)%(putstr)
+.\" %(putstr(trim{comp}))
+.\" The latter can be used as a single expression for %<.
+.\" It does make a difference for (decode) because in the former
+.\" way, wrapping (decode) with (void) can be necessary.
+.\" What is the prefered way?
.PP
Component escapes write the value of their message header in
.IR str .
.\" compflag comp integer Set \fInum\fR to component flags bits (internal)
.\" decodecomp comp string Set \fIstr\fR to RFC-2047 decoded component text
decode expr string decode \fIstr\fR as RFC-2047 (MIME-encoded)
- component
+ component and print it
unquote expr string remove RFC-2822 quotes from \fIstr\fR
trim expr trim trailing white-space from \fIstr\fR
putstr expr print \fIstr\fR
dst date integer daylight savings in effect? (0 or 1)
clock date integer seconds since the UNIX epoch
rclock date integer seconds prior to current time
-tws date string official 822 rendering
+tws date string official RFC-822 rendering
pretty date string user-friendly rendering
.fi
.RE
.nf
.ta \w'Fformataddr 'u +\w'Aboolean 'u +\w'Rboolean 'u
.I "Function Argument Return Description
-proper addr string official 822 rendering
+proper addr string official RFC-822 rendering
friendly addr string user-friendly rendering
addr addr string mbox@host or host!mbox rendering*
pers addr string the personal name*
component in fourteen characters with trailing spaces added as needed.
For \fIputstrf\fR, using a negative value for the field width causes
right-justification of the string within the field, with padding on
-the left up to the field width.
-The functions (\fIputnum\fR\^) and
-(\fIputstr\fR\^) are somewhat special: they print their result in the minimum number of characters
-required, and ignore any leading field width argument.
+the left up to the field width. The functions (\fIputnum\fR\^) and
+(\fIputstr\fR\^) are somewhat special: they print their result in
+the minimum number of characters required, and ignore any leading
+field width argument.
.PP
The available output width is kept in an internal register; any output
past this width will be truncated.
.SS Examples
-With all this in mind,
-here's the default format string for
+With all this in mind, here's a format string for
.BR scan .
It's been divided into several pieces for readability.
The first part is:
.RE
.PP
This formats the
-`From:', `Sender:' and `Return-Path:'
+`From:', `Sender:' or `Return-Path:'
headers, stopping as soon as one of them is present. Next:
.PP
.RS 5
.PP
.RS 5
.nf
-%<{subject}Subject: Re: %{subject}\\n%>\\
+%<{subject}Subject: Re: %(decode{subject})\\n%>\\
.fi
.RE
.PP
.nf
.ta .5i 1i 1.5i 2i
if (comp_exists(message-id)) then
- print (`In-reply-to: ')
- print (message-id.value)
- print (`\\n')
+ print("In-reply-to: ")
+ print(message-id.value)
+ print("\\n")
endif
if (comp_exists(message-id)) then
- print (`References: ')
+ print("References: ")
if (comp_exists(references)) then
print(references.value);
endif
- print (message-id.value)
- print (`\\n')
+ print(message-id.value)
+ print("\\n")
endif
.fi
.RE
.\" (Note that this pseudocode begs the question ``why not just
.\" support this syntax?'' MH has been hacked on for a long time...)
.\".PP
-One more example: Currently,
-.B nmh
+One more example:
+.B Mmh
supports very
large message numbers, and it is not uncommon for a folder
to have far more than 10000 messages.
.\" process 200 messages a day and still get some real work
.\" done." The authors apparently only planned to get
.\" real work done for about 50 days per folder.)
-Nontheless (as noted above)
-the various scan format strings are inherited
+Nonetheless several scan format strings are inherited
from older MH versions, and are generally hard-coded to 4
digits of message number before formatting problems
start to occur.
-The nmh format strings can be modified to behave more sensibly with larger
+The mh format strings can be modified to behave more sensibly with larger
message numbers:
.PP
.RS
.\"
.TH MH-MAIL %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mh-mail \- message format for nmh message system
+mh-mail \- message format for mh message system
.SH DESCRIPTION
-.B nmh
+.B mmh
processes messages in a particular format. It should be noted
that although neither Bell nor Berkeley mailers produce message files
in the format that
-.B nmh
+.B mmh
prefers,
-.B nmh
+.B mmh
can read message files in that antiquated format.
.PP
Each user possesses a system maildrop box which initially receives all
called the body. The header must always exist, but the body is optional.
These parts are separated by an empty line, i.e., two consecutive newline
characters. Within
-.B nmh ,
+.B mmh ,
the header and body may be separated by a line consisting of dashes:
.PP
.RS 5
.SS "Process Profile Entries"
The following profile elements are used whenever an
-.B nmh
+.B mmh
program invokes some other program such as
.BR more .
The profile can be used to select alternate programs if the
.\"
.TH MH-SEQUENCE %manext7% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mh-sequence \- sequence specification for nmh message system
+mh-sequence \- sequence specification for mh message system
.SH DESCRIPTION
A sequence (or sequence set) is a symbolic name representing a
message or collection of messages.
-.B nmh
+.B mmh
has several internally
defined sequences, as well as allowing users to define their own
sequences.
.SS "Message Specification and Pre\-Defined Message Sequences"
Most
-.B nmh
+.B mmh
commands accept a `msg' or `msgs' specification, where
`msg' indicates one message and `msgs' indicates one or more messages.
To designate a message, you may use either its number (e.g., 1, 10, 234)
.SS "User\-Defined Message Sequences"
In addition to the `reserved' (pre-defined) message names given
above,
-.B nmh
+.B mmh
supports user-defined sequence names. User-defined
sequences allow the
-.B nmh
+.B mmh
user a tremendous amount of power in dealing
with groups of messages in the same folder by allowing the user to bind
a group of messages to a meaningful symbolic name.
character followed by zero or more alphanumeric characters, and can not
be one of the `reserved' message names above. After defining a
sequence, it can be used wherever an
-.B nmh
+.B mmh
command expects a `msg' or
`msgs' argument.
.PP
.SS "Public and Private User-Defined Sequences"
There are two varieties of user-defined sequences:
public and private. Public sequences of a folder are accessible to any
-.B nmh
+.B mmh
user that can read that folder. They are kept in each folder
in the file determined by the `Mh\-Sequences' profile entry
(default is
.IR \&.mh_sequences ).
Private sequences are accessible
only to the
-.B nmh
+.B mmh
user that defined those sequences and are kept in
the user's
-.B nmh
+.B mh
context file.
.PP
In general, the commands that create sequences (such as
.BR mark )
will create public sequences if the folder for which
the sequences are being defined is writable by the
-.B nmh
+.B mmh
user.
For most commands, this can be overridden by using the switches
.B \-public
\fIprivate\fR sequences will be created instead.
.SS "Sequence Negation"
-.B Nmh
+.B Mmh
provides the ability to select all messages
.B not
elements of a user-defined sequence.
The default negation prefix is the exlamation mark `!',
but it may be change to any string, by defining the entry
`Sequence\-Negation' in the
-.B nmh
+.B mmh
profile file.
For example, if the profile entry is:
.PP
.RE
.PP
then anytime an
-.B nmh
+.B mmh
command is given `notfoo' as a `msg' or
`msgs' argument, it would substitute all messages that are not elements
of the sequence `foo'.
profile to an empty value.
.SS "The Previous Sequence"
-.B Nmh
+.B Mmh
provides the ability to remember the `msgs' or `msg' argument
last given to an
-.B nmh
+.B mmh
command. The entry `Previous\-Sequence'
should be defined in the
-.B nmh
+.B mmh
profile; its value should be a sequence
name or multiple sequence names separated by spaces. If this entry
is defined, when an
-.B nmh
+.B mmh
command finishes, it will define the
sequence(s) named in the value of this entry to be those messages that
were specified to the command. Hence, a profile entry of
.RE
.PP
directs any
-.B nmh
+.B mmh
command that accepts a `msg' or `msgs' argument to
define the sequence `pseq' as those messages when it finishes.
.PP
there can be a performance penalty in using the
`Previous\-Sequence' facility. If it is used,
.B all
-.B nmh
+.B mmh
programs have to write the sequence information to the
.I \&.mh_sequences
file for the folder each time they run. If the
.PP
.RS 5
.nf
-#audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
+#audio/basic |raw2audio \-F < /usr/lib/sound/giggle.au
.fi
.RE
.PP
An example entry might be:
.PP
.RS 5
-mhbuild-compose-audio/basic: record | raw2audio -F
+mhbuild-compose-audio/basic: record | raw2audio \-F
.RE
.PP
Because commands like these will vary, depending on the display
#
This third part will be text/plain
#audio/basic [silly giggle] \\
- |raw2audio -F < /usr/lib/sounds/giggle.au
+ |raw2audio \-F < /usr/lib/sounds/giggle.au
#image/gif [photo of foobar] \\
/home/foobar/lib/picture.gif
.fi
.\"
.TH MHL %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mhl \- produce formatted listings of nmh messages
+mhl \- produce formatted listings of mh messages
.SH SYNOPSIS
.HP 5
.na
.SH DESCRIPTION
.B Mhl
is an
-.B nmh
+.B mmh
command for filtering and/or displaying text
messages. It is the default method of displaying text messages for
-.B nmh
+.B mmh
(it is the default
.IR showproc ).
.PP
.ta \w'%etcdir%/ExtraBigFileName 'u
^%etcdir%/mhl.format~^The message template
^or $HOME/.mmh/mhl.format~^Rather than the standard template
-^$HOME/.mh/profile~^The user profile
+^$HOME/.mmh/profile~^The user profile
.fi
.SH "PROFILE COMPONENTS"
accept the source message on the standard input. Note that the
file, or input from standard input should be a validly formatted
message, just like any other
-.B nmh
+.B mh
message. It should
.B NOT
be in mail drop format (to convert a file in mail drop format to
a folder of
-.B nmh
+.B mh
messages, see
.BR inc (1)).
.PP
or
.BR mailx ),
which is compatible with
-.BR nmh .
+.BR mmh .
This program was intended for the use of programs such as
.BR cron ,
which expect to send mail automatically to various
addresses. It was also used by various
-.B nmh
+.B mmh
commands to mail various error notifications.
.PP
When invoked without arguments, it had once simply invoked
.\"
.TH MHPARAM %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mhparam \- print nmh profile and context components
+mhparam \- print mmh profile and context components
.SH SYNOPSIS
.HP 5
.na
.\"
.TH MHPATH %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-mhpath \- print full pathnames of nmh messages and folders
+mhpath \- print full pathnames of mh messages and folders
.SH SYNOPSIS
.HP 5
.na
(`Path') is output; this can be useful in shell scripts.
.PP
Contrasted with other
-.B nmh
+.B mmh
commands, a message argument to
.B mhpath
may often be intended for writing. Because of this:
.SH BUGS
Like all
-.B nmh
+.B mmh
commands,
.B mhpath
expands and sorts
accept the source message on the standard input. Note that the
file, or input from standard input should be a validly formatted
message, just like any other
-.B nmh
+.B mh
message. It should
.B NOT
be in mail drop format (to convert a file in mail drop format to
a folder of
-.B nmh
+.B mh
messages, see
.BR inc (1)).
.PP
mhstore-store-text: %m%P.txt
mhstore-store-text: +inbox
mhstore-store-message/partial: +
-mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
+mhstore-store-audio/basic: | raw2audio \-e ulaw \-s 8000 \-c 1 > %m%P.au
mhstore-store-image/jpeg: %m%P.jpg
mhstore-store-application/PostScript: %m%P.ps
.fi
.RE
.PP
which is created automatically during
-.B nmh
+.B mmh
installation.
.SH FILES
.\"
.TH PACKF %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-packf \- pack messages in nmh folder into a single mbox file
+packf \- pack messages in mh folder into a single mbox file
.SH SYNOPSIS
.HP 5
.na
.B extremely
useful for
quickly generating arguments for other
-.B nmh
+.B mmh
programs by using the
`backquoting' syntax of the shell. For example, the command
.PP
backquoting
.B pick
is empty. In the case of
-.B nmh
+.B mmh
programs,
the outer command now acts as if the default `msg' or `msgs' should be
used (e.g., `all' in the case of
.B prompter
under several names (e.g.,
`rapid') and give appropriate switches in the profile entries
-under these names (e.g., `rapid: -rapid'). This facilitates
+under these names (e.g., `rapid: \-rapid'). This facilitates
invoking prompter differently for different
.B mmh
commands (e.g.,
-`forw: -editor rapid').
+`forw: \-editor rapid').
.PP
Former
.B mutt
.SH DESCRIPTION
.B Rcvstore
incorporates a message from the standard input into an
-.B nmh
+.B mh
folder. This command is typically used in conjunction with
mail filtering programs such as
.B slocal
.B Rcvstore
will incorporate anything except zero length messages
into the user's
-.B nmh
+.B mh
folder. It will not change the message in any
way.
.PP
If the user's profile contains a `Msg\-Protect: nnn' entry, it
will be used as the protection on the newly created message, otherwise
the
-.B nmh
+.B mmh
default of 0644 will be used. For all subsequent operations
on this message, this initially assigned protection will be preserved.
.PP
If you use the `Unseen\-Sequence' profile entry,
.B rcvstore
could try to update the context while another
-.B nmh
+.B mmh
process
is also trying to do so. This can cause the context to become
corrupted. To avoid this, do not use
as the source message to be filed, rather than a message from a folder.
Note that the file should be a validly formatted message, just like
any other
-.B nmh
+.B mh
message. It should
.B NOT
be in mail drop format
(to convert a file in mail drop format to a folder of
-.B nmh
+.B mh
messages,
see
.BR inc (1)).
.SH DEFAULTS
.nf
-.RB ` "\-src\ +folder" "' defaults to the current folder"
+.RB ` "\-src\ \fI+folder\fP" "' defaults to the current folder"
.RB ` msgs "' defaults to the current message"
.RB ` \-nolink '
.fi
.SH CONTEXT
If
-.B \-src
-.I +folder
-is given, it will become the current folder.
-If
.B \-link
is specified, the current message in the
source folder will be set to the last message specified; otherwise, the
those sequences for the destination folders. See
.B mh\-sequence (7)
for information concerning the previous sequence.
+
+.SH HISTORY
+Since mmh-0.3,
+.B refile
+does never change the current folder.
+(It used to change it when
+.BI \-src\ +folder
+was given, but this behavior had usability disadvantages.)
If the switch
.B \-nofilter
is given, then the message
-to which you are replying will not be formated and thus not included in
+to which you are replying will not be formatted and thus not included in
the body of the draft.
(It may be added as MIME attachment with
.B \-mime
to the user for editing.
No
.B whatnow
-programm is invoked.
+program is invoked.
No mail is actually sent.
.PP
The
.I msgfile
switch specifies the message to be replied to as an
exact filename rather than as an
-.B nmh
+.B mh
folder and message number. It is
intended to be used by the
.B msh
.ta \w'%etcdir%/ExtraBigFileName 'u
^%etcdir%/replcomps~^The standard reply template
^or $HOME/.mmh/replcomps~^Rather than the standard template
-^%etcdir%/replgroupcomps~^The standard `reply -group' template
+^%etcdir%/replgroupcomps~^The standard `reply \-group' template
^or $HOME/.mmh/replgroupcomps~^Rather than the standard template
^%etcdir%/mhl.reply~^The standard message filter
^or $HOME/.mmh/mhl.reply~^Rather than the standard filter
.\"
.TH RMF %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-rmf \- remove an nmh folder
+rmf \- remove an mh folder
.SH SYNOPSIS
.HP 5
.na
(or default) folder, and then removes the folder (directory) itself.
.PP
If there are any files within the folder which are not a part of
-.BR nmh ,
+.BR mmh ,
they will
.B not
be removed, and an error will be produced.
15+ 10/\|05 crocker nned
16\- 10/\|05 crocker message id format
18 10/\|06 brien Re: Exit status from mkdir
-19 10/\|07*brien `scan' listing format in nmh
+19 10/\|07*brien `scan' listing format in mmh
.fi
.RE
.PP
will accept the source message
on the standard input. Note that the file, or input from standard input
should be a validly formatted message, just like any other
-.B nmh
+.B mh
message. It should
.B NOT
be in mail drop format (to convert a file in
mail drop format to a folder of
-.B nmh
+.B mh
messages, see
.BR inc (1)).
.PP
command (part of the StarOffice package) can be used to display
Microsoft Word content, but it uses the suffix to determine how to display
the file. If no suffix is present, the file is not correctly loaded.
-Similarily, older versions of the
+Similarly, older versions of the
.B gs
command append a `.ps' suffix to
the filename if one was missing. As a result, these cannot be used to read
.PP
.RS 5
.nf
-mhshow-show-text/plain: %liconv -f <source-charset>
+mhshow-show-text/plain: %liconv \-f <source-charset>
mhshow-show-message/rfc822: %lshow \-file %F
.fi
.RE
.nf
mhshow-show-audio/basic: raw2audio 2>/dev/null | play
mhshow-show-image: xv %f
-mhshow-show-application/PostScript: lpr -Pps
+mhshow-show-application/PostScript: lpr \-Pps
.fi
.RE
.PP
piping it through:
.PP
.RS 5
-iconv -f '<source-charset>'
+iconv \-f '<source-charset>'
.RE
.PP
Note that if you have a custom `mhshow-show-*' display string, you
.RE
.PP
which is created automatically during
-.B nmh
+.B mmh
installation.
.SH FILES
.B show
instead. To circumvent this, add a
profile\-entry for the link to your
-.B nmh
+.B mmh
profile and add the argument
.I n
or
Append the message to the mbox file named by
.IR string .
This is handled by piping the message to the
-.B nmh
+.B mmh
program
.BR rcvpack .
If
.TP 4
.IR folder " or " +
Store the message in the
-.B nmh
+.B mh
folder named by
.IR string .
This is handled by piping the message to the
-.B nmh
+.B mmh
program
.BR rcvstore .
If
.nf
.ta \w'default 'u +\w'mh-workersxx 'uC +\w'destroy 'uC +\w'result 'u
#
-# .maildelivery file for nmh's slocal
+# .maildelivery file for mmh's slocal
#
# Blank lines and lines beginning with a '#' are ignored
#
For example, to order a folder by date-major, subject-minor, use:
.PP
.RS 5
-sortm -textfield subject +folder
+sortm \-textfield subject +folder
.RE
.SH FILES
is the default program that queries the user about
the disposition of a composed draft. It is normally automatically
invoked by one of the
-.B nmh
+.B mmh
commands
.BR comp ,
.BR dist ,
.BR mh\-profile (5)
for further information about how editors
are used by
-.BR nmh .
+.BR mmh .
It also discusses how environment variables can be
used to direct
.BR whatnow 's
error.c execprog.c ext_hook.c folder_addmsg.c folder_delmsgs.c \
folder_free.c folder_read.c \
folder_realloc.c gans.c getans.c getanswer.c \
- getarguments.c getcpy.c \
+ getarguments.c \
fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c \
fmt_scan.c lock_file.c m_atoi.c \
m_convert.c m_draft.c m_getfld2.c m_gmprot.c \
dftype = LOCALHOST;
}
- mp = (struct mailname *) mh_xcalloc((size_t) 1, sizeof(*mp));
+ mp = mh_xcalloc(1, sizeof(*mp));
if (mp == NULL) {
if (eresult)
strcpy(eresult, "insufficient memory to represent address");
}
mp->m_next = NULL;
- mp->m_text = getcpy(str);
+ mp->m_text = mh_xstrdup(str);
if (pers)
- mp->m_pers = getcpy(pers);
+ mp->m_pers = mh_xstrdup(pers);
if (mbox == NULL) {
mp->m_type = BADHOST;
mp->m_nohost = 1;
mp->m_ingrp = ingrp;
- mp->m_gname = getcpy(grp);
+ mp->m_gname = mh_xstrdup(grp);
if (note)
- mp->m_note = getcpy(note);
+ mp->m_note = mh_xstrdup(note);
return mp;
}
if (host) {
- mp->m_mbox = getcpy(mbox);
- mp->m_host = getcpy(host);
+ mp->m_mbox = mh_xstrdup(mbox);
+ mp->m_host = mh_xstrdup(host);
} else {
mp->m_nohost = 1;
- mp->m_mbox = getcpy(mbox);
+ mp->m_mbox = mh_xstrdup(mbox);
if (route == NULL && dftype == LOCALHOST) {
mp->m_host = NULL;
mp->m_type = dftype;
} else {
- mp->m_host = route ? NULL : getcpy(dfhost);
+ mp->m_host = route ? NULL : mh_xstrdup(dfhost);
mp->m_type = route ? NETHOST : dftype;
}
goto got_host;
got_host: ;
if (route)
- mp->m_path = getcpy(route);
+ mp->m_path = mh_xstrdup(route);
mp->m_ingrp = ingrp;
if (grp)
- mp->m_gname = getcpy(grp);
+ mp->m_gname = mh_xstrdup(grp);
if (note)
- mp->m_note = getcpy(note);
+ mp->m_note = mh_xstrdup(note);
return mp;
}
return;
if (mp->m_text)
- free(mp->m_text);
+ mh_free0(&(mp->m_text));
if (mp->m_pers)
- free(mp->m_pers);
+ mh_free0(&(mp->m_pers));
if (mp->m_mbox)
- free(mp->m_mbox);
+ mh_free0(&(mp->m_mbox));
if (mp->m_host)
- free(mp->m_host);
+ mh_free0(&(mp->m_host));
if (mp->m_path)
- free(mp->m_path);
+ mh_free0(&(mp->m_path));
if (mp->m_gname)
- free(mp->m_gname);
+ mh_free0(&(mp->m_gname));
if (mp->m_note)
- free(mp->m_note);
+ mh_free0(&(mp->m_note));
- free((char *) mp);
+ mh_free0(&mp);
}
while (first->m_next != NULL && first->m_next != next) {
mp = first->m_next;
first->m_next = mp->m_next;
- free(mp);
+ mh_free0(&mp);
}
first->m_next = next;
return -1;
/* allocate initial space for pointers on first call */
if (!broken) {
len = NUMBROKEN;
- broken = (char **)mh_xmalloc((size_t)(len * sizeof(*broken)));
+ broken = mh_xcalloc(len, sizeof(*broken));
}
/*
/* enlarge pointer array, if necessary */
if (i >= len) {
len += NUMBROKEN;
- broken = mh_xrealloc(broken,
- (size_t)(len * sizeof(*broken)));
+ broken = mh_xrealloc(broken, len * sizeof(*broken));
}
/* handle separators */
len += strlen(cp);
va_end(list);
- dp = sp = mh_xmalloc(len);
+ dp = sp = mh_xcalloc(len, sizeof(char));
sp = copy(s1, sp);
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
** Delete a key/value pair from the context/profile list.
pp->n_next = np->n_next;
else
m_defs = np->n_next;
- free(np->n_name);
+ mh_free0(&(np->n_name));
if (np->n_field)
- free(np->n_field);
- free((char *) np);
+ mh_free0(&(np->n_field));
+ mh_free0(&np);
ctxflags |= CTXMOD;
return 0;
}
*/
#include <h/mh.h> /* mh internals */
+#include <h/utils.h>
#include <errno.h> /* system call errors */
#include <pwd.h> /* structure for getpwuid() results */
#include <unistd.h>
** set mmhpath
*/
if ((cp = getenv("MMH")) && *cp) {
- mmhpath = getcpy(expanddir(cp)); /* rel to cwd */
+ mmhpath = mh_xstrdup(expanddir(cp)); /* rel to cwd */
if (stat(mmhpath, &st) != -1 && (st.st_mode & S_IFDIR) == 0) {
adios(EX_CONFIG, NULL, "`%s' specified by your MMH environment variable is not a directory", cp);
}
*/
if ((cp = getenv("MMHP")) && *cp) {
if (*cp == '/') {
- defpath = getcpy(cp);
+ defpath = mh_xstrdup(cp);
} else {
defpath = concat(mmhpath, "/", cp, NULL);
}
if (!getanswer(cp)) {
adios(EX_NOPERM, NULL, "Unable to access the mail storage directory `%s'", nd);
}
- free(cp);
+ mh_free0(&cp);
if (!makedir(nd)) {
adios(EX_CANTCREAT, nd, "unable to create");
}
}
if (*cp == '/') {
- ctxpath = getcpy(cp);
+ ctxpath = mh_xstrdup(cp);
} else {
ctxpath = concat(mmhpath, "/", cp, NULL);
}
** If list is emtpy, allocate head of profile/context list.
*/
if (!m_defs) {
- m_defs = (struct node *) mh_xmalloc(sizeof(*np));
+ m_defs = mh_xcalloc(1, sizeof(*np));
np = m_defs;
- np->n_name = getcpy(key);
- np->n_field = getcpy(value);
+ np->n_name = mh_xstrdup(key);
+ np->n_field = mh_xstrdup(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
if (!np->n_context)
admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
if (np->n_field)
- free(np->n_field);
- np->n_field = getcpy(value);
+ mh_free0(&(np->n_field));
+ np->n_field = mh_xstrdup(value);
ctxflags |= CTXMOD;
}
return;
/*
** Else add this new entry at the end
*/
- np->n_next = (struct node *) mh_xmalloc(sizeof(*np));
+ np->n_next = mh_xcalloc(1, sizeof(*np));
np = np->n_next;
- np->n_name = getcpy(key);
- np->n_field = getcpy(value);
+ np->n_name = mh_xstrdup(key);
+ np->n_field = mh_xstrdup(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
}
if (strcmp(name, ".") == 0) {
- prefix = getcpy("");
+ prefix = mh_xstrdup("");
} else {
prefix = concat(name, "/", (void *)NULL);
}
/* add_folder saves child in the list, don't free it */
add_folder(child, crawl);
} else {
- free(child);
+ mh_free0(&child);
}
}
closedir(dd);
- free(prefix);
+ mh_free0(&prefix);
}
static void
void
crawl_folders(char *dir, crawl_callback_t *callback, void *baton)
{
- struct crawl_context *crawl = mh_xmalloc(sizeof(*crawl));
+ struct crawl_context *crawl = mh_xcalloc(1, sizeof(*crawl));
crawl->max = CRAWL_NUMFOLDERS;
crawl->total = crawl->start = crawl->foldp = 0;
- crawl->folders = mh_xmalloc(crawl->max * sizeof(*crawl->folders));
+ crawl->folders = mh_xcalloc(crawl->max, sizeof(*crawl->folders));
crawl_folders_body(crawl, dir, callback, baton);
** Note that we "leak" the folder names, on the assumption that the
** caller is using them.
*/
- free(crawl->folders);
- free(crawl);
+ mh_free0(&(crawl->folders));
+ mh_free0(&crawl);
}
** least one) until we get to the actual
** text. Copy until we get to a non-space.
*/
- output = mh_xmalloc(outlen);
+ output = mh_xcalloc(outlen, sizeof(char));
q = output;
while (is_fws(*p)) {
*q++ = *p++;
}
*q = '\0';
- free(*value);
+ mh_free0(value);
*value = output;
return 0;
static void
unfold_header(char **value, int len)
{
- char *str = mh_xmalloc(len + 1);
+ char *str = mh_xcalloc(len + 1, sizeof(char));
char *p = str, *q = *value;
while (*q != '\0') {
}
*p = '\0';
- free(*value);
+ mh_free0(value);
*value = str;
}
output = add(cp, output);
column += len;
- free(cp);
- cp = NULL;
+ mh_free0(&cp);
}
/*
output = add("\n", output);
- free(*value);
+ mh_free0(value);
*value = output;
output = NULL;
out:
if (tmpbuf) {
- free(tmpbuf);
+ mh_free0(&tmpbuf);
}
if (output) {
- free(output);
+ mh_free0(&output);
}
return errflag > 0;
** returns a pointer to the concatenated address string.
**
** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
** length of the result string.
**
** This routine is placed in a separate library so it can be
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = mh_xmalloc(BUFINCR);
+ buf = mh_xcalloc(BUFINCR, sizeof(char));
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
/* Add new component to the hash table */
#define NEWCOMP(cm,name) do { \
- cm = ((struct comp *) mh_xcalloc(1, sizeof (struct comp)));\
+ cm = (mh_xcalloc(1, sizeof (struct comp)));\
cm->c_name = name;\
ncomp++;\
i = CHASH(name);\
size_t i;
if (format_string)
- free(format_string);
- format_string = getcpy(fstring);
+ mh_free0(&format_string);
+ format_string = mh_xstrdup(fstring);
usr_fstring = fstring;
/* init the component hash table. */
i = strlen(fstring)/2 + 1;
if (i == 1)
i++;
- next_fp = formatvec = (struct format *)mh_xcalloc((size_t) i,
- sizeof(struct format));
+ next_fp = formatvec = mh_xcalloc(i, sizeof(struct format));
if (next_fp == NULL)
adios(EX_OSERR, NULL, "unable to allocate format storage");
if (cm->c_type & CT_ADDR) {
CERROR("component used as both date and address");
}
- cm->c_tws = (struct tws *)
- mh_xcalloc((size_t) 1, sizeof(*cm->c_tws));
+ cm->c_tws = mh_xcalloc(1, sizeof(*cm->c_tws));
fp->f_type = preprocess;
PUTCOMP(sp);
cm->c_type |= CT_DATE;
FILE *fp;
if (formats) {
- free(formats);
+ mh_free0(&formats);
}
if (form) {
if (*form == '=') {
- formats = getcpy(form+1);
+ formats = mh_xstrdup(form+1);
} else {
if ((fp = fopen(etcpath(form), "r")) == NULL) {
adios(EX_IOERR, form, "unable to open format file");
if (fstat(fileno(fp), &st) == -1) {
adios(EX_IOERR, form, "unable to stat format file");
}
- formats = mh_xmalloc((size_t) st.st_size + 1);
+ formats = mh_xcalloc(st.st_size + 1, sizeof(char));
if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
adios(EX_IOERR, form, "error reading format file");
}
}
} else if (def_form) {
if (*def_form == '=') {
- formats = getcpy(def_form+1);
+ formats = mh_xstrdup(def_form+1);
} else {
if ((fp = fopen(etcpath(def_form), "r")) == NULL) {
adios(EX_IOERR, def_form, "unable to open format file");
if (fstat(fileno(fp), &st) == -1) {
adios(EX_IOERR, def_form, "unable to stat format file");
}
- formats = mh_xmalloc((size_t) st.st_size + 1);
+ formats = mh_xcalloc(st.st_size + 1, sizeof(char));
if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
adios(EX_IOERR, def_form, "error reading format file");
}
if (use_iconv) {
saveq = q;
savedstlen = dstlen;
- q = convbuf = (char *) mh_xmalloc(endofmime - startofmime);
+ q = convbuf = mh_xcalloc(endofmime - startofmime, sizeof(char));
}
/*
** ADDCHR2 is for adding characters when q is or might be convbuf:
if (!dstlen || !savedstlen)
goto buffull;
dstlen = savedstlen;
- free(convbuf);
+ mh_free0(&convbuf);
}
#endif
*/
#include <h/mh.h>
-
+#include <h/utils.h>
void
folder_free(struct msgs *mp)
return;
if (mp->foldpath)
- free(mp->foldpath);
+ mh_free0(&(mp->foldpath));
/* free the sequence names */
for (i = 0; mp->msgattrs[i]; i++)
- free(mp->msgattrs[i]);
+ mh_free0(&(mp->msgattrs[i]));
- free(mp->msgstats); /* free message status area */
- free(mp); /* free main folder structure */
+ mh_free0(&(mp->msgstats)); /* free message status area */
+ mh_free0(&mp); /* free main folder structure */
}
struct dirent *dp;
DIR *dd;
- name = getcpy(toabsdir(name));
+ name = mh_xstrdup(toabsdir(name));
if (!(dd = opendir(name))) {
- free(name);
+ mh_free0(&name);
return NULL;
}
if (stat(name, &st) == -1) {
- free(name);
+ mh_free0(&name);
closedir(dd);
return NULL;
}
/* Allocate the main structure for folder information */
- mp = (struct msgs *) mh_xmalloc((size_t) sizeof(*mp));
+ mp = mh_xcalloc(1, sizeof(*mp));
clear_folder_flags(mp);
mp->foldpath = name;
** name of the messages in this folder.
*/
len = NUMMSGS;
- mi = (int *) mh_xmalloc((size_t) (len * sizeof(*mi)));
+ mi = mh_xcalloc(len, sizeof(*mi));
while ((dp = readdir(dd))) {
if ((msgnum = m_atoi(dp->d_name)) && msgnum > 0) {
*/
if (mp->nummsg >= len) {
len += NUMMSGS;
- mi = (int *) mh_xrealloc(mi, (size_t) (len * sizeof(*mi)));
+ mi = mh_xrealloc(mi, len * sizeof(*mi));
}
/* Check if this is the first message we've seen */
/* Allocate space for status of each message. */
- mp->msgstats = mh_xmalloc(MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
+ mp->msgstats = mh_xcalloc(MSGSTATSIZE(mp, mp->lowoff, mp->hghoff), 1);
/*
** Clear all the flag bits for all the message
for (msgnum = 0; msgnum < mp->nummsg; msgnum++)
set_exists(mp, mi[msgnum]);
- free(mi); /* We don't need this anymore */
+ mh_free0(&mi); /* We don't need this anymore */
/*
** Read and initialize the sequence information.
seqset_t *tmpstats;
/* first allocate the new message status space */
- tmpstats = mh_xmalloc(MSGSTATSIZE(mp, lo, hi));
+ tmpstats = mh_xcalloc(MSGSTATSIZE(mp, lo, hi), 1);
/* then copy messages status array with shift */
if (mp->nummsg > 0) {
tmpstats[msgnum - lo] = mp->msgstats[msgnum - mp->lowoff];
}
}
- free(mp->msgstats);
+ mh_free0(&(mp->msgstats));
mp->msgstats = tmpstats;
}
** Check if profile/context specifies any arguments
*/
if (check_context && (cp = context_find(invo_name))) {
- cp = getcpy(cp); /* make copy */
+ cp = mh_xstrdup(cp); /* make copy */
ap = brkstring(cp, " ", "\n"); /* split string */
/* Count number of arguments split */
n++;
}
- arguments = (char **) mh_xmalloc((argc + n) * sizeof(*arguments));
+ arguments = mh_xcalloc(argc + n, sizeof(*arguments));
bp = arguments;
/* Copy any arguments from profile/context */
+++ /dev/null
-/*
-** getcpy.c -- copy a string in managed memory
-**
-** THIS IS OBSOLETE. NEED TO REPLACE ALL OCCURENCES
-** OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE
-** CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
-**
-** This code is Copyright (c) 2002, by the authors of nmh. See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-#include <h/utils.h>
-
-
-char *
-getcpy(char *str)
-{
- char *cp;
- size_t len;
-
- if (str) {
- len = strlen(str) + 1;
- cp = mh_xmalloc(len);
- memcpy(cp, str, len);
- } else {
- cp = mh_xmalloc((size_t) 1);
- *cp = '\0';
- }
- return cp;
-}
struct lock *lp;
size_t len;
- lp = (struct lock *) mh_xmalloc(sizeof(*lp));
+ lp = mh_xcalloc(1, sizeof(*lp));
len = strlen(curlock) + 1;
lp->l_fd = fd;
- lp->l_lock = mh_xmalloc(len);
+ lp->l_lock = mh_xcalloc(len, sizeof(char));
memcpy(lp->l_lock, curlock, len);
lp->l_next = l_top;
else
pp->l_next = lp->l_next;
- free(lp->l_lock);
- free(lp);
+ mh_free0(&(lp->l_lock));
+ mh_free0(&lp);
}
}
static char buffer[BUFSIZ];
char *folder;
- folder = getcpy(toabsdir(draftfolder));
+ folder = mh_xstrdup(toabsdir(draftfolder));
create_folder(folder, 0, exit);
if (!(mp = folder_read(folder))) {
adios(EX_IOERR, NULL, "unable to read folder %s", folder);
}
- free(folder);
+ mh_free0(&folder);
/*
** Make sure we have enough message status space for all
for(;;)
pause();
}
- p = mh_xmalloc((size_t) (strlen(s) + 2));
+ p = mh_xcalloc(strlen(s) + 2, sizeof(char));
strcpy(p, s);
return p;
}
struct adrx *adrxp = &adrxs2;
if (pers)
- free(pers);
+ mh_free0(&pers);
if (mbox)
- free(mbox);
+ mh_free0(&mbox);
if (host)
- free(host);
+ mh_free0(&host);
if (path)
- free(path);
+ mh_free0(&path);
if (grp)
- free(grp);
+ mh_free0(&grp);
if (note)
- free(note);
- pers = mbox = host = path = grp = note = NULL;
+ mh_free0(¬e);
err[0] = 0;
if (dp == NULL) {
dp = cp = getcpy(addrs ? addrs : "");
glevel = 0;
} else if (cp == NULL) {
- free(dp);
- dp = NULL;
+ mh_free0(&dp);
return NULL;
}
switch (parse_address()) {
case DONE:
- free(dp);
- dp = cp = NULL;
+ mh_free0(&dp);
+ cp = NULL;
return NULL;
case OK:
}
case LX_COMA:
if (note) {
- free(note);
- note = NULL;
+ mh_free0(¬e);
}
goto again;
case LX_AT: /* sigh (0) */
mbox = add(host, add("%", mbox));
- free(host);
- host = NULL;
+ mh_free0(&host);
continue;
default:
int i;
char **ep, **nep, *cp;
- cp = mh_xmalloc((size_t) (strlen(name) + strlen(value) + 2));
+ cp = mh_xcalloc(strlen(name) + strlen(value) + 2, sizeof(char));
sprintf(cp, "%s=%s", name, value);
return 0;
}
- nep = (char **) mh_xmalloc((size_t) ((i + 2) * sizeof(*nep)));
+ nep = mh_xcalloc(i + 2, sizeof(*nep));
for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
continue;
for (state = FLD2;;) {
switch (state = m_getfld2(state, &f, ib)) {
case FLD2:
- np = (struct node *) mh_xmalloc(sizeof(*np));
+ np = mh_xcalloc(1, sizeof(*np));
*npp = np;
*(npp = &np->n_next) = NULL;
- np->n_name = getcpy(f.name);
+ np->n_name = mh_xstrdup(f.name);
np->n_field = trimcpy(f.value);
np->n_context = ctx;
/* On first invocation, allocate initial buffer space */
if (!buffer) {
len = MAXBUFFER;
- buffer = mh_xmalloc((size_t) len);
+ buffer = mh_xcalloc(len, sizeof(char));
}
/*
char *newbuf;
len += MAXBUFFER;
- newbuf = mh_xrealloc(buffer, (size_t) len);
+ newbuf = mh_xrealloc(buffer, len);
bp = newbuf + (bp - buffer);
buffer = newbuf;
}
** Initialize the list of sequence names. Go ahead and
** add the cur sequence to the list of sequences.
*/
- mp->msgattrs[0] = getcpy(seq_cur);
+ mp->msgattrs[0] = mh_xstrdup(seq_cur);
mp->msgattrs[1] = NULL;
make_all_public(mp); /* initially, make all public */
for (state = FLD2;;) {
switch (state = m_getfld2(state, &f, fp)) {
case FLD2:
- seq_init(mp, getcpy(f.name), trimcpy(f.value));
+ seq_init(mp, mh_xstrdup(f.name), trimcpy(f.value));
continue;
case BODY2:
(j = strlen(np->n_name) - plen) > alen &&
*(np->n_name + j) == '-' &&
strcmp(mp->foldpath, np->n_name + j + 1)==0) {
- cp = getcpy(np->n_name + alen);
+ cp = mh_xstrdup(np->n_name + alen);
*(cp + j - alen) = '\0';
- if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
+ if ((i = seq_init(mp, cp, mh_xstrdup(np->n_field))) != -1)
make_seq_private(mp, i);
}
}
/* Return error, if too many sequences */
if (i >= NUMATTRS) {
- free(name);
- free(field);
+ mh_free0(&name);
+ mh_free0(&field);
return -1;
}
** name string. Else add it to the list of sequence names.
*/
if (mp->msgattrs[i]) {
- free(name);
+ mh_free0(&name);
} else {
mp->msgattrs[i] = name;
mp->msgattrs[i + 1] = NULL;
}
}
- free(field); /* free string containing message ranges */
+ mh_free0(&field); /* free string containing message ranges */
return i;
}
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
** Add all the messages currently SELECTED to
** and split them.
*/
if ((cp = context_find(psequence))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
- free(dp);
+ mh_free0(&dp);
return;
}
} else {
for (; *ap; ap++)
seq_addsel(mp, *ap, -1, 1);
- free(dp);
+ mh_free0(&dp);
}
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
** We scan through the folder and act upon all messages
** and split them.
*/
if ((cp = context_find(usequence))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
} else {
/* not set in profile, thus use the default */
- dp = getcpy(seq_unseen);
+ dp = mh_xstrdup(seq_unseen);
}
if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
/* contains no sequence name, i.e. we're finished */
- free(dp);
+ mh_free0(&dp);
return;
}
}
}
- free(dp);
+ mh_free0(&dp);
}
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <ctype.h>
}
/* now return a copy */
- return getcpy(cp);
+ return mh_xstrdup(cp);
}
#define MAXMSGS 256
/*
-** Safely call malloc
-*/
-void *
-mh_xmalloc(size_t size)
-{
- void *memory;
-
- if (size == 0) {
- adios(EX_SOFTWARE, NULL, "Tried to malloc 0 bytes");
- }
-
- memory = malloc(size);
- if (!memory) {
- adios(EX_OSERR, NULL, "Malloc failed");
- }
-
- return memory;
-}
-
-/*
** Safely call realloc
*/
void *
/* Some non-POSIX realloc()s don't cope with realloc(NULL,sz) */
if (!ptr) {
- return mh_xcalloc((size_t) 1, size);
+ return mh_xcalloc(1, size);
}
if (size == 0) {
adios(EX_SOFTWARE, NULL, "Tried to realloc 0 bytes");
}
/*
+** Free a pointer and set it to NULL.
+*/
+void
+mh_free0(void * ptr)
+{
+ void ** p;
+ p = ptr;
+ free(*p);
+ *p = NULL;
+}
+
+/*
** Return the present working directory, if the current directory does not
** exist, or is too long, make / the pwd.
*/
/*
** add -- If "s1" is NULL, this routine just creates a
** -- copy of "s2" into newly malloc'ed memory.
-** -- (use getcpy() instead in this case)
+** -- (use mh_xstrdup() instead in this case)
** --
** -- If "s1" is not NULL, then copy the concatenation
** -- of "s1" and "s2" (note the order) into newly
len2 = strlen(s2);
}
- cp = mh_xmalloc(len1 + len2 + 1);
+ cp = mh_xcalloc(len1 + len2 + 1, sizeof(char));
/* Copy s1 and free it */
if (s1) {
memcpy(cp, s1, len1);
- free(s1);
+ mh_free0(&s1);
}
/* Copy s2 */
if (!getanswer(cp)) {
done_callback(EX_CANTCREAT);
}
- free(cp);
+ mh_free0(&cp);
} else if (autocreate == -1) {
/* do not create, so exit */
done_callback(EX_CANTCREAT);
}
msgs->msgs[msgs->size++] = cp;
}
+
+/*
+** mh_xstrdup() is a wrapper of strdup() to replace getcpy(). It returns
+** a copy of its argument if this is nonnull; otherwise, it returns a
+** string of length 0.
+*/
+char *
+mh_xstrdup(char * s)
+{
+ char * tmp;
+ tmp = strdup(s ? s : "");
+ if (!tmp) {
+ adios(EX_OSERR, "strdup", "can't copy string");
+ }
+ return tmp;
+}
static char *pp = NULL;
if (pp == NULL)
- pp = mh_xmalloc((size_t) (len = BUFSIZ));
+ pp = mh_xcalloc(len = BUFSIZ, sizeof(char));
for (ep = (cp = pp) + len - 1;;) {
if (fgets(cp, ep - cp + 1, in) == NULL) {
if (cp >= ep) {
int curlen = cp - pp;
- dp = mh_xrealloc(pp, (size_t) (len += BUFSIZ));
+ dp = mh_xrealloc(pp, len += BUFSIZ);
cp = dp + curlen;
ep = (pp = dp) + len - 1;
}
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhsign (correct alias expansion with -enc)
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# setup some aliases
+
+cat >"$MH_TEST_DIR/.mmh/aliases" <<!
+a1: unknownperson
+a2: unknownperson@example.org
+a3: Unknown Person <unknownperson>
+a4: Unknown Person <unknownperson@example.org>
+a5: "Unknown Person" <unknownperson@example.org>
+a6: (Unknown) <unknownperson@example.org> (Person)
+a7: Unknown <unknownperson@example.org>, unknownperson@example.org
+!
+cat >>"$MH_TEST_DIR/.mmh/profile" <<!
+aliasfile: aliases
+!
+
+
+# override gpg with our own function for defined output
+
+echo '#!/bin/sh
+exit 1
+' >"$MH_TEST_DIR/bin/gpg"
+chmod +x "$MH_TEST_DIR/bin/gpg"
+export MMHPGPKEY=0x12345678
+
+
+# now test it
+
+draft=`mhpath +drafts b`
+cat >"$draft" <<!
+To: a1, a2, a3, a4, a5
+Cc: a6, a7
+Subject: mhsign -enc test
+--------
+secret
+!
+
+runandcheck "whom -noali $draft" <<!
+a1
+a2
+a3
+a4
+a5
+a6
+a7
+!
+
+runandcheck "whom -ali $draft" <<!
+unknownperson
+unknownperson@example.org
+Unknown Person <unknownperson>
+Unknown Person <unknownperson@example.org>
+"Unknown Person" <unknownperson@example.org>
+(Unknown) <unknownperson@example.org> (Person)
+Unknown <unknownperson@example.org>
+unknownperson@example.org
+!
+
+runandcheck "mhsign -enc $draft" <<!
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+!
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test refile
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+runandcheck "scan +inbox" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 4 2006-09-29 00:00 Test4 Testing message 4
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+
+
+# refile one msg from cur folder into one other folder
+
+folder +inbox >/dev/null
+runandcheck "refile 4 +fol1" <<!
+!
+runandcheck folder <<!
+inbox+ has 9 messages (1-10)
+!
+runandcheck "scan +inbox" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 6 2006-09-29 00:00 Test6 Testing message 6
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+runandcheck "scan +fol1" <<!
+ 1 2006-09-29 00:00 Test4 Testing message 4
+!
+
+
+# refile one msg from cur folder into two other folders
+
+folder +inbox >/dev/null
+runandcheck "refile 6 +fol1 +fol2" <<!
+!
+runandcheck folder <<!
+inbox+ has 8 messages (1-10)
+!
+runandcheck "scan +inbox" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 8 2006-09-29 00:00 Test8 Testing message 8
+ 9 2006-09-29 00:00 Test9 Testing message 9
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+runandcheck "scan +fol1" <<!
+ 1 2006-09-29 00:00 Test4 Testing message 4
+ 2 2006-09-29 00:00 Test6 Testing message 6
+!
+runandcheck "scan +fol2" <<!
+ 1 2006-09-29 00:00 Test6 Testing message 6
+!
+
+
+# refile two msg from cur folder into two other folders
+
+folder +inbox >/dev/null
+runandcheck "refile 8 9 +fol1 +fol2" <<!
+!
+runandcheck folder <<!
+inbox+ has 6 messages (1-10)
+!
+runandcheck "scan +inbox" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+runandcheck "scan +fol1" <<!
+ 1 2006-09-29 00:00 Test4 Testing message 4
+ 2 2006-09-29 00:00 Test6 Testing message 6
+ 3 2006-09-29 00:00 Test8 Testing message 8
+ 4 2006-09-29 00:00 Test9 Testing message 9
+!
+runandcheck "scan +fol2" <<!
+ 1 2006-09-29 00:00 Test6 Testing message 6
+ 2 2006-09-29 00:00 Test8 Testing message 8
+ 3 2006-09-29 00:00 Test9 Testing message 9
+!
+
+
+# refile one msg from other folder into one other folder
+
+folder +inbox >/dev/null
+runandcheck "refile -src +fol1 1 +fol2" <<!
+!
+# Check new behavior as of mmh-0.3: Current folder stays the same!
+runandcheck folder <<!
+inbox+ has 6 messages (1-10)
+!
+runandcheck "scan +inbox" <<!
+ 1 2006-09-29 00:00 Test1 Testing message 1
+ 2 2006-09-29 00:00 Test2 Testing message 2
+ 3 2006-09-29 00:00 Test3 Testing message 3
+ 5 2006-09-29 00:00 Test5 Testing message 5
+ 7 2006-09-29 00:00 Test7 Testing message 7
+ 10 2006-09-29 00:00 Test10 Testing message 10
+!
+runandcheck "scan +fol1" <<!
+ 2 2006-09-29 00:00 Test6 Testing message 6
+ 3 2006-09-29 00:00 Test8 Testing message 8
+ 4 2006-09-29 00:00 Test9 Testing message 9
+!
+runandcheck "scan +fol2" <<!
+ 1 2006-09-29 00:00 Test6 Testing message 6
+ 2 2006-09-29 00:00 Test8 Testing message 8
+ 3 2006-09-29 00:00 Test9 Testing message 9
+ 4 2006-09-29 00:00 Test4 Testing message 4
+!
+
+
+
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test that repl and repl -g decode recipient addrs
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# create message to reply to
+
+msgfile=`mhpath b +inbox`
+cat >"$msgfile" <<EOF
+From: =?UTF-8?Q?J=C3=BCrgen?= <juergen@example.net>
+To: bob@example.com
+Cc: =?UTF-8?Q?K=C3=A4the?= <kaethe@example.org>
+Subject: repl addr decode
+Date: Mon, 18 Apr 2016 08:36:14 +0200
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Message-ID: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+
+foo
+EOF
+
+
+# create the reply draft
+runandcheck 'repl -nocc all -whatnow true l +inbox' <<!
+!
+
+# check the draft
+runandcheck 'cat `mhpath +drafts l`' <<!
+To: Jürgen <juergen@example.net>
+Cc:
+Fcc: +sent
+Subject: Re: repl addr decode
+In-reply-to: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+References: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+Comments: In-reply-to Jürgen <juergen@example.net>
+ message dated "Mon, 18 Apr 2016 08:36:14 +0200."
+--------
+[2016-04-18 08:36] Jürgen <juergen@example.net>
+>
+> part text/plain 4
+> foo
+!
+
+
+
+# create the group reply draft
+runandcheck 'repl -group -nocc me -whatnow true l +inbox' <<!
+!
+
+# check the draft
+runandcheck 'cat `mhpath +drafts l`' <<!
+To: Jürgen <juergen@example.net>
+Cc: bob@example.com, Käthe <kaethe@example.org>
+Fcc: +sent
+Subject: Re: repl addr decode
+In-reply-to: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+References: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+Comments: In-reply-to Jürgen <juergen@example.net>
+ message dated "Mon, 18 Apr 2016 08:36:14 +0200."
+--------
+[2016-04-18 08:36] Jürgen <juergen@example.net>
+>
+> part text/plain 4
+> foo
+!
+
X-NOSTRING: 3x missing
X-NONUMBER: 3x no
--------
+> part text/plain 25
> This is message number 1
EOF
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test trailing space handling in format files
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+msgfile=`mhpath b +inbox`
+cat >"$msgfile" <<!
+Subject: =?UTF-8?Q?3_trailing_spaces___?=
+Mime-Version: 1.0
+From: Bob <bob@example.org>
+Date: Wed, 20 Apr 2016 07:38:12 +0200
+Message-Id: <83C58147-7B2B-4B7F-9502-17C1EB9526BC@example.org>
+To: Alice <alice@example.net>
+Content-Type: text/plain; charset=utf-8
+
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!
+
+
+# output has no trailing spaces
+runandcheck "scan -width 80 +inbox l" <<!
+ 11 2016-04-20 07:38 Bob 3 trailing spaces
+!
+
+
+
+runandcheck "show +inbox l" <<!
+Date: Wed, 20 Apr 2016 07:38:12 +0200
+From: Bob <bob@example.org>
+To: Alice <alice@example.net>
+Subject: 3 trailing spaces
+
+part text/plain 145
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!
chmod +x mmhwrap
mhsign: mhsign.sh
- cp $(srcdir)/mhsign.sh mhsign
+ sed "s,%libdir%,"$(libdir)"," $(srcdir)/mhsign.sh >mhsign
chmod +x mhsign
mhpgp: mhpgp.sh
if (deffiles && (cp = context_find("Aliasfile"))) {
char *dp = NULL;
- for (ap = brkstring(dp=getcpy(cp), " ", "\n");
+ for (ap = brkstring(dp=mh_xstrdup(cp), " ", "\n");
ap && *ap; ap++) {
if ((i = alias(etcpath(*ap))) != AK_OK) {
adios(EX_DATAERR, NULL, "aliasing error in %s: %s",
}
}
if (dp) {
- free(dp);
+ mh_free0(&dp);
}
}
if (!mh_strcasecmp(mp->m_host, np->m_host)
&& !mh_strcasecmp(mp->m_mbox, np->m_mbox)) {
vp = vp ? add(ak->ak_name, add(",", vp))
- : getcpy(ak->ak_name);
+ : mh_xstrdup(ak->ak_name);
mnfree(np);
while (getname(""))
continue;
print_aka(vp ? vp : s, list, 0);
if (vp)
- free(vp);
+ mh_free0(&vp);
}
for (ad = ak->ak_addr; ad; ad = ad->ad_next) {
pp = ad->ad_local ? akval(ak->ak_next, ad->ad_text)
- : getcpy(ad->ad_text);
+ : mh_xstrdup(ad->ad_text);
if (cp) {
dp = cp;
cp = concat(cp, ",", pp, NULL);
- free(dp);
- free(pp);
+ mh_free0(&dp);
+ mh_free0(&pp);
} else
cp = pp;
}
if (aleq(s, ak->ak_name))
return akresult(ak);
- return getcpy(s);
+ return mh_xstrdup(s);
}
if (strcmp(pp, ad->ad_text)==0)
return;
- ad = (struct adr *) mh_xmalloc(sizeof(*ad));
- ad->ad_text = getcpy(pp);
+ ad = mh_xcalloc(1, sizeof(*ad));
+ ad->ad_text = mh_xstrdup(pp);
ad->ad_local = strchr(pp, '@') == NULL;
ad->ad_next = NULL;
if (ak->ak_addr)
{
struct aka *p;
- p = (struct aka *) mh_xmalloc(sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
- p->ak_name = getcpy(id);
+ p->ak_name = mh_xstrdup(id);
p->ak_visible = 0;
p->ak_addr = NULL;
p->ak_next = NULL;
{
struct home *p;
- p = (struct home *) mh_xmalloc(sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
- p->h_name = getcpy(pw->pw_name);
+ p->h_name = mh_xstrdup(pw->pw_name);
p->h_uid = pw->pw_uid;
p->h_gid = pw->pw_gid;
- p->h_home = getcpy(pw->pw_dir);
- p->h_shell = getcpy(pw->pw_shell);
+ p->h_home = mh_xstrdup(pw->pw_dir);
+ p->h_shell = mh_xstrdup(pw->pw_shell);
p->h_ngrps = 0;
p->h_next = NULL;
/* append to end */
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else if (*cp == '/' || *cp == '.') {
if (file)
adios(EX_USAGE, NULL, "only one file at a time!");
}
/* We'll grow this buffer as needed. */
- field = (char *)mh_xmalloc(field_size = 256);
+ field = mh_xcalloc(field_size = 256, sizeof(char));
make_comp(&comp);
length = strlen(comp); /* Convenience copy. */
break;
}
if (++n >= field_size - 1) {
- field = (char *)mh_xrealloc(field,
- field_size += 256);
+ field = mh_xrealloc(field, field_size += 256);
cp = field + n - 1;
}
}
} while (*field && *field != '-');
- free(field);
+ mh_free0(&field);
fclose(fp);
return;
if ((fp = fdopen(fd, "r")) == NULL) {
adios(EX_IOERR, NULL, "unable to fdopen file.");
}
- field = (char *)mh_xmalloc(field_size);
+ field = mh_xcalloc(field_size, sizeof(char));
/*
** Copy lines from the input file to the temporary file
}
if (++n >= field_size - 1) {
- field = (char *) mh_xrealloc(field,
- field_size *= 2);
+ field = mh_xrealloc(field, field_size *= 2);
cp = field + n - 1;
}
}
} while (*field && *field != '-');
- free(field);
+ mh_free0(&field);
fflush(tmp);
fflush(fp); /* The underlying fd will be closed by lkclose() */
(q = &pq)->pq_next = NULL;
while ((cp = getname(arg))) {
- p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
- p->pq_text = getcpy(cp);
- p->pq_error = getcpy(error);
+ p->pq_text = mh_xstrdup(cp);
+ p->pq_error = mh_xstrdup(error);
status++;
} else {
- p->pq_text = getcpy(mp->m_text);
+ p->pq_text = mh_xstrdup(mp->m_text);
mnfree(mp);
}
q = (q->pq_next = p);
fmt_scan(fmt, buffer, BUFSIZ, dat);
fputs(buffer, stdout);
- free(p->pq_text);
+ mh_free0(&(p->pq_text));
if (p->pq_error)
- free(p->pq_error);
+ mh_free0(&(p->pq_error));
q = p->pq_next;
- free((char *) p);
+ mh_free0(&p);
}
return status;
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
exit(EX_SOFTWARE);
seq_setprev(mp); /* set the previous-sequence */
- smsgs = (struct smsg *)
- mh_xcalloc((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
+ smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof(*smsgs));
hi = mp->hghmsg + 1;
}
}
- free(smsgs);
+ mh_free0(&smsgs);
context_replace(curfolder, folder);
/*
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
if (msg) {
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
if (form && (folder || msg)) {
adios(EX_USAGE, NULL, "can't mix forms and folders/msgs");
if (mp->numsel > 1) {
adios(EX_USAGE, NULL, "only one message at a time!");
}
- if ((in = open(form = getcpy(m_name(mp->lowsel)),
+ if ((in = open(form = mh_xstrdup(m_name(mp->lowsel)),
O_RDONLY)) == NOTOK) {
adios(EX_IOERR, form, "unable to open message");
}
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
if (msg) {
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
strncpy(drft, m_draft(seq_beyond), sizeof(drft));
if ((out = creat(drft, m_gmprot())) == NOTOK) {
adios(EX_USAGE, NULL, "only one message at a time!");
}
- msgnam = getcpy(m_name(mp->lowsel));
+ msgnam = mh_xstrdup(m_name(mp->lowsel));
if ((in = open(msgnam, O_RDONLY)) == NOTOK) {
adios(EX_IOERR, msgnam, "unable to open message");
}
/* allocate the initial space to record the folder names */
numfolders = 0;
maxfolders = MAXFOLDERS;
- foldersToDo = (char **) mh_xmalloc((size_t)
- (maxfolders * sizeof(*foldersToDo)));
+ foldersToDo = mh_xcalloc(maxfolders, sizeof(*foldersToDo));
/* no sequences yet */
numsequences = 0;
*/
if (numfolders >= maxfolders) {
maxfolders += MAXFOLDERS;
- foldersToDo = (char **) mh_xrealloc(foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo)));
+ foldersToDo = mh_xrealloc(foldersToDo, maxfolders * sizeof(*foldersToDo));
}
if (*cp == '+' || *cp == '@') {
- foldersToDo[numfolders++] = getcpy(expandfol(cp));
+ foldersToDo[numfolders++] = mh_xstrdup(expandfol(cp));
} else
foldersToDo[numfolders++] = cp;
}
} else {
cp = seq_unseen; /* use default */
}
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
for (; ap && *ap; ap++) {
if (numsequences >= NUMATTRS) {
AllocFolders(&orders, &nOrdersAlloced, nOrders + 1);
o = &orders[nOrders++];
o->priority = priority++;
- o->name = (char *) mh_xmalloc(p - s + 1);
+ o->name = mh_xcalloc(p - s + 1, sizeof(char));
strncpy(o->name, s, p - s);
o->name[p - s] = 0;
} else
/* Oops, error occurred. Record it and continue. */
AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
f = &folders[nFolders++];
- f->name = getcpy(name);
+ f->name = mh_xstrdup(name);
f->error = 1;
f->priority = AssignPriority(f->name);
return 0;
/* save general folder information */
AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
f = &folders[nFolders++];
- f->name = getcpy(name);
+ f->name = mh_xstrdup(name);
f->nMsgs = mp->nummsg;
f->error = 0;
f->priority = AssignPriority(f->name);
return;
if (*f == NULL) {
*nfa = 10;
- *f = (struct Folder *) mh_xmalloc(
- *nfa * (sizeof(struct Folder)));
+ *f = mh_xcalloc(*nfa, sizeof(struct Folder));
} else {
*nfa *= 2;
- *f = (struct Folder *) mh_xrealloc(
- *f, *nfa * (sizeof(struct Folder)));
+ *f = mh_xrealloc(*f, *nfa * sizeof(struct Folder));
}
}
form = cp;
}
- /*
- ** Get new format string. Must be before chdir().
- */
- fmtstr = new_fs(form, FORMAT);
+ /* Set format string. Must be before chdir(). */
+ fmtstr = new_fs(form, scanformat);
fmt_compile(fmtstr, &fmt);
fmt_dump(fmt);
if (argfolder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- argfolder = getcpy(expandfol(cp));
+ argfolder = mh_xstrdup(expandfol(cp));
} else {
if (msg)
adios(EX_USAGE, NULL, "only one (current) message at a time!");
/* If no folder is given, the current folder and */
/* the top of the folder stack are swapped. */
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
- argfolder = getcpy(*ap++);
+ argfolder = mh_xstrdup(*ap++);
} else {
adios(EX_USAGE, NULL, "no other folder");
}
- for (cp = getcpy(getcurfol()); *ap; ap++)
+ for (cp = mh_xstrdup(getcurfol()); *ap; ap++)
cp = add(*ap, add(" ", cp));
- free(dp);
+ mh_free0(&dp);
context_replace(stack, cp); /* update folder stack */
} else {
/* update folder stack */
context_replace(stack, (cp = context_find (stack)) ?
concat(getcurfol(), " ", cp, NULL) :
- getcpy(getcurfol()));
+ mh_xstrdup(getcurfol()));
}
}
if (argfolder)
adios(EX_USAGE, NULL, "sorry, no folders allowed with -pop");
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
- argfolder = getcpy(*ap++);
+ argfolder = mh_xstrdup(*ap++);
} else {
adios(EX_DATAERR, NULL, "folder stack empty");
}
if (*ap) {
/* if there's anything left in the stack */
- cp = getcpy(*ap++);
+ cp = mh_xstrdup(*ap++);
for (; *ap; ap++)
cp = add(*ap, add(" ", cp));
context_replace(stack, cp); /* update folder stack */
/* delete folder stack entry from context */
context_del(stack);
}
- free(dp);
+ mh_free0(&dp);
}
if (pushsw || popsw) {
cp = toabsdir(argfolder);
if (listsw) {
printf("%s", argfolder ? argfolder : getcurfol());
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
printf(" %s", *ap);
- free(dp);
+ mh_free0(&dp);
}
printf("\n");
/* Allocate initial space to record folder information */
maxFolderInfo = CRAWL_NUMFOLDERS;
- fi = mh_xmalloc(maxFolderInfo * sizeof(*fi));
+ fi = mh_xcalloc(maxFolderInfo, sizeof(*fi));
/*
** Scan the folders
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
strncpy(drft, buildsw ? toabsdir("draft") : m_draft(seq_beyond),
sizeof(drft));
/*
if (digest) {
snprintf(buf, sizeof(buf), IFORMAT, digest);
snprintf(value, sizeof(value), "%d", issue);
- context_replace(buf, getcpy(value));
+ context_replace(buf, mh_xstrdup(value));
snprintf(buf, sizeof(buf), VFORMAT, digest);
snprintf(value, sizeof(value), "%d", volume);
- context_replace(buf, getcpy(value));
+ context_replace(buf, mh_xstrdup(value));
}
context_replace(curfolder, folder); /* update current folder */
cptr->c_text = digest;
FINDCOMP(cptr, "date");
if (cptr)
- cptr->c_text = getcpy(dtimenow());
+ cptr->c_text = mh_xstrdup(dtimenow());
dat[0] = issue;
dat[1] = volume;
if ((in = dup(fileno(tmp))) == NOTOK)
adios(EX_OSERR, "dup", "unable to");
- line = mh_xmalloc((unsigned) fmtsize);
+ line = mh_xcalloc(fmtsize, sizeof(char));
fmt_scan(fmt, line, fmtsize, dat);
fputs(line, tmp);
- free(line);
+ mh_free0(&line);
if (fclose(tmp))
adios(EX_IOERR, tmpfil, "error writing");
case AUDSW:
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]);
- audfile = getcpy(expanddir(cp));
+ audfile = mh_xstrdup(expanddir(cp));
continue;
case NAUDSW:
audfile = NULL;
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- from = getcpy(expanddir(cp));
+ from = mh_xstrdup(expanddir(cp));
/*
** If the truncate file is in default state,
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
dtimenow(), from);
}
- /* Get new format string */
- fmtstr = new_fs(form, FORMAT);
+ /* Set format string */
+ fmtstr = new_fs(form, scanformat);
if (noisy) {
printf("Incorporating new mail into %s...\n\n", folder);
break;
}
giveup:;
- free(maildir_copy);
+ mh_free0(&maildir_copy);
if (incerr < 0) { /* error */
if (locked) {
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
/* Check if we have a file to process */
if (!compfile)
/*
** Allocate space for primary (outside) content
*/
- ct = (CT) mh_xcalloc(1, sizeof(*ct));
+ ct = mh_xcalloc(1, sizeof(*ct));
/*
** Allocate structure for handling decoded content
}
/* add the header data to the list */
- add_header(ct, getcpy(f.name), getcpy(f.value));
+ add_header(ct, mh_xstrdup(f.name), mh_xstrdup(f.value));
continue;
** Now add the MIME-Version header field
** to the list of header fields.
*/
- np = getcpy(VRSN_FIELD);
+ np = mh_xstrdup(VRSN_FIELD);
vp = concat(" ", VRSN_VALUE, "\n", NULL);
add_header(ct, np, vp);
}
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_MIXED;
- ct->c_file = getcpy(infile);
+ ct->c_file = mh_xstrdup(infile);
m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
if (!p)
continue;
- part = (struct part *) mh_xcalloc(1, sizeof(*part));
+ part = mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
{
CE ce;
- ce = (CE) mh_xcalloc(1, sizeof(*ce));
+ ce = mh_xcalloc(1, sizeof(*ce));
ct->c_cefile = ce;
ct->c_ceopenfnx = open7Bit; /* since unencoded */
}
/* allocate basic Content structure */
- ct = (CT) mh_xcalloc(1, sizeof(*ct));
+ ct = mh_xcalloc(1, sizeof(*ct));
*ctp = ct;
/* allocate basic structure for handling decoded content */
adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
/* use a temp file to collect the plain text lines */
- ce->ce_file = getcpy(cp);
+ ce->ce_file = mh_xstrdup(cp);
ce->ce_unlink = 1;
if (buf[0] == '#' && buf[1] == '<') {
continue;
if (!*cp)
adios(EX_DATAERR, NULL, "empty pipe command for #%s directive", ci->ci_type);
- cp = getcpy(cp);
- free(ci->ci_magic);
+ cp = mh_xstrdup(cp);
+ mh_free0(&(ci->ci_magic));
ci->ci_magic = cp;
} else {
/* record filename of decoded contents */
exit(EX_CONFIG);
}
}
- ci->ci_magic = getcpy(cp);
+ ci->ci_magic = mh_xstrdup(cp);
return OK;
}
if (folder)
adios(EX_USAGE, NULL, "only one folder per #forw directive");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
}
/* else, use the current folder */
if (!folder)
- folder = getcpy(getcurfol());
+ folder = mh_xstrdup(getcurfol());
if (!(mp = folder_read(folder)))
adios(EX_IOERR, NULL, "unable to read folder %s", folder);
if (!m_convert(mp, cp))
exit(EX_USAGE);
}
- free(folder);
+ mh_free0(&folder);
free_ctinfo(ct);
/*
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_DIGEST;
- m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+ m = mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
CT p;
CE pe;
- p = (CT) mh_xcalloc(1, sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
init_decoded_content(p);
pe = p->c_cefile;
if (get_ctinfo("message/rfc822", p, 0)
snprintf(buffer, sizeof(buffer),
"%s/%d", mp->foldpath,
msgnum);
- pe->ce_file = getcpy(buffer);
+ pe->ce_file = mh_xstrdup(buffer);
- part = (struct part *) mh_xcalloc(1, sizeof(*part));
+ part = mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
msgnum = mp->lowsel;
snprintf(buffer, sizeof(buffer), "%s/%d",
mp->foldpath, msgnum);
- ce->ce_file = getcpy(buffer);
+ ce->ce_file = mh_xstrdup(buffer);
}
folder_free(mp); /* free folder/message structure */
ct->c_type = CT_MULTIPART;
ct->c_subtype = vrsn;
- m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+ m = mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
if (!p)
continue;
- part = (struct part *) mh_xcalloc(1, sizeof(*part));
+ part = mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
snprintf(msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
(int) getpid(), (long) clock, LocalName());
partno = 0;
- msgfmt = getcpy(msgid);
+ msgfmt = mh_xstrdup(msgid);
}
snprintf(msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
- ct->c_id = getcpy(msgid);
+ ct->c_id = mh_xstrdup(msgid);
}
CT p = part->mp_part;
sprintf(pp, "%d", partnum);
- p->c_partno = getcpy(partnam);
+ p->c_partno = mh_xstrdup(partnam);
if (compose_content(p) == NOTOK)
return NOTOK;
}
if (tfile == NULL) {
adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
}
- ce->ce_file = getcpy(tfile);
+ ce->ce_file = mh_xstrdup(tfile);
ce->ce_unlink = 1;
xstdout = 0;
NULL);
} else {
t->tx_charset = CHARSET_USASCII;
- *ap = getcpy("charset=us-ascii");
+ *ap = mh_xstrdup("charset=us-ascii");
}
cp = strchr(*ap++, '=');
ep = ci->ci_values;
snprintf(buffer, sizeof(buffer), "boundary=%s%d",
prefix, level++);
- cp = strchr(*ap++ = getcpy(buffer), '=');
+ cp = strchr(*ap++ = mh_xstrdup(buffer), '=');
*ap = NULL;
*cp++ = '\0';
*ep = cp;
/*
** output the content type and subtype
*/
- np = getcpy(TYPE_FIELD);
+ np = mh_xstrdup(TYPE_FIELD);
vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
/* keep track of length of line */
** output the Content-ID
*/
if (ct->c_id) {
- np = getcpy(ID_FIELD);
+ np = mh_xstrdup(ID_FIELD);
vp = concat(" ", ct->c_id, NULL);
add_header(ct, np, vp);
}
** output the Content-Description
*/
if (ct->c_descr) {
- np = getcpy(DESCR_FIELD);
+ np = mh_xstrdup(DESCR_FIELD);
vp = concat(" ", ct->c_descr, NULL);
if (encode_rfc2047(DESCR_FIELD, &vp, NULL)) {
adios(EX_DATAERR, NULL, "Unable to encode %s header", DESCR_FIELD);
** output the Content-Disposition
*/
if (ct->c_dispo) {
- np = getcpy(DISPO_FIELD);
+ np = mh_xstrdup(DISPO_FIELD);
vp = concat(" ", ct->c_dispo, NULL);
add_header(ct, np, vp);
}
if (ct->c_type == CT_MESSAGE)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "8bit", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "quoted-printable", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "base64", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "binary", "\n", NULL);
add_header(ct, np, vp);
break;
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <errno.h>
#include <h/mime.h>
#include <h/mhparse.h>
free_header(ct);
if (ct->c_partno)
- free(ct->c_partno);
+ mh_free0(&(ct->c_partno));
if (ct->c_vrsn)
- free(ct->c_vrsn);
+ mh_free0(&(ct->c_vrsn));
if (ct->c_ctline)
- free(ct->c_ctline);
+ mh_free0(&(ct->c_ctline));
free_ctinfo(ct);
}
if (ct->c_charset)
- free(ct->c_charset);
+ mh_free0(&(ct->c_charset));
if (ct->c_showproc)
- free(ct->c_showproc);
+ mh_free0(&(ct->c_showproc));
if (ct->c_storeproc)
- free(ct->c_storeproc);
+ mh_free0(&(ct->c_storeproc));
if (ct->c_celine)
- free(ct->c_celine);
+ mh_free0(&(ct->c_celine));
/* free structures for content encodings */
free_encoding(ct, 1);
if (ct->c_id)
- free(ct->c_id);
+ mh_free0(&(ct->c_id));
if (ct->c_descr)
- free(ct->c_descr);
+ mh_free0(&(ct->c_descr));
if (ct->c_dispo)
- free(ct->c_dispo);
+ mh_free0(&(ct->c_dispo));
if (ct->c_file) {
if (ct->c_unlink)
unlink(ct->c_file);
- free(ct->c_file);
+ mh_free0(&(ct->c_file));
}
if (ct->c_fp)
fclose(ct->c_fp);
if (ct->c_storage)
- free(ct->c_storage);
+ mh_free0(&(ct->c_storage));
if (ct->c_folder)
- free(ct->c_folder);
+ mh_free0(&(ct->c_folder));
- free(ct);
+ mh_free0(&ct);
}
while (hp1) {
hp2 = hp1->next;
- free(hp1->name);
- free(hp1->value);
- free(hp1);
+ mh_free0(&(hp1->name));
+ mh_free0(&(hp1->value));
+ mh_free0(&hp1);
hp1 = hp2;
}
ci = &ct->c_ctinfo;
if (ci->ci_type) {
- free(ci->ci_type);
- ci->ci_type = NULL;
+ mh_free0(&(ci->ci_type));
}
if (ci->ci_subtype) {
- free(ci->ci_subtype);
- ci->ci_subtype = NULL;
+ mh_free0(&(ci->ci_subtype));
}
for (ap = ci->ci_attrs; *ap; ap++) {
- free(*ap);
- *ap = NULL;
+ mh_free0(ap);
}
if (ci->ci_comment) {
- free(ci->ci_comment);
- ci->ci_comment = NULL;
+ mh_free0(&(ci->ci_comment));
}
if (ci->ci_magic) {
- free(ci->ci_magic);
- ci->ci_magic = NULL;
+ mh_free0(&(ci->ci_magic));
}
}
if (!(t = (struct text *) ct->c_ctparams))
return;
- free((char *) t);
- ct->c_ctparams = NULL;
+ mh_free0(&t);
}
return;
if (m->mp_start)
- free(m->mp_start);
+ mh_free0(&(m->mp_start));
if (m->mp_stop)
- free(m->mp_stop);
+ mh_free0(&(m->mp_stop));
for (part = m->mp_parts; part; part = next) {
next = part->mp_next;
free_content(part->mp_part);
- free((char *) part);
+ mh_free0(&part);
}
- m->mp_parts = NULL;
- free((char *) m);
- ct->c_ctparams = NULL;
+ mh_free0(&m);
}
return;
if (p->pm_partid)
- free(p->pm_partid);
+ mh_free0(&(p->pm_partid));
- free((char *) p);
- ct->c_ctparams = NULL;
+ mh_free0(&p);
}
if (ce->ce_file) {
if (ce->ce_unlink)
unlink(ce->ce_file);
- free(ce->ce_file);
- ce->ce_file = NULL;
+ mh_free0(&(ce->ce_file));
}
if (toplevel) {
- free((char *) ce);
- ct->c_cefile = NULL;
+ mh_free0(&ce);
} else {
ct->c_ceopenfnx = NULL;
}
int n = 0;
/* split the fields */
- tmparray = brkstring(getcpy(++parptr), ",",
+ tmparray = brkstring(mh_xstrdup(++parptr), ",",
NULL);
/*
** copy pointers to split fields
if (!c1->c_fstr && global.c_fstr) {
if ((c1->c_flags & DATEFMT) &&
(global.c_flags & DATEFMT)) {
- c1->c_fstr = getcpy(global.c_fstr);
+ c1->c_fstr = mh_xstrdup(global.c_fstr);
} else if ((c1->c_flags & ADDRFMT) &&
(global.c_flags & ADDRFMT)) {
- c1->c_fstr = getcpy(global.c_fstr);
+ c1->c_fstr = mh_xstrdup(global.c_fstr);
}
}
continue;
return 1;
cp = concat("=", cp, NULL);
fmtstr = new_fs(cp, NULL);
- free(cp);
- c1->c_fstr = getcpy(fmtstr);
+ mh_free0(&cp);
+ c1->c_fstr = mh_xstrdup(fmtstr);
c1->c_flags |= FORMAT;
return 0;
}
char *fmtstr;
fmtstr = new_fs("=%(decode{text})", NULL);
- c1->c_fstr = getcpy(fmtstr);
+ c1->c_fstr = mh_xstrdup(fmtstr);
c1->c_flags |= FORMAT;
return 0;
}
}
c = *parptr;
*parptr = 0;
- *s = getcpy(cp);
+ *s = mh_xstrdup(cp);
if ((*parptr = c) == '"')
parptr++;
return 0;
if (fp != stdin)
fclose(fp);
if (holder.c_text) {
- free(holder.c_text);
- holder.c_text = NULL;
+ mh_free0(&(holder.c_text));
}
free_queue(&msghd, &msgtl);
for (c1 = fmthd; c1; c1 = c1->c_next)
holder.c_text = concat("(Message ",
mname, ")\n", NULL);
putcomp(c1, &holder, ONECOMP);
- free(holder.c_text);
- holder.c_text = NULL;
+ mh_free0(&(holder.c_text));
continue;
}
if (mh_strcasecmp(c1->c_name, "extras")==0) {
continue;
}
if (dobody && mh_strcasecmp(c1->c_name, "body")==0) {
- holder.c_text = getcpy(f.value);
+ holder.c_text = mh_xstrdup(f.value);
while (state == BODY2) {
putcomp(c1, &holder, BODYCOMP);
state = m_getfld2(state, &f, fp);
free(holder.c_text);
- holder.c_text = getcpy(f.value);
+ holder.c_text = mh_xstrdup(f.value);
}
- free(holder.c_text);
- holder.c_text = NULL;
+ mh_free0(&(holder.c_text));
continue;
}
for (c2 = msghd; c2; c2 = c2->c_next) {
fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
/* Don't need to append a newline, dctime() already did */
- c2->c_text = getcpy(buffer);
+ c2->c_text = mh_xstrdup(buffer);
- free(ap);
+ mh_free0(&ap);
return;
}
(q = &pq)->pq_next = NULL;
while ((cp = getname(ap))) {
- p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
- p->pq_text = getcpy(cp);
- p->pq_error = getcpy(error);
+ p->pq_text = mh_xstrdup(cp);
+ p->pq_error = mh_xstrdup(error);
} else {
- p->pq_text = getcpy(mp->m_text);
+ p->pq_text = mh_xstrdup(mp->m_text);
mnfree(mp);
}
q = (q->pq_next = p);
c2->c_text = add(buffer, c2->c_text);
}
- free(p->pq_text);
+ mh_free0(&(p->pq_text));
if (p->pq_error)
- free(p->pq_error);
+ mh_free0(&(p->pq_error));
q = p->pq_next;
- free((char *) p);
+ mh_free0(&p);
}
c2->c_text = add("\n", c2->c_text);
{
struct mcomp *c1;
- c1 = (struct mcomp *) mh_xcalloc((size_t) 1, sizeof(*c1));
+ c1 = mh_xcalloc(1, sizeof(*c1));
c1->c_flags = flags & ~INIT;
- if ((c1->c_name = name ? getcpy(name) : NULL))
+ if ((c1->c_name = name ? mh_xstrdup(name) : NULL))
c1->c_flags |= mcomp_flags(c1->c_name);
- c1->c_text = text ? getcpy(text) : NULL;
+ c1->c_text = text ? mh_xstrdup(text) : NULL;
if (flags & INIT) {
if (global.c_ovtxt)
- c1->c_ovtxt = getcpy(global.c_ovtxt);
+ c1->c_ovtxt = mh_xstrdup(global.c_ovtxt);
c1->c_offset = global.c_offset;
c1->c_ovoff = global. c_ovoff;
c1->c_width = 0;
for (c1 = *head; c1; c1 = c2) {
c2 = c1->c_next;
if (c1->c_name)
- free(c1->c_name);
+ mh_free0(&(c1->c_name));
if (c1->c_text)
- free(c1->c_text);
+ mh_free0(&(c1->c_text));
if (c1->c_ovtxt)
- free(c1->c_ovtxt);
+ mh_free0(&(c1->c_ovtxt));
if (c1->c_fstr)
- free(c1->c_fstr);
+ mh_free0(&(c1->c_fstr));
if (c1->c_fmt)
- free((char *) c1->c_fmt);
- free((char *) c1);
+ mh_free0(&(c1->c_fmt));
+ mh_free0(&c1);
}
*head = *tail = NULL;
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** check if message is coming from file
*/
if (file) {
- cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+ cts = mh_xcalloc(2, sizeof(*cts));
ctp = cts;
if ((ct = parse_mime(file)))
}
seq_setprev(mp); /* set the previous-sequence */
- cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
- sizeof(*cts));
+ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
for (ctp = cts; *ctp; ctp++)
free_content(*ctp);
- free((char *) cts);
- cts = NULL;
+ mh_free0(&cts);
/* If reading from a folder, do some updating */
if (mp) {
/* print Content-Description */
if (ct->c_descr) {
char *dp;
-
- dp = trimcpy(cp = getcpy(ct->c_descr));
- free(cp);
+ dp = trimcpy(cp = mh_xstrdup(ct->c_descr));
+ mh_free0(&cp);
printf(LSTFMT2d1, dp);
- free(dp);
+ mh_free0(&dp);
}
printf("\n");
dp = trimcpy(cp = add(ci->ci_comment, NULL));
free (cp);
snprintf(buffer, sizeof(buffer), "(%s)", dp);
- free(dp);
+ mh_free0(&dp);
printf(LSTFMT2d2, buffer);
}
}
}
if (iscc)
cclist = cclist ? add(cp, add(", ", cclist)) :
- getcpy(cp);
+ mh_xstrdup(cp);
else
tolist = tolist ? add(cp, add(", ", tolist)) :
- getcpy(cp);
+ mh_xstrdup(cp);
}
if (tolist == NULL)
ep = concat("Create directory \"", file, "\"? ", NULL);
answer = getanswer(ep);
- free(ep);
+ mh_free0(&ep);
if (!answer)
goto losing_directory;
if (errs) {
fflush(stdout);
fprintf(stderr, "%s", errs);
- free(errs);
- errs = NULL;
+ mh_free0(&errs);
}
}
{ "replgroupcomps", &replgroupcomps },
{ "mhlformat", &mhlformat },
{ "mhlreply", &mhlreply },
+ { "scanformat", &scanformat },
{ "#--Default-Sequence-Names--", &empty },
{ "seq-all", &seq_all },
advise("mhparse", "unable to create temporary file");
return NULL;
}
- file = getcpy(tfile);
+ file = mh_xstrdup(tfile);
chmod(file, 0600);
while (fgets(buffer, sizeof(buffer), stdin))
HF hp;
/* allocate the content structure */
- ct = (CT) mh_xcalloc(1, sizeof(*ct));
+ ct = mh_xcalloc(1, sizeof(*ct));
ct->c_fp = in;
- ct->c_file = getcpy(file);
+ ct->c_file = mh_xstrdup(file);
ct->c_begin = ftell(ct->c_fp) + 1;
/*
compnum++;
/* add the header data to the list */
- add_header(ct, getcpy(f.name), getcpy(f.value));
+ add_header(ct, mh_xstrdup(f.name), mh_xstrdup(f.value));
ct->c_begin = ftell(in) + 1;
continue;
advise(NULL, "message %s has multiple %s: fields", ct->c_file, VRSN_FIELD);
goto next_header;
}
- ct->c_vrsn = getcpy(hp->value);
+ ct->c_vrsn = mh_xstrdup(hp->value);
/* Now, cleanup this field */
cp = ct->c_vrsn;
}
/* get copy of this field */
- ct->c_celine = cp = getcpy(hp->value);
+ ct->c_celine = cp = mh_xstrdup(hp->value);
while (isspace(*cp))
cp++;
HF hp;
/* allocate header field structure */
- hp = mh_xmalloc(sizeof(*hp));
+ hp = mh_xcalloc(1, sizeof(*hp));
/* link data into header structure */
hp->name = name;
** Insert at first semicolon, if any.
** If none, append to end.
*/
- prefix = getcpy(buf);
+ prefix = mh_xstrdup(buf);
if ((cp = strchr(prefix, ';'))) {
suffix = concat(cp, NULL);
*cp = '\0';
newbuf = concat(prefix, insertion, suffix,
"\n", NULL);
- free(suffix);
+ mh_free0(&suffix);
} else {
/* Append to end. */
newbuf = concat(buf, insertion, "\n", NULL);
}
- free(prefix);
- free(insertion);
- free(buf);
+ mh_free0(&prefix);
+ mh_free0(&insertion);
+ mh_free0(&buf);
}
- free(name_plus_equal);
+ mh_free0(&name_plus_equal);
}
return newbuf;
char *name_suffix_equals = strstr(value, name_suffix_plus_quote);
char *cp;
- free(name_suffix_plus_quote);
+ mh_free0(&name_suffix_plus_quote);
if (name_suffix_equals) {
char *name_suffix_begin;
for (; *cp != '"'; ++cp)
;
- extracted_name_value = mh_xmalloc(cp - name_suffix_begin + 1);
+ extracted_name_value = mh_xcalloc(cp - name_suffix_begin + 1, sizeof(char));
memcpy(extracted_name_value, name_suffix_begin,
cp - name_suffix_begin);
extracted_name_value[cp - name_suffix_begin] = '\0';
i = strlen(invo_name) + 2;
/* store copy of Content-Type line */
- cp = ct->c_ctline = getcpy(cp);
+ cp = ct->c_ctline = mh_xstrdup(cp);
while (isspace(*cp)) /* trim leading spaces */
cp++;
for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_type = getcpy(cp); /* store content type */
+ ci->ci_type = mh_xstrdup(cp); /* store content type */
*dp = c, cp = dp;
if (!*ci->ci_type) {
if (*cp != '/') {
if (!magic)
- ci->ci_subtype = getcpy("");
+ ci->ci_subtype = mh_xstrdup("");
goto magic_skip;
}
for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_subtype = getcpy(cp); /* store the content subtype */
+ ci->ci_subtype = mh_xstrdup(cp); /* store the content subtype */
*dp = c, cp = dp;
if (!*ci->ci_subtype) {
return NOTOK;
}
- vp = (*ap = getcpy(cp)) + (up - cp);
+ vp = (*ap = mh_xstrdup(cp)) + (up - cp);
*vp = '\0';
for (dp++; isspace(*dp);)
dp++;
*/
if (magic && *cp == '<') {
if (ct->c_id) {
- free(ct->c_id);
- ct->c_id = NULL;
+ mh_free0(&(ct->c_id));
}
if (!(dp = strchr(ct->c_id = ++cp, '>'))) {
advise(NULL, "invalid ID in message %s", ct->c_file);
*/
if (*cp) {
if (magic) {
- ci->ci_magic = getcpy(cp);
+ ci->ci_magic = mh_xstrdup(cp);
/*
** If there is a Content-Disposition header and
if (istype) {
if ((dp = ci->ci_comment)) {
ci->ci_comment = concat(dp, " ", buffer, NULL);
- free(dp);
+ mh_free0(&dp);
} else {
- ci->ci_comment = getcpy(buffer);
+ ci->ci_comment = mh_xstrdup(buffer);
}
}
ct->c_subtype = kv->kv_value;
/* allocate text character set structure */
- t = (struct text *) mh_xcalloc(1, sizeof(*t));
+ t = mh_xcalloc(1, sizeof(*t));
ct->c_ctparams = (void *) t;
/* scan for charset parameter */
/* check if content specified a character set */
if (*ap) {
/* store its name */
- ct->c_charset = getcpy(norm_charmap(*ep));
+ ct->c_charset = mh_xstrdup(norm_charmap(*ep));
/* match character set or set to CHARSET_UNKNOWN */
for (kv = Charset; kv->kv_key; kv++) {
if (!mh_strcasecmp(*ep, kv->kv_key)) {
}
/* allocate primary structure for multipart info */
- m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+ m = mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
/* check if boundary parameter contains only whitespace characters */
if (strcmp(buffer + 2, m->mp_start)!=0)
continue;
next_part:
- part = (struct part *) mh_xcalloc(1, sizeof(*part));
+ part = mh_xcalloc(1, sizeof(*part));
*next = part;
next = &part->mp_next;
continue;
*next = NULL;
free_content(p);
- free((char *) part);
+ mh_free0(&part);
}
}
p = part->mp_part;
sprintf(pp, "%d", partnum);
- p->c_partno = getcpy(partnam);
+ p->c_partno = mh_xstrdup(partnam);
/* initialize the content of the subparts */
if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) {
i++;
/* allocate array of pointers to the parts */
- base = (struct part **) mh_xcalloc((size_t) (i + 1), sizeof(*base));
+ base = mh_xcalloc(i + 1, sizeof(*base));
bmp = base;
/* point at all the parts */
*next = NULL;
/* free array of pointers */
- free((char *) base);
+ mh_free0(&base);
}
char **ap, **ep;
struct partial *p;
- p = (struct partial *) mh_xcalloc(1, sizeof(*p));
+ p = mh_xcalloc(1, sizeof(*p));
ct->c_ctparams = (void *) p;
/*
*/
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!mh_strcasecmp(*ap, "id")) {
- p->pm_partid = getcpy(*ep);
+ p->pm_partid = mh_xstrdup(*ep);
continue;
}
if (!mh_strcasecmp(*ap, "number")) {
{
CE ce;
- ce = (CE) mh_xcalloc(1, sizeof(*ce));
+ ce = mh_xcalloc(1, sizeof(*ce));
ct->c_cefile = ce;
ct->c_ceopenfnx = openfnx;
}
if (*file == NULL) {
- ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+ ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = getcpy(*file);
+ ce->ce_file = mh_xstrdup(*file);
ce->ce_unlink = 0;
}
** Temporary file already exists, so we rename to
** version with extension.
*/
- char *file_org = strdup(ce->ce_file);
+ char *file_org = mh_xstrdup(ce->ce_file);
ce->ce_file = add(cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
file_org);
}
- free(file_org);
+ mh_free0(&file_org);
} else {
ce->ce_file = add(cp, ce->ce_file);
}
if (*file == NULL) {
- ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+ ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = getcpy(*file);
+ ce->ce_file = mh_xstrdup(*file);
ce->ce_unlink = 0;
}
** Temporary file already exists, so we rename to
** version with extension.
*/
- char *file_org = strdup(ce->ce_file);
+ char *file_org = mh_xstrdup(ce->ce_file);
ce->ce_file = add(cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
file_org);
}
- free(file_org);
+ mh_free0(&file_org);
} else {
ce->ce_file = add(cp, ce->ce_file);
}
if (*file == NULL) {
- ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+ ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = getcpy(*file);
+ ce->ce_file = mh_xstrdup(*file);
ce->ce_unlink = 0;
}
** Temporary file already exists, so we rename to
** version with extension.
*/
- char *file_org = strdup(ce->ce_file);
+ char *file_org = mh_xstrdup(ce->ce_file);
ce->ce_file = add(cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
file_org);
}
- free(file_org);
+ mh_free0(&file_org);
} else {
ce->ce_file = add(cp, ce->ce_file);
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case FORMSW:
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
if (formsw)
- free(formsw);
- formsw = getcpy(etcpath(cp));
+ mh_free0(&formsw);
+ formsw = mh_xstrdup(etcpath(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else if (mode != SHOW) {
adios(EX_USAGE, NULL, "Either call show as `%s' or give message arguments", invo_name);
} else {
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** check if message is coming from file
*/
if (file) {
- cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+ cts = mh_xcalloc(2, sizeof(*cts));
ctp = cts;
if ((ct = parse_mime(file)))
seq_setprev(mp); /* set the Previous-Sequence */
seq_setunseen(mp, 0); /* unset unseen seqs for shown msgs */
- cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
- sizeof(*cts));
+ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
ctp = cts;
/*
for (ctp = cts; *ctp; ctp++)
free_content(*ctp);
- free((char *) cts);
- cts = NULL;
+ mh_free0(&cts);
/* If reading from a folder, do some updating */
if (mp) {
** for showing headers of MIME messages.
*/
if (!formsw)
- formsw = getcpy(etcpath("mhl.headers"));
+ formsw = mh_xstrdup(etcpath("mhl.headers"));
/*
** If form is "mhl.null", suppress display of header.
s = trimcpy(ct->c_descr);
strncpy(bp, s, buflen);
- free(s);
+ mh_free0(&s);
}
break;
} else {
snprintf(buffer, sizeof(buffer), "%%lcat");
}
- ct->c_showproc = getcpy(buffer);
+ ct->c_showproc = mh_xstrdup(buffer);
return show_content_aux(ct, alternate, ct->c_showproc, NULL);
}
return NOTOK;
/* I'm not sure if this is necessary? */
- p->c_storage = getcpy(file);
+ p->c_storage = mh_xstrdup(file);
if (p->c_showproc && strcmp(p->c_showproc, "true")==0)
return (alternate ? DONE : OK);
s = trimcpy(ct->c_descr);
strncpy(bp, s, buflen);
- free(s);
+ mh_free0(&s);
}
break;
/* default method for message/rfc822 */
if (ct->c_subtype == MESSAGE_RFC822) {
- cp = (ct->c_showproc = getcpy("%lshow -file %F"));
+ cp = (ct->c_showproc = mh_xstrdup("%lshow -file %F"));
return show_content_aux(ct, alternate, cp, NULL);
}
echo "Encryption is not supported for BCCs" >&2
return 1
fi
-
- for i in `whom -ali -tocc -nobcc "$1"` ; do
+
+ whom -ali -tocc -nobcc "$1" | while read i ; do
case "$i" in
'|'*) echo "Ignoring pipe address" >&2
continue ;;
*@*) ;;
- *) i="$i@`hostname -f`" ;;
+ *) a="$i@`hostname -f`" ;;
esac
+ # extract the actual address
+ format='%<{error}%{error}: %{text}%|%(addr{text})%>'
+ i=`%libdir%/ap -form "=$format" "$i"`
if k=`lookupkeyfile "$i"` ; then
KL="$KL $k"
elif k=`lookupkeyring "$i"` ; then
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case DEBUGSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/*
** Cache the current directory before we do any chdirs()'s.
*/
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
/*
** Check for storage directory. If specified,
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** check if message is coming from file
*/
if (file) {
- cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+ cts = mh_xcalloc(2, sizeof(*cts));
ctp = cts;
if ((ct = parse_mime(file)))
exit(EX_USAGE);
seq_setprev(mp); /* set the previous-sequence */
- cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
- sizeof(*cts));
+ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
for (ctp = cts; *ctp; ctp++)
free_content(*ctp);
- free((char *) cts);
- cts = NULL;
+ mh_free0(&cts);
/* If reading from a folder, do some updating */
if (mp) {
** store any contents.
*/
if ((cp = context_find(nmhstorage)) && *cp)
- dir = getcpy(cp);
+ dir = mh_xstrdup(cp);
else
- dir = getcpy(cwd);
+ dir = mh_xstrdup(cwd);
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
!strchr(cp, '%')) {
/* filename looks good: use it */
- ct->c_storeproc = getcpy(cp);
+ ct->c_storeproc = mh_xstrdup(cp);
}
break;
}
return NOTOK;
}
- base = (CT *) mh_xcalloc((size_t) (i + 1), sizeof(*base));
+ base = mh_xcalloc(i + 1, sizeof(*base));
ctq = base;
for (ctp = cts; *ctp; ctp++) {
ct = *ctq++;
if (store_content(ct, NULL) == NOTOK) {
losing:
- free((char *) base);
+ mh_free0(&base);
return NOTOK;
}
goto losing;
}
- free((char *) base);
+ mh_free0(&base);
return OK;
}
*/
if (p) {
appending = 1;
- ct->c_storage = getcpy(p->c_storage);
+ ct->c_storage = mh_xstrdup(p->c_storage);
/* record the folder name */
if (p->c_folder) {
- ct->c_folder = getcpy(p->c_folder);
+ ct->c_folder = mh_xstrdup(p->c_folder);
}
goto got_filename;
}
/* Store content in temporary file for now */
tmpfilenam = m_mktemp(invo_name, NULL, NULL);
- ct->c_storage = getcpy(tmpfilenam);
+ ct->c_storage = mh_xstrdup(tmpfilenam);
/* Get the folder name */
if (cp[1])
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
else
folder = getcurfol();
create_folder(toabsdir(folder), 0, exit);
/* Record the folder name */
- ct->c_folder = getcpy(folder);
+ ct->c_folder = mh_xstrdup(folder);
if (cp[1])
- free(folder);
+ mh_free0(&folder);
goto got_filename;
}
return show_content_aux(ct, 0, buffer + 1, dir);
/* record the filename */
- ct->c_storage = getcpy(buffer);
+ ct->c_storage = mh_xstrdup(buffer);
got_filename:
/* flush the output stream */
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case OUTFILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- outfile = *cp == '-' ? cp : getcpy(expanddir(cp));
+ outfile = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** check if message is coming from file
*/
if (file) {
- cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+ cts = mh_xcalloc(2, sizeof(*cts));
ctp = cts;
if ((ct = parse_mime(file)))
exit(EX_USAGE);
seq_setprev(mp); /* set the previous-sequence */
- cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
- sizeof(*cts));
+ cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
ctp = cts;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
for (ctp = cts; *ctp; ctp++)
free_content(*ctp);
- free((char *) cts);
- cts = NULL;
+ mh_free0(&cts);
/* If reading from a folder, do some updating */
if (mp) {
int j, k;
char *cp, **ap;
- field = getcpy(field);
+ field = mh_xstrdup(field);
/* copied from seq_read.c:seq_init */
for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
}
}
- free(field);
+ mh_free0(&field);
return total;
}
old_msgnums = msgnums;
msgnums = concat(old_msgnums, " ",
this_msgnums,
- (void *)NULL);
- free(old_msgnums);
- free(this_msgnums);
+ NULL);
+ mh_free0(&old_msgnums);
+ mh_free0(&this_msgnums);
}
}
continue;
if (is_cur || msgnums != NULL) {
if (*b->first == NULL) {
- *b->first = b->node = mh_xmalloc(sizeof(*b->node));
+ *b->first = b->node = mh_xcalloc(1, sizeof(*b->node));
} else {
- b->node->n_next = mh_xmalloc(sizeof(*b->node));
+ b->node->n_next = mh_xcalloc(1, sizeof(*b->node));
b->node = b->node->n_next;
}
b->node->n_name = folder;
while (vfgets(fp, &line) == OK) {
len = strlen(line) - 1;
line[len] = '\0';
- check_folder(getcpy(line), len, &b);
+ check_folder(mh_xstrdup(line), len, &b);
}
fclose(fp);
}
for (i = 0; sequences[i] != NULL; i++) {
len += strlen(sequences[i]) + 1;
}
- result = mh_xmalloc(len + 1);
+ result = mh_xcalloc(len + 1, sizeof(char));
for (i = 0, cp = result; sequences[i] != NULL; i++, cp += len + 1) {
len = strlen(sequences[i]);
} else {
unseen = seq_unseen; /* use default */
}
- dp = getcpy(unseen);
+ dp = mh_xstrdup(unseen);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++) {
sequences[i++] = *ap;
}
if (*cp == '+' || *cp == '@') {
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
padvise(NULL, "pattern error in %s %s", argp[-2], cp);
return NULL;
}
- n->n_patbuf = getcpy(dp);
+ n->n_patbuf = mh_xstrdup(dp);
return n;
case PROTHR:
{
struct nexus *p;
- p = (struct nexus *) mh_xcalloc((size_t) 1, sizeof *p);
+ p = mh_xcalloc(1, sizeof *p);
p->n_action = action;
return p;
switch (state = m_getfld2(state, &f, fp)) {
case FLD2:
if (bp) {
- free(bp);
- bp = NULL;
+ mh_free0(&bp);
}
- bp = getcpy(f.value);
+ bp = mh_xstrdup(f.value);
if (mh_strcasecmp(f.name, n->n_datef)==0) {
break;
}
case BODY2:
case FILEEOF2:
- if (bp) {
- free(bp);
- }
+ mh_free0(&bp);
return 0;
default:
: (twsort(tw, &n->n_tws) < 0);
if (bp != NULL)
- free(bp);
+ mh_free0(&bp);
return state;
}
continue;
}
}
- addrs = addrs ? add(cp, add(", ", addrs)) : getcpy(cp);
+ addrs = addrs ? add(cp, add(", ", addrs)) : mh_xstrdup(cp);
}
if (!addrs) {
}
char_read += strlen(f.value);
if (!cptr->c_text) {
- cptr->c_text = getcpy(f.value);
+ cptr->c_text = mh_xstrdup(f.value);
} else {
cp = cptr->c_text;
i = strlen(cp) - 1;
finished: ;
i = format_len + char_read + 256;
- scanl = mh_xmalloc((size_t) i + 2);
+ scanl = mh_xcalloc(i + 2, sizeof(char));
dat[0] = dat[1] = dat[2] = dat[4] = 0;
dat[3] = OUTPUTLINELEN;
fmt_scan(fmt, scanl, i, dat);
}
fclose(out);
- free(scanl);
+ mh_free0(&scanl);
}
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <fcntl.h>
#include <h/signals.h>
#include <errno.h>
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
continue;
case FILESW:
if (filep > NFOLDERS)
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- files[filep++] = getcpy(expanddir(cp));
+ files[filep++] = mh_xstrdup(expanddir(cp));
continue;
}
}
if (foldp > NFOLDERS)
adios(EX_USAGE, NULL, "only %d folders allowed!",
NFOLDERS);
- folders[foldp++].f_name = getcpy(expandfol(cp));
+ folders[foldp++].f_name = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (foldp == 0)
adios(EX_USAGE, NULL, "no folder specified");
- /*
- ** We are refiling a file to the folders
- */
if (filep > 0) {
- if (folder || msgs.size)
+ /*
+ ** We are refiling one or more files (-file) to the folders
+ */
+ if (msgs.size) {
adios(EX_USAGE, NULL, "use -file or msgs, not both");
+ }
+ if (folder) {
+ adios(EX_USAGE, NULL, "use -file or -src, not both");
+ }
opnfolds(folders, foldp);
- for (i = 0; i < filep; i++)
- if (m_file(files[i], folders, foldp, 0))
+ for (i = 0; i < filep; i++) {
+ if (m_file(files[i], folders, foldp, 0)) {
exit(EX_IOERR);
+ }
+ }
/* If -nolink, then unlink files */
if (!linkf) {
int i;
char **files = filevec;
- /* just unlink the files */
for (i = 0; i < filep; i++) {
- if (unlink(files[i]) == NOTOK)
+ if (unlink(files[i]) == NOTOK) {
admonish(files[i], "unable to unlink");
+ }
}
}
exit(EX_OK);
}
- if (!msgs.size)
+ /*
+ ** We are refiling messages to the folders
+ */
+ if (!msgs.size) {
app_msgarg(&msgs, seq_cur);
- if (!folder)
+ }
+ if (!folder) {
folder = getcurfol();
- strncpy(maildir, toabsdir(folder), sizeof(maildir));
+ }
- if (chdir(maildir) == NOTOK)
+ strncpy(maildir, toabsdir(folder), sizeof(maildir));
+ if (chdir(maildir) == NOTOK) {
adios(EX_OSERR, maildir, "unable to change directory to");
+ }
/* read source folder and create message structure */
- if (!(mp = folder_read(folder)))
+ if (!(mp = folder_read(folder))) {
adios(EX_IOERR, NULL, "unable to read folder %s", folder);
+ }
- /* check for empty folder */
- if (mp->nummsg == 0)
+ if (mp->nummsg == 0) {
adios(EX_DATAERR, NULL, "no messages in %s", folder);
+ }
/* parse the message range/sequence/name and set SELECTED */
- for (msgnum = 0; msgnum < msgs.size; msgnum++)
- if (!m_convert(mp, msgs.msgs[msgnum]))
+ for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+ if (!m_convert(mp, msgs.msgs[msgnum])) {
exit(EX_SOFTWARE);
- seq_setprev(mp); /* set the previous-sequence */
+ }
+ }
+ seq_setprev(mp);
/* create folder structures for each destination folder */
opnfolds(folders, foldp);
- /* Link all the selected messages into destination folders.
+ /*
+ ** Link all the selected messages into destination folders.
**
** This causes the add hook to be run for messages that are
** linked into another folder. The refile hook is run for
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
- cp = getcpy(m_name(msgnum));
- if (m_file(cp, folders, foldp, !linkf))
+ cp = mh_xstrdup(m_name(msgnum));
+ if (m_file(cp, folders, foldp, !linkf)) {
exit(EX_IOERR);
- free(cp);
+ }
+ mh_free0(&cp);
}
}
if (linkf) {
seq_setcur(mp, mp->hghsel);
}
- seq_save(mp); /* synchronize message sequences */
+ seq_save(mp);
- context_replace(curfolder, folder);
context_save();
folder_free(mp);
return 0;
create_folder(nmaildir, 0, exit);
- if (chdir(nmaildir) == NOTOK)
+ if (chdir(nmaildir) == NOTOK) {
adios(EX_OSERR, nmaildir, "unable to change directory to");
- if (!(mp = folder_read(fp->f_name)))
+ }
+ if (!(mp = folder_read(fp->f_name))) {
adios(EX_IOERR, NULL, "unable to read folder %s", fp->f_name);
+ }
mp->curmsg = 0;
fp->f_mp = mp;
struct st_fold *fp, *ep;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
- if ((msgnum = folder_addmsg(&fp->f_mp, msgfile, 1, 0,
- 0, nfolders == 1 && refile, maildir)) == -1)
+ if ((msgnum = folder_addmsg(&fp->f_mp, msgfile, 1, 0, 0,
+ nfolders == 1 && refile, maildir)) == -1) {
return 1;
+ }
}
return 0;
}
FILE *in;
int buildsw = 0;
- filter = getcpy(etcpath(mhlreply));
-
setlocale(LC_ALL, "");
invo_name = mhbasename(argv[0]);
/* read user profile/context */
context_read();
+ filter = mh_xstrdup(etcpath(mhlreply));
+
arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = getcpy(expanddir(cp));
+ file = mh_xstrdup(expanddir(cp));
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- filter = getcpy(etcpath(cp));
+ filter = mh_xstrdup(etcpath(cp));
continue;
case NFILTSW:
filter = NULL;
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
if (msg)
adios(EX_USAGE, NULL, "only one message at a time!");
if (ccme == -1)
ccme = groupreply;
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
if (file && (msg || folder))
adios(EX_USAGE, NULL, "can't mix files and folders/msgs");
context_save(); /* save the context file */
}
- msg = file ? file : getcpy(m_name(mp->lowsel));
+ msg = file ? file : mh_xstrdup(m_name(mp->lowsel));
if ((in = fopen(msg, "r")) == NULL)
adios(EX_IOERR, msg, "unable to open");
if ((cp = getenv("USER"))) {
FINDCOMP(cptr, "user");
if (cptr)
- cptr->c_text = getcpy(cp);
+ cptr->c_text = mh_xstrdup(cp);
}
if (!ccme)
ismymbox(NULL);
}
char_read += strlen(f.value);
if (!cptr->c_text) {
- cptr->c_text = getcpy(f.value);
+ cptr->c_text = mh_xstrdup(f.value);
i = strlen(cptr->c_text) - 1;
if (cptr->c_text[i] == '\n') {
cptr->c_text[i] = '\0';
}
if (sp != cptr->c_text) {
cp = cptr->c_text;
- cptr->c_text = getcpy(sp);
- free(cp);
+ cptr->c_text = mh_xstrdup(sp);
+ mh_free0(&cp);
}
}
i = format_len + char_read + 256;
- scanl = mh_xmalloc((size_t) i + 2);
+ scanl = mh_xcalloc(i + 2, sizeof(char));
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
}
/* return dynamically allocated buffers */
- free(scanl);
+ mh_free0(&scanl);
}
static char *buf; /* our current working buffer */
** returns a pointer to the concatenated address string.
**
** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
** length of the result string.
**
** This routine is an override for the equally named one in sbr/fmt_addr.c.
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = mh_xmalloc(BUFINCR);
+ buf = mh_xcalloc(BUFINCR, sizeof(char));
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
static void
replfilter(FILE *in, FILE *out, char *filter)
{
- int pid, n;
+ int pid, pid_show, n;
+ int mailpipe[2];
char *errstr;
if (filter == NULL)
rewind(in);
lseek(fileno(in), (off_t) 0, SEEK_SET);
- switch (pid = fork()) {
+ if (pipe(mailpipe) == -1) {
+ adios(EX_OSERR, "pipe", "can't create pipe");
+ }
+
+ switch (pid_show = fork()) {
case NOTOK:
adios(EX_OSERR, "fork", "unable to");
case OK:
dup2(fileno(in), fileno(stdin));
+ dup2(mailpipe[1], fileno(stdout));
+ for (n=3; n<OPEN_MAX; n++) {
+ close(n);
+ }
+
+ execlp("show", "show", "-file", "-", NULL);
+
+ adios(EX_OSERR, "exec", "unable to");
+ }
+
+ switch (pid = fork()) {
+ case NOTOK:
+ adios(EX_OSERR, "fork", "unable to");
+
+ case OK:
+ dup2(mailpipe[0], fileno(stdin));
dup2(fileno(out), fileno(stdout));
for (n=3; n<OPEN_MAX; n++) {
close(n);
_exit(EX_OSERR);
default:
- if (pidXwait(pid, "mhl"))
+ if (pidXwait(-1, "show | mhl"))
exit(EX_SOFTWARE);
fseek(out, 0L, SEEK_END);
break;
}
+
+ close(mailpipe[0]);
+ close(mailpipe[1]);
}
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <unistd.h>
#include <dirent.h>
#include <locale.h>
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
cp = concat("Remove folder \"", folder, "\"? ", NULL);
if (!getanswer(cp))
exit(EX_OK);
- free(cp);
+ mh_free0(&cp);
}
if (rmf(folder) == OK) {
struct node *np, *pp;
alen = strlen("atr-");
- plen = strlen(cp = getcpy(toabsdir(folder))) + 1;
+ plen = strlen(cp = mh_xstrdup(toabsdir(folder))) + 1;
/*
** Search context list for keys that look like
pp = np;
}
}
- free(cp);
+ mh_free0(&cp);
}
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
adios(EX_SOFTWARE, NULL, "more than %d messages for refile exec",
MAXARGS - 6);
}
- vec = (char **)mh_xmalloc((size_t)(msgs.size + 6) * sizeof(*vec));
+ vec = mh_xcalloc(msgs.size + 6, sizeof(*vec));
vec[vecp++] = "refile";
vec[vecp++] = "-src";
vec[vecp++] = concat("+", folder, NULL);
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
if (strcmp(file = cp, "-")!=0)
- file = getcpy(expanddir(cp));
+ file = mh_xstrdup(expanddir(cp));
continue;
}
}
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
- /*
- ** Get new format string. Must be before chdir().
- */
- fmtstr = new_fs(form, FORMAT);
+ /* Set format string. Must be before chdir(). */
+ fmtstr = new_fs(form, scanformat);
/*
** We are scanning a maildrop file
if (*cp) {
char **ap, *dp;
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
for (i = 0; ap && *ap; i++, ap++) {
seqnum[i] = seq_getnum(mp, *ap);
}
num_unseen_seq = i;
if (dp) {
- free(dp);
+ mh_free0(&dp);
}
}
width = MAXSCANL;
}
dat[3] = slwidth = width;
- scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
- (slwidth + 2)); /* probably for \n and \0 */
+ scanl = mh_xcalloc(slwidth + 2, SCAN_CHARWIDTH); /* probably for \n and \0 */
/* Compile format string */
ncomps = fmt_compile(fmtstr, &fmt) + 1;
FINDCOMP(datecomp, "date");
free(cptr->c_text);
cptr->c_text = NULL;
}
- cptr->c_text = getcpy(f.value);
+ cptr->c_text = mh_xstrdup(f.value);
cp = cptr->c_text + strlen(cptr->c_text) - 1;
for (; cp >= cptr->c_text; cp--) {
if (isspace(*cp)) {
if (datecomp && !datecomp->c_text) {
if (!datecomp->c_text) {
if (!datecomp->c_tws)
- datecomp->c_tws = (struct tws *) mh_xcalloc((size_t) 1, sizeof(*datecomp->c_tws));
+ datecomp->c_tws = mh_xcalloc(1, sizeof(*datecomp->c_tws));
if (!datecomp->c_tws)
adios(EX_OSERR, NULL, "unable to allocate tws buffer");
*datecomp->c_tws = *dlocaltime((time_t *) &st.st_mtime);
for (nmsgs = 0, msgnum = mp->lowsel;
msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
- files[nfiles++] = getcpy(m_name(msgnum));
+ files[nfiles++] = mh_xstrdup(m_name(msgnum));
unset_exists(mp, msgnum);
}
}
adios(EX_IOERR, altmsg, "unable to open for reading");
}
fstat(in, &st2);
- distfile = getcpy(m_mktemp2(NULL, invo_name, NULL, NULL));
+ distfile = mh_xstrdup(m_mktemp2(NULL, invo_name, NULL, NULL));
if ((out = creat(distfile, (int)st2.st_mode & 0777))==NOTOK) {
adios(EX_IOERR, distfile, "unable to open for writing");
}
}
/* We'll grow the buffer as needed. */
- field = (char *)mh_xmalloc(field_size = 256);
+ field = mh_xcalloc(field_size = 256, sizeof(char));
/*
** Scan the draft file for an attachment header field name.
}
/* We'll grow the buffer as needed. */
- field = (char *)mh_xmalloc(field_size = 256);
+ field = mh_xcalloc(field_size = 256, sizeof(char));
/* Scan the draft file for an attachment header field name. */
while (get_line() != EOF && *field != '\0' && *field != '-') {
break;
}
if (++n >= field_size - 1) {
- field = (char *)mh_xrealloc(field, field_size += 256);
+ field = mh_xrealloc(field, field_size += 256);
p = field + n - 1;
}
}
/* add special entries to lookup table */
if ((p = lookup(hdrs, "source"))) {
- p->p_value = getcpy(sender);
+ p->p_value = mh_xstrdup(sender);
}
if ((p = lookup(hdrs, "addr"))) {
- p->p_value = getcpy(addr);
+ p->p_value = mh_xstrdup(addr);
}
/*
for (i = 0, state = FLD2;;) {
switch (state = m_getfld2(state, &f, in)) {
case FLD2:
- lp = getcpy(f.value);
+ lp = mh_xstrdup(f.value);
for (p = hdrs; p->p_name; p++) {
if (mh_strcasecmp(p->p_name, f.name)!=0) {
if (!(p->p_flags & P_HID)) {
}
p->p_value = add(lp, cp);
}
- free(lp);
+ mh_free0(&lp);
break;
}
}
if (!p->p_name && i < NVEC) {
- p->p_name = getcpy(f.name);
+ p->p_name = mh_xstrdup(f.name);
p->p_value = lp;
p->p_flags = P_NIL;
p++, i++;
if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
q = lookup(hdrs, "from");
}
- p->p_value = getcpy(q ? q->p_value : "");
+ p->p_value = mh_xstrdup(q ? q->p_value : "");
p->p_flags &= ~P_CHK;
if (debug) {
debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
return;
}
if ((p = lookup(vars, "sender"))) {
- p->p_value = getcpy(sender);
+ p->p_value = mh_xstrdup(sender);
}
if ((p = lookup(vars, "address"))) {
- p->p_value = getcpy(addr);
+ p->p_value = mh_xstrdup(addr);
}
if ((p = lookup(vars, "size"))) {
snprintf(buffer, sizeof(buffer), "%d",
fstat(fd, &st) != -1 ? (int) st.st_size : 0);
- p->p_value = getcpy(buffer);
+ p->p_value = mh_xstrdup(buffer);
}
if ((p = lookup(vars, "info"))) {
- p->p_value = getcpy(info);
+ p->p_value = mh_xstrdup(info);
}
if (debug) {
for (p = vars; p->p_name; p++) {
unsigned char buffer[BUFSIZ];
if (!envelope) {
- *sender = getcpy("");
+ *sender = mh_xstrdup("");
return;
}
} else {
break;
}
- *sender = getcpy(buffer);
+ *sender = mh_xstrdup(buffer);
}
** get copy of envelope information
** ("From " line)
*/
- envelope = getcpy(buffer);
+ envelope = mh_xstrdup(buffer);
/* Put the delivery date in message */
fputs(ddate, ffp);
*sp = ' ';
}
}
- return getcpy(bp);
+ return mh_xstrdup(bp);
}
/*
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/*
** sort a list of pointers to our "messages to be sorted".
*/
- dlist = (struct smsg **) mh_xcalloc((size_t) (nmsgs+1), sizeof(*dlist));
+ dlist = mh_xcalloc(nmsgs+1, sizeof(*dlist));
for (i = 0; i < nmsgs; i++)
dlist[i] = &smsgs[i];
dlist[nmsgs] = 0;
struct smsg **slist, **flist;
struct smsg ***il, **fp, **dp;
- slist = (struct smsg **)
- mh_xmalloc((nmsgs+1) * sizeof(*slist));
+ slist = mh_xcalloc(nmsgs+1, sizeof(*slist));
memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist));
qsort((char *)slist, nmsgs, sizeof(*slist),
(qsort_comp) subsort);
** the collection of messages with the same subj
** given a message number.
*/
- il = (struct smsg ***) mh_xcalloc(mp->hghsel+1, sizeof(*il));
+ il = mh_xcalloc(mp->hghsel+1, sizeof(*il));
if (! il)
adios(EX_OSERR, NULL, "couldn't allocate msg list");
for (i = 0; i < nmsgs; i++)
** make up the final list, chronological but with
** all the same subjects grouped together.
*/
- flist = (struct smsg **)
- mh_xmalloc((nmsgs+1) * sizeof(*flist));
+ flist = mh_xcalloc(nmsgs+1, sizeof(*flist));
fp = flist;
for (dp = dlist; *dp;) {
struct smsg **s = il[(*dp++)->s_msg];
}
}
*fp = 0;
- free(slist);
- free(dlist);
+ mh_free0(&slist);
+ mh_free0(&dlist);
dlist = flist;
}
twscopy(&tb, dlocaltimenow());
- smsgs = (struct smsg *) mh_xcalloc((size_t) (mp->hghsel - mp->lowsel + 2),
- sizeof(*smsgs));
+ smsgs = mh_xcalloc(mp->hghsel - mp->lowsel + 2, sizeof(*smsgs));
s = smsgs;
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
switch (state = m_getfld2(state, &f, in)) {
case FLD2:
if (mh_strcasecmp(f.name, datesw)==0) {
- datecomp = getcpy(f.value);
+ datecomp = mh_xstrdup(f.value);
if (!subjsort || subjcomp) {
break;
}
} else if (subjsort && mh_strcasecmp(f.name,
subjsort)==0) {
- subjcomp = getcpy(f.value);
+ subjcomp = mh_xstrdup(f.value);
if (datecomp) {
break;
}
case IOERR2:
admonish(NULL, "format error in message %d (header #%d)", msg, compnum);
if (datecomp) {
- free(datecomp);
+ mh_free0(&datecomp);
}
if (subjcomp) {
- free(subjcomp);
+ mh_free0(&subjcomp);
}
fclose(in);
return (0);
}
fclose(in);
if (datecomp)
- free(datecomp);
+ mh_free0(&datecomp);
return (1);
}
static char *tmpfil;
static char *subject = NULL; /* the subject field for BCC'ing */
+static struct mailname *from = NULL; /* the from field for BCC'ing */
static char fccs[BUFSIZ] = "";
struct mailname *bccs = NULL; /* list of the bcc recipients */
struct mailname *recipients = NULL; /* list of the recipients */
verbose++;
out = stdout;
} else {
- tmpfil = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+ tmpfil = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
}
/* check for "Aliasfile:" profile entry */
char *dp, **ap;
aliasflg = 1;
- for (ap=brkstring(dp=getcpy(cp), " ", "\n"); ap && *ap;
+ for (ap=brkstring(dp=mh_xstrdup(cp), " ", "\n"); ap && *ap;
ap++) {
if ((state = alias(etcpath(*ap))) != AK_OK) {
adios(EX_IOERR, NULL, "aliasing error in file %s: %s",
adios(EX_DATAERR, NULL, "message has no recipients");
}
- sargv = mh_xmalloc(sizeof(char **) * (recipientsc + 4));
+ sargv = mh_xcalloc(recipientsc + 4, sizeof(char **));
argp = sargv;
*argp++ = "send-mail";
}
while (recipients != NULL) {
- cp = getcpy(recipients->m_mbox);
+ cp = mh_xstrdup(recipients->m_mbox);
if (recipients->m_host) {
cp = add("@", cp);
cp = add(recipients->m_host, cp);
}
if (hdr->flags & HSUB) {
- subject = getcpy(str);
+ subject = mh_xstrdup(str);
}
if (!(hdr->flags & HADR)) {
/* needed because the address parser holds global state */
ismymbox(NULL);
- for ( mp = addr_start.m_next; mp; mp = mp->m_next) {
+ for (mp = addr_start.m_next; mp; mp = mp->m_next) {
if (ismymbox(mp)) {
msgflags |= MFMM;
if (my == NULL) {
- my = mp;
+ from = my = mp;
}
}
}
}
if (mp->m_ingrp) {
if (mp->m_gname != NULL) {
- cp = getcpy(mp->m_gname);
+ cp = mh_xstrdup(mp->m_gname);
cp = add(";", cp);
linepos = putone(cp, linepos, namelen);
- free(cp);
+ mh_free0(&cp);
cp = NULL;
}
} else {
fprintf(stderr, "Skipped %sFcc %s: unable to system().\n",
msgstate == resent ? "Resent-" : "", folders);
} else if (status != 0) {
- fprintf(stderr, "%sFcc %s: Problems occured.\n",
+ fprintf(stderr, "%sFcc %s: Problems occurred.\n",
msgstate == resent ? "Resent-" : "", folders);
}
}
FILE *out = NULL;
for (mp=bccs; mp; mp=mp->m_next) {
- bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+ bccdraft = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
fprintf(out, "To: %s\n", mp->m_text);
+ if (from) {
+ fprintf(out, "From: %s\n", from->m_text);
+ }
fprintf(out, "Subject: [BCC] %s", subject ? subject : "");
fprintf(out, "%s: %s\n", attach_hdr, origmsg);
fprintf(out, "------------\n");
}
if ((!drft && !(drft = getenv("mhdraft"))) || !*drft)
- drft = getcpy(m_draft(seq_cur));
+ drft = mh_xstrdup(m_draft(seq_cur));
if ((cp = getenv("mhuse")) && *cp)
use = atoi(cp);
}
/* remember which editor we used */
- edsave = getcpy(*ed);
+ edsave = mh_xstrdup(*ed);
*ed = NULL;
}
pclose(in);
}
- free(cmd);
+ mh_free0(&cmd);
naddrs += n;
cmd = add("ali -list", NULL);
}
pclose(in);
}
- free(cmd);
+ mh_free0(&cmd);
naddrs += n;
cmd = add("ali -list", NULL);
}
pclose(in);
}
- free(cmd);
+ mh_free0(&cmd);
naddrs += n;
return naddrs ? 0 : 1;