Skip to content

Commit 7e38c3f

Browse files
committed
Cosmetic changes
1 parent 3e14664 commit 7e38c3f

File tree

5 files changed

+50
-23
lines changed

5 files changed

+50
-23
lines changed

src/api/Compressor.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace kanzi {
156156

157157

158158
// Create internal cContext and CompressedOutputStream
159-
ARCHIVER_API int CDECL initCompressor(struct cData* pData, FILE* dst, struct cContext** pCtx)
159+
KANZI_API int CDECL initCompressor(struct cData* pData, FILE* dst, struct cContext** pCtx)
160160
{
161161
if ((pData == nullptr) || (pCtx == nullptr) || (dst == nullptr))
162162
return Error::ERR_INVALID_PARAM;
@@ -224,7 +224,7 @@ ARCHIVER_API int CDECL initCompressor(struct cData* pData, FILE* dst, struct cCo
224224
return 0;
225225
}
226226

227-
ARCHIVER_API int CDECL compress(struct cContext* pCtx, const unsigned char* src, size_t inSize, size_t* outSize)
227+
KANZI_API int CDECL compress(struct cContext* pCtx, const unsigned char* src, size_t inSize, size_t* outSize)
228228
{
229229
if ((pCtx == nullptr) || (outSize == nullptr)) {
230230
return Error::ERR_INVALID_PARAM;
@@ -256,7 +256,7 @@ ARCHIVER_API int CDECL compress(struct cContext* pCtx, const unsigned char* src,
256256
}
257257

258258
// Cleanup allocated internal data structures
259-
ARCHIVER_API int CDECL disposeCompressor(struct cContext** ppCtx, size_t* outSize)
259+
KANZI_API int CDECL disposeCompressor(struct cContext** ppCtx, size_t* outSize)
260260
{
261261
*outSize = 0;
262262

@@ -294,3 +294,10 @@ ARCHIVER_API int CDECL disposeCompressor(struct cContext** ppCtx, size_t* outSiz
294294

295295
return 0;
296296
}
297+
298+
KANZI_API unsigned int CDECL getCompressorVersion(void)
299+
{
300+
return (KANZI_COMP_VERSION_MAJOR << 16) |
301+
(KANZI_COMP_VERSION_MINOR << 8) |
302+
KANZI_COMP_VERSION_PATCH;
303+
}

src/api/Compressor.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ limitations under the License.
2020
#ifdef _WIN32
2121
#define CDECL __cdecl
2222

23-
#ifdef ARCHIVER_EXPORTS
24-
#define ARCHIVER_API __declspec(dllexport)
23+
#ifdef KANZI_EXPORTS
24+
#define KANZI_API __declspec(dllexport)
2525
#else
26-
#define ARCHIVER_API __declspec(dllimport)
26+
#define KANZI_API __declspec(dllimport)
2727
#endif
2828
#else
2929
#define CDECL
30-
#define ARCHIVER_API
30+
#define KANZI_API
3131
#endif
3232

3333
#include <stdio.h>
3434

3535

36-
#define ARCHIVER_VERSION_STRING "1.0.0"
36+
#define KANZI_COMP_VERSION_MAJOR 1
37+
#define KANZI_COMP_VERSION_MINOR 0
38+
#define KANZI_COMP_VERSION_PATCH 0
3739

3840

3941
#ifdef __cplusplus
@@ -64,7 +66,7 @@ limitations under the License.
6466
* @return the version number of the library.
6567
* Useful for checking for compatibility at runtime.
6668
*/
67-
ARCHIVER_API unsigned int CDECL Archiver_GetVersion(void);
69+
KANZI_API unsigned int CDECL getVersion(void);
6870

6971

7072
/**
@@ -76,7 +78,7 @@ limitations under the License.
7678
*
7779
* @return 0 in case of success, else see error code in Error.hpp
7880
*/
79-
ARCHIVER_API int CDECL initCompressor(struct cData* cParam, FILE* dst, struct cContext** ctx);
81+
KANZI_API int CDECL initCompressor(struct cData* cParam, FILE* dst, struct cContext** ctx);
8082

8183
/**
8284
* Compress a block of data. The compressor must have been initialized.
@@ -89,7 +91,7 @@ limitations under the License.
8991
*
9092
* @return 0 in case of success, else see error code in Error.hpp
9193
*/
92-
ARCHIVER_API int CDECL compress(struct cContext* ctx, const unsigned char* src, size_t inSize, size_t* outSize);
94+
KANZI_API int CDECL compress(struct cContext* ctx, const unsigned char* src, size_t inSize, size_t* outSize);
9395

9496
/**
9597
* Dispose the compressor and cleanup memory resources.
@@ -100,7 +102,7 @@ limitations under the License.
100102
*
101103
* @return 0 in case of success, else see error code in Error.hpp
102104
*/
103-
ARCHIVER_API int CDECL disposeCompressor(struct cContext** ctx, size_t* outSize);
105+
KANZI_API int CDECL disposeCompressor(struct cContext** ctx, size_t* outSize);
104106

105107
#ifdef __cplusplus
106108
}

src/api/Decompressor.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace kanzi {
103103

104104

105105
// Create internal dContext and CompressedInputStream
106-
ARCHIVER_API int CDECL initDecompressor(struct dData* pData, FILE* src, struct dContext** pCtx)
106+
KANZI_API int CDECL initDecompressor(struct dData* pData, FILE* src, struct dContext** pCtx)
107107
{
108108
if ((pData == nullptr) || (pCtx == nullptr) || (src == nullptr))
109109
return Error::ERR_INVALID_PARAM;
@@ -185,7 +185,7 @@ ARCHIVER_API int CDECL initDecompressor(struct dData* pData, FILE* src, struct d
185185
}
186186

187187

188-
ARCHIVER_API int CDECL decompress(struct dContext* pCtx, unsigned char* dst, size_t* inSize, size_t* outSize)
188+
KANZI_API int CDECL decompress(struct dContext* pCtx, unsigned char* dst, size_t* inSize, size_t* outSize)
189189
{
190190
if ((pCtx == nullptr) || (outSize == nullptr)) {
191191
return Error::ERR_INVALID_PARAM;
@@ -229,7 +229,7 @@ ARCHIVER_API int CDECL decompress(struct dContext* pCtx, unsigned char* dst, siz
229229
}
230230

231231
// Cleanup allocated internal data structures
232-
ARCHIVER_API int CDECL disposeDecompressor(struct dContext** ppCtx)
232+
KANZI_API int CDECL disposeDecompressor(struct dContext** ppCtx)
233233
{
234234
if ((ppCtx == nullptr) || (*ppCtx == nullptr))
235235
return Error::ERR_INVALID_PARAM;
@@ -264,3 +264,11 @@ ARCHIVER_API int CDECL disposeDecompressor(struct dContext** ppCtx)
264264

265265
return 0;
266266
}
267+
268+
KANZI_API unsigned int CDECL getDecompressorVersion(void)
269+
{
270+
return (KANZI_DECOMP_VERSION_MAJOR << 16) |
271+
(KANZI_DECOMP_VERSION_MINOR << 8) |
272+
KANZI_DECOMP_VERSION_PATCH;
273+
}
274+

src/api/Decompressor.hpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ limitations under the License.
2020
#ifdef _WIN32
2121
#define CDECL __cdecl
2222

23-
#ifdef ARCHIVER_EXPORTS
24-
#define ARCHIVER_API __declspec(dllexport)
23+
#ifdef KANZI_EXPORTS
24+
#define KANZI_API __declspec(dllexport)
2525
#else
26-
#define ARCHIVER_API __declspec(dllimport)
26+
#define KANZI_API __declspec(dllimport)
2727
#endif
2828
#else
2929
#define CDECL
30-
#define ARCHIVER_API
30+
#define KANZI_API
3131
#endif
3232

3333
#include <stdio.h>
3434

35+
#define KANZI_DECOMP_VERSION_MAJOR 1
36+
#define KANZI_DECOMP_VERSION_MINOR 0
37+
#define KANZI_DECOMP_VERSION_PATCH 0
38+
3539
#ifdef __cplusplus
3640
extern "C" {
3741
#endif
@@ -59,6 +63,12 @@ limitations under the License.
5963
int bsVersion; /* version of the bitstream */
6064
};
6165

66+
/**
67+
* @return the version number of the library.
68+
* Useful for checking for compatibility at runtime.
69+
*/
70+
KANZI_API unsigned int CDECL getVersion(void);
71+
6272
/**
6373
* Initialize the decompressor internal states.
6474
*
@@ -69,7 +79,7 @@ limitations under the License.
6979
*
7080
* @return 0 in case of success, else see error code in Error.hpp
7181
*/
72-
ARCHIVER_API int CDECL initDecompressor(struct dData* dParam, FILE* src, struct dContext** ctx);
82+
KANZI_API int CDECL initDecompressor(struct dData* dParam, FILE* src, struct dContext** ctx);
7383

7484
/**
7585
* Decompress a block of data. The decompressor must have been initialized.
@@ -82,7 +92,7 @@ limitations under the License.
8292
*
8393
* @return 0 in case of success, else see error code in Error.hpp
8494
*/
85-
ARCHIVER_API int CDECL decompress(struct dContext* ctx, unsigned char* dst, size_t* inSize, size_t* outSize);
95+
KANZI_API int CDECL decompress(struct dContext* ctx, unsigned char* dst, size_t* inSize, size_t* outSize);
8696

8797
/**
8898
* Dispose the decompressor and cleanup memory resources.
@@ -91,7 +101,7 @@ limitations under the License.
91101
*
92102
* @return 0 in case of success, else see error code in Error.hpp
93103
*/
94-
ARCHIVER_API int CDECL disposeDecompressor(struct dContext** ctx);
104+
KANZI_API int CDECL disposeDecompressor(struct dContext** ctx);
95105

96106
#ifdef __cplusplus
97107
}

src/test/TestAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static void test_headerless()
467467
size_t outBytes = sizeof(outbuf);
468468

469469
ASSERT(decompress(dctx, outbuf, &inBytes, &outBytes) == 0, "failed to decompress data");
470-
ASSERT(outBytes == (int)strlen(input), "failed to decompress data: wrong data size");
470+
ASSERT(outBytes == strlen(input), "failed to decompress data: wrong data size");
471471
ASSERT(memcmp(outbuf, input, strlen(input)) == 0, "failed to decompress data: data differ from original");
472472

473473
disposeDecompressor(&dctx);

0 commit comments

Comments
 (0)