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