Simplify sidebar code
[apps/madmutt.git] / mx.c
diff --git a/mx.c b/mx.c
index 936fc25..fde597c 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -8,32 +8,12 @@
  * please see the file GPL in the top level source directory.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <lib-lib/lib-lib.h>
 
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
 #include <utime.h>
 
-#include <lib-lib/mem.h>
-#include <lib-lib/ascii.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
-#include <lib-lib/file.h>
-#include <lib-lib/url.h>
-
 #include <lib-sys/unix.h>
-
 #include <lib-mime/mime.h>
-
 #include <lib-ui/sidebar.h>
 
 #include "mutt.h"
@@ -78,7 +58,7 @@ static list2_t* MailboxFormats = NULL;
  * retry - should retry if unable to lock?
  */
 
-static int invoke_dotlock (const char *path, int dummy, int flags, int retry)
+static int invoke_dotlock (const char *path, int flags, int retry)
 {
   char cmd[LONG_STRING + _POSIX_PATH_MAX];
   char f[SHORT_STRING + _POSIX_PATH_MAX];
@@ -102,7 +82,7 @@ static int invoke_dotlock (const char *path, int dummy, int flags, int retry)
   return mutt_system (cmd);
 }
 
-static int dotlock_file (const char *path, int fd, int retry)
+static int dotlock_file (const char *path, int retry)
 {
   int r;
   int flags = DL_FL_USEPRIV | DL_FL_RETRY;
@@ -111,7 +91,7 @@ static int dotlock_file (const char *path, int fd, int retry)
     retry = 1;
 
 retry_lock:
-  if ((r = invoke_dotlock (path, fd, flags, retry)) == DL_EX_EXIST) {
+  if ((r = invoke_dotlock (path, flags, retry)) == DL_EX_EXIST) {
     if (!option (OPTNOCURSES)) {
       char msg[LONG_STRING];
 
@@ -131,9 +111,9 @@ retry_lock:
   return (r == DL_EX_OK ? 0 : -1);
 }
 
-static int undotlock_file (const char *path, int fd)
+static int undotlock_file (const char *path)
 {
-  return (invoke_dotlock (path, fd, DL_FL_USEPRIV | DL_FL_UNLOCK, 0) ==
+  return (invoke_dotlock (path,  DL_FL_USEPRIV | DL_FL_UNLOCK, 0) ==
           DL_EX_OK ? 0 : -1);
 }
 
@@ -256,7 +236,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int time_out)
 
 #ifdef USE_DOTLOCK
   if (r == 0 && dot)
-    r = dotlock_file (path, fd, time_out);
+    r = dotlock_file (path, time_out);
 #endif /* USE_DOTLOCK */
 
   if (r == -1) {
@@ -294,13 +274,13 @@ int mx_unlock_file (const char *path, int fd, int dot)
 
 #ifdef USE_DOTLOCK
   if (dot)
-    undotlock_file (path, fd);
+    undotlock_file (path);
 #endif
 
   return 0;
 }
 
-void mx_unlink_empty (const char *path)
+static void mx_unlink_empty (const char *path)
 {
   int fd;
 
@@ -317,7 +297,7 @@ void mx_unlink_empty (const char *path)
   }
 
 #ifdef USE_DOTLOCK
-  invoke_dotlock (path, fd, DL_FL_UNLINK, 1);
+  invoke_dotlock (path, DL_FL_UNLINK, 1);
 #else
   if (fstat (fd, &sb) == 0 && sb.st_size == 0)
     unlink (path);
@@ -1388,7 +1368,7 @@ int mx_rebuild_cache (void) {
     if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP)
       continue;
     sidebar_set_current (b->path);
-    sidebar_draw (CurrentMenu);
+    sidebar_draw ();
     if ((ctx = mx_open_mailbox (b->path,
                                 M_READONLY | M_NOSORT | M_COUNT,
                                 NULL)) != NULL)
@@ -1398,7 +1378,7 @@ int mx_rebuild_cache (void) {
 
   if (Context && Context->path)
     sidebar_set_current (Context->path);
-  sidebar_draw (CurrentMenu);
+  sidebar_draw ();
 
   return (0);
 #endif