1 /* $OpenBSD: c_rle.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */
5 #include <openssl/objects.h>
6 #include <openssl/comp.h>
8 static int rle_compress_block(COMP_CTX
*ctx
, unsigned char *out
,
9 unsigned int olen
, unsigned char *in
, unsigned int ilen
);
10 static int rle_expand_block(COMP_CTX
*ctx
, unsigned char *out
,
11 unsigned int olen
, unsigned char *in
, unsigned int ilen
);
13 static COMP_METHOD rle_method
= {
14 .type
= NID_rle_compression
,
15 .name
= LN_rle_compression
,
16 .compress
= rle_compress_block
,
17 .expand
= rle_expand_block
27 rle_compress_block(COMP_CTX
*ctx
, unsigned char *out
, unsigned int olen
,
28 unsigned char *in
, unsigned int ilen
)
31 if (ilen
== 0 || olen
< (ilen
- 1)) {
36 memcpy(out
, in
, ilen
);
41 rle_expand_block(COMP_CTX
*ctx
, unsigned char *out
, unsigned int olen
,
42 unsigned char *in
, unsigned int ilen
)
46 if (olen
< (ilen
- 1)) {
52 memcpy(out
, in
, ilen
- 1);