/*
- * refile.c -- move or link message(s) from a source folder
- * -- into one or more destination folders
- *
- * 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.
- */
+** refile.c -- move or link message(s) from a source folder
+** -- into one or more destination folders
+**
+** 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>
};
/*
- * static prototypes
- */
+** static prototypes
+*/
static void opnfolds (struct st_fold *, int);
static void clsfolds (struct st_fold *, int);
static void remove_files (int, char **);
argp = arguments;
/*
- * Parse arguments
- */
+ ** Parse arguments
+ */
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
adios (NULL, "-%s unknown\n", cp);
case HELPSW:
- snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...",
- invo_name);
+ snprintf (buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name);
print_help (buf, switches, 1);
done (1);
case VERSIONSW:
adios (NULL, "only one source folder at a time!");
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
- folder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
- *cp != '@' ? TFOLDER : TSUBCWF);
+ folder = path (*cp == '+' || *cp == '@' ?
+ cp + 1 : cp,
+ *cp != '@' ?
+ TFOLDER : TSUBCWF);
continue;
case FILESW:
if (filep > NFOLDERS)
- adios (NULL, "only %d files allowed!", NFOLDERS);
+ adios (NULL, "only %d files allowed!",
+ NFOLDERS);
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
files[filep++] = path (cp, TFILE);
continue;
case RPROCSW:
if (!(rmmproc = *argp++) || *rmmproc == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
+ adios (NULL, "missing argument to %s",
+ argp[-2]);
continue;
case NRPRCSW:
rmmproc = NULL;
}
if (*cp == '+' || *cp == '@') {
if (foldp > NFOLDERS)
- adios (NULL, "only %d folders allowed!", NFOLDERS);
+ adios (NULL, "only %d folders allowed!",
+ NFOLDERS);
folders[foldp++].f_name =
pluspath (cp);
} else
#endif /* WHATNOW */
/*
- * We are refiling a file to the folders
- */
+ ** We are refiling a file to the folders
+ */
if (filep > 0) {
if (folder || msgs.size)
adios (NULL, "use -file or some messages, not both");
opnfolds (folders, foldp);
/* 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
- * messages that are moved to another folder.
- */
+ **
+ ** This causes the add hook to be run for messages that are
+ ** linked into another folder. The refile hook is run for
+ ** messages that are moved to another folder.
+ */
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected (mp, msgnum)) {
cp = getcpy (m_name (msgnum));
}
/*
- * This is a hack. If we are using an external rmmproc,
- * then save the current folder to the context file,
- * so the external rmmproc will remove files from the correct
- * directory. This should be moved to folder_delmsgs().
- */
+ ** This is a hack. If we are using an external rmmproc,
+ ** then save the current folder to the context file,
+ ** so the external rmmproc will remove files from the correct
+ ** directory. This should be moved to folder_delmsgs().
+ */
if (rmmproc) {
context_replace (pfolder, folder);
context_save ();
fflush (stdout);
}
- /* If -nolink, then "remove" messages from source folder.
- *
- * Note that folder_delmsgs does not call the delete hook
- * because the message has already been handled above.
- */
+ /*
+ ** If -nolink, then "remove" messages from source folder.
+ **
+ ** Note that folder_delmsgs does not call the delete hook
+ ** because the message has already been handled above.
+ */
if (!linkf) {
folder_delmsgs (mp, unlink_msgs, 1);
}
/*
- * Read all the destination folders and
- * create folder structures for all of them.
- */
+** Read all the destination folders and
+** create folder structures for all of them.
+*/
static void
opnfolds (struct st_fold *folders, int nfolders)
/*
- * Set the Previous-Sequence and then sychronize the
- * sequence file, for each destination folder.
- */
+** Set the Previous-Sequence and then sychronize the
+** sequence file, for each destination folder.
+*/
static void
clsfolds (struct st_fold *folders, int nfolders)
/*
- * If you have a "rmmproc" defined, we called that
- * to remove all the specified files. If "rmmproc"
- * is not defined, then just unlink the files.
- */
+** If you have a "rmmproc" defined, we called that
+** to remove all the specified files. If "rmmproc"
+** is not defined, then just unlink the files.
+*/
static void
remove_files (int filep, char **files)
/*
- * Link (or copy) the message into each of
- * the destination folders.
- */
+** Link (or copy) the message into each of
+** the destination folders.
+*/
static int
-m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve, int refile)
+m_file (char *msgfile, struct st_fold *folders, int nfolders, int preserve,
+ int refile)
{
int msgnum;
struct st_fold *fp, *ep;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
- if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0, preserve, nfolders == 1 && refile, maildir)) == -1)
+ if ((msgnum = folder_addmsg (&fp->f_mp, msgfile, 1, 0,
+ preserve, nfolders == 1 && refile, maildir))
+ == -1)
return 1;
}
return 0;