From 05094bbee2bed33cb4aaecce5fc7076de98ebbc7 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 17 Sep 2012 15:07:39 +0000 Subject: [PATCH] Corrigindo passagem de parametros HLLAPI --- configure.ac | 2 +- po/pt_BR.po | 2 +- src/include/pw3270/hllapi.h | 3 ++- src/plugins/remotectl/Makefile.in | 20 ++++++++++---------- src/plugins/remotectl/hllapi.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- src/plugins/remotectl/remotectl.c | 7 +++++++ src/pw3270/plugin.c | 3 +++ 7 files changed, 64 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 08217bc..b80f913 100644 --- a/configure.ac +++ b/configure.ac @@ -119,7 +119,7 @@ case "$host" in SOCKET_LIBS="-lws2_32" CFLAGS="$CFLAGS -mms-bitfields" localedir="locale" - DLL_FLAGS="-shared" + DLL_FLAGS="-shared -Wl,--add-stdcall-alias" LDSOFLAGS="-Wl,-soname,\`basename \$@\`" LDAPPFLAGS="-mwindows" DBGRPATH="" diff --git a/po/pt_BR.po b/po/pt_BR.po index 67c5fef..d073096 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-09-15 13:07-0300\n" +"POT-Creation-Date: 2012-09-17 09:45-0300\n" "PO-Revision-Date: 2012-09-14 14:32-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português \n" diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index 9786ba8..e1e4abc 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -58,7 +58,8 @@ extern "C" { } HLLAPI_DATA; #pragma pack() - LIB3270_EXPORT int hllapi(unsigned long function, char *string, unsigned short length, unsigned short *rc); + #warning Remover comentario +// LIB3270_EXPORT int hllapi(unsigned long func, char *str, unsigned short length, unsigned short *rc); #ifdef __cplusplus } /* end of extern "C" */ diff --git a/src/plugins/remotectl/Makefile.in b/src/plugins/remotectl/Makefile.in index 443c003..7a566ef 100644 --- a/src/plugins/remotectl/Makefile.in +++ b/src/plugins/remotectl/Makefile.in @@ -76,31 +76,31 @@ $(OBJRLS)/%.o: %.c $(DEPENDS) #---[ Release targets ]-------------------------------------------------------- -Release: $(BINRLS)/plugins/$(MODULE_NAME).dll $(BINRLS)/libhllapi.dll +Release: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINRLS)/libhllapi@DLLEXT@ -$(BINRLS)/plugins/$(MODULE_NAME).dll: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) +$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS) + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS) -$(BINRLS)/libhllapi.dll: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJRLS)/$(SRC).o) +$(BINRLS)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJRLS)/$(SRC).o) @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) #---[ Debug targets ]---------------------------------------------------------- -Debug: $(BINDBG)/plugins/$(MODULE_NAME).dll $(BINDBG)/libhllapi.dll +Debug: $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINDBG)/libhllapi@DLLEXT@ -$(BINDBG)/plugins/$(MODULE_NAME).dll: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) +$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS) + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS) -$(BINDBG)/libhllapi.dll: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(SRC).o) +$(BINDBG)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(SRC).o) @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) #---[ Misc targets ]----------------------------------------------------------- diff --git a/src/plugins/remotectl/hllapi.c b/src/plugins/remotectl/hllapi.c index 7acbcae..b9d61d5 100644 --- a/src/plugins/remotectl/hllapi.c +++ b/src/plugins/remotectl/hllapi.c @@ -41,7 +41,7 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ - static int run_query(unsigned long func, char *string, unsigned short length, unsigned short *rc) + static int run_query(unsigned long func, const char *arg, char *string, unsigned short length, unsigned short *rc) { int result = -1; @@ -70,10 +70,15 @@ data->rc = *rc; data->len = length; - if(string && length > 0) - memcpy(data->string,string,length); + if(length > 0) + { + memset(data->string,0,length); + if(arg) + strncpy(data->string,arg,length); + } - memset(buffer,0,HLLAPI_MAXLENGTH); if(!CallNamedPipe(PipeName,(LPVOID)data,cbSize,buffer,HLLAPI_MAXLENGTH,&cbSize,NMPWAIT_USE_DEFAULT_WAIT)) + memset(buffer,0,HLLAPI_MAXLENGTH); + if(!CallNamedPipe(PipeName,(LPVOID)data,cbSize,buffer,HLLAPI_MAXLENGTH,&cbSize,NMPWAIT_USE_DEFAULT_WAIT)) { result = GetLastError(); } @@ -113,13 +118,38 @@ return 0; } - LIB3270_EXPORT int hllapi(unsigned long func, char *str, unsigned short length, unsigned short *rc) + LIB3270_EXPORT int hllapi(unsigned long *func, char *str, unsigned short *length, unsigned short *rc) { - int result = 1; - switch(func) + int result = 1; + char * arg; + + if(!length || *length > HLLAPI_MAXLENGTH) + return EINVAL; + + if(length > 0) + { + arg = malloc(*length+1); + strncpy(arg,str,(int) *length); + arg[(size_t) *length] = 0; + } + else + { + arg = malloc(1); + *arg = 0; + } + +/* +#ifdef DEBUG + freopen("hllapi.log","a",stderr); +#endif // DEBUG +*/ + + switch(*func) { case HLLAPI_CMD_CONNECTPS: - result = set_session_name(str); + result = set_session_name(arg); + if(!result) + result = run_query(*func, arg, str, *length, rc); break; default: @@ -128,9 +158,10 @@ if(set_session_name("pw3270A")) return ENOENT; } - result = run_query(func, str, length, rc); + result = run_query(*func, arg, str, *length, rc); } + free(arg); return result; } diff --git a/src/plugins/remotectl/remotectl.c b/src/plugins/remotectl/remotectl.c index e586722..32b6d04 100644 --- a/src/plugins/remotectl/remotectl.c +++ b/src/plugins/remotectl/remotectl.c @@ -133,6 +133,12 @@ return 0; } + static int cmd_connectps(unsigned short rc, char *string, unsigned short length) + { + g_message("%s","HLLAPI ConnectPS request received"); + return 0; + } + static int cmd_getrevision(unsigned short rc, char *string, unsigned short length) { strncpy(string,lib3270_get_revision(),length); @@ -171,6 +177,7 @@ int (*exec)(unsigned short rc, char *string, unsigned short length); } cmd[] = { + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, { HLLAPI_CMD_GETREVISION, cmd_getrevision } diff --git a/src/pw3270/plugin.c b/src/pw3270/plugin.c index ede142c..0078609 100644 --- a/src/pw3270/plugin.c +++ b/src/pw3270/plugin.c @@ -46,6 +46,9 @@ GError * err = NULL; GList * lst = NULL; + if(!g_file_test(path,G_FILE_TEST_IS_DIR)) + return; + trace("Loading plugins from %s",path); dir = g_dir_open(path,0,&err); -- libgit2 0.21.2