lz4s.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, Ben Charrow
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 ********************************************************************/
34 
35 #ifndef ROSLZ4_LZ4S_H
36 #define ROSLZ4_LZ4S_H
37 
38 #include <lz4.h>
39 #include <ros/macros.h>
40 
41 // Import/export for windows dll's and visibility for gcc shared libraries.
42 #ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
43  #ifdef roslz4_EXPORTS // we are building a shared lib/dll
44  #define ROSLZ4S_DECL ROS_HELPER_EXPORT
45  #else // we are using shared lib/dll
46  #define ROSLZ4S_DECL ROS_HELPER_IMPORT
47  #endif
48 #else // ros is being built around static libraries
49  #define ROSLZ4S_DECL
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 // Return codes
57 const int ROSLZ4_MEMORY_ERROR = -5;
58 const int ROSLZ4_PARAM_ERROR = -4;
59 const int ROSLZ4_DATA_ERROR = -3;
60 const int ROSLZ4_OUTPUT_SMALL = -2;
61 const int ROSLZ4_ERROR = -1;
62 const int ROSLZ4_OK = 0;
63 const int ROSLZ4_STREAM_END = 2;
64 
65 // Actions
66 const int ROSLZ4_RUN = 0;
67 const int ROSLZ4_FINISH = 1;
68 
69 typedef struct {
70  char *input_next;
72 
73  char *output_next;
75 
76  int total_in;
77  int total_out;
78 
80 
81  // Internal use
82  void *state;
84 
85 // Low level functions
86 ROSLZ4S_DECL int roslz4_blockSizeFromIndex(int block_id);
87 
88 ROSLZ4S_DECL int roslz4_compressStart(roslz4_stream *stream, int block_size_id);
89 ROSLZ4S_DECL int roslz4_compress(roslz4_stream *stream, int action);
91 
95 
96 // Oneshot compression / decompression
97 ROSLZ4S_DECL int roslz4_buffToBuffCompress(char *input, unsigned int input_size,
98  char *output, unsigned int *output_size,
99  int block_size_id);
100 ROSLZ4S_DECL int roslz4_buffToBuffDecompress(char *input, unsigned int input_size,
101  char *output, unsigned int *output_size);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif // ROSLZ4_LZ4S_H
ROSLZ4S_DECL void roslz4_decompressEnd(roslz4_stream *str)
Definition: lz4s.c:579
const int ROSLZ4_MEMORY_ERROR
Definition: lz4s.h:57
int total_out
Definition: lz4s.h:77
int block_size_id
Definition: lz4s.h:79
const int ROSLZ4_OUTPUT_SMALL
Definition: lz4s.h:60
ROSLZ4S_DECL void roslz4_compressEnd(roslz4_stream *stream)
Definition: lz4s.c:365
#define ROSLZ4S_DECL
Definition: lz4s.h:49
ROSLZ4S_DECL int roslz4_compressStart(roslz4_stream *stream, int block_size_id)
Definition: lz4s.c:323
ROSLZ4S_DECL int roslz4_decompress(roslz4_stream *stream)
Definition: lz4s.c:548
int total_in
Definition: lz4s.h:76
const int ROSLZ4_STREAM_END
Definition: lz4s.h:63
int input_left
Definition: lz4s.h:71
const int ROSLZ4_PARAM_ERROR
Definition: lz4s.h:58
char * output_next
Definition: lz4s.h:73
void * state
Definition: lz4s.h:82
ROSLZ4S_DECL int roslz4_buffToBuffDecompress(char *input, unsigned int input_size, char *output, unsigned int *output_size)
Definition: lz4s.c:619
char * input_next
Definition: lz4s.h:70
const int ROSLZ4_DATA_ERROR
Definition: lz4s.h:59
const int ROSLZ4_OK
Definition: lz4s.h:62
ROSLZ4S_DECL int roslz4_decompressStart(roslz4_stream *stream)
Definition: lz4s.c:371
const int ROSLZ4_FINISH
Definition: lz4s.h:67
const int ROSLZ4_ERROR
Definition: lz4s.h:61
ROSLZ4S_DECL int roslz4_blockSizeFromIndex(int block_id)
Definition: lz4s.c:319
ROSLZ4S_DECL int roslz4_compress(roslz4_stream *stream, int action)
Definition: lz4s.c:329
const int ROSLZ4_RUN
Definition: lz4s.h:66
int output_left
Definition: lz4s.h:74
ROSLZ4S_DECL int roslz4_buffToBuffCompress(char *input, unsigned int input_size, char *output, unsigned int *output_size, int block_size_id)
Definition: lz4s.c:585


roslz4
Author(s): Ben Charrow
autogenerated on Mon Feb 28 2022 23:33:18