From: markus schnalke Date: Wed, 21 Mar 2012 10:38:23 +0000 (+0100) Subject: packf prints to stdout now. X-Git-Tag: mmh-thesis-end~278 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=ca1023716d4c2ab890696f3e41fa0d94267a940e;p=mmh packf prints to stdout now. --- diff --git a/man/mmh-intro.man7 b/man/mmh-intro.man7 index 84bdc44..dd356ed 100644 --- a/man/mmh-intro.man7 +++ b/man/mmh-intro.man7 @@ -203,12 +203,12 @@ commands: ^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 diff --git a/man/packf.man1 b/man/packf.man1 index 79dccac..916db9e 100644 --- a/man/packf.man1 +++ b/man/packf.man1 @@ -3,35 +3,20 @@ .\" .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 @@ -60,7 +45,6 @@ can be unpacked using .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" @@ -70,7 +54,6 @@ inc(1) .nf .RB ` +folder "' defaults to the current folder" .RB ` msgs "' defaults to all" -.RB ` "\-file ./msgbox" ' .fi .SH CONTEXT diff --git a/uip/packf.c b/uip/packf.c index fc7fcba..70065c0 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -13,21 +13,13 @@ #include 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) @@ -37,9 +29,6 @@ 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, ""); @@ -71,14 +60,6 @@ main(int argc, char **argv) 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 == '@') { @@ -89,23 +70,6 @@ main(int argc, char **argv) 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); @@ -131,42 +95,26 @@ main(int argc, char **argv) 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); -}