diff --git a/bindings/generate_SWIG_interface.pl b/bindings/generate_SWIG_interface.pl index e21873d5b..653829ebf 100755 --- a/bindings/generate_SWIG_interface.pl +++ b/bindings/generate_SWIG_interface.pl @@ -300,10 +300,6 @@ JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_getFd(JNIEnv *env, jclass jcls, job } } -%typemap(freearg) unsigned char *in_data { - free(buf\$argnum); -} - /* for ssl_client_new() */ %typemap(in) const unsigned char session_id[] { /* check for a reference */ @@ -321,6 +317,32 @@ JNIEXPORT jint JNICALL Java_axTLSj_axtlsjJNI_getFd(JNIEnv *env, jclass jcls, job /* Some SWIG magic to make the API a bit more Lua friendly */ #ifdef SWIGLUA +/* for ssl_session_id() */ +%typemap(out) const unsigned char * { + int i; + lua_newtable(L); + for (i = 0; i < SSL_SESSION_ID_SIZE; i++){ + lua_pushnumber(L,(lua_Number)result[i]); + lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ + } + SWIG_arg++; +} + +%typemap(in) unsigned char **in_data (unsigned char *buf) { + \$1 = &buf; +} + +%typemap(argout) unsigned char **in_data { + if (result > SSL_OK) { + int i; + lua_newtable(L); + for (i = 0; i < result; i++){ + lua_pushnumber(L,(lua_Number)buf2[i]); + lua_rawseti(L,-2,i+1); /* -1 is the number, -2 is the table */ + } + SWIG_arg++; + } +} #endif END diff --git a/bindings/lua/Makefile b/bindings/lua/Makefile index 771c1acb8..d256c7ddf 100644 --- a/bindings/lua/Makefile +++ b/bindings/lua/Makefile @@ -24,7 +24,7 @@ all: lib ifdef CONFIG_PLATFORM_WIN32 TARGET=../../$(STAGE)/axtlsl.dll else -TARGET=../../$(STAGE)/libaxtlsl.so +TARGET=../../$(STAGE)/axtlsl.so endif ifneq ($(MAKECMDGOALS), clean) @@ -36,11 +36,9 @@ CONFIG_HOME=$(AXTLS_HOME)/config OBJ:=axTLSl_wrap.o include ../../config/makefile.post +# libaxtls has to be linked in as a single object for this (TODO: see if this is completely necessary) $(TARGET) : $(OBJ) - $(LD) $(LDFLAGS) -L ../../$(STAGE) -L $(CONFIG_LUA_CORE)/lib $(LDSHARED) -o $@ $(OBJ) -laxtls -llua -ifdef CONFIG_PLATFORM_CYGWIN - cd ../../$(STAGE); ln -sf $(notdir $@) axtlsl.dll -endif + $(LD) $(LDFLAGS) -L$(CONFIG_LUA_CORE)/lib $(LDSHARED) -o $@ $(OBJ) ../../$(STAGE)/libaxtls.a -llua CFLAGS += -I$(CONFIG_HOME) -I$(SSL_HOME) -I $(CONFIG_LUA_CORE)/include else