new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_zlib / zlib-test.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All rights reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #include <stdlib.h>
11 #include <string.h>
12 #include <stdio.h>
13
14 #include "os_zlib.h"
15
16 #ifndef ARGV0
17 #define ARGV0   "zlib-test"
18 #endif
19
20
21 /* Zlib test */
22 int main(int argc, char **argv)
23 {
24     unsigned long int ret, srcsize, dstsize = 2010;
25     char dst[2048];
26     char dst2[2048];
27
28     memset(dst, 0, 2048);
29     memset(dst2, 0, 2048);
30
31     if (argc < 2) {
32         printf("%s: string\n", argv[0]);
33         exit(1);
34     }
35
36     srcsize = strlen(argv[1]);
37     if (srcsize > 2000) {
38         printf("%s: string too large\n", argv[0]);
39         exit(1);
40
41     }
42
43     if ((ret = os_zlib_compress(argv[1], dst, srcsize, dstsize))) {
44         printf("Compressed, from %lu->%lu\n", srcsize, ret);
45     } else {
46         printf("FAILED compressing.\n");
47         exit(1);
48     }
49
50     /* Set new srcsize for decompression */
51     srcsize = ret;
52
53     if ((ret = os_zlib_uncompress(dst, dst2, srcsize, dstsize))) {
54         printf("Uncompressed ok. String: '%s', size %lu->%lu\n",
55                dst2, srcsize, ret);
56     } else {
57         printf("FAILED uncompressing.\n");
58         exit(1);
59     }
60
61     return (0);
62 }