summaryrefslogtreecommitdiff
path: root/package/cfgfs/src/compress.h
blob: 413075d831ac6fa8439130ecfd7575c8cde85fef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* $MirOS: contrib/hosted/fwcf/compress.h,v 1.10 2007/03/09 22:35:13 tg Exp $ */

/*
 * This file is part of the FreeWRT project. FreeWRT is copyrighted
 * material, please see the LICENCE file in the top-level directory
 * or at http://www.freewrt.org/licence for details.
 */

#ifndef COMPRESS_H
#define COMPRESS_H

#include <sys/types.h>

/* BEGIN of plug-in API description - hook yer proprietary modules here */

/* returns 0 on success, -1 on failure */
typedef int (*fwcf_compress_init_func)(void);
/* in: *dst (malloc'd), src, size of source (max. INT_MAX) */
/* returns size of destination on success, -1 on failure */
typedef int (*fwcf_compress_work_func)(char **, char *, size_t)
    __attribute__((bounded (string, 2, 3)));
/* in: dst, max size of dst, src, size of source (max. INT_MAX) */
/* returns size of destination on success, -1 on failure */
typedef int (*fwcf_compress_rev_func)(char *, size_t, char *, size_t)
    __attribute__((bounded (string, 1, 2)))
    __attribute__((bounded (string, 3, 4)));

typedef struct FWCF_COMPRESSOR {
	fwcf_compress_init_func init;
	fwcf_compress_work_func compress;
	fwcf_compress_rev_func decompress;
	const char *name;
	u_int8_t code;
} fwcf_compressor;

/* 0=success 1=EINVAL 2=slot already used */
int compress_register(fwcf_compressor *);

/* END of plug-in API description, version 1.0 */

/* low-level */
fwcf_compressor *compress_enumerate(void);
int compress_list(void);

/* high-level */
fwcf_compressor *compressor_get(u_int8_t);
int compressor_getbyname(const char *);
int list_compressors(void);

#endif