return (sb.st_size);
}
-static const char *compresshook_format_str (char *dest, ssize_t destlen,
- char op, const char *src,
- const char *fmt,
- const char *ifstring __attribute__ ((unused)),
- const char *elsestring __attribute__ ((unused)),
- unsigned long data,
- format_flag flags __attribute__ ((unused)))
+static const char *
+compresshook_format_str(char *dest, ssize_t destlen,
+ char op, const char *src, const char *fmt,
+ const char *ifstr __attribute__ ((unused)),
+ const char *elstr __attribute__ ((unused)),
+ anytype data,
+ format_flag flags __attribute__ ((unused)))
{
- char tmp[SHORT_STRING];
+ char tmp[STRING];
- CONTEXT *ctx = (CONTEXT *) data;
+ CONTEXT *ctx = data.ptr;
switch (op) {
case 'f':
return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
}
-static char *get_compression_cmd (const char *cmd, const CONTEXT * ctx)
+static char *get_compression_cmd(const char *cmd, const CONTEXT *ctx)
{
- char expanded[_POSIX_PATH_MAX];
-
- mutt_FormatString (expanded, sizeof (expanded), cmd,
- compresshook_format_str, (unsigned long) ctx, 0);
- return m_strdup(expanded);
+ char buf[_POSIX_PATH_MAX];
+ m_strformat(buf, sizeof(buf), 0, cmd, compresshook_format_str, (void*)ctx, 0);
+ return m_strdup(buf);
}
int mutt_check_mailbox_compressed (CONTEXT * ctx)
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
rc = mutt_system (cmd);
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
if (rc) {
mutt_any_key_to_continue (NULL);
if (!is_new (ctx->realpath))
if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
if ((fh = safe_fopen (ctx->path, "w")))
- fclose (fh);
+ m_fclose(&fh);
/* No error checking - the parent function will catch it */
return (0);
void mutt_fast_close_compressed (CONTEXT * ctx)
{
if (ctx->cinfo) {
- if (ctx->fp)
- fclose (ctx->fp);
- ctx->fp = NULL;
+ m_fclose(&ctx->fp);
+
/* if the folder was removed, remove the gzipped folder too */
if (access (ctx->path, F_OK) != 0 && !option (OPTSAVEEMPTY))
remove (ctx->realpath);
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
p_delete(&cmd);
return (0);
}
- if (ctx->fp)
- fclose (ctx->fp);
- ctx->fp = NULL;
+ m_fclose(&ctx->fp);
if (!ctx->quiet) {
if (append == ci->close)
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
p_delete(&cmd);
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
return (-1);
}
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
remove_file (ctx);
restore_path (ctx);
p_delete(&cmd);