Remove three more bogus files (2x temp file, 1x trash)
[openssl.git] / crypto / comp / c_rle.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "objects.h"
5 #include "comp.h"
6
7 static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
8         unsigned int olen, unsigned char *in, unsigned int ilen);
9 static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
10         unsigned int olen, unsigned char *in, unsigned int ilen);
11
12 static COMP_METHOD rle_method={
13         NID_rle_compression,
14         LN_rle_compression,
15         NULL,
16         NULL,
17         rle_compress_block,
18         rle_expand_block,
19         NULL,
20         };
21
22 COMP_METHOD *COMP_rle()
23         {
24         return(&rle_method);
25         }
26
27 static int rle_compress_block(ctx,out,olen,in,ilen)
28 COMP_CTX *ctx;
29 unsigned char *out;
30 unsigned int olen;
31 unsigned char *in;
32 unsigned int ilen;
33         {
34         /* int i; */
35
36         if (olen < (ilen+1))
37                 {
38                 /* ZZZZZZZZZZZZZZZZZZZZZZ */
39                 return(-1);
40                 }
41
42         *(out++)=0;
43         memcpy(out,in,ilen);
44         return(ilen+1);
45         }
46
47 static int rle_expand_block(ctx,out,olen,in,ilen)
48 COMP_CTX *ctx;
49 unsigned char *out;
50 unsigned int olen;
51 unsigned char *in;
52 unsigned int ilen;
53         {
54         int i;
55
56         if (olen < (ilen-1))
57                 {
58                 /* ZZZZZZZZZZZZZZZZZZZZZZ */
59                 return(-1);
60                 }
61
62         i= *(in++);
63         if (i == 0)
64                 {
65                 memcpy(out,in,ilen-1);
66                 }
67         return(ilen-1);
68         }
69