NeoMutt  2020-04-24
Teaching an old dog new tricks
DOXYGEN
compress.c File Reference

Shared compression code. More...

#include "config.h"
#include <stdio.h>
#include <string.h>
#include "compress_private.h"
#include "mutt/lib.h"
#include "lib.h"
+ Include dependency graph for compress.c:

Go to the source code of this file.

Macros

#define COMPRESS_EXPORT(name)   extern const struct ComprOps compr_##name##_ops;
 

Functions

const char * compress_list (void)
 Get a list of compression backend names. More...
 
const struct ComprOpscompress_get_ops (const char *compr)
 Get the API functions for a compress backend. More...
 

Variables

const struct ComprOpscompr_ops []
 Backend implementations. More...
 

Detailed Description

Shared compression code.

Authors
  • Tino Reichardt

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file compress.c.

Macro Definition Documentation

◆ COMPRESS_EXPORT

#define COMPRESS_EXPORT (   name)    extern const struct ComprOps compr_##name##_ops;

Definition at line 36 of file compress.c.

Function Documentation

◆ compress_list()

const char* compress_list ( void  )

Get a list of compression backend names.

Return values
ptrComma-space-separated list of names
Note
The caller should free the string

Definition at line 64 of file compress.c.

65 {
66  char tmp[256] = { 0 };
67  const struct ComprOps **ops = compr_ops;
68  size_t len = 0;
69 
70  for (; *ops; ops++)
71  {
72  if (len != 0)
73  {
74  len += snprintf(tmp + len, sizeof(tmp) - len, ", ");
75  }
76  len += snprintf(tmp + len, sizeof(tmp) - len, "%s", (*ops)->name);
77  }
78 
79  return mutt_str_strdup(tmp);
80 }
const struct ComprOps * compr_ops[]
Backend implementations.
Definition: compress.c:45
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
Header Cache Compression API.
Definition: lib.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compress_get_ops()

const struct ComprOps* compress_get_ops ( const char *  compr)

Get the API functions for a compress backend.

Parameters
comprName of the backend
Return values
ptrSet of function pointers

Definition at line 87 of file compress.c.

88 {
89  const struct ComprOps **ops = compr_ops;
90 
91  if (!compr || !*compr)
92  return *ops;
93 
94  for (; *ops; ops++)
95  {
96  if (strcmp(compr, (*ops)->name) == 0)
97  break;
98  }
99 
100  return *ops;
101 }
const struct ComprOps * compr_ops[]
Backend implementations.
Definition: compress.c:45
Header Cache Compression API.
Definition: lib.h:55
+ Here is the caller graph for this function:

Variable Documentation

◆ compr_ops

const struct ComprOps* compr_ops[]
Initial value:
= {
NULL,
}
const struct ComprOps compr_lz4_ops
const struct ComprOps compr_zstd_ops
const struct ComprOps compr_zlib_ops

Backend implementations.

Definition at line 45 of file compress.c.