NeoMutt  2020-11-20
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 "private.h"
33 #include "mutt/lib.h"
34 #include "lib.h"
35 
39 const struct ComprOps *compr_ops[] = {
40 #ifdef HAVE_LZ4
42 #endif
43 #ifdef HAVE_ZLIB
45 #endif
46 #ifdef HAVE_ZSTD
48 #endif
49  NULL,
50 };
51 
58 const char *compress_list(void)
59 {
60  char tmp[256] = { 0 };
61  const struct ComprOps **ops = compr_ops;
62  size_t len = 0;
63 
64  for (; *ops; ops++)
65  {
66  if (len != 0)
67  {
68  len += snprintf(tmp + len, sizeof(tmp) - len, ", ");
69  }
70  len += snprintf(tmp + len, sizeof(tmp) - len, "%s", (*ops)->name);
71  }
72 
73  return mutt_str_dup(tmp);
74 }
75 
81 const struct ComprOps *compress_get_ops(const char *compr)
82 {
83  const struct ComprOps **ops = compr_ops;
84 
85  if (!compr || !*compr)
86  return *ops;
87 
88  for (; *ops; ops++)
89  {
90  if (strcmp(compr, (*ops)->name) == 0)
91  break;
92  }
93 
94  return *ops;
95 }
const struct ComprOps * compress_get_ops(const char *compr)
Get the API functions for a compress backend.
Definition: compress.c:81
const struct ComprOps compr_lz4_ops
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
Shared constants/structs that are private to Compression.
API for the header cache compression.
const struct ComprOps * compr_ops[]
Backend implementations.
Definition: compress.c:39
const struct ComprOps compr_zstd_ops
const char * compress_list(void)
Get a list of compression backend names.
Definition: compress.c:58
const struct ComprOps compr_zlib_ops
Header Cache Compression API.
Definition: lib.h:55
Convenience wrapper for the library headers.