Skip to content

Commit

Permalink
add windows mex files, updates to allow to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jul 12, 2019
1 parent 13ad7fa commit 749240d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
Binary file added octave/win64/zipmat.mex
Binary file not shown.
Binary file added private/zipmat.mexw64
Binary file not shown.
2 changes: 1 addition & 1 deletion src/compilezmat.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if(~exist('OCTAVE_VERSION','builtin'))
mex CFLAGS='$CFLAGS -O3 -g' -Ieasylzma/easylzma-0.0.8/include -c zmatlib.c
mex zmat.cpp zmatlib.o easylzma/easylzma-0.0.8/lib/libeasylzma_s.a -Ieasylzma/easylzma-0.0.8/include -output ../zipmat -outdir ../ CXXLIBS='$CXXLIBS -lz'
mex zmat.cpp zmatlib.obj easylzma/easylzma-0.0.8/lib/libeasylzma_s.a -Ieasylzma/easylzma-0.0.8/include -output ../zipmat -outdir ../ CXXLIBS='$CXXLIBS -lz'
else
mex -Ieasylzma/easylzma-0.0.8/include -c zmatlib.c
mex zmat.cpp zmatlib.o easylzma/easylzma-0.0.8/lib/libeasylzma_s.a -Ieasylzma/easylzma-0.0.8/include -o ../zipmat -lz
Expand Down
4 changes: 1 addition & 3 deletions src/zmat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ void zmat_usage();

const char *metadata[]={"type","size","byte","method","status"};

extern char *zmat_err[];

/** @brief Mex function for the zmat - an interface to compress/decompress binary data
* This is the master function to interface for zipping and unzipping a char/int8 buffer
*/
Expand Down Expand Up @@ -77,7 +75,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
unsigned char * inputstr=(mxIsChar(prhs[0])? (unsigned char *)mxArrayToString(prhs[0]) : (unsigned char *)mxGetData(prhs[0]));
int errcode=zmat_run(inputsize, inputstr, &outputsize, &outputbuf, zipid, &ret, iscompress);
if(errcode<0)
mexErrMsgTxt(zmat_err[-errcode]);
mexErrMsgTxt(zmat_error(-errcode));
if(outputbuf){
buflen[0]=1;
buflen[1]=outputsize;
Expand Down
10 changes: 9 additions & 1 deletion src/zmatlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@

#include "zlib.h"

char *zmat_err[]={
char *zmat_errcode[]={
"No error",
"input can not be empty",
"failed to initialize zlib",
"zlib error, see info.status for error flag",
"easylzma error, see info.status for error flag"
};


char * zmat_error(int id){
if(id>=0 && id<(sizeof(zmat_errcode) / sizeof(zmat_errcode[0])))
return zmat_errcode[id];
else
return "unknown error";
}

int zmat_run(const size_t inputsize, unsigned char *inputstr, size_t *outputsize, unsigned char **outputbuf, const int zipid, int *ret, const int iscompress){
z_stream zs;
size_t buflen[2]={0};
Expand Down
2 changes: 2 additions & 0 deletions src/zmatlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ int zmat_encode(const size_t inputsize, unsigned char *inputstr, size_t *outputs
int zmat_decode(const size_t inputsize, unsigned char *inputstr, size_t *outputsize, unsigned char **outputbuf, const int zipid, int *ret);

int zmat_keylookup(char *origkey, const char *table[]);
char *zmat_error(int id);

unsigned char * base64_encode(const unsigned char *src, size_t len,
size_t *out_len);
unsigned char * base64_decode(const unsigned char *src, size_t len,
Expand Down

0 comments on commit 749240d

Please sign in to comment.