NeoMutt  2021-02-05-666-ge300cd
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 
38 static const struct ComprOps *compr_ops[] = {
39 #ifdef HAVE_LZ4
41 #endif
42 #ifdef HAVE_ZLIB
44 #endif
45 #ifdef HAVE_ZSTD
47 #endif
48  NULL,
49 };
50 
57 const char *compress_list(void)
58 {
59  char tmp[256] = { 0 };
60  const struct ComprOps **ops = compr_ops;
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 
80 const struct ComprOps *compress_get_ops(const char *compr)
81 {
82  const struct ComprOps **ops = compr_ops;
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 struct ComprOps * compress_get_ops(const char *compr)
Get the API functions for a compress backend.
Definition: compress.c:80
const struct ComprOps compr_lz4_ops
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
API for the header cache compression.
static const struct ComprOps * compr_ops[]
Backend implementations.
Definition: compress.c:38
const struct ComprOps compr_zstd_ops
const char * compress_list(void)
Get a list of compression backend names.
Definition: compress.c:57
const struct ComprOps compr_zlib_ops
Definition: lib.h:59
Convenience wrapper for the library headers.