/* rmm.c - remove a message */
static char ident
[] = "@(#)$Id: rmm.c,v 1.5 1992/12/15 00:20:22 jromine Exp $";
static struct swit switches
[] = {
invo_name
= r1bindex (argv
[0], '/');
if ((cp
= m_find (invo_name
)) != NULL
) {
ap
= brkstring (cp
= getcpy (cp
), " ", "\n");
ap
= copyip (ap
, arguments
);
(void) copyip (argv
+ 1, ap
);
switch (smatch (++cp
, switches
)) {
adios (NULLCP
, "-%s unknown\n", cp
);
(void) sprintf (buf
, "%s [+folder] [msgs] [switches]",
if (*cp
== '+' || *cp
== '@') {
adios (NULLCP
, "only one folder at a time!");
folder
= path (cp
+ 1, *cp
== '+' ? TFOLDER
: TSUBCWF
);
free (path ("./", TFOLDER
));
maildir
= m_maildir (folder
);
if (chdir (maildir
) == NOTOK
)
adios (maildir
, "unable to change directory to");
if (!(mp
= m_gmsg (folder
)))
adios (NULLCP
, "unable to read folder %s", folder
);
adios (NULLCP
, "no messages in %s", folder
);
for (msgnum
= 0; msgnum
< msgp
; msgnum
++)
if (!m_convert (mp
, msgs
[msgnum
]))
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if (mp
-> msgstats
[msgnum
] & SELECTED
) {
mp
-> msgstats
[msgnum
] |= DELETED
;
mp
-> msgstats
[msgnum
] &= ~EXISTS
;
mp
-> msgflags
|= SEQMOD
;
m_replace (pfolder
, folder
);
if (mp
-> numsel
> MAXARGS
- 2)
adios (NULLCP
, "more than %d messages for %s exec", MAXARGS
- 2,
vec
= (char **) calloc ((unsigned) (mp
-> numsel
+ 2), sizeof *vec
);
adios (NULLCP
, "unable to allocate exec vector");
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if (mp
-> msgstats
[msgnum
] & SELECTED
)
vec
[vecp
++] = getcpy (m_name (msgnum
));
vec
[0] = r1bindex (rmmproc
, '/');
adios (rmmproc
, "unable to exec");
for (msgnum
= mp
-> lowsel
; msgnum
<= mp
-> hghsel
; msgnum
++)
if (mp
-> msgstats
[msgnum
] & SELECTED
) {
(void) strcpy (buf
, m_backup (dp
= m_name (msgnum
)));
if (rename (dp
, buf
) == NOTOK
)
admonish (buf
, "unable to rename %s to", dp
);