Also, include compress.h in compress.c so the mx_comp_ops doesn't need to be redeclared.
# HG changeset patch # User Kevin McCarthy <ke...@8t8.us> # Date 1478734906 28800 # Wed Nov 09 15:41:46 2016 -0800 # Node ID 6d7f9d97d0c00656d4f546a35c3774e7a46f7ccd # Parent f2cb736bcb7af5109de1f0ef007835f62a62c6d8 Compress: prefix external functions with "mutt_" Also, include compress.h in compress.c so the mx_comp_ops doesn't need to be redeclared. diff --git a/compress.c b/compress.c --- a/compress.c +++ b/compress.c @@ -24,16 +24,17 @@ #include <string.h> #include <sys/stat.h> #include <unistd.h> #include "mutt.h" #include "mailbox.h" #include "mutt_curses.h" #include "mx.h" +#include "compress.h" /* Notes: * Any references to compressed files also apply to encrypted files. * ctx->path == plaintext file * ctx->realpath == compressed file */ /** @@ -460,18 +461,16 @@ or_fail: /* remove the partial uncompressed file */ remove (ctx->path); restore_path (ctx); return 0; } -struct mx_ops mx_comp_ops; - /** * open_mailbox - Open a compressed mailbox * @ctx: Mailbox to open * * Set up a compressed mailbox to be read. * First call open_read() to decompress the file. * Then determine the type of the mailbox so we can delegate the handling of * messages. @@ -780,30 +779,30 @@ return -1; /* Delegate */ return ops->open_new_msg (msg, ctx, hdr); } /** - * comp_can_append - Can we append to this path? + * mutt_comp_can_append - Can we append to this path? * @path: pathname of file to be tested * * To append to a file we can either use an 'append-hook' or a combination of * 'open-hook' and 'close-hook'. * * A match means it's our responsibility to append to the file. * * Returns: * 1: Yes, we can append to the file * 0: No, appending isn't possible */ int -comp_can_append (CONTEXT *ctx) +mutt_comp_can_append (CONTEXT *ctx) { if (!ctx) return 0; /* If this succeeds, we know there's an open-hook */ COMPRESS_INFO *ci = set_compress_info (ctx); if (!ci) return 0; @@ -813,52 +812,52 @@ if (ci->append || ci->close) return 1; mutt_error (_("Cannot append without an append-hook or close-hook : %s"), ctx->path); return 0; } /** - * comp_can_read - Can we read from this file? + * mutt_comp_can_read - Can we read from this file? * @path: Pathname of file to be tested * * Search for an 'open-hook' with a regex that matches the path. * * A match means it's our responsibility to open the file. * * Returns: * 1: Yes, we can read the file * 0: No, we cannot read the file */ int -comp_can_read (const char *path) +mutt_comp_can_read (const char *path) { if (!path) return 0; if (find_hook (MUTT_OPENHOOK, path)) return 1; else return 0; } /** - * comp_sync - Save changes to the compressed mailbox file + * mutt_comp_sync - Save changes to the compressed mailbox file * @ctx: Mailbox to sync * - * Changes in Mutt only affect the tmp file. Calling comp_sync() will commit - * them to the compressed file. + * Changes in Mutt only affect the tmp file. Calling mutt_comp_sync() + * will commit them to the compressed file. * * Returns: * 0: Success * -1: Failure */ int -comp_sync (CONTEXT *ctx) +mutt_comp_sync (CONTEXT *ctx) { if (!ctx) return -1; COMPRESS_INFO *ci = ctx->compress_info; if (!ci) return -1; @@ -873,28 +872,28 @@ return -1; store_size (ctx); return 0; } /** - * comp_valid_command - Is this command string allowed? + * mutt_comp_valid_command - Is this command string allowed? * @cmd: Command string * * A valid command string must have both "%f" (from file) and "%t" (to file). * We don't check if we can actually run the command. * * Returns: * 1: Valid command * 0: "%f" and/or "%t" is missing */ int -comp_valid_command (const char *cmd) +mutt_comp_valid_command (const char *cmd) { if (!cmd) return 0; return (strstr (cmd, "%f") && strstr (cmd, "%t")); } diff --git a/compress.h b/compress.h --- a/compress.h +++ b/compress.h @@ -14,16 +14,16 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _COMPRESS_H_ #define _COMPRESS_H_ -int comp_can_append (CONTEXT *ctx); -int comp_can_read (const char *path); -int comp_sync (CONTEXT *ctx); -int comp_valid_command (const char *cmd); +int mutt_comp_can_append (CONTEXT *ctx); +int mutt_comp_can_read (const char *path); +int mutt_comp_sync (CONTEXT *ctx); +int mutt_comp_valid_command (const char *cmd); extern struct mx_ops mx_comp_ops; #endif /* _COMPRESS_H_ */ diff --git a/hook.c b/hook.c --- a/hook.c +++ b/hook.c @@ -110,17 +110,17 @@ } FREE (&pattern.data); memset (&pattern, 0, sizeof (pattern)); pattern.data = safe_strdup (path); } #ifdef USE_COMPRESSED else if (data & (MUTT_APPENDHOOK | MUTT_OPENHOOK | MUTT_CLOSEHOOK)) { - if (comp_valid_command (command.data) == 0) { + if (mutt_comp_valid_command (command.data) == 0) { strfcpy (err->data, _("badly formatted command string"), err->dsize); return -1; } } #endif else if (DefaultHook && !(data & (MUTT_CHARSETHOOK | MUTT_ICONVHOOK | MUTT_ACCOUNTHOOK)) && (!WithCrypto || !(data & MUTT_CRYPTHOOK)) ) diff --git a/mx.c b/mx.c --- a/mx.c +++ b/mx.c @@ -447,17 +447,17 @@ dprint (1, (debugfile, "mx_get_magic(): unable to open file %s for reading.\n", path)); return (-1); } #ifdef USE_COMPRESSED /* If there are no other matches, see if there are any * compress hooks that match */ - if ((magic == 0) && comp_can_read (path)) + if ((magic == 0) && mutt_comp_can_read (path)) return MUTT_COMPRESSED; #endif return (magic); } /* * set DefaultMagic to the given value */ @@ -517,17 +517,17 @@ return -1; } } else return -1; } #ifdef USE_COMPRESSED - if (comp_can_append (ctx)) + if (mutt_comp_can_append (ctx)) ctx->mx_ops = &mx_comp_ops; else #endif ctx->mx_ops = mx_get_ops (ctx->magic); if (!ctx->mx_ops || !ctx->mx_ops->open_append) return -1; return ctx->mx_ops->open_append (ctx, flags); @@ -717,19 +717,19 @@ mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path); #endif if (tmp && tmp->new == 0) mutt_update_mailbox (tmp); #ifdef USE_COMPRESSED /* If everything went well, the mbox handler saved the changes to our - * temporary file. Next, comp_sync() will compress the temporary file. */ + * temporary file. Next, mutt_comp_sync() will compress the temporary file. */ if ((rc == 0) && ctx->compress_info) - return comp_sync (ctx); + return mutt_comp_sync (ctx); #endif return rc; } /* move deleted mails to the trash folder */ static int trash_append (CONTEXT *ctx) {