^mmh(1)~^\- initialize the mmh environment
^msgchk(1)~^\- check for messages
^next(1)~^\- show the next message
-^packf(1)~^\- compress a folder into a single file
+^packf(1)~^\- pack a folder into mbox format
^pick(1)~^\- select messages by content
^prev(1)~^\- show the previous message
^prompter(1)~^\- prompting editor front end
^rcvdist(1)~^\- asynchronously redistribute new mail
-^rcvpack(1)~^\- append message to file
+^rcvpack(1)~^\- asynchronously append a message to an mbox file
^rcvstore(1)~^\- asynchronously incorporate new mail
^refile(1)~^\- file messages in other folders
^repl(1)~^\- reply to a message
.\"
.TH PACKF %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
-packf \- pack messages in nmh folder into a single file
+packf \- pack messages in nmh folder into a single mbox file
.SH SYNOPSIS
.HP 5
.na
.B packf
.RI [ +folder ]
.RI [ msgs ]
-.RB [ \-file
-.IR name ]
.RB [ \-version ]
.RB [ \-help ]
.ad
.SH DESCRIPTION
.B Packf
-will pack copies of messages from a folder, into a single
-file.
-The messages are separated using mbox (uucp) style delimiters.
-This is the format used by most mail clients (elm, mailx, etc.).
-.PP
-You may specify the name of the file in which to use with the
-.B \-file
-.I name
-switch. If you do not specify the name of the file, it
-will default to
-.RI \*(lq msgbox \*(rq.
-.PP
-If the given file name points to an existing file, then the specified
-messages will be appended to the end of the file, otherwise the file
-will be created and the messages appended.
+will pack copies of messages from a folder, into mbox format and
+print it to the standard output.
.PP
.B packf
makes an mbox-style delimiter by examining the first line
.ta \w'ExtraBigProfileName 'u
^Path:~^To determine the user's mail storage
^Current\-Folder:~^To find the default current folder
-^Msg\-Protect:~^To set mode when creating a new `file'
.fi
.SH "SEE ALSO"
.nf
.RB ` +folder "' defaults to the current folder"
.RB ` msgs "' defaults to all"
-.RB ` "\-file ./msgbox" '
.fi
.SH CONTEXT
#include <errno.h>
static struct swit switches[] = {
-#define FILESW 0
- { "file name", 0 },
-#define VERSIONSW 1
+#define VERSIONSW 0
{ "version", 0 },
-#define HELPSW 2
+#define HELPSW 1
{ "help", 0 },
{ NULL, 0 }
};
-static int md = NOTOK;
-
-static void mbxclose_done(int) NORETURN;
-
-char *file = NULL;
-
int
main(int argc, char **argv)
char **argp, **arguments;
struct msgs_array msgs = { 0, 0, NULL };
struct msgs *mp;
- struct stat st;
-
- done=mbxclose_done;
#ifdef LOCALE
setlocale(LC_ALL, "");
case VERSIONSW:
print_version(invo_name);
done(1);
-
- case FILESW:
- if (file)
- adios(NULL, "only one file at a time!");
- if (!(file = *argp++) || *file == '-')
- adios(NULL, "missing argument to %s",
- argp[-2]);
- continue;
}
}
if (*cp == '+' || *cp == '@') {
app_msgarg(&msgs, cp);
}
- if (!file)
- file = "./msgbox";
- file = getcpy(expanddir(file));
-
- /*
- ** Check if file to be created (or appended to)
- ** exists. If not, ask for confirmation.
- */
- if (stat (file, &st) == NOTOK) {
- if (errno != ENOENT)
- adios(file, "error on file");
- cp = concat("Create file \"", file, "\"? ", NULL);
- if (!getanswer(cp))
- done(1);
- free(cp);
- }
-
/* default is to pack whole folder */
if (!msgs.size)
app_msgarg(&msgs, seq_all);
done(1);
seq_setprev(mp); /* set the previous-sequence */
- /* open and lock new maildrop file */
- if ((md = mbx_open(file, getuid(), getgid(), m_gmprot()))
- == NOTOK)
- adios(file, "unable to open");
-
- /* copy all the SELECTED messages to the file */
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
+ /* copy all the SELECTED messages to stdout */
+ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
if ((fd = open(msgnam = m_name(msgnum), O_RDONLY))
== NOTOK) {
admonish(msgnam, "unable to read message");
break;
}
-
- if (mbx_copy(md, fd) == NOTOK)
- adios(file, "error writing to file");
-
+ if (mbx_copy(fileno(stdout), fd) == NOTOK) {
+ adios(NULL, "error writing to stdout");
+ }
close(fd);
}
-
- /* close and unlock maildrop file */
- mbx_close(file, md);
-
- context_replace(curfolder, folder); /* update current folder */
+ }
+ context_replace(curfolder, folder);
if (mp->hghsel != mp->curmsg)
seq_setcur(mp, mp->lowsel);
seq_save(mp);
- context_save(); /* save the context file */
- folder_free(mp); /* free folder/message structure */
+ context_save();
+ folder_free(mp);
done(0);
return 1;
}
-
-static void
-mbxclose_done(int status)
-{
- mbx_close(file, md);
- exit(status);
-}