Commit 46e2902ffcf3e5997874c2b14f80dbb4fba97c58

Authored by perry.werneck@gmail.com
1 parent 5c12e21e

Padronizando construção do plugin hllapi

src/classlib/remote.cc
... ... @@ -721,8 +721,10 @@
721 721 size_t cbSize = sizeof(struct hllapi_packet_connect);
722 722 struct hllapi_packet_connect * pkt = (struct hllapi_packet_connect *) malloc(cbSize);
723 723  
  724 + memset(pkt,0,cbSize);
  725 +
724 726 pkt->packet_id = HLLAPI_PACKET_CONNECT;
725   - pkt->wait = (unsigned char) wait;
  727 + pkt->wait = 0;
726 728  
727 729 rc = query_intval((void *) pkt,cbSize,true);
728 730  
... ...
src/include/plugin.mak.in
... ... @@ -67,6 +67,7 @@ INSTALL_DATA=@INSTALL_DATA@
67 67 #---[ Rules ]------------------------------------------------------------------
68 68 VERSION=@VERSION@
69 69 DLL_FLAGS=@DLL_FLAGS@
  70 +SYSDLL_FLAGS=@SYSDLL_FLAGS@
70 71 DLL_CFLAGS=@DLL_CFLAGS@
71 72 DEBUG_CFLAGS=-DDEBUG=1 -g -Wall
72 73 LIB3270_MODE ?= Default
... ... @@ -128,10 +129,11 @@ Debug: $(BINDBG)/$(PLUGIN_NAME)
128 129  
129 130 $(BINDBG)$(DLL_NAME): $(BINDBG)$(DLL_NAME).$(VERSION)
130 131 @rm -f $@
131   - @cd $(BINDBG)@DLLDIR@ && $(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@
  132 + $(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) $@
132 133  
133 134 $(BINRLS)$(DLL_NAME): $(BINRLS)$(DLL_NAME).$(VERSION)
134 135 @rm -f $@
  136 + @rm -f $(BINRLS)@DLLDIR@/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@
135 137 @cd $(BINRLS)@DLLDIR@ && $(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@
136 138  
137 139 clean:
... ...
src/include/pw3270/hllapi.h
... ... @@ -68,69 +68,69 @@ extern "C" {
68 68  
69 69 #define HLLAPI_STATUS_WAITING HLLAPI_STATUS_TIMEOUT
70 70  
71   -#ifdef _WIN32
  71 + #ifdef WIN32
  72 + #include <windows.h>
  73 +
72 74 // http://www.mingw.org/wiki/Visual_Basic_DLL
73   - __declspec (dllexport) int __stdcall hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
74   -
75   - __declspec (dllexport) DWORD __stdcall hllapi_init(LPSTR mode);
76   - __declspec (dllexport) DWORD __stdcall hllapi_deinit(void);
77   -
78   - __declspec (dllexport) DWORD __stdcall hllapi_get_revision(void);
79   - __declspec (dllexport) DWORD __stdcall hllapi_get_datadir(LPSTR datadir);
80   -
81   - __declspec (dllexport) DWORD __stdcall hllapi_connect(LPSTR uri, WORD wait);
82   - __declspec (dllexport) DWORD __stdcall hllapi_disconnect(void);
83   - __declspec (dllexport) DWORD __stdcall hllapi_get_message_id(void);
84   - __declspec (dllexport) DWORD __stdcall hllapi_is_connected(void);
85   - __declspec (dllexport) DWORD __stdcall hllapi_get_state(void);
86   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
87   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
88   - __declspec (dllexport) DWORD __stdcall hllapi_enter(void);
89   - __declspec (dllexport) DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text);
90   - __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
91   - __declspec (dllexport) DWORD __stdcall hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting);
92   - __declspec (dllexport) DWORD __stdcall hllapi_wait_for_ready(WORD seconds);
93   - __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds);
94   - __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key);
95   - __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key);
96   - __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD key);
97   - __declspec (dllexport) DWORD __stdcall hllapi_getcursor();
98   - __declspec (dllexport) DWORD __stdcall hllapi_erase_eof(void);
99   - __declspec (dllexport) DWORD __stdcall hllapi_print(void);
100   -
101   -#else
102   -
103   - typedef unsigned short DWORD
104   -
105   - LIB3270_EXPORT int __stdcall hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
106   -
107   - LIB3270_EXPORT DWORD __stdcall hllapi_init(LPSTR mode);
108   - LIB3270_EXPORT DWORD __stdcall hllapi_deinit(void);
109   -
110   - LIB3270_EXPORT DWORD __stdcall hllapi_get_revision(void);
111   - LIB3270_EXPORT DWORD __stdcall hllapi_get_datadir(LPSTR datadir);
112   -
113   - LIB3270_EXPORT DWORD __stdcall hllapi_connect(LPSTR uri, WORD wait);
114   - LIB3270_EXPORT DWORD __stdcall hllapi_disconnect(void);
115   - LIB3270_EXPORT DWORD __stdcall hllapi_get_message_id(void);
116   - LIB3270_EXPORT DWORD __stdcall hllapi_is_connected(void);
117   - LIB3270_EXPORT DWORD __stdcall hllapi_get_state(void);
118   - LIB3270_EXPORT DWORD __stdcall hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
119   - LIB3270_EXPORT DWORD __stdcall hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
120   - LIB3270_EXPORT DWORD __stdcall hllapi_enter(void);
121   - LIB3270_EXPORT DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text);
122   - LIB3270_EXPORT DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
123   - LIB3270_EXPORT DWORD __stdcall hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting);
124   - LIB3270_EXPORT DWORD __stdcall hllapi_wait_for_ready(WORD seconds);
125   - LIB3270_EXPORT DWORD __stdcall hllapi_wait(WORD seconds);
126   - LIB3270_EXPORT DWORD __stdcall hllapi_pfkey(WORD key);
127   - LIB3270_EXPORT DWORD __stdcall hllapi_pakey(WORD key);
128   - LIB3270_EXPORT DWORD __stdcall hllapi_setcursor(WORD key);
129   - LIB3270_EXPORT DWORD __stdcall hllapi_getcursor();
130   - LIB3270_EXPORT DWORD __stdcall hllapi_erase_eof(void);
131   - LIB3270_EXPORT DWORD __stdcall hllapi_print(void);
132   -
133   -#endif // _WIN32
  75 + #define HLLAPI_API_CALL __declspec (dllexport) DWORD __stdcall
  76 +
  77 + #endif // WIN32
  78 +
  79 + HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
  80 +
  81 + HLLAPI_API_CALL hllapi_init(LPSTR mode);
  82 + HLLAPI_API_CALL hllapi_deinit(void);
  83 +
  84 + HLLAPI_API_CALL hllapi_get_revision(void);
  85 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir);
  86 +
  87 + HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait);
  88 + HLLAPI_API_CALL hllapi_disconnect(void);
  89 + HLLAPI_API_CALL hllapi_get_message_id(void);
  90 + HLLAPI_API_CALL hllapi_is_connected(void);
  91 + HLLAPI_API_CALL hllapi_get_state(void);
  92 + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
  93 + HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
  94 + HLLAPI_API_CALL hllapi_enter(void);
  95 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
  96 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
  97 + HLLAPI_API_CALL hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting);
  98 + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
  99 + HLLAPI_API_CALL hllapi_wait(WORD seconds);
  100 + HLLAPI_API_CALL hllapi_pfkey(WORD key);
  101 + HLLAPI_API_CALL hllapi_pakey(WORD key);
  102 + HLLAPI_API_CALL hllapi_setcursor(WORD key);
  103 + HLLAPI_API_CALL hllapi_getcursor();
  104 + HLLAPI_API_CALL hllapi_erase_eof(void);
  105 + HLLAPI_API_CALL hllapi_print(void);
  106 +
  107 + HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
  108 +
  109 + HLLAPI_API_CALL hllapi_init(LPSTR mode);
  110 + HLLAPI_API_CALL hllapi_deinit(void);
  111 +
  112 + HLLAPI_API_CALL hllapi_get_revision(void);
  113 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir);
  114 +
  115 + HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait);
  116 + HLLAPI_API_CALL hllapi_disconnect(void);
  117 + HLLAPI_API_CALL hllapi_get_message_id(void);
  118 + HLLAPI_API_CALL hllapi_is_connected(void);
  119 + HLLAPI_API_CALL hllapi_get_state(void);
  120 + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
  121 + HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
  122 + HLLAPI_API_CALL hllapi_enter(void);
  123 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
  124 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
  125 + HLLAPI_API_CALL hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting);
  126 + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
  127 + HLLAPI_API_CALL hllapi_wait(WORD seconds);
  128 + HLLAPI_API_CALL hllapi_pfkey(WORD key);
  129 + HLLAPI_API_CALL hllapi_pakey(WORD key);
  130 + HLLAPI_API_CALL hllapi_setcursor(WORD key);
  131 + HLLAPI_API_CALL hllapi_getcursor();
  132 + HLLAPI_API_CALL hllapi_erase_eof(void);
  133 + HLLAPI_API_CALL hllapi_print(void);
134 134  
135 135 #ifdef __cplusplus
136 136 } /* end of extern "C" */
... ...
src/plugins/hllapi/Makefile.in
... ... @@ -31,127 +31,38 @@
31 31 MODULE_NAME=hllapi
32 32 DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
33 33 PLUGIN_SRC=pluginmain.c
34   -HLLAPI_SRC=hllapi.c calls.c
  34 +EXTAPI_SRC=calls.c hllapi.c
35 35  
36   -CLASSLIBDIR=../../classlib
37   -
38   -#---[ Paths ]------------------------------------------------------------------
39   -
40   -ROOTDIR ?= .
41   -OBJDIR ?= $(ROOTDIR)/.obj
42   -BINDIR ?= $(ROOTDIR)/.bin
43   -BINDBG ?= $(BINDIR)/Debug
44   -BINRLS ?= $(BINDIR)/Release
45   -
46   -OBJDBG = $(OBJDIR)/Debug
47   -OBJRLS = $(OBJDIR)/Release
48   -OBJEXT = o
49   -
50   -#---[ Tools ]------------------------------------------------------------------
51   -
52   -MKDIR=@MKDIR_P@
53   -CC=@CXX@
54   -CXX=@CXX@
55   -LD=@CXX@
56   -MSGCAT=@MSGCAT@
57   -XGETTEXT=@XGETTEXT@
58   -
59   -#---[ Rules ]------------------------------------------------------------------
60   -
61   -DLL_FLAGS=@DLL_FLAGS@
62   -SYSDLL_FLAGS=@SYSDLL_FLAGS@
  36 +#---[ Include plugin rules ]---------------------------------------------------
63 37  
64   -DEBUG_CFLAGS=-DDEBUG=1 -g -Wall
65   -
66   -LIB3270_MODE ?= Default
67   -
68   -ifeq ($(LIB3270_MODE),Debug)
69   - PW3270_CFLAGS=-I../../../src/include
70   - LIB3270_CFLAGS=-I../../../src/include
71   -endif
72   -
73   -ifeq ($(LIB3270_MODE),Release)
74   - PW3270_CFLAGS=-I../../../src/include
75   - LIB3270_CFLAGS=-I../../../src/include
76   -endif
77   -
78   -ifeq ($(LIB3270_MODE),Default)
79   - LIB3270_CFLAGS ?= `pkg-config --cflags lib3270`
80   - PW3270_CFLAGS ?= `pkg-config --cflags pw3270 lib3270`
81   -endif
82   -
83   -GTK_CFLAGS ?= @GTK_CFLAGS@ @GTKMAC_CFLAGS@
84   -GTK_LIBS ?= @GTK_LIBS@ @GTKMAC_LIBS@
  38 +CLASSLIBDIR=../../classlib
85 39  
  40 +include ../../include/plugin.mak
86 41 include $(CLASSLIBDIR)/class.mak
87 42  
88   -$(OBJDBG)/%.o: %.cc $(DEPENDS)
89   - @echo " CC `basename $@`"
90   - @$(MKDIR) `dirname $@`
91   - @$(CXX) $(CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
  43 +#---[ Release Targets ]--------------------------------------------------------
92 44  
93   -$(OBJDBG)/%.o: %.c $(DEPENDS)
94   - @echo " CC `basename $@`"
95   - @$(MKDIR) `dirname $@`
96   - @$(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
97   -
98   -$(OBJRLS)/%.o: %.cc $(DEPENDS)
99   - @echo " CC `basename $@`"
100   - @$(MKDIR) `dirname $@`
101   - @$(CXX) $(CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
102   -
103   -$(OBJRLS)/%.o: %.c $(DEPENDS)
104   - @echo " CC `basename $@`"
105   - @$(MKDIR) `dirname $@`
106   - @$(CC) $(CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
107   -
108   -
109   -#---[ Release targets ]--------------------------------------------------------
110   -
111   -Release: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINRLS)/libhllapi@DLLEXT@
112   -
113   -$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o)
  45 +$(BINRLS)/$(PLUGIN_NAME): $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) $(BINRLS)$(DLL_NAME)
114 46 @echo " CCLD `basename $@`"
115 47 @$(MKDIR) `dirname $@`
116   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
  48 + $(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS)
117 49  
118   -$(BINRLS)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJRLS)/$(SRC).o) $(CLASS_RELEASE_OBJECTS)
  50 +$(BINRLS)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJRLS)/$(SRC).o) $(CLASS_RELEASE_OBJECTS)
119 51 @echo " CCLD `basename $@`"
120 52 @$(MKDIR) `dirname $@`
121   - @$(LD) $(SYSDLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS)
  53 + @$(CXX) $(SYSDLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(CLASS_LIBS)
122 54  
123   -#---[ Debug targets ]----------------------------------------------------------
  55 +install:
124 56  
125   -Debug: $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINDBG)/libhllapi@DLLEXT@
  57 +#---[ Debug Targets ]----------------------------------------------------------
126 58  
127   -$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o)
  59 +$(BINDBG)/$(PLUGIN_NAME): $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o) $(BINDBG)$(DLL_NAME)
128 60 @echo " CCLD `basename $@`"
129 61 @$(MKDIR) `dirname $@`
130   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
  62 + @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ @DBGRPATH@ $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS)
131 63  
132   -$(BINDBG)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(SRC).o) $(CLASS_DEBUG_OBJECTS)
  64 +$(BINDBG)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJDBG)/$(SRC)@OBJEXT@) $(CLASS_DEBUG_OBJECTS)
133 65 @echo " CCLD `basename $@`"
134 66 @$(MKDIR) `dirname $@`
135   - @$(LD) $(SYSDLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS) $(CLASS_LIBS)
136   -
137   -#---[ Misc targets ]-----------------------------------------------------------
138   -
139   -$(BINDBG)/testprogram@EXEEXT@: $(OBJDBG)/testprogram.o $(BINDBG)/libhllapi@DLLEXT@
140   - @echo " CCLD `basename $@`"
141   - @$(MKDIR) `dirname $@`
142   - @$(CXX) $(CFLAGS) $(PW3270_CFLAGS) -L$(BINDBG) $(DEBUG_CFLAGS) -lhllapi -o $@ $(OBJDBG)/testprogram.o
143   -
144   -test: $(BINDBG)/testprogram@EXEEXT@
145   -
146   -run: $(BINDBG)/testprogram@EXEEXT@
147   - @cd $(BINDBG) ; ./testprogram@EXEEXT@
148   -
149   -install: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@
150   - @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
151   - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
  67 + $(CXX) $(SYSDLL_FLAGS) $(LDFLAGS) @LDSOFLAGS@ @DBGRPATH@ -o $@ $^ $(CLASS_LIBS)
152 68  
153   -clean:
154   - @rm -fr $(OBJDIR)
155   - @rm -fr $(BINDIR)
156   - @rm -f testprogram@EXEEXT@
157   - @find . -name "*~" -exec rm -f {} \;
... ...
src/plugins/hllapi/calls.cc
... ... @@ -42,7 +42,7 @@
42 42  
43 43 /*--[ Implement ]------------------------------------------------------------------------------------*/
44 44  
45   - __declspec (dllexport) DWORD __stdcall hllapi_init(LPSTR mode)
  45 + HLLAPI_API_CALL hllapi_init(LPSTR mode)
46 46 {
47 47 trace("%s(%s)",__FUNCTION__,mode);
48 48  
... ... @@ -62,7 +62,7 @@
62 62 return hSession ? HLLAPI_STATUS_SUCCESS : HLLAPI_STATUS_SYSTEM_ERROR;
63 63 }
64 64  
65   - __declspec (dllexport) DWORD __stdcall hllapi_deinit(void)
  65 + HLLAPI_API_CALL hllapi_deinit(void)
66 66 {
67 67 trace("%s()",__FUNCTION__);
68 68  
... ... @@ -82,7 +82,7 @@
82 82 return HLLAPI_STATUS_SUCCESS;
83 83 }
84 84  
85   - __declspec (dllexport) DWORD __stdcall hllapi_get_revision(void)
  85 + HLLAPI_API_CALL hllapi_get_revision(void)
86 86 {
87 87 try
88 88 {
... ... @@ -95,7 +95,7 @@
95 95 return (DWORD) -1;
96 96 }
97 97  
98   - __declspec (dllexport) DWORD __stdcall hllapi_connect(LPSTR uri, WORD wait)
  98 + HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait)
99 99 {
100 100 int rc = HLLAPI_STATUS_SUCCESS;
101 101  
... ... @@ -111,12 +111,12 @@
111 111 return rc;
112 112 }
113 113  
114   - __declspec (dllexport) DWORD __stdcall hllapi_is_connected(void)
  114 + HLLAPI_API_CALL hllapi_is_connected(void)
115 115 {
116 116 return session::get_default()->is_connected();
117 117 }
118 118  
119   - __declspec (dllexport) DWORD __stdcall hllapi_get_state(void)
  119 + HLLAPI_API_CALL hllapi_get_state(void)
120 120 {
121 121 switch(hllapi_get_message_id())
122 122 {
... ... @@ -146,28 +146,28 @@
146 146 return HLLAPI_STATUS_SYSTEM_ERROR;
147 147 }
148 148  
149   - __declspec (dllexport) DWORD __stdcall hllapi_disconnect(void)
  149 + HLLAPI_API_CALL hllapi_disconnect(void)
150 150 {
151 151 session::get_default()->disconnect();
152 152 return HLLAPI_STATUS_SUCCESS;
153 153 }
154 154  
155   - __declspec (dllexport) DWORD __stdcall hllapi_wait_for_ready(WORD seconds)
  155 + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds)
156 156 {
157 157 return session::get_default()->wait_for_ready(seconds);
158 158 }
159 159  
160   - __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds)
  160 + HLLAPI_API_CALL hllapi_wait(WORD seconds)
161 161 {
162 162 return session::get_default()->wait(seconds);
163 163 }
164 164  
165   - __declspec (dllexport) DWORD __stdcall hllapi_get_message_id(void)
  165 + HLLAPI_API_CALL hllapi_get_message_id(void)
166 166 {
167 167 return session::get_default()->get_cstate();
168 168 }
169 169  
170   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
  170 + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
171 171 {
172 172 if(!(buffer && *buffer))
173 173 return HLLAPI_STATUS_SYSTEM_ERROR;
... ... @@ -186,12 +186,12 @@
186 186 return HLLAPI_STATUS_SUCCESS;
187 187 }
188 188  
189   - __declspec (dllexport) DWORD __stdcall hllapi_enter(void)
  189 + HLLAPI_API_CALL hllapi_enter(void)
190 190 {
191 191 return session::get_default()->enter();
192 192 }
193 193  
194   - __declspec (dllexport) DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text)
  194 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text)
195 195 {
196 196 try
197 197 {
... ... @@ -205,7 +205,7 @@
205 205 return HLLAPI_STATUS_SUCCESS;
206 206 }
207 207  
208   - __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
  208 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
209 209 {
210 210 int rc = HLLAPI_STATUS_SYSTEM_ERROR;
211 211 try
... ... @@ -220,17 +220,17 @@
220 220 return rc;
221 221 }
222 222  
223   - __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key)
  223 + HLLAPI_API_CALL hllapi_pfkey(WORD key)
224 224 {
225 225 return session::get_default()->pfkey(key);
226 226 }
227 227  
228   - __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key)
  228 + HLLAPI_API_CALL hllapi_pakey(WORD key)
229 229 {
230 230 return session::get_default()->pakey(key);
231 231 }
232 232  
233   - __declspec (dllexport) DWORD __stdcall hllapi_get_datadir(LPSTR datadir)
  233 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir)
234 234 {
235 235 HKEY hKey = 0;
236 236 unsigned long datalen = strlen(datadir);
... ... @@ -248,17 +248,17 @@
248 248 return *datadir;
249 249 }
250 250  
251   - __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD pos)
  251 + HLLAPI_API_CALL hllapi_setcursor(WORD pos)
252 252 {
253 253 return session::get_default()->set_cursor_addr(pos-1);
254 254 }
255 255  
256   - __declspec (dllexport) DWORD __stdcall hllapi_getcursor()
  256 + HLLAPI_API_CALL hllapi_getcursor()
257 257 {
258 258 return session::get_default()->get_cursor_addr()+1;
259 259 }
260 260  
261   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen(WORD offset, LPSTR buffer, WORD len)
  261 + HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len)
262 262 {
263 263 int rc = HLLAPI_STATUS_SYSTEM_ERROR;
264 264  
... ... @@ -284,19 +284,19 @@
284 284 return rc;
285 285 }
286 286  
287   - __declspec (dllexport) DWORD __stdcall hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting)
  287 + HLLAPI_API_CALL hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting)
288 288 {
289 289 session::get_default()->emulate_input(buffer);
290 290 return HLLAPI_STATUS_SUCCESS;
291 291 }
292 292  
293   - __declspec (dllexport) DWORD __stdcall hllapi_erase_eof(void)
  293 + HLLAPI_API_CALL hllapi_erase_eof(void)
294 294 {
295 295 session::get_default()->erase_eof();
296 296 return HLLAPI_STATUS_SUCCESS;
297 297 }
298 298  
299   - __declspec (dllexport) DWORD __stdcall hllapi_print(void)
  299 + HLLAPI_API_CALL hllapi_print(void)
300 300 {
301 301 return session::get_default()->print();
302 302 }
... ...
src/plugins/hllapi/client.h
... ... @@ -27,7 +27,6 @@
27 27 *
28 28 */
29 29  
30   - #include <windows.h>
31 30 #include <pw3270/hllapi.h>
32 31  
33 32 #ifndef ETIMEDOUT
... ... @@ -43,9 +42,14 @@
43 42 #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }
44 43 #endif // DEBUG
45 44  
  45 + #ifdef __cplusplus
  46 + extern "C" {
  47 + #endif
  48 +
  49 +/*
46 50 void * hllapi_pipe_init(const char *id);
47 51 void hllapi_pipe_deinit(void *h);
48   - const char * hllapi_pipe_get_revision(void);
  52 + const char * hllapi_pipe_get_revision(void);
49 53 void hllapi_pipe_release_memory(void *p);
50 54 int hllapi_pipe_connect(void *h, const char *n, int wait);
51 55 void hllapi_pipe_disconnect(void *h);
... ... @@ -65,9 +69,13 @@
65 69 int hllapi_pipe_setcursor(void *h, int baddr);
66 70 int hllapi_pipe_emulate_input(void *hSession, const char *s, int len, int pasting);
67 71 int hllapi_pipe_print(void *h);
  72 +*/
68 73  
69 74 char * hllapi_get_string(int offset, size_t len);
70 75 void hllapi_free(void *p);
71 76  
  77 + #ifdef __cplusplus
  78 + } /* end of extern "C" */
  79 + #endif
72 80  
73 81  
... ...
src/plugins/hllapi/hllapi.c
... ... @@ -85,11 +85,7 @@
85 85  
86 86 /*--[ Implement ]------------------------------------------------------------------------------------*/
87 87  
88   -#ifdef _WIN32
89   - __declspec (dllexport) int __stdcall hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
90   -#else
91   - LIB3270_EXPORT int hllapi(const unsigned long *func, char *buffer, unsigned short *length, unsigned short *rc)
92   -#endif // _WIN32
  88 +HLLAPI_API_CALL hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
93 89 {
94 90 unsigned int f;
95 91  
... ...
src/plugins/hllapi/pipesource.c
... ... @@ -1,385 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como pipesource.c e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include <pw3270.h>
33   - #include <pw3270/v3270.h>
34   -
35   - #include <windows.h>
36   - #include <stdarg.h>
37   - #include "remotectl.h"
38   -
39   -/*---[ Defines ]----------------------------------------------------------------------------*/
40   -
41   - #pragma pack(1)
42   -
43   - typedef struct _pipe_source
44   - {
45   - GSource gsrc;
46   - HANDLE hPipe;
47   -
48   - enum _PIPE_STATE
49   - {
50   - PIPE_STATE_WAITING,
51   - PIPE_STATE_READ,
52   - PIPE_STATE_PENDING_READ,
53   -
54   - PIPE_STATE_UNDEFINED,
55   - } state;
56   -
57   - OVERLAPPED overlap;
58   - unsigned char buffer[PIPE_BUFFER_LENGTH+1];
59   - } pipe_source;
60   -
61   - #pragma pack()
62   -
63   -/*---[ GSource ]----------------------------------------------------------------------------*/
64   -
65   -static void wait_for_client(pipe_source *source)
66   -{
67   - set_active(FALSE);
68   - if(ConnectNamedPipe(source->hPipe,&source->overlap))
69   - {
70   - popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
71   - return;
72   - }
73   -
74   - switch(GetLastError())
75   - {
76   - // The overlapped connection in progress.
77   - case ERROR_IO_PENDING:
78   - // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
79   - source->state = PIPE_STATE_WAITING;
80   - break;
81   -
82   - // Client is already connected, so signal an event.
83   - case ERROR_PIPE_CONNECTED:
84   - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
85   - set_active(TRUE);
86   - if(SetEvent(source->overlap.hEvent))
87   - break;
88   -
89   - // If an error occurs during the connect operation...
90   - default:
91   - popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
92   - }
93   -
94   - }
95   -
96   - static gboolean IO_prepare(GSource *source, gint *timeout)
97   - {
98   - /*
99   - * Called before all the file descriptors are polled.
100   - * If the source can determine that it is ready here
101   - * (without waiting for the results of the poll() call)
102   - * it should return TRUE.
103   - *
104   - * It can also return a timeout_ value which should be the maximum
105   - * timeout (in milliseconds) which should be passed to the poll() call.
106   - * The actual timeout used will be -1 if all sources returned -1,
107   - * or it will be the minimum of all the timeout_ values
108   - * returned which were >= 0.
109   - *
110   - */
111   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
112   - {
113   - // trace("%s: source=%p",__FUNCTION__,source);
114   - return TRUE;
115   - }
116   -
117   - *timeout = 10;
118   - return FALSE;
119   - }
120   -
121   - static gboolean IO_check(GSource *source)
122   - {
123   - /*
124   - * Called after all the file descriptors are polled.
125   - * The source should return TRUE if it is ready to be dispatched.
126   - * Note that some time may have passed since the previous prepare
127   - * function was called, so the source should be checked again here.
128   - *
129   - */
130   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
131   - return TRUE;
132   -
133   - return FALSE;
134   - }
135   -
136   - static void process_input(pipe_source *source, DWORD cbRead)
137   - {
138   - HLLAPI_DATA * data = (HLLAPI_DATA *) source->buffer;
139   - QUERY * qry = g_malloc0(sizeof(QUERY)+cbRead+1);
140   -
141   - qry->hPipe = source->hPipe;
142   - qry->text = (const gchar *) (qry+1);
143   -
144   - if(data->id == HLLAPI_REQUEST_QUERY)
145   - {
146   - // HLLAPI query
147   - qry->cmd = (int) data->func;
148   - qry->pos = (int) data->rc;
149   - qry->length = data->value;
150   - memcpy((gchar *)(qry->text),data->string,qry->length);
151   - }
152   - else
153   - {
154   - qry->cmd = -1;
155   - }
156   -
157   - enqueue_request(qry);
158   - }
159   -
160   - void request_complete(QUERY *qry, int rc, const gchar *text)
161   - {
162   - request_buffer(qry,rc,strlen(text),(const gpointer) text);
163   - }
164   -
165   - void request_status(QUERY *qry, int rc)
166   - {
167   - if(rc)
168   - {
169   - const gchar *msg = strerror(rc);
170   - request_buffer(qry, rc, strlen(msg), (const gpointer) msg);
171   - }
172   - else
173   - {
174   - request_buffer(qry, rc, 0, NULL);
175   - }
176   - }
177   -
178   - void request_value(QUERY *qry, int rc, unsigned int value)
179   - {
180   - HLLAPI_DATA data;
181   -
182   - memset(&data,0,sizeof(data));
183   - data.id = HLLAPI_RESPONSE_VALUE;
184   - data.func = qry->cmd;
185   - data.rc = rc;
186   - data.value = value;
187   -
188   -#ifdef WIN32
189   - {
190   - DWORD wrote = sizeof(data);
191   - WriteFile(qry->hPipe,&data,wrote,&wrote,NULL);
192   - trace("Wrote=%d len=%d",(int) wrote, sizeof(data));
193   - }
194   -#endif // WIN32
195   -
196   - g_free(qry);
197   -
198   -
199   - }
200   -
201   - void request_buffer(QUERY *qry, int rc, size_t szBuffer, const gpointer buffer)
202   - {
203   - size_t sz;
204   - HLLAPI_DATA *data;
205   -
206   - if(buffer)
207   - {
208   - sz = sizeof(HLLAPI_DATA)+szBuffer;
209   - data = g_malloc0(sz);
210   - data->id = HLLAPI_RESPONSE_TEXT;
211   - memcpy(data->string,buffer,szBuffer);
212   - }
213   - else
214   - {
215   - sz = sizeof(HLLAPI_DATA);
216   - data = g_malloc0(sz);
217   - data->id = HLLAPI_RESPONSE_VALUE;
218   - }
219   -
220   - data->func = qry->cmd;
221   - data->rc = rc;
222   - data->value = szBuffer;
223   -
224   - trace("rc=%d data->len=%d",rc,(int) szBuffer);
225   -
226   -#ifdef WIN32
227   - {
228   - DWORD wrote = sz;
229   - WriteFile(qry->hPipe,data,wrote,&wrote,NULL);
230   - trace("Wrote=%d len=%d",(int) wrote, (int) sz);
231   - }
232   -#endif // WIN32
233   -
234   - g_free(data);
235   - g_free(qry);
236   -
237   - }
238   -
239   - static void read_input_pipe(pipe_source *source)
240   - {
241   - DWORD cbRead = 0;
242   -
243   - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
244   - process_input(source,cbRead);
245   -
246   - // The read operation is still pending.
247   - switch(GetLastError())
248   - {
249   - case 0:
250   - break;
251   -
252   - case ERROR_IO_PENDING:
253   - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
254   - source->state = PIPE_STATE_PENDING_READ;
255   - break;
256   -
257   - case ERROR_PIPE_LISTENING:
258   - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
259   - source->state = PIPE_STATE_READ;
260   - break;
261   -
262   - case ERROR_BROKEN_PIPE:
263   - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
264   -
265   - if(!DisconnectNamedPipe(source->hPipe))
266   - {
267   - set_active(FALSE);
268   - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
269   - }
270   - else
271   - {
272   - wait_for_client(source);
273   - }
274   - break;
275   -
276   - case ERROR_PIPE_NOT_CONNECTED:
277   - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
278   - set_active(FALSE);
279   - break;
280   -
281   - default:
282   - if(source->hPipe != INVALID_HANDLE_VALUE)
283   - popup_lasterror("%s",_( "Error receiving message from pipe" ) );
284   - }
285   -
286   - }
287   -
288   - static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data)
289   - {
290   - /*
291   - * Called to dispatch the event source,
292   - * after it has returned TRUE in either its prepare or its check function.
293   - * The dispatch function is passed in a callback function and data.
294   - * The callback function may be NULL if the source was never connected
295   - * to a callback using g_source_set_callback(). The dispatch function
296   - * should call the callback function with user_data and whatever additional
297   - * parameters are needed for this type of event source.
298   - */
299   - BOOL fSuccess;
300   - DWORD cbRead = 0;
301   -// DWORD dwErr = 0;
302   -
303   - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
304   -
305   - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
306   -
307   - switch(((pipe_source *) source)->state)
308   - {
309   - case PIPE_STATE_WAITING:
310   - if(fSuccess)
311   - {
312   - trace("Pipe connected (cbRet=%d)",(int) cbRead);
313   - set_active(TRUE);
314   - ((pipe_source *) source)->state = PIPE_STATE_READ;
315   - }
316   - else
317   - {
318   - popup_lasterror("%s", _( "Pipe connection failed" ));
319   - }
320   - break;
321   -
322   - case PIPE_STATE_READ:
323   - // trace("Reading pipe (cbRead=%d)",(int) cbRead);
324   - read_input_pipe( (pipe_source *) source);
325   - break;
326   -
327   - case PIPE_STATE_PENDING_READ:
328   - if(fSuccess && cbRead > 0)
329   - process_input((pipe_source *) source,cbRead);
330   - ((pipe_source *) source)->state = PIPE_STATE_READ;
331   - break;
332   -
333   -//#ifdef DEBUG
334   -// default:
335   -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
336   -//#endif
337   - }
338   -
339   - return TRUE;
340   - }
341   -
342   - static void IO_finalize(GSource *source)
343   - {
344   -// trace("%s: source=%p",__FUNCTION__,source);
345   -
346   - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
347   - {
348   - CloseHandle(((pipe_source *) source)->hPipe);
349   - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
350   - }
351   -
352   - }
353   -
354   - static gboolean IO_closure(gpointer data)
355   - {
356   -// trace("%s: data=%p",__FUNCTION__,data);
357   - return 0;
358   - }
359   -
360   -
361   - void init_source_pipe(HANDLE hPipe)
362   - {
363   - static GSourceFuncs pipe_source_funcs =
364   - {
365   - IO_prepare,
366   - IO_check,
367   - IO_dispatch,
368   - IO_finalize,
369   - IO_closure,
370   - NULL
371   - };
372   -
373   - pipe_source *source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
374   -
375   - source->hPipe = hPipe;
376   - source->state = PIPE_STATE_WAITING;
377   - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
378   -
379   - g_source_attach((GSource *) source,NULL);
380   -
381   - wait_for_client(source);
382   -
383   - return;
384   - }
385   -
src/plugins/hllapi/pluginmain.c
... ... @@ -144,6 +144,7 @@
144 144 {
145 145 struct hllapi_packet_text *pkt;
146 146 DWORD szBlock;
  147 + int f;
147 148  
148 149 if(text)
149 150 {
... ... @@ -161,7 +162,7 @@
161 162 }
162 163  
163 164 trace("szBlock=%d text=\"%s\"",szBlock, ( (struct hllapi_packet_text *) pkt)->text);
164   - for(int f=0;f< (int) szBlock;f++)
  165 + for(f=0;f< (int) szBlock;f++)
165 166 {
166 167 trace("rsp(%d)= %d \"%s\"",f,* (((char *) pkt)+f),((char *) pkt)+f);
167 168 }
... ...
src/plugins/hllapi/remote.c
... ... @@ -1,372 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como calls.c e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - *
28   - */
29   -
30   - #include <lib3270.h>
31   - #include <malloc.h>
32   - #include <string.h>
33   - #include <errno.h>
34   - #include <stdio.h>
35   - #include <time.h>
36   - #include <lib3270/log.h>
37   - #include <pw3270/ipcpackets.h>
38   -
39   - #include "client.h"
40   -
41   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
42   -
43   -/*--[ Implement ]------------------------------------------------------------------------------------*/
44   -
45   - void * hllapi_pipe_init(const char *id)
46   - {
47   - HANDLE hPipe = INVALID_HANDLE_VALUE;
48   - static DWORD dwMode = PIPE_READMODE_MESSAGE;
49   - char buffer[4096];
50   - char * name = strdup(id);
51   - char * ptr;
52   -
53   - trace("%s(%s)",__FUNCTION__,id);
54   -
55   - for(ptr=name;*ptr;ptr++)
56   - {
57   - if(*ptr == ':')
58   - *ptr = '_';
59   - }
60   -
61   - snprintf(buffer,4095,"\\\\.\\pipe\\%s",name);
62   -
63   - free(name);
64   -
65   - trace("Opening \"%s\"",buffer);
66   -
67   - if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT))
68   - {
69   - trace("%s: Pipe not found",__FUNCTION__);
70   - errno = ENOENT;
71   - return NULL;
72   - }
73   -
74   - hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
75   -
76   - if(hPipe == INVALID_HANDLE_VALUE)
77   - {
78   - errno = GetLastError();
79   - return NULL;
80   - }
81   -
82   - if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL))
83   - {
84   - errno = GetLastError();
85   - return NULL;
86   - }
87   -
88   - trace("hPipe=%p",(void *) hPipe);
89   - return hPipe;
90   - }
91   -
92   - void hllapi_pipe_deinit(void *h)
93   - {
94   - trace("%s(%p)",__FUNCTION__,h);
95   -
96   - if(!h)
97   - return;
98   -
99   - CloseHandle((HANDLE) h);
100   - }
101   -
102   - const char * hllapi_pipe_get_revision(void)
103   - {
104   - return PACKAGE_REVISION;
105   - }
106   -
107   - int hllapi_pipe_connect(void *h, const char *n, int wait)
108   - {
109   - struct hllapi_packet_connect * pkt;
110   - struct hllapi_packet_result response;
111   - DWORD cbSize;
112   -
113   - if(!n)
114   - n = "";
115   -
116   - cbSize = sizeof(struct hllapi_packet_connect)+strlen(n);
117   - pkt = malloc(cbSize);
118   -
119   - pkt->packet_id = HLLAPI_PACKET_CONNECT;
120   - pkt->wait = (unsigned char) wait;
121   - strcpy(pkt->hostname,n);
122   -
123   - trace("Sending %s",pkt->hostname);
124   -
125   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL))
126   - {
127   - errno = GetLastError();
128   - response.rc = -1;
129   - }
130   -
131   - free(pkt);
132   -
133   - return response.rc;
134   - }
135   -
136   - void hllapi_pipe_disconnect(void *h)
137   - {
138   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT };
139   - struct hllapi_packet_result response;
140   - DWORD cbSize = sizeof(query);
141   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
142   - }
143   -
144   - LIB3270_MESSAGE hllapi_pipe_get_message(void *h)
145   - {
146   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_PROGRAM_MESSAGE };
147   - struct hllapi_packet_result response;
148   - DWORD cbSize = sizeof(query);
149   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
150   - return (LIB3270_MESSAGE) response.rc;
151   - }
152   -
153   - char * hllapi_pipe_get_text_at(void *h, int row, int col, int len)
154   - {
155   - struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, row, col, len };
156   - struct hllapi_packet_text * response;
157   - DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
158   - char * text = NULL;
159   -
160   - response = malloc(cbSize+2);
161   - memset(response,0,cbSize+2);
162   -
163   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL))
164   - return NULL;
165   -
166   - if(response->packet_id)
167   - errno = response->packet_id;
168   - else
169   - text = strdup(response->text);
170   -
171   - free(response);
172   - return text;
173   - }
174   -
175   - int hllapi_pipe_enter(void *h)
176   - {
177   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER };
178   - struct hllapi_packet_result response;
179   - DWORD cbSize = sizeof(query);
180   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
181   - return response.rc;
182   - }
183   -
184   - int hllapi_pipe_erase_eof(void *h)
185   - {
186   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_ERASE_EOF };
187   - struct hllapi_packet_result response;
188   - DWORD cbSize = sizeof(query);
189   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
190   - return response.rc;
191   - }
192   -
193   -
194   - int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str)
195   - {
196   - struct hllapi_packet_text_at * query;
197   - struct hllapi_packet_result response;
198   - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str);
199   -
200   - query = malloc(cbSize);
201   - query->packet_id = HLLAPI_PACKET_SET_TEXT_AT;
202   - query->row = row;
203   - query->col = col;
204   - strcpy(query->text,(const char *) str);
205   -
206   - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
207   -
208   - free(query);
209   -
210   - return response.rc;
211   - }
212   -
213   - int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text)
214   - {
215   - struct hllapi_packet_text_at * query;
216   - struct hllapi_packet_result response;
217   - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text);
218   -
219   - query = malloc(cbSize);
220   - query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT;
221   - query->row = row;
222   - query->col = col;
223   - strcpy(query->text,text);
224   -
225   - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
226   -
227   - free(query);
228   -
229   - return response.rc;
230   - }
231   -
232   - int hllapi_pipe_pfkey(void *h, int key)
233   - {
234   - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, key };
235   - struct hllapi_packet_result response;
236   - DWORD cbSize = sizeof(query);
237   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
238   - return response.rc;
239   - }
240   -
241   - int hllapi_pipe_pakey(void *h, int key)
242   - {
243   - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, key };
244   - struct hllapi_packet_result response;
245   - DWORD cbSize = sizeof(query);
246   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
247   - return response.rc;
248   - }
249   -
250   - void hllapi_pipe_release_memory(void *p)
251   - {
252   - free(p);
253   - }
254   -
255   - int hllapi_pipe_wait_for_ready(void *h, int seconds)
256   - {
257   - time_t end = time(0)+seconds;
258   -
259   - while(time(0) < end)
260   - {
261   - if(!hllapi_pipe_is_connected(h))
262   - return ENOTCONN;
263   -
264   - if(hllapi_pipe_get_message(h) == 0)
265   - return 0;
266   - Sleep(250);
267   - }
268   -
269   - return ETIMEDOUT;
270   - }
271   -
272   - int hllapi_pipe_is_connected(void *h)
273   - {
274   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED };
275   - struct hllapi_packet_result response;
276   - DWORD cbSize = sizeof(query);
277   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
278   - return (LIB3270_MESSAGE) response.rc;
279   - }
280   -
281   - int hllapi_pipe_sleep(void *h, int seconds)
282   - {
283   - time_t end = time(0)+seconds;
284   -
285   - while(time(0) < end)
286   - {
287   - if(!hllapi_pipe_is_connected(h))
288   - return ENOTCONN;
289   - Sleep(500);
290   - }
291   -
292   - return 0;
293   - }
294   -
295   - int hllapi_pipe_getcursor(void *h)
296   - {
297   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR };
298   - struct hllapi_packet_result response;
299   - DWORD cbSize = sizeof(query);
300   -
301   - trace("%s",__FUNCTION__);
302   -
303   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
304   - return (LIB3270_MESSAGE) response.rc;
305   -
306   - }
307   -
308   - int hllapi_pipe_setcursor(void *h, int baddr)
309   - {
310   - struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr };
311   - struct hllapi_packet_result response;
312   - DWORD cbSize = sizeof(query);
313   -
314   - trace("%s(%d)",__FUNCTION__,query.addr);
315   -
316   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
317   - return response.rc;
318   - }
319   -
320   - char * hllapi_pipe_get_text(void *h, int offset, int len)
321   - {
322   - struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, offset, len };
323   - struct hllapi_packet_text * response;
324   - DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
325   - char * text = NULL;
326   -
327   - trace("cbSize=%d",(int) cbSize);
328   -
329   - response = malloc(cbSize+2);
330   - memset(response,0,cbSize+2);
331   -
332   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(query), response, cbSize, &cbSize,NULL))
333   - return NULL;
334   -
335   - trace("rc=%d",response->packet_id);
336   -
337   - if(response->packet_id)
338   - errno = response->packet_id;
339   - else
340   - text = strdup(response->text);
341   -
342   - free(response);
343   - return text;
344   - }
345   -
346   - int hllapi_pipe_emulate_input(void *h, const char *text, int len, int pasting)
347   - {
348   - struct hllapi_packet_emulate_input * query;
349   - struct hllapi_packet_result response;
350   - DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+strlen(text);
351   -
352   - query = malloc(cbSize);
353   - query->packet_id = HLLAPI_PACKET_EMULATE_INPUT;
354   - query->len = len;
355   - query->pasting = pasting;
356   - strcpy(query->text,text);
357   -
358   - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
359   -
360   - free(query);
361   -
362   - return response.rc;
363   - }
364   -
365   - int hllapi_pipe_print(void *h)
366   - {
367   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_PRINT };
368   - struct hllapi_packet_result response;
369   - DWORD cbSize = sizeof(query);
370   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
371   - return response.rc;
372   - }
src/plugins/rx3270/Makefile.in
... ... @@ -61,26 +61,3 @@ $(BINDBG)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJ
61 61 @$(MKDIR) `dirname $@`
62 62 @$(CXX) $(SYSDLL_FLAGS) $(LDFLAGS) @LDSOFLAGS@ @DBGRPATH@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(CLASS_LIBS)
63 63  
64   -#---[ Release Targets ]--------------------------------------------------------
65   -
66   -$(BINRLS)/$(PLUGIN_NAME): $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) $(BINRLS)$(DLL_NAME)
67   - @echo " CCLD `basename $@`"
68   - @$(MKDIR) `dirname $@`
69   - $(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS)
70   -
71   -$(BINRLS)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJRLS)/$(SRC).o) $(CLASS_RELEASE_OBJECTS)
72   - @echo " CCLD `basename $@`"
73   - @$(MKDIR) `dirname $@`
74   - @$(CXX) $(SYSDLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(CLASS_LIBS)
75   -
76   -install:
77   - @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugin
78   - @$(INSTALL_PROGRAM) $(BINRLS)/$(PLUGIN_NAME) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
79   -
80   - @$(MKDIR) $(DESTDIR)$(REXXLIBDIR)
81   - @$(INSTALL_PROGRAM) $(BINRLS)$(DLL_NAME).$(VERSION) $(DESTDIR)$(REXXLIBDIR)
82   - @$(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) $(DESTDIR)$(REXXLIBDIR)/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@
83   -
84   - @$(MKDIR) $(DESTDIR)$(REXX_HOME)
85   - @$(INSTALL_DATA) rx3270.cls $(DESTDIR)$(REXX_HOME)
86   -
... ...