Commit 309193200c6b3f0710c6968beb88f300f70839af
1 parent
28be8394
Exists in
master
and in
5 other branches
Verificando possível segfault no módulo hllapi.
Showing
7 changed files
with
47 additions
and
17 deletions
Show diff stats
configure.ac
| ... | ... | @@ -167,7 +167,6 @@ case "$host" in |
| 167 | 167 | |
| 168 | 168 | AC_CONFIG_FILES(nsi/runtime-init.nsi) |
| 169 | 169 | |
| 170 | - AC_CONFIG_FILES(src/plugins/hllapi/Makefile) | |
| 171 | 170 | AC_CONFIG_FILES(makegtkruntime.sh) |
| 172 | 171 | |
| 173 | 172 | ;; |
| ... | ... | @@ -203,6 +202,9 @@ case "$host" in |
| 203 | 202 | |
| 204 | 203 | esac |
| 205 | 204 | |
| 205 | +# It's easier to test hllapi on linux | |
| 206 | +AC_CONFIG_FILES(src/plugins/hllapi/Makefile) | |
| 207 | + | |
| 206 | 208 | #--[ Check gettext ]------------------------------------------------------------------------------------------------------------------------------------------ |
| 207 | 209 | |
| 208 | 210 | AC_PATH_TOOL([XGETTEXT], [xgettext], [no]) | ... | ... |
src/include/pw3270/hllapi.h
| ... | ... | @@ -113,23 +113,21 @@ extern "C" { |
| 113 | 113 | |
| 114 | 114 | #else |
| 115 | 115 | |
| 116 | - #define HLLAPI_API_CALL __attribute__((visibility("default"))) extern | |
| 117 | - | |
| 118 | 116 | // From wtypesbase.h |
| 119 | - typedef byte BYTE; | |
| 120 | - typedef unsigned short WORD; | |
| 117 | + typedef uint8_t BYTE; | |
| 118 | + typedef uint16_t WORD; | |
| 121 | 119 | typedef unsigned int UINT; |
| 122 | 120 | typedef int INT; |
| 121 | + typedef uint32_t LONG; | |
| 123 | 122 | typedef LONG WINBOOL; |
| 124 | - typedef LONG LONG; | |
| 125 | - typedef ULONG DWORD; | |
| 123 | + typedef uint32_t DWORD; | |
| 126 | 124 | typedef void *HANDLE; |
| 127 | 125 | typedef WORD *LPWORD; |
| 128 | 126 | typedef DWORD *LPDWORD; |
| 129 | 127 | typedef char CHAR; |
| 130 | 128 | typedef CHAR *LPSTR; |
| 131 | 129 | typedef const CHAR *LPCSTR; |
| 132 | - typedef wchar_t WCHAR; | |
| 130 | + typedef char WCHAR; | |
| 133 | 131 | typedef WCHAR TCHAR; |
| 134 | 132 | typedef WCHAR *LPWSTR; |
| 135 | 133 | typedef TCHAR *LPTSTR; |
| ... | ... | @@ -142,6 +140,8 @@ extern "C" { |
| 142 | 140 | #define LPSTR char * |
| 143 | 141 | #define HANDLE int |
| 144 | 142 | |
| 143 | + #define HLLAPI_API_CALL __attribute__((visibility("default"))) extern DWORD | |
| 144 | + | |
| 145 | 145 | #endif // WIN32 |
| 146 | 146 | |
| 147 | 147 | HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); |
| ... | ... | @@ -179,8 +179,6 @@ extern "C" { |
| 179 | 179 | |
| 180 | 180 | HLLAPI_API_CALL hllapi_print(void); |
| 181 | 181 | |
| 182 | - HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); | |
| 183 | - | |
| 184 | 182 | HLLAPI_API_CALL hllapi_init(LPSTR mode); |
| 185 | 183 | HLLAPI_API_CALL hllapi_deinit(void); |
| 186 | 184 | ... | ... |
src/plugins/hllapi/Makefile.in
| ... | ... | @@ -36,6 +36,7 @@ EXTAPI_SRC=calls.c hllapi.c |
| 36 | 36 | #---[ Include plugin rules ]--------------------------------------------------- |
| 37 | 37 | |
| 38 | 38 | CLASSLIBDIR=../../classlib |
| 39 | +LIBS=@LIBS@ | |
| 39 | 40 | |
| 40 | 41 | include ../../include/plugin.mak |
| 41 | 42 | include $(CLASSLIBDIR)/class.mak |
| ... | ... | @@ -47,7 +48,7 @@ $(BINRLS)/$(PLUGIN_NAME): \ |
| 47 | 48 | |
| 48 | 49 | @echo " CCLD `basename $@`" |
| 49 | 50 | @$(MKDIR) `dirname $@` |
| 50 | - @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS) | |
| 51 | + @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(CLASS_LIBS) | |
| 51 | 52 | |
| 52 | 53 | $(BINRLS)$(DLL_NAME).$(VERSION): \ |
| 53 | 54 | $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJRLS)/$(SRC).o) $(CLASS_RELEASE_OBJECTS) |
| ... | ... | @@ -65,7 +66,7 @@ $(BINDBG)/$(PLUGIN_NAME): \ |
| 65 | 66 | |
| 66 | 67 | @echo " CCLD `basename $@`" |
| 67 | 68 | @$(MKDIR) `dirname $@` |
| 68 | - @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ @DBGRPATH@ $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS) | |
| 69 | + @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ @DBGRPATH@ $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(CLASS_LIBS) | |
| 69 | 70 | |
| 70 | 71 | $(BINDBG)$(DLL_NAME).$(VERSION): \ |
| 71 | 72 | $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJDBG)/$(SRC)@OBJEXT@) $(CLASS_DEBUG_OBJECTS) |
| ... | ... | @@ -85,5 +86,5 @@ $(BINDBG)/test@EXEEXT@: \ |
| 85 | 86 | |
| 86 | 87 | @echo " CCLD `basename $@`" |
| 87 | 88 | @$(MKDIR) `dirname $@` |
| 88 | - @$(LD) -o $@ $^ $(LIBS) $(BINDBG)$(DLL_NAME).$(VERSION) | |
| 89 | + $(LD) -o $@ $^ -Wl,-rpath,$(BINDBG)/lib $(LIBS) $(BINDBG)$(DLL_NAME).$(VERSION) | |
| 89 | 90 | ... | ... |
src/plugins/hllapi/calls.cc
| ... | ... | @@ -28,6 +28,9 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <exception> |
| 31 | + #include <cstdlib> | |
| 32 | + #include <cstring> | |
| 33 | + | |
| 31 | 34 | #include <pw3270/class.h> |
| 32 | 35 | #include <pw3270/hllapi.h> |
| 33 | 36 | #include "client.h" |
| ... | ... | @@ -232,6 +235,7 @@ |
| 232 | 235 | |
| 233 | 236 | HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) |
| 234 | 237 | { |
| 238 | + #ifdef _WIN32 | |
| 235 | 239 | HKEY hKey = 0; |
| 236 | 240 | unsigned long datalen = strlen(datadir); |
| 237 | 241 | |
| ... | ... | @@ -244,6 +248,7 @@ |
| 244 | 248 | *datadir = 0; |
| 245 | 249 | RegCloseKey(hKey); |
| 246 | 250 | } |
| 251 | +#endif // _WIN32 | |
| 247 | 252 | |
| 248 | 253 | return *datadir; |
| 249 | 254 | } | ... | ... |
src/plugins/hllapi/hllapi.c
| ... | ... | @@ -85,7 +85,7 @@ |
| 85 | 85 | |
| 86 | 86 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 87 | 87 | |
| 88 | -HLLAPI_API_CALL hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) | |
| 88 | +HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) | |
| 89 | 89 | { |
| 90 | 90 | unsigned int f; |
| 91 | 91 | ... | ... |
src/plugins/hllapi/hllapi.cbp
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | </Linker> |
| 38 | 38 | </Target> |
| 39 | 39 | <Target title="test"> |
| 40 | - <Option output=".bin/Debug/testprogram" prefix_auto="1" extension_auto="1" /> | |
| 40 | + <Option output=".bin/Debug/test" prefix_auto="1" extension_auto="1" /> | |
| 41 | 41 | <Option object_output=".obj/Debug/" /> |
| 42 | 42 | <Option type="1" /> |
| 43 | 43 | <Option compiler="gcc" /> | ... | ... |
src/plugins/hllapi/testprogram.c
| ... | ... | @@ -28,17 +28,42 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <stdio.h> |
| 31 | + #include <string.h> | |
| 31 | 32 | #include <time.h> |
| 32 | 33 | #include <pw3270/hllapi.h> |
| 33 | 34 | |
| 34 | - #define BUFFER_LENGTH 8000 | |
| 35 | + #define MAX_DATA_SIZE 8000 //< Maximum data size for this application. | |
| 36 | + | |
| 37 | + static CHAR hllapi_data[MAX_DATA_SIZE]; | |
| 35 | 38 | |
| 36 | 39 | /*---[ Implement ]--------------------------------------------------------------------------------*/ |
| 37 | 40 | |
| 41 | + static void connect(const char *session) | |
| 42 | + { | |
| 43 | + WORD len; | |
| 44 | + WORD fn = HLLAPI_CMD_CONNECTPS; | |
| 45 | + WORD rc = 0; | |
| 46 | + | |
| 47 | + strncpy(hllapi_data,session,MAX_DATA_SIZE); | |
| 48 | + | |
| 49 | + len = strlen(session); | |
| 50 | + hllapi(&fn,hllapi_data,&len,&rc); | |
| 51 | + | |
| 52 | + if(rc) | |
| 53 | + { | |
| 54 | + fprintf(stderr,"HLLAPI_CMD_CONNECTPS exits with rc=%d",(int) rc); | |
| 55 | + } | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 38 | 59 | int main(int numpar, char *param[]) |
| 39 | 60 | { |
| 40 | 61 | const char *session = "pw3270:a"; |
| 41 | 62 | |
| 63 | + connect(session); | |
| 64 | + | |
| 65 | + /* | |
| 66 | + | |
| 42 | 67 | printf("init(%s)=%d\n",session,(int) hllapi_init((LPSTR) session)); |
| 43 | 68 | printf("revision=%d\n",(int) hllapi_get_revision()); |
| 44 | 69 | printf("connect=%d\n",(int) hllapi_connect((char *) "fandezhi.efglobe.com:23",1)); |
| ... | ... | @@ -50,7 +75,6 @@ |
| 50 | 75 | |
| 51 | 76 | printf("deinit=%d\n",(int) hllapi_deinit()); |
| 52 | 77 | |
| 53 | -/* | |
| 54 | 78 | DWORD revision; |
| 55 | 79 | int rc; |
| 56 | 80 | ... | ... |