Removed configure option --with-hash-prefix and moved backup-prefix to profile
[mmh] / sbr / folder_delmsgs.c
index 3d2e549..e6fac04 100644 (file)
@@ -2,8 +2,6 @@
 /*
  * folder_delmsgs.c -- "remove" SELECTED messages from a folder
  *
- * $Id$
- *
  * 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.
  * 2) Else if unlink_msgs is non-zero, then unlink the
  *    SELECTED messages.
  * 3) Else rename SELECTED messages by prefixing name
- *    with a standard prefix.
+ *    with backup_prefix.
  *
  * If there is an error, return -1, else return 0.
  */
 
 int
-folder_delmsgs (struct msgs *mp, int unlink_msgs)
+folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
 {
     pid_t pid;
     int msgnum, vecp, retval = 0;
     char buf[100], *dp, **vec;
+    char       msgpath[BUFSIZ];
 
     /*
      * If "rmmproc" is defined, exec it to remove messages.
@@ -83,6 +82,19 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs)
            unset_selected (mp, msgnum);
            mp->numsel--;
 
+           /*
+            *  Run the external hook on the message if one was specified in the context.
+            *  All we have is the message number; we have changed to the directory
+            *  containing the message.  So, we need to extract that directory to form
+            *  the complete path.  Note that the caller knows the directory, but has
+            *  no way of passing that to us.
+            */
+
+           if (!nohook) {
+                   (void)snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum);
+                   (void)ext_hook("del-hook", msgpath, (char *)0);
+               }
+
            dp = m_name (msgnum);
 
            if (unlink_msgs) {