1/*
2 Itay Marom
3 Cisco Systems, Inc.
4*/
5
6/*
7Copyright (c) 2015-2015 Cisco Systems, Inc.
8
9Licensed under the Apache License, Version 2.0 (the "License");
10you may not use this file except in compliance with the License.
11You may obtain a copy of the License at
12
13    http://www.apache.org/licenses/LICENSE-2.0
14
15Unless required by applicable law or agreed to in writing, software
16distributed under the License is distributed on an "AS IS" BASIS,
17WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18See the License for the specific language governing permissions and
19limitations under the License.
20*/
21#include <string>
22
23class TrexRpcZip {
24public:
25
26    /**
27     * return true if message is compressed
28     *
29     */
30    static bool is_compressed(const std::string &input);
31
32    /**
33     * uncompress an 'input' to 'output'
34     * on success return true else returns false
35     */
36    static bool uncompress(const std::string &input, std::string &output);
37
38    /**
39     * compress 'input' to 'output'
40     * on success return true else returns false
41     */
42    static bool compress(const std::string &input, std::string &output);
43
44private:
45
46    /**
47     * packed header for reading binary compressed messages
48     *
49     * @author imarom (15-Feb-16)
50     */
51    struct header_st {
52        uint32_t    magic;
53        uint32_t    uncmp_size;
54        char        data[0];
55    } __attribute__((packed));
56
57
58    static const uint32_t G_HEADER_MAGIC = 0xABE85CEA;
59};
60
61