NeoMutt  2022-04-29-215-gc12b98
Teaching an old dog new tricks
DOXYGEN
compress.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stdio.h>
31#include <string.h>
32#include "mutt/lib.h"
33#include "lib.h"
34
38static const struct ComprOps *CompressOps[] = {
39#ifdef HAVE_LZ4
41#endif
42#ifdef HAVE_ZLIB
44#endif
45#ifdef HAVE_ZSTD
47#endif
48 NULL,
49};
50
57const char *compress_list(void)
58{
59 char tmp[256] = { 0 };
60 const struct ComprOps **ops = CompressOps;
61 size_t len = 0;
62
63 for (; *ops; ops++)
64 {
65 if (len != 0)
66 {
67 len += snprintf(tmp + len, sizeof(tmp) - len, ", ");
68 }
69 len += snprintf(tmp + len, sizeof(tmp) - len, "%s", (*ops)->name);
70 }
71
72 return mutt_str_dup(tmp);
73}
74
80const struct ComprOps *compress_get_ops(const char *compr)
81{
82 const struct ComprOps **ops = CompressOps;
83
84 if (!compr || !*compr)
85 return *ops;
86
87 for (; *ops; ops++)
88 {
89 if (strcmp(compr, (*ops)->name) == 0)
90 break;
91 }
92
93 return *ops;
94}
const char * compress_list(void)
Get a list of compression backend names.
Definition: compress.c:57
const struct ComprOps * compress_get_ops(const char *compr)
Get the API functions for a compress backend.
Definition: compress.c:80
static const struct ComprOps * CompressOps[]
Backend implementations.
Definition: compress.c:38
const struct ComprOps compr_zlib_ops
const struct ComprOps compr_lz4_ops
const struct ComprOps compr_zstd_ops
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
Key value store.
Definition: lib.h:60