Commit 8a1561e62b458df5689c177e8e71496003f65bfe

Authored by Perry Werneck
1 parent 040ef525
Exists in master and in 1 other branch develop

Preparing for version 5.2

@@ -16,3 +16,4 @@ dbus-glue.h @@ -16,3 +16,4 @@ dbus-glue.h
16 *.cache 16 *.cache
17 *.zip 17 *.zip
18 *.bak 18 *.bak
  19 +*.[0-9]
@@ -24,38 +24,22 @@ @@ -24,38 +24,22 @@
24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) 24 # erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
25 # 25 #
26 26
27 -PACKAGE_NAME=@PACKAGE_NAME@  
28 -  
29 -#---[ PLugin configuration ]-------------------------------------------------------------  
30 -  
31 -PLUGIN_NAME=ipc3270c  
32 -  
33 -PLUGIN_SOURCES= \  
34 - $(wildcard src/$(PLUGIN_NAME)/*.c) \  
35 - $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.c) \  
36 - $(wildcard src/$(PLUGIN_NAME)/@OSNAME@/*.rc)  
37 -  
38 -PLUGIN_TEST_SOURCES= \  
39 - src/testprograms/$(PLUGIN_NAME).c  
40 -  
41 #---[ Library configuration ]------------------------------------------------------------ 27 #---[ Library configuration ]------------------------------------------------------------
42 28
43 -LIBRARY_NAME=hllapi 29 +LIBNAME=libhllapi
44 30
45 -LIBRARY_SOURCES= \  
46 - $(wildcard src/$(LIBRARY_NAME)/*.c) \  
47 - $(wildcard src/$(LIBRARY_NAME)/*.cc) \  
48 - $(wildcard src/$(LIBRARY_NAME)/@OSNAME@/*.c) \  
49 - $(wildcard src/$(LIBRARY_NAME)/@OSNAME@/*.rc) 31 +SOURCES= \
  32 + $(wildcard src/core/*.cc) \
  33 + $(wildcard src/core/@OSNAME@/*.rc) \
  34 + $(wildcard src/core/@OSNAME@/*.cc)
50 35
51 -LIBRARY_TEST_SOURCES= \  
52 - src/testprograms/$(LIBRARY_NAME).c 36 +TEST_SOURCES= \
  37 + $(wildcard src/testprogram/*.cc)
53 38
54 #---[ Tools ]---------------------------------------------------------------------------- 39 #---[ Tools ]----------------------------------------------------------------------------
55 40
56 -CC=@CC@  
57 -LD=@CC@  
58 CXX=@CXX@ 41 CXX=@CXX@
  42 +LD=@CXX@
59 LN_S=@LN_S@ 43 LN_S=@LN_S@
60 MKDIR=@MKDIR_P@ 44 MKDIR=@MKDIR_P@
61 INSTALL=@INSTALL@ 45 INSTALL=@INSTALL@
@@ -65,7 +49,11 @@ XGETTEXT=@XGETTEXT@ @@ -65,7 +49,11 @@ XGETTEXT=@XGETTEXT@
65 MSGCAT=@MSGCAT@ 49 MSGCAT=@MSGCAT@
66 WINDRES=@WINDRES@ 50 WINDRES=@WINDRES@
67 AR=@AR@ 51 AR=@AR@
68 -DBUSBINDINGTOOL=@DBUSBINDINGTOOL@ 52 +VALGRIND=@VALGRIND@
  53 +GENMARSHAL=@GENMARSHAL@
  54 +CONVERT=@CONVERT@
  55 +OPTIPNG=@OPTIPNG@
  56 +ZIP=@ZIP@
69 57
70 #---[ Paths ]---------------------------------------------------------------------------- 58 #---[ Paths ]----------------------------------------------------------------------------
71 59
@@ -82,9 +70,7 @@ sysconfdir=@sysconfdir@ @@ -82,9 +70,7 @@ sysconfdir=@sysconfdir@
82 70
83 BASEDIR=@BASEDIR@ 71 BASEDIR=@BASEDIR@
84 72
85 -POTDIR=$(BASEDIR)/.pot  
86 -  
87 -OBJDIR=$(BASEDIR)/.obj 73 +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME)
88 OBJDBG=$(OBJDIR)/Debug 74 OBJDBG=$(OBJDIR)/Debug
89 OBJRLS=$(OBJDIR)/Release 75 OBJRLS=$(OBJDIR)/Release
90 76
@@ -96,44 +82,18 @@ BINRLS=$(BINDIR)/Release @@ -96,44 +82,18 @@ BINRLS=$(BINDIR)/Release
96 82
97 DEPENDS= \ 83 DEPENDS= \
98 Makefile \ 84 Makefile \
99 - @DEPENDS@ 85 + src/include/*.h
100 86
101 CFLAGS= \ 87 CFLAGS= \
102 @CFLAGS@ \ 88 @CFLAGS@ \
103 -g \ 89 -g \
104 -Isrc/include \ 90 -Isrc/include \
105 -DBUILD_DATE=`date +%Y%m%d` \ 91 -DBUILD_DATE=`date +%Y%m%d` \
106 - @LIB3270_CFLAGS@ \  
107 - @V3270_CFLAGS@ \  
108 - @GTK_CFLAGS@ \  
109 - @GLIB_CFLAGS@ \  
110 - @PW3270_CFLAGS@ \  
111 - @DBUS_CFLAGS@ \  
112 - @GDBUS_CFLAGS@  
113 -  
114 -GTK_LIBS=@GTK_LIBS@  
115 -V3270_LIBS=@V3270_LIBS@  
116 -GLIB_LIBS=@GLIB_LIBS@  
117 -DBUS_LIBS=@DBUS_LIBS@ @GDBUS_LIBS@  
118 -STATIC_LDFLAGS=@STATIC_LDFLAGS@  
119 -LDFLAGS=@LDFLAGS@ 92 + @IPC3270_CFLAGS@
120 93
121 LIBS= \ 94 LIBS= \
122 @LIBS@ \ 95 @LIBS@ \
123 - @LIBICONV@ \  
124 - @INTL_LIBS@ \  
125 - @LIB3270_LIBS@ \  
126 - @PW3270_LIBS@  
127 -  
128 -src/include/dbus-glue.h: \  
129 - pw3270dbus.xml  
130 -  
131 - @echo $@ ...  
132 - @$(DBUSBINDINGTOOL) \  
133 - --mode=glib-server \  
134 - --output=$@ \  
135 - --prefix=pw3270_dbus $^  
136 - 96 + @IPC3270_LIBS@
137 97
138 #---[ Debug Rules ]---------------------------------------------------------------------- 98 #---[ Debug Rules ]----------------------------------------------------------------------
139 99
@@ -142,32 +102,20 @@ $(OBJDBG)/%.o: \ @@ -142,32 +102,20 @@ $(OBJDBG)/%.o: \
142 $(DEPENDS) 102 $(DEPENDS)
143 103
144 @echo $< ... 104 @echo $< ...
145 - @$(MKDIR) $(@D)  
146 -  
147 - @$(CC) \  
148 - $(CFLAGS) \  
149 - -Wall -Wextra -fstack-check \  
150 - -DDEBUG=1 \  
151 - -o $@ -c $<  
152 -  
153 -$(OBJDBG)/%.o: \  
154 - %.cc \  
155 - $(DEPENDS)  
156 -  
157 - @echo $< ...  
158 - @$(MKDIR) $(@D) 105 + @$(MKDIR) $(dir $@)
159 106
160 @$(CXX) \ 107 @$(CXX) \
161 $(CFLAGS) \ 108 $(CFLAGS) \
162 -Wall -Wextra -fstack-check \ 109 -Wall -Wextra -fstack-check \
163 -DDEBUG=1 \ 110 -DDEBUG=1 \
164 - -o $@ -c $< 111 + -o $@ \
  112 + -c $<
165 113
166 $(OBJDBG)/%.o: \ 114 $(OBJDBG)/%.o: \
167 %.rc 115 %.rc
168 116
169 @echo $< ... 117 @echo $< ...
170 - @$(MKDIR) $(@D) 118 + @$(MKDIR) $(dir $@)
171 @$(WINDRES) $< -O coff -o $@ 119 @$(WINDRES) $< -O coff -o $@
172 120
173 #---[ Release Rules ]-------------------------------------------------------------------- 121 #---[ Release Rules ]--------------------------------------------------------------------
@@ -177,277 +125,112 @@ $(OBJRLS)/%.o: \ @@ -177,277 +125,112 @@ $(OBJRLS)/%.o: \
177 $(DEPENDS) 125 $(DEPENDS)
178 126
179 @echo $< ... 127 @echo $< ...
180 - @$(MKDIR) $(@D)  
181 - @$(CC) \  
182 - $(CFLAGS) \  
183 - -DNDEBUG=1 \  
184 - -o $@ -c $<  
185 -  
186 -$(OBJRLS)/%.o: \  
187 - %.cc \  
188 - $(DEPENDS)  
189 -  
190 - @echo $< ...  
191 - @$(MKDIR) $(@D) 128 + @$(MKDIR) $(dir $@)
192 @$(CXX) \ 129 @$(CXX) \
193 $(CFLAGS) \ 130 $(CFLAGS) \
194 -DNDEBUG=1 \ 131 -DNDEBUG=1 \
195 - -o $@ -c $< 132 + -o $@ \
  133 + -c $<
196 134
197 $(OBJRLS)/%.o: \ 135 $(OBJRLS)/%.o: \
198 %.rc 136 %.rc
199 137
200 @echo $< ... 138 @echo $< ...
201 - @$(MKDIR) $(@D) 139 + @$(MKDIR) $(dir $@)
202 @$(WINDRES) $< -O coff -o $@ 140 @$(WINDRES) $< -O coff -o $@
203 141
204 -#---[ Misc Rules ]-----------------------------------------------------------------------  
205 -  
206 -$(POTDIR)/$(PLUGIN_NAME)/%.pot: \  
207 - %.c  
208 -  
209 - @echo $(notdir $@) ...  
210 - @$(MKDIR) $(@D)  
211 - @$(XGETTEXT) \  
212 - --language=C \  
213 - --keyword=_ \  
214 - --keyword=N_ \  
215 - --keyword=MSG_:2 \  
216 - --output=$@ \  
217 - $<  
218 - @touch $@  
219 -  
220 -$(POTDIR)/$(PLUGIN_NAME)/%.pot: \  
221 - %.rc  
222 -  
223 - @echo $< ...  
224 - @$(MKDIR) $(@D)  
225 - @touch $@  
226 -  
227 -  
228 #---[ Release Targets ]------------------------------------------------------------------ 142 #---[ Release Targets ]------------------------------------------------------------------
229 143
230 all: \ 144 all: \
231 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \  
232 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \  
233 - $(POTDIR)/$(PLUGIN_NAME).pot 145 + $(BINRLS)/$(SONAME) \
  146 + $(BINRLS)/static/$(LIBNAME).a \
  147 + $(POTDIR)/$(LIBNAME).pot
234 148
235 Release: \ 149 Release: \
236 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \  
237 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ 150 + $(BINRLS)/$(SONAME)
238 151
239 -$(BINRLS)/$(PLUGIN_NAME)@DLLEXT@: \  
240 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) 152 +$(BINRLS)/$(SONAME): \
  153 + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o)
241 154
242 - @$(MKDIR) $(@D) 155 + @$(MKDIR) $(dir $@)
243 @echo $< ... 156 @echo $< ...
244 @$(LD) \ 157 @$(LD) \
245 - -shared -Wl,-soname,$(@F) \ 158 + @DLL_LDFLAGS@ \
246 -o $@ \ 159 -o $@ \
247 $(LDFLAGS) \ 160 $(LDFLAGS) \
248 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \  
249 - $(V3270_LIBS) \  
250 - $(LIBS) \  
251 - $(GTK_LIBS) \  
252 - $(DBUS_LIBS)  
253 -  
254 -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@: \  
255 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@  
256 -  
257 - @echo $< ...  
258 - @rm -f $@  
259 - @$(LN_S) \  
260 - $^ \  
261 - $@  
262 -  
263 -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \  
264 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
265 -  
266 - @rm -f $@  
267 - @$(LN_S) \  
268 $^ \ 161 $^ \
269 - $@  
270 -  
271 -$(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \  
272 - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJRLS)/$(SRC).o)  
273 -  
274 - @$(MKDIR) $(@D)  
275 - @echo $< ...  
276 - @$(CXX) \  
277 - -shared -Wl,-soname,$(@F) \  
278 - -o $@ \  
279 - $(LDFLAGS) $(STATIC_LDFLAGS)\  
280 - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJRLS)/$(SRC).o) \  
281 - -lpw3270cpp \  
282 - -L$(BINDBG) \  
283 - $(LIBS) \  
284 - $(DBUS_LIBS)  
285 -  
286 -zip: \  
287 - $(PLUGIN_NAME)-@PACKAGE_VERSION@.@host@.zip  
288 -  
289 -$(PLUGIN_NAME)-@PACKAGE_VERSION@.@host@.zip: \  
290 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \  
291 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \  
292 - $(POTDIR)/$(PLUGIN_NAME).pot  
293 -  
294 - @rm -f $@  
295 - @zip -9 -j $@ \  
296 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \  
297 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@ \  
298 - $(POTDIR)/$(PLUGIN_NAME).pot 162 + $(LIBS)
299 163
300 #---[ Install Targets ]------------------------------------------------------------------ 164 #---[ Install Targets ]------------------------------------------------------------------
301 165
302 install: \ 166 install: \
303 - install-shared \  
304 - install-plugin 167 + $(BINRLS)/$(SONAME)
305 168
306 -install-plugin: \  
307 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@  
308 -  
309 - @$(MKDIR) $(DESTDIR)$(libdir)/pw3270-plugins  
310 -  
311 - @$(INSTALL_PROGRAM) \  
312 - $(BINRLS)/$(PLUGIN_NAME)@DLLEXT@ \  
313 - $(DESTDIR)$(libdir)/pw3270-plugins  
314 -  
315 -install-shared: \  
316 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@  
317 -  
318 - @$(MKDIR) $(DESTDIR)/$(libdir) 169 + # Install library
  170 + @$(MKDIR) $(DESTDIR)$(libdir)
319 171
320 @$(INSTALL_PROGRAM) \ 172 @$(INSTALL_PROGRAM) \
321 - $(BINRLS)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \  
322 - $(DESTDIR)/$(libdir) 173 + $(BINRLS)/$(SONAME) \
  174 + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@
323 175
324 @$(LN_S) \ 176 @$(LN_S) \
325 - lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \  
326 - $(DESTDIR)/$(libdir)/lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ 177 + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \
  178 + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@
327 179
328 @$(LN_S) \ 180 @$(LN_S) \
329 - lib$(LIBRARY_NAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \  
330 - $(DESTDIR)/$(libdir)/lib$(LIBRARY_NAME)@DLLEXT@  
331 -  
332 -#---[ Misc Targets ]--------------------------------------------------------------------- 181 + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \
  182 + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@
333 183
334 -$(POTDIR)/$(PLUGIN_NAME).pot: \  
335 - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(PLUGIN_NAME)/$(SRC).pot)  
336 -  
337 - @rm -f $@  
338 - @mkdir -p `dirname $@`  
339 - @$(MSGCAT) --sort-output $^ > $@  
340 -  
341 -locale: \  
342 - $(POTDIR)/$(PLUGIN_NAME).pot  
343 -  
344 -run-plugin: \  
345 - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@  
346 -  
347 - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@  
348 -  
349 -run-library: \  
350 - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@  
351 -  
352 - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@  
353 184
354 #---[ Debug Targets ]-------------------------------------------------------------------- 185 #---[ Debug Targets ]--------------------------------------------------------------------
355 186
356 Debug: \ 187 Debug: \
357 - Debug-plugin \  
358 - Debug-library  
359 -  
360 -Debug-plugin: \  
361 - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@  
362 -  
363 -Debug-library: \  
364 - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@  
365 -  
366 -zip-debug: \  
367 - $(PLUGIN_NAME)-debug-@PACKAGE_VERSION@.@host@.zip  
368 -  
369 -$(PLUGIN_NAME)-debug-@PACKAGE_VERSION@.@host@.zip: \  
370 - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \  
371 - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ \  
372 - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ \  
373 - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@  
374 -  
375 - @rm -f $@  
376 - @zip -9 -j $@ \  
377 - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ \  
378 - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ \  
379 - $(BINDBG)/$(PLUGIN_NAME)@EXEEXT@ \  
380 - $(BINDBG)/$(LIBRARY_NAME)@EXEEXT@  
381 - 188 + $(BINDBG)/$(LIBNAME)@EXEEXT@
382 189
383 -$(BINDBG)/$(PLUGIN_NAME)@EXEEXT@: \  
384 - $(foreach SRC, $(basename $(PLUGIN_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \  
385 - $(BINDBG)/$(PLUGIN_NAME)@DLLEXT@ 190 +$(BINDBG)/$(LIBNAME)@EXEEXT@: \
  191 + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \
  192 + $(BINDBG)/$(SONAME)
386 193
387 - @$(MKDIR) $(@D) 194 + @$(MKDIR) $(dir $@)
388 @echo $< ... 195 @echo $< ...
389 @$(LD) \ 196 @$(LD) \
390 -o $@ \ 197 -o $@ \
391 - $(foreach SRC, $(basename $(PLUGIN_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ 198 + $^ \
392 -L$(BINDBG) \ 199 -L$(BINDBG) \
393 -Wl,-rpath,$(BINDBG) \ 200 -Wl,-rpath,$(BINDBG) \
394 $(LDFLAGS) \ 201 $(LDFLAGS) \
395 - $(LIBS) \  
396 - $(V3270_LIBS) \  
397 - $(GTK_LIBS) \  
398 - $(GLIB_LIBS) \  
399 - $(DBUS_LIBS) 202 + $(LIBS)
  203 +
  204 +run: \
  205 + $(BINDBG)/$(LIBNAME)@EXEEXT@
400 206
401 -$(BINDBG)/$(PLUGIN_NAME)@DLLEXT@: \  
402 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) 207 +ifeq ($(VALGRIND),no)
403 208
404 - @$(MKDIR) $(@D)  
405 - @echo $< ...  
406 - @$(LD) \  
407 - -shared -Wl,-soname,$(@F) \  
408 - -o $@ \  
409 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \  
410 - $(LDFLAGS) \  
411 - -L$(BINDBG) \  
412 - $(LIBS) \  
413 - $(V3270_LIBS) \  
414 - $(GTK_LIBS) \  
415 - $(GLIB_LIBS) \  
416 - $(DBUS_LIBS) 209 + @LD_LIBRARY_PATH=$(BINDBG) \
  210 + $(BINDBG)/$(LIBNAME)@EXEEXT@
417 211
418 -$(BINDBG)/$(LIBRARY_NAME)@EXEEXT@: \  
419 - $(foreach SRC, $(basename $(LIBRARY_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \  
420 - $(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@ 212 +else
  213 + @touch valgrind.suppression
  214 +
  215 + @LD_LIBRARY_PATH=$(BINDBG) \
  216 + $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \
  217 + $(BINDBG)/$(LIBNAME)@EXEEXT@
  218 +endif
421 219
422 - @$(MKDIR) $(@D)  
423 - @echo $< ...  
424 - @$(CXX) \  
425 - -o $@ \  
426 - $(foreach SRC, $(basename $(LIBRARY_TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \  
427 - -Wl,-rpath,$(BINDBG) \  
428 - $(LDFLAGS) \  
429 - -L$(BINDBG) \  
430 - -l$(LIBRARY_NAME) \  
431 - $(LIBS) \  
432 - $(V3270_LIBS) \  
433 - $(GTK_LIBS) \  
434 - $(GLIB_LIBS) \  
435 - $(DBUS_LIBS)  
436 220
437 -$(BINDBG)/lib$(LIBRARY_NAME)@DLLEXT@: \  
438 - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJDBG)/$(SRC).o) 221 +$(BINDBG)/$(SONAME): \
  222 + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
439 223
440 - @$(MKDIR) $(@D) 224 + @$(MKDIR) $(dir $@)
441 @echo $< ... 225 @echo $< ...
442 - @$(CXX) \ 226 + @$(LD) \
443 -shared -Wl,-soname,$(@F) \ 227 -shared -Wl,-soname,$(@F) \
444 -o $@ \ 228 -o $@ \
445 - $(LDFLAGS) $(STATIC_LDFLAGS)\  
446 - $(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJDBG)/$(SRC).o) \  
447 - -lpw3270cpp \  
448 -L$(BINDBG) \ 229 -L$(BINDBG) \
449 - $(LIBS) \  
450 - $(DBUS_LIBS) 230 + $(LDFLAGS) \
  231 + $^ \
  232 + $(LIBS)
  233 +
451 234
452 #---[ Clean Targets ]-------------------------------------------------------------------- 235 #---[ Clean Targets ]--------------------------------------------------------------------
453 236
@@ -455,19 +238,18 @@ clean: \ @@ -455,19 +238,18 @@ clean: \
455 cleanDebug \ 238 cleanDebug \
456 cleanRelease 239 cleanRelease
457 240
458 - @rm -fr $(BASEDIR)/.tmp/$(PLUGIN_NAME)  
459 - @rm -fr $(POTDIR)/$(PLUGIN_NAME)  
460 -  
461 cleanDebug: 241 cleanDebug:
462 242
463 @rm -fr $(OBJDBG) 243 @rm -fr $(OBJDBG)
464 @rm -fr $(BINDBG) 244 @rm -fr $(BINDBG)
465 - @rm -fr $(OBJDIR)/marshal  
466 245
467 cleanRelease: 246 cleanRelease:
468 247
469 @rm -fr $(OBJRLS) 248 @rm -fr $(OBJRLS)
470 @rm -fr $(BINRLS) 249 @rm -fr $(BINRLS)
471 - @rm -fr $(OBJDIR)/marshal 250 +
  251 +clean: \
  252 + cleanDebug \
  253 + cleanRelease
472 254
473 255
@@ -31,7 +31,7 @@ AC_PREREQ(2.61) @@ -31,7 +31,7 @@ AC_PREREQ(2.61)
31 31
32 dnl Initialise automake with the package name, version and 32 dnl Initialise automake with the package name, version and
33 dnl bug-reporting address. 33 dnl bug-reporting address.
34 -AC_INIT([ipc3270], [5.1], [perry.werneck@gmail.com]) 34 +AC_INIT([hllapi], [5.2], [perry.werneck@gmail.com])
35 35
36 dnl Place auxilliary scripts here. 36 dnl Place auxilliary scripts here.
37 AC_CONFIG_AUX_DIR([scripts]) 37 AC_CONFIG_AUX_DIR([scripts])
@@ -54,7 +54,7 @@ AC_PROG_CXX @@ -54,7 +54,7 @@ AC_PROG_CXX
54 AC_PROG_SED 54 AC_PROG_SED
55 AC_PROG_LN_S 55 AC_PROG_LN_S
56 56
57 -AC_LANG([C]) 57 +AC_LANG([C++])
58 58
59 dnl --------------------------------------------------------------------------- 59 dnl ---------------------------------------------------------------------------
60 dnl Initialize defaults 60 dnl Initialize defaults
@@ -65,8 +65,7 @@ RLS_CFLAGS=&quot;-DNDEBUG=1&quot; @@ -65,8 +65,7 @@ RLS_CFLAGS=&quot;-DNDEBUG=1&quot;
65 PLUGINS="" 65 PLUGINS=""
66 APP_RESOURCES="" 66 APP_RESOURCES=""
67 APP_LDFLAGS="" 67 APP_LDFLAGS=""
68 -DLL_LDFLAGS="-shared"  
69 -STATIC_LDFLAGS="" 68 +DLL_LDFLAGS="-shared -Wl,-soname,\$(@F)"
70 DEPENDS="" 69 DEPENDS=""
71 70
72 dnl --------------------------------------------------------------------------- 71 dnl ---------------------------------------------------------------------------
@@ -85,9 +84,12 @@ case &quot;$host&quot; in @@ -85,9 +84,12 @@ case &quot;$host&quot; in
85 DLLEXT=".dll" 84 DLLEXT=".dll"
86 DLLPREFIX="" 85 DLLPREFIX=""
87 86
88 - app_win32_revision=$(date +%y.%m.%d.%H) 87 + app_win32_revision=$(date +%-y.%-m.%-d.%-H)
89 AC_SUBST(WIN32_VERSION,$app_win32_revision) 88 AC_SUBST(WIN32_VERSION,$app_win32_revision)
90 - AC_CONFIG_FILES(src/ipc3270c/windows/resources.rc) 89 +
  90 + app_win32_file_version=$(date +%-y,%-m,%-d,%-H)
  91 + AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version)
  92 +
91 AC_CONFIG_FILES(src/hllapi/windows/resources.rc) 93 AC_CONFIG_FILES(src/hllapi/windows/resources.rc)
92 ;; 94 ;;
93 95
@@ -125,7 +127,7 @@ dnl --------------------------------------------------------------------------- @@ -125,7 +127,7 @@ dnl ---------------------------------------------------------------------------
125 dnl Version info 127 dnl Version info
126 dnl --------------------------------------------------------------------------- 128 dnl ---------------------------------------------------------------------------
127 129
128 -AC_SUBST(PACKAGE_DESCRIPTION,"PW3270 IPC Compatible Module") 130 +AC_SUBST(PACKAGE_DESCRIPTION,"PW3270 HLLAPI Module")
129 131
130 app_vrs_major=$(echo $VERSION | cut -d. -f1) 132 app_vrs_major=$(echo $VERSION | cut -d. -f1)
131 app_vrs_minor=$(echo $VERSION | cut -d. -f2) 133 app_vrs_minor=$(echo $VERSION | cut -d. -f2)
@@ -136,7 +138,7 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor) @@ -136,7 +138,7 @@ AC_DEFINE_UNQUOTED(PACKAGE_MINOR_VERSION, $app_vrs_minor)
136 AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major) 138 AC_SUBST(PACKAGE_MAJOR_VERSION,$app_vrs_major)
137 AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor) 139 AC_SUBST(PACKAGE_MINOR_VERSION,$app_vrs_minor)
138 140
139 -AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%y`.`date +%m`.`date +%d`" ]) 141 +AC_ARG_WITH([release], [AS_HELP_STRING([--with-release], [Set release])], [ app_cv_release="$withval" ],[ app_cv_release="`date +%-y`.`date +%-m`.`date +%-d`" ])
140 142
141 app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1) 143 app_rls_major=$(echo $app_cv_release.0.0 | cut -d. -f1)
142 app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2) 144 app_rls_minor=$(echo $app_cv_release.0.0 | cut -d. -f2)
@@ -149,6 +151,20 @@ AC_SUBST(PACKAGE_RELEASE,$app_cv_release) @@ -149,6 +151,20 @@ AC_SUBST(PACKAGE_RELEASE,$app_cv_release)
149 AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major) 151 AC_SUBST(PACKAGE_MAJOR_RELEASE,$app_rls_major)
150 AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor) 152 AC_SUBST(PACKAGE_MINOR_RELEASE,$app_rls_minor)
151 153
  154 +case "$host" in
  155 + *-mingw32|*-pc-msys)
  156 + AC_SUBST(SONAME,hllapi.dll)
  157 + ;;
  158 +
  159 + s390x-*)
  160 + AC_SUBST(SONAME,libhllapi.so)
  161 + ;;
  162 +
  163 + *)
  164 + AC_SUBST(SONAME,libhllapi.so.$app_vrs_major.$app_vrs_minor)
  165 +
  166 +esac
  167 +
152 dnl --------------------------------------------------------------------------- 168 dnl ---------------------------------------------------------------------------
153 dnl Check for libintl 169 dnl Check for libintl
154 dnl --------------------------------------------------------------------------- 170 dnl ---------------------------------------------------------------------------
@@ -164,68 +180,13 @@ AC_PATH_TOOL([MSGFMT], [msgfmt], [no]) @@ -164,68 +180,13 @@ AC_PATH_TOOL([MSGFMT], [msgfmt], [no])
164 AC_SUBST(INTL_LIBS) 180 AC_SUBST(INTL_LIBS)
165 181
166 dnl --------------------------------------------------------------------------- 182 dnl ---------------------------------------------------------------------------
167 -dnl Check for LIB3270  
168 -dnl ---------------------------------------------------------------------------  
169 -  
170 -PKG_CHECK_MODULES( [LIB3270], [lib3270], AC_DEFINE(HAVE_LIB3270), AC_MSG_ERROR([LIB3270 not present.]))  
171 -  
172 -AC_SUBST(LIB3270_LIBS)  
173 -AC_SUBST(LIB3270_CFLAGS)  
174 -  
175 -dnl ---------------------------------------------------------------------------  
176 -dnl Check for PW3270  
177 -dnl ---------------------------------------------------------------------------  
178 -  
179 -PKG_CHECK_MODULES( [PW3270], [pw3270], AC_DEFINE(HAVE_PW3270), AC_MSG_ERROR([PW3270 not present.]))  
180 -  
181 -AC_SUBST(PW3270_LIBS)  
182 -AC_SUBST(PW3270_CFLAGS)  
183 -  
184 -dnl ---------------------------------------------------------------------------  
185 -dnl Check for LIBV3270 183 +dnl Check for IPC3270
186 dnl --------------------------------------------------------------------------- 184 dnl ---------------------------------------------------------------------------
187 185
188 -PKG_CHECK_MODULES( [V3270], [libv3270], AC_DEFINE(HAVE_V3270), AC_MSG_ERROR([V3270 not present.]))  
189 -  
190 -AC_SUBST(V3270_LIBS)  
191 -AC_SUBST(V3270_CFLAGS)  
192 -  
193 -dnl ---------------------------------------------------------------------------  
194 -dnl Check for GTK  
195 -dnl ---------------------------------------------------------------------------  
196 -  
197 -PKG_CHECK_MODULES( [GTK], [gtk+-3.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.]))  
198 -  
199 -AC_SUBST(GTK_LIBS)  
200 -AC_SUBST(GTK_CFLAGS)  
201 -  
202 -dnl ---------------------------------------------------------------------------  
203 -dnl Check for GLIB  
204 -dnl ---------------------------------------------------------------------------  
205 -  
206 -PKG_CHECK_MODULES( [GLIB], [glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0], AC_DEFINE(HAVE_GLIB), AC_MSG_ERROR([GLIB not present.] ))  
207 -AC_SUBST(GLIB_LIBS)  
208 -AC_SUBST(GLIB_CFLAGS)  
209 -  
210 -dnl ---------------------------------------------------------------------------  
211 -dnl Check for D-Bus  
212 -dnl ---------------------------------------------------------------------------  
213 -  
214 -AC_PATH_TOOL([DBUSBINDINGTOOL],[dbus-binding-tool],[no])  
215 -  
216 -PKG_CHECK_MODULES( [DBUS], [dbus-1], app_cv_libdbus=yes, AC_MSG_NOTICE([ No DBUS support.]) )  
217 -AC_SUBST(DBUS_LIBS)  
218 -AC_SUBST(DBUS_CFLAGS)  
219 -  
220 -PKG_CHECK_MODULES( [GDBUS], [dbus-glib-1], app_cv_dbus=yes, AC_MSG_NOTICE([No GDBUS support.]) )  
221 -AC_SUBST(GDBUS_LIBS)  
222 -AC_SUBST(GDBUS_CFLAGS)  
223 -  
224 -if test "$app_cv_dbus" == "yes"; then  
225 - AC_DEFINE(HAVE_DBUS)  
226 - DEPENDS="$DEPENDS src/include/dbus-glue.h"  
227 -fi 186 +PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(HAVE_IPC3270), AC_MSG_ERROR([LIB3270 not present.]))
228 187
  188 +AC_SUBST(IPC3270_LIBS)
  189 +AC_SUBST(IPC3270_CFLAGS)
229 190
230 dnl --------------------------------------------------------------------------- 191 dnl ---------------------------------------------------------------------------
231 dnl Check for pic 192 dnl Check for pic
src/core/calls.cc 0 → 100644
@@ -0,0 +1,826 @@ @@ -0,0 +1,826 @@
  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.cc 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 <exception>
  31 + #include <cstdlib>
  32 + #include <cstring>
  33 +
  34 + #include <pw3270/hllapi.h>
  35 + #include <pw3270/pw3270cpp.h>
  36 + #include "client.h"
  37 +
  38 + using namespace std;
  39 + using namespace PW3270_NAMESPACE;
  40 +
  41 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  42 +
  43 + static session * hSession = NULL;
  44 + static time_t hllapi_timeout = 120;
  45 +
  46 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  47 +
  48 + HLLAPI_API_CALL hllapi_init(LPSTR mode)
  49 + {
  50 + trace("%s(%s)",__FUNCTION__,mode);
  51 +
  52 + try
  53 + {
  54 + if(hSession)
  55 + delete hSession;
  56 + hSession = session::create(mode);
  57 +
  58 + if(!hSession) {
  59 + return HLLAPI_STATUS_UNAVAILABLE;
  60 + }
  61 +
  62 + hSession->set_display_charset();
  63 +
  64 + trace("hSession=%p",hSession);
  65 + }
  66 + catch(std::exception &e)
  67 + {
  68 + trace("Error \"%s\"",e.what());
  69 + return HLLAPI_STATUS_SYSTEM_ERROR;
  70 + }
  71 +
  72 + return HLLAPI_STATUS_SUCCESS;
  73 +
  74 + }
  75 +
  76 + HLLAPI_API_CALL hllapi_deinit(void)
  77 + {
  78 + trace("%s()",__FUNCTION__);
  79 +
  80 + try
  81 + {
  82 + if(hSession)
  83 + {
  84 + delete hSession;
  85 + hSession = NULL;
  86 + }
  87 + }
  88 + catch(std::exception &e)
  89 + {
  90 + return HLLAPI_STATUS_SYSTEM_ERROR;
  91 + }
  92 +
  93 + return HLLAPI_STATUS_SUCCESS;
  94 + }
  95 +
  96 + HLLAPI_API_CALL hllapi_get_revision(void)
  97 + {
  98 + try
  99 + {
  100 + return atoi(session::get_default()->get_revision().c_str());
  101 + }
  102 + catch(std::exception &e)
  103 + {
  104 + return -1;
  105 + }
  106 + return (DWORD) -1;
  107 + }
  108 +
  109 + HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait)
  110 + {
  111 + try
  112 + {
  113 + session::get_default()->connect(uri,hllapi_timeout);
  114 + }
  115 + catch(std::exception &e)
  116 + {
  117 + return HLLAPI_STATUS_SYSTEM_ERROR;
  118 + }
  119 +
  120 + return hllapi_get_state();
  121 + }
  122 +
  123 + HLLAPI_API_CALL hllapi_is_connected(void)
  124 + {
  125 + if(!session::has_default())
  126 + {
  127 + return 0;
  128 + }
  129 +
  130 + return session::get_default()->is_connected();
  131 + }
  132 +
  133 + HLLAPI_API_CALL hllapi_get_state(void)
  134 + {
  135 + switch(hllapi_get_message_id())
  136 + {
  137 + case LIB3270_MESSAGE_NONE: // 0 - No message
  138 + return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input.
  139 +
  140 + case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host
  141 + return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session.
  142 +
  143 + case LIB3270_MESSAGE_MINUS:
  144 + case LIB3270_MESSAGE_PROTECTED:
  145 + case LIB3270_MESSAGE_NUMERIC:
  146 + case LIB3270_MESSAGE_OVERFLOW:
  147 + case LIB3270_MESSAGE_INHIBIT:
  148 + case LIB3270_MESSAGE_KYBDLOCK:
  149 + return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked.
  150 +
  151 + case LIB3270_MESSAGE_SYSWAIT:
  152 + case LIB3270_MESSAGE_TWAIT:
  153 + case LIB3270_MESSAGE_AWAITING_FIRST:
  154 + case LIB3270_MESSAGE_X:
  155 + case LIB3270_MESSAGE_RESOLVING:
  156 + case LIB3270_MESSAGE_CONNECTING:
  157 + return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation.
  158 + }
  159 +
  160 + return HLLAPI_STATUS_SYSTEM_ERROR;
  161 + }
  162 +
  163 + HLLAPI_API_CALL hllapi_disconnect(void)
  164 + {
  165 + session::get_default()->disconnect();
  166 + return HLLAPI_STATUS_SUCCESS;
  167 + }
  168 +
  169 + HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds)
  170 + {
  171 + if(!hllapi_is_connected())
  172 + return HLLAPI_STATUS_DISCONNECTED;
  173 +
  174 + session::get_default()->wait_for_ready(seconds);
  175 +
  176 + return hllapi_get_state();
  177 + }
  178 +
  179 + HLLAPI_API_CALL hllapi_wait(WORD seconds)
  180 + {
  181 + if(!hllapi_is_connected())
  182 + return HLLAPI_STATUS_DISCONNECTED;
  183 +
  184 + session::get_default()->wait(seconds);
  185 +
  186 + return hllapi_get_state();
  187 + }
  188 +
  189 + HLLAPI_API_CALL hllapi_get_message_id(void)
  190 + {
  191 + if(!hllapi_is_connected())
  192 + return HLLAPI_STATUS_DISCONNECTED;
  193 +
  194 + return session::get_default()->get_program_message();
  195 + }
  196 +
  197 + HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
  198 + {
  199 + if(!hllapi_is_connected())
  200 + return HLLAPI_STATUS_DISCONNECTED;
  201 +
  202 + if(!(buffer && *buffer))
  203 + return HLLAPI_STATUS_SYSTEM_ERROR;
  204 +
  205 + try
  206 + {
  207 + size_t sz = strlen(buffer);
  208 + string str = session::get_default()->get_string_at(row,col,sz);
  209 + strncpy(buffer,str.c_str(),sz);
  210 + }
  211 + catch(std::exception &e)
  212 + {
  213 + return HLLAPI_STATUS_SYSTEM_ERROR;
  214 + }
  215 +
  216 + return HLLAPI_STATUS_SUCCESS;
  217 + }
  218 +
  219 + HLLAPI_API_CALL hllapi_enter(void)
  220 + {
  221 + if(!hllapi_is_connected())
  222 + return HLLAPI_STATUS_DISCONNECTED;
  223 +
  224 + return session::get_default()->enter();
  225 + }
  226 +
  227 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text)
  228 + {
  229 + if(!hllapi_is_connected())
  230 + return HLLAPI_STATUS_DISCONNECTED;
  231 +
  232 + try
  233 + {
  234 + session::get_default()->set_string_at(row,col,text);
  235 + }
  236 + catch(std::exception &e)
  237 + {
  238 + return HLLAPI_STATUS_SYSTEM_ERROR;
  239 + }
  240 +
  241 + return HLLAPI_STATUS_SUCCESS;
  242 + }
  243 +
  244 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
  245 + {
  246 +
  247 + if(!hllapi_is_connected())
  248 + return HLLAPI_STATUS_DISCONNECTED;
  249 +
  250 + int rc = HLLAPI_STATUS_SYSTEM_ERROR;
  251 +
  252 + try
  253 + {
  254 + rc = session::get_default()->cmp_string_at(row,col,text);
  255 + }
  256 + catch(std::exception &e)
  257 + {
  258 + return HLLAPI_STATUS_SYSTEM_ERROR;
  259 + }
  260 +
  261 + return rc;
  262 + }
  263 +
  264 + HLLAPI_API_CALL hllapi_find_text(LPSTR text)
  265 + {
  266 + if(!hllapi_is_connected())
  267 + return HLLAPI_STATUS_DISCONNECTED;
  268 +
  269 + return (int) session::get_default()->find_string((const char *) text, false);
  270 + }
  271 +
  272 + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms)
  273 + {
  274 + session::get_default()->set_unlock_delay(ms);
  275 + return 0;
  276 + }
  277 +
  278 + HLLAPI_API_CALL hllapi_set_charset(LPSTR text)
  279 + {
  280 + try
  281 + {
  282 +
  283 + session::get_default()->set_display_charset(NULL, (const char *) text);
  284 +
  285 + }
  286 + catch(std::exception &e)
  287 + {
  288 + return HLLAPI_STATUS_SYSTEM_ERROR;
  289 + }
  290 +
  291 + return 0;
  292 + }
  293 +
  294 + HLLAPI_API_CALL hllapi_pfkey(WORD key)
  295 + {
  296 + if(!hllapi_is_connected())
  297 + return HLLAPI_STATUS_DISCONNECTED;
  298 +
  299 + return session::get_default()->pfkey(key);
  300 + }
  301 +
  302 + HLLAPI_API_CALL hllapi_pakey(WORD key)
  303 + {
  304 + if(!hllapi_is_connected())
  305 + return HLLAPI_STATUS_DISCONNECTED;
  306 +
  307 + return session::get_default()->pakey(key);
  308 + }
  309 +
  310 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir)
  311 + {
  312 + #ifdef _WIN32
  313 + HKEY hKey = 0;
  314 + unsigned long datalen = strlen(datadir);
  315 +
  316 + *datadir = 0;
  317 +
  318 + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
  319 + {
  320 + unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
  321 + if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
  322 + *datadir = 0;
  323 + RegCloseKey(hKey);
  324 + }
  325 +#endif // _WIN32
  326 +
  327 + return *datadir;
  328 + }
  329 +
  330 + HLLAPI_API_CALL hllapi_setcursor(WORD pos)
  331 + {
  332 + if(!hllapi_is_connected())
  333 + return HLLAPI_STATUS_DISCONNECTED;
  334 +
  335 + session::get_default()->set_cursor_addr(pos-1);
  336 +
  337 + return HLLAPI_STATUS_SUCCESS;
  338 +
  339 + }
  340 +
  341 + HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos)
  342 + {
  343 + if(!hllapi_is_connected())
  344 + return HLLAPI_STATUS_DISCONNECTED;
  345 +
  346 + session::get_default()->set_cursor_addr(pos-1);
  347 +
  348 + return HLLAPI_STATUS_SUCCESS;
  349 +
  350 + }
  351 +
  352 + HLLAPI_API_CALL hllapi_get_cursor_address()
  353 + {
  354 + return session::get_default()->get_cursor_addr()+1;
  355 + }
  356 +
  357 + HLLAPI_API_CALL hllapi_getcursor()
  358 + {
  359 + return session::get_default()->get_cursor_addr()+1;
  360 + }
  361 +
  362 + HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len)
  363 + {
  364 + if(!hllapi_is_connected())
  365 + return HLLAPI_STATUS_DISCONNECTED;
  366 +
  367 + int rc = HLLAPI_STATUS_SYSTEM_ERROR;
  368 +
  369 + if(offset < 1)
  370 + {
  371 + return HLLAPI_STATUS_BAD_PARAMETER;
  372 + }
  373 +
  374 + offset--;
  375 +
  376 + if(!session::has_default())
  377 + {
  378 + return HLLAPI_STATUS_DISCONNECTED;
  379 + }
  380 +
  381 + if(!(buffer && *buffer)) {
  382 + return HLLAPI_STATUS_BAD_PARAMETER;
  383 + }
  384 +
  385 + try
  386 + {
  387 + size_t szBuffer;
  388 +
  389 + if(len > 0)
  390 + {
  391 + szBuffer = (size_t) len;
  392 + }
  393 + else
  394 + {
  395 + return HLLAPI_STATUS_BAD_PARAMETER;
  396 + }
  397 +
  398 + memset(buffer,' ',szBuffer);
  399 +
  400 + string str = session::get_default()->get_string(offset,szBuffer,false);
  401 + strncpy(buffer,str.c_str(),szBuffer);
  402 + rc = HLLAPI_STATUS_SUCCESS;
  403 + }
  404 + catch(std::exception &e)
  405 + {
  406 + rc = HLLAPI_STATUS_SYSTEM_ERROR;
  407 + }
  408 +
  409 + return rc;
  410 + }
  411 +
  412 + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting)
  413 + {
  414 + if(!hllapi_is_connected())
  415 + return HLLAPI_STATUS_DISCONNECTED;
  416 +
  417 + try
  418 + {
  419 + session::get_default()->input_string(buffer);
  420 + }
  421 + catch(std::exception &e)
  422 + {
  423 + return HLLAPI_STATUS_SYSTEM_ERROR;
  424 + }
  425 +
  426 + return HLLAPI_STATUS_SUCCESS;
  427 + }
  428 +
  429 + HLLAPI_API_CALL hllapi_erase(void)
  430 + {
  431 + try
  432 + {
  433 + session::get_default()->erase();
  434 + }
  435 + catch(std::exception &e)
  436 + {
  437 + return HLLAPI_STATUS_SYSTEM_ERROR;
  438 + }
  439 + return HLLAPI_STATUS_SUCCESS;
  440 + }
  441 +
  442 + HLLAPI_API_CALL hllapi_erase_eof(void)
  443 + {
  444 + if(!hllapi_is_connected())
  445 + return HLLAPI_STATUS_DISCONNECTED;
  446 +
  447 + try
  448 + {
  449 + session::get_default()->erase_eof();
  450 + }
  451 + catch(std::exception &e)
  452 + {
  453 + return HLLAPI_STATUS_SYSTEM_ERROR;
  454 + }
  455 + return HLLAPI_STATUS_SUCCESS;
  456 + }
  457 +
  458 + HLLAPI_API_CALL hllapi_erase_eol(void)
  459 + {
  460 + if(!hllapi_is_connected())
  461 + return HLLAPI_STATUS_DISCONNECTED;
  462 +
  463 + try
  464 + {
  465 + session::get_default()->erase_eol();
  466 + }
  467 + catch(std::exception &e)
  468 + {
  469 + return HLLAPI_STATUS_SYSTEM_ERROR;
  470 + }
  471 + return HLLAPI_STATUS_SUCCESS;
  472 + }
  473 +
  474 + HLLAPI_API_CALL hllapi_erase_input(void)
  475 + {
  476 + if(!hllapi_is_connected())
  477 + return HLLAPI_STATUS_DISCONNECTED;
  478 +
  479 + try
  480 + {
  481 + session::get_default()->erase_input();
  482 + }
  483 + catch(std::exception &e)
  484 + {
  485 + return HLLAPI_STATUS_SYSTEM_ERROR;
  486 + }
  487 + return HLLAPI_STATUS_SUCCESS;
  488 + }
  489 +
  490 + HLLAPI_API_CALL hllapi_action(LPSTR buffer) {
  491 + try
  492 + {
  493 + session::get_default()->action((const char *) buffer);
  494 + }
  495 + catch(std::exception &e)
  496 + {
  497 + return HLLAPI_STATUS_SYSTEM_ERROR;
  498 + }
  499 + return HLLAPI_STATUS_SUCCESS;
  500 + }
  501 +
  502 + HLLAPI_API_CALL hllapi_print(void)
  503 + {
  504 + return session::get_default()->print();
  505 + }
  506 +
  507 + char * hllapi_get_string(int offset, size_t len)
  508 + {
  509 + try
  510 + {
  511 + string str = session::get_default()->get_string(offset-1,len);
  512 + char * ret = strdup(str.c_str());
  513 + return ret;
  514 + }
  515 + catch(std::exception &e)
  516 + {
  517 + }
  518 +
  519 + return NULL;
  520 + }
  521 +
  522 + void hllapi_free(void *p)
  523 + {
  524 + free(p);
  525 + }
  526 +
  527 + HLLAPI_API_CALL hllapi_reset(void)
  528 + {
  529 + return HLLAPI_STATUS_SUCCESS;
  530 + }
  531 +
  532 + HLLAPI_API_CALL hllapi_input_string(LPSTR input, WORD length)
  533 + {
  534 + static const char control_char = '@';
  535 +
  536 + size_t szText;
  537 + char * text;
  538 + int rc = 0;
  539 +
  540 + if(!hllapi_is_connected()) {
  541 + return HLLAPI_STATUS_DISCONNECTED;
  542 + }
  543 +
  544 + if(!input)
  545 + {
  546 + return HLLAPI_STATUS_BAD_PARAMETER;
  547 + }
  548 +
  549 + if(length > 0 )
  550 + szText = length;
  551 + else
  552 + szText = strlen(input);
  553 +
  554 + text = (char *) malloc(szText+2);
  555 + memcpy(text,input,szText);
  556 + text[szText] = 0;
  557 +
  558 + trace("input[%s]",text);
  559 +
  560 + if(strchr(text,control_char))
  561 + {
  562 + // Convert control char
  563 + char * buffer = text;
  564 + char * ptr;
  565 +
  566 + for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))
  567 + {
  568 + *(ptr++) = 0;
  569 +
  570 + trace("input[%s]",buffer);
  571 + hllapi_emulate_input(buffer,-1,0);
  572 +
  573 + switch(*(ptr++))
  574 + {
  575 + case 'P': // Print
  576 + rc = hllapi_print();
  577 + break;
  578 +
  579 + case 'E': // Enter
  580 + hllapi_enter();
  581 + break;
  582 +
  583 + case 'F': // Erase EOF
  584 + hllapi_erase_eof();
  585 + break;
  586 +
  587 + case '1': // PF1
  588 + hllapi_pfkey(1);
  589 + break;
  590 +
  591 + case '2': // PF2
  592 + hllapi_pfkey(2);
  593 + break;
  594 +
  595 + case '3': // PF3
  596 + hllapi_pfkey(3);
  597 + break;
  598 +
  599 + case '4': // PF4
  600 + hllapi_pfkey(4);
  601 + break;
  602 +
  603 + case '5': // PF5
  604 + hllapi_pfkey(5);
  605 + break;
  606 +
  607 + case '6': // PF6
  608 + hllapi_pfkey(6);
  609 + break;
  610 +
  611 + case '7': // PF7
  612 + hllapi_pfkey(7);
  613 + break;
  614 +
  615 + case '8': // PF8
  616 + hllapi_pfkey(8);
  617 + break;
  618 +
  619 + case '9': // PF9
  620 + hllapi_pfkey(9);
  621 + break;
  622 +
  623 + case 'a': // PF10
  624 + hllapi_pfkey(10);
  625 + break;
  626 +
  627 + case 'b': // PF11
  628 + hllapi_pfkey(11);
  629 + break;
  630 +
  631 + case 'c': // PF12
  632 + hllapi_pfkey(12);
  633 + break;
  634 +
  635 + case 'd': // PF13
  636 + hllapi_pfkey(13);
  637 + break;
  638 +
  639 + case 'e': // PF14
  640 + hllapi_pfkey(14);
  641 + break;
  642 +
  643 + case 'f': // PF15
  644 + hllapi_pfkey(15);
  645 + break;
  646 +
  647 + case 'g': // PF16
  648 + hllapi_pfkey(16);
  649 + break;
  650 +
  651 + case 'h': // PF17
  652 + hllapi_pfkey(17);
  653 + break;
  654 +
  655 + case 'i': // PF18
  656 + hllapi_pfkey(18);
  657 + break;
  658 +
  659 + case 'j': // PF19
  660 + hllapi_pfkey(19);
  661 + break;
  662 +
  663 + case 'k': // PF20
  664 + hllapi_pfkey(20);
  665 + break;
  666 +
  667 + case 'l': // PF21
  668 + hllapi_pfkey(21);
  669 + break;
  670 +
  671 + case 'm': // PF22
  672 + hllapi_pfkey(22);
  673 + break;
  674 +
  675 + case 'n': // PF23
  676 + hllapi_pfkey(23);
  677 + break;
  678 +
  679 + case 'o': // PF24
  680 + hllapi_pfkey(24);
  681 + break;
  682 +
  683 + case '@': // Send '@' character
  684 + hllapi_emulate_input((LPSTR) "@",-1,0);
  685 + break;
  686 +
  687 + case 'x': // PA1
  688 + hllapi_pakey(1);
  689 + break;
  690 +
  691 + case 'y': // PA2
  692 + hllapi_pakey(2);
  693 + break;
  694 +
  695 + case 'z': // PA3
  696 + hllapi_pakey(3);
  697 + break;
  698 +
  699 + case 'B': // PC_LEFTTAB = "@B"
  700 + break;
  701 +
  702 + case 'T': // PC_RIGHTTAB = "@T"
  703 + break;
  704 +
  705 + case 'N': // PC_NEWLINE = "@N"
  706 + break;
  707 +
  708 + case 'C': // PC_CLEAR = "@C"
  709 + hllapi_erase_input();
  710 + break;
  711 +
  712 + case 'D': // PC_DELETE = "@D"
  713 + break;
  714 +
  715 + case 'H': // PC_HELP = "@H"
  716 + break;
  717 +
  718 + case 'I': // PC_INSERT = "@I"
  719 + break;
  720 +
  721 + case 'L': // PC_CURSORLEFT = "@L"
  722 + break;
  723 +
  724 + case 'R': // PC_RESET = "@R"
  725 + hllapi_reset();
  726 + break;
  727 +
  728 + case 'U': // PC_CURSORUP = "@U"
  729 + break;
  730 +
  731 + case 'V': // PC_CURSORDOWN = "@V"
  732 + break;
  733 +
  734 + case 'Z': // PC_CURSORRIGHT = "@Z"
  735 + break;
  736 +
  737 + case '0': // PC_HOME = "@0"
  738 + break;
  739 +
  740 + case 'p': // PC_PLUSKEY = "@p"
  741 + break;
  742 +
  743 + case 'q': // PC_END = "@q"
  744 + break;
  745 +
  746 + case 's': // PC_SCRLK = "@s"
  747 + break;
  748 +
  749 + case 't': // PC_NUMLOCK = "@t"
  750 + break;
  751 +
  752 + case 'u': // PC_PAGEUP = "@u"
  753 + break;
  754 +
  755 + case 'v': // PC_PAGEDOWN = "@v"
  756 + break;
  757 +
  758 + case '/': // PC_OVERRUNOFQUEUE = "@/" ' Queue overflow, used in Get Key only
  759 + break;
  760 +
  761 + case '$': // PC_ALTCURSOR = "@$" ' Presentation Manager only, unused in VB environment
  762 + break;
  763 +
  764 + case '<': // PC_BACKSPACE = "@<"
  765 + break;
  766 +
  767 +
  768 +/*
  769 +
  770 +Global Const PC_TEST = "@A@C"
  771 +Global Const PC_WORDDELETE = "@A@D"
  772 +Global Const PC_FIELDEXIT = "@A@E"
  773 +Global Const PC_ERASEINPUT = "@A@F"
  774 +Global Const PC_SYSTEMREQUEST = "@A@H"
  775 +Global Const PC_INSERTTOGGLE = "@A@I"
  776 +Global Const PC_CURSORSELECT = "@A@J"
  777 +Global Const PC_CURSLEFTFAST = "@A@L"
  778 +Global Const PC_GETCURSOR = "@A@N"
  779 +Global Const PC_LOCATECURSOR = "@A@O"
  780 +Global Const PC_ATTENTION = "@A@Q"
  781 +Global Const PC_DEVICECANCEL = "@A@R"
  782 +Global Const PC_PRINTPS = "@A@T"
  783 +Global Const PC_CURSUPFAST = "@A@U"
  784 +Global Const PC_CURSDOWNFAST = "@A@V"
  785 +Global Const PC_HEX = "@A@X"
  786 +Global Const PC_FUNCTIONKEY = "@A@Y"
  787 +Global Const PC_CURSRIGHTFAST = "@A@Z"
  788 +
  789 +Global Const PC_REVERSEVIDEO = "@A@9"
  790 +Global Const PC_UNDERSCORE = "@A@b"
  791 +Global Const PC_BLINK = "@A@c"
  792 +Global Const PC_RED = "@A@d"
  793 +Global Const PC_PINK = "@A@e"
  794 +Global Const PC_GREEN = "@A@f"
  795 +Global Const PC_YELLOW = "@A@g"
  796 +Global Const PC_BLUE = "@A@h"
  797 +Global Const PC_TURQOISE = "@A@i"
  798 +Global Const PC_WHITE = "@A@j"
  799 +Global Const PC_RSTHOSTCOLORS = "@A@l"
  800 +Global Const PC_PRINTPC = "@A@t"
  801 +
  802 +Global Const PC_FIELDMINUS = "@A@-"
  803 +Global Const PC_FIELDPLUS = "@A@+"
  804 +
  805 +*/
  806 +
  807 + }
  808 +
  809 + buffer = ptr;
  810 +
  811 + }
  812 +
  813 + if(*buffer)
  814 + hllapi_emulate_input(buffer,-1,0);
  815 +
  816 + }
  817 + else
  818 + {
  819 + hllapi_emulate_input(text,szText,0);
  820 + }
  821 +
  822 + free(text);
  823 +
  824 + return rc;
  825 + }
  826 +
src/core/environ.bat 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +@echo off
  2 +
  3 +set VC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
  4 +set WINSDK=C:\Program Files (x86)\Windows Kits\8.1
  5 +set PATH=%PATH%;"%VC%\bin";"%WINSDK%\bin\x86\"
  6 +
src/core/hllapi.cbp 0 → 100644
@@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  2 +<CodeBlocks_project_file>
  3 + <FileVersion major="1" minor="6" />
  4 + <Project>
  5 + <Option title="pw3270 HLLAPI" />
  6 + <Option makefile_is_custom="1" />
  7 + <Option pch_mode="2" />
  8 + <Option compiler="gcc" />
  9 + <Build>
  10 + <Target title="Debug">
  11 + <Option output=".bin/Debug/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
  12 + <Option object_output=".obj/Debug/" />
  13 + <Option type="1" />
  14 + <Option compiler="gcc" />
  15 + <Compiler>
  16 + <Add option="-g" />
  17 + </Compiler>
  18 + <MakeCommands>
  19 + <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />
  20 + <CompileFile command="$make -f $makefile $file" />
  21 + <Clean command="$make -f $makefile clean$target" />
  22 + <DistClean command="$make -f $makefile distclean$target" />
  23 + <AskRebuildNeeded command="$make -q -f $makefile $target" />
  24 + <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />
  25 + </MakeCommands>
  26 + </Target>
  27 + <Target title="Release">
  28 + <Option output=".bin/Release/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
  29 + <Option object_output=".obj/Release/" />
  30 + <Option type="1" />
  31 + <Option compiler="gcc" />
  32 + <Compiler>
  33 + <Add option="-O2" />
  34 + </Compiler>
  35 + <Linker>
  36 + <Add option="-s" />
  37 + </Linker>
  38 + </Target>
  39 + <Target title="test">
  40 + <Option output=".bin/Debug/test" prefix_auto="1" extension_auto="1" />
  41 + <Option object_output=".obj/Debug/" />
  42 + <Option type="1" />
  43 + <Option compiler="gcc" />
  44 + <Compiler>
  45 + <Add option="-g" />
  46 + </Compiler>
  47 + <Environment>
  48 + <Variable name="LIB3270_CFLAGS" value='&quot;-I../../../src/include&quot;' />
  49 + <Variable name="LIB3270_LIBS" value='&quot;-L../../../.bin/Debug -l3270&quot;' />
  50 + <Variable name="PW3270_LIBS" value='&quot;-L../../../.bin/Debug -lpw3270 -l3270&quot;' />
  51 + </Environment>
  52 + <MakeCommands>
  53 + <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />
  54 + <CompileFile command="$make -f $makefile $file" />
  55 + <Clean command="$make -f $makefile clean$target" />
  56 + <DistClean command="$make -f $makefile distclean$target" />
  57 + <AskRebuildNeeded command="$make -q -f $makefile $target" />
  58 + <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />
  59 + </MakeCommands>
  60 + </Target>
  61 + </Build>
  62 + <Compiler>
  63 + <Add option="-Wall" />
  64 + </Compiler>
  65 + <Unit filename="../../include/lib3270.h" />
  66 + <Unit filename="../../include/pw3270/hllapi.h" />
  67 + <Unit filename="../../include/pw3270cpp.h" />
  68 + <Unit filename="Makefile.in" />
  69 + <Unit filename="calls.cc" />
  70 + <Unit filename="client.h" />
  71 + <Unit filename="hllapi.c">
  72 + <Option compilerVar="CC" />
  73 + </Unit>
  74 + <Unit filename="pluginmain.c">
  75 + <Option compilerVar="CC" />
  76 + </Unit>
  77 + <Unit filename="remotectl.h" />
  78 + <Unit filename="server.h" />
  79 + <Unit filename="testprogram.c">
  80 + <Option compilerVar="CC" />
  81 + </Unit>
  82 + <Extensions>
  83 + <code_completion />
  84 + <envvars />
  85 + <debugger />
  86 + <lib_finder disable_auto="1" />
  87 + </Extensions>
  88 + </Project>
  89 +</CodeBlocks_project_file>
src/core/hllapi.cc 0 → 100644
@@ -0,0 +1,466 @@ @@ -0,0 +1,466 @@
  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 hllapi.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 <pw3270/hllapi.h>
  35 + #include <stdio.h>
  36 + #include <time.h>
  37 + #include <lib3270/log.h>
  38 + #include "client.h"
  39 +
  40 + /*--[ Prototipes ]-----------------------------------------------------------------------------------*/
  41 +
  42 + static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc);
  43 + static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc);
  44 + static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc);
  45 + static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc);
  46 + static int copy_str_to_ps(char *buffer, unsigned short *length, unsigned short *rc);
  47 + static int search_ps(char *buffer, unsigned short *length, unsigned short *rc);
  48 + static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc);
  49 + static int wait_system(char *buffer, unsigned short *length, unsigned short *rc);
  50 + static int reset_system(char *buffer, unsigned short *length, unsigned short *rc);
  51 + static int pause_system(char *buffer, unsigned short *length, unsigned short *rc);
  52 + static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc);
  53 +
  54 + static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
  55 + static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
  56 + static int input_string(char *buffer, unsigned short *length, unsigned short *rc);
  57 +
  58 + static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc);
  59 +
  60 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  61 +
  62 + static const struct _hllapi_call
  63 + {
  64 + unsigned long func;
  65 + int (*exec)(char *buffer, unsigned short *length, unsigned short *rc);
  66 + } hllapi_call[] =
  67 + {
  68 + { HLLAPI_CMD_CONNECTPS, connect_ps },
  69 + { HLLAPI_CMD_DISCONNECTPS, disconnect_ps },
  70 + { HLLAPI_CMD_GETREVISION, get_library_revision },
  71 + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position },
  72 + { HLLAPI_CMD_SETCURSOR, set_cursor_position },
  73 + { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str },
  74 + { HLLAPI_CMD_INPUTSTRING, input_string },
  75 + { HLLAPI_CMD_WAIT, wait_system },
  76 + { HLLAPI_CMD_COPYPS, copy_ps },
  77 + { HLLAPI_CMD_SEARCHPS, search_ps },
  78 + { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps },
  79 + { HLLAPI_CMD_SENDFILE, invalid_request },
  80 + { HLLAPI_CMD_RECEIVEFILE, invalid_request },
  81 + { HLLAPI_RESET_SYSTEM, reset_system },
  82 + { HLLAPI_CMD_PAUSE, pause_system },
  83 + { HLLAPI_SET_SESSION_PARAMETERS, set_session_parameters }
  84 +
  85 + };
  86 +
  87 + static enum _pause_mode
  88 + {
  89 + PAUSE_MODE_IPAUSE, ///< @brief Interruptible pause. After the Start Host Notification (23) function is executed, a host event satisfies a pause.
  90 + PAUSE_MODE_FPAUSE ///< @brief A full-duration pause lasts for however long you specified in the Pause (18) function.
  91 + } pause_mode = PAUSE_MODE_IPAUSE;
  92 +
  93 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  94 +
  95 +HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
  96 +{
  97 + unsigned int f;
  98 +
  99 + trace("%s(%d)",__FUNCTION__,*func);
  100 +
  101 + for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++)
  102 + {
  103 + if(hllapi_call[f].func == *func)
  104 + {
  105 + int status = hllapi_call[f].exec(buffer,length,rc);
  106 + trace("hllapi(%d) exits with rc=%d",*func,status);
  107 + return status;
  108 + }
  109 + }
  110 +
  111 + trace("hllapi(%d) failed",*func);
  112 +
  113 + *rc = HLLAPI_STATUS_UNSUPPORTED;
  114 + return *rc;
  115 +
  116 +}
  117 +
  118 +static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc)
  119 +{
  120 + *rc = HLLAPI_STATUS_BAD_PARAMETER;
  121 + return *rc;
  122 +}
  123 +
  124 +static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)
  125 +{
  126 + char *tempbuffer = NULL;
  127 +
  128 + trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer));
  129 +
  130 + if(strlen(buffer) > *length)
  131 + buffer[*length] = 0;
  132 +
  133 + if(!strrchr(buffer,':'))
  134 + {
  135 + int sz = strlen(buffer);
  136 +
  137 + tempbuffer = (char *) malloc(sz+2);
  138 + strcpy(tempbuffer,buffer);
  139 + tempbuffer[sz-1] = ':';
  140 + tempbuffer[sz] = buffer[sz-1];
  141 + tempbuffer[sz+1] = 0;
  142 + buffer = tempbuffer;
  143 + }
  144 +
  145 + *rc = hllapi_init(buffer);
  146 +
  147 + if(tempbuffer)
  148 + free(tempbuffer);
  149 +
  150 + return 0;
  151 +}
  152 +
  153 +static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc)
  154 +{
  155 + *rc = hllapi_deinit();
  156 + return 0;
  157 +}
  158 +
  159 +static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc)
  160 +{
  161 + *rc = hllapi_get_revision();
  162 + return 0;
  163 +}
  164 +
  165 +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
  166 +{
  167 + int pos = hllapi_getcursor();
  168 +
  169 + trace("%s(%d)",__FUNCTION__,pos);
  170 +
  171 + if(pos < 0)
  172 + return -1;
  173 +
  174 + *rc = pos;
  175 + return 0;
  176 +}
  177 +
  178 +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
  179 +{
  180 + trace("%s(%d)",__FUNCTION__,*rc);
  181 + *rc = hllapi_setcursor(*rc);
  182 + return 0;
  183 +}
  184 +
  185 +static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc)
  186 +{
  187 +
  188 + // Length Length of the target data string.
  189 + // PS Position Position within the host presentation space of the first byte in your target data string.
  190 + *rc = hllapi_get_screen(*rc,buffer,*length);
  191 +
  192 + return 0;
  193 +}
  194 +
  195 +static int input_string(char *buffer, unsigned short *length, unsigned short *rc)
  196 +{
  197 + *rc = hllapi_input_string(buffer,*length);
  198 + return 0;
  199 +}
  200 +
  201 +static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)
  202 +{
  203 + /*
  204 + * Data String Target string for search.
  205 + * Length Length of the target data string. Overridden in EOT mode.
  206 + * PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end
  207 + * (SRCHBKWD option). Overridden in SRCHALL (default) mode.
  208 + *
  209 + * Return in *ps:
  210 + *
  211 + * = 0 The string was not found.
  212 + * > 0 The string was found at the indicated host presentation space position.
  213 + *
  214 + * Return code:
  215 + *
  216 + * 0 The Search Presentation Space function was successful.
  217 + * 1 Your program is not connected to a host session.
  218 + * 2 An error was made in specifying parameters.
  219 + * 7 The host presentation space position is not valid.
  220 + * 9 A system error was encountered.
  221 + * 24 The search string was not found.
  222 + *
  223 + */
  224 + size_t szBuffer = strlen(buffer);
  225 + char * text;
  226 + int rc = HLLAPI_STATUS_SYSTEM_ERROR;
  227 +
  228 + if(!hllapi_is_connected())
  229 + return HLLAPI_STATUS_DISCONNECTED;
  230 +
  231 + if(*length < szBuffer)
  232 + szBuffer = *length;
  233 +
  234 +
  235 + text = hllapi_get_string(*ps,szBuffer);
  236 + if(!text)
  237 + return HLLAPI_STATUS_SYSTEM_ERROR;
  238 +
  239 + if(strncmp(text,buffer,szBuffer))
  240 + {
  241 + // String not found
  242 + *ps = 0;
  243 + rc = HLLAPI_STATUS_NOT_FOUND;
  244 + }
  245 + else
  246 + {
  247 + // String found
  248 + *ps = 1;
  249 + rc = HLLAPI_STATUS_SUCCESS;
  250 + }
  251 +
  252 + hllapi_free(text);
  253 +
  254 + return rc;
  255 +}
  256 +
  257 +static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)
  258 +{
  259 + /*
  260 + * Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space.
  261 + * DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space.
  262 + *
  263 + * Length NA (the length of the host presentation space is implied).
  264 + * PS Position NA.
  265 + *
  266 + * Return values:
  267 + *
  268 + * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.
  269 + * 1 Your program is not connected to a host session.
  270 + * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.
  271 + * 5 The host presentation space was copied. The keyboard was locked.
  272 + * 9 A system error was encountered.
  273 + *
  274 + */
  275 + size_t szBuffer = strlen(buffer);
  276 + char * text;
  277 +
  278 + if(!hllapi_is_connected())
  279 + return HLLAPI_STATUS_DISCONNECTED;
  280 +
  281 + text = hllapi_get_string(1, szBuffer);
  282 +
  283 + if(!text)
  284 + return HLLAPI_STATUS_SYSTEM_ERROR;
  285 +
  286 + memcpy(buffer,text,szBuffer);
  287 +
  288 + hllapi_free(text);
  289 +
  290 + return hllapi_get_state();
  291 +}
  292 +
  293 +static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
  294 +{
  295 + /*
  296 + * Checks the status of the host-connected presentation space. If the session is
  297 + * waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait
  298 + * function causes HLLAPI to wait up to 1 minute to see if the condition clears.
  299 + *
  300 + */
  301 +
  302 + /*
  303 + * Return Code Definition
  304 + *
  305 + * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input.
  306 + * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session.
  307 + * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM.
  308 + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked.
  309 + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
  310 + *
  311 + */
  312 +
  313 + /*
  314 + time_t end = time(0) + 60;
  315 +
  316 + while(time(0) < end)
  317 + {
  318 + int state = hllapi_get_state();
  319 +
  320 + if(state != HLLAPI_STATUS_WAITING)
  321 + return state;
  322 +
  323 + hllapi_wait(1);
  324 +
  325 + }
  326 +
  327 + return HLLAPI_STATUS_TIMEOUT;
  328 + */
  329 +
  330 + int state = hllapi_wait_for_ready(60);
  331 + return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);
  332 +
  333 +}
  334 +
  335 +static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)
  336 +{
  337 + /*
  338 + * Call Parameters
  339 + *
  340 + * Data String of ASCII data to be copied into the host presentation space.
  341 + * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.
  342 + * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.
  343 + *
  344 + * Return Parameters
  345 + *
  346 + * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful.
  347 + * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session.
  348 + * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy.
  349 + * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).
  350 + * 6 The copy was completed, but the data was truncated.
  351 + * 7 The host presentation space position is not valid.
  352 + * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.
  353 + *
  354 + */
  355 + size_t szText = strlen(text);
  356 +
  357 + if(*length < szText)
  358 + szText = *length;
  359 +
  360 + if(!szText)
  361 + return HLLAPI_STATUS_BAD_PARAMETER;
  362 +
  363 + switch(hllapi_get_message_id())
  364 + {
  365 + case LIB3270_MESSAGE_NONE:
  366 + break;
  367 +
  368 + case LIB3270_MESSAGE_DISCONNECTED:
  369 + return HLLAPI_STATUS_DISCONNECTED;
  370 +
  371 + case LIB3270_MESSAGE_MINUS:
  372 + case LIB3270_MESSAGE_PROTECTED:
  373 + case LIB3270_MESSAGE_NUMERIC:
  374 + case LIB3270_MESSAGE_OVERFLOW:
  375 + case LIB3270_MESSAGE_INHIBIT:
  376 + case LIB3270_MESSAGE_KYBDLOCK:
  377 + return HLLAPI_STATUS_KEYBOARD_LOCKED;
  378 +
  379 + default:
  380 + return HLLAPI_STATUS_SYSTEM_ERROR;
  381 + }
  382 +
  383 + return hllapi_emulate_input(text,szText,0);
  384 +}
  385 +
  386 +static int reset_system(char *buffer, unsigned short *length, unsigned short *rc)
  387 +{
  388 + return hllapi_reset();
  389 +}
  390 +
  391 +
  392 +static int pause_system(char *buffer, unsigned short *length, unsigned short *rc)
  393 +{
  394 + if(!*length)
  395 + {
  396 + // If you use the IPAUSE option and the pause value is zero, then the function
  397 + // waits up to 2400 half-second intervals, unless interrupted sooner. If you use the
  398 + // FPAUSE option and the pause value is zero, then the function returns
  399 + // immediately.
  400 +
  401 + if(pause_mode == PAUSE_MODE_FPAUSE)
  402 + {
  403 + return HLLAPI_STATUS_SUCCESS;
  404 + }
  405 + return hllapi_wait_for_ready(1200);
  406 + }
  407 +
  408 + if(pause_mode == PAUSE_MODE_FPAUSE)
  409 + {
  410 + // Pause fixo - Aguarda pelo tempo informado, independente de eventos.
  411 + return hllapi_wait( (*length) / 2);
  412 + }
  413 +
  414 + // Pause "flexivel", aguarda mudança no conteúdo da tela!!!
  415 +
  416 + // #warning Mudar comportamento na lib!
  417 +
  418 + return hllapi_wait_for_ready((*length) / 2);
  419 +}
  420 +
  421 +static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc)
  422 +{
  423 + if(!(*length && buffer && *buffer))
  424 + {
  425 + return HLLAPI_STATUS_BAD_PARAMETER;
  426 + }
  427 +
  428 + *rc = hllapi_set_session_parameter(buffer, *length, *rc);
  429 +
  430 + return 0;
  431 +}
  432 +
  433 +HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value)
  434 +{
  435 + if(!param)
  436 + {
  437 + return HLLAPI_STATUS_BAD_PARAMETER;
  438 + }
  439 +
  440 + if(!len)
  441 + {
  442 + len = strlen(param);
  443 + }
  444 +
  445 + if(!strncasecmp(param,"IPAUSE",len))
  446 + {
  447 + // IPAUSE
  448 + pause_mode = PAUSE_MODE_IPAUSE;
  449 + }
  450 + else if(!strncasecmp(param,"FPAUSE",len))
  451 + {
  452 + // FPAUSE
  453 + pause_mode = PAUSE_MODE_FPAUSE;
  454 + }
  455 + else if(!strncasecmp(param,"UNLOCKDELAY",len))
  456 + {
  457 + // UNLOCKDELAY
  458 + hllapi_set_unlock_delay(value);
  459 + }
  460 + else
  461 + {
  462 + return HLLAPI_STATUS_BAD_PARAMETER;
  463 + }
  464 +
  465 + return HLLAPI_STATUS_SUCCESS;
  466 +}
src/core/idlcomp.bat 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +@echo off
  2 +
  3 +midl.exe /I "%WINSDK%\Include\um" /I "%WINSDK%\Include\shared" /cpp_cmd "cl.exe" pw3270.idl
src/core/remotectl.h 0 → 100644
@@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
  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. 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., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como remotectl.h 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 + * Agradecimento:
  29 + *
  30 + * Hélio Passos
  31 + *
  32 + */
  33 +
  34 + #define ENABLE_NLS
  35 + #define GETTEXT_PACKAGE PACKAGE_NAME
  36 +
  37 + #include <libintl.h>
  38 + #include <glib/gi18n.h>
  39 + #include <gtk/gtk.h>
  40 +
  41 + #include <lib3270.h>
  42 + #include <lib3270/log.h>
  43 + #include <pw3270/hllapi.h>
  44 +
  45 + typedef struct _remotequery
  46 + {
  47 +#ifdef _WIN32
  48 + HANDLE hPipe; /**< Pipe handle (for response) */
  49 +#endif // _WIN32
  50 +
  51 + H3270 * hSession; /**< 3270 Session */
  52 + int cmd; /**< Command */
  53 + int rc; /**< Response status */
  54 +
  55 + int pos;
  56 + unsigned short length; /**< Query string length */
  57 + const gchar * text; /**< Query string */
  58 +
  59 + } QUERY;
  60 +
  61 + G_GNUC_INTERNAL void enqueue_request(QUERY *qry);
  62 + G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text);
  63 +
  64 + G_GNUC_INTERNAL void request_status(QUERY *qry, int rc);
  65 + G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value);
  66 + G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer);
  67 +
  68 +// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);
  69 +
  70 +
  71 +#ifdef _WIN32
  72 +
  73 + #define PIPE_BUFFER_LENGTH 8192
  74 +
  75 + void init_source_pipe(HANDLE hPipe);
  76 + void popup_lasterror(const gchar *fmt, ...);
  77 +
  78 +#endif // _WIN32
  79 +
  80 +
  81 +
  82 +
  83 +
  84 +
src/core/windows/resources.rc.in 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +#include <windows.h>
  2 +
  3 +VS_VERSION_INFO VERSIONINFO
  4 +FILEVERSION @WIN32_FILE_VERSION@
  5 +PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@
  6 +
  7 +BEGIN
  8 +
  9 + BLOCK "StringFileInfo"
  10 + BEGIN
  11 + BLOCK "080904E4"
  12 + BEGIN
  13 + VALUE "FileDescription", "pw3270 HLLAPI Client Module\0"
  14 + VALUE "CompanyName", "Banco do Brasil S/A.\0"
  15 + VALUE "FileVersion", "@WIN32_VERSION@\0"
  16 + VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"
  17 + VALUE "OriginalFilename", "hllapi@DLLEXT@\0"
  18 + VALUE "ProductName", "pw3270\0"
  19 + VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0"
  20 + END
  21 + END
  22 +
  23 + BLOCK "VarFileInfo"
  24 + BEGIN
  25 + VALUE "Translation", 0x809, 0x04E4
  26 + END
  27 +
  28 +END
  29 +
src/daemon/linux/daemon.c
@@ -1,122 +0,0 @@ @@ -1,122 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como daemon.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 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 -#include <glib.h>  
37 -#include <dbus/dbus.h>  
38 -#include <dbus/dbus-glib-lowlevel.h>  
39 -#include <dbus/dbus-glib.h>  
40 -  
41 -#include "daemon.h"  
42 -#include "dbus-glue.h"  
43 -  
44 -#define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270"  
45 -#define PW3270_DBUS_SERVICE "br.com.bb.pw3270"  
46 -  
47 -  
48 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
49 -  
50 - static DBusGConnection * connection = NULL;  
51 - static DBusGProxy * proxy = NULL;  
52 - static H3270 * hSession = NULL;  
53 -  
54 - GMainLoop * main_loop = NULL;  
55 -  
56 -  
57 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
58 -  
59 -static int initialize(void)  
60 -{  
61 - GError * error = NULL;  
62 - guint result;  
63 -  
64 - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);  
65 - if(error)  
66 - {  
67 - g_message("Error \"%s\" getting session dbus",error->message);  
68 - g_error_free(error);  
69 - return -1;  
70 - }  
71 -  
72 - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);  
73 -  
74 - org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);  
75 -  
76 - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH);  
77 -  
78 - return 0;  
79 -}  
80 -  
81 -static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args)  
82 -{  
83 - g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args);  
84 -}  
85 -  
86 -int main(int numpar, char *param[])  
87 -{  
88 - g_type_init ();  
89 -  
90 - if (!g_thread_supported ())  
91 - g_thread_init (NULL);  
92 -  
93 - dbus_g_thread_init ();  
94 -  
95 - lib3270_set_log_handler(loghandler);  
96 - pw3270_dbus_register_io_handlers();  
97 -  
98 - hSession = lib3270_session_new("");  
99 -  
100 - main_loop = g_main_loop_new (NULL, FALSE);  
101 -  
102 - if(initialize())  
103 - return -1;  
104 -  
105 - g_main_loop_run(main_loop);  
106 -  
107 - lib3270_session_free(hSession);  
108 -  
109 - return 0;  
110 -}  
111 -  
112 -void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context)  
113 -{  
114 - g_main_loop_quit(main_loop);  
115 - dbus_g_method_return(context,0);  
116 -}  
117 -  
118 -H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object)  
119 -{  
120 - return hSession;  
121 -}  
122 -  
src/daemon/linux/iocallback.c
@@ -1,361 +0,0 @@ @@ -1,361 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como iocallback.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 -#if defined(_WIN32) /*[*/  
33 - #include <windows.h>  
34 -#elif defined(__APPLE__)  
35 - #include <poll.h>  
36 - #include <string.h>  
37 -#else  
38 - #include <poll.h>  
39 - #include <string.h>  
40 -#endif /*]*/  
41 -  
42 -#include <stdio.h>  
43 -#include <glib.h>  
44 -#include "daemon.h"  
45 -  
46 -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm);  
47 -static void static_RemoveSource(void *id);  
48 -  
49 -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session));  
50 -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session));  
51 -  
52 -static void * static_AddTimeOut(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session));  
53 -static void static_RemoveTimeOut(void * timer);  
54 -static int static_Sleep(H3270 *hSession, int seconds);  
55 -static int static_RunPendingEvents(H3270 *hSession, int wait);  
56 -  
57 -static gboolean IO_prepare(GSource *source, gint *timeout);  
58 -static gboolean IO_check(GSource *source);  
59 -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);  
60 -static void IO_finalize(GSource *source); /* Can be NULL */  
61 -static gboolean IO_closure(gpointer data);  
62 -  
63 -/*---[ Structs ]-------------------------------------------------------------------------------------------*/  
64 -  
65 - typedef struct _IO_Source  
66 - {  
67 - GSource gsrc;  
68 - GPollFD poll;  
69 -#if defined(_WIN32)  
70 - HANDLE source;  
71 -#else  
72 - int source;  
73 -#endif // _WIN32  
74 - void (*fn)(H3270 *session);  
75 - H3270 *session;  
76 - } IO_Source;  
77 -  
78 - typedef struct _timer  
79 - {  
80 - unsigned char remove;  
81 - void (*fn)(H3270 *session);  
82 - H3270 *session;  
83 - } TIMER;  
84 -  
85 - static GSourceFuncs IOSources =  
86 - {  
87 - IO_prepare,  
88 - IO_check,  
89 - IO_dispatch,  
90 - IO_finalize,  
91 - IO_closure,  
92 - NULL  
93 - };  
94 -  
95 -/*---[ Implement ]-----------------------------------------------------------------------------------------*/  
96 -  
97 -#ifdef _WIN32  
98 -static void * AddSource(HANDLE source, H3270 *session, gushort events, void (*fn)(H3270 *session))  
99 -#else  
100 -static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session))  
101 -#endif // _WIN32  
102 -{  
103 - IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source));  
104 -  
105 - src->source = source;  
106 - src->fn = fn;  
107 - src->poll.fd = (int) source;  
108 - src->poll.events = events;  
109 - src->session = session;  
110 -  
111 - g_source_attach((GSource *) src,NULL);  
112 - g_source_add_poll((GSource *) src,&src->poll);  
113 -  
114 - return src;  
115 -}  
116 -  
117 -#ifdef _WIN32  
118 -static void * static_AddInput(HANDLE source, H3270 *session, void (*fn)(H3270 *session))  
119 -#else  
120 -static void * static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session))  
121 -#endif // _WIN32  
122 -{  
123 - return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn);  
124 -}  
125 -  
126 -static void static_RemoveSource(void *id)  
127 -{  
128 - if(id)  
129 - g_source_destroy((GSource *) id);  
130 -}  
131 -  
132 -#if defined(_WIN32)  
133 -static void * static_AddExcept(HANDLE source, H3270 *session, void (*fn)(H3270 *session))  
134 -{  
135 - return 0;  
136 -}  
137 -#else  
138 -static void * static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session))  
139 -{  
140 - return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn);  
141 -}  
142 -#endif // _WIN32  
143 -  
144 -static gboolean do_timer(TIMER *t)  
145 -{  
146 - if(!t->remove)  
147 - t->fn(t->session);  
148 - return FALSE;  
149 -}  
150 -  
151 -static void * static_AddTimeOut(unsigned long interval, H3270 *session, void (*proc)(H3270 *session))  
152 -{  
153 - TIMER *t = g_malloc0(sizeof(TIMER));  
154 -  
155 - t->fn = proc;  
156 - t->session = session;  
157 -  
158 - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free);  
159 -  
160 - return t;  
161 -}  
162 -  
163 -static void static_RemoveTimeOut(void * timer)  
164 -{  
165 - ((TIMER *) timer)->remove++;  
166 -}  
167 -  
168 -static gboolean IO_prepare(GSource *source, gint *timeout)  
169 -{  
170 - /*  
171 - * Called before all the file descriptors are polled.  
172 - * If the source can determine that it is ready here  
173 - * (without waiting for the results of the poll() call)  
174 - * it should return TRUE.  
175 - *  
176 - * It can also return a timeout_ value which should be the maximum  
177 - * timeout (in milliseconds) which should be passed to the poll() call.  
178 - * The actual timeout used will be -1 if all sources returned -1,  
179 - * or it will be the minimum of all the timeout_ values  
180 - * returned which were >= 0.  
181 - *  
182 - */  
183 - return 0;  
184 -}  
185 -  
186 -static gboolean IO_check(GSource *source)  
187 -{  
188 - /*  
189 - * Called after all the file descriptors are polled.  
190 - * The source should return TRUE if it is ready to be dispatched.  
191 - * Note that some time may have passed since the previous prepare  
192 - * function was called, so the source should be checked again here.  
193 - *  
194 - */  
195 -#if defined(_WIN32) /*[*/  
196 -  
197 - if(WaitForSingleObject(((IO_Source *) source)->source,0) == WAIT_OBJECT_0)  
198 - return TRUE;  
199 -  
200 -#else /*][*/  
201 -  
202 - struct pollfd fds;  
203 -  
204 - memset(&fds,0,sizeof(fds));  
205 -  
206 - fds.fd = ((IO_Source *) source)->poll.fd;  
207 - fds.events = ((IO_Source *) source)->poll.events;  
208 -  
209 - if(poll(&fds,1,0) > 0)  
210 - return TRUE;  
211 -  
212 -#endif /*]*/  
213 -  
214 - return FALSE;  
215 -}  
216 -  
217 -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)  
218 -{  
219 - /*  
220 - * Called to dispatch the event source,  
221 - * after it has returned TRUE in either its prepare or its check function.  
222 - * The dispatch function is passed in a callback function and data.  
223 - * The callback function may be NULL if the source was never connected  
224 - * to a callback using g_source_set_callback(). The dispatch function  
225 - * should call the callback function with user_data and whatever additional  
226 - * parameters are needed for this type of event source.  
227 - */  
228 - ((IO_Source *) source)->fn(((IO_Source *) source)->session);  
229 - return TRUE;  
230 -}  
231 -  
232 -static void IO_finalize(GSource *source)  
233 -{  
234 -  
235 -}  
236 -  
237 -static gboolean IO_closure(gpointer data)  
238 -{  
239 - return 0;  
240 -}  
241 -  
242 -struct bgParameter  
243 -{  
244 - gboolean running;  
245 - gboolean timer;  
246 - H3270 *session;  
247 - int rc;  
248 - int(*callback)(H3270 *session, void *);  
249 - void *parm;  
250 -  
251 -};  
252 -  
253 -gpointer BgCall(struct bgParameter *p)  
254 -{  
255 -// trace("%s starts",__FUNCTION__);  
256 - p->rc = p->callback(p->session, p->parm);  
257 - p->running = FALSE;  
258 -// trace("%s ends",__FUNCTION__);  
259 - return 0;  
260 -}  
261 -  
262 -static gboolean wait_for_thread(struct bgParameter *p)  
263 -{  
264 - if(!p->running)  
265 - {  
266 - p->timer = 0;  
267 - return FALSE;  
268 - }  
269 - return TRUE;  
270 -}  
271 -  
272 -static int static_CallAndWait(int(*callback)(H3270 *session, void *), H3270 *session, void *parm)  
273 -{  
274 - struct bgParameter p = { TRUE, TRUE, session, -1, callback, parm };  
275 - GThread * thread;  
276 -  
277 -// trace("Starting auxiliary thread for callback %p",callback);  
278 -  
279 - p.running = TRUE;  
280 - p.timer = TRUE;  
281 -  
282 - thread = g_thread_create( (GThreadFunc) BgCall, &p, 0, NULL);  
283 -  
284 - if(!thread)  
285 - {  
286 - g_error("Can't start background thread");  
287 - return -1;  
288 - }  
289 -  
290 - g_timeout_add(50,(GSourceFunc) wait_for_thread,(gpointer) &p);  
291 -  
292 - while(p.timer)  
293 - g_main_context_iteration(g_main_loop_get_context(main_loop),TRUE);  
294 -  
295 - return p.rc;  
296 -}  
297 -  
298 -static int static_Sleep(H3270 *hSession, int seconds)  
299 -{  
300 - time_t end = time(0) + seconds;  
301 -  
302 - while(time(0) < end)  
303 - g_main_iteration(TRUE);  
304 -  
305 - return 0;  
306 -}  
307 -  
308 -static int static_RunPendingEvents(H3270 *hSession, int wait)  
309 -{  
310 - GMainContext *context = g_main_loop_get_context(main_loop);  
311 - int rc = 0;  
312 - while(g_main_context_pending(context))  
313 - {  
314 - rc = 1;  
315 - g_main_context_iteration(context,FALSE);  
316 - }  
317 -  
318 - if(wait)  
319 - g_main_context_iteration(context,TRUE);  
320 -  
321 - return rc;  
322 -}  
323 -  
324 -static void beep(H3270 *session)  
325 -{  
326 -}  
327 -  
328 -void pw3270_dbus_register_io_handlers(void)  
329 -{  
330 - static const struct lib3270_callbacks hdl =  
331 - {  
332 - sizeof(struct lib3270_callbacks),  
333 -  
334 - static_AddTimeOut,  
335 - static_RemoveTimeOut,  
336 -  
337 - static_AddInput,  
338 - static_RemoveSource,  
339 -  
340 - static_AddExcept,  
341 -  
342 -#ifdef G_THREADS_ENABLED  
343 - static_CallAndWait,  
344 -#else  
345 - NULL,  
346 -#endif  
347 -  
348 - static_Sleep,  
349 - static_RunPendingEvents,  
350 - beep  
351 -  
352 - };  
353 -  
354 - #error Need rewrite  
355 -  
356 - if(lib3270_register_handlers(&hdl))  
357 - {  
358 - g_error("%s","Can't set lib3270 I/O handlers");  
359 - }  
360 -  
361 -}  
src/hllapi/Makefile.in
@@ -1,315 +0,0 @@ @@ -1,315 +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 -# Contatos:  
22 -#  
23 -# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
24 -# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)  
25 -#  
26 -  
27 -MODULE_NAME=hllapi  
28 -LIBNAME=lib$(MODULE_NAME)@DLLEXT@  
29 -  
30 -PLUGIN_SOURCES=pluginmain.c  
31 -API_SOURCES=calls.c hllapi.c  
32 -  
33 -#---[ Configuration values ]-------------------------------------------------------------  
34 -  
35 -PACKAGE_NAME=@PACKAGE_NAME@  
36 -PACKAGE_VERSION=@PACKAGE_VERSION@  
37 -PACKAGE_TARNAME=@PACKAGE_TARNAME@  
38 -  
39 -prefix=@prefix@  
40 -exec_prefix=@exec_prefix@  
41 -bindir=@bindir@  
42 -sbindir=@sbindir@  
43 -libdir=@libdir@  
44 -  
45 -BASEDIR=@BASEDIR@  
46 -SRCDIR=$(BASEDIR)/.src/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)/src/plugins/$(MODULE_NAME)  
47 -POTDIR=$(BASEDIR)/.pot/plugins/$(MODULE_NAME)  
48 -  
49 -OBJDIR=$(BASEDIR)/.obj/plugins/$(MODULE_NAME)  
50 -OBJDBG=$(OBJDIR)/Debug  
51 -OBJRLS=$(OBJDIR)/Release  
52 -  
53 -BINDIR=$(BASEDIR)/.bin  
54 -BINDBG=$(BINDIR)/Debug  
55 -BINRLS=$(BINDIR)/Release  
56 -  
57 -MKDIR=@MKDIR_P@  
58 -CC=@CC@  
59 -CXX=@CXX@  
60 -LD=@CXX@  
61 -AR=@AR@  
62 -XGETTEXT=@XGETTEXT@  
63 -MSGCAT=@MSGCAT@  
64 -INSTALL=@INSTALL@  
65 -INSTALL_DATA=@INSTALL_DATA@  
66 -INSTALL_PROGRAM=@INSTALL_PROGRAM@  
67 -LN_S=@LN_S@  
68 -  
69 -CFLAGS=\  
70 - @CFLAGS@ \  
71 - @LIBV3270_CFLAGS@ \  
72 - @GTK_CFLAGS@ \  
73 - -I$(BASEDIR)/src/include  
74 -  
75 -LIBS=@LIBS@  
76 -  
77 -API_LIBS=\  
78 - $(LIBS) \  
79 - -lpw3270cpp \  
80 - @LIBICONV@  
81 -  
82 -PLUGIN_LIBS=\  
83 - $(LIBS) \  
84 - @GTK_LIBS@ \  
85 - @GLIB_LIBS@ \  
86 - @LIB3270_LIBS@ \  
87 - @LIBV3270_LIBS@ \  
88 - @PW3270_LIBS@  
89 -  
90 -LDFLAGS=\  
91 - @LDFLAGS@  
92 -  
93 -#---[ Rules ]----------------------------------------------------------------------------  
94 -  
95 -DEPENDS=*.h Makefile  
96 -  
97 -$(OBJDBG)/%.o: \  
98 - %.c \  
99 - $(DEPENDS)  
100 -  
101 - @echo $< ...  
102 - @$(MKDIR) `dirname $@`  
103 - @$(CC) $(CFLAGS) \  
104 - @DBG_CFLAGS@ \  
105 - -DBUILD_DATE=`date +"0x%Y%m%d"`\  
106 - -o $@ -c $<  
107 -  
108 -$(OBJDBG)/%.o: \  
109 - %.cc \  
110 - $(DEPENDS)  
111 -  
112 - @echo $< ...  
113 - @$(MKDIR) `dirname $@`  
114 - @$(CXX) $(CFLAGS) \  
115 - @DBG_CFLAGS@ \  
116 - -DBUILD_DATE=`date +"0x%Y%m%d"`\  
117 - -o $@ -c $<  
118 -  
119 -$(OBJRLS)/%.o: \  
120 - %.c \  
121 - $(DEPENDS)  
122 -  
123 - @echo $< ...  
124 - @$(MKDIR) `dirname $@`  
125 - @$(CC) $(CFLAGS) \  
126 - @RLS_CFLAGS@ \  
127 - -DBUILD_DATE=`date +"0x%Y%m%d"` \  
128 - -o $@ -c $<  
129 -  
130 -$(OBJRLS)/%.o: \  
131 - %.cc \  
132 - $(DEPENDS)  
133 -  
134 - @echo $< ...  
135 - @$(MKDIR) `dirname $@`  
136 - @$(CXX) $(CFLAGS) \  
137 - @RLS_CFLAGS@ \  
138 - -DBUILD_DATE=`date +"0x%Y%m%d"` \  
139 - -o $@ -c $<  
140 -  
141 -$(POTDIR)/%.pot: %.c  
142 -  
143 - @echo $(notdir $@) ...  
144 - @$(MKDIR) `dirname $@`  
145 - @$(XGETTEXT) \  
146 - --default-domain=$(PACKAGE) \  
147 - --language=C \  
148 - --keyword=_ \  
149 - --keyword=N_ \  
150 - --keyword=MSG_:2 \  
151 - --output=$@ \  
152 - $<  
153 -  
154 - @touch $@  
155 -  
156 -#---[ Release Targets ]------------------------------------------------------------------  
157 -  
158 -Release: \  
159 - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@  
160 -  
161 -install: \  
162 - $(BINRLS)/$(LIBNAME) \  
163 - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@  
164 -  
165 - @echo $@ ...  
166 - @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins  
167 - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins/$(MODULE_NAME)@DLLEXT@  
168 -  
169 - @$(MKDIR) $(DESTDIR)$(libdir)  
170 - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)$(libdir)  
171 -  
172 -$(DESTDIR)$(libdir)/$(PACKAGE_TARNAME)-plugins/$(MODULE_NAME)@DLLEXT@: \  
173 - $(BINRLS)/$(LIBNAME) \  
174 - $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@  
175 -  
176 - @echo $@ ...  
177 - @$(MKDIR) `dirname $@`  
178 - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $@  
179 -  
180 - @$(MKDIR) $(DESTDIR)$(libdir)  
181 - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)$(libdir)  
182 -  
183 -$(BINRLS)/$(LIBNAME): \  
184 - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@  
185 -  
186 - @echo $(basename $@) ...  
187 - @$(MKDIR) `dirname $@`  
188 - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@  
189 -  
190 -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \  
191 - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
192 -  
193 - @echo $(basename $@) ...  
194 - @$(MKDIR) `dirname $@`  
195 - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@  
196 -  
197 -$(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \  
198 - $(foreach SRC, $(basename $(API_SOURCES)), $(OBJRLS)/$(SRC).o)  
199 -  
200 - @echo $@ ...  
201 - @$(MKDIR) `dirname $@`  
202 - @$(LD) \  
203 - $(LDFLAGS) \  
204 - @DLL_LDFLAGS@ \  
205 - -Wl,-soname,`basename $@` \  
206 - -L$(BASEDIR)/.bin/Release \  
207 - @STATIC_LDFLAGS@ \  
208 - -o $@ $^ \  
209 - $(API_LIBS)  
210 -  
211 -$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: \  
212 - $(BINRLS)/$(LIBNAME) \  
213 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o)  
214 -  
215 - @echo $@ ...  
216 - @$(MKDIR) `dirname $@`  
217 - @$(LD) \  
218 - $(LDFLAGS) \  
219 - @DLL_LDFLAGS@ \  
220 - -Wl,-soname,$(MODULE_NAME)d \  
221 - -L$(BASEDIR)/.bin/Release \  
222 - -o $@ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJRLS)/$(SRC).o) \  
223 - $(PLUGIN_LIBS)  
224 -  
225 -pot: \  
226 - $(BASEDIR)/.pot/plugins/$(MODULE_NAME).pot  
227 -  
228 -$(BASEDIR)/.pot/plugins/$(MODULE_NAME).pot: \  
229 - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(SRC).pot)  
230 -  
231 - @rm -f $@  
232 - @mkdir -p `dirname $@`  
233 - @$(MSGCAT) --sort-output $^ > $@  
234 -  
235 -$(SRCDIR): \  
236 - clean  
237 -  
238 - @$(MKDIR) $@  
239 - @$(INSTALL_DATA) *.c *.cc *.h *.in *.cbp $@  
240 -  
241 -  
242 -#---[ Debug Targets ]--------------------------------------------------------------------  
243 -  
244 -Debug: \  
245 - $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@  
246 -  
247 -test: \  
248 - $(BINDBG)/$(LIBNAME) \  
249 - $(OBJDBG)/testprogram.o  
250 -  
251 - $(LD) -Wl,--rpath,$(BINDBG) -o $(BINDBG)/$(MODULE_NAME)@EXEEXT@ $(OBJDBG)/testprogram.o -L$(BINDBG) $(LIBS) -l$(MODULE_NAME)  
252 -  
253 -$(BINDBG)/$(LIBNAME): \  
254 - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@  
255 -  
256 - @echo $(basename $@) ...  
257 - @$(MKDIR) `dirname $@`  
258 - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $@  
259 -  
260 -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@: \  
261 - $(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@  
262 -  
263 - @echo $(basename $@) ...  
264 - @$(MKDIR) `dirname $@`  
265 - @$(LN_S) -f $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $@  
266 -  
267 -$(BINDBG)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \  
268 - $(foreach SRC, $(basename $(API_SOURCES)), $(OBJDBG)/$(SRC).o)  
269 -  
270 - @echo $@ ...  
271 - @$(MKDIR) `dirname $@`  
272 - @$(LD) \  
273 - -shared \  
274 - -Wl,-soname,`basename $@` \  
275 - $(LDFLAGS) \  
276 - -L$(BASEDIR)/.bin/Debug \  
277 - -o $@ $^ \  
278 - $(API_LIBS)  
279 -  
280 -$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: \  
281 - $(BINDBG)/$(LIBNAME) \  
282 - $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o)  
283 -  
284 - @echo $@ ...  
285 - @$(MKDIR) `dirname $@`  
286 - @$(LD) \  
287 - -shared \  
288 - -Wl,-soname,$(MODULE_NAME)d,--rpath,$(BASEDIR)/.bin/Debug \  
289 - $(LDFLAGS) \  
290 - -L$(BASEDIR)/.bin/Debug \  
291 - -o $@ $(foreach SRC, $(basename $(PLUGIN_SOURCES)), $(OBJDBG)/$(SRC).o) \  
292 - $(PLUGIN_LIBS)  
293 -  
294 -  
295 -#---[ Clean Targets]---------------------------------------------------------------------  
296 -  
297 -cleanDebug:  
298 -  
299 - @rm -fr $(BINDBG)/$(MODULE_NAME)@DLLEXT@ \  
300 - $(OBJDBG) \  
301 - dbus-glue.h  
302 -  
303 -cleanRelease:  
304 -  
305 - @rm -fr $(BINRLS)/$(MODULE_NAME)@DLLEXT@ \  
306 - $(OBJRLS) \  
307 - dbus-glue.h  
308 -  
309 - @rm -fr $(POTDIR)  
310 -  
311 -clean: \  
312 - cleanDebug \  
313 - cleanRelease  
314 -  
315 -  
src/hllapi/calls.cc
@@ -1,826 +0,0 @@ @@ -1,826 +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.cc 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 <exception>  
31 - #include <cstdlib>  
32 - #include <cstring>  
33 -  
34 - #include <pw3270/hllapi.h>  
35 - #include <pw3270/pw3270cpp.h>  
36 - #include "client.h"  
37 -  
38 - using namespace std;  
39 - using namespace PW3270_NAMESPACE;  
40 -  
41 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
42 -  
43 - static session * hSession = NULL;  
44 - static time_t hllapi_timeout = 120;  
45 -  
46 -/*--[ Implement ]------------------------------------------------------------------------------------*/  
47 -  
48 - HLLAPI_API_CALL hllapi_init(LPSTR mode)  
49 - {  
50 - trace("%s(%s)",__FUNCTION__,mode);  
51 -  
52 - try  
53 - {  
54 - if(hSession)  
55 - delete hSession;  
56 - hSession = session::create(mode);  
57 -  
58 - if(!hSession) {  
59 - return HLLAPI_STATUS_UNAVAILABLE;  
60 - }  
61 -  
62 - hSession->set_display_charset();  
63 -  
64 - trace("hSession=%p",hSession);  
65 - }  
66 - catch(std::exception &e)  
67 - {  
68 - trace("Error \"%s\"",e.what());  
69 - return HLLAPI_STATUS_SYSTEM_ERROR;  
70 - }  
71 -  
72 - return HLLAPI_STATUS_SUCCESS;  
73 -  
74 - }  
75 -  
76 - HLLAPI_API_CALL hllapi_deinit(void)  
77 - {  
78 - trace("%s()",__FUNCTION__);  
79 -  
80 - try  
81 - {  
82 - if(hSession)  
83 - {  
84 - delete hSession;  
85 - hSession = NULL;  
86 - }  
87 - }  
88 - catch(std::exception &e)  
89 - {  
90 - return HLLAPI_STATUS_SYSTEM_ERROR;  
91 - }  
92 -  
93 - return HLLAPI_STATUS_SUCCESS;  
94 - }  
95 -  
96 - HLLAPI_API_CALL hllapi_get_revision(void)  
97 - {  
98 - try  
99 - {  
100 - return atoi(session::get_default()->get_revision().c_str());  
101 - }  
102 - catch(std::exception &e)  
103 - {  
104 - return -1;  
105 - }  
106 - return (DWORD) -1;  
107 - }  
108 -  
109 - HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait)  
110 - {  
111 - try  
112 - {  
113 - session::get_default()->connect(uri,hllapi_timeout);  
114 - }  
115 - catch(std::exception &e)  
116 - {  
117 - return HLLAPI_STATUS_SYSTEM_ERROR;  
118 - }  
119 -  
120 - return hllapi_get_state();  
121 - }  
122 -  
123 - HLLAPI_API_CALL hllapi_is_connected(void)  
124 - {  
125 - if(!session::has_default())  
126 - {  
127 - return 0;  
128 - }  
129 -  
130 - return session::get_default()->is_connected();  
131 - }  
132 -  
133 - HLLAPI_API_CALL hllapi_get_state(void)  
134 - {  
135 - switch(hllapi_get_message_id())  
136 - {  
137 - case LIB3270_MESSAGE_NONE: // 0 - No message  
138 - return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input.  
139 -  
140 - case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host  
141 - return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session.  
142 -  
143 - case LIB3270_MESSAGE_MINUS:  
144 - case LIB3270_MESSAGE_PROTECTED:  
145 - case LIB3270_MESSAGE_NUMERIC:  
146 - case LIB3270_MESSAGE_OVERFLOW:  
147 - case LIB3270_MESSAGE_INHIBIT:  
148 - case LIB3270_MESSAGE_KYBDLOCK:  
149 - return HLLAPI_STATUS_KEYBOARD_LOCKED; // keyboard is locked.  
150 -  
151 - case LIB3270_MESSAGE_SYSWAIT:  
152 - case LIB3270_MESSAGE_TWAIT:  
153 - case LIB3270_MESSAGE_AWAITING_FIRST:  
154 - case LIB3270_MESSAGE_X:  
155 - case LIB3270_MESSAGE_RESOLVING:  
156 - case LIB3270_MESSAGE_CONNECTING:  
157 - return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation.  
158 - }  
159 -  
160 - return HLLAPI_STATUS_SYSTEM_ERROR;  
161 - }  
162 -  
163 - HLLAPI_API_CALL hllapi_disconnect(void)  
164 - {  
165 - session::get_default()->disconnect();  
166 - return HLLAPI_STATUS_SUCCESS;  
167 - }  
168 -  
169 - HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds)  
170 - {  
171 - if(!hllapi_is_connected())  
172 - return HLLAPI_STATUS_DISCONNECTED;  
173 -  
174 - session::get_default()->wait_for_ready(seconds);  
175 -  
176 - return hllapi_get_state();  
177 - }  
178 -  
179 - HLLAPI_API_CALL hllapi_wait(WORD seconds)  
180 - {  
181 - if(!hllapi_is_connected())  
182 - return HLLAPI_STATUS_DISCONNECTED;  
183 -  
184 - session::get_default()->wait(seconds);  
185 -  
186 - return hllapi_get_state();  
187 - }  
188 -  
189 - HLLAPI_API_CALL hllapi_get_message_id(void)  
190 - {  
191 - if(!hllapi_is_connected())  
192 - return HLLAPI_STATUS_DISCONNECTED;  
193 -  
194 - return session::get_default()->get_program_message();  
195 - }  
196 -  
197 - HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)  
198 - {  
199 - if(!hllapi_is_connected())  
200 - return HLLAPI_STATUS_DISCONNECTED;  
201 -  
202 - if(!(buffer && *buffer))  
203 - return HLLAPI_STATUS_SYSTEM_ERROR;  
204 -  
205 - try  
206 - {  
207 - size_t sz = strlen(buffer);  
208 - string str = session::get_default()->get_string_at(row,col,sz);  
209 - strncpy(buffer,str.c_str(),sz);  
210 - }  
211 - catch(std::exception &e)  
212 - {  
213 - return HLLAPI_STATUS_SYSTEM_ERROR;  
214 - }  
215 -  
216 - return HLLAPI_STATUS_SUCCESS;  
217 - }  
218 -  
219 - HLLAPI_API_CALL hllapi_enter(void)  
220 - {  
221 - if(!hllapi_is_connected())  
222 - return HLLAPI_STATUS_DISCONNECTED;  
223 -  
224 - return session::get_default()->enter();  
225 - }  
226 -  
227 - HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text)  
228 - {  
229 - if(!hllapi_is_connected())  
230 - return HLLAPI_STATUS_DISCONNECTED;  
231 -  
232 - try  
233 - {  
234 - session::get_default()->set_string_at(row,col,text);  
235 - }  
236 - catch(std::exception &e)  
237 - {  
238 - return HLLAPI_STATUS_SYSTEM_ERROR;  
239 - }  
240 -  
241 - return HLLAPI_STATUS_SUCCESS;  
242 - }  
243 -  
244 - HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)  
245 - {  
246 -  
247 - if(!hllapi_is_connected())  
248 - return HLLAPI_STATUS_DISCONNECTED;  
249 -  
250 - int rc = HLLAPI_STATUS_SYSTEM_ERROR;  
251 -  
252 - try  
253 - {  
254 - rc = session::get_default()->cmp_string_at(row,col,text);  
255 - }  
256 - catch(std::exception &e)  
257 - {  
258 - return HLLAPI_STATUS_SYSTEM_ERROR;  
259 - }  
260 -  
261 - return rc;  
262 - }  
263 -  
264 - HLLAPI_API_CALL hllapi_find_text(LPSTR text)  
265 - {  
266 - if(!hllapi_is_connected())  
267 - return HLLAPI_STATUS_DISCONNECTED;  
268 -  
269 - return (int) session::get_default()->find_string((const char *) text, false);  
270 - }  
271 -  
272 - HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms)  
273 - {  
274 - session::get_default()->set_unlock_delay(ms);  
275 - return 0;  
276 - }  
277 -  
278 - HLLAPI_API_CALL hllapi_set_charset(LPSTR text)  
279 - {  
280 - try  
281 - {  
282 -  
283 - session::get_default()->set_display_charset(NULL, (const char *) text);  
284 -  
285 - }  
286 - catch(std::exception &e)  
287 - {  
288 - return HLLAPI_STATUS_SYSTEM_ERROR;  
289 - }  
290 -  
291 - return 0;  
292 - }  
293 -  
294 - HLLAPI_API_CALL hllapi_pfkey(WORD key)  
295 - {  
296 - if(!hllapi_is_connected())  
297 - return HLLAPI_STATUS_DISCONNECTED;  
298 -  
299 - return session::get_default()->pfkey(key);  
300 - }  
301 -  
302 - HLLAPI_API_CALL hllapi_pakey(WORD key)  
303 - {  
304 - if(!hllapi_is_connected())  
305 - return HLLAPI_STATUS_DISCONNECTED;  
306 -  
307 - return session::get_default()->pakey(key);  
308 - }  
309 -  
310 - HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir)  
311 - {  
312 - #ifdef _WIN32  
313 - HKEY hKey = 0;  
314 - unsigned long datalen = strlen(datadir);  
315 -  
316 - *datadir = 0;  
317 -  
318 - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)  
319 - {  
320 - unsigned long datatype; // #defined in winnt.h (predefined types 0-11)  
321 - if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)  
322 - *datadir = 0;  
323 - RegCloseKey(hKey);  
324 - }  
325 -#endif // _WIN32  
326 -  
327 - return *datadir;  
328 - }  
329 -  
330 - HLLAPI_API_CALL hllapi_setcursor(WORD pos)  
331 - {  
332 - if(!hllapi_is_connected())  
333 - return HLLAPI_STATUS_DISCONNECTED;  
334 -  
335 - session::get_default()->set_cursor_addr(pos-1);  
336 -  
337 - return HLLAPI_STATUS_SUCCESS;  
338 -  
339 - }  
340 -  
341 - HLLAPI_API_CALL hllapi_set_cursor_address(WORD pos)  
342 - {  
343 - if(!hllapi_is_connected())  
344 - return HLLAPI_STATUS_DISCONNECTED;  
345 -  
346 - session::get_default()->set_cursor_addr(pos-1);  
347 -  
348 - return HLLAPI_STATUS_SUCCESS;  
349 -  
350 - }  
351 -  
352 - HLLAPI_API_CALL hllapi_get_cursor_address()  
353 - {  
354 - return session::get_default()->get_cursor_addr()+1;  
355 - }  
356 -  
357 - HLLAPI_API_CALL hllapi_getcursor()  
358 - {  
359 - return session::get_default()->get_cursor_addr()+1;  
360 - }  
361 -  
362 - HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len)  
363 - {  
364 - if(!hllapi_is_connected())  
365 - return HLLAPI_STATUS_DISCONNECTED;  
366 -  
367 - int rc = HLLAPI_STATUS_SYSTEM_ERROR;  
368 -  
369 - if(offset < 1)  
370 - {  
371 - return HLLAPI_STATUS_BAD_PARAMETER;  
372 - }  
373 -  
374 - offset--;  
375 -  
376 - if(!session::has_default())  
377 - {  
378 - return HLLAPI_STATUS_DISCONNECTED;  
379 - }  
380 -  
381 - if(!(buffer && *buffer)) {  
382 - return HLLAPI_STATUS_BAD_PARAMETER;  
383 - }  
384 -  
385 - try  
386 - {  
387 - size_t szBuffer;  
388 -  
389 - if(len > 0)  
390 - {  
391 - szBuffer = (size_t) len;  
392 - }  
393 - else  
394 - {  
395 - return HLLAPI_STATUS_BAD_PARAMETER;  
396 - }  
397 -  
398 - memset(buffer,' ',szBuffer);  
399 -  
400 - string str = session::get_default()->get_string(offset,szBuffer,false);  
401 - strncpy(buffer,str.c_str(),szBuffer);  
402 - rc = HLLAPI_STATUS_SUCCESS;  
403 - }  
404 - catch(std::exception &e)  
405 - {  
406 - rc = HLLAPI_STATUS_SYSTEM_ERROR;  
407 - }  
408 -  
409 - return rc;  
410 - }  
411 -  
412 - HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting)  
413 - {  
414 - if(!hllapi_is_connected())  
415 - return HLLAPI_STATUS_DISCONNECTED;  
416 -  
417 - try  
418 - {  
419 - session::get_default()->input_string(buffer);  
420 - }  
421 - catch(std::exception &e)  
422 - {  
423 - return HLLAPI_STATUS_SYSTEM_ERROR;  
424 - }  
425 -  
426 - return HLLAPI_STATUS_SUCCESS;  
427 - }  
428 -  
429 - HLLAPI_API_CALL hllapi_erase(void)  
430 - {  
431 - try  
432 - {  
433 - session::get_default()->erase();  
434 - }  
435 - catch(std::exception &e)  
436 - {  
437 - return HLLAPI_STATUS_SYSTEM_ERROR;  
438 - }  
439 - return HLLAPI_STATUS_SUCCESS;  
440 - }  
441 -  
442 - HLLAPI_API_CALL hllapi_erase_eof(void)  
443 - {  
444 - if(!hllapi_is_connected())  
445 - return HLLAPI_STATUS_DISCONNECTED;  
446 -  
447 - try  
448 - {  
449 - session::get_default()->erase_eof();  
450 - }  
451 - catch(std::exception &e)  
452 - {  
453 - return HLLAPI_STATUS_SYSTEM_ERROR;  
454 - }  
455 - return HLLAPI_STATUS_SUCCESS;  
456 - }  
457 -  
458 - HLLAPI_API_CALL hllapi_erase_eol(void)  
459 - {  
460 - if(!hllapi_is_connected())  
461 - return HLLAPI_STATUS_DISCONNECTED;  
462 -  
463 - try  
464 - {  
465 - session::get_default()->erase_eol();  
466 - }  
467 - catch(std::exception &e)  
468 - {  
469 - return HLLAPI_STATUS_SYSTEM_ERROR;  
470 - }  
471 - return HLLAPI_STATUS_SUCCESS;  
472 - }  
473 -  
474 - HLLAPI_API_CALL hllapi_erase_input(void)  
475 - {  
476 - if(!hllapi_is_connected())  
477 - return HLLAPI_STATUS_DISCONNECTED;  
478 -  
479 - try  
480 - {  
481 - session::get_default()->erase_input();  
482 - }  
483 - catch(std::exception &e)  
484 - {  
485 - return HLLAPI_STATUS_SYSTEM_ERROR;  
486 - }  
487 - return HLLAPI_STATUS_SUCCESS;  
488 - }  
489 -  
490 - HLLAPI_API_CALL hllapi_action(LPSTR buffer) {  
491 - try  
492 - {  
493 - session::get_default()->action((const char *) buffer);  
494 - }  
495 - catch(std::exception &e)  
496 - {  
497 - return HLLAPI_STATUS_SYSTEM_ERROR;  
498 - }  
499 - return HLLAPI_STATUS_SUCCESS;  
500 - }  
501 -  
502 - HLLAPI_API_CALL hllapi_print(void)  
503 - {  
504 - return session::get_default()->print();  
505 - }  
506 -  
507 - char * hllapi_get_string(int offset, size_t len)  
508 - {  
509 - try  
510 - {  
511 - string str = session::get_default()->get_string(offset-1,len);  
512 - char * ret = strdup(str.c_str());  
513 - return ret;  
514 - }  
515 - catch(std::exception &e)  
516 - {  
517 - }  
518 -  
519 - return NULL;  
520 - }  
521 -  
522 - void hllapi_free(void *p)  
523 - {  
524 - free(p);  
525 - }  
526 -  
527 - HLLAPI_API_CALL hllapi_reset(void)  
528 - {  
529 - return HLLAPI_STATUS_SUCCESS;  
530 - }  
531 -  
532 - HLLAPI_API_CALL hllapi_input_string(LPSTR input, WORD length)  
533 - {  
534 - static const char control_char = '@';  
535 -  
536 - size_t szText;  
537 - char * text;  
538 - int rc = 0;  
539 -  
540 - if(!hllapi_is_connected()) {  
541 - return HLLAPI_STATUS_DISCONNECTED;  
542 - }  
543 -  
544 - if(!input)  
545 - {  
546 - return HLLAPI_STATUS_BAD_PARAMETER;  
547 - }  
548 -  
549 - if(length > 0 )  
550 - szText = length;  
551 - else  
552 - szText = strlen(input);  
553 -  
554 - text = (char *) malloc(szText+2);  
555 - memcpy(text,input,szText);  
556 - text[szText] = 0;  
557 -  
558 - trace("input[%s]",text);  
559 -  
560 - if(strchr(text,control_char))  
561 - {  
562 - // Convert control char  
563 - char * buffer = text;  
564 - char * ptr;  
565 -  
566 - for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))  
567 - {  
568 - *(ptr++) = 0;  
569 -  
570 - trace("input[%s]",buffer);  
571 - hllapi_emulate_input(buffer,-1,0);  
572 -  
573 - switch(*(ptr++))  
574 - {  
575 - case 'P': // Print  
576 - rc = hllapi_print();  
577 - break;  
578 -  
579 - case 'E': // Enter  
580 - hllapi_enter();  
581 - break;  
582 -  
583 - case 'F': // Erase EOF  
584 - hllapi_erase_eof();  
585 - break;  
586 -  
587 - case '1': // PF1  
588 - hllapi_pfkey(1);  
589 - break;  
590 -  
591 - case '2': // PF2  
592 - hllapi_pfkey(2);  
593 - break;  
594 -  
595 - case '3': // PF3  
596 - hllapi_pfkey(3);  
597 - break;  
598 -  
599 - case '4': // PF4  
600 - hllapi_pfkey(4);  
601 - break;  
602 -  
603 - case '5': // PF5  
604 - hllapi_pfkey(5);  
605 - break;  
606 -  
607 - case '6': // PF6  
608 - hllapi_pfkey(6);  
609 - break;  
610 -  
611 - case '7': // PF7  
612 - hllapi_pfkey(7);  
613 - break;  
614 -  
615 - case '8': // PF8  
616 - hllapi_pfkey(8);  
617 - break;  
618 -  
619 - case '9': // PF9  
620 - hllapi_pfkey(9);  
621 - break;  
622 -  
623 - case 'a': // PF10  
624 - hllapi_pfkey(10);  
625 - break;  
626 -  
627 - case 'b': // PF11  
628 - hllapi_pfkey(11);  
629 - break;  
630 -  
631 - case 'c': // PF12  
632 - hllapi_pfkey(12);  
633 - break;  
634 -  
635 - case 'd': // PF13  
636 - hllapi_pfkey(13);  
637 - break;  
638 -  
639 - case 'e': // PF14  
640 - hllapi_pfkey(14);  
641 - break;  
642 -  
643 - case 'f': // PF15  
644 - hllapi_pfkey(15);  
645 - break;  
646 -  
647 - case 'g': // PF16  
648 - hllapi_pfkey(16);  
649 - break;  
650 -  
651 - case 'h': // PF17  
652 - hllapi_pfkey(17);  
653 - break;  
654 -  
655 - case 'i': // PF18  
656 - hllapi_pfkey(18);  
657 - break;  
658 -  
659 - case 'j': // PF19  
660 - hllapi_pfkey(19);  
661 - break;  
662 -  
663 - case 'k': // PF20  
664 - hllapi_pfkey(20);  
665 - break;  
666 -  
667 - case 'l': // PF21  
668 - hllapi_pfkey(21);  
669 - break;  
670 -  
671 - case 'm': // PF22  
672 - hllapi_pfkey(22);  
673 - break;  
674 -  
675 - case 'n': // PF23  
676 - hllapi_pfkey(23);  
677 - break;  
678 -  
679 - case 'o': // PF24  
680 - hllapi_pfkey(24);  
681 - break;  
682 -  
683 - case '@': // Send '@' character  
684 - hllapi_emulate_input((LPSTR) "@",-1,0);  
685 - break;  
686 -  
687 - case 'x': // PA1  
688 - hllapi_pakey(1);  
689 - break;  
690 -  
691 - case 'y': // PA2  
692 - hllapi_pakey(2);  
693 - break;  
694 -  
695 - case 'z': // PA3  
696 - hllapi_pakey(3);  
697 - break;  
698 -  
699 - case 'B': // PC_LEFTTAB = "@B"  
700 - break;  
701 -  
702 - case 'T': // PC_RIGHTTAB = "@T"  
703 - break;  
704 -  
705 - case 'N': // PC_NEWLINE = "@N"  
706 - break;  
707 -  
708 - case 'C': // PC_CLEAR = "@C"  
709 - hllapi_erase_input();  
710 - break;  
711 -  
712 - case 'D': // PC_DELETE = "@D"  
713 - break;  
714 -  
715 - case 'H': // PC_HELP = "@H"  
716 - break;  
717 -  
718 - case 'I': // PC_INSERT = "@I"  
719 - break;  
720 -  
721 - case 'L': // PC_CURSORLEFT = "@L"  
722 - break;  
723 -  
724 - case 'R': // PC_RESET = "@R"  
725 - hllapi_reset();  
726 - break;  
727 -  
728 - case 'U': // PC_CURSORUP = "@U"  
729 - break;  
730 -  
731 - case 'V': // PC_CURSORDOWN = "@V"  
732 - break;  
733 -  
734 - case 'Z': // PC_CURSORRIGHT = "@Z"  
735 - break;  
736 -  
737 - case '0': // PC_HOME = "@0"  
738 - break;  
739 -  
740 - case 'p': // PC_PLUSKEY = "@p"  
741 - break;  
742 -  
743 - case 'q': // PC_END = "@q"  
744 - break;  
745 -  
746 - case 's': // PC_SCRLK = "@s"  
747 - break;  
748 -  
749 - case 't': // PC_NUMLOCK = "@t"  
750 - break;  
751 -  
752 - case 'u': // PC_PAGEUP = "@u"  
753 - break;  
754 -  
755 - case 'v': // PC_PAGEDOWN = "@v"  
756 - break;  
757 -  
758 - case '/': // PC_OVERRUNOFQUEUE = "@/" ' Queue overflow, used in Get Key only  
759 - break;  
760 -  
761 - case '$': // PC_ALTCURSOR = "@$" ' Presentation Manager only, unused in VB environment  
762 - break;  
763 -  
764 - case '<': // PC_BACKSPACE = "@<"  
765 - break;  
766 -  
767 -  
768 -/*  
769 -  
770 -Global Const PC_TEST = "@A@C"  
771 -Global Const PC_WORDDELETE = "@A@D"  
772 -Global Const PC_FIELDEXIT = "@A@E"  
773 -Global Const PC_ERASEINPUT = "@A@F"  
774 -Global Const PC_SYSTEMREQUEST = "@A@H"  
775 -Global Const PC_INSERTTOGGLE = "@A@I"  
776 -Global Const PC_CURSORSELECT = "@A@J"  
777 -Global Const PC_CURSLEFTFAST = "@A@L"  
778 -Global Const PC_GETCURSOR = "@A@N"  
779 -Global Const PC_LOCATECURSOR = "@A@O"  
780 -Global Const PC_ATTENTION = "@A@Q"  
781 -Global Const PC_DEVICECANCEL = "@A@R"  
782 -Global Const PC_PRINTPS = "@A@T"  
783 -Global Const PC_CURSUPFAST = "@A@U"  
784 -Global Const PC_CURSDOWNFAST = "@A@V"  
785 -Global Const PC_HEX = "@A@X"  
786 -Global Const PC_FUNCTIONKEY = "@A@Y"  
787 -Global Const PC_CURSRIGHTFAST = "@A@Z"  
788 -  
789 -Global Const PC_REVERSEVIDEO = "@A@9"  
790 -Global Const PC_UNDERSCORE = "@A@b"  
791 -Global Const PC_BLINK = "@A@c"  
792 -Global Const PC_RED = "@A@d"  
793 -Global Const PC_PINK = "@A@e"  
794 -Global Const PC_GREEN = "@A@f"  
795 -Global Const PC_YELLOW = "@A@g"  
796 -Global Const PC_BLUE = "@A@h"  
797 -Global Const PC_TURQOISE = "@A@i"  
798 -Global Const PC_WHITE = "@A@j"  
799 -Global Const PC_RSTHOSTCOLORS = "@A@l"  
800 -Global Const PC_PRINTPC = "@A@t"  
801 -  
802 -Global Const PC_FIELDMINUS = "@A@-"  
803 -Global Const PC_FIELDPLUS = "@A@+"  
804 -  
805 -*/  
806 -  
807 - }  
808 -  
809 - buffer = ptr;  
810 -  
811 - }  
812 -  
813 - if(*buffer)  
814 - hllapi_emulate_input(buffer,-1,0);  
815 -  
816 - }  
817 - else  
818 - {  
819 - hllapi_emulate_input(text,szText,0);  
820 - }  
821 -  
822 - free(text);  
823 -  
824 - return rc;  
825 - }  
826 -  
src/hllapi/client.h
@@ -1,56 +0,0 @@ @@ -1,56 +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 private.h 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 <pw3270/hllapi.h>  
31 -  
32 - #ifndef ETIMEDOUT  
33 - #define ETIMEDOUT 1238  
34 - #endif // ETIMEDOUT  
35 -  
36 - #define PIPE_BUFFER_LENGTH 8192  
37 -  
38 - #define set_active(x) /* x */  
39 -  
40 - #if defined(DEBUG) && defined(_WIN32)  
41 - #undef trace  
42 - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);  
43 - #endif // DEBUG  
44 -  
45 - #ifdef __cplusplus  
46 - extern "C" {  
47 - #endif  
48 -  
49 - char * hllapi_get_string(int offset, size_t len);  
50 - void hllapi_free(void *p);  
51 -  
52 - #ifdef __cplusplus  
53 - } /* end of extern "C" */  
54 - #endif  
55 -  
56 -  
src/hllapi/environ.bat
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -@echo off  
2 -  
3 -set VC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC  
4 -set WINSDK=C:\Program Files (x86)\Windows Kits\8.1  
5 -set PATH=%PATH%;"%VC%\bin";"%WINSDK%\bin\x86\"  
6 -  
src/hllapi/hllapi.c
@@ -1,466 +0,0 @@ @@ -1,466 +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 hllapi.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 <pw3270/hllapi.h>  
35 - #include <stdio.h>  
36 - #include <time.h>  
37 - #include <lib3270/log.h>  
38 - #include "client.h"  
39 -  
40 - /*--[ Prototipes ]-----------------------------------------------------------------------------------*/  
41 -  
42 - static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc);  
43 - static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc);  
44 - static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc);  
45 - static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc);  
46 - static int copy_str_to_ps(char *buffer, unsigned short *length, unsigned short *rc);  
47 - static int search_ps(char *buffer, unsigned short *length, unsigned short *rc);  
48 - static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc);  
49 - static int wait_system(char *buffer, unsigned short *length, unsigned short *rc);  
50 - static int reset_system(char *buffer, unsigned short *length, unsigned short *rc);  
51 - static int pause_system(char *buffer, unsigned short *length, unsigned short *rc);  
52 - static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc);  
53 -  
54 - static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);  
55 - static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);  
56 - static int input_string(char *buffer, unsigned short *length, unsigned short *rc);  
57 -  
58 - static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc);  
59 -  
60 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
61 -  
62 - static const struct _hllapi_call  
63 - {  
64 - unsigned long func;  
65 - int (*exec)(char *buffer, unsigned short *length, unsigned short *rc);  
66 - } hllapi_call[] =  
67 - {  
68 - { HLLAPI_CMD_CONNECTPS, connect_ps },  
69 - { HLLAPI_CMD_DISCONNECTPS, disconnect_ps },  
70 - { HLLAPI_CMD_GETREVISION, get_library_revision },  
71 - { HLLAPI_CMD_QUERYCURSOR, get_cursor_position },  
72 - { HLLAPI_CMD_SETCURSOR, set_cursor_position },  
73 - { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str },  
74 - { HLLAPI_CMD_INPUTSTRING, input_string },  
75 - { HLLAPI_CMD_WAIT, wait_system },  
76 - { HLLAPI_CMD_COPYPS, copy_ps },  
77 - { HLLAPI_CMD_SEARCHPS, search_ps },  
78 - { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps },  
79 - { HLLAPI_CMD_SENDFILE, invalid_request },  
80 - { HLLAPI_CMD_RECEIVEFILE, invalid_request },  
81 - { HLLAPI_RESET_SYSTEM, reset_system },  
82 - { HLLAPI_CMD_PAUSE, pause_system },  
83 - { HLLAPI_SET_SESSION_PARAMETERS, set_session_parameters }  
84 -  
85 - };  
86 -  
87 - static enum _pause_mode  
88 - {  
89 - PAUSE_MODE_IPAUSE, ///< @brief Interruptible pause. After the Start Host Notification (23) function is executed, a host event satisfies a pause.  
90 - PAUSE_MODE_FPAUSE ///< @brief A full-duration pause lasts for however long you specified in the Pause (18) function.  
91 - } pause_mode = PAUSE_MODE_IPAUSE;  
92 -  
93 -/*--[ Implement ]------------------------------------------------------------------------------------*/  
94 -  
95 -HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)  
96 -{  
97 - unsigned int f;  
98 -  
99 - trace("%s(%d)",__FUNCTION__,*func);  
100 -  
101 - for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++)  
102 - {  
103 - if(hllapi_call[f].func == *func)  
104 - {  
105 - int status = hllapi_call[f].exec(buffer,length,rc);  
106 - trace("hllapi(%d) exits with rc=%d",*func,status);  
107 - return status;  
108 - }  
109 - }  
110 -  
111 - trace("hllapi(%d) failed",*func);  
112 -  
113 - *rc = HLLAPI_STATUS_UNSUPPORTED;  
114 - return *rc;  
115 -  
116 -}  
117 -  
118 -static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc)  
119 -{  
120 - *rc = HLLAPI_STATUS_BAD_PARAMETER;  
121 - return *rc;  
122 -}  
123 -  
124 -static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)  
125 -{  
126 - char *tempbuffer = NULL;  
127 -  
128 - trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer));  
129 -  
130 - if(strlen(buffer) > *length)  
131 - buffer[*length] = 0;  
132 -  
133 - if(!strrchr(buffer,':'))  
134 - {  
135 - int sz = strlen(buffer);  
136 -  
137 - tempbuffer = (char *) malloc(sz+2);  
138 - strcpy(tempbuffer,buffer);  
139 - tempbuffer[sz-1] = ':';  
140 - tempbuffer[sz] = buffer[sz-1];  
141 - tempbuffer[sz+1] = 0;  
142 - buffer = tempbuffer;  
143 - }  
144 -  
145 - *rc = hllapi_init(buffer);  
146 -  
147 - if(tempbuffer)  
148 - free(tempbuffer);  
149 -  
150 - return 0;  
151 -}  
152 -  
153 -static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc)  
154 -{  
155 - *rc = hllapi_deinit();  
156 - return 0;  
157 -}  
158 -  
159 -static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc)  
160 -{  
161 - *rc = hllapi_get_revision();  
162 - return 0;  
163 -}  
164 -  
165 -static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)  
166 -{  
167 - int pos = hllapi_getcursor();  
168 -  
169 - trace("%s(%d)",__FUNCTION__,pos);  
170 -  
171 - if(pos < 0)  
172 - return -1;  
173 -  
174 - *rc = pos;  
175 - return 0;  
176 -}  
177 -  
178 -static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)  
179 -{  
180 - trace("%s(%d)",__FUNCTION__,*rc);  
181 - *rc = hllapi_setcursor(*rc);  
182 - return 0;  
183 -}  
184 -  
185 -static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc)  
186 -{  
187 -  
188 - // Length Length of the target data string.  
189 - // PS Position Position within the host presentation space of the first byte in your target data string.  
190 - *rc = hllapi_get_screen(*rc,buffer,*length);  
191 -  
192 - return 0;  
193 -}  
194 -  
195 -static int input_string(char *buffer, unsigned short *length, unsigned short *rc)  
196 -{  
197 - *rc = hllapi_input_string(buffer,*length);  
198 - return 0;  
199 -}  
200 -  
201 -static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)  
202 -{  
203 - /*  
204 - * Data String Target string for search.  
205 - * Length Length of the target data string. Overridden in EOT mode.  
206 - * PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end  
207 - * (SRCHBKWD option). Overridden in SRCHALL (default) mode.  
208 - *  
209 - * Return in *ps:  
210 - *  
211 - * = 0 The string was not found.  
212 - * > 0 The string was found at the indicated host presentation space position.  
213 - *  
214 - * Return code:  
215 - *  
216 - * 0 The Search Presentation Space function was successful.  
217 - * 1 Your program is not connected to a host session.  
218 - * 2 An error was made in specifying parameters.  
219 - * 7 The host presentation space position is not valid.  
220 - * 9 A system error was encountered.  
221 - * 24 The search string was not found.  
222 - *  
223 - */  
224 - size_t szBuffer = strlen(buffer);  
225 - char * text;  
226 - int rc = HLLAPI_STATUS_SYSTEM_ERROR;  
227 -  
228 - if(!hllapi_is_connected())  
229 - return HLLAPI_STATUS_DISCONNECTED;  
230 -  
231 - if(*length < szBuffer)  
232 - szBuffer = *length;  
233 -  
234 -  
235 - text = hllapi_get_string(*ps,szBuffer);  
236 - if(!text)  
237 - return HLLAPI_STATUS_SYSTEM_ERROR;  
238 -  
239 - if(strncmp(text,buffer,szBuffer))  
240 - {  
241 - // String not found  
242 - *ps = 0;  
243 - rc = HLLAPI_STATUS_NOT_FOUND;  
244 - }  
245 - else  
246 - {  
247 - // String found  
248 - *ps = 1;  
249 - rc = HLLAPI_STATUS_SUCCESS;  
250 - }  
251 -  
252 - hllapi_free(text);  
253 -  
254 - return rc;  
255 -}  
256 -  
257 -static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)  
258 -{  
259 - /*  
260 - * Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space.  
261 - * DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space.  
262 - *  
263 - * Length NA (the length of the host presentation space is implied).  
264 - * PS Position NA.  
265 - *  
266 - * Return values:  
267 - *  
268 - * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.  
269 - * 1 Your program is not connected to a host session.  
270 - * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.  
271 - * 5 The host presentation space was copied. The keyboard was locked.  
272 - * 9 A system error was encountered.  
273 - *  
274 - */  
275 - size_t szBuffer = strlen(buffer);  
276 - char * text;  
277 -  
278 - if(!hllapi_is_connected())  
279 - return HLLAPI_STATUS_DISCONNECTED;  
280 -  
281 - text = hllapi_get_string(1, szBuffer);  
282 -  
283 - if(!text)  
284 - return HLLAPI_STATUS_SYSTEM_ERROR;  
285 -  
286 - memcpy(buffer,text,szBuffer);  
287 -  
288 - hllapi_free(text);  
289 -  
290 - return hllapi_get_state();  
291 -}  
292 -  
293 -static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)  
294 -{  
295 - /*  
296 - * Checks the status of the host-connected presentation space. If the session is  
297 - * waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait  
298 - * function causes HLLAPI to wait up to 1 minute to see if the condition clears.  
299 - *  
300 - */  
301 -  
302 - /*  
303 - * Return Code Definition  
304 - *  
305 - * HLLAPI_STATUS_SUCCESS 0 The keyboard is unlocked and ready for input.  
306 - * HLLAPI_STATUS_DISCONNECTED 1 Your application program is not connected to a valid session.  
307 - * HLLAPI_STATUS_TIMEOUT 4 Timeout while still in XCLOCK (X []) or XSYSTEM.  
308 - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The keyboard is locked.  
309 - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.  
310 - *  
311 - */  
312 -  
313 - /*  
314 - time_t end = time(0) + 60;  
315 -  
316 - while(time(0) < end)  
317 - {  
318 - int state = hllapi_get_state();  
319 -  
320 - if(state != HLLAPI_STATUS_WAITING)  
321 - return state;  
322 -  
323 - hllapi_wait(1);  
324 -  
325 - }  
326 -  
327 - return HLLAPI_STATUS_TIMEOUT;  
328 - */  
329 -  
330 - int state = hllapi_wait_for_ready(60);  
331 - return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);  
332 -  
333 -}  
334 -  
335 -static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)  
336 -{  
337 - /*  
338 - * Call Parameters  
339 - *  
340 - * Data String of ASCII data to be copied into the host presentation space.  
341 - * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.  
342 - * PS Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.  
343 - *  
344 - * Return Parameters  
345 - *  
346 - * HLLAPI_STATUS_SUCCESS 0 The Copy String to Presentation Space function was successful.  
347 - * HLLAPI_STATUS_DISCONNECTED 1 Your program is not connected to a host session.  
348 - * HLLAPI_STATUS_BAD_PARAMETER 2 Parameter error or zero length for copy.  
349 - * HLLAPI_STATUS_KEYBOARD_LOCKED 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).  
350 - * 6 The copy was completed, but the data was truncated.  
351 - * 7 The host presentation space position is not valid.  
352 - * HLLAPI_STATUS_SYSTEM_ERROR 9 A system error was encountered.  
353 - *  
354 - */  
355 - size_t szText = strlen(text);  
356 -  
357 - if(*length < szText)  
358 - szText = *length;  
359 -  
360 - if(!szText)  
361 - return HLLAPI_STATUS_BAD_PARAMETER;  
362 -  
363 - switch(hllapi_get_message_id())  
364 - {  
365 - case LIB3270_MESSAGE_NONE:  
366 - break;  
367 -  
368 - case LIB3270_MESSAGE_DISCONNECTED:  
369 - return HLLAPI_STATUS_DISCONNECTED;  
370 -  
371 - case LIB3270_MESSAGE_MINUS:  
372 - case LIB3270_MESSAGE_PROTECTED:  
373 - case LIB3270_MESSAGE_NUMERIC:  
374 - case LIB3270_MESSAGE_OVERFLOW:  
375 - case LIB3270_MESSAGE_INHIBIT:  
376 - case LIB3270_MESSAGE_KYBDLOCK:  
377 - return HLLAPI_STATUS_KEYBOARD_LOCKED;  
378 -  
379 - default:  
380 - return HLLAPI_STATUS_SYSTEM_ERROR;  
381 - }  
382 -  
383 - return hllapi_emulate_input(text,szText,0);  
384 -}  
385 -  
386 -static int reset_system(char *buffer, unsigned short *length, unsigned short *rc)  
387 -{  
388 - return hllapi_reset();  
389 -}  
390 -  
391 -  
392 -static int pause_system(char *buffer, unsigned short *length, unsigned short *rc)  
393 -{  
394 - if(!*length)  
395 - {  
396 - // If you use the IPAUSE option and the pause value is zero, then the function  
397 - // waits up to 2400 half-second intervals, unless interrupted sooner. If you use the  
398 - // FPAUSE option and the pause value is zero, then the function returns  
399 - // immediately.  
400 -  
401 - if(pause_mode == PAUSE_MODE_FPAUSE)  
402 - {  
403 - return HLLAPI_STATUS_SUCCESS;  
404 - }  
405 - return hllapi_wait_for_ready(1200);  
406 - }  
407 -  
408 - if(pause_mode == PAUSE_MODE_FPAUSE)  
409 - {  
410 - // Pause fixo - Aguarda pelo tempo informado, independente de eventos.  
411 - return hllapi_wait( (*length) / 2);  
412 - }  
413 -  
414 - // Pause "flexivel", aguarda mudança no conteúdo da tela!!!  
415 -  
416 - // #warning Mudar comportamento na lib!  
417 -  
418 - return hllapi_wait_for_ready((*length) / 2);  
419 -}  
420 -  
421 -static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc)  
422 -{  
423 - if(!(*length && buffer && *buffer))  
424 - {  
425 - return HLLAPI_STATUS_BAD_PARAMETER;  
426 - }  
427 -  
428 - *rc = hllapi_set_session_parameter(buffer, *length, *rc);  
429 -  
430 - return 0;  
431 -}  
432 -  
433 -HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value)  
434 -{  
435 - if(!param)  
436 - {  
437 - return HLLAPI_STATUS_BAD_PARAMETER;  
438 - }  
439 -  
440 - if(!len)  
441 - {  
442 - len = strlen(param);  
443 - }  
444 -  
445 - if(!strncasecmp(param,"IPAUSE",len))  
446 - {  
447 - // IPAUSE  
448 - pause_mode = PAUSE_MODE_IPAUSE;  
449 - }  
450 - else if(!strncasecmp(param,"FPAUSE",len))  
451 - {  
452 - // FPAUSE  
453 - pause_mode = PAUSE_MODE_FPAUSE;  
454 - }  
455 - else if(!strncasecmp(param,"UNLOCKDELAY",len))  
456 - {  
457 - // UNLOCKDELAY  
458 - hllapi_set_unlock_delay(value);  
459 - }  
460 - else  
461 - {  
462 - return HLLAPI_STATUS_BAD_PARAMETER;  
463 - }  
464 -  
465 - return HLLAPI_STATUS_SUCCESS;  
466 -}  
src/hllapi/hllapi.cbp
@@ -1,89 +0,0 @@ @@ -1,89 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>  
2 -<CodeBlocks_project_file>  
3 - <FileVersion major="1" minor="6" />  
4 - <Project>  
5 - <Option title="pw3270 HLLAPI" />  
6 - <Option makefile_is_custom="1" />  
7 - <Option pch_mode="2" />  
8 - <Option compiler="gcc" />  
9 - <Build>  
10 - <Target title="Debug">  
11 - <Option output=".bin/Debug/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />  
12 - <Option object_output=".obj/Debug/" />  
13 - <Option type="1" />  
14 - <Option compiler="gcc" />  
15 - <Compiler>  
16 - <Add option="-g" />  
17 - </Compiler>  
18 - <MakeCommands>  
19 - <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />  
20 - <CompileFile command="$make -f $makefile $file" />  
21 - <Clean command="$make -f $makefile clean$target" />  
22 - <DistClean command="$make -f $makefile distclean$target" />  
23 - <AskRebuildNeeded command="$make -q -f $makefile $target" />  
24 - <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />  
25 - </MakeCommands>  
26 - </Target>  
27 - <Target title="Release">  
28 - <Option output=".bin/Release/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />  
29 - <Option object_output=".obj/Release/" />  
30 - <Option type="1" />  
31 - <Option compiler="gcc" />  
32 - <Compiler>  
33 - <Add option="-O2" />  
34 - </Compiler>  
35 - <Linker>  
36 - <Add option="-s" />  
37 - </Linker>  
38 - </Target>  
39 - <Target title="test">  
40 - <Option output=".bin/Debug/test" prefix_auto="1" extension_auto="1" />  
41 - <Option object_output=".obj/Debug/" />  
42 - <Option type="1" />  
43 - <Option compiler="gcc" />  
44 - <Compiler>  
45 - <Add option="-g" />  
46 - </Compiler>  
47 - <Environment>  
48 - <Variable name="LIB3270_CFLAGS" value='&quot;-I../../../src/include&quot;' />  
49 - <Variable name="LIB3270_LIBS" value='&quot;-L../../../.bin/Debug -l3270&quot;' />  
50 - <Variable name="PW3270_LIBS" value='&quot;-L../../../.bin/Debug -lpw3270 -l3270&quot;' />  
51 - </Environment>  
52 - <MakeCommands>  
53 - <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />  
54 - <CompileFile command="$make -f $makefile $file" />  
55 - <Clean command="$make -f $makefile clean$target" />  
56 - <DistClean command="$make -f $makefile distclean$target" />  
57 - <AskRebuildNeeded command="$make -q -f $makefile $target" />  
58 - <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />  
59 - </MakeCommands>  
60 - </Target>  
61 - </Build>  
62 - <Compiler>  
63 - <Add option="-Wall" />  
64 - </Compiler>  
65 - <Unit filename="../../include/lib3270.h" />  
66 - <Unit filename="../../include/pw3270/hllapi.h" />  
67 - <Unit filename="../../include/pw3270cpp.h" />  
68 - <Unit filename="Makefile.in" />  
69 - <Unit filename="calls.cc" />  
70 - <Unit filename="client.h" />  
71 - <Unit filename="hllapi.c">  
72 - <Option compilerVar="CC" />  
73 - </Unit>  
74 - <Unit filename="pluginmain.c">  
75 - <Option compilerVar="CC" />  
76 - </Unit>  
77 - <Unit filename="remotectl.h" />  
78 - <Unit filename="server.h" />  
79 - <Unit filename="testprogram.c">  
80 - <Option compilerVar="CC" />  
81 - </Unit>  
82 - <Extensions>  
83 - <code_completion />  
84 - <envvars />  
85 - <debugger />  
86 - <lib_finder disable_auto="1" />  
87 - </Extensions>  
88 - </Project>  
89 -</CodeBlocks_project_file>  
src/hllapi/idlcomp.bat
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -@echo off  
2 -  
3 -midl.exe /I "%WINSDK%\Include\um" /I "%WINSDK%\Include\shared" /cpp_cmd "cl.exe" pw3270.idl  
src/hllapi/maketest.sh
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -make LIB3270_MODE=Debug test  
src/hllapi/pw3270.idl
@@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
1 -// This is the type library for libhllapi.dll  
2 -  
3 -//  
4 -// References:  
5 -//  
6 -// http://support.microsoft.com/kb/189133  
7 -// http://msdn.microsoft.com/en-us/library/windows/desktop/aa367300(v=vs.85).aspx  
8 -//  
9 -[  
10 - // Use GUIDGEN.EXE to create the UUID that uniquely identifies  
11 - // this library on the user's system. NOTE: This must be done!!  
12 - uuid(4CC73F7D-5C10-4313-8FFD-F01999A44656),  
13 -  
14 - // This helpstring defines how the library will appear in the  
15 - // References dialog of VB.  
16 - helpstring("PW3270 HLLAPI typelib"),  
17 -  
18 - // Assume standard English locale.  
19 - lcid(0x0409),  
20 -  
21 - // Assign a version number to keep track of changes.  
22 - version(5.0)  
23 -]  
24 -  
25 -library HLLAPI  
26 -{  
27 -  
28 - // Now define the module that will "declare" your C functions.  
29 - [  
30 - helpstring("HLLAPI calls for pw3270"),  
31 -  
32 - version(5.0),  
33 -  
34 - // Give the name of your DLL here.  
35 - dllname("libhllapi.dll")  
36 - ]  
37 -  
38 - module hllApiFunctions  
39 - {  
40 - [  
41 - helpstring("Initialize pw3270´s instance."),  
42 - entry("hllapi_init")  
43 - ]  
44 - // The [in], [out], and [in, out] keywords tell the Automation  
45 - // client which direction parameters need to be passed. Some  
46 - // calls can be optimized if a function only needs a parameter  
47 - // to be passed one-way.  
48 - DWORD __stdcall hllapi_init( [in] LPSTR mode);  
49 -  
50 -  
51 - } // End of Module  
52 -  
53 -}; // End of Library  
src/hllapi/remotectl.h
@@ -1,84 +0,0 @@ @@ -1,84 +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. 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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como remotectl.h 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 - * Agradecimento:  
29 - *  
30 - * Hélio Passos  
31 - *  
32 - */  
33 -  
34 - #define ENABLE_NLS  
35 - #define GETTEXT_PACKAGE PACKAGE_NAME  
36 -  
37 - #include <libintl.h>  
38 - #include <glib/gi18n.h>  
39 - #include <gtk/gtk.h>  
40 -  
41 - #include <lib3270.h>  
42 - #include <lib3270/log.h>  
43 - #include <pw3270/hllapi.h>  
44 -  
45 - typedef struct _remotequery  
46 - {  
47 -#ifdef _WIN32  
48 - HANDLE hPipe; /**< Pipe handle (for response) */  
49 -#endif // _WIN32  
50 -  
51 - H3270 * hSession; /**< 3270 Session */  
52 - int cmd; /**< Command */  
53 - int rc; /**< Response status */  
54 -  
55 - int pos;  
56 - unsigned short length; /**< Query string length */  
57 - const gchar * text; /**< Query string */  
58 -  
59 - } QUERY;  
60 -  
61 - G_GNUC_INTERNAL void enqueue_request(QUERY *qry);  
62 - G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text);  
63 -  
64 - G_GNUC_INTERNAL void request_status(QUERY *qry, int rc);  
65 - G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value);  
66 - G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer);  
67 -  
68 -// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);  
69 -  
70 -  
71 -#ifdef _WIN32  
72 -  
73 - #define PIPE_BUFFER_LENGTH 8192  
74 -  
75 - void init_source_pipe(HANDLE hPipe);  
76 - void popup_lasterror(const gchar *fmt, ...);  
77 -  
78 -#endif // _WIN32  
79 -  
80 -  
81 -  
82 -  
83 -  
84 -  
src/hllapi/windows/resources.rc.in
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -#include <windows.h>  
2 -  
3 -VS_VERSION_INFO VERSIONINFO  
4 -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
5 -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
6 -  
7 -BEGIN  
8 -  
9 - BLOCK "StringFileInfo"  
10 - BEGIN  
11 - BLOCK "080904E4"  
12 - BEGIN  
13 - VALUE "FileDescription", "pw3270 HLLAPI Client Module\0"  
14 - VALUE "CompanyName", "Banco do Brasil S/A.\0"  
15 - VALUE "FileVersion", "@WIN32_VERSION@\0"  
16 - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"  
17 - VALUE "OriginalFilename", "hllapi@DLLEXT@\0"  
18 - VALUE "ProductName", "pw3270\0"  
19 - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0"  
20 - END  
21 - END  
22 -  
23 - BLOCK "VarFileInfo"  
24 - BEGIN  
25 - VALUE "Translation", 0x809, 0x04E4  
26 - END  
27 -  
28 -END  
29 -  
src/include/config.h.in
@@ -27,15 +27,12 @@ @@ -27,15 +27,12 @@
27 * 27 *
28 */ 28 */
29 29
30 -#ifndef LIBV3270_CONFIG_INCLUDED 30 +#ifndef CONFIG_H_INCLUDED
31 31
32 - #define LIBV3270_CONFIG_INCLUDED 1 32 + #define CONFIG_H_INCLUDED 1
33 33
34 #undef PACKAGE_NAME 34 #undef PACKAGE_NAME
35 #undef PACKAGE_VERSION 35 #undef PACKAGE_VERSION
36 #undef PACKAGE_RELEASE 36 #undef PACKAGE_RELEASE
37 37
38 - #undef HAVE_GNOME  
39 - #undef HAVE_GTKMAC  
40 -  
41 -#endif /* LIBV3270_CONFIG_INCLUDED */ 38 +#endif /* CONFIG_H_INCLUDED */
src/include/lib3270/hllapi.h 0 → 100644
@@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
  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 private.h 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 <pw3270/hllapi.h>
  31 +
  32 + #ifndef ETIMEDOUT
  33 + #define ETIMEDOUT 1238
  34 + #endif // ETIMEDOUT
  35 +
  36 + #define PIPE_BUFFER_LENGTH 8192
  37 +
  38 + #define set_active(x) /* x */
  39 +
  40 + #if defined(DEBUG) && defined(_WIN32)
  41 + #undef trace
  42 + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
  43 + #endif // DEBUG
  44 +
  45 + #ifdef __cplusplus
  46 + extern "C" {
  47 + #endif
  48 +
  49 + char * hllapi_get_string(int offset, size_t len);
  50 + void hllapi_free(void *p);
  51 +
  52 + #ifdef __cplusplus
  53 + } /* end of extern "C" */
  54 + #endif
  55 +
  56 +
src/ipc3270c/linux/daemon.h
@@ -1,46 +0,0 @@ @@ -1,46 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como daemon.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 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 - #include "service.h"  
37 -  
38 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
39 -  
40 - G_GNUC_INTERNAL GMainLoop * main_loop;  
41 -  
42 -  
43 -/*---[ Prototipes ]------------------------------------------------------------------------------*/  
44 -  
45 - G_GNUC_INTERNAL void pw3270_dbus_register_io_handlers(void);  
46 -  
src/ipc3270c/linux/globals.h
@@ -1,67 +0,0 @@ @@ -1,67 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como globals.h 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 -#ifndef PW3270_DBUS_GLOBALS_H_INCLUDED  
33 -  
34 - #define PW3270_DBUS_GLOBALS_H_INCLUDED 1  
35 -  
36 - #include <libintl.h>  
37 - #include <glib.h>  
38 - #include <glib/gi18n.h>  
39 -  
40 - #include <errno.h>  
41 - #include <lib3270.h>  
42 - #include <lib3270/log.h>  
43 - #include <glib.h>  
44 -  
45 -#if ! GLIB_CHECK_VERSION(2,44,0)  
46 -  
47 - G_GNUC_INTERNAL void hllapi_autoptr_cleanup_generic_gfree(void *p);  
48 - #define g_autofree __attribute__((cleanup(hllapi_autoptr_cleanup_generic_gfree)))  
49 -  
50 -#endif // ! GLIB(2,44,0)  
51 -  
52 - //  
53 - // Disabling warning on unused-function defined in dbus-glib-bindings.h  
54 - // warning: 'org_freedesktop_DBus_reload_config' defined but not used [-Wunused-function] ...  
55 - //  
56 - #pragma GCC diagnostic ignored "-Wunused-function"  
57 -  
58 - #include <dbus/dbus-glib.h>  
59 - #include <dbus/dbus-glib-bindings.h>  
60 - #include <dbus/dbus-glib-lowlevel.h>  
61 -  
62 - #define ERROR_DOMAIN g_quark_from_static_string("pw3270DBUS")  
63 -  
64 - G_GNUC_INTERNAL gpointer pw3270_dbus_register_object (DBusGConnection *connection,DBusGProxy *proxy,GType object_type,const DBusGObjectInfo *info,const gchar *path);  
65 -  
66 -  
67 -#endif // PW3270_DBUS_GLOBALS_H_INCLUDED  
src/ipc3270c/linux/gobject.c
@@ -1,621 +0,0 @@ @@ -1,621 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como gobject.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 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 -#include <glib.h>  
37 -#include <gtk/gtk.h>  
38 -#include <dbus/dbus.h>  
39 -#include <dbus/dbus-glib-lowlevel.h>  
40 -#include <dbus/dbus-glib.h>  
41 -  
42 -#include <config.h>  
43 -#include <lib3270.h>  
44 -#include <pw3270.h>  
45 -#include <v3270.h>  
46 -#include <lib3270/actions.h>  
47 -#include <lib3270/charset.h>  
48 -#include <lib3270/toggle.h>  
49 -  
50 -#include "service.h"  
51 -  
52 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
53 -  
54 -  
55 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
56 -  
57 -G_DEFINE_TYPE(PW3270Dbus, pw3270_dbus, G_TYPE_OBJECT)  
58 -  
59 -static void pw3270_dbus_finalize(GObject *object)  
60 -{  
61 - G_OBJECT_CLASS(pw3270_dbus_parent_class)->finalize (object);  
62 -}  
63 -  
64 -  
65 -static void pw3270_dbus_class_init(PW3270DbusClass *klass)  
66 -{  
67 - GObjectClass *object_class;  
68 - object_class = G_OBJECT_CLASS (klass);  
69 - object_class->finalize = pw3270_dbus_finalize;  
70 - debug("%s",__FUNCTION__);  
71 -}  
72 -  
73 -static void pw3270_dbus_init(PW3270Dbus *object)  
74 -{  
75 - debug("%s(%p)",__FUNCTION__,object);  
76 -}  
77 -  
78 -PW3270Dbus * pw3270_dbus_new(void)  
79 -{  
80 - return (PW3270Dbus *) g_object_new(PW3270_TYPE_DBUS, NULL);  
81 -}  
82 -  
83 -void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context)  
84 -{  
85 - debug("%s object=%p context=%p",__FUNCTION__,object,context);  
86 - dbus_g_method_return(context,lib3270_get_revision());  
87 -}  
88 -  
89 -void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)  
90 -{  
91 - H3270 *hSession = pw3270_dbus_get_session_handle(PW3270_DBUS(object));  
92 -  
93 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
94 -  
95 - if(uri && *uri)  
96 - {  
97 - lib3270_set_url(hSession,uri);  
98 - g_message("Connecting to \"%s\" by remote request",lib3270_get_url(hSession));  
99 - }  
100 - else  
101 - {  
102 - g_message("%s","Connecting by remote request");  
103 - }  
104 -  
105 - dbus_g_method_return(context,lib3270_reconnect(hSession,0));  
106 -}  
107 -  
108 -void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context)  
109 -{  
110 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
111 -  
112 - g_message("Changing host to \"%s\" by remote request",uri);  
113 -  
114 - dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) != 0);  
115 -}  
116 -  
117 -void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context)  
118 -{  
119 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
120 - dbus_g_method_return(context,lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object))));  
121 -}  
122 -  
123 -  
124 -void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context)  
125 -{  
126 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
127 -  
128 - g_message("Disconnecting by remote request");  
129 - lib3270_disconnect(pw3270_dbus_get_session_handle(object));  
130 - dbus_g_method_return(context,0);  
131 -}  
132 -  
133 -void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context)  
134 -{  
135 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
136 - dbus_g_method_return(context,lib3270_get_program_message(pw3270_dbus_get_session_handle(object)));  
137 -}  
138 -  
139 -void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
140 -{  
141 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
142 - dbus_g_method_return(context,lib3270_get_connection_state(pw3270_dbus_get_session_handle(object)));  
143 -}  
144 -  
145 -void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
146 -{  
147 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
148 - dbus_g_method_return(context,lib3270_get_secure(pw3270_dbus_get_session_handle(object)));  
149 -}  
150 -  
151 -GError * pw3270_dbus_get_error_from_errno(int code)  
152 -{  
153 - return g_error_new(ERROR_DOMAIN,code,"%s",g_strerror(code));  
154 -}  
155 -  
156 -int pw3270_dbus_check_valid_state(PW3270Dbus *object, DBusGMethodInvocation *context)  
157 -{  
158 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
159 - GError * error = NULL;  
160 -  
161 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
162 -  
163 - if(!lib3270_is_connected(hSession))  
164 - {  
165 - error = pw3270_dbus_get_error_from_errno(ENOTCONN);  
166 - }  
167 - else  
168 - {  
169 - LIB3270_MESSAGE state = lib3270_get_program_message(hSession);  
170 -  
171 - switch(state)  
172 - {  
173 - case LIB3270_MESSAGE_NONE:  
174 - return 0;  
175 -  
176 - case LIB3270_MESSAGE_DISCONNECTED:  
177 - error = pw3270_dbus_get_error_from_errno(ENOTCONN);  
178 - break;  
179 -  
180 - case LIB3270_MESSAGE_MINUS:  
181 - case LIB3270_MESSAGE_PROTECTED:  
182 - case LIB3270_MESSAGE_NUMERIC:  
183 - case LIB3270_MESSAGE_OVERFLOW:  
184 - case LIB3270_MESSAGE_INHIBIT:  
185 - case LIB3270_MESSAGE_KYBDLOCK:  
186 - case LIB3270_MESSAGE_X:  
187 - error = g_error_new(ERROR_DOMAIN,-1,_( "State %04d can't accept requests" ),state);  
188 - break;  
189 -  
190 - case LIB3270_MESSAGE_SYSWAIT:  
191 - case LIB3270_MESSAGE_TWAIT:  
192 - case LIB3270_MESSAGE_CONNECTED:  
193 - case LIB3270_MESSAGE_AWAITING_FIRST:  
194 - error = pw3270_dbus_get_error_from_errno(EBUSY);  
195 - break;  
196 -  
197 - case LIB3270_MESSAGE_RESOLVING:  
198 - case LIB3270_MESSAGE_CONNECTING:  
199 - error = g_error_new(ERROR_DOMAIN,EINPROGRESS,_( "Connecting to host" ));  
200 - break;  
201 -  
202 - case LIB3270_MESSAGE_USER:  
203 - error = g_error_new(ERROR_DOMAIN,-1,_( "Unexpected state %04d" ),state);  
204 - }  
205 - }  
206 -  
207 - if(error)  
208 - {  
209 - dbus_g_method_return_error(context,error);  
210 - g_error_free(error);  
211 - return -1;  
212 - }  
213 -  
214 - return 0;  
215 -}  
216 -  
217 -void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context)  
218 -{  
219 - char * text;  
220 - gchar * utftext;  
221 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
222 -  
223 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
224 -  
225 - if(pw3270_dbus_check_valid_state(object,context))  
226 - return;  
227 -  
228 - text = lib3270_get_string_at_address(hSession,0,-1,'\n');  
229 -  
230 - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
231 -  
232 - lib3270_free(text);  
233 -  
234 - dbus_g_method_return(context,utftext);  
235 -  
236 - g_free(utftext);  
237 -  
238 -}  
239 -  
240 -void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context)  
241 -{  
242 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
243 - if(pw3270_dbus_check_valid_state(object,context))  
244 - return;  
245 - dbus_g_method_return(context,lib3270_enter(pw3270_dbus_get_session_handle(object)));  
246 -}  
247 -  
248 -void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context)  
249 -{  
250 - gchar * text;  
251 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
252 -  
253 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
254 - if(pw3270_dbus_check_valid_state(object,context))  
255 - return;  
256 -  
257 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
258 -  
259 - int sz = lib3270_set_string_at(hSession,row,col,(const unsigned char *) text);  
260 -  
261 - trace("%s returns %d",__FUNCTION__,sz);  
262 - dbus_g_method_return(context,sz);  
263 -  
264 - g_free(text);  
265 -}  
266 -  
267 -void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context)  
268 -{  
269 - gchar * text;  
270 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
271 -  
272 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
273 - if(pw3270_dbus_check_valid_state(object,context))  
274 - return;  
275 -  
276 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
277 -  
278 - dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1));  
279 -  
280 - g_free(text);  
281 -}  
282 -  
283 -  
284 -void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context)  
285 -{  
286 - gchar * text;  
287 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
288 -  
289 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
290 - if(pw3270_dbus_check_valid_state(object,context))  
291 - return;  
292 -  
293 - text = lib3270_get_string_at(hSession, row, col, len, lf);  
294 - if(!text)  
295 - {  
296 - GError *error = pw3270_dbus_get_error_from_errno(errno);  
297 - dbus_g_method_return_error(context,error);  
298 - g_error_free(error);  
299 - }  
300 - else  
301 - {  
302 - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
303 -  
304 - lib3270_free(text);  
305 -  
306 - dbus_g_method_return(context,utftext);  
307 -  
308 - g_free(utftext);  
309 - }  
310 - }  
311 -  
312 - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context)  
313 - {  
314 - gchar * text;  
315 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
316 -  
317 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
318 - if(pw3270_dbus_check_valid_state(object,context))  
319 - return;  
320 -  
321 - if(len < 0) {  
322 - len = lib3270_get_length(hSession);  
323 - }  
324 -  
325 - text = lib3270_get_string_at_address(hSession,offset,len,lf);  
326 - if(!text)  
327 - {  
328 - GError *error = pw3270_dbus_get_error_from_errno(errno);  
329 - dbus_g_method_return_error(context,error);  
330 - g_error_free(error);  
331 - }  
332 - else  
333 - {  
334 - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
335 -  
336 - lib3270_free(text);  
337 -  
338 - debug("\n%s\n",utftext);  
339 -  
340 - dbus_g_method_return(context,utftext);  
341 -  
342 - g_free(utftext);  
343 - }  
344 -  
345 - }  
346 -  
347 - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context)  
348 - {  
349 - trace("%s object=%p context=%p connected=%s",__FUNCTION__,object,context, lib3270_is_connected(pw3270_dbus_get_session_handle(object)) ? "Yes" : "No");  
350 - dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object)));  
351 - }  
352 -  
353 - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context)  
354 - {  
355 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
356 - dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object)));  
357 - }  
358 -  
359 - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context)  
360 - {  
361 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
362 - dbus_g_method_return(context,lib3270_in_tn3270e(pw3270_dbus_get_session_handle(object)));  
363 - }  
364 -  
365 - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context)  
366 - {  
367 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
368 - dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout));  
369 - }  
370 -  
371 - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)  
372 - {  
373 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
374 - dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col));  
375 - }  
376 -  
377 - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context)  
378 - {  
379 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
380 - dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr));  
381 - }  
382 -  
383 - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context)  
384 - {  
385 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
386 - dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object)));  
387 - }  
388 -  
389 - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context)  
390 - {  
391 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
392 - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));  
393 - }  
394 -  
395 - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context)  
396 - {  
397 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
398 - dbus_g_method_return(context,lib3270_get_height(pw3270_dbus_get_session_handle(object)));  
399 - }  
400 -  
401 - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context)  
402 - {  
403 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
404 - dbus_g_method_return(context,lib3270_get_width(pw3270_dbus_get_session_handle(object)));  
405 - }  
406 -  
407 - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context)  
408 - {  
409 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
410 - dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),(LIB3270_TOGGLE) id,value));  
411 - }  
412 -  
413 -void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context)  
414 -{  
415 - gchar * text;  
416 - H3270 * hSession = pw3270_dbus_get_session_handle(object);  
417 -  
418 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
419 - if(pw3270_dbus_check_valid_state(object,context))  
420 - return;  
421 -  
422 - text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);  
423 -  
424 - dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf));  
425 -  
426 - g_free(text);  
427 -}  
428 -  
429 -void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)  
430 -{  
431 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
432 - if(pw3270_dbus_check_valid_state(object,context))  
433 - return;  
434 - dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key));  
435 -}  
436 -  
437 -void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)  
438 -{  
439 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
440 - if(pw3270_dbus_check_valid_state(object,context))  
441 - return;  
442 - dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key));  
443 -}  
444 -  
445 - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
446 - {  
447 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
448 - dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr));  
449 - }  
450 -  
451 - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
452 - {  
453 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
454 - dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr));  
455 - }  
456 -  
457 - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
458 - {  
459 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
460 - dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr));  
461 - }  
462 -  
463 - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context)  
464 - {  
465 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
466 - dbus_g_method_return(context,lib3270_get_is_protected(pw3270_dbus_get_session_handle(object),baddr));  
467 - }  
468 -  
469 - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)  
470 - {  
471 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
472 - dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col));  
473 - }  
474 -  
475 - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)  
476 - {  
477 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
478 - dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text));  
479 - }  
480 -  
481 - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context)  
482 - {  
483 - gchar *text;  
484 -  
485 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
486 -  
487 - if(pw3270_dbus_check_valid_state(object,context))  
488 - return;  
489 -  
490 - text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD));  
491 -  
492 - trace("Clipboard:\n%s\n",text);  
493 -  
494 - if(!text)  
495 - {  
496 - GError *error = pw3270_dbus_get_error_from_errno(ENOENT);  
497 - dbus_g_method_return_error(context,error);  
498 - g_error_free(error);  
499 - }  
500 - else  
501 - {  
502 - dbus_g_method_return(context,text);  
503 - g_free(text);  
504 - }  
505 -}  
506 -  
507 -void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)  
508 -{  
509 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
510 - gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1);  
511 - dbus_g_method_return(context,0);  
512 -}  
513 -  
514 -void pw3270_dbus_set_script(PW3270Dbus *object, const gchar G_GNUC_UNUSED(*text), int mode, DBusGMethodInvocation *context)  
515 -{  
516 - GtkWidget *widget = pw3270_get_terminal_widget(NULL);  
517 -  
518 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
519 -  
520 - if(!widget)  
521 - {  
522 - GError *error = pw3270_dbus_get_error_from_errno(EINVAL);  
523 - dbus_g_method_return_error(context,error);  
524 - g_error_free(error);  
525 - return;  
526 - }  
527 -  
528 - dbus_g_method_return(context,v3270_set_script(widget,mode == 0 ? 0 : 'S'));  
529 -}  
530 -  
531 -void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context)  
532 -{  
533 - lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text);  
534 - dbus_g_method_return(context,0);  
535 -}  
536 -  
537 -void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context)  
538 -{  
539 - dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object)));  
540 -}  
541 -  
542 -void pw3270_dbus_get_display_charset(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)  
543 -{  
544 - // Allways return UTF-8 to avoid double conversion  
545 - dbus_g_method_return(context,"UTF-8");  
546 -}  
547 -  
548 -void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context)  
549 -{  
550 - dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset));  
551 -}  
552 -  
553 -void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context)  
554 -{  
555 - trace("%s object=%p context=%p",__FUNCTION__,object,context);  
556 - dbus_g_method_return(context,lib3270_eraseeof(pw3270_dbus_get_session_handle(object)));  
557 -}  
558 -  
559 -void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context)  
560 -{  
561 - dbus_g_method_return(context,lib3270_print_all(pw3270_dbus_get_session_handle(object)));  
562 -}  
563 -  
564 -void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context)  
565 -{  
566 - lib3270_set_unlock_delay(pw3270_dbus_get_session_handle(object),(unsigned short) value);  
567 - dbus_g_method_return(context,0);  
568 -}  
569 -  
570 -  
571 -void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)  
572 -{  
573 - int sz = strlen(from);  
574 -  
575 - if(sz > 0)  
576 - {  
577 - unsigned char buffer[sz+1];  
578 - memcpy(buffer,from,sz);  
579 - dbus_g_method_return(context,lib3270_ebc2asc(pw3270_dbus_get_session_handle(object),buffer,sz));  
580 - return;  
581 - }  
582 -  
583 - dbus_g_method_return(context,"");  
584 -  
585 -}  
586 -  
587 -void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context)  
588 -{  
589 - int sz = strlen(from);  
590 -  
591 - if(sz > 0)  
592 - {  
593 - unsigned char buffer[sz+1];  
594 - memcpy(buffer,from,sz);  
595 - dbus_g_method_return(context,lib3270_asc2ebc(pw3270_dbus_get_session_handle(object),buffer,sz));  
596 - return;  
597 - }  
598 -  
599 - dbus_g_method_return(context,"");  
600 -  
601 -}  
602 -  
603 -void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context)  
604 -{  
605 - /*  
606 - dbus_g_method_return(context,  
607 - v3270_transfer_file(  
608 - v3270_get_default_widget(),  
609 - (LIB3270_FT_OPTION) flags,  
610 - local,  
611 - remote,  
612 - lrecl,  
613 - blksize,  
614 - primspace,  
615 - secspace,  
616 - dft  
617 - ));  
618 - */  
619 - return;  
620 -}  
621 -  
src/ipc3270c/linux/main.c
@@ -1,189 +0,0 @@ @@ -1,189 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como main.c e possui - linhas de código.  
22 - *  
23 - * Referências:  
24 - *  
25 - * https://github.com/fbuihuu/samples-dbus/blob/master/dbus-server.c  
26 - *  
27 - * Contatos:  
28 - *  
29 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
30 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
31 - *  
32 - */  
33 -  
34 -#include <glib.h>  
35 -#include <dbus/dbus.h>  
36 -#include <dbus/dbus-glib-lowlevel.h>  
37 -#include <dbus/dbus-glib.h>  
38 -  
39 -#include <v3270.h>  
40 -#include <pw3270.h>  
41 -#include <pw3270/plugin.h>  
42 -  
43 -#include "service.h"  
44 -#include "globals.h"  
45 -#include "dbus-glue.h"  
46 -  
47 -#include <gtk/gtk.h>  
48 -  
49 -/*---[ Globals ]---------------------------------------------------------------------------------*/  
50 -  
51 - static DBusGConnection * connection = NULL;  
52 - static DBusGProxy * proxy = NULL;  
53 - static gchar * service_name = NULL;  
54 -  
55 -  
56 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
57 -  
58 - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal)  
59 - {  
60 - GError * error = NULL;  
61 - guint result;  
62 - char session_id = 0;  
63 - char id = 'a';  
64 - gchar * ptr;  
65 - const gchar * name = v3270_get_session_name(terminal);  
66 -  
67 - connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);  
68 - if(error)  
69 - {  
70 - GtkWidget *dialog = gtk_message_dialog_new(  
71 - GTK_WINDOW(window),  
72 - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),  
73 - GTK_MESSAGE_ERROR,  
74 - GTK_BUTTONS_OK,  
75 - _( "Can't connect to DBUS server" ));  
76 -  
77 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
78 -  
79 - g_message("Error \"%s\" getting session dbus",error->message);  
80 -  
81 - g_error_free(error);  
82 -  
83 - gtk_dialog_run(GTK_DIALOG(dialog));  
84 - gtk_widget_destroy(dialog);  
85 -  
86 - return -1;  
87 - }  
88 -  
89 - proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);  
90 -  
91 - for(id='a'; id < 'z' && !error && !service_name; id++)  
92 - {  
93 - gboolean has_owner = FALSE;  
94 -  
95 - service_name = g_strdup_printf("br.com.bb.%s.%c",name,(int) id);  
96 - for(ptr=service_name;*ptr;ptr++)  
97 - *ptr = g_ascii_tolower(*ptr);  
98 -  
99 - org_freedesktop_DBus_name_has_owner(proxy, service_name, &has_owner, NULL);  
100 -  
101 - if(has_owner)  
102 - {  
103 - trace("Service \"%s\" has owner",service_name)  
104 - g_free(service_name);  
105 - service_name = NULL;  
106 - }  
107 - else  
108 - {  
109 - session_id = id;  
110 - g_message("DBUS service name is %s",service_name);  
111 - org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);  
112 - }  
113 - }  
114 -  
115 - if(error)  
116 - {  
117 - GtkWidget *dialog = gtk_message_dialog_new(  
118 - GTK_WINDOW(window),  
119 - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),  
120 - GTK_MESSAGE_ERROR,  
121 - GTK_BUTTONS_OK,  
122 - _( "Can't get DBUS object name" ));  
123 -  
124 - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message);  
125 -  
126 - g_message("Error \"%s\" requesting DBUS name",error->message);  
127 -  
128 - g_error_free(error);  
129 -  
130 - gtk_dialog_run(GTK_DIALOG(dialog));  
131 - gtk_widget_destroy(dialog);  
132 -  
133 - return -1;  
134 - }  
135 -  
136 - if(session_id)  
137 - {  
138 -  
139 - g_autofree gchar * session = g_strdup_printf("%s:%c",name,g_ascii_toupper(session_id));  
140 -  
141 - static const gchar * path = "/br/com/bb/pw3270";  
142 - g_message("DBUS service path is %s, session name is %s",path,session);  
143 - v3270_set_session_name(terminal,session);  
144 -  
145 - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,path);  
146 -  
147 - }  
148 -  
149 - return 0;  
150 - }  
151 -  
152 - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal))  
153 - {  
154 - if(proxy)  
155 - {  
156 - debug("%s: Releasing proxy",__FUNCTION__);  
157 - g_object_unref(proxy);  
158 - proxy = NULL;  
159 - }  
160 -  
161 - if(service_name)  
162 - {  
163 - g_free(service_name);  
164 - service_name = NULL;  
165 - }  
166 - return 0;  
167 - }  
168 -  
169 - void pw3270_dbus_quit(PW3270Dbus G_GNUC_UNUSED(*object), DBusGMethodInvocation *context)  
170 - {  
171 - gtk_main_quit();  
172 - dbus_g_method_return(context,0);  
173 - }  
174 -  
175 - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus G_GNUC_UNUSED(*object))  
176 - {  
177 - debug("%s=%p",__FUNCTION__,lib3270_get_default_session_handle());  
178 - return lib3270_get_default_session_handle();  
179 - }  
180 -  
181 -#if ! GLIB_CHECK_VERSION(2,44,0)  
182 -// Reference: https://github.com/ImageMagick/glib/blob/master/glib/glib-autocleanups.h  
183 -void hllapi_autoptr_cleanup_generic_gfree(void *p)  
184 -{  
185 - void **pp = (void**)p;  
186 - g_free (*pp);  
187 -}  
188 -#endif // ! GLIB(2,44,0)  
189 -  
src/ipc3270c/linux/misc.c
@@ -1,47 +0,0 @@ @@ -1,47 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como misc.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 - * Referencias:  
31 - *  
32 - * https://live.gnome.org/DBusGlibBindings  
33 - *  
34 - */  
35 -  
36 -#include "globals.h"  
37 -  
38 -/*---[ Implement ]-------------------------------------------------------------------------------*/  
39 -  
40 -gpointer pw3270_dbus_register_object(DBusGConnection *connection,DBusGProxy G_GNUC_UNUSED(*proxy),GType object_type,const DBusGObjectInfo *info,const gchar *path)  
41 -{  
42 - GObject *object = G_OBJECT(g_object_new(object_type, NULL));  
43 - dbus_g_object_type_install_info (object_type, info);  
44 - dbus_g_connection_register_g_object (connection, path, object);  
45 - return object;  
46 -}  
47 -  
src/ipc3270c/linux/service.h
@@ -1,138 +0,0 @@ @@ -1,138 +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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como service.h 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 -#ifndef _PW3270_DBUS_SERVICE_H  
33 -  
34 - #define _PW3270_DBUS_SERVICE_H 1  
35 -  
36 - #define ENABLE_NLS  
37 - #define GETTEXT_PACKAGE PACKAGE_NAME  
38 -  
39 - #include "globals.h"  
40 -  
41 - #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ())  
42 - #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus))  
43 - #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass))  
44 - #define IS_PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PW3270_TYPE_DBUS))  
45 - #define IS_PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DBUS))  
46 - #define PW3270_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DBUS, PW3270DbusClass))  
47 -  
48 - G_BEGIN_DECLS  
49 -  
50 - typedef struct _PW3270Dbus PW3270Dbus;  
51 - typedef struct _PW3270DbusClass PW3270DbusClass;  
52 -  
53 - struct _PW3270Dbus  
54 - {  
55 - GObject parent;  
56 - };  
57 -  
58 - struct _PW3270DbusClass  
59 - {  
60 - GObjectClass parent;  
61 - };  
62 -  
63 - PW3270Dbus * pw3270_dbus_new (void);  
64 - GType pw3270_dbus_get_type (void);  
65 -  
66 - void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context);  
67 - void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context);  
68 - void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);  
69 - void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context);  
70 - void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context);  
71 - void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context);  
72 -  
73 - void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context);  
74 - void pw3270_dbus_get_connection_state(PW3270Dbus *object, DBusGMethodInvocation *context);  
75 - void pw3270_dbus_get_secure_state(PW3270Dbus *object, DBusGMethodInvocation *context);  
76 -  
77 - void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *context);  
78 - H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object);  
79 - GError * pw3270_dbus_get_error_from_errno(int code);  
80 -  
81 - void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context);  
82 - void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context);  
83 - void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context);  
84 -  
85 - void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);  
86 - void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context);  
87 - void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context);  
88 -  
89 - void pw3270_dbus_get_screen_width(PW3270Dbus *object, DBusGMethodInvocation *context);  
90 - void pw3270_dbus_get_screen_height(PW3270Dbus *object, DBusGMethodInvocation *context);  
91 - void pw3270_dbus_get_screen_length(PW3270Dbus *object, DBusGMethodInvocation *context);  
92 -  
93 - void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context);  
94 -  
95 - void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context);  
96 -  
97 - void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
98 - void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
99 - void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
100 -  
101 - void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);  
102 - void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);  
103 -  
104 - void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context);  
105 -  
106 - void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context);  
107 -  
108 - void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);  
109 -  
110 - // Actions  
111 - void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context);  
112 - void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);  
113 - void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);  
114 - void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);  
115 - void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context);  
116 - void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context);  
117 - void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context);  
118 - void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context);  
119 -  
120 - void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);  
121 - void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context);  
122 -  
123 - void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context);  
124 - void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context);  
125 - void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context);  
126 - void pw3270_dbus_erase_eof(PW3270Dbus *object, DBusGMethodInvocation *context);  
127 - void pw3270_dbus_print(PW3270Dbus *object, DBusGMethodInvocation *context);  
128 -  
129 - void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);  
130 - void pw3270_dbus_ebc2asc(PW3270Dbus *object, const gchar *from, DBusGMethodInvocation *context);  
131 -  
132 - void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context);  
133 -  
134 - void pw3270_dbus_set_unlock_delay(PW3270Dbus *object, int value, DBusGMethodInvocation *context);  
135 -  
136 - G_END_DECLS  
137 -  
138 -#endif // _PW3270_DBUS_SERVICE_H  
src/ipc3270c/windows/main.c
@@ -1,671 +0,0 @@ @@ -1,671 +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. 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., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como - 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 - * Agradecimento:  
29 - *  
30 - * Hélio Passos  
31 - *  
32 - */  
33 -  
34 - #include "private.h"  
35 -  
36 -#ifdef _WIN32  
37 - #include <windows.h>  
38 -#else  
39 - #error HLLAPI is designed for windows.  
40 -#endif // _WIN32  
41 -  
42 - #include <pw3270/plugin.h>  
43 - #include <v3270.h>  
44 - #include <pw3270/ipcpackets.h>  
45 - #include <lib3270/actions.h>  
46 - #include <lib3270/charset.h>  
47 - #include <lib3270/toggle.h>  
48 -  
49 -/*--[ Defines ]--------------------------------------------------------------------------------------*/  
50 -  
51 - #pragma pack(1)  
52 -  
53 - enum PIPE_STATE  
54 - {  
55 - PIPE_STATE_WAITING,  
56 - PIPE_STATE_READ,  
57 - PIPE_STATE_PENDING_READ,  
58 - PIPE_STATE_UNDEFINED  
59 - };  
60 -  
61 - typedef struct _pipe_source  
62 - {  
63 - GSource gsrc;  
64 - HANDLE hPipe;  
65 -  
66 - enum PIPE_STATE state;  
67 -  
68 - OVERLAPPED overlap;  
69 - unsigned char buffer[PIPE_BUFFER_LENGTH+1];  
70 - } pipe_source;  
71 -  
72 - #pragma pack()  
73 -  
74 -  
75 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
76 -  
77 -// static const gchar control_char = '@';  
78 -  
79 -/*--[ Implement ]------------------------------------------------------------------------------------*/  
80 -  
81 - static void IO_accept(pipe_source *source)  
82 - {  
83 - set_active(FALSE);  
84 -  
85 - if(ConnectNamedPipe(source->hPipe,&source->overlap))  
86 - {  
87 - popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));  
88 - return;  
89 - }  
90 -  
91 - switch(GetLastError())  
92 - {  
93 - // The overlapped connection in progress.  
94 - case ERROR_IO_PENDING:  
95 - // trace("%s: ERROR_IO_PENDING",__FUNCTION__);  
96 - source->state = PIPE_STATE_WAITING;  
97 - break;  
98 -  
99 - // Client is already connected, so signal an event.  
100 - case ERROR_PIPE_CONNECTED:  
101 - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);  
102 - set_active(TRUE);  
103 - SetEvent(source->overlap.hEvent);  
104 - break;  
105 -  
106 - // If an error occurs during the connect operation...  
107 - default:  
108 - popup_lasterror("%s", _( "ConnectNamedPipe failed" ));  
109 - }  
110 -  
111 - }  
112 -  
113 - static gboolean IO_prepare(GSource *source, gint *timeout)  
114 - {  
115 - /*  
116 - * Called before all the file descriptors are polled.  
117 - * If the source can determine that it is ready here  
118 - * (without waiting for the results of the poll() call)  
119 - * it should return TRUE.  
120 - *  
121 - * It can also return a timeout_ value which should be the maximum  
122 - * timeout (in milliseconds) which should be passed to the poll() call.  
123 - * The actual timeout used will be -1 if all sources returned -1,  
124 - * or it will be the minimum of all the timeout_ values  
125 - * returned which were >= 0.  
126 - *  
127 - */  
128 - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
129 - return TRUE;  
130 -  
131 - *timeout = 10;  
132 - return FALSE;  
133 - }  
134 -  
135 - static gboolean IO_check(GSource *source)  
136 - {  
137 - /*  
138 - * Called after all the file descriptors are polled.  
139 - * The source should return TRUE if it is ready to be dispatched.  
140 - * Note that some time may have passed since the previous prepare  
141 - * function was called, so the source should be checked again here.  
142 - *  
143 - */  
144 - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)  
145 - return TRUE;  
146 -  
147 - return FALSE;  
148 - }  
149 -  
150 - static void send_text(pipe_source *source, char *text)  
151 - {  
152 - struct hllapi_packet_text *pkt;  
153 - DWORD szBlock;  
154 - int f;  
155 -  
156 - if(text)  
157 - {  
158 - szBlock = sizeof(struct hllapi_packet_text)+strlen(text);  
159 - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);  
160 - pkt->packet_id = 0;  
161 - strcpy(pkt->text,text);  
162 - lib3270_free(text);  
163 - }  
164 - else  
165 - {  
166 - szBlock = sizeof(struct hllapi_packet_text);  
167 - pkt = (struct hllapi_packet_text *) g_malloc0(szBlock);  
168 - pkt->packet_id = errno ? errno : -1;  
169 - }  
170 -  
171 - trace("szBlock=%d text=\"%s\"",szBlock, ( (struct hllapi_packet_text *) pkt)->text);  
172 - for(f=0;f< (int) szBlock;f++)  
173 - {  
174 - trace("rsp(%d)= %d \"%s\"",f,* (((char *) pkt)+f),((char *) pkt)+f);  
175 - }  
176 -  
177 - WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL);  
178 -  
179 - g_free(pkt);  
180 - }  
181 -  
182 - static void send_result(pipe_source *source, int rc)  
183 - {  
184 - struct hllapi_packet_result pkt = { rc };  
185 - DWORD wrote = sizeof(pkt);  
186 - WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL);  
187 - }  
188 -  
189 - static int do_file_transfer(struct hllapi_packet_file_transfer G_GNUC_UNUSED(* source))  
190 - {  
191 - /*  
192 - const gchar * local = (const char *) source->text;  
193 - const gchar * remote = (const char *) (local+strlen(local)+1);  
194 -  
195 - return v3270_transfer_file( v3270_get_default_widget(),  
196 - (LIB3270_FT_OPTION) source->options,  
197 - local,  
198 - remote,  
199 - source->lrecl,  
200 - source->blksize,  
201 - source->primspace,  
202 - source->secspace,  
203 - source->dft );  
204 - */  
205 - return EINVAL;  
206 - }  
207 -  
208 - static void get_host(pipe_source *source) {  
209 - send_text(source,strdup(lib3270_get_url(lib3270_get_default_session_handle())));  
210 - }  
211 -  
212 - static void process_input(pipe_source *source, DWORD G_GNUC_UNUSED(cbRead))  
213 - {  
214 - const struct hllapi_packet_query * query = ((struct hllapi_packet_query *) source->buffer);  
215 -  
216 - trace("%s id=%d",__FUNCTION__,query->packet_id);  
217 -  
218 - switch(query->packet_id)  
219 - {  
220 - case HLLAPI_PACKET_CONNECT:  
221 - send_result(source,lib3270_reconnect( lib3270_get_default_session_handle(),  
222 - ((struct hllapi_packet_connect *) source->buffer)->wait));  
223 - break;  
224 -  
225 - case HLLAPI_PACKET_CONNECT_URL:  
226 - send_result(source,lib3270_connect_url(lib3270_get_default_session_handle(),(const char *) (query+1),0));  
227 - break;  
228 -  
229 - case HLLAPI_PACKET_SET_HOST:  
230 - send_result(source,lib3270_set_url(lib3270_get_default_session_handle(),  
231 - ((struct hllapi_packet_text *) source->buffer)->text));  
232 - break;  
233 -  
234 - case HLLAPI_PACKET_GET_HOST:  
235 - get_host(source);  
236 - break;  
237 -  
238 - case HLLAPI_PACKET_DISCONNECT:  
239 - send_result(source,lib3270_disconnect(lib3270_get_default_session_handle()));  
240 - break;  
241 -  
242 - case HLLAPI_PACKET_IS_CONNECTED:  
243 - send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle()));  
244 - break;  
245 -  
246 - case HLLAPI_PACKET_IS_READY:  
247 - send_result(source,lib3270_is_ready(lib3270_get_default_session_handle()));  
248 - break;  
249 -  
250 - case HLLAPI_PACKET_ENTER:  
251 - send_result(source,lib3270_enter(lib3270_get_default_session_handle()));  
252 - break;  
253 -  
254 - case HLLAPI_PACKET_PRINT:  
255 - send_result(source,lib3270_print_all(lib3270_get_default_session_handle()));  
256 - break;  
257 -  
258 - case HLLAPI_PACKET_ERASE:  
259 - send_result(source,lib3270_erase(lib3270_get_default_session_handle()));  
260 - break;  
261 -  
262 - case HLLAPI_PACKET_ERASE_EOF:  
263 - send_result(source,lib3270_eraseeof(lib3270_get_default_session_handle()));  
264 - break;  
265 -  
266 - case HLLAPI_PACKET_ERASE_EOL:  
267 - send_result(source,lib3270_eraseeol(lib3270_get_default_session_handle()));  
268 - break;  
269 -  
270 - case HLLAPI_PACKET_ERASE_INPUT:  
271 - send_result(source,lib3270_eraseinput(lib3270_get_default_session_handle()));  
272 - break;  
273 -  
274 - case HLLAPI_PACKET_PFKEY:  
275 - send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(),  
276 - ((struct hllapi_packet_keycode *) source->buffer)->keycode));  
277 - break;  
278 -  
279 - case HLLAPI_PACKET_PAKEY:  
280 - send_result(source,lib3270_pakey( lib3270_get_default_session_handle(),  
281 - ((struct hllapi_packet_keycode *) source->buffer)->keycode));  
282 - break;  
283 -  
284 - case HLLAPI_PACKET_SET_CURSOR_POSITION:  
285 - send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(),  
286 - ((struct hllapi_packet_cursor *) source->buffer)->row,  
287 - ((struct hllapi_packet_cursor *) source->buffer)->col));  
288 - break;  
289 -  
290 - case HLLAPI_PACKET_SET_TEXT_AT:  
291 - send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(),  
292 - ((struct hllapi_packet_text_at *) source->buffer)->row,  
293 - ((struct hllapi_packet_text_at *) source->buffer)->col,  
294 - (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));  
295 - break;  
296 -  
297 - case HLLAPI_PACKET_GET_TEXT_AT:  
298 - send_text(source,lib3270_get_string_at( lib3270_get_default_session_handle(),  
299 - ((struct hllapi_packet_at *) source->buffer)->row,  
300 - ((struct hllapi_packet_at *) source->buffer)->col,  
301 - ((struct hllapi_packet_at *) source->buffer)->len,  
302 - ((struct hllapi_packet_at *) source->buffer)->lf));  
303 - break;  
304 -  
305 - case HLLAPI_PACKET_GET_TEXT_AT_OFFSET:  
306 - send_text(source,lib3270_get_string_at_address( lib3270_get_default_session_handle(),  
307 - ((struct hllapi_packet_query_offset *) source->buffer)->addr,  
308 - ((struct hllapi_packet_query_offset *) source->buffer)->len,  
309 - ((struct hllapi_packet_query_offset *) source->buffer)->lf));  
310 - break;  
311 -  
312 - case HLLAPI_PACKET_CMP_TEXT_AT:  
313 - send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),  
314 - ((struct hllapi_packet_text_at *) source->buffer)->row,  
315 - ((struct hllapi_packet_text_at *) source->buffer)->col,  
316 - ((struct hllapi_packet_text_at *) source->buffer)->text,  
317 - ((struct hllapi_packet_text_at *) source->buffer)->lf));  
318 - break;  
319 -  
320 - case HLLAPI_PACKET_INPUT_STRING:  
321 - send_result(source,lib3270_input_string(lib3270_get_default_session_handle(),  
322 - (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text));  
323 - break;  
324 -  
325 - case HLLAPI_PACKET_EMULATE_INPUT:  
326 - send_result(source,lib3270_emulate_input(lib3270_get_default_session_handle(),  
327 - (const char *) ((struct hllapi_packet_emulate_input *) source->buffer)->text,  
328 - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->len,  
329 - (int) ((struct hllapi_packet_emulate_input *) source->buffer)->pasting));  
330 - break;  
331 -  
332 - case HLLAPI_PACKET_SET_CURSOR:  
333 - send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(),  
334 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
335 - break;  
336 -  
337 - case HLLAPI_PACKET_GET_CURSOR:  
338 - send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle()));  
339 - break;  
340 -  
341 - case HLLAPI_PACKET_GET_WIDTH:  
342 - send_result(source,lib3270_get_width(lib3270_get_default_session_handle()));  
343 - break;  
344 -  
345 - case HLLAPI_PACKET_GET_HEIGHT:  
346 - send_result(source,lib3270_get_height(lib3270_get_default_session_handle()));  
347 - break;  
348 -  
349 - case HLLAPI_PACKET_GET_LENGTH:  
350 - send_result(source,lib3270_get_length(lib3270_get_default_session_handle()));  
351 - break;  
352 -  
353 - case HLLAPI_PACKET_GET_PROGRAM_MESSAGE:  
354 - send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle()));  
355 - break;  
356 -  
357 - case HLLAPI_PACKET_GET_SSL_STATE:  
358 - send_result(source,lib3270_get_secure(lib3270_get_default_session_handle()));  
359 - break;  
360 -  
361 - case HLLAPI_PACKET_SET_UNLOCK_DELAY:  
362 - lib3270_set_unlock_delay(lib3270_get_default_session_handle(),(unsigned short) ((struct hllapi_packet_set_int *) source->buffer)->value);  
363 - send_result(source,0);  
364 - break;  
365 -  
366 - case HLLAPI_PACKET_SET_TOGGLE:  
367 - send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(),  
368 - (LIB3270_TOGGLE) ((struct hllapi_packet_set *) source->buffer)->id,  
369 - ((struct hllapi_packet_set *) source->buffer)->value));  
370 - break;  
371 -  
372 - case HLLAPI_PACKET_FIELD_START:  
373 - send_result(source,lib3270_get_field_start(lib3270_get_default_session_handle(),  
374 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
375 - break;  
376 -  
377 -  
378 - case HLLAPI_PACKET_FIELD_LEN:  
379 - send_result(source,lib3270_get_field_len(lib3270_get_default_session_handle(),  
380 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
381 - break;  
382 -  
383 - case HLLAPI_PACKET_NEXT_UNPROTECTED:  
384 - send_result(source,lib3270_get_next_unprotected(lib3270_get_default_session_handle(),  
385 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
386 - break;  
387 -  
388 - case HLLAPI_PACKET_IS_PROTECTED:  
389 - send_result(source,lib3270_get_is_protected(lib3270_get_default_session_handle(),  
390 - ((struct hllapi_packet_addr *) source->buffer)->addr));  
391 - break;  
392 -  
393 - case HLLAPI_PACKET_IS_PROTECTED_AT:  
394 - send_result(source,lib3270_get_is_protected_at( lib3270_get_default_session_handle(),  
395 - ((struct hllapi_packet_query_at *) source->buffer)->row,  
396 - ((struct hllapi_packet_query_at *) source->buffer)->col));  
397 - break;  
398 -  
399 - case HLLAPI_PACKET_QUIT:  
400 - gtk_main_quit();  
401 - send_result(source,0);  
402 - break;  
403 -  
404 - case HLLAPI_PACKET_SET_HOST_CHARSET:  
405 - send_result(source,lib3270_set_host_charset( lib3270_get_default_session_handle(),  
406 - (const char *) ((struct hllapi_packet_set_text *) source->buffer)->text));  
407 - break;  
408 -  
409 - case HLLAPI_PACKET_ASC2EBC:  
410 - send_text(source,(char *) lib3270_asc2ebc(  
411 - lib3270_get_default_session_handle(),  
412 - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1  
413 - ));  
414 - break;  
415 -  
416 - case HLLAPI_PACKET_EBC2ASC:  
417 - send_text(source,(char *) lib3270_ebc2asc(  
418 - lib3270_get_default_session_handle(),  
419 - (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text,-1  
420 - ));  
421 - break;  
422 -  
423 - case HLLAPI_PACKET_FILE_TRANSFER:  
424 - send_result(source,do_file_transfer((struct hllapi_packet_file_transfer *) source));  
425 - break;  
426 -  
427 - case HLLAPI_PACKET_GET_HOST_CHARSET:  
428 - trace("%s","HLLAPI_PACKET_GET_HOST_CHARSET");  
429 - send_text(source,(char *) lib3270_get_host_charset(lib3270_get_default_session_handle()));  
430 - break;  
431 -  
432 - case HLLAPI_PACKET_ACTION:  
433 - send_result(source,lib3270_action(lib3270_get_default_session_handle(),  
434 - (const char *) ((struct hllapi_packet_text *) source->buffer)->text));  
435 - break;  
436 -  
437 -  
438 - default:  
439 - send_result(source, EINVAL);  
440 - g_message("Invalid remote request (id=%d)",source->buffer[0]);  
441 - }  
442 -  
443 - }  
444 -  
445 - static void read_input_pipe(pipe_source *source)  
446 - {  
447 - DWORD cbRead = 0;  
448 -  
449 - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)  
450 - process_input(source,cbRead);  
451 -  
452 - // The read operation is still pending.  
453 - switch(GetLastError())  
454 - {  
455 - case 0:  
456 - break;  
457 -  
458 - case ERROR_IO_PENDING:  
459 - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);  
460 - source->state = PIPE_STATE_PENDING_READ;  
461 - break;  
462 -  
463 - case ERROR_PIPE_LISTENING:  
464 - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);  
465 - source->state = PIPE_STATE_READ;  
466 - break;  
467 -  
468 - case ERROR_BROKEN_PIPE:  
469 - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);  
470 -  
471 - if(!DisconnectNamedPipe(source->hPipe))  
472 - {  
473 - set_active(FALSE);  
474 - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));  
475 - }  
476 - else  
477 - {  
478 - IO_accept(source);  
479 - }  
480 - break;  
481 -  
482 - case ERROR_PIPE_NOT_CONNECTED:  
483 - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);  
484 - set_active(FALSE);  
485 - break;  
486 -  
487 - default:  
488 - if(source->hPipe != INVALID_HANDLE_VALUE)  
489 - popup_lasterror("%s",_( "Error receiving message from pipe" ) );  
490 - }  
491 -  
492 - }  
493 -  
494 - static gboolean IO_dispatch(GSource *source, GSourceFunc G_GNUC_UNUSED(callback), gpointer G_GNUC_UNUSED(data))  
495 - {  
496 - /*  
497 - * Called to dispatch the event source,  
498 - * after it has returned TRUE in either its prepare or its check function.  
499 - * The dispatch function is passed in a callback function and data.  
500 - * The callback function may be NULL if the source was never connected  
501 - * to a callback using g_source_set_callback(). The dispatch function  
502 - * should call the callback function with user_data and whatever additional  
503 - * parameters are needed for this type of event source.  
504 - */  
505 - BOOL fSuccess;  
506 - DWORD cbRead = 0;  
507 -// DWORD dwErr = 0;  
508 -  
509 - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );  
510 -  
511 - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);  
512 -  
513 - switch(((pipe_source *) source)->state)  
514 - {  
515 - case PIPE_STATE_WAITING:  
516 - if(fSuccess)  
517 - {  
518 - trace("Pipe connected (cbRet=%d)",(int) cbRead);  
519 - set_active(TRUE);  
520 - ((pipe_source *) source)->state = PIPE_STATE_READ;  
521 - }  
522 - else  
523 - {  
524 - popup_lasterror("%s", _( "Pipe connection failed" ));  
525 - }  
526 - break;  
527 -  
528 - case PIPE_STATE_READ:  
529 - // trace("Reading pipe (cbRead=%d)",(int) cbRead);  
530 - read_input_pipe( (pipe_source *) source);  
531 - break;  
532 -  
533 - case PIPE_STATE_PENDING_READ:  
534 - if(fSuccess && cbRead > 0)  
535 - process_input((pipe_source *) source,cbRead);  
536 - ((pipe_source *) source)->state = PIPE_STATE_READ;  
537 - break;  
538 -  
539 - case PIPE_STATE_UNDEFINED:  
540 - break;  
541 -  
542 -//#ifdef DEBUG  
543 -// default:  
544 -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);  
545 -//#endif  
546 - }  
547 -  
548 - return TRUE;  
549 - }  
550 -  
551 - static void IO_finalize(GSource *source)  
552 - {  
553 -// trace("%s: source=%p",__FUNCTION__,source);  
554 -  
555 - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)  
556 - {  
557 - CloseHandle(((pipe_source *) source)->hPipe);  
558 - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;  
559 - }  
560 -  
561 - }  
562 -  
563 - static gboolean IO_closure(gpointer G_GNUC_UNUSED(data))  
564 - {  
565 - return 0;  
566 - }  
567 -  
568 - void popup_lasterror(const gchar *fmt, ...)  
569 - {  
570 - char buffer[4096];  
571 - va_list arg_ptr;  
572 - int sz;  
573 - DWORD errcode = GetLastError();  
574 - char *ptr;  
575 - LPVOID lpMsgBuf = 0;  
576 -  
577 - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);  
578 -  
579 - for(ptr= (char *) lpMsgBuf;*ptr && *ptr != '\n';ptr++);  
580 - *ptr = 0;  
581 -  
582 - va_start(arg_ptr, fmt);  
583 - vsnprintf(buffer,4095,fmt,arg_ptr);  
584 - va_end(arg_ptr);  
585 -  
586 - sz = strlen(buffer);  
587 - snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode);  
588 -  
589 - printf("%s\n",buffer);  
590 -  
591 -#ifdef DEBUG  
592 - fprintf(stderr,"%s\n",buffer);  
593 - fflush(stderr);  
594 -#endif  
595 -  
596 - LocalFree(lpMsgBuf);  
597 - }  
598 -  
599 - LIB3270_EXPORT int pw3270_plugin_start(GtkWidget G_GNUC_UNUSED(*window), GtkWidget *terminal)  
600 - {  
601 - char id;  
602 - const gchar * name = v3270_get_session_name(terminal);  
603 -  
604 - for(id='A';id < 'Z';id++)  
605 - {  
606 - g_autofree gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",name,id);  
607 - gchar * ptr;  
608 - HANDLE hPipe;  
609 -  
610 - for(ptr=pipename;*ptr;ptr++)  
611 - *ptr = g_ascii_tolower(*ptr);  
612 -  
613 - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name  
614 - PIPE_ACCESS_DUPLEX | // read/write access  
615 - FILE_FLAG_OVERLAPPED, // overlapped mode  
616 - PIPE_TYPE_MESSAGE | // pipe type  
617 - PIPE_READMODE_MESSAGE | // pipe mode  
618 - PIPE_WAIT, // blocking mode  
619 - 1, // number of instances  
620 - PIPE_BUFFER_LENGTH, // output buffer size  
621 - PIPE_BUFFER_LENGTH, // input buffer size  
622 - NMPWAIT_USE_DEFAULT_WAIT, // client time-out  
623 - NULL); // default security attributes  
624 -  
625 - trace("%s = %p",pipename,hPipe);  
626 -  
627 - if(hPipe != INVALID_HANDLE_VALUE)  
628 - {  
629 - static GSourceFuncs pipe_source_funcs =  
630 - {  
631 - IO_prepare,  
632 - IO_check,  
633 - IO_dispatch,  
634 - IO_finalize,  
635 - IO_closure,  
636 - NULL  
637 - };  
638 - g_autofree gchar * session = g_strdup_printf("%s:%c",name,id);  
639 - pipe_source * source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));  
640 -  
641 - source->hPipe = hPipe;  
642 - source->state = PIPE_STATE_WAITING;  
643 - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);  
644 -  
645 - g_source_attach((GSource *) source,NULL);  
646 - IO_accept(source);  
647 -  
648 - v3270_set_session_name(terminal,session);  
649 - g_message("Session %s attached to %s",session,pipename);  
650 -  
651 - return 0;  
652 - }  
653 -  
654 - }  
655 -  
656 - popup_lasterror( "%s", _( "Can´t create remote control pipe" ));  
657 -  
658 - return -1;  
659 - }  
660 -  
661 - LIB3270_EXPORT int pw3270_plugin_stop(GtkWidget G_GNUC_UNUSED(*window), GtkWidget G_GNUC_UNUSED(*terminal))  
662 - {  
663 -  
664 - return 0;  
665 - }  
666 -  
667 - G_GNUC_INTERNAL void set_active(gboolean on)  
668 - {  
669 - trace("%s(%s)",__FUNCTION__,on ? "Active" : "Inactive");  
670 - // v3270_set_script(v3270_get_default_widget(),'H');  
671 - }  
src/ipc3270c/windows/private.h
@@ -1,50 +0,0 @@ @@ -1,50 +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 -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 <config.h>  
31 - #define ENABLE_NLS  
32 - #define GETTEXT_PACKAGE PACKAGE_NAME  
33 -  
34 - #include <libintl.h>  
35 - #include <glib/gi18n.h>  
36 - #include <gtk/gtk.h>  
37 -  
38 - #include <lib3270.h>  
39 - #include <lib3270/log.h>  
40 - #include <pw3270.h>  
41 - #include <pw3270/hllapi.h>  
42 -  
43 - #include <windows.h>  
44 -  
45 - #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30  
46 -  
47 - G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...);  
48 - G_GNUC_INTERNAL void set_active(gboolean on);  
49 -  
50 -  
src/ipc3270c/windows/resources.rc.in
@@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
1 -#include <windows.h>  
2 -  
3 -VS_VERSION_INFO VERSIONINFO  
4 -FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
5 -PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,0  
6 -  
7 -BEGIN  
8 -  
9 - BLOCK "StringFileInfo"  
10 - BEGIN  
11 - BLOCK "080904E4"  
12 - BEGIN  
13 - VALUE "FileDescription", "IPC Compatibility Plugin for pw3270\0"  
14 - VALUE "CompanyName", "Banco do Brasil S/A.\0"  
15 - VALUE "FileVersion", "@WIN32_VERSION@\0"  
16 - VALUE "LegalCopyright", "(C) 2017 Banco do Brasil S/A. All Rights Reserved\0"  
17 - VALUE "OriginalFilename", "ipc3270@DLLEXT@\0"  
18 - VALUE "ProductName", "pw3270\0"  
19 - VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.0\0"  
20 - END  
21 - END  
22 -  
23 - BLOCK "VarFileInfo"  
24 - BEGIN  
25 - VALUE "Translation", 0x809, 0x04E4  
26 - END  
27 -  
28 -END  
29 -  
src/testprogram/hllapi.c 0 → 100644
@@ -0,0 +1,185 @@ @@ -0,0 +1,185 @@
  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 testprogram.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 <stdio.h>
  31 + #include <string.h>
  32 + #include <time.h>
  33 + #include <getopt.h>
  34 + #include <pw3270/hllapi.h>
  35 +
  36 + #if defined(DEBUG) && defined(_WIN32)
  37 + #undef trace
  38 + #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); } }
  39 + #endif // DEBUG
  40 +
  41 + #define MAX_DATA_SIZE 8000 //< Maximum data size for this application.
  42 +
  43 +// static CHAR hllapi_data[MAX_DATA_SIZE];
  44 +
  45 +/*---[ Implement ]--------------------------------------------------------------------------------*/
  46 +
  47 + /*
  48 + static void connect_ps(const char *session)
  49 + {
  50 + WORD len;
  51 + WORD fn = HLLAPI_CMD_CONNECTPS;
  52 + WORD rc = 0;
  53 +
  54 + strncpy(hllapi_data,session,MAX_DATA_SIZE);
  55 +
  56 + len = strlen(session);
  57 + hllapi(&fn,hllapi_data,&len,&rc);
  58 +
  59 + }
  60 + */
  61 +
  62 + int main(int argc, char **argv)
  63 + {
  64 + const char *host = NULL;
  65 + const char *session = "pw3270:A";
  66 +
  67 + #pragma GCC diagnostic push
  68 + static struct option options[] =
  69 + {
  70 + { "host", required_argument, 0, 'h' },
  71 + { "session-name", required_argument, 0, 'S' },
  72 + { 0, 0, 0, 0}
  73 + };
  74 + #pragma GCC diagnostic pop
  75 +
  76 + int long_index =0;
  77 + int opt;
  78 + while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1)
  79 + {
  80 +
  81 + switch(opt)
  82 + {
  83 + case 'h':
  84 + host = optarg;
  85 + break;
  86 +
  87 + case 'S':
  88 + session = optarg;
  89 + break;
  90 +
  91 + }
  92 +
  93 + }
  94 +
  95 + int rc = hllapi_init((char *) session);
  96 + if(rc)
  97 + {
  98 + printf("hllapi_init returns with rc=%d\n",rc);
  99 + return rc;
  100 + }
  101 +
  102 + printf("Library revision is %d\n",(int) hllapi_get_revision());
  103 +
  104 + if(host) {
  105 +
  106 + printf("connect=%d\n",(int) hllapi_connect((char *) host,1));
  107 + printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10));
  108 + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
  109 +
  110 + printf("disconnect=%d\n",(int) hllapi_disconnect());
  111 + }
  112 +
  113 + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
  114 +
  115 + rc = hllapi_deinit();
  116 + printf("hllapi_deinit exits with rc=%d\n",rc);
  117 +
  118 + return 0;
  119 + }
  120 +
  121 +/*
  122 + int main(int numpar, char *param[])
  123 + {
  124 + char buffer[BUFFER_LENGTH];
  125 + unsigned short rc;
  126 + unsigned short len;
  127 + unsigned long fn;
  128 +
  129 + static const struct _cmd
  130 + {
  131 + const char * name;
  132 + unsigned short fn;
  133 + const char * arg;
  134 + } cmd[] =
  135 + {
  136 + { "GetRevision", HLLAPI_CMD_GETREVISION, " " },
  137 + { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" },
  138 + { "InputString", HLLAPI_CMD_INPUTSTRING, "test" },
  139 +
  140 + };
  141 +
  142 + int f;
  143 +
  144 +
  145 + for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++)
  146 + {
  147 + len = strlen(cmd[f].arg);
  148 + memcpy(buffer,cmd[f].arg,len);
  149 + hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc);
  150 + printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer);
  151 + }
  152 +
  153 + len = 80;
  154 + rc = 1040;
  155 + fn = HLLAPI_CMD_COPYPSTOSTR;
  156 + hllapi((LPWORD) &fn,buffer,&len,&rc);
  157 + printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer);
  158 +
  159 + // Performance
  160 + len = strlen(cmd[0].arg);
  161 + memcpy(buffer,cmd[0].arg,len);
  162 + if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0)
  163 + {
  164 + time_t end = time(0) + 5;
  165 + int qtd = 0;
  166 + do
  167 + {
  168 + qtd++;
  169 + } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0)<end);
  170 + printf("%d interacoes em 5 segundos (rc=%d)\n",qtd,rc);
  171 +
  172 + }
  173 +
  174 + // Disconnect
  175 + len = 10;
  176 + rc = 1;
  177 + fn = HLLAPI_CMD_DISCONNECTPS;
  178 + *buffer = 0;
  179 + hllapi((LPWORD) &fn,buffer,&len,&rc);
  180 + printf("%s exits with rc=%d\n[%s]\n","HLLAPI_CMD_DISCONNECTPS",rc,buffer);
  181 +
  182 +
  183 + return 0;
  184 + }
  185 +*/
src/testprogram/ipc3270c.c 0 → 100644
@@ -0,0 +1,236 @@ @@ -0,0 +1,236 @@
  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. Registro no INPI sob
  5 + * o nome G3270.
  6 + *
  7 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  8 + *
  9 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  10 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  11 + * Free Software Foundation.
  12 + *
  13 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  14 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  15 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  16 + * obter mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  19 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  20 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  21 + *
  22 + * Este programa está nomeado como testprogram.c e possui - linhas de código.
  23 + *
  24 + * Contatos:
  25 + *
  26 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  27 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  28 + *
  29 + */
  30 +
  31 +
  32 + /**
  33 + * @brief Test program for pw3270 HLLAPI compatibility plugin.
  34 + *
  35 + */
  36 +
  37 + #include <config.h>
  38 + #include <v3270.h>
  39 + #include <v3270/trace.h>
  40 + #include <pw3270/plugin.h>
  41 + #include <string.h>
  42 + #include <stdlib.h>
  43 + #include <pw3270.h>
  44 +
  45 + /*---[ Globals ]------------------------------------------------------------------------------------*/
  46 +
  47 + const gchar * plugin_path = ".bin/Debug";
  48 + const gchar * session_name = "pw3270";
  49 + const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX;
  50 +
  51 + /*---[ Implement ]----------------------------------------------------------------------------------*/
  52 +
  53 + static void close_module(GtkWidget *widget, GModule *module)
  54 + {
  55 + g_message("Closing module %p",module);
  56 +
  57 + static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL;
  58 + if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop))
  59 + {
  60 + g_message("Can't get stop method from plugin: %s",g_module_error());
  61 + }
  62 + else
  63 + {
  64 + stop(gtk_widget_get_toplevel(widget),widget);
  65 + }
  66 +
  67 + g_module_close(module);
  68 + g_message("Module %p was closed",module);
  69 + }
  70 +
  71 + static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  72 + {
  73 + v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button));
  74 + }
  75 +
  76 + static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  77 + {
  78 + v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button));
  79 + }
  80 +
  81 + static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  82 + {
  83 + v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button));
  84 + }
  85 +
  86 + static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal)
  87 + {
  88 + v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button));
  89 + }
  90 +
  91 + static void toggle_started_trace(GtkToggleToolButton *button, GModule *module)
  92 + {
  93 + if(!module)
  94 + return;
  95 +
  96 + GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal"));
  97 +
  98 + const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop");
  99 +
  100 + static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL;
  101 + if(!g_module_symbol(module,method_name,(void **) &call))
  102 + {
  103 + g_message("Can't get method \"%s\": %s",method_name,g_module_error());
  104 + return;
  105 + }
  106 +
  107 + g_message("Calling %s",method_name);
  108 + call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal));
  109 +
  110 + }
  111 +
  112 + static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback)
  113 + {
  114 + GtkToolItem * item = gtk_toggle_tool_button_new();
  115 + gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label);
  116 +
  117 + g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal);
  118 +
  119 + if(tooltip)
  120 + gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip);
  121 +
  122 + return item;
  123 + }
  124 +
  125 + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
  126 +
  127 + GtkWidget * window = gtk_application_window_new(app);
  128 + GtkWidget * terminal = v3270_new();
  129 + GtkWidget * notebook = gtk_notebook_new();
  130 + GModule * module = NULL;
  131 +
  132 + gtk_widget_set_name(window,session_name);
  133 + v3270_set_session_name(terminal, session_name);
  134 +
  135 + // Setup tabs
  136 + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal)));
  137 +
  138 + // Load plugin
  139 + {
  140 + g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL);
  141 +
  142 + g_message("Loading %s",plugin);
  143 +
  144 + module = g_module_open(plugin,G_MODULE_BIND_LOCAL);
  145 +
  146 + if(module)
  147 + {
  148 + g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module);
  149 + }
  150 + else
  151 + {
  152 + g_message("Can't open \"%s\": %s",plugin,g_module_error());
  153 + gtk_main_quit();
  154 + }
  155 +
  156 + }
  157 + // Create trace window
  158 + {
  159 + GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  160 + GtkWidget * trace = v3270_trace_new(terminal);
  161 + GtkWidget * toolbar = gtk_toolbar_new();
  162 + GtkToolItem * start = gtk_toggle_tool_button_new();
  163 +
  164 + gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL);
  165 +
  166 + g_object_set_data(G_OBJECT(start),"terminal",terminal);
  167 +
  168 + gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable");
  169 + g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module);
  170 + gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module");
  171 +
  172 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1);
  173 +
  174 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1);
  175 +
  176 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1);
  177 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1);
  178 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1);
  179 + gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1);
  180 +
  181 + gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0);
  182 + gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0);
  183 + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace"));
  184 + }
  185 +
  186 + // Setup and show main window
  187 + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
  188 + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);
  189 + gtk_container_add(GTK_CONTAINER(window),notebook);
  190 + gtk_widget_show_all (window);
  191 +
  192 + // Setup title.
  193 + const gchar *url = lib3270_get_url(v3270_get_session(terminal));
  194 + if(url) {
  195 +
  196 + v3270_set_url(terminal,url);
  197 + v3270_reconnect(terminal);
  198 +
  199 + gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url);
  200 + gtk_window_set_title(GTK_WINDOW(window), title);
  201 + g_free(title);
  202 +
  203 + } else {
  204 +
  205 + gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal));
  206 +
  207 + }
  208 +
  209 +}
  210 +
  211 +int main (int argc, char **argv) {
  212 +
  213 + static const GOptionEntry app_options[] = {
  214 + { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL },
  215 + { "session-name", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" },
  216 + { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX },
  217 +
  218 + { NULL }
  219 + };
  220 +
  221 + GtkApplication *app;
  222 + int status;
  223 +
  224 + app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE);
  225 +
  226 + g_application_add_main_option_entries(G_APPLICATION(app),app_options);
  227 + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);
  228 +
  229 + status = g_application_run (G_APPLICATION (app), argc, argv);
  230 + g_object_unref (app);
  231 +
  232 + g_message("rc=%d",status);
  233 + return status;
  234 +
  235 +}
  236 +
src/testprogram/linux/test.sh 0 → 100755
@@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
  1 +#!/bin/bash
  2 +
  3 +SESSION=a
  4 +DEST=br.com.bb.pw3270
  5 +BPATH=/br/com/bb/pw3270
  6 +
  7 +run_command()
  8 +{
  9 +
  10 + case $1 in
  11 +
  12 + revision)
  13 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision
  14 + ;;
  15 +
  16 + message)
  17 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID
  18 + ;;
  19 +
  20 + ssl)
  21 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState
  22 + ;;
  23 +
  24 + connect)
  25 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10
  26 + ;;
  27 +
  28 + disconnect)
  29 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect
  30 + ;;
  31 +
  32 + url)
  33 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL
  34 + ;;
  35 +
  36 + quit)
  37 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit
  38 + ;;
  39 +
  40 + get)
  41 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents
  42 + ;;
  43 +
  44 + gettext)
  45 +# addr,len,lf
  46 +# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0
  47 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10
  48 + ;;
  49 +
  50 + protect)
  51 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3
  52 + ;;
  53 +
  54 + set)
  55 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4
  56 + ;;
  57 +
  58 + action)
  59 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2
  60 + ;;
  61 +
  62 + enter)
  63 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter
  64 + ;;
  65 +
  66 + isconnected)
  67 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected
  68 + ;;
  69 +
  70 + hostcharset)
  71 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset
  72 + ;;
  73 +
  74 + displaycharset)
  75 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset
  76 + ;;
  77 +
  78 + unlockdelay)
  79 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2
  80 + ;;
  81 +
  82 + *)
  83 + echo "Comando $1 desconhecido"
  84 + ;;
  85 +
  86 + esac
  87 +}
  88 +
  89 +
  90 +
  91 +until [ -z "$1" ]
  92 +do
  93 + if [ ${1:0:2} = '--' ]; then
  94 + tmp=${1:2}
  95 + parameter=${tmp%%=*}
  96 + parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]")
  97 + value=${tmp##*=}
  98 +
  99 + case "$parameter" in
  100 + SESSION)
  101 + SESSION=$value
  102 + ;;
  103 + HELP)
  104 + echo "$0 options"
  105 + echo ""
  106 + echo "Options:"
  107 + echo ""
  108 + echo " --session pw3270's session manager"
  109 + echo ""
  110 + exit 0
  111 + ;;
  112 +
  113 + *)
  114 + eval $parameter=$value
  115 + ;;
  116 +
  117 + esac
  118 +
  119 + else
  120 + run_command $@
  121 + exit 0
  122 + fi
  123 +
  124 + shift
  125 +done
  126 +
src/testprograms/hllapi.c
@@ -1,185 +0,0 @@ @@ -1,185 +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 testprogram.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 <stdio.h>  
31 - #include <string.h>  
32 - #include <time.h>  
33 - #include <getopt.h>  
34 - #include <pw3270/hllapi.h>  
35 -  
36 - #if defined(DEBUG) && defined(_WIN32)  
37 - #undef trace  
38 - #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); } }  
39 - #endif // DEBUG  
40 -  
41 - #define MAX_DATA_SIZE 8000 //< Maximum data size for this application.  
42 -  
43 -// static CHAR hllapi_data[MAX_DATA_SIZE];  
44 -  
45 -/*---[ Implement ]--------------------------------------------------------------------------------*/  
46 -  
47 - /*  
48 - static void connect_ps(const char *session)  
49 - {  
50 - WORD len;  
51 - WORD fn = HLLAPI_CMD_CONNECTPS;  
52 - WORD rc = 0;  
53 -  
54 - strncpy(hllapi_data,session,MAX_DATA_SIZE);  
55 -  
56 - len = strlen(session);  
57 - hllapi(&fn,hllapi_data,&len,&rc);  
58 -  
59 - }  
60 - */  
61 -  
62 - int main(int argc, char **argv)  
63 - {  
64 - const char *host = NULL;  
65 - const char *session = "pw3270:A";  
66 -  
67 - #pragma GCC diagnostic push  
68 - static struct option options[] =  
69 - {  
70 - { "host", required_argument, 0, 'h' },  
71 - { "session-name", required_argument, 0, 'S' },  
72 - { 0, 0, 0, 0}  
73 - };  
74 - #pragma GCC diagnostic pop  
75 -  
76 - int long_index =0;  
77 - int opt;  
78 - while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1)  
79 - {  
80 -  
81 - switch(opt)  
82 - {  
83 - case 'h':  
84 - host = optarg;  
85 - break;  
86 -  
87 - case 'S':  
88 - session = optarg;  
89 - break;  
90 -  
91 - }  
92 -  
93 - }  
94 -  
95 - int rc = hllapi_init((char *) session);  
96 - if(rc)  
97 - {  
98 - printf("hllapi_init returns with rc=%d\n",rc);  
99 - return rc;  
100 - }  
101 -  
102 - printf("Library revision is %d\n",(int) hllapi_get_revision());  
103 -  
104 - if(host) {  
105 -  
106 - printf("connect=%d\n",(int) hllapi_connect((char *) host,1));  
107 - printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10));  
108 - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");  
109 -  
110 - printf("disconnect=%d\n",(int) hllapi_disconnect());  
111 - }  
112 -  
113 - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");  
114 -  
115 - rc = hllapi_deinit();  
116 - printf("hllapi_deinit exits with rc=%d\n",rc);  
117 -  
118 - return 0;  
119 - }  
120 -  
121 -/*  
122 - int main(int numpar, char *param[])  
123 - {  
124 - char buffer[BUFFER_LENGTH];  
125 - unsigned short rc;  
126 - unsigned short len;  
127 - unsigned long fn;  
128 -  
129 - static const struct _cmd  
130 - {  
131 - const char * name;  
132 - unsigned short fn;  
133 - const char * arg;  
134 - } cmd[] =  
135 - {  
136 - { "GetRevision", HLLAPI_CMD_GETREVISION, " " },  
137 - { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" },  
138 - { "InputString", HLLAPI_CMD_INPUTSTRING, "test" },  
139 -  
140 - };  
141 -  
142 - int f;  
143 -  
144 -  
145 - for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++)  
146 - {  
147 - len = strlen(cmd[f].arg);  
148 - memcpy(buffer,cmd[f].arg,len);  
149 - hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc);  
150 - printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer);  
151 - }  
152 -  
153 - len = 80;  
154 - rc = 1040;  
155 - fn = HLLAPI_CMD_COPYPSTOSTR;  
156 - hllapi((LPWORD) &fn,buffer,&len,&rc);  
157 - printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer);  
158 -  
159 - // Performance  
160 - len = strlen(cmd[0].arg);  
161 - memcpy(buffer,cmd[0].arg,len);  
162 - if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0)  
163 - {  
164 - time_t end = time(0) + 5;  
165 - int qtd = 0;  
166 - do  
167 - {  
168 - qtd++;  
169 - } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0)<end);  
170 - printf("%d interacoes em 5 segundos (rc=%d)\n",qtd,rc);  
171 -  
172 - }  
173 -  
174 - // Disconnect  
175 - len = 10;  
176 - rc = 1;  
177 - fn = HLLAPI_CMD_DISCONNECTPS;  
178 - *buffer = 0;  
179 - hllapi((LPWORD) &fn,buffer,&len,&rc);  
180 - printf("%s exits with rc=%d\n[%s]\n","HLLAPI_CMD_DISCONNECTPS",rc,buffer);  
181 -  
182 -  
183 - return 0;  
184 - }  
185 -*/  
src/testprograms/ipc3270c.c
@@ -1,236 +0,0 @@ @@ -1,236 +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. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes.  
17 - *  
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
21 - *  
22 - * Este programa está nomeado como testprogram.c e possui - linhas de código.  
23 - *  
24 - * Contatos:  
25 - *  
26 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
27 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
28 - *  
29 - */  
30 -  
31 -  
32 - /**  
33 - * @brief Test program for pw3270 HLLAPI compatibility plugin.  
34 - *  
35 - */  
36 -  
37 - #include <config.h>  
38 - #include <v3270.h>  
39 - #include <v3270/trace.h>  
40 - #include <pw3270/plugin.h>  
41 - #include <string.h>  
42 - #include <stdlib.h>  
43 - #include <pw3270.h>  
44 -  
45 - /*---[ Globals ]------------------------------------------------------------------------------------*/  
46 -  
47 - const gchar * plugin_path = ".bin/Debug";  
48 - const gchar * session_name = "pw3270";  
49 - const gchar * plugin_name = "ipc3270c." G_MODULE_SUFFIX;  
50 -  
51 - /*---[ Implement ]----------------------------------------------------------------------------------*/  
52 -  
53 - static void close_module(GtkWidget *widget, GModule *module)  
54 - {  
55 - g_message("Closing module %p",module);  
56 -  
57 - static void (*stop)(GtkWidget *window, GtkWidget *terminal) = NULL;  
58 - if(!g_module_symbol(module,"pw3270_plugin_stop",(void **) &stop))  
59 - {  
60 - g_message("Can't get stop method from plugin: %s",g_module_error());  
61 - }  
62 - else  
63 - {  
64 - stop(gtk_widget_get_toplevel(widget),widget);  
65 - }  
66 -  
67 - g_module_close(module);  
68 - g_message("Module %p was closed",module);  
69 - }  
70 -  
71 - static void toggle_ds_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
72 - {  
73 - v3270_set_toggle(terminal,LIB3270_TOGGLE_DS_TRACE,gtk_toggle_tool_button_get_active(button));  
74 - }  
75 -  
76 - static void toggle_event_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
77 - {  
78 - v3270_set_toggle(terminal,LIB3270_TOGGLE_EVENT_TRACE,gtk_toggle_tool_button_get_active(button));  
79 - }  
80 -  
81 - static void toggle_ssl_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
82 - {  
83 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SSL_TRACE,gtk_toggle_tool_button_get_active(button));  
84 - }  
85 -  
86 - static void toggle_screen_trace(GtkToggleToolButton *button, GtkWidget *terminal)  
87 - {  
88 - v3270_set_toggle(terminal,LIB3270_TOGGLE_SCREEN_TRACE,gtk_toggle_tool_button_get_active(button));  
89 - }  
90 -  
91 - static void toggle_started_trace(GtkToggleToolButton *button, GModule *module)  
92 - {  
93 - if(!module)  
94 - return;  
95 -  
96 - GtkWidget * terminal = GTK_WIDGET(g_object_get_data(G_OBJECT(button),"terminal"));  
97 -  
98 - const gchar * method_name = (gtk_toggle_tool_button_get_active(button) ? "pw3270_plugin_start" : "pw3270_plugin_stop");  
99 -  
100 - static void (*call)(GtkWidget *window, GtkWidget *terminal) = NULL;  
101 - if(!g_module_symbol(module,method_name,(void **) &call))  
102 - {  
103 - g_message("Can't get method \"%s\": %s",method_name,g_module_error());  
104 - return;  
105 - }  
106 -  
107 - g_message("Calling %s",method_name);  
108 - call(gtk_widget_get_toplevel(terminal), GTK_WIDGET(terminal));  
109 -  
110 - }  
111 -  
112 - static GtkToolItem * create_tool_item(GtkWidget *terminal, const gchar *label, const gchar *tooltip, GCallback callback)  
113 - {  
114 - GtkToolItem * item = gtk_toggle_tool_button_new();  
115 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(item),label);  
116 -  
117 - g_signal_connect(GTK_WIDGET(item), "toggled", G_CALLBACK(callback), terminal);  
118 -  
119 - if(tooltip)  
120 - gtk_widget_set_tooltip_text(GTK_WIDGET(item),tooltip);  
121 -  
122 - return item;  
123 - }  
124 -  
125 - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {  
126 -  
127 - GtkWidget * window = gtk_application_window_new(app);  
128 - GtkWidget * terminal = v3270_new();  
129 - GtkWidget * notebook = gtk_notebook_new();  
130 - GModule * module = NULL;  
131 -  
132 - gtk_widget_set_name(window,session_name);  
133 - v3270_set_session_name(terminal, session_name);  
134 -  
135 - // Setup tabs  
136 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new(v3270_get_session_name(terminal)));  
137 -  
138 - // Load plugin  
139 - {  
140 - g_autofree gchar * plugin = g_build_filename(plugin_path,plugin_name,NULL);  
141 -  
142 - g_message("Loading %s",plugin);  
143 -  
144 - module = g_module_open(plugin,G_MODULE_BIND_LOCAL);  
145 -  
146 - if(module)  
147 - {  
148 - g_signal_connect (terminal, "destroy", G_CALLBACK(close_module), module);  
149 - }  
150 - else  
151 - {  
152 - g_message("Can't open \"%s\": %s",plugin,g_module_error());  
153 - gtk_main_quit();  
154 - }  
155 -  
156 - }  
157 - // Create trace window  
158 - {  
159 - GtkWidget * box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);  
160 - GtkWidget * trace = v3270_trace_new(terminal);  
161 - GtkWidget * toolbar = gtk_toolbar_new();  
162 - GtkToolItem * start = gtk_toggle_tool_button_new();  
163 -  
164 - gtk_widget_set_sensitive(GTK_WIDGET(start),module != NULL);  
165 -  
166 - g_object_set_data(G_OBJECT(start),"terminal",terminal);  
167 -  
168 - gtk_tool_button_set_label(GTK_TOOL_BUTTON(start),"Enable");  
169 - g_signal_connect(GTK_WIDGET(start), "toggled", G_CALLBACK(toggle_started_trace), module);  
170 - gtk_widget_set_tooltip_text(GTK_WIDGET(start),"Start/Stop plugin module");  
171 -  
172 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), start, -1);  
173 -  
174 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),gtk_separator_tool_item_new(),-1);  
175 -  
176 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "DS Trace","Toggle DS Trace",G_CALLBACK(toggle_ds_trace)),-1);  
177 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Event Trace","Toggle Event Trace",G_CALLBACK(toggle_event_trace)),-1);  
178 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "Screen Trace","Toggle Screen Trace",G_CALLBACK(toggle_screen_trace)),-1);  
179 - gtk_toolbar_insert(GTK_TOOLBAR(toolbar),create_tool_item(terminal, "SSL Trace","Toggle SSL Trace",G_CALLBACK(toggle_ssl_trace)),-1);  
180 -  
181 - gtk_box_pack_start(GTK_BOX(box),toolbar,FALSE,FALSE,0);  
182 - gtk_box_pack_start(GTK_BOX(box),trace,TRUE,TRUE,0);  
183 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),box,gtk_label_new("Trace"));  
184 - }  
185 -  
186 - // Setup and show main window  
187 - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);  
188 - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);  
189 - gtk_container_add(GTK_CONTAINER(window),notebook);  
190 - gtk_widget_show_all (window);  
191 -  
192 - // Setup title.  
193 - const gchar *url = lib3270_get_url(v3270_get_session(terminal));  
194 - if(url) {  
195 -  
196 - v3270_set_url(terminal,url);  
197 - v3270_reconnect(terminal);  
198 -  
199 - gchar * title = g_strdup_printf("%s - %s", v3270_get_session_name(terminal), url);  
200 - gtk_window_set_title(GTK_WINDOW(window), title);  
201 - g_free(title);  
202 -  
203 - } else {  
204 -  
205 - gtk_window_set_title(GTK_WINDOW(window), v3270_get_session_name(terminal));  
206 -  
207 - }  
208 -  
209 -}  
210 -  
211 -int main (int argc, char **argv) {  
212 -  
213 - static const GOptionEntry app_options[] = {  
214 - { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL },  
215 - { "session-name", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" },  
216 - { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX },  
217 -  
218 - { NULL }  
219 - };  
220 -  
221 - GtkApplication *app;  
222 - int status;  
223 -  
224 - app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE);  
225 -  
226 - g_application_add_main_option_entries(G_APPLICATION(app),app_options);  
227 - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);  
228 -  
229 - status = g_application_run (G_APPLICATION (app), argc, argv);  
230 - g_object_unref (app);  
231 -  
232 - g_message("rc=%d",status);  
233 - return status;  
234 -  
235 -}  
236 -  
src/testprograms/linux/test.sh
@@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
1 -#!/bin/bash  
2 -  
3 -SESSION=a  
4 -DEST=br.com.bb.pw3270  
5 -BPATH=/br/com/bb/pw3270  
6 -  
7 -run_command()  
8 -{  
9 -  
10 - case $1 in  
11 -  
12 - revision)  
13 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getRevision  
14 - ;;  
15 -  
16 - message)  
17 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getMessageID  
18 - ;;  
19 -  
20 - ssl)  
21 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getSecureState  
22 - ;;  
23 -  
24 - connect)  
25 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.connect string:$2 int32:10  
26 - ;;  
27 -  
28 - disconnect)  
29 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.disconnect  
30 - ;;  
31 -  
32 - url)  
33 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getURL  
34 - ;;  
35 -  
36 - quit)  
37 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.quit  
38 - ;;  
39 -  
40 - get)  
41 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getScreenContents  
42 - ;;  
43 -  
44 - gettext)  
45 -# addr,len,lf  
46 -# dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:0  
47 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getText int32:1 int32:-1 byte:10  
48 - ;;  
49 -  
50 - protect)  
51 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getIsProtectedAt int32:$2 int32:$3  
52 - ;;  
53 -  
54 - set)  
55 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setTextAt int32:$2 int32:$3 string:$4  
56 - ;;  
57 -  
58 - action)  
59 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.action string:$2  
60 - ;;  
61 -  
62 - enter)  
63 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.enter  
64 - ;;  
65 -  
66 - isconnected)  
67 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected  
68 - ;;  
69 -  
70 - hostcharset)  
71 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset  
72 - ;;  
73 -  
74 - displaycharset)  
75 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset  
76 - ;;  
77 -  
78 - unlockdelay)  
79 - dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.setUnlockDelay int32:$2  
80 - ;;  
81 -  
82 - *)  
83 - echo "Comando $1 desconhecido"  
84 - ;;  
85 -  
86 - esac  
87 -}  
88 -  
89 -  
90 -  
91 -until [ -z "$1" ]  
92 -do  
93 - if [ ${1:0:2} = '--' ]; then  
94 - tmp=${1:2}  
95 - parameter=${tmp%%=*}  
96 - parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]")  
97 - value=${tmp##*=}  
98 -  
99 - case "$parameter" in  
100 - SESSION)  
101 - SESSION=$value  
102 - ;;  
103 - HELP)  
104 - echo "$0 options"  
105 - echo ""  
106 - echo "Options:"  
107 - echo ""  
108 - echo " --session pw3270's session manager"  
109 - echo ""  
110 - exit 0  
111 - ;;  
112 -  
113 - *)  
114 - eval $parameter=$value  
115 - ;;  
116 -  
117 - esac  
118 -  
119 - else  
120 - run_command $@  
121 - exit 0  
122 - fi  
123 -  
124 - shift  
125 -done  
126 -