X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=compress.c;h=f4b8b6749066f9d705a692bfebe50aefaa9a963e;hp=622bbc5aec9265b6d8a11c2077e3b50d570fd89b;hb=250e22d7ca2420a08b34711713839780fd042ba9;hpb=8e037c67a88cb4680c4391134c578e3b55a80f8a diff --git a/compress.c b/compress.c index 622bbc5..f4b8b67 100644 --- a/compress.c +++ b/compress.c @@ -7,25 +7,18 @@ * please see the file GPL in the top level source directory. */ -#include +#include -#include "mutt.h" +#include +#include + +#include -#ifdef USE_COMPRESSED +#include "mutt.h" #include "mx.h" #include "mbox.h" -#include "mutt_curses.h" - -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" -#include "lib/debug.h" - -#include -#include -#include -#include +#include "compress.h" typedef struct { const char *close; /* close-hook command */ @@ -41,7 +34,7 @@ char echo_cmd[HUGE_STRING]; * excl - exclusive lock? * retry - should retry if unable to lock? */ -int mbox_lock_compressed (CONTEXT * ctx, FILE * fp, int excl, int retry) +static int mbox_lock_compressed (CONTEXT * ctx, FILE * fp, int excl, int retry) { int r; @@ -55,7 +48,7 @@ int mbox_lock_compressed (CONTEXT * ctx, FILE * fp, int excl, int retry) return (r); } -void mbox_unlock_compressed (CONTEXT * ctx, FILE * fp) +static void mbox_unlock_compressed (CONTEXT * ctx, FILE * fp) { if (ctx->locked) { fflush (fp); @@ -132,7 +125,7 @@ static void set_path (CONTEXT * ctx) /* Uncompress to /tmp */ mutt_mktemp (tmppath); - ctx->path = p_dupstr(tmppath, str_len(tmppath)); + ctx->path = p_dupstr(tmppath, m_strlen(tmppath)); } static int get_size (const char *path) @@ -151,13 +144,13 @@ static void store_size (CONTEXT * ctx) ci->size = get_size (ctx->realpath); } -static const char *compresshook_format_str (char *dest, size_t destlen, +static const char *compresshook_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, - const char *ifstring, - const char *elsestring, + const char *ifstring __attribute__ ((unused)), + const char *elsestring __attribute__ ((unused)), unsigned long data, - format_flag flags) + format_flag flags __attribute__ ((unused))) { char tmp[SHORT_STRING]; @@ -190,7 +183,7 @@ static char *get_compression_cmd (const char *cmd, const CONTEXT * ctx) mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str, (unsigned long) ctx, 0); - return str_dup (expanded); + return m_strdup(expanded); } int mutt_check_mailbox_compressed (CONTEXT * ctx) @@ -232,7 +225,6 @@ int mutt_open_read_compressed (CONTEXT * ctx) cmd = get_compression_cmd (ci->open, ctx); if (cmd == NULL) return (-1); - debug_print (2, ("DecompressCmd: '%s'\n", cmd)); if ((fp = fopen (ctx->realpath, "r")) == NULL) { mutt_perror (ctx->realpath); @@ -277,14 +269,14 @@ int mutt_open_read_compressed (CONTEXT * ctx) return (0); } -void restore_path (CONTEXT * ctx) +static void restore_path (CONTEXT * ctx) { p_delete(&ctx->path); ctx->path = ctx->realpath; } /* remove the temporary mailbox */ -void remove_file (CONTEXT * ctx) +static void remove_file (CONTEXT * ctx) { if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) remove (ctx->path); @@ -320,8 +312,6 @@ int mutt_open_append_compressed (CONTEXT * ctx) /* close a compressed mailbox */ void mutt_fast_close_compressed (CONTEXT * ctx) { - debug_print (2, ("called on '%s'\n", ctx->path)); - if (ctx->compressinfo) { if (ctx->fp) fclose (ctx->fp); @@ -369,8 +359,6 @@ int mutt_sync_compressed (CONTEXT * ctx) return (-1); } - debug_print (2, ("CompressCommand: '%s'\n", cmd)); - endwin (); fflush (stdout); sprintf (echo_cmd, _("echo Compressing %s..."), ctx->realpath); @@ -401,8 +389,6 @@ int mutt_slow_close_compressed (CONTEXT * ctx) char *cmd; COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; - debug_print (2, ("called on '%s'\n", ctx->path)); - if (!(ctx->append && ((append = get_append_command (ctx->realpath, ctx)) || (append = ci->close)))) { /* if we can not or should not append, * we only have to remove the compressed info, because sync was already @@ -442,8 +428,6 @@ int mutt_slow_close_compressed (CONTEXT * ctx) return (-1); } - debug_print (2, ("CompressCmd: '%s'\n", cmd)); - endwin (); fflush (stdout); @@ -477,15 +461,17 @@ int mutt_slow_close_compressed (CONTEXT * ctx) return (0); } -mx_t* compress_reg_mx (void) { - mx_t* fmt = mem_calloc (1, sizeof (mx_t)); - fmt->type = M_COMPRESSED; - fmt->local = 1; - fmt->mx_is_magic = mbox_is_magic; - fmt->mx_check_empty = mbox_check_empty; - fmt->mx_access = access; - fmt->mx_open_mailbox = mutt_open_read_compressed; - return (fmt); -} - -#endif /* USE_COMPRESSED */ +mx_t const compress_mx = { + M_COMPRESSED, + 1, + mbox_is_magic, + mbox_check_empty, + access, + mutt_open_read_compressed, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +};