Commit 1e2ce022add512cb4e261c68fc66853e96207ea6
1 parent
217e703b
Exists in
master
and in
1 other branch
Reorganizing client library sources.
Showing
40 changed files
with
3117 additions
and
3107 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,71 @@ |
| 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="C++ Bindings for lib3270" /> | |
| 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/lib3270++" 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 | + <Add option="-DDEBUG=1" /> | |
| 18 | + </Compiler> | |
| 19 | + </Target> | |
| 20 | + <Target title="Release"> | |
| 21 | + <Option output=".bin/Release/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" /> | |
| 22 | + <Option object_output=".obj/Release/" /> | |
| 23 | + <Option type="1" /> | |
| 24 | + <Option compiler="gcc" /> | |
| 25 | + <Compiler> | |
| 26 | + <Add option="-O2" /> | |
| 27 | + <Add option="-std=c++11" /> | |
| 28 | + <Add option="-DNDEBUG=1" /> | |
| 29 | + </Compiler> | |
| 30 | + <Linker> | |
| 31 | + <Add option="-s" /> | |
| 32 | + </Linker> | |
| 33 | + </Target> | |
| 34 | + </Build> | |
| 35 | + <Compiler> | |
| 36 | + <Add option="-Wall" /> | |
| 37 | + <Add option="`pkg-config --clags lib3270`" /> | |
| 38 | + <Add directory="../include" /> | |
| 39 | + </Compiler> | |
| 40 | + <Linker> | |
| 41 | + <Add option="`pkg-config --libs lib3270`" /> | |
| 42 | + </Linker> | |
| 43 | + <Unit filename="../include/config.h.in" /> | |
| 44 | + <Unit filename="../include/lib3270++.h" /> | |
| 45 | + <Unit filename="../include/lib3270.h" /> | |
| 46 | + <Unit filename="../include/lib3270/action_table.h" /> | |
| 47 | + <Unit filename="../include/lib3270/actions.h" /> | |
| 48 | + <Unit filename="../include/lib3270/popup.h" /> | |
| 49 | + <Unit filename="../include/lib3270/session.h" /> | |
| 50 | + <Unit filename="private.h" /> | |
| 51 | + <Unit filename="src/core/abstract.cc" /> | |
| 52 | + <Unit filename="src/core/events.cc" /> | |
| 53 | + <Unit filename="src/core/host.cc" /> | |
| 54 | + <Unit filename="src/core/linux/request.cc" /> | |
| 55 | + <Unit filename="src/core/session.cc" /> | |
| 56 | + <Unit filename="src/os/linux/request.cc" /> | |
| 57 | + <Unit filename="src/os/linux/session.cc" /> | |
| 58 | + <Unit filename="src/os/windows/request.cc" /> | |
| 59 | + <Unit filename="src/os/windows/session.cc" /> | |
| 60 | + <Unit filename="src/session/local/events.cc" /> | |
| 61 | + <Unit filename="src/session/local/session.cc" /> | |
| 62 | + <Unit filename="src/session/remote/session.cc" /> | |
| 63 | + <Unit filename="src/testprogram/testprogram.cc" /> | |
| 64 | + <Extensions> | |
| 65 | + <code_completion /> | |
| 66 | + <envvars /> | |
| 67 | + <debugger /> | |
| 68 | + <lib_finder disable_auto="1" /> | |
| 69 | + </Extensions> | |
| 70 | + </Project> | |
| 71 | +</CodeBlocks_project_file> | ... | ... |
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +prefix=@prefix@ | |
| 2 | +exec_prefix=@exec_prefix@ | |
| 3 | +libdir=@libdir@ | |
| 4 | +includedir=@includedir@ | |
| 5 | + | |
| 6 | +version_major=@PACKAGE_MAJOR_VERSION@ | |
| 7 | +version_minor=@PACKAGE_MINOR_VERSION@ | |
| 8 | +sdk_version=@LIB3270_SDK_VERSION@ | |
| 9 | + | |
| 10 | +Name: @PACKAGE_NAME@ | |
| 11 | +Description: @PACKAGE_DESCRIPTION@ | |
| 12 | +Version: @PACKAGE_VERSION@ | |
| 13 | +Libs: -L\@libdir@ -l3270++ | |
| 14 | +Libs.private: @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ -l@LIB3270_NAME@ | |
| 15 | +Cflags: -I@includedir@ | |
| 16 | + | ... | ... |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +prefix=@prefix@ | |
| 2 | +exec_prefix=@exec_prefix@ | |
| 3 | +libdir=@libdir@ | |
| 4 | +includedir=@includedir@ | |
| 5 | + | |
| 6 | +version_major=@PACKAGE_MAJOR_VERSION@ | |
| 7 | +version_minor=@PACKAGE_MINOR_VERSION@ | |
| 8 | +sdk_version=@LIB3270_SDK_VERSION@ | |
| 9 | + | |
| 10 | +Name: @PACKAGE_NAME@ | |
| 11 | +Description: @PACKAGE_DESCRIPTION@ | |
| 12 | +Version: @PACKAGE_VERSION@ | |
| 13 | +Libs: -L\@libdir@ -l@LIB3270_NAME@++static @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ | |
| 14 | +Cflags: -I@includedir@ | |
| 15 | + | ... | ... |
| ... | ... | @@ -0,0 +1,391 @@ |
| 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 | +#---[ Library configuration ]------------------------------------------------------------ | |
| 28 | + | |
| 29 | +LIBNAME=lib@LIB3270_NAME@++ | |
| 30 | + | |
| 31 | +SOURCES= \ | |
| 32 | + $(wildcard *.cc) \ | |
| 33 | + $(wildcard local/*.cc) \ | |
| 34 | + $(wildcard ipc/*.cc) \ | |
| 35 | + $(wildcard @OSNAME@/*.cc) \ | |
| 36 | + $(wildcard @OSNAME@/*.rc) | |
| 37 | + | |
| 38 | +TEST_SOURCES= \ | |
| 39 | + $(wildcard testprogram/*.cc) | |
| 40 | + | |
| 41 | +#---[ Tools ]---------------------------------------------------------------------------- | |
| 42 | + | |
| 43 | +CXX=@CXX@ | |
| 44 | +HOST_CC=@HOST_CC@ | |
| 45 | +LD=@CXX@ | |
| 46 | +LN_S=@LN_S@ | |
| 47 | +MKDIR=@MKDIR_P@ | |
| 48 | +INSTALL=@INSTALL@ | |
| 49 | +INSTALL_DATA=@INSTALL_DATA@ | |
| 50 | +INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
| 51 | +XGETTEXT=@XGETTEXT@ | |
| 52 | +MSGCAT=@MSGCAT@ | |
| 53 | +WINDRES=@WINDRES@ | |
| 54 | +AR=@AR@ | |
| 55 | +VALGRIND=@VALGRIND@ | |
| 56 | + | |
| 57 | +#---[ Paths ]---------------------------------------------------------------------------- | |
| 58 | + | |
| 59 | +prefix=@prefix@ | |
| 60 | +exec_prefix=@exec_prefix@ | |
| 61 | +bindir=@bindir@ | |
| 62 | +sbindir=@sbindir@ | |
| 63 | +libdir=@libdir@ | |
| 64 | +includedir=@includedir@ | |
| 65 | +datarootdir=@datarootdir@ | |
| 66 | +localedir=@localedir@ | |
| 67 | +docdir=@docdir@ | |
| 68 | +sysconfdir=@sysconfdir@ | |
| 69 | + | |
| 70 | +BASEDIR=@BASEDIR@ | |
| 71 | + | |
| 72 | +POTDIR=$(BASEDIR)/.pot | |
| 73 | + | |
| 74 | +OBJDIR=$(BASEDIR)/.obj/$(LIBNAME) | |
| 75 | +OBJDBG=$(OBJDIR)/Debug | |
| 76 | +OBJRLS=$(OBJDIR)/Release | |
| 77 | + | |
| 78 | +BINDIR=$(BASEDIR)/.bin | |
| 79 | +BINDBG=$(BINDIR)/Debug | |
| 80 | +BINRLS=$(BINDIR)/Release | |
| 81 | + | |
| 82 | +#---[ Rules ]---------------------------------------------------------------------------- | |
| 83 | + | |
| 84 | +DEPENDS= \ | |
| 85 | + Makefile \ | |
| 86 | + ../include/*.h \ | |
| 87 | + ../include/lib3270/*.h \ | |
| 88 | + ../lib3270/*.h | |
| 89 | + | |
| 90 | + | |
| 91 | +CFLAGS= \ | |
| 92 | + @CFLAGS@ \ | |
| 93 | + @CPPFLAGS@ \ | |
| 94 | + -g \ | |
| 95 | + -I../include \ | |
| 96 | + -DBUILD_DATE=`date +%Y%m%d` \ | |
| 97 | + @DBUS_CFLAGS@ | |
| 98 | + | |
| 99 | +LIBS= \ | |
| 100 | + @LIBS@ \ | |
| 101 | + @LIBSSL_LIBS@ \ | |
| 102 | + @LIBICONV@ \ | |
| 103 | + @INTL_LIBS@ \ | |
| 104 | + @DBUS_LIBS@ | |
| 105 | + | |
| 106 | + | |
| 107 | +#---[ Debug Rules ]---------------------------------------------------------------------- | |
| 108 | + | |
| 109 | +$(OBJDBG)/%.o: \ | |
| 110 | + %.cc \ | |
| 111 | + $(DEPENDS) | |
| 112 | + | |
| 113 | + @echo $< ... | |
| 114 | + @$(MKDIR) `dirname $@` | |
| 115 | + @$(CXX) \ | |
| 116 | + $(CFLAGS) \ | |
| 117 | + -Wall -Wextra -fstack-check \ | |
| 118 | + -DDEBUG=1 \ | |
| 119 | + -o $@ -c $< | |
| 120 | + | |
| 121 | +$(OBJDBG)/%.o: \ | |
| 122 | + %.rc | |
| 123 | + | |
| 124 | + @echo $< ... | |
| 125 | + @$(MKDIR) `dirname $@` | |
| 126 | + @$(WINDRES) $< -O coff -o $@ | |
| 127 | + | |
| 128 | +#---[ Release Rules ]-------------------------------------------------------------------- | |
| 129 | + | |
| 130 | +$(OBJRLS)/%.o: \ | |
| 131 | + %.cc \ | |
| 132 | + $(DEPENDS) | |
| 133 | + | |
| 134 | + @echo $< ... | |
| 135 | + @$(MKDIR) `dirname $@` | |
| 136 | + @$(CXX) \ | |
| 137 | + $(CFLAGS) \ | |
| 138 | + -DNDEBUG=1 \ | |
| 139 | + -o $@ -c $< | |
| 140 | + | |
| 141 | +$(OBJRLS)/%.o: \ | |
| 142 | + %.rc | |
| 143 | + | |
| 144 | + @echo $< ... | |
| 145 | + @$(MKDIR) `dirname $@` | |
| 146 | + @$(WINDRES) $< -O coff -o $@ | |
| 147 | + | |
| 148 | +#---[ Misc Rules ]----------------------------------------------------------------------- | |
| 149 | + | |
| 150 | +$(POTDIR)/$(LIBNAME)/%.pot: \ | |
| 151 | + %.cc | |
| 152 | + | |
| 153 | + @echo $(notdir $@) ... | |
| 154 | + @$(MKDIR) `dirname $@` | |
| 155 | + @$(XGETTEXT) \ | |
| 156 | + --language=C \ | |
| 157 | + --keyword=_ \ | |
| 158 | + --keyword=N_ \ | |
| 159 | + --keyword=MSG_:2 \ | |
| 160 | + --output=$@ \ | |
| 161 | + $< | |
| 162 | + @touch $@ | |
| 163 | + | |
| 164 | +$(POTDIR)/$(LIBNAME)/%.pot: \ | |
| 165 | + %.rc | |
| 166 | + | |
| 167 | + @echo $< ... | |
| 168 | + @$(MKDIR) `dirname $@` | |
| 169 | + @touch $@ | |
| 170 | + | |
| 171 | +#---[ Release Targets ]------------------------------------------------------------------ | |
| 172 | + | |
| 173 | +all: \ | |
| 174 | + $(BINRLS)/$(LIBNAME)@DLLEXT@ \ | |
| 175 | + $(BINRLS)/static/$(LIBNAME).a \ | |
| 176 | + $(POTDIR)/$(LIBNAME).pot | |
| 177 | + | |
| 178 | + | |
| 179 | +Release: \ | |
| 180 | + $(BINRLS)/$(LIBNAME)@DLLEXT@ \ | |
| 181 | + $(BINRLS)/static/$(LIBNAME).a | |
| 182 | + | |
| 183 | + | |
| 184 | +$(BINRLS)/$(LIBNAME)@DLLEXT@: \ | |
| 185 | + $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 186 | + | |
| 187 | + @echo $< ... | |
| 188 | + @rm -f $@ | |
| 189 | + @$(LN_S) \ | |
| 190 | + $^ \ | |
| 191 | + $@ | |
| 192 | + | |
| 193 | +$(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ | |
| 194 | + $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 195 | + | |
| 196 | + @rm -f $@ | |
| 197 | + @$(LN_S) \ | |
| 198 | + $^ \ | |
| 199 | + $@ | |
| 200 | + | |
| 201 | +$(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
| 202 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
| 203 | + | |
| 204 | + @$(MKDIR) $(@D) | |
| 205 | + @echo $< ... | |
| 206 | + | |
| 207 | + @$(LD) \ | |
| 208 | + @DLL_LDFLAGS@ \ | |
| 209 | + -o $@ \ | |
| 210 | + $(LDFLAGS) \ | |
| 211 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
| 212 | + -L$(BINRLS) \ | |
| 213 | + $(LIBS) \ | |
| 214 | + -l@LIB3270_NAME@ | |
| 215 | + | |
| 216 | +$(BINRLS)/static/$(LIBNAME).a: \ | |
| 217 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
| 218 | + | |
| 219 | + @echo $@ ... | |
| 220 | + @$(MKDIR) `dirname $@` | |
| 221 | + @$(AR) rcs $@ $^ | |
| 222 | + | |
| 223 | + | |
| 224 | +#---[ Install Targets ]------------------------------------------------------------------ | |
| 225 | + | |
| 226 | +install: \ | |
| 227 | + install-shared \ | |
| 228 | + install-static \ | |
| 229 | + install-dev | |
| 230 | + | |
| 231 | +install-shared: \ | |
| 232 | + $(BINRLS)/$(LIBNAME)@DLLEXT@ | |
| 233 | + | |
| 234 | + # Install library | |
| 235 | + @mkdir -p $(DESTDIR)$(libdir) | |
| 236 | + | |
| 237 | + @$(INSTALL_PROGRAM) \ | |
| 238 | + $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
| 239 | + $(DESTDIR)$(libdir) | |
| 240 | + | |
| 241 | + | |
| 242 | + @$(LN_S) \ | |
| 243 | + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
| 244 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 245 | + | |
| 246 | + @$(LN_S) \ | |
| 247 | + $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ | |
| 248 | + $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ | |
| 249 | + | |
| 250 | +install-static: \ | |
| 251 | + $(BINRLS)/static/$(LIBNAME).a | |
| 252 | + | |
| 253 | + # Install static library | |
| 254 | + @mkdir -p $(DESTDIR)$(libdir) | |
| 255 | + @$(INSTALL_DATA) \ | |
| 256 | + $(BINRLS)/static/$(LIBNAME).a \ | |
| 257 | + $(DESTDIR)$(libdir)/$(LIBNAME)static.a | |
| 258 | + | |
| 259 | + # Install static PKG-CONFIG files | |
| 260 | + @mkdir -p $(DESTDIR)$(libdir)/pkgconfig | |
| 261 | + @$(INSTALL_DATA) \ | |
| 262 | + lib3270++static.pc \ | |
| 263 | + $(DESTDIR)$(libdir)/pkgconfig/lib3270++static.pc | |
| 264 | + | |
| 265 | +install-dev: | |
| 266 | + | |
| 267 | + # Install SDK | |
| 268 | + @$(INSTALL_DATA) \ | |
| 269 | + ../include/lib3270++.h \ | |
| 270 | + $(DESTDIR)$(includedir)/lib3270++.h | |
| 271 | + | |
| 272 | + # Install PKG-CONFIG files | |
| 273 | + @mkdir -p $(DESTDIR)$(libdir)/pkgconfig | |
| 274 | + @$(INSTALL_DATA) \ | |
| 275 | + lib3270++.pc \ | |
| 276 | + $(DESTDIR)$(libdir)/pkgconfig/lib3270++.pc | |
| 277 | + | |
| 278 | + | |
| 279 | +#---[ Misc Targets ]--------------------------------------------------------------------- | |
| 280 | + | |
| 281 | +$(POTDIR)/$(LIBNAME).pot: \ | |
| 282 | + $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(LIBNAME)/$(SRC).pot) | |
| 283 | + | |
| 284 | + @rm -f $@ | |
| 285 | + @mkdir -p `dirname $@` | |
| 286 | + @$(MSGCAT) --sort-output $^ > $@ | |
| 287 | + | |
| 288 | +locale: \ | |
| 289 | + $(POTDIR)/$(LIBNAME).pot | |
| 290 | + | |
| 291 | + | |
| 292 | +#---[ Debug Targets ]-------------------------------------------------------------------- | |
| 293 | + | |
| 294 | +Debug: \ | |
| 295 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 296 | + | |
| 297 | +$(BINDBG)/$(LIBNAME)@EXEEXT@: \ | |
| 298 | + $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 299 | + $(BINDBG)/$(LIBNAME)@DLLEXT@ | |
| 300 | + | |
| 301 | + @$(MKDIR) `dirname $@` | |
| 302 | + @echo $< ... | |
| 303 | + @$(LD) \ | |
| 304 | + -Wl,--rpath,$(BINDBG) \ | |
| 305 | + -o $@ \ | |
| 306 | + $^ \ | |
| 307 | + $(LDFLAGS) \ | |
| 308 | + $(LIBS) | |
| 309 | + | |
| 310 | +run: \ | |
| 311 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 312 | + | |
| 313 | +ifeq ($(VALGRIND),no) | |
| 314 | + | |
| 315 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
| 316 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 317 | + | |
| 318 | +else | |
| 319 | + @touch valgrind.suppression | |
| 320 | + | |
| 321 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
| 322 | + $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \ | |
| 323 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 324 | +endif | |
| 325 | + | |
| 326 | + | |
| 327 | +$(BINDBG)/$(LIBNAME)@DLLEXT@: \ | |
| 328 | + $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 329 | + | |
| 330 | + @echo $< ... | |
| 331 | + @rm -f $@ | |
| 332 | + @$(LN_S) \ | |
| 333 | + $^ \ | |
| 334 | + $@ | |
| 335 | + | |
| 336 | +$(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ | |
| 337 | + $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 338 | + | |
| 339 | + @rm -f $@ | |
| 340 | + @$(LN_S) \ | |
| 341 | + $^ \ | |
| 342 | + $@ | |
| 343 | + | |
| 344 | +$(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
| 345 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) | |
| 346 | + | |
| 347 | + @$(MKDIR) `dirname $@` | |
| 348 | + @echo $< ... | |
| 349 | + @$(LD) \ | |
| 350 | + -shared \ | |
| 351 | + -Wl,-soname,$(@F) \ | |
| 352 | + -Wl,--rpath,$(BINDBG) \ | |
| 353 | + -o $@ \ | |
| 354 | + $(LDFLAGS) \ | |
| 355 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 356 | + -L$(BINDBG) \ | |
| 357 | + $(LIBS) \ | |
| 358 | + -l@LIB3270_NAME@ | |
| 359 | + | |
| 360 | +#---[ Clean Targets ]-------------------------------------------------------------------- | |
| 361 | + | |
| 362 | +clean: \ | |
| 363 | + cleanDebug \ | |
| 364 | + cleanRelease | |
| 365 | + | |
| 366 | + @rm -fr $(BASEDIR)/.tmp/$(LIBNAME) | |
| 367 | + @rm -fr $(POTDIR)/$(LIBNAME) | |
| 368 | + | |
| 369 | +cleanDebug: | |
| 370 | + | |
| 371 | + @rm -fr $(OBJDBG) | |
| 372 | + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 373 | + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 374 | + @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@ | |
| 375 | + | |
| 376 | +cleanRelease: | |
| 377 | + | |
| 378 | + @rm -fr $(OBJRLS) | |
| 379 | + | |
| 380 | + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 381 | + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 382 | + @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@ | |
| 383 | + | |
| 384 | + @rm -fr $(POTDIR) | |
| 385 | + @rm -f lib$(LIBNAME).pot | |
| 386 | + | |
| 387 | +clean: \ | |
| 388 | + cleanDebug \ | |
| 389 | + cleanRelease | |
| 390 | + | |
| 391 | + | ... | ... |
| ... | ... | @@ -0,0 +1,153 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/core/abstract.cc | |
| 32 | + * | |
| 33 | + * @brief Implements abstract session object. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + #include <cstring> | |
| 41 | + | |
| 42 | + | |
| 43 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | + | |
| 45 | + namespace TN3270 { | |
| 46 | + | |
| 47 | + Abstract::Session::Session() { | |
| 48 | + | |
| 49 | +#ifdef HAVE_ICONV | |
| 50 | + this->converter.local = (iconv_t) (-1); | |
| 51 | + this->converter.host = (iconv_t) (-1); | |
| 52 | +#endif | |
| 53 | + | |
| 54 | + this->baddr = 0; | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + Abstract::Session::~Session() { | |
| 59 | + | |
| 60 | +#ifdef HAVE_ICONV | |
| 61 | + | |
| 62 | + if(this->converter.local != (iconv_t) (-1)) | |
| 63 | + iconv_close(this->converter.local); | |
| 64 | + | |
| 65 | + if(this->converter.host != (iconv_t) (-1)) | |
| 66 | + iconv_close(this->converter.host); | |
| 67 | + | |
| 68 | +#endif | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + /// @brief Setup charsets | |
| 73 | + void Abstract::Session::setCharSet(const char *remote, const char *local) { | |
| 74 | + | |
| 75 | +#ifdef HAVE_ICONV | |
| 76 | + | |
| 77 | + if(this->converter.local != (iconv_t) (-1)) | |
| 78 | + iconv_close(converter.local); | |
| 79 | + | |
| 80 | + if(this->converter.host != (iconv_t) (-1)) | |
| 81 | + iconv_close(converter.host); | |
| 82 | + | |
| 83 | + if(strcmp(local,remote)) { | |
| 84 | + | |
| 85 | + // Local and remote charsets aren't the same, setup conversion | |
| 86 | + converter.local = iconv_open(local, remote); | |
| 87 | + converter.host = iconv_open(remote,local); | |
| 88 | + | |
| 89 | + } else { | |
| 90 | + // Same charset, doesn't convert | |
| 91 | + converter.local = converter.host = (iconv_t)(-1); | |
| 92 | + } | |
| 93 | + | |
| 94 | +#else | |
| 95 | + | |
| 96 | + throw std::runtime_error("No ICONV Support"); | |
| 97 | + | |
| 98 | +#endif | |
| 99 | + | |
| 100 | + | |
| 101 | + } | |
| 102 | + | |
| 103 | + /// @brief Converte charset. | |
| 104 | + std::string Abstract::Session::convertCharset(iconv_t &converter, const char *str) { | |
| 105 | + | |
| 106 | + std::string rc; | |
| 107 | + | |
| 108 | +#ifdef HAVE_ICONV | |
| 109 | + size_t in = strlen(str); | |
| 110 | + | |
| 111 | + if(in && converter != (iconv_t)(-1)) { | |
| 112 | + | |
| 113 | + size_t out = (in << 1); | |
| 114 | + char * ptr; | |
| 115 | + char * outBuffer = (char *) malloc(out); | |
| 116 | + ICONV_CONST char * inBuffer = (ICONV_CONST char *) str; | |
| 117 | + | |
| 118 | + memset(ptr=outBuffer,0,out); | |
| 119 | + | |
| 120 | + iconv(converter,NULL,NULL,NULL,NULL); // Reset state | |
| 121 | + | |
| 122 | + if(iconv(converter,&inBuffer,&in,&ptr,&out) != ((size_t) -1)) | |
| 123 | + rc.assign(outBuffer); | |
| 124 | + | |
| 125 | + free(outBuffer); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | +#else | |
| 130 | + | |
| 131 | + rc = str; | |
| 132 | + | |
| 133 | +#endif // HAVE_ICONV | |
| 134 | + | |
| 135 | + return rc; | |
| 136 | + } | |
| 137 | + | |
| 138 | + /// @brief Converte string recebida do host para o charset atual. | |
| 139 | + std::string Abstract::Session::convertFromHost(const char *str) const { | |
| 140 | + return convertCharset(const_cast<Abstract::Session *>(this)->converter.local,str); | |
| 141 | + } | |
| 142 | + | |
| 143 | + /// @brief Converte string do charset atual para o charset do host. | |
| 144 | + std::string Abstract::Session::convertToHost(const char *str) const { | |
| 145 | + return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,str); | |
| 146 | + } | |
| 147 | + | |
| 148 | + | |
| 149 | + } | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | ... | ... |
| ... | ... | @@ -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., 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 | + */ | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * @file src/core/events.cc | |
| 32 | + * | |
| 33 | + * @brief Implements event object. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + | |
| 41 | + | |
| 42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | + | |
| 44 | + namespace TN3270 { | |
| 45 | + | |
| 46 | + Event::Event(enum Event::Type type) { | |
| 47 | + this->type = type; | |
| 48 | + } | |
| 49 | + | |
| 50 | + Event::~Event() { | |
| 51 | + } | |
| 52 | + | |
| 53 | + } | |
| 54 | + | |
| 55 | + | |
| 56 | + | ... | ... |
| ... | ... | @@ -0,0 +1,179 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/core/host.cc | |
| 32 | + * | |
| 33 | + * @brief Implements host object. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + | |
| 41 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 42 | + | |
| 43 | + namespace TN3270 { | |
| 44 | + | |
| 45 | + Host::Host(const char *id, const char *url, time_t timeout) { | |
| 46 | + this->timeout = timeout; | |
| 47 | + this->session = Session::create(id); | |
| 48 | + if(url) { | |
| 49 | + this->connect(url); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + Host::~Host() { | |
| 54 | + delete this->session; | |
| 55 | + this->session = nullptr; | |
| 56 | + } | |
| 57 | + | |
| 58 | + void Host::connect(const char *url, bool sync) { | |
| 59 | + this->session->connect(url); | |
| 60 | + if(sync) { | |
| 61 | + this->sync(); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + | |
| 66 | + /// @brief Writes characters to the associated file from the put area | |
| 67 | + int Host::sync() { | |
| 68 | + this->session->waitForReady(this->timeout); | |
| 69 | + return 0; | |
| 70 | + } | |
| 71 | + | |
| 72 | + /// @brief Writes characters to the associated output sequence from the put area. | |
| 73 | + int Host::overflow(int c) { | |
| 74 | + | |
| 75 | + if (c != EOF) { | |
| 76 | + char str[] = { static_cast<char>(c), 0 }; | |
| 77 | + this->session->push((const char *) str); | |
| 78 | + } else { | |
| 79 | + sync(); | |
| 80 | + } | |
| 81 | + | |
| 82 | + return c; | |
| 83 | + | |
| 84 | + } | |
| 85 | + | |
| 86 | + Host & Host::push(const Action action) { | |
| 87 | + session->push(action); | |
| 88 | + sync(); | |
| 89 | + return *this; | |
| 90 | + } | |
| 91 | + | |
| 92 | + bool Host::isReady() const { | |
| 93 | + this->session->waitForReady(this->timeout); | |
| 94 | + return getProgramMessage() == MESSAGE_NONE; | |
| 95 | + } | |
| 96 | + | |
| 97 | + bool Host::isConnected() const { | |
| 98 | + this->session->waitForReady(this->timeout); | |
| 99 | + return getConnectionState() == CONNECTED_TN3270E; | |
| 100 | + } | |
| 101 | + | |
| 102 | + std::string Host::toString() const { | |
| 103 | + | |
| 104 | + this->session->waitForReady(this->timeout); | |
| 105 | + | |
| 106 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 107 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 108 | + } | |
| 109 | + | |
| 110 | + return this->session->toString(); | |
| 111 | + } | |
| 112 | + | |
| 113 | + std::string Host::toString(int baddr, size_t len, char lf) const { | |
| 114 | + | |
| 115 | + this->session->waitForReady(this->timeout); | |
| 116 | + | |
| 117 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 118 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 119 | + } | |
| 120 | + | |
| 121 | + return this->session->toString(baddr,len,lf); | |
| 122 | + | |
| 123 | + } | |
| 124 | + | |
| 125 | + std::string Host::toString(int row, int col, size_t sz, char lf) const { | |
| 126 | + | |
| 127 | + this->session->waitForReady(this->timeout); | |
| 128 | + | |
| 129 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 130 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 131 | + } | |
| 132 | + | |
| 133 | + return this->session->toString(row,col,sz,lf); | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + Host & Host::pop(int baddr, std::string &text) { | |
| 139 | + | |
| 140 | + this->session->waitForReady(this->timeout); | |
| 141 | + | |
| 142 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 143 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 144 | + } | |
| 145 | + | |
| 146 | + session->pop(baddr, text); | |
| 147 | + | |
| 148 | + return *this; | |
| 149 | + } | |
| 150 | + | |
| 151 | + Host & Host::pop(int row, int col, std::string &text) { | |
| 152 | + | |
| 153 | + this->session->waitForReady(this->timeout); | |
| 154 | + | |
| 155 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 156 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 157 | + } | |
| 158 | + | |
| 159 | + session->pop(row,col,text); | |
| 160 | + | |
| 161 | + return *this; | |
| 162 | + } | |
| 163 | + | |
| 164 | + Host & Host::pop(std::string &text) { | |
| 165 | + | |
| 166 | + this->session->waitForReady(this->timeout); | |
| 167 | + | |
| 168 | + if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 169 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 170 | + } | |
| 171 | + | |
| 172 | + session->pop(text); | |
| 173 | + | |
| 174 | + return *this; | |
| 175 | + } | |
| 176 | + | |
| 177 | + | |
| 178 | + } | |
| 179 | + | ... | ... |
| ... | ... | @@ -0,0 +1,267 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/os/linux/request.cc | |
| 32 | + * | |
| 33 | + * @brief Implements linux request methods for remote session. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + | |
| 41 | + using std::string; | |
| 42 | + | |
| 43 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | + | |
| 45 | + namespace TN3270 { | |
| 46 | + | |
| 47 | + IPC::Request::Request(const Session &session) { | |
| 48 | + this->conn = session.conn; | |
| 49 | + this->msg.in = nullptr; | |
| 50 | + this->msg.out = nullptr; | |
| 51 | + } | |
| 52 | + | |
| 53 | + IPC::Request::Request(const Session &session, const char *method) : Request(session) { | |
| 54 | + | |
| 55 | + this->msg.out = dbus_message_new_method_call( | |
| 56 | + session.name.c_str(), // Destination | |
| 57 | + session.path.c_str(), // Path | |
| 58 | + session.interface.c_str(), // Interface | |
| 59 | + method // Method | |
| 60 | + ); | |
| 61 | + | |
| 62 | + if(!msg.out) { | |
| 63 | + throw std::runtime_error("Can't create D-Bus Method Call"); | |
| 64 | + } | |
| 65 | + | |
| 66 | + } | |
| 67 | + | |
| 68 | + IPC::Request::Request(const Session &session, bool isSet, const char *property) : Request(session) { | |
| 69 | + | |
| 70 | +/* | |
| 71 | + dbus-send \ | |
| 72 | + --session \ | |
| 73 | + --dest=br.com.bb.pw3270.a\ | |
| 74 | + --print-reply \ | |
| 75 | + "/br/com/bb/tn3270/session" \ | |
| 76 | + "org.freedesktop.DBus.Properties.Get" \ | |
| 77 | + string:br.com.bb.tn3270.session \ | |
| 78 | + string:${1} | |
| 79 | +*/ | |
| 80 | + this->msg.out = dbus_message_new_method_call( | |
| 81 | + session.name.c_str(), // Destination | |
| 82 | + session.path.c_str(), // Path | |
| 83 | + "org.freedesktop.DBus.Properties", // Interface | |
| 84 | + (isSet ? "Set" : "Get") | |
| 85 | + ); | |
| 86 | + | |
| 87 | + if(!msg.out) { | |
| 88 | + throw std::runtime_error("Can't create D-Bus Property Call"); | |
| 89 | + } | |
| 90 | + | |
| 91 | + // | |
| 92 | + // https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties | |
| 93 | + // org.freedesktop.DBus.Properties.Get (in STRING interface_name, | |
| 94 | + // in STRING property_name, | |
| 95 | + // out VARIANT value); | |
| 96 | + // org.freedesktop.DBus.Properties.Set (in STRING interface_name, | |
| 97 | + // in STRING property_name, | |
| 98 | + // | |
| 99 | + const char *interface_name = session.interface.c_str(); | |
| 100 | + | |
| 101 | + dbus_message_append_args( | |
| 102 | + this->msg.out, | |
| 103 | + DBUS_TYPE_STRING,&interface_name, | |
| 104 | + DBUS_TYPE_STRING,&property, | |
| 105 | + DBUS_TYPE_INVALID | |
| 106 | + ); | |
| 107 | + | |
| 108 | + } | |
| 109 | + | |
| 110 | + IPC::Request::~Request() { | |
| 111 | + if(msg.out) { | |
| 112 | + dbus_message_unref(msg.out); | |
| 113 | + } | |
| 114 | + if(msg.in) { | |
| 115 | + dbus_message_unref(msg.in); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + IPC::Request & IPC::Request::call() { | |
| 120 | + | |
| 121 | + if(msg.in) { | |
| 122 | + dbus_message_unref(msg.in); | |
| 123 | + msg.in = nullptr; | |
| 124 | + } | |
| 125 | + | |
| 126 | + DBusError error; | |
| 127 | + dbus_error_init(&error); | |
| 128 | + this->msg.in = dbus_connection_send_with_reply_and_block(this->conn,this->msg.out,10000,&error); | |
| 129 | + | |
| 130 | + if(!this->msg.in) { | |
| 131 | + string message = error.message; | |
| 132 | + dbus_error_free(&error); | |
| 133 | + throw std::runtime_error(message.c_str()); | |
| 134 | + } | |
| 135 | + | |
| 136 | + dbus_message_iter_init(msg.in, &msg.iter); | |
| 137 | + | |
| 138 | + debug(__FUNCTION__," got a valid response"); | |
| 139 | + | |
| 140 | + return *this; | |
| 141 | + | |
| 142 | + } | |
| 143 | + | |
| 144 | + IPC::Request & IPC::Request::push(const char *arg) { | |
| 145 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_STRING,&arg,DBUS_TYPE_INVALID); | |
| 146 | + return *this; | |
| 147 | + } | |
| 148 | + | |
| 149 | + IPC::Request & IPC::Request::push(const bool arg) { | |
| 150 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_BOOLEAN,&arg,DBUS_TYPE_INVALID); | |
| 151 | + return *this; | |
| 152 | + } | |
| 153 | + | |
| 154 | + IPC::Request & IPC::Request::push(const uint8_t arg) { | |
| 155 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_BYTE,&arg,DBUS_TYPE_INVALID); | |
| 156 | + return *this; | |
| 157 | + } | |
| 158 | + | |
| 159 | + IPC::Request & IPC::Request::push(const int32_t arg) { | |
| 160 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_INT32,&arg,DBUS_TYPE_INVALID); | |
| 161 | + return *this; | |
| 162 | + } | |
| 163 | + | |
| 164 | + IPC::Request & IPC::Request::push(const uint32_t arg) { | |
| 165 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_UINT32,&arg,DBUS_TYPE_INVALID); | |
| 166 | + return *this; | |
| 167 | + } | |
| 168 | + | |
| 169 | + | |
| 170 | + IPC::Request & IPC::Request::pop(std::string &value) { | |
| 171 | + | |
| 172 | + const char * str = ""; | |
| 173 | + | |
| 174 | + if(dbus_message_iter_get_arg_type(&msg.iter) == DBUS_TYPE_STRING) { | |
| 175 | + | |
| 176 | + dbus_message_iter_get_basic(&msg.iter, &str); | |
| 177 | + | |
| 178 | + } else if(dbus_message_iter_get_arg_type(&msg.iter) == DBUS_TYPE_VARIANT) { | |
| 179 | + | |
| 180 | + DBusMessageIter sub; | |
| 181 | + int current_type; | |
| 182 | + | |
| 183 | + dbus_message_iter_recurse(&msg.iter, &sub); | |
| 184 | + | |
| 185 | + while ((current_type = dbus_message_iter_get_arg_type(&sub)) != DBUS_TYPE_INVALID) { | |
| 186 | + | |
| 187 | + if (current_type == DBUS_TYPE_STRING) { | |
| 188 | + dbus_message_iter_get_basic(&sub, &str); | |
| 189 | + break; | |
| 190 | + } | |
| 191 | + dbus_message_iter_next(&sub); | |
| 192 | + } | |
| 193 | + | |
| 194 | + } else { | |
| 195 | + | |
| 196 | + debug("Argument type is ", ((char) dbus_message_iter_get_arg_type(&msg.iter)) ); | |
| 197 | + throw std::runtime_error("Expected an string data type"); | |
| 198 | + | |
| 199 | + } | |
| 200 | + | |
| 201 | + dbus_message_iter_next(&msg.iter); | |
| 202 | + | |
| 203 | + value.assign(str); | |
| 204 | + | |
| 205 | + debug(__FUNCTION__,"= \"",str,"\""); | |
| 206 | + | |
| 207 | + return *this; | |
| 208 | + } | |
| 209 | + | |
| 210 | + static int getIntValue(DBusMessageIter &iter) { | |
| 211 | + | |
| 212 | + if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) { | |
| 213 | + | |
| 214 | + dbus_int32_t rc = 0; | |
| 215 | + dbus_message_iter_get_basic(&iter, &rc); | |
| 216 | + return (int) rc; | |
| 217 | + | |
| 218 | + } else if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT16) { | |
| 219 | + | |
| 220 | + dbus_int16_t rc = 0; | |
| 221 | + dbus_message_iter_get_basic(&iter, &rc); | |
| 222 | + return (int) rc; | |
| 223 | + | |
| 224 | + } else if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) { | |
| 225 | + | |
| 226 | + DBusMessageIter sub; | |
| 227 | + int current_type; | |
| 228 | + | |
| 229 | + dbus_message_iter_recurse(&iter, &sub); | |
| 230 | + | |
| 231 | + while ((current_type = dbus_message_iter_get_arg_type(&sub)) != DBUS_TYPE_INVALID) { | |
| 232 | + | |
| 233 | + if (current_type == DBUS_TYPE_INT32) { | |
| 234 | + | |
| 235 | + dbus_int32_t rc = 0; | |
| 236 | + dbus_message_iter_get_basic(&sub, &rc); | |
| 237 | + return (int) rc; | |
| 238 | + | |
| 239 | + } else if (current_type == DBUS_TYPE_INT16) { | |
| 240 | + dbus_int16_t rc = 0; | |
| 241 | + dbus_message_iter_get_basic(&sub, &rc); | |
| 242 | + return (int) rc; | |
| 243 | + | |
| 244 | + } | |
| 245 | + dbus_message_iter_next(&sub); | |
| 246 | + } | |
| 247 | + | |
| 248 | + } | |
| 249 | + | |
| 250 | + debug("Argument type is ", ((char) dbus_message_iter_get_arg_type(&iter)) ); | |
| 251 | + throw std::runtime_error("Expected an integer data type"); | |
| 252 | + | |
| 253 | + } | |
| 254 | + | |
| 255 | + IPC::Request & IPC::Request::Request::pop(int &value) { | |
| 256 | + | |
| 257 | + value = getIntValue(msg.iter); | |
| 258 | + dbus_message_iter_next(&msg.iter); | |
| 259 | + debug(__FUNCTION__,"= \"",value,"\""); | |
| 260 | + | |
| 261 | + return *this; | |
| 262 | + | |
| 263 | + } | |
| 264 | + | |
| 265 | + } | |
| 266 | + | |
| 267 | + | ... | ... |
| ... | ... | @@ -0,0 +1,98 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/os/linux/linux/session.cc | |
| 32 | + * | |
| 33 | + * @brief Implements Linux session methods. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + #include <cstring> | |
| 41 | + #include <lib3270/trace.h> | |
| 42 | + | |
| 43 | + using std::string; | |
| 44 | + | |
| 45 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 46 | + | |
| 47 | + static void throws_if_error(DBusError &err) { | |
| 48 | + | |
| 49 | + if(dbus_error_is_set(&err)) { | |
| 50 | + string message = err.message; | |
| 51 | + dbus_error_free(&err); | |
| 52 | + throw std::runtime_error(message.c_str()); | |
| 53 | + } | |
| 54 | + | |
| 55 | + return; | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + namespace TN3270 { | |
| 60 | + | |
| 61 | + IPC::Session::Session(const char *id) : Abstract::Session() { | |
| 62 | + | |
| 63 | + // Create D-Bus session. | |
| 64 | + DBusError err; | |
| 65 | + | |
| 66 | + dbus_error_init(&err); | |
| 67 | + this->conn = dbus_bus_get(DBUS_BUS_SESSION, &err); | |
| 68 | + | |
| 69 | + debug("dbus_bus_get conn=",conn); | |
| 70 | + | |
| 71 | + throws_if_error(err); | |
| 72 | + | |
| 73 | + if(!conn) | |
| 74 | + throw std::runtime_error("DBUS Connection failed"); | |
| 75 | + | |
| 76 | + auto sep = strchr(id,':'); | |
| 77 | + if(!sep) { | |
| 78 | + throw std::system_error(EINVAL, std::system_category()); | |
| 79 | + } | |
| 80 | + | |
| 81 | + this->name = "br.com.bb."; | |
| 82 | + this->name += string(id,(sep - id)); | |
| 83 | + this->name += "."; | |
| 84 | + this->name += (sep+1); | |
| 85 | + this->path = "/br/com/bb/tn3270/session"; | |
| 86 | + this->interface = "br.com.bb.tn3270.session"; | |
| 87 | + | |
| 88 | + debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\""); | |
| 89 | + | |
| 90 | + } | |
| 91 | + | |
| 92 | + IPC::Session::~Session() { | |
| 93 | + | |
| 94 | + } | |
| 95 | + | |
| 96 | + } | |
| 97 | + | |
| 98 | + | ... | ... |
| ... | ... | @@ -0,0 +1,78 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/core/session.cc | |
| 32 | + * | |
| 33 | + * @brief Implements common session object. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + | |
| 41 | + | |
| 42 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | + | |
| 44 | + namespace TN3270 { | |
| 45 | + | |
| 46 | + /// @brief Create a tn3270 session. | |
| 47 | + Session * Session::create(const char *id) { | |
| 48 | + | |
| 49 | + if(!id) { | |
| 50 | + return new Local::Session(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return new IPC::Session(id); | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + | |
| 58 | + Session::Session() { | |
| 59 | + | |
| 60 | + } | |
| 61 | + | |
| 62 | + Session::~Session() { | |
| 63 | + | |
| 64 | + } | |
| 65 | + | |
| 66 | + void Session::insert(Event::Type type, std::function <void(const Event &event)> listener) { | |
| 67 | + } | |
| 68 | + | |
| 69 | + /// @brief Fire event. | |
| 70 | + void Session::fire(const Event &event) { | |
| 71 | + | |
| 72 | + | |
| 73 | + } | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | + | |
| 78 | + | ... | ... |
| ... | ... | @@ -0,0 +1,191 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/os/windows/request.cc | |
| 32 | + * | |
| 33 | + * @brief Implements WIN32 request methods. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include "../private.h" | |
| 40 | + | |
| 41 | + using std::string; | |
| 42 | + | |
| 43 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | + | |
| 45 | + namespace TN3270 { | |
| 46 | + | |
| 47 | + #define PIPE_BUFFER_LENGTH 8192 | |
| 48 | + | |
| 49 | + IPC::Request::Request(const Session &session) { | |
| 50 | + | |
| 51 | + this->hPipe = session.hPipe; | |
| 52 | + | |
| 53 | + in.length = PIPE_BUFFER_LENGTH; | |
| 54 | + in.used = 0; | |
| 55 | + in.block = new uint8_t[in.length]; | |
| 56 | + | |
| 57 | + out.length = PIPE_BUFFER_LENGTH; | |
| 58 | + out.used = 0; | |
| 59 | + out.block = new uint8_t[out.length]; | |
| 60 | + | |
| 61 | + } | |
| 62 | + | |
| 63 | + IPC::Request::Request(const Session &session, const char *method) : Request(session) { | |
| 64 | + | |
| 65 | + // Add name | |
| 66 | + strcpy((char *) out.block, method); | |
| 67 | + out.used += strlen((char *) method) + 1; | |
| 68 | + | |
| 69 | + // Add ID | |
| 70 | + *((uint16_t *) (out.block + out.used)) = (uint16_t) 3; | |
| 71 | + out.used += sizeof(uint16_t); | |
| 72 | + | |
| 73 | + } | |
| 74 | + | |
| 75 | + IPC::Request::Request(const Session &session, bool isSet, const char *property) : Request(session) { | |
| 76 | + | |
| 77 | + // Add name | |
| 78 | + strcpy((char *) out.block, property); | |
| 79 | + out.used += strlen((char *) property) + 1; | |
| 80 | + | |
| 81 | + // Add ID (SetProperty = 2, getProperty = 1) | |
| 82 | + *((uint16_t *) (out.block + out.used)) = (uint16_t) (isSet ? 2 : 1); | |
| 83 | + out.used += sizeof(uint16_t); | |
| 84 | + | |
| 85 | + } | |
| 86 | + | |
| 87 | + IPC::Request::~Request() { | |
| 88 | + | |
| 89 | + delete[] ((uint8_t *) in.block); | |
| 90 | + delete[] ((uint8_t *) out.block); | |
| 91 | + | |
| 92 | + } | |
| 93 | + | |
| 94 | + /// @brief Store value on data block. | |
| 95 | + IPC::Request::DataBlock * IPC::Request::pushBlock(const void *ptr, size_t length) { | |
| 96 | + | |
| 97 | + if((out.used + length + sizeof(IPC::Request::DataBlock)) >= out.length) { | |
| 98 | + throw std::runtime_error("Too big"); | |
| 99 | + } | |
| 100 | + | |
| 101 | + IPC::Request::DataBlock * rc = (IPC::Request::DataBlock *) (out.block + out.used); | |
| 102 | + memcpy(((uint8_t *) (rc+1)), ((uint8_t *) ptr), length); | |
| 103 | + | |
| 104 | + out.used += (sizeof(IPC::Request::DataBlock) + length); | |
| 105 | + | |
| 106 | + return rc; | |
| 107 | + | |
| 108 | + } | |
| 109 | + | |
| 110 | + /// @brief Get next argument. | |
| 111 | + IPC::Request::DataBlock * IPC::Request::getNextBlock() const { | |
| 112 | + | |
| 113 | + if((in.current + sizeof(IPC::Request::DataBlock)) >= in.used) { | |
| 114 | + throw std::runtime_error("Out of range"); | |
| 115 | + } | |
| 116 | + | |
| 117 | + return (IPC::Request::DataBlock *) (in.block + in.current); | |
| 118 | + | |
| 119 | + } | |
| 120 | + | |
| 121 | + IPC::Request & IPC::Request::push(const char *arg) { | |
| 122 | + pushBlock(arg, strlen(arg)+1)->type = IPC::Request::String; | |
| 123 | + return *this; | |
| 124 | + } | |
| 125 | + | |
| 126 | + IPC::Request & IPC::Request::push(const bool arg) { | |
| 127 | + uint8_t value = (uint8_t) (arg ? 0xff : 0); | |
| 128 | + pushBlock(&value, sizeof(value))->type = IPC::Request::Boolean; | |
| 129 | + return *this; | |
| 130 | + } | |
| 131 | + | |
| 132 | + IPC::Request & IPC::Request::push(const uint8_t arg) { | |
| 133 | + pushBlock(&arg, sizeof(arg))->type = IPC::Request::Uchar; | |
| 134 | + return *this; | |
| 135 | + } | |
| 136 | + | |
| 137 | + IPC::Request & IPC::Request::push(const int32_t arg) { | |
| 138 | + pushBlock(&arg, sizeof(arg))->type = IPC::Request::Int32; | |
| 139 | + return *this; | |
| 140 | + } | |
| 141 | + | |
| 142 | + IPC::Request & IPC::Request::push(const uint32_t arg) { | |
| 143 | + pushBlock(&arg, sizeof(arg))->type = IPC::Request::Uint32; | |
| 144 | + return *this; | |
| 145 | + } | |
| 146 | + | |
| 147 | + IPC::Request & IPC::Request::pop(std::string &value) { | |
| 148 | + DataBlock * block = getNextBlock(); | |
| 149 | + | |
| 150 | + if(block->type != IPC::Request::String) | |
| 151 | + throw std::runtime_error("Invalid format"); | |
| 152 | + | |
| 153 | + const char *ptr = (const char *) (block+1); | |
| 154 | + | |
| 155 | + in.current += (strlen(ptr)+1+sizeof(DataBlock)); | |
| 156 | + | |
| 157 | + value.assign(ptr); | |
| 158 | + | |
| 159 | + return *this; | |
| 160 | + } | |
| 161 | + | |
| 162 | + IPC::Request & IPC::Request::Request::pop(int &value) { | |
| 163 | + | |
| 164 | + DataBlock * block = getNextBlock(); | |
| 165 | + | |
| 166 | + switch(block->type) { | |
| 167 | + case IPC::Request::Int16: | |
| 168 | + value = * ((int16_t *) (block+1)); | |
| 169 | + in.current += sizeof(int16_t) + sizeof(DataBlock); | |
| 170 | + break; | |
| 171 | + | |
| 172 | + case IPC::Request::Int32: | |
| 173 | + value = * ((int32_t *) (block+1)); | |
| 174 | + in.current += sizeof(int32_t) + sizeof(DataBlock); | |
| 175 | + break; | |
| 176 | + | |
| 177 | + case IPC::Request::Int64: | |
| 178 | + value = * ((int64_t *) (block+1)); | |
| 179 | + in.current += sizeof(int64_t) + sizeof(DataBlock); | |
| 180 | + break; | |
| 181 | + | |
| 182 | + default: | |
| 183 | + throw std::runtime_error("Invalid format"); | |
| 184 | + } | |
| 185 | + | |
| 186 | + return *this; | |
| 187 | + } | |
| 188 | + | |
| 189 | + } | |
| 190 | + | |
| 191 | + | ... | ... |
| ... | ... | @@ -0,0 +1,29 @@ |
| 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", "3270 C++ Access Library\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", "@PACKAGE_TARNAME@@DLLEXT@\0" | |
| 18 | + VALUE "ProductName", "@PACKAGE_NAME@\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 | + | ... | ... |
| ... | ... | @@ -0,0 +1,142 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/os/windows/session.cc | |
| 32 | + * | |
| 33 | + * @brief Implements WIN32 remote session methods. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include "../private.h" | |
| 40 | + #include <cstring> | |
| 41 | + #include <lib3270/trace.h> | |
| 42 | + #include <algorithm> | |
| 43 | + | |
| 44 | + using std::string; | |
| 45 | + | |
| 46 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 47 | + | |
| 48 | + namespace TN3270 { | |
| 49 | + | |
| 50 | + IPC::Session::Session(const char *id) : Abstract::Session() { | |
| 51 | + | |
| 52 | + char *ptr = strchr(id,':'); | |
| 53 | + | |
| 54 | + if(!ptr) | |
| 55 | + throw std::system_error(EINVAL, std::system_category()); | |
| 56 | + | |
| 57 | + string pipename{"\\\\.\\pipe\\"}; | |
| 58 | + | |
| 59 | + pipename += string(id,ptr - id); | |
| 60 | + pipename += "\\"; | |
| 61 | + pipename += (ptr+1); | |
| 62 | + | |
| 63 | + std::transform(pipename.begin(), pipename.end(), pipename.begin(), ::tolower); | |
| 64 | + | |
| 65 | + debug("pipename: \"%s\"",pipename.c_str()); | |
| 66 | + | |
| 67 | + this->hPipe = CreateFile( | |
| 68 | + TEXT(pipename.c_str()), // pipe name | |
| 69 | + GENERIC_READ | // read and write access | |
| 70 | + GENERIC_WRITE, | |
| 71 | + 0, // no sharing | |
| 72 | + NULL, // default security attributes | |
| 73 | + OPEN_EXISTING, // opens existing pipe | |
| 74 | + 0, // default attributes | |
| 75 | + NULL // no template file | |
| 76 | + ); | |
| 77 | + | |
| 78 | + if (hPipe == INVALID_HANDLE_VALUE) { | |
| 79 | + throw std::runtime_error("Can't open IPC Channel"); | |
| 80 | + } | |
| 81 | + | |
| 82 | + // The pipe connected; change to message-read mode. | |
| 83 | + DWORD dwMode = PIPE_READMODE_MESSAGE; | |
| 84 | + if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) { | |
| 85 | + throw std::runtime_error("Can't set IPC Channel mode"); | |
| 86 | + } | |
| 87 | + | |
| 88 | + } | |
| 89 | + | |
| 90 | + IPC::Session::~Session() { | |
| 91 | + CloseHandle(this->hPipe); | |
| 92 | + } | |
| 93 | + | |
| 94 | + | |
| 95 | + IPC::Request & IPC::Request::call() { | |
| 96 | + | |
| 97 | +#ifdef DEBUG | |
| 98 | + // lib3270_trace_data(NULL,"Request block",(const char *) this->out.block, this->out.used); | |
| 99 | +#endif // DEBUG | |
| 100 | + | |
| 101 | + in.current = 0; | |
| 102 | + | |
| 103 | + if(!TransactNamedPipe( | |
| 104 | + this->hPipe, | |
| 105 | + this->out.block, | |
| 106 | + this->out.used, | |
| 107 | + this->in.block, | |
| 108 | + this->in.length, | |
| 109 | + &this->in.used, | |
| 110 | + NULL) | |
| 111 | + ) { | |
| 112 | + | |
| 113 | + throw std::runtime_error("Can't transact on IPC Channel"); | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 117 | + debug("Received response \"", in.block, "\" with ", in.used, " bytes"); | |
| 118 | +#ifdef DEBUG | |
| 119 | + // lib3270_trace_data(NULL,"Response block",(const char *) this->in.block, this->in.used); | |
| 120 | +#endif // DEBUG | |
| 121 | + | |
| 122 | + // Extract response name | |
| 123 | + in.current = strlen((const char *) in.block)+1; | |
| 124 | + | |
| 125 | + // Extract return code | |
| 126 | + uint16_t rc = *((uint16_t *) (in.block + in.current)); | |
| 127 | + in.current += sizeof(uint16_t); | |
| 128 | + | |
| 129 | + // Extract argc | |
| 130 | + uint16_t argc = *((uint16_t *) (in.block + in.current)); | |
| 131 | + in.current += sizeof(uint16_t); | |
| 132 | + | |
| 133 | + debug("Received response \"", ((const char *) in.block), "\" with rc=", rc, " and ", argc, " arguments"); | |
| 134 | + | |
| 135 | + return *this; | |
| 136 | + } | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + | ... | ... |
| ... | ... | @@ -0,0 +1,385 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/lib3270++/private.h | |
| 32 | + * | |
| 33 | + * @brief | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | +#ifndef PRIVATE_H_INCLUDED | |
| 40 | + | |
| 41 | + #define PRIVATE_H_INCLUDED | |
| 42 | + | |
| 43 | + #include <config.h> | |
| 44 | + | |
| 45 | + #ifdef _WIN32 | |
| 46 | + #include <winsock2.h> | |
| 47 | + #include <windows.h> | |
| 48 | + #include <ws2tcpip.h> | |
| 49 | + #else | |
| 50 | + #include <dbus/dbus.h> | |
| 51 | + #endif // WIN32 | |
| 52 | + | |
| 53 | + #include <iostream> | |
| 54 | + #include <mutex> | |
| 55 | + #include <lib3270++.h> | |
| 56 | + #include <lib3270/popup.h> | |
| 57 | + #include <system_error> | |
| 58 | + #include <stdexcept> | |
| 59 | + | |
| 60 | +#ifdef HAVE_LIBINTL | |
| 61 | + #include <libintl.h> | |
| 62 | + #define _( x ) gettext(x) | |
| 63 | + #define N_( x ) x | |
| 64 | +#else | |
| 65 | + #define _( x ) x | |
| 66 | + #define N_( x ) x | |
| 67 | +#endif // HAVE_LIBINTL | |
| 68 | + | |
| 69 | +#ifdef HAVE_ICONV | |
| 70 | + #include <iconv.h> | |
| 71 | +#endif // HAVE_ICONV | |
| 72 | + | |
| 73 | +#ifdef WIN32 | |
| 74 | + #define SYSTEM_CHARSET "CP1252" | |
| 75 | +#else | |
| 76 | + #define SYSTEM_CHARSET "UTF-8" | |
| 77 | +#endif // WIN32 | |
| 78 | + | |
| 79 | +#ifdef DEBUG | |
| 80 | + | |
| 81 | + inline void console(std::ostream &out) { | |
| 82 | + out << std::endl; | |
| 83 | + } | |
| 84 | + | |
| 85 | + template<typename T, typename... Targs> | |
| 86 | + void console(std::ostream &out, T value, Targs... Fargs) { | |
| 87 | + out << value; | |
| 88 | + console(out, Fargs...); | |
| 89 | + } | |
| 90 | + | |
| 91 | + template<typename T, typename... Targs> | |
| 92 | + void log(T value, Targs... Fargs) { | |
| 93 | + console(std::clog,value,Fargs...); | |
| 94 | + } | |
| 95 | + | |
| 96 | + #define debug(...) log(__FILE__, "(", __LINE__, ") ", __VA_ARGS__); | |
| 97 | + | |
| 98 | +#else | |
| 99 | + | |
| 100 | + #define debug(...) /* __VA_ARGS__ */ | |
| 101 | + | |
| 102 | +#endif | |
| 103 | + | |
| 104 | + namespace TN3270 { | |
| 105 | + | |
| 106 | + namespace Abstract { | |
| 107 | + | |
| 108 | + class TN3270_PRIVATE Session : public TN3270::Session { | |
| 109 | + private: | |
| 110 | + | |
| 111 | +#ifdef HAVE_ICONV | |
| 112 | + struct { | |
| 113 | + | |
| 114 | + /// @brief Convert strings from host codepage to local codepage. | |
| 115 | + iconv_t local; | |
| 116 | + | |
| 117 | + /// @brief Convert string from local codepage to host codepage. | |
| 118 | + iconv_t host; | |
| 119 | + | |
| 120 | + } converter; | |
| 121 | +#endif | |
| 122 | + | |
| 123 | + /// @brief Converte charset. | |
| 124 | + static std::string convertCharset(iconv_t &converter, const char *str); | |
| 125 | + | |
| 126 | + protected: | |
| 127 | + | |
| 128 | + /// @brief Current in/out position. | |
| 129 | + int baddr; | |
| 130 | + | |
| 131 | + Session(); | |
| 132 | + virtual ~Session(); | |
| 133 | + | |
| 134 | + /// @brief Setup charsets | |
| 135 | + void setCharSet(const char *remote, const char *local = SYSTEM_CHARSET); | |
| 136 | + | |
| 137 | + /// @brief Converte string recebida do host para o charset atual. | |
| 138 | + std::string convertFromHost(const char *str) const; | |
| 139 | + | |
| 140 | + /// @brief Converte string do charset atual para o charset do host. | |
| 141 | + std::string convertToHost(const char *str) const; | |
| 142 | + | |
| 143 | + }; | |
| 144 | + | |
| 145 | + } | |
| 146 | + | |
| 147 | + /// @brief lib3270 direct access objects (no IPC); | |
| 148 | + namespace Local { | |
| 149 | + | |
| 150 | + class TN3270_PRIVATE Session : public TN3270::Abstract::Session { | |
| 151 | + private: | |
| 152 | + | |
| 153 | + /// @brief Handle of the related instance of lib3270 | |
| 154 | + H3270 * hSession; | |
| 155 | + | |
| 156 | + /// @brief Mutex to serialize access to lib3270 | |
| 157 | + std::mutex sync; | |
| 158 | + | |
| 159 | + /// @brief Popup Handler. | |
| 160 | + static void popupHandler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | |
| 161 | + | |
| 162 | + /// @brief Connect Handler. | |
| 163 | + static void connectHandler(H3270 *session, unsigned char connected); | |
| 164 | + | |
| 165 | + /// @brief Wait for network events | |
| 166 | + void wait(time_t timeout = 5); | |
| 167 | + | |
| 168 | + public: | |
| 169 | + Session(); | |
| 170 | + virtual ~Session(); | |
| 171 | + | |
| 172 | + // Connect/disconnect | |
| 173 | + void connect(const char *url) override; | |
| 174 | + void disconnect() override; | |
| 175 | + | |
| 176 | + // Wait for session state. | |
| 177 | + void waitForReady(time_t timeout = 5) throw() override; | |
| 178 | + | |
| 179 | + // Get properties. | |
| 180 | + void getProperty(const char *name, int &value) const override; | |
| 181 | + void getProperty(const char *name, std::string &value) const override; | |
| 182 | + void getProperty(const char *name, bool &value) const override; | |
| 183 | + | |
| 184 | + std::string getVersion() const override; | |
| 185 | + std::string getRevision() const override; | |
| 186 | + | |
| 187 | + // Gets | |
| 188 | + std::string toString(int baddr, size_t len, char lf) const override; | |
| 189 | + std::string toString(int row, int col, size_t sz, char lf) const override; | |
| 190 | + | |
| 191 | + ProgramMessage getProgramMessage() const override; | |
| 192 | + | |
| 193 | + ConnectionState getConnectionState() const override; | |
| 194 | + | |
| 195 | + TN3270::Session & setCursorPosition(unsigned short addr) override; | |
| 196 | + TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | |
| 197 | + | |
| 198 | + /// @brief Set field at current posicion, jumps to next writable field. | |
| 199 | + TN3270::Session & push(const char *text) override; | |
| 200 | + | |
| 201 | + TN3270::Session & push(int baddr, const std::string &text) override; | |
| 202 | + TN3270::Session & push(int row, int col, const std::string &text) override; | |
| 203 | + TN3270::Session & push(const PFKey key) override; | |
| 204 | + TN3270::Session & push(const PAKey key) override; | |
| 205 | + TN3270::Session & push(const Action action) override; | |
| 206 | + | |
| 207 | + // Get contents. | |
| 208 | + TN3270::Session & pop(int baddr, std::string &text) override; | |
| 209 | + TN3270::Session & pop(int row, int col, std::string &text) override; | |
| 210 | + TN3270::Session & pop(std::string &text) override; | |
| 211 | + | |
| 212 | + /// @brief Execute action by name. | |
| 213 | + TN3270::Session & action(const char *action_name) override; | |
| 214 | + | |
| 215 | + }; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | + /// @brief IPC Based acess (Access and active instance of pw3270 or pw3270d) | |
| 220 | + namespace IPC { | |
| 221 | + | |
| 222 | + class Session; | |
| 223 | + | |
| 224 | + /// @brief PW3270 IPC Request/Response. | |
| 225 | + class Request { | |
| 226 | + private: | |
| 227 | + | |
| 228 | +#ifdef _WIN32 | |
| 229 | + /// @brief Pipe Handle. | |
| 230 | + HANDLE hPipe; | |
| 231 | + | |
| 232 | + /// @brief IPC Data type. | |
| 233 | + enum Type : uint8_t { | |
| 234 | + String = 's', | |
| 235 | + Boolean = 'b', | |
| 236 | + Uchar = 'y', | |
| 237 | + Int16 = 'n', | |
| 238 | + Uint16 = 'q', | |
| 239 | + Int32 = 'i', | |
| 240 | + Int32x = 'h', | |
| 241 | + Uint32 = 'u', | |
| 242 | + Int64 = 'x', | |
| 243 | + Uint64 = 't' | |
| 244 | + }; | |
| 245 | + | |
| 246 | + struct { | |
| 247 | + DWORD length; ///< @brief Length of input buffer. | |
| 248 | + DWORD used; ///< @brief Length of used block. | |
| 249 | + DWORD current; ///< @brief Offset of the current argument. | |
| 250 | + uint8_t * block; | |
| 251 | + } in; | |
| 252 | + | |
| 253 | + struct { | |
| 254 | + DWORD length; | |
| 255 | + DWORD used; | |
| 256 | + uint8_t * block; | |
| 257 | + } out; | |
| 258 | + | |
| 259 | + struct DataBlock { | |
| 260 | + Type type; | |
| 261 | + }; | |
| 262 | + | |
| 263 | + /// @brief Store value on data block. | |
| 264 | + DataBlock * pushBlock(const void *ptr, size_t len); | |
| 265 | + | |
| 266 | + /// @brief Get next argument. | |
| 267 | + DataBlock * getNextBlock() const; | |
| 268 | + | |
| 269 | +#else | |
| 270 | + struct { | |
| 271 | + DBusMessage * in; | |
| 272 | + DBusMessage * out; | |
| 273 | + DBusMessageIter iter; | |
| 274 | + | |
| 275 | + } msg; | |
| 276 | + DBusConnection * conn; | |
| 277 | + | |
| 278 | +#endif // _WIN32 | |
| 279 | + | |
| 280 | + Request(const Session &session); | |
| 281 | + | |
| 282 | + public: | |
| 283 | + | |
| 284 | + /// @brief Create a method call. | |
| 285 | + Request(const Session &session, const char *method); | |
| 286 | + | |
| 287 | + /// @brief Create a get/set property call. | |
| 288 | + /// | |
| 289 | + /// @param session Session object. | |
| 290 | + /// @param isSet true if this is a setProperty call. | |
| 291 | + /// @param property Property name. | |
| 292 | + // | |
| 293 | + Request(const Session &session, bool isSet, const char *property); | |
| 294 | + | |
| 295 | + ~Request(); | |
| 296 | + | |
| 297 | + Request & call(); | |
| 298 | + | |
| 299 | + // Push values | |
| 300 | + Request & push(const char *arg); | |
| 301 | + Request & push(const bool arg); | |
| 302 | + Request & push(const int32_t arg); | |
| 303 | + Request & push(const uint32_t arg); | |
| 304 | + Request & push(const uint8_t arg); | |
| 305 | + | |
| 306 | + // Pop values | |
| 307 | + Request & pop(std::string &value); | |
| 308 | + Request & pop(int &value); | |
| 309 | + | |
| 310 | + }; | |
| 311 | + | |
| 312 | + class TN3270_PRIVATE Session : public TN3270::Abstract::Session { | |
| 313 | + private: | |
| 314 | + | |
| 315 | + friend class Request; | |
| 316 | + | |
| 317 | +#ifdef _WIN32 | |
| 318 | + /// @brief Pipe Handle. | |
| 319 | + HANDLE hPipe; | |
| 320 | +#else | |
| 321 | + | |
| 322 | + DBusConnection * conn; | |
| 323 | + std::string name; ///< @brief D-Bus Object name. | |
| 324 | + std::string path; ///< @brief D-Bus Object path. | |
| 325 | + std::string interface; ///< @brief D-Bus interface. | |
| 326 | + | |
| 327 | +#endif // _WIN32 | |
| 328 | + | |
| 329 | + void call(Request &request); | |
| 330 | + | |
| 331 | + public: | |
| 332 | + | |
| 333 | + Session(const char *id); | |
| 334 | + virtual ~Session(); | |
| 335 | + | |
| 336 | + // Connect/disconnect | |
| 337 | + void connect(const char *url) override; | |
| 338 | + void disconnect() override; | |
| 339 | + | |
| 340 | + // Wait for session state. | |
| 341 | + void waitForReady(time_t timeout = 5) override; | |
| 342 | + | |
| 343 | + // Get properties. | |
| 344 | + void getProperty(const char *name, int &value) const override; | |
| 345 | + void getProperty(const char *name, std::string &value) const override; | |
| 346 | + void getProperty(const char *name, bool &value) const override; | |
| 347 | + | |
| 348 | + std::string getVersion() const override; | |
| 349 | + std::string getRevision() const override; | |
| 350 | + | |
| 351 | + // Gets | |
| 352 | + std::string toString(int baddr, size_t len, char lf) const override; | |
| 353 | + std::string toString(int row, int col, size_t sz, char lf) const override; | |
| 354 | + | |
| 355 | + ProgramMessage getProgramMessage() const override; | |
| 356 | + | |
| 357 | + ConnectionState getConnectionState() const override; | |
| 358 | + | |
| 359 | + TN3270::Session & setCursorPosition(unsigned short addr) override; | |
| 360 | + TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | |
| 361 | + | |
| 362 | + /// @brief Set field at current posicion, jumps to next writable field. | |
| 363 | + TN3270::Session & push(const char *text) override; | |
| 364 | + | |
| 365 | + TN3270::Session & push(int baddr, const std::string &text) override; | |
| 366 | + TN3270::Session & push(int row, int col, const std::string &text) override; | |
| 367 | + TN3270::Session & push(const PFKey key) override; | |
| 368 | + TN3270::Session & push(const PAKey key) override; | |
| 369 | + TN3270::Session & push(const Action action) override; | |
| 370 | + | |
| 371 | + // Get contents. | |
| 372 | + TN3270::Session & pop(int baddr, std::string &text) override; | |
| 373 | + TN3270::Session & pop(int row, int col, std::string &text) override; | |
| 374 | + TN3270::Session & pop(std::string &text) override; | |
| 375 | + | |
| 376 | + /// @brief Execute action by name. | |
| 377 | + TN3270::Session & action(const char *action_name) override; | |
| 378 | + | |
| 379 | + }; | |
| 380 | + | |
| 381 | + } | |
| 382 | + | |
| 383 | + } | |
| 384 | + | |
| 385 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,177 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/session/local/events.cc | |
| 32 | + * | |
| 33 | + * @brief Implement lib3270 direct access events. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + #include <stdio.h> | |
| 41 | + #include <cstring> | |
| 42 | + #include <malloc.h> | |
| 43 | + | |
| 44 | + extern "C" { | |
| 45 | + #include <lib3270/actions.h> | |
| 46 | + #include <lib3270/session.h> | |
| 47 | + } | |
| 48 | + | |
| 49 | + using std::string; | |
| 50 | + | |
| 51 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 52 | + | |
| 53 | +#ifndef HAVE_VASPRINTF | |
| 54 | + int vasprintf(char **strp, const char *fmt, va_list ap) { | |
| 55 | + char buf[1024]; | |
| 56 | + | |
| 57 | + int nc = vsnprintf(buf, sizeof(buf), fmt, ap); | |
| 58 | + | |
| 59 | + if(nc < 0) { | |
| 60 | + | |
| 61 | + *strp = strdup(_("Error in vasprintf")); | |
| 62 | + | |
| 63 | + } else if (nc < sizeof(buf)) { | |
| 64 | + | |
| 65 | + *strp = (char *) malloc(nc+1); | |
| 66 | + strcpy(*strp, buf); | |
| 67 | + | |
| 68 | + } else { | |
| 69 | + | |
| 70 | + *strp = (char *) malloc(nc + 1); | |
| 71 | + if(vsnprintf(*strp, nc, fmt, ap) < 0) { | |
| 72 | + free(*strp); | |
| 73 | + *strp = strdup( _( "Out of memory in vasprintf" ) ); | |
| 74 | + } | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 78 | + return nc; | |
| 79 | + } | |
| 80 | +#endif // !HAVE_VASPRINTF | |
| 81 | + | |
| 82 | + namespace TN3270 { | |
| 83 | + | |
| 84 | + /// @brief Popup Handler. | |
| 85 | + void Local::Session::popupHandler(H3270 *h3270, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) { | |
| 86 | + | |
| 87 | + Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); | |
| 88 | + | |
| 89 | + if(!session) { | |
| 90 | + throw std::runtime_error(_( "Invalid session handler" )); | |
| 91 | + } | |
| 92 | + | |
| 93 | + class PopupEvent : public TN3270::Event { | |
| 94 | + private: | |
| 95 | + LIB3270_NOTIFY type; | |
| 96 | + string title; | |
| 97 | + string msg; | |
| 98 | + string description; | |
| 99 | + | |
| 100 | + public: | |
| 101 | + PopupEvent(LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) : Event(Event::Popup) { | |
| 102 | + | |
| 103 | + this->type = type; | |
| 104 | + this->title = title; | |
| 105 | + this->msg = msg; | |
| 106 | + | |
| 107 | + char * buffer = NULL; | |
| 108 | + if(vasprintf(&buffer,fmt,arg) != -1) { | |
| 109 | + this->description = buffer; | |
| 110 | + free(buffer); | |
| 111 | + } | |
| 112 | + | |
| 113 | +#ifdef DEBUG | |
| 114 | + std::cerr << "Popup:" << std::endl | |
| 115 | + << "\t" << title << std::endl | |
| 116 | + << "\t" << msg << std::endl | |
| 117 | + << "\t" << description << std::endl; | |
| 118 | +#endif // DEBUG | |
| 119 | + | |
| 120 | + } | |
| 121 | + | |
| 122 | + virtual ~PopupEvent() { | |
| 123 | + } | |
| 124 | + | |
| 125 | + /// @brief Get event description. | |
| 126 | + std::string toString() const override { | |
| 127 | + return msg; | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + }; | |
| 132 | + | |
| 133 | + session->fire(PopupEvent(type,title,msg,fmt,arg)); | |
| 134 | + | |
| 135 | + } | |
| 136 | + | |
| 137 | + /// @brief Connect Handler. | |
| 138 | + void Local::Session::connectHandler(H3270 *h3270, unsigned char connected) { | |
| 139 | + | |
| 140 | + Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); | |
| 141 | + | |
| 142 | + if(!session) { | |
| 143 | + throw std::runtime_error(_("Invalid session handler")); | |
| 144 | + } | |
| 145 | + | |
| 146 | + class ConnectionEvent : public TN3270::Event { | |
| 147 | + private: | |
| 148 | + bool connected; | |
| 149 | + | |
| 150 | + public: | |
| 151 | + ConnectionEvent(unsigned char connected) : Event(Event::Connection) { | |
| 152 | + this->connected = (connected != 0); | |
| 153 | + | |
| 154 | +#ifdef DEBUG | |
| 155 | + std::cerr << "Session is " << this->toString().c_str() << std::endl; | |
| 156 | +#endif // DEBUG | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + virtual ~ConnectionEvent() { | |
| 161 | + } | |
| 162 | + | |
| 163 | + /// @brief Get event description. | |
| 164 | + std::string toString() const override { | |
| 165 | + return this->connected ? _("connected") : _("disconnected"); | |
| 166 | + } | |
| 167 | + | |
| 168 | + }; | |
| 169 | + | |
| 170 | + session->fire(ConnectionEvent(connected)); | |
| 171 | + | |
| 172 | + } | |
| 173 | + | |
| 174 | + | |
| 175 | + } | |
| 176 | + | |
| 177 | + | ... | ... |
| ... | ... | @@ -0,0 +1,389 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/session/local/session.cc | |
| 32 | + * | |
| 33 | + * @brief Implement lib3270 direct access layout (NO IPC). | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + #include <lib3270/actions.h> | |
| 41 | + #include <lib3270/properties.h> | |
| 42 | + #include <cstring> | |
| 43 | + | |
| 44 | + extern "C" { | |
| 45 | + #include <lib3270/session.h> | |
| 46 | + } | |
| 47 | + | |
| 48 | + using std::string; | |
| 49 | + | |
| 50 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 51 | + | |
| 52 | + namespace TN3270 { | |
| 53 | + | |
| 54 | + Local::Session::Session() : Abstract::Session() { | |
| 55 | + | |
| 56 | + std::lock_guard<std::mutex> lock(sync); | |
| 57 | + | |
| 58 | + this->hSession = lib3270_session_new(""); | |
| 59 | + lib3270_set_user_data(this->hSession,(void *) this); | |
| 60 | + setCharSet(lib3270_get_display_charset(this->hSession)); | |
| 61 | + | |
| 62 | + lib3270_set_popup_handler(this->hSession, popupHandler); | |
| 63 | + | |
| 64 | + // Setup callbacks | |
| 65 | + struct lib3270_session_callbacks *cbk; | |
| 66 | + | |
| 67 | + cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks)); | |
| 68 | + if(!cbk) { | |
| 69 | + throw std::runtime_error( _("Invalid callback table, possible version mismatch in lib3270") ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + cbk->update_connect = connectHandler; | |
| 73 | + | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | + Local::Session::~Session() { | |
| 78 | + | |
| 79 | + std::lock_guard<std::mutex> lock(sync); | |
| 80 | + | |
| 81 | + lib3270_session_free(this->hSession); | |
| 82 | + this->hSession = nullptr; | |
| 83 | + } | |
| 84 | + | |
| 85 | + void Local::Session::wait(time_t timeout) { | |
| 86 | + | |
| 87 | + std::lock_guard<std::mutex> lock(sync); | |
| 88 | + | |
| 89 | + int rc = lib3270_wait_for_ready(this->hSession, timeout); | |
| 90 | + | |
| 91 | + if(rc) { | |
| 92 | + throw std::system_error(rc, std::system_category()); | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + void Local::Session::connect(const char *url) { | |
| 98 | + std::lock_guard<std::mutex> lock(sync); | |
| 99 | + int rc = lib3270_connect_url(hSession,url,0); | |
| 100 | + | |
| 101 | + if(rc) { | |
| 102 | + throw std::system_error(rc, std::system_category()); | |
| 103 | + } | |
| 104 | + | |
| 105 | + } | |
| 106 | + | |
| 107 | + void Local::Session::disconnect() { | |
| 108 | + std::lock_guard<std::mutex> lock(sync); | |
| 109 | + lib3270_disconnect(hSession); | |
| 110 | + } | |
| 111 | + | |
| 112 | + // Wait for session state. | |
| 113 | + void Local::Session::waitForReady(time_t timeout) throw() { | |
| 114 | + this->wait(timeout); | |
| 115 | + } | |
| 116 | + | |
| 117 | + std::string Local::Session::toString(int baddr, size_t len, char lf) const { | |
| 118 | + | |
| 119 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 120 | + | |
| 121 | + char * text = lib3270_get_string_at_address(hSession, baddr, len, lf); | |
| 122 | + | |
| 123 | + if(!text) { | |
| 124 | + throw std::runtime_error( _("Can't get screen contents") ); | |
| 125 | + } | |
| 126 | + | |
| 127 | + string rc = convertFromHost(text); | |
| 128 | + | |
| 129 | + lib3270_free(text); | |
| 130 | + | |
| 131 | + return rc; | |
| 132 | + | |
| 133 | + } | |
| 134 | + | |
| 135 | + std::string Local::Session::toString(int row, int col, size_t sz, char lf) const { | |
| 136 | + | |
| 137 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 138 | + | |
| 139 | + char * text = lib3270_get_string_at(hSession, row, col, sz, lf); | |
| 140 | + | |
| 141 | + if(!text) { | |
| 142 | + throw std::runtime_error( _("Can't get screen contents") ); | |
| 143 | + } | |
| 144 | + | |
| 145 | + string rc = convertFromHost(text); | |
| 146 | + | |
| 147 | + lib3270_free(text); | |
| 148 | + | |
| 149 | + return rc; | |
| 150 | + } | |
| 151 | + | |
| 152 | + void Local::Session::getProperty(const char *name, int &value) const { | |
| 153 | + | |
| 154 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
| 155 | + for(size_t ix = 0; intprop[ix].name; ix++) { | |
| 156 | + | |
| 157 | + if(!strcasecmp(name,intprop[ix].name)) { | |
| 158 | + | |
| 159 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 160 | + | |
| 161 | + value = intprop[ix].get(hSession); | |
| 162 | + | |
| 163 | + if(value < 0 && errno != 0) { | |
| 164 | + throw std::system_error(errno, std::system_category()); | |
| 165 | + } | |
| 166 | + | |
| 167 | + | |
| 168 | + } | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | + throw std::system_error(ENOENT, std::system_category()); | |
| 173 | + | |
| 174 | + } | |
| 175 | + | |
| 176 | + void Local::Session::getProperty(const char *name, std::string &value) const { | |
| 177 | + | |
| 178 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
| 179 | + | |
| 180 | + for(size_t ix = 0; strprop[ix].name; ix++) { | |
| 181 | + | |
| 182 | + if(!strcasecmp(name,strprop[ix].name)) { | |
| 183 | + | |
| 184 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 185 | + | |
| 186 | + // Found it! | |
| 187 | + const char * str = strprop[ix].get(hSession); | |
| 188 | + | |
| 189 | + if(str) { | |
| 190 | + value.assign(str); | |
| 191 | + return; | |
| 192 | + } | |
| 193 | + | |
| 194 | + throw std::system_error(errno, std::system_category()); | |
| 195 | + | |
| 196 | + } | |
| 197 | + | |
| 198 | + } | |
| 199 | + | |
| 200 | + throw std::system_error(ENOENT, std::system_category()); | |
| 201 | + } | |
| 202 | + | |
| 203 | + void Local::Session::getProperty(const char *name, bool &value) const { | |
| 204 | + | |
| 205 | + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(name); | |
| 206 | + if(toggle != (LIB3270_TOGGLE) -1) { | |
| 207 | + | |
| 208 | + // Is a Tn3270 toggle, get it! | |
| 209 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 210 | + value = lib3270_get_toggle(hSession,toggle); | |
| 211 | + | |
| 212 | + } | |
| 213 | + | |
| 214 | + throw std::system_error(ENOENT, std::system_category()); | |
| 215 | + } | |
| 216 | + | |
| 217 | + ProgramMessage Local::Session::getProgramMessage() const { | |
| 218 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 219 | + return (ProgramMessage) lib3270_get_program_message(this->hSession); | |
| 220 | + } | |
| 221 | + | |
| 222 | + ConnectionState Local::Session::getConnectionState() const { | |
| 223 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 224 | + return (ConnectionState) lib3270_get_connection_state(this->hSession); | |
| 225 | + } | |
| 226 | + | |
| 227 | + /// @brief Set field at current position, jumps to next writable field. | |
| 228 | + TN3270::Session & Local::Session::push(const char *text) { | |
| 229 | + std::lock_guard<std::mutex> lock(sync); | |
| 230 | + return *this; | |
| 231 | + } | |
| 232 | + | |
| 233 | + TN3270::Session & Local::Session::push(int baddr, const std::string &text) { | |
| 234 | + std::lock_guard<std::mutex> lock(sync); | |
| 235 | + return *this; | |
| 236 | + } | |
| 237 | + | |
| 238 | + TN3270::Session & Local::Session::push(int row, int col, const std::string &text) { | |
| 239 | + std::lock_guard<std::mutex> lock(sync); | |
| 240 | + return *this; | |
| 241 | + } | |
| 242 | + | |
| 243 | + TN3270::Session & Local::Session::push(const PFKey key) { | |
| 244 | + std::lock_guard<std::mutex> lock(sync); | |
| 245 | + lib3270_pfkey(hSession,(int) key); | |
| 246 | + return *this; | |
| 247 | + } | |
| 248 | + | |
| 249 | + TN3270::Session & Local::Session::push(const PAKey key) { | |
| 250 | + std::lock_guard<std::mutex> lock(sync); | |
| 251 | + lib3270_pakey(hSession,(int) key); | |
| 252 | + return *this; | |
| 253 | + } | |
| 254 | + | |
| 255 | + TN3270::Session & Local::Session::push(const Action action) { | |
| 256 | + | |
| 257 | + typedef int (*ActionCallback)(H3270 *); | |
| 258 | + | |
| 259 | + static const ActionCallback actions[] = { | |
| 260 | + lib3270_enter, | |
| 261 | + lib3270_erase, | |
| 262 | + lib3270_eraseeof, | |
| 263 | + lib3270_eraseeol, | |
| 264 | + lib3270_eraseinput | |
| 265 | + }; | |
| 266 | + | |
| 267 | + if( ((size_t) action) > (sizeof(actions)/sizeof(actions[0]))) { | |
| 268 | + throw std::system_error(EINVAL, std::system_category()); | |
| 269 | + } | |
| 270 | + | |
| 271 | + std::lock_guard<std::mutex> lock(sync); | |
| 272 | + | |
| 273 | + int rc = actions[(size_t) action](hSession); | |
| 274 | + | |
| 275 | + if(rc) { | |
| 276 | + throw std::system_error(errno, std::system_category()); | |
| 277 | + } | |
| 278 | + | |
| 279 | + return *this; | |
| 280 | + } | |
| 281 | + | |
| 282 | + TN3270::Session & Local::Session::pop(int baddr, std::string &text) { | |
| 283 | + | |
| 284 | + std::lock_guard<std::mutex> lock(sync); | |
| 285 | + | |
| 286 | + if(!lib3270_is_connected(hSession)) { | |
| 287 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 288 | + } | |
| 289 | + | |
| 290 | + char *contents = lib3270_get_field_text_at(hSession, baddr); | |
| 291 | + | |
| 292 | + if(!contents) { | |
| 293 | + throw std::system_error(errno, std::system_category()); | |
| 294 | + } | |
| 295 | + | |
| 296 | + text.assign(convertFromHost(contents).c_str()); | |
| 297 | + | |
| 298 | + lib3270_free(contents); | |
| 299 | + | |
| 300 | + return *this; | |
| 301 | + } | |
| 302 | + | |
| 303 | + TN3270::Session & Local::Session::pop(int row, int col, std::string &text) { | |
| 304 | + return this->pop(lib3270_translate_to_address(hSession,row,col),text); | |
| 305 | + } | |
| 306 | + | |
| 307 | + TN3270::Session & Local::Session::pop(std::string &text) { | |
| 308 | + | |
| 309 | + std::lock_guard<std::mutex> lock(sync); | |
| 310 | + | |
| 311 | + if(!lib3270_is_connected(hSession)) { | |
| 312 | + throw std::system_error(ENOTCONN, std::system_category()); | |
| 313 | + } | |
| 314 | + | |
| 315 | + int baddr = lib3270_get_cursor_address(hSession); | |
| 316 | + if(baddr < 0) { | |
| 317 | + throw std::system_error(errno, std::system_category()); | |
| 318 | + } | |
| 319 | + | |
| 320 | + char *contents = lib3270_get_field_text_at(hSession, baddr); | |
| 321 | + | |
| 322 | + if(!contents) { | |
| 323 | + throw std::system_error(errno, std::system_category()); | |
| 324 | + } | |
| 325 | + | |
| 326 | + text.assign(convertFromHost(contents).c_str()); | |
| 327 | + | |
| 328 | + lib3270_free(contents); | |
| 329 | + | |
| 330 | + baddr = lib3270_get_next_unprotected(hSession,baddr); | |
| 331 | + if(!baddr) { | |
| 332 | + baddr = lib3270_get_next_unprotected(hSession,0); | |
| 333 | + } | |
| 334 | + | |
| 335 | + if(lib3270_set_cursor_address(hSession,baddr)) { | |
| 336 | + throw std::system_error(errno, std::system_category()); | |
| 337 | + } | |
| 338 | + | |
| 339 | + return *this; | |
| 340 | + } | |
| 341 | + | |
| 342 | + /// @brief Set cursor address. | |
| 343 | + /// | |
| 344 | + /// @param addr Cursor address. | |
| 345 | + TN3270::Session & Local::Session::setCursorPosition(unsigned short addr) { | |
| 346 | + | |
| 347 | + if(lib3270_set_cursor_address(hSession,addr) < 0) { | |
| 348 | + throw std::system_error(errno, std::system_category()); | |
| 349 | + } | |
| 350 | + | |
| 351 | + return *this; | |
| 352 | + } | |
| 353 | + | |
| 354 | + /// @brief Set cursor position. | |
| 355 | + /// | |
| 356 | + /// @param row New cursor row. | |
| 357 | + /// @param col New cursor column. | |
| 358 | + TN3270::Session & Local::Session::setCursorPosition(unsigned short row, unsigned short col) { | |
| 359 | + | |
| 360 | + if(lib3270_set_cursor_position(hSession,row,col)) { | |
| 361 | + throw std::system_error(errno, std::system_category()); | |
| 362 | + } | |
| 363 | + | |
| 364 | + return *this; | |
| 365 | + | |
| 366 | + } | |
| 367 | + | |
| 368 | + // Get properties. | |
| 369 | + std::string Local::Session::getVersion() const { | |
| 370 | + return lib3270_get_version(); | |
| 371 | + } | |
| 372 | + | |
| 373 | + std::string Local::Session::getRevision() const { | |
| 374 | + return lib3270_get_revision(); | |
| 375 | + } | |
| 376 | + | |
| 377 | + /// @brief Execute action by name. | |
| 378 | + TN3270::Session & Local::Session::action(const char *action_name) { | |
| 379 | + | |
| 380 | + if(lib3270_action(hSession,action_name)) { | |
| 381 | + throw std::system_error(errno, std::system_category()); | |
| 382 | + } | |
| 383 | + | |
| 384 | + return *this; | |
| 385 | + } | |
| 386 | + | |
| 387 | + } | |
| 388 | + | |
| 389 | + | ... | ... |
| ... | ... | @@ -0,0 +1,365 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/session/remote/session.cc | |
| 32 | + * | |
| 33 | + * @brief Implements lib3270 access using IPC calls. | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <ipc-client-internals.h> | |
| 40 | + #include <cstring> | |
| 41 | + | |
| 42 | + using std::string; | |
| 43 | + | |
| 44 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 45 | + | |
| 46 | + namespace TN3270 { | |
| 47 | + | |
| 48 | + void IPC::Session::connect(const char *url) { | |
| 49 | + Request request(*this,"connect"); | |
| 50 | + request.push(url).call(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + void IPC::Session::disconnect() { | |
| 54 | + Request(*this,"disconnect").call(); | |
| 55 | + } | |
| 56 | + | |
| 57 | + // Wait for session state. | |
| 58 | + void IPC::Session::waitForReady(time_t timeout) { | |
| 59 | + | |
| 60 | + int rc; | |
| 61 | + | |
| 62 | + time_t end = time(nullptr) + timeout; | |
| 63 | + | |
| 64 | + while(time(nullptr) < end) { | |
| 65 | + | |
| 66 | + debug("Running waitForReady request..."); | |
| 67 | + | |
| 68 | + Request(*this,"waitForReady") | |
| 69 | + .push((uint32_t) 1) | |
| 70 | + .call() | |
| 71 | + .pop(rc); | |
| 72 | + | |
| 73 | + debug("Wait for ready returned ",rc); | |
| 74 | + | |
| 75 | + if(rc == 0) | |
| 76 | + return; | |
| 77 | + | |
| 78 | + } | |
| 79 | + | |
| 80 | + throw std::system_error(ETIMEDOUT, std::system_category()); | |
| 81 | + } | |
| 82 | + | |
| 83 | + std::string IPC::Session::toString(int baddr, size_t len, char lf) const { | |
| 84 | + | |
| 85 | + std::string rc; | |
| 86 | + | |
| 87 | + Request(*this,"getStringAtAddress") | |
| 88 | + .push((uint32_t) baddr) | |
| 89 | + .push((uint32_t) len) | |
| 90 | + .push((uint8_t) lf) | |
| 91 | + .call() | |
| 92 | + .pop(rc); | |
| 93 | + | |
| 94 | + return rc; | |
| 95 | + } | |
| 96 | + | |
| 97 | + std::string IPC::Session::toString(int row, int col, size_t sz, char lf) const { | |
| 98 | + | |
| 99 | + std::string rc; | |
| 100 | + | |
| 101 | + Request(*this,"getStringAt") | |
| 102 | + .push((uint32_t) row) | |
| 103 | + .push((uint32_t) col) | |
| 104 | + .push((uint32_t) sz) | |
| 105 | + .push((uint8_t) lf) | |
| 106 | + .call() | |
| 107 | + .pop(rc); | |
| 108 | + | |
| 109 | + return rc; | |
| 110 | + } | |
| 111 | + | |
| 112 | + ProgramMessage IPC::Session::getProgramMessage() const { | |
| 113 | + | |
| 114 | + int program_message; | |
| 115 | + getProperty("program_message",program_message); | |
| 116 | + return (ProgramMessage) program_message; | |
| 117 | + | |
| 118 | + } | |
| 119 | + | |
| 120 | + ConnectionState IPC::Session::getConnectionState() const { | |
| 121 | + | |
| 122 | + int cstate; | |
| 123 | + getProperty("cstate",cstate); | |
| 124 | + return (ConnectionState) cstate; | |
| 125 | + | |
| 126 | + } | |
| 127 | + | |
| 128 | + /// @brief Set field at current position, jumps to next writable field. | |
| 129 | + TN3270::Session & IPC::Session::push(const char *text) { | |
| 130 | + | |
| 131 | + int rc; | |
| 132 | + | |
| 133 | + Request(*this,"setString") | |
| 134 | + .push(text) | |
| 135 | + .call() | |
| 136 | + .pop(rc); | |
| 137 | + | |
| 138 | + if(rc) { | |
| 139 | + throw std::system_error((int) rc, std::system_category()); | |
| 140 | + } | |
| 141 | + | |
| 142 | + return *this; | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + TN3270::Session & IPC::Session::push(int baddr, const std::string &text) { | |
| 147 | + | |
| 148 | + int rc; | |
| 149 | + | |
| 150 | + Request(*this,"setStringAtAddress") | |
| 151 | + .push((uint32_t) baddr) | |
| 152 | + .push(text.c_str()) | |
| 153 | + .call() | |
| 154 | + .pop(rc); | |
| 155 | + | |
| 156 | + if(rc) { | |
| 157 | + throw std::system_error((int) rc, std::system_category()); | |
| 158 | + } | |
| 159 | + | |
| 160 | + return *this; | |
| 161 | + | |
| 162 | + } | |
| 163 | + | |
| 164 | + TN3270::Session & IPC::Session::push(int row, int col, const std::string &text) { | |
| 165 | + | |
| 166 | + int32_t rc; | |
| 167 | + | |
| 168 | + Request(*this,"setStringAt") | |
| 169 | + .push((uint32_t) row) | |
| 170 | + .push((uint32_t) col) | |
| 171 | + .push(text.c_str()) | |
| 172 | + .call() | |
| 173 | + .pop(rc); | |
| 174 | + | |
| 175 | + if(rc) { | |
| 176 | + throw std::system_error((int) rc, std::system_category()); | |
| 177 | + } | |
| 178 | + | |
| 179 | + return *this; | |
| 180 | + | |
| 181 | + } | |
| 182 | + | |
| 183 | + TN3270::Session & IPC::Session::push(const PFKey key) { | |
| 184 | + | |
| 185 | + int32_t rc; | |
| 186 | + | |
| 187 | + Request(*this,"pfkey") | |
| 188 | + .push((uint32_t) key) | |
| 189 | + .call() | |
| 190 | + .pop(rc); | |
| 191 | + | |
| 192 | + if(rc) { | |
| 193 | + throw std::system_error((int) rc, std::system_category()); | |
| 194 | + } | |
| 195 | + | |
| 196 | + return *this; | |
| 197 | + | |
| 198 | + } | |
| 199 | + | |
| 200 | + TN3270::Session & IPC::Session::push(const PAKey key) { | |
| 201 | + | |
| 202 | + int32_t rc; | |
| 203 | + | |
| 204 | + Request(*this,"pakey") | |
| 205 | + .push((uint32_t) key) | |
| 206 | + .call() | |
| 207 | + .pop(rc); | |
| 208 | + | |
| 209 | + if(rc) { | |
| 210 | + throw std::system_error((int) rc, std::system_category()); | |
| 211 | + } | |
| 212 | + | |
| 213 | + return *this; | |
| 214 | + | |
| 215 | + } | |
| 216 | + | |
| 217 | + TN3270::Session & IPC::Session::push(const Action action) { | |
| 218 | + | |
| 219 | + const char * actions[] = { | |
| 220 | + "enter", | |
| 221 | + "erase", | |
| 222 | + "eraseeof", | |
| 223 | + "eraseeol", | |
| 224 | + "eraseinput" | |
| 225 | + }; | |
| 226 | + | |
| 227 | + if( ((size_t) action) > (sizeof(actions)/sizeof(actions[0]))) { | |
| 228 | + throw std::system_error(EINVAL, std::system_category()); | |
| 229 | + } | |
| 230 | + | |
| 231 | + return this->action(actions[action]); | |
| 232 | + | |
| 233 | + } | |
| 234 | + | |
| 235 | + TN3270::Session & IPC::Session::pop(int baddr, std::string &text) { | |
| 236 | + | |
| 237 | + Request(*this,"getFieldAtAddress") | |
| 238 | + .push((uint32_t) baddr) | |
| 239 | + .call() | |
| 240 | + .pop(text); | |
| 241 | + | |
| 242 | + return *this; | |
| 243 | + } | |
| 244 | + | |
| 245 | + TN3270::Session & IPC::Session::pop(int row, int col, std::string &text) { | |
| 246 | + | |
| 247 | + Request(*this,"getFieldAt") | |
| 248 | + .push((uint32_t) row) | |
| 249 | + .push((uint32_t) col) | |
| 250 | + .call() | |
| 251 | + .pop(text); | |
| 252 | + | |
| 253 | + return *this; | |
| 254 | + } | |
| 255 | + | |
| 256 | + TN3270::Session & IPC::Session::pop(std::string &text) { | |
| 257 | + | |
| 258 | + Request(*this,"getFieldAtCursor") | |
| 259 | + .call() | |
| 260 | + .pop(text); | |
| 261 | + | |
| 262 | + return *this; | |
| 263 | + | |
| 264 | + } | |
| 265 | + | |
| 266 | + /// @brief Set cursor address. | |
| 267 | + /// | |
| 268 | + /// @param addr Cursor address. | |
| 269 | + TN3270::Session & IPC::Session::setCursorPosition(unsigned short addr) { | |
| 270 | + | |
| 271 | + int32_t rc; | |
| 272 | + | |
| 273 | + Request(*this,"setCursorAddress") | |
| 274 | + .push((uint32_t) addr) | |
| 275 | + .call() | |
| 276 | + .pop(rc); | |
| 277 | + | |
| 278 | + if(rc) { | |
| 279 | + throw std::system_error((int) rc, std::system_category()); | |
| 280 | + } | |
| 281 | + | |
| 282 | + return *this; | |
| 283 | + | |
| 284 | + } | |
| 285 | + | |
| 286 | + /// @brief Set cursor position. | |
| 287 | + /// | |
| 288 | + /// @param row New cursor row. | |
| 289 | + /// @param col New cursor column. | |
| 290 | + TN3270::Session & IPC::Session::setCursorPosition(unsigned short row, unsigned short col) { | |
| 291 | + | |
| 292 | + int32_t rc; | |
| 293 | + | |
| 294 | + Request(*this,"setCursorPosition") | |
| 295 | + .push((uint32_t) row) | |
| 296 | + .push((uint32_t) col) | |
| 297 | + .call() | |
| 298 | + .pop(rc); | |
| 299 | + | |
| 300 | + if(rc) { | |
| 301 | + throw std::system_error((int) rc, std::system_category()); | |
| 302 | + } | |
| 303 | + | |
| 304 | + return *this; | |
| 305 | + | |
| 306 | + } | |
| 307 | + | |
| 308 | + void IPC::Session::getProperty(const char *name, int &value) const { | |
| 309 | + | |
| 310 | + Request(*this,false,name) | |
| 311 | + .call() | |
| 312 | + .pop(value); | |
| 313 | + | |
| 314 | + } | |
| 315 | + | |
| 316 | + void IPC::Session::getProperty(const char *name, std::string &value) const { | |
| 317 | + | |
| 318 | + Request(*this,false,name) | |
| 319 | + .call() | |
| 320 | + .pop(value); | |
| 321 | + | |
| 322 | + } | |
| 323 | + | |
| 324 | + void IPC::Session::getProperty(const char *name, bool &value) const { | |
| 325 | + throw std::system_error(ENOENT, std::system_category()); | |
| 326 | + } | |
| 327 | + | |
| 328 | + /// @brief Get lib3270 version. | |
| 329 | + std::string IPC::Session::getVersion() const { | |
| 330 | + | |
| 331 | + string rc; | |
| 332 | + getProperty("version",rc); | |
| 333 | + return rc; | |
| 334 | + | |
| 335 | + } | |
| 336 | + | |
| 337 | + /// @brief Get lib3270 revision. | |
| 338 | + std::string IPC::Session::getRevision() const { | |
| 339 | + | |
| 340 | + string rc; | |
| 341 | + getProperty("revision",rc); | |
| 342 | + return rc; | |
| 343 | + | |
| 344 | + } | |
| 345 | + | |
| 346 | + /// @brief Execute action by name. | |
| 347 | + TN3270::Session & IPC::Session::action(const char *action_name) { | |
| 348 | + | |
| 349 | + int32_t rc; | |
| 350 | + | |
| 351 | + Request(*this,"action") | |
| 352 | + .push(action_name) | |
| 353 | + .call() | |
| 354 | + .pop(rc); | |
| 355 | + | |
| 356 | + if(rc) { | |
| 357 | + throw std::system_error((int) rc, std::system_category()); | |
| 358 | + } | |
| 359 | + | |
| 360 | + return *this; | |
| 361 | + } | |
| 362 | + | |
| 363 | + } | |
| 364 | + | |
| 365 | + | ... | ... |
| ... | ... | @@ -0,0 +1,103 @@ |
| 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 - 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 | +/** | |
| 31 | + * @file src/lib3270++/testprogram/testprogram.cc | |
| 32 | + * | |
| 33 | + * @brief | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include <getopt.h> | |
| 40 | + #include <cstdlib> | |
| 41 | + #include <lib3270++.h> | |
| 42 | + | |
| 43 | + using namespace std; | |
| 44 | + | |
| 45 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 46 | + | |
| 47 | + int main(int argc, char **argv) { | |
| 48 | + | |
| 49 | + const char * session = "pw3270:a"; | |
| 50 | + | |
| 51 | + #pragma GCC diagnostic push | |
| 52 | + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | |
| 53 | + static struct option options[] = { | |
| 54 | + { "session", required_argument, 0, 's' }, | |
| 55 | + { 0, 0, 0, 0} | |
| 56 | + | |
| 57 | + }; | |
| 58 | + #pragma GCC diagnostic pop | |
| 59 | + | |
| 60 | + int long_index =0; | |
| 61 | + int opt; | |
| 62 | + while((opt = getopt_long(argc, argv, "s:", options, &long_index )) != -1) { | |
| 63 | + | |
| 64 | + switch(opt) { | |
| 65 | + case 's': | |
| 66 | + session = optarg; | |
| 67 | + break; | |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + } | |
| 72 | + | |
| 73 | + TN3270::Host host{session}; | |
| 74 | + | |
| 75 | + try { | |
| 76 | + | |
| 77 | + cout | |
| 78 | + << "Version: " << host.getVersion() | |
| 79 | + << "\tRevision: " << host.getRevision() | |
| 80 | + << std::endl; | |
| 81 | + | |
| 82 | + cout | |
| 83 | + << "Connection state is " << host.getConnectionState() | |
| 84 | + << "\tProgram message is " << host.getProgramMessage() | |
| 85 | + << std::endl; | |
| 86 | + | |
| 87 | + // host.connect(getenv("LIB3270_DEFAULT_HOST")); | |
| 88 | + | |
| 89 | + if(host) { | |
| 90 | + cout << host << endl; | |
| 91 | + } | |
| 92 | + | |
| 93 | + } catch(const std::exception &e) { | |
| 94 | + | |
| 95 | + cerr << std::endl << e.what() << std::endl << std::endl; | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + return 0; | |
| 101 | + } | |
| 102 | + | |
| 103 | + | ... | ... |
common/src/include/config.h.in
configure.ac
| ... | ... | @@ -50,6 +50,7 @@ AM_ICONV |
| 50 | 50 | |
| 51 | 51 | dnl Checks for programs. |
| 52 | 52 | AC_PROG_CC |
| 53 | +AC_PROG_CXX | |
| 53 | 54 | AC_PROG_SED |
| 54 | 55 | AC_PROG_LN_S |
| 55 | 56 | |
| ... | ... | @@ -84,8 +85,9 @@ case "$host" in |
| 84 | 85 | |
| 85 | 86 | app_win32_revision=$(date +%y.%m.%d.%H) |
| 86 | 87 | AC_SUBST(WIN32_VERSION,$app_win32_revision) |
| 87 | - AC_CONFIG_FILES(src/service/windows/resources.rc) | |
| 88 | - AC_CONFIG_FILES(src/plugin/windows/resources.rc) | |
| 88 | + AC_CONFIG_FILES(server/src/plugin/windows/resources.rc) | |
| 89 | + AC_CONFIG_FILES(server/src/service/windows/resources.rc) | |
| 90 | + AC_CONFIG_FILES(client/src/core/windows/resources.rc) | |
| 89 | 91 | ;; |
| 90 | 92 | |
| 91 | 93 | *) |
| ... | ... | @@ -107,6 +109,8 @@ AC_SUBST(LOGDIR) |
| 107 | 109 | AC_SUBST(DLLEXT) |
| 108 | 110 | AC_SUBST(DLLPREFIX) |
| 109 | 111 | |
| 112 | +AC_CHECK_FUNC(vasprintf, AC_DEFINE(HAVE_VASPRINTF) ) | |
| 113 | + | |
| 110 | 114 | dnl --------------------------------------------------------------------------- |
| 111 | 115 | dnl Check for other programs |
| 112 | 116 | dnl --------------------------------------------------------------------------- |
| ... | ... | @@ -285,6 +289,7 @@ dnl Configure which files to generate. |
| 285 | 289 | dnl --------------------------------------------------------------------------- |
| 286 | 290 | |
| 287 | 291 | AC_CONFIG_FILES(server/Makefile) |
| 292 | +AC_CONFIG_FILES(client/Makefile) | |
| 288 | 293 | |
| 289 | 294 | dnl --------------------------------------------------------------------------- |
| 290 | 295 | dnl Output the generated config.status script. | ... | ... |
src/client/lib3270++.cbp
| ... | ... | @@ -1,70 +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="C++ Bindings for lib3270" /> | |
| 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/lib3270++" 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 | - <Add option="-DDEBUG=1" /> | |
| 18 | - </Compiler> | |
| 19 | - </Target> | |
| 20 | - <Target title="Release"> | |
| 21 | - <Option output=".bin/Release/C++ Bindings for lib3270" prefix_auto="1" extension_auto="1" /> | |
| 22 | - <Option object_output=".obj/Release/" /> | |
| 23 | - <Option type="1" /> | |
| 24 | - <Option compiler="gcc" /> | |
| 25 | - <Compiler> | |
| 26 | - <Add option="-O2" /> | |
| 27 | - <Add option="-std=c++11" /> | |
| 28 | - <Add option="-DNDEBUG=1" /> | |
| 29 | - </Compiler> | |
| 30 | - <Linker> | |
| 31 | - <Add option="-s" /> | |
| 32 | - </Linker> | |
| 33 | - </Target> | |
| 34 | - </Build> | |
| 35 | - <Compiler> | |
| 36 | - <Add option="-Wall" /> | |
| 37 | - <Add option="`pkg-config --clags lib3270`" /> | |
| 38 | - <Add directory="../include" /> | |
| 39 | - </Compiler> | |
| 40 | - <Linker> | |
| 41 | - <Add option="`pkg-config --libs lib3270`" /> | |
| 42 | - </Linker> | |
| 43 | - <Unit filename="../include/config.h.in" /> | |
| 44 | - <Unit filename="../include/lib3270++.h" /> | |
| 45 | - <Unit filename="../include/lib3270.h" /> | |
| 46 | - <Unit filename="../include/lib3270/action_table.h" /> | |
| 47 | - <Unit filename="../include/lib3270/actions.h" /> | |
| 48 | - <Unit filename="../include/lib3270/popup.h" /> | |
| 49 | - <Unit filename="../include/lib3270/session.h" /> | |
| 50 | - <Unit filename="private.h" /> | |
| 51 | - <Unit filename="src/core/abstract.cc" /> | |
| 52 | - <Unit filename="src/core/events.cc" /> | |
| 53 | - <Unit filename="src/core/host.cc" /> | |
| 54 | - <Unit filename="src/core/session.cc" /> | |
| 55 | - <Unit filename="src/os/linux/request.cc" /> | |
| 56 | - <Unit filename="src/os/linux/session.cc" /> | |
| 57 | - <Unit filename="src/os/windows/request.cc" /> | |
| 58 | - <Unit filename="src/os/windows/session.cc" /> | |
| 59 | - <Unit filename="src/session/local/events.cc" /> | |
| 60 | - <Unit filename="src/session/local/session.cc" /> | |
| 61 | - <Unit filename="src/session/remote/session.cc" /> | |
| 62 | - <Unit filename="src/testprogram/testprogram.cc" /> | |
| 63 | - <Extensions> | |
| 64 | - <code_completion /> | |
| 65 | - <envvars /> | |
| 66 | - <debugger /> | |
| 67 | - <lib_finder disable_auto="1" /> | |
| 68 | - </Extensions> | |
| 69 | - </Project> | |
| 70 | -</CodeBlocks_project_file> |
src/client/lib3270++.pc.in
| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | -prefix=@prefix@ | |
| 2 | -exec_prefix=@exec_prefix@ | |
| 3 | -libdir=@libdir@ | |
| 4 | -includedir=@includedir@ | |
| 5 | - | |
| 6 | -version_major=@PACKAGE_MAJOR_VERSION@ | |
| 7 | -version_minor=@PACKAGE_MINOR_VERSION@ | |
| 8 | -sdk_version=@LIB3270_SDK_VERSION@ | |
| 9 | - | |
| 10 | -Name: @PACKAGE_NAME@ | |
| 11 | -Description: @PACKAGE_DESCRIPTION@ | |
| 12 | -Version: @PACKAGE_VERSION@ | |
| 13 | -Libs: -L\@libdir@ -l3270++ | |
| 14 | -Libs.private: @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ -l@LIB3270_NAME@ | |
| 15 | -Cflags: -I@includedir@ | |
| 16 | - |
src/client/lib3270++static.pc.in
| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | -prefix=@prefix@ | |
| 2 | -exec_prefix=@exec_prefix@ | |
| 3 | -libdir=@libdir@ | |
| 4 | -includedir=@includedir@ | |
| 5 | - | |
| 6 | -version_major=@PACKAGE_MAJOR_VERSION@ | |
| 7 | -version_minor=@PACKAGE_MINOR_VERSION@ | |
| 8 | -sdk_version=@LIB3270_SDK_VERSION@ | |
| 9 | - | |
| 10 | -Name: @PACKAGE_NAME@ | |
| 11 | -Description: @PACKAGE_DESCRIPTION@ | |
| 12 | -Version: @PACKAGE_VERSION@ | |
| 13 | -Libs: -L\@libdir@ -l@LIB3270_NAME@++static @LIBSSL_LIBS@ @LIBICONV@ @INTL_LIBS@ | |
| 14 | -Cflags: -I@includedir@ | |
| 15 | - |
src/client/private.h
| ... | ... | @@ -1,385 +0,0 @@ |
| 1 | -/* | |
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | - * | |
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | - * | |
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | - * Free Software Foundation. | |
| 11 | - * | |
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | - * obter mais detalhes. | |
| 16 | - * | |
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 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 | - */ | |
| 29 | - | |
| 30 | -/** | |
| 31 | - * @file src/lib3270++/private.h | |
| 32 | - * | |
| 33 | - * @brief | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | -#ifndef PRIVATE_H_INCLUDED | |
| 40 | - | |
| 41 | - #define PRIVATE_H_INCLUDED | |
| 42 | - | |
| 43 | - #include <config.h> | |
| 44 | - | |
| 45 | - #ifdef _WIN32 | |
| 46 | - #include <winsock2.h> | |
| 47 | - #include <windows.h> | |
| 48 | - #include <ws2tcpip.h> | |
| 49 | - #else | |
| 50 | - #include <dbus/dbus.h> | |
| 51 | - #endif // WIN32 | |
| 52 | - | |
| 53 | - #include <iostream> | |
| 54 | - #include <mutex> | |
| 55 | - #include <lib3270++.h> | |
| 56 | - #include <lib3270/popup.h> | |
| 57 | - #include <system_error> | |
| 58 | - #include <stdexcept> | |
| 59 | - | |
| 60 | -#ifdef HAVE_LIBINTL | |
| 61 | - #include <libintl.h> | |
| 62 | - #define _( x ) gettext(x) | |
| 63 | - #define N_( x ) x | |
| 64 | -#else | |
| 65 | - #define _( x ) x | |
| 66 | - #define N_( x ) x | |
| 67 | -#endif // HAVE_LIBINTL | |
| 68 | - | |
| 69 | -#ifdef HAVE_ICONV | |
| 70 | - #include <iconv.h> | |
| 71 | -#endif // HAVE_ICONV | |
| 72 | - | |
| 73 | -#ifdef WIN32 | |
| 74 | - #define SYSTEM_CHARSET "CP1252" | |
| 75 | -#else | |
| 76 | - #define SYSTEM_CHARSET "UTF-8" | |
| 77 | -#endif // WIN32 | |
| 78 | - | |
| 79 | -#ifdef DEBUG | |
| 80 | - | |
| 81 | - inline void console(std::ostream &out) { | |
| 82 | - out << std::endl; | |
| 83 | - } | |
| 84 | - | |
| 85 | - template<typename T, typename... Targs> | |
| 86 | - void console(std::ostream &out, T value, Targs... Fargs) { | |
| 87 | - out << value; | |
| 88 | - console(out, Fargs...); | |
| 89 | - } | |
| 90 | - | |
| 91 | - template<typename T, typename... Targs> | |
| 92 | - void log(T value, Targs... Fargs) { | |
| 93 | - console(std::clog,value,Fargs...); | |
| 94 | - } | |
| 95 | - | |
| 96 | - #define debug(...) log(__FILE__, "(", __LINE__, ") ", __VA_ARGS__); | |
| 97 | - | |
| 98 | -#else | |
| 99 | - | |
| 100 | - #define debug(...) /* __VA_ARGS__ */ | |
| 101 | - | |
| 102 | -#endif | |
| 103 | - | |
| 104 | - namespace TN3270 { | |
| 105 | - | |
| 106 | - namespace Abstract { | |
| 107 | - | |
| 108 | - class TN3270_PRIVATE Session : public TN3270::Session { | |
| 109 | - private: | |
| 110 | - | |
| 111 | -#ifdef HAVE_ICONV | |
| 112 | - struct { | |
| 113 | - | |
| 114 | - /// @brief Convert strings from host codepage to local codepage. | |
| 115 | - iconv_t local; | |
| 116 | - | |
| 117 | - /// @brief Convert string from local codepage to host codepage. | |
| 118 | - iconv_t host; | |
| 119 | - | |
| 120 | - } converter; | |
| 121 | -#endif | |
| 122 | - | |
| 123 | - /// @brief Converte charset. | |
| 124 | - static std::string convertCharset(iconv_t &converter, const char *str); | |
| 125 | - | |
| 126 | - protected: | |
| 127 | - | |
| 128 | - /// @brief Current in/out position. | |
| 129 | - int baddr; | |
| 130 | - | |
| 131 | - Session(); | |
| 132 | - virtual ~Session(); | |
| 133 | - | |
| 134 | - /// @brief Setup charsets | |
| 135 | - void setCharSet(const char *remote, const char *local = SYSTEM_CHARSET); | |
| 136 | - | |
| 137 | - /// @brief Converte string recebida do host para o charset atual. | |
| 138 | - std::string convertFromHost(const char *str) const; | |
| 139 | - | |
| 140 | - /// @brief Converte string do charset atual para o charset do host. | |
| 141 | - std::string convertToHost(const char *str) const; | |
| 142 | - | |
| 143 | - }; | |
| 144 | - | |
| 145 | - } | |
| 146 | - | |
| 147 | - /// @brief lib3270 direct access objects (no IPC); | |
| 148 | - namespace Local { | |
| 149 | - | |
| 150 | - class TN3270_PRIVATE Session : public TN3270::Abstract::Session { | |
| 151 | - private: | |
| 152 | - | |
| 153 | - /// @brief Handle of the related instance of lib3270 | |
| 154 | - H3270 * hSession; | |
| 155 | - | |
| 156 | - /// @brief Mutex to serialize access to lib3270 | |
| 157 | - std::mutex sync; | |
| 158 | - | |
| 159 | - /// @brief Popup Handler. | |
| 160 | - static void popupHandler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | |
| 161 | - | |
| 162 | - /// @brief Connect Handler. | |
| 163 | - static void connectHandler(H3270 *session, unsigned char connected); | |
| 164 | - | |
| 165 | - /// @brief Wait for network events | |
| 166 | - void wait(time_t timeout = 5); | |
| 167 | - | |
| 168 | - public: | |
| 169 | - Session(); | |
| 170 | - virtual ~Session(); | |
| 171 | - | |
| 172 | - // Connect/disconnect | |
| 173 | - void connect(const char *url) override; | |
| 174 | - void disconnect() override; | |
| 175 | - | |
| 176 | - // Wait for session state. | |
| 177 | - void waitForReady(time_t timeout = 5) throw() override; | |
| 178 | - | |
| 179 | - // Get properties. | |
| 180 | - void getProperty(const char *name, int &value) const override; | |
| 181 | - void getProperty(const char *name, std::string &value) const override; | |
| 182 | - void getProperty(const char *name, bool &value) const override; | |
| 183 | - | |
| 184 | - std::string getVersion() const override; | |
| 185 | - std::string getRevision() const override; | |
| 186 | - | |
| 187 | - // Gets | |
| 188 | - std::string toString(int baddr, size_t len, char lf) const override; | |
| 189 | - std::string toString(int row, int col, size_t sz, char lf) const override; | |
| 190 | - | |
| 191 | - ProgramMessage getProgramMessage() const override; | |
| 192 | - | |
| 193 | - ConnectionState getConnectionState() const override; | |
| 194 | - | |
| 195 | - TN3270::Session & setCursorPosition(unsigned short addr) override; | |
| 196 | - TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | |
| 197 | - | |
| 198 | - /// @brief Set field at current posicion, jumps to next writable field. | |
| 199 | - TN3270::Session & push(const char *text) override; | |
| 200 | - | |
| 201 | - TN3270::Session & push(int baddr, const std::string &text) override; | |
| 202 | - TN3270::Session & push(int row, int col, const std::string &text) override; | |
| 203 | - TN3270::Session & push(const PFKey key) override; | |
| 204 | - TN3270::Session & push(const PAKey key) override; | |
| 205 | - TN3270::Session & push(const Action action) override; | |
| 206 | - | |
| 207 | - // Get contents. | |
| 208 | - TN3270::Session & pop(int baddr, std::string &text) override; | |
| 209 | - TN3270::Session & pop(int row, int col, std::string &text) override; | |
| 210 | - TN3270::Session & pop(std::string &text) override; | |
| 211 | - | |
| 212 | - /// @brief Execute action by name. | |
| 213 | - TN3270::Session & action(const char *action_name) override; | |
| 214 | - | |
| 215 | - }; | |
| 216 | - | |
| 217 | - } | |
| 218 | - | |
| 219 | - /// @brief IPC Based acess (Access and active instance of pw3270 or pw3270d) | |
| 220 | - namespace IPC { | |
| 221 | - | |
| 222 | - class Session; | |
| 223 | - | |
| 224 | - /// @brief PW3270 IPC Request/Response. | |
| 225 | - class Request { | |
| 226 | - private: | |
| 227 | - | |
| 228 | -#ifdef _WIN32 | |
| 229 | - /// @brief Pipe Handle. | |
| 230 | - HANDLE hPipe; | |
| 231 | - | |
| 232 | - /// @brief IPC Data type. | |
| 233 | - enum Type : uint8_t { | |
| 234 | - String = 's', | |
| 235 | - Boolean = 'b', | |
| 236 | - Uchar = 'y', | |
| 237 | - Int16 = 'n', | |
| 238 | - Uint16 = 'q', | |
| 239 | - Int32 = 'i', | |
| 240 | - Int32x = 'h', | |
| 241 | - Uint32 = 'u', | |
| 242 | - Int64 = 'x', | |
| 243 | - Uint64 = 't' | |
| 244 | - }; | |
| 245 | - | |
| 246 | - struct { | |
| 247 | - DWORD length; ///< @brief Length of input buffer. | |
| 248 | - DWORD used; ///< @brief Length of used block. | |
| 249 | - DWORD current; ///< @brief Offset of the current argument. | |
| 250 | - uint8_t * block; | |
| 251 | - } in; | |
| 252 | - | |
| 253 | - struct { | |
| 254 | - DWORD length; | |
| 255 | - DWORD used; | |
| 256 | - uint8_t * block; | |
| 257 | - } out; | |
| 258 | - | |
| 259 | - struct DataBlock { | |
| 260 | - Type type; | |
| 261 | - }; | |
| 262 | - | |
| 263 | - /// @brief Store value on data block. | |
| 264 | - DataBlock * pushBlock(const void *ptr, size_t len); | |
| 265 | - | |
| 266 | - /// @brief Get next argument. | |
| 267 | - DataBlock * getNextBlock() const; | |
| 268 | - | |
| 269 | -#else | |
| 270 | - struct { | |
| 271 | - DBusMessage * in; | |
| 272 | - DBusMessage * out; | |
| 273 | - DBusMessageIter iter; | |
| 274 | - | |
| 275 | - } msg; | |
| 276 | - DBusConnection * conn; | |
| 277 | - | |
| 278 | -#endif // _WIN32 | |
| 279 | - | |
| 280 | - Request(const Session &session); | |
| 281 | - | |
| 282 | - public: | |
| 283 | - | |
| 284 | - /// @brief Create a method call. | |
| 285 | - Request(const Session &session, const char *method); | |
| 286 | - | |
| 287 | - /// @brief Create a get/set property call. | |
| 288 | - /// | |
| 289 | - /// @param session Session object. | |
| 290 | - /// @param isSet true if this is a setProperty call. | |
| 291 | - /// @param property Property name. | |
| 292 | - // | |
| 293 | - Request(const Session &session, bool isSet, const char *property); | |
| 294 | - | |
| 295 | - ~Request(); | |
| 296 | - | |
| 297 | - Request & call(); | |
| 298 | - | |
| 299 | - // Push values | |
| 300 | - Request & push(const char *arg); | |
| 301 | - Request & push(const bool arg); | |
| 302 | - Request & push(const int32_t arg); | |
| 303 | - Request & push(const uint32_t arg); | |
| 304 | - Request & push(const uint8_t arg); | |
| 305 | - | |
| 306 | - // Pop values | |
| 307 | - Request & pop(std::string &value); | |
| 308 | - Request & pop(int &value); | |
| 309 | - | |
| 310 | - }; | |
| 311 | - | |
| 312 | - class TN3270_PRIVATE Session : public TN3270::Abstract::Session { | |
| 313 | - private: | |
| 314 | - | |
| 315 | - friend class Request; | |
| 316 | - | |
| 317 | -#ifdef _WIN32 | |
| 318 | - /// @brief Pipe Handle. | |
| 319 | - HANDLE hPipe; | |
| 320 | -#else | |
| 321 | - | |
| 322 | - DBusConnection * conn; | |
| 323 | - std::string name; ///< @brief D-Bus Object name. | |
| 324 | - std::string path; ///< @brief D-Bus Object path. | |
| 325 | - std::string interface; ///< @brief D-Bus interface. | |
| 326 | - | |
| 327 | -#endif // _WIN32 | |
| 328 | - | |
| 329 | - void call(Request &request); | |
| 330 | - | |
| 331 | - public: | |
| 332 | - | |
| 333 | - Session(const char *id); | |
| 334 | - virtual ~Session(); | |
| 335 | - | |
| 336 | - // Connect/disconnect | |
| 337 | - void connect(const char *url) override; | |
| 338 | - void disconnect() override; | |
| 339 | - | |
| 340 | - // Wait for session state. | |
| 341 | - void waitForReady(time_t timeout = 5) override; | |
| 342 | - | |
| 343 | - // Get properties. | |
| 344 | - void getProperty(const char *name, int &value) const override; | |
| 345 | - void getProperty(const char *name, std::string &value) const override; | |
| 346 | - void getProperty(const char *name, bool &value) const override; | |
| 347 | - | |
| 348 | - std::string getVersion() const override; | |
| 349 | - std::string getRevision() const override; | |
| 350 | - | |
| 351 | - // Gets | |
| 352 | - std::string toString(int baddr, size_t len, char lf) const override; | |
| 353 | - std::string toString(int row, int col, size_t sz, char lf) const override; | |
| 354 | - | |
| 355 | - ProgramMessage getProgramMessage() const override; | |
| 356 | - | |
| 357 | - ConnectionState getConnectionState() const override; | |
| 358 | - | |
| 359 | - TN3270::Session & setCursorPosition(unsigned short addr) override; | |
| 360 | - TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | |
| 361 | - | |
| 362 | - /// @brief Set field at current posicion, jumps to next writable field. | |
| 363 | - TN3270::Session & push(const char *text) override; | |
| 364 | - | |
| 365 | - TN3270::Session & push(int baddr, const std::string &text) override; | |
| 366 | - TN3270::Session & push(int row, int col, const std::string &text) override; | |
| 367 | - TN3270::Session & push(const PFKey key) override; | |
| 368 | - TN3270::Session & push(const PAKey key) override; | |
| 369 | - TN3270::Session & push(const Action action) override; | |
| 370 | - | |
| 371 | - // Get contents. | |
| 372 | - TN3270::Session & pop(int baddr, std::string &text) override; | |
| 373 | - TN3270::Session & pop(int row, int col, std::string &text) override; | |
| 374 | - TN3270::Session & pop(std::string &text) override; | |
| 375 | - | |
| 376 | - /// @brief Execute action by name. | |
| 377 | - TN3270::Session & action(const char *action_name) override; | |
| 378 | - | |
| 379 | - }; | |
| 380 | - | |
| 381 | - } | |
| 382 | - | |
| 383 | - } | |
| 384 | - | |
| 385 | -#endif // PRIVATE_H_INCLUDED |
src/client/src/Makefile.in
| ... | ... | @@ -1,391 +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 | -#---[ Library configuration ]------------------------------------------------------------ | |
| 28 | - | |
| 29 | -LIBNAME=lib@LIB3270_NAME@++ | |
| 30 | - | |
| 31 | -SOURCES= \ | |
| 32 | - $(wildcard *.cc) \ | |
| 33 | - $(wildcard local/*.cc) \ | |
| 34 | - $(wildcard ipc/*.cc) \ | |
| 35 | - $(wildcard @OSNAME@/*.cc) \ | |
| 36 | - $(wildcard @OSNAME@/*.rc) | |
| 37 | - | |
| 38 | -TEST_SOURCES= \ | |
| 39 | - $(wildcard testprogram/*.cc) | |
| 40 | - | |
| 41 | -#---[ Tools ]---------------------------------------------------------------------------- | |
| 42 | - | |
| 43 | -CXX=@CXX@ | |
| 44 | -HOST_CC=@HOST_CC@ | |
| 45 | -LD=@CXX@ | |
| 46 | -LN_S=@LN_S@ | |
| 47 | -MKDIR=@MKDIR_P@ | |
| 48 | -INSTALL=@INSTALL@ | |
| 49 | -INSTALL_DATA=@INSTALL_DATA@ | |
| 50 | -INSTALL_PROGRAM=@INSTALL_PROGRAM@ | |
| 51 | -XGETTEXT=@XGETTEXT@ | |
| 52 | -MSGCAT=@MSGCAT@ | |
| 53 | -WINDRES=@WINDRES@ | |
| 54 | -AR=@AR@ | |
| 55 | -VALGRIND=@VALGRIND@ | |
| 56 | - | |
| 57 | -#---[ Paths ]---------------------------------------------------------------------------- | |
| 58 | - | |
| 59 | -prefix=@prefix@ | |
| 60 | -exec_prefix=@exec_prefix@ | |
| 61 | -bindir=@bindir@ | |
| 62 | -sbindir=@sbindir@ | |
| 63 | -libdir=@libdir@ | |
| 64 | -includedir=@includedir@ | |
| 65 | -datarootdir=@datarootdir@ | |
| 66 | -localedir=@localedir@ | |
| 67 | -docdir=@docdir@ | |
| 68 | -sysconfdir=@sysconfdir@ | |
| 69 | - | |
| 70 | -BASEDIR=@BASEDIR@ | |
| 71 | - | |
| 72 | -POTDIR=$(BASEDIR)/.pot | |
| 73 | - | |
| 74 | -OBJDIR=$(BASEDIR)/.obj/$(LIBNAME) | |
| 75 | -OBJDBG=$(OBJDIR)/Debug | |
| 76 | -OBJRLS=$(OBJDIR)/Release | |
| 77 | - | |
| 78 | -BINDIR=$(BASEDIR)/.bin | |
| 79 | -BINDBG=$(BINDIR)/Debug | |
| 80 | -BINRLS=$(BINDIR)/Release | |
| 81 | - | |
| 82 | -#---[ Rules ]---------------------------------------------------------------------------- | |
| 83 | - | |
| 84 | -DEPENDS= \ | |
| 85 | - Makefile \ | |
| 86 | - ../include/*.h \ | |
| 87 | - ../include/lib3270/*.h \ | |
| 88 | - ../lib3270/*.h | |
| 89 | - | |
| 90 | - | |
| 91 | -CFLAGS= \ | |
| 92 | - @CFLAGS@ \ | |
| 93 | - @CPPFLAGS@ \ | |
| 94 | - -g \ | |
| 95 | - -I../include \ | |
| 96 | - -DBUILD_DATE=`date +%Y%m%d` \ | |
| 97 | - @DBUS_CFLAGS@ | |
| 98 | - | |
| 99 | -LIBS= \ | |
| 100 | - @LIBS@ \ | |
| 101 | - @LIBSSL_LIBS@ \ | |
| 102 | - @LIBICONV@ \ | |
| 103 | - @INTL_LIBS@ \ | |
| 104 | - @DBUS_LIBS@ | |
| 105 | - | |
| 106 | - | |
| 107 | -#---[ Debug Rules ]---------------------------------------------------------------------- | |
| 108 | - | |
| 109 | -$(OBJDBG)/%.o: \ | |
| 110 | - %.cc \ | |
| 111 | - $(DEPENDS) | |
| 112 | - | |
| 113 | - @echo $< ... | |
| 114 | - @$(MKDIR) `dirname $@` | |
| 115 | - @$(CXX) \ | |
| 116 | - $(CFLAGS) \ | |
| 117 | - -Wall -Wextra -fstack-check \ | |
| 118 | - -DDEBUG=1 \ | |
| 119 | - -o $@ -c $< | |
| 120 | - | |
| 121 | -$(OBJDBG)/%.o: \ | |
| 122 | - %.rc | |
| 123 | - | |
| 124 | - @echo $< ... | |
| 125 | - @$(MKDIR) `dirname $@` | |
| 126 | - @$(WINDRES) $< -O coff -o $@ | |
| 127 | - | |
| 128 | -#---[ Release Rules ]-------------------------------------------------------------------- | |
| 129 | - | |
| 130 | -$(OBJRLS)/%.o: \ | |
| 131 | - %.cc \ | |
| 132 | - $(DEPENDS) | |
| 133 | - | |
| 134 | - @echo $< ... | |
| 135 | - @$(MKDIR) `dirname $@` | |
| 136 | - @$(CXX) \ | |
| 137 | - $(CFLAGS) \ | |
| 138 | - -DNDEBUG=1 \ | |
| 139 | - -o $@ -c $< | |
| 140 | - | |
| 141 | -$(OBJRLS)/%.o: \ | |
| 142 | - %.rc | |
| 143 | - | |
| 144 | - @echo $< ... | |
| 145 | - @$(MKDIR) `dirname $@` | |
| 146 | - @$(WINDRES) $< -O coff -o $@ | |
| 147 | - | |
| 148 | -#---[ Misc Rules ]----------------------------------------------------------------------- | |
| 149 | - | |
| 150 | -$(POTDIR)/$(LIBNAME)/%.pot: \ | |
| 151 | - %.cc | |
| 152 | - | |
| 153 | - @echo $(notdir $@) ... | |
| 154 | - @$(MKDIR) `dirname $@` | |
| 155 | - @$(XGETTEXT) \ | |
| 156 | - --language=C \ | |
| 157 | - --keyword=_ \ | |
| 158 | - --keyword=N_ \ | |
| 159 | - --keyword=MSG_:2 \ | |
| 160 | - --output=$@ \ | |
| 161 | - $< | |
| 162 | - @touch $@ | |
| 163 | - | |
| 164 | -$(POTDIR)/$(LIBNAME)/%.pot: \ | |
| 165 | - %.rc | |
| 166 | - | |
| 167 | - @echo $< ... | |
| 168 | - @$(MKDIR) `dirname $@` | |
| 169 | - @touch $@ | |
| 170 | - | |
| 171 | -#---[ Release Targets ]------------------------------------------------------------------ | |
| 172 | - | |
| 173 | -all: \ | |
| 174 | - $(BINRLS)/$(LIBNAME)@DLLEXT@ \ | |
| 175 | - $(BINRLS)/static/$(LIBNAME).a \ | |
| 176 | - $(POTDIR)/$(LIBNAME).pot | |
| 177 | - | |
| 178 | - | |
| 179 | -Release: \ | |
| 180 | - $(BINRLS)/$(LIBNAME)@DLLEXT@ \ | |
| 181 | - $(BINRLS)/static/$(LIBNAME).a | |
| 182 | - | |
| 183 | - | |
| 184 | -$(BINRLS)/$(LIBNAME)@DLLEXT@: \ | |
| 185 | - $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 186 | - | |
| 187 | - @echo $< ... | |
| 188 | - @rm -f $@ | |
| 189 | - @$(LN_S) \ | |
| 190 | - $^ \ | |
| 191 | - $@ | |
| 192 | - | |
| 193 | -$(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ | |
| 194 | - $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 195 | - | |
| 196 | - @rm -f $@ | |
| 197 | - @$(LN_S) \ | |
| 198 | - $^ \ | |
| 199 | - $@ | |
| 200 | - | |
| 201 | -$(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
| 202 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
| 203 | - | |
| 204 | - @$(MKDIR) $(@D) | |
| 205 | - @echo $< ... | |
| 206 | - | |
| 207 | - @$(LD) \ | |
| 208 | - @DLL_LDFLAGS@ \ | |
| 209 | - -o $@ \ | |
| 210 | - $(LDFLAGS) \ | |
| 211 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) \ | |
| 212 | - -L$(BINRLS) \ | |
| 213 | - $(LIBS) \ | |
| 214 | - -l@LIB3270_NAME@ | |
| 215 | - | |
| 216 | -$(BINRLS)/static/$(LIBNAME).a: \ | |
| 217 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) | |
| 218 | - | |
| 219 | - @echo $@ ... | |
| 220 | - @$(MKDIR) `dirname $@` | |
| 221 | - @$(AR) rcs $@ $^ | |
| 222 | - | |
| 223 | - | |
| 224 | -#---[ Install Targets ]------------------------------------------------------------------ | |
| 225 | - | |
| 226 | -install: \ | |
| 227 | - install-shared \ | |
| 228 | - install-static \ | |
| 229 | - install-dev | |
| 230 | - | |
| 231 | -install-shared: \ | |
| 232 | - $(BINRLS)/$(LIBNAME)@DLLEXT@ | |
| 233 | - | |
| 234 | - # Install library | |
| 235 | - @mkdir -p $(DESTDIR)$(libdir) | |
| 236 | - | |
| 237 | - @$(INSTALL_PROGRAM) \ | |
| 238 | - $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
| 239 | - $(DESTDIR)$(libdir) | |
| 240 | - | |
| 241 | - | |
| 242 | - @$(LN_S) \ | |
| 243 | - $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ \ | |
| 244 | - $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 245 | - | |
| 246 | - @$(LN_S) \ | |
| 247 | - $(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ \ | |
| 248 | - $(DESTDIR)$(libdir)/$(LIBNAME)@DLLEXT@ | |
| 249 | - | |
| 250 | -install-static: \ | |
| 251 | - $(BINRLS)/static/$(LIBNAME).a | |
| 252 | - | |
| 253 | - # Install static library | |
| 254 | - @mkdir -p $(DESTDIR)$(libdir) | |
| 255 | - @$(INSTALL_DATA) \ | |
| 256 | - $(BINRLS)/static/$(LIBNAME).a \ | |
| 257 | - $(DESTDIR)$(libdir)/$(LIBNAME)static.a | |
| 258 | - | |
| 259 | - # Install static PKG-CONFIG files | |
| 260 | - @mkdir -p $(DESTDIR)$(libdir)/pkgconfig | |
| 261 | - @$(INSTALL_DATA) \ | |
| 262 | - lib3270++static.pc \ | |
| 263 | - $(DESTDIR)$(libdir)/pkgconfig/lib3270++static.pc | |
| 264 | - | |
| 265 | -install-dev: | |
| 266 | - | |
| 267 | - # Install SDK | |
| 268 | - @$(INSTALL_DATA) \ | |
| 269 | - ../include/lib3270++.h \ | |
| 270 | - $(DESTDIR)$(includedir)/lib3270++.h | |
| 271 | - | |
| 272 | - # Install PKG-CONFIG files | |
| 273 | - @mkdir -p $(DESTDIR)$(libdir)/pkgconfig | |
| 274 | - @$(INSTALL_DATA) \ | |
| 275 | - lib3270++.pc \ | |
| 276 | - $(DESTDIR)$(libdir)/pkgconfig/lib3270++.pc | |
| 277 | - | |
| 278 | - | |
| 279 | -#---[ Misc Targets ]--------------------------------------------------------------------- | |
| 280 | - | |
| 281 | -$(POTDIR)/$(LIBNAME).pot: \ | |
| 282 | - $(foreach SRC, $(basename $(SOURCES)), $(POTDIR)/$(LIBNAME)/$(SRC).pot) | |
| 283 | - | |
| 284 | - @rm -f $@ | |
| 285 | - @mkdir -p `dirname $@` | |
| 286 | - @$(MSGCAT) --sort-output $^ > $@ | |
| 287 | - | |
| 288 | -locale: \ | |
| 289 | - $(POTDIR)/$(LIBNAME).pot | |
| 290 | - | |
| 291 | - | |
| 292 | -#---[ Debug Targets ]-------------------------------------------------------------------- | |
| 293 | - | |
| 294 | -Debug: \ | |
| 295 | - $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 296 | - | |
| 297 | -$(BINDBG)/$(LIBNAME)@EXEEXT@: \ | |
| 298 | - $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 299 | - $(BINDBG)/$(LIBNAME)@DLLEXT@ | |
| 300 | - | |
| 301 | - @$(MKDIR) `dirname $@` | |
| 302 | - @echo $< ... | |
| 303 | - @$(LD) \ | |
| 304 | - -Wl,--rpath,$(BINDBG) \ | |
| 305 | - -o $@ \ | |
| 306 | - $^ \ | |
| 307 | - $(LDFLAGS) \ | |
| 308 | - $(LIBS) | |
| 309 | - | |
| 310 | -run: \ | |
| 311 | - $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 312 | - | |
| 313 | -ifeq ($(VALGRIND),no) | |
| 314 | - | |
| 315 | - @LD_LIBRARY_PATH=$(BINDBG) \ | |
| 316 | - $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 317 | - | |
| 318 | -else | |
| 319 | - @touch valgrind.suppression | |
| 320 | - | |
| 321 | - @LD_LIBRARY_PATH=$(BINDBG) \ | |
| 322 | - $(VALGRIND) --leak-check=full --track-origins=yes --gen-suppressions=all --suppressions=valgrind.suppression \ | |
| 323 | - $(BINDBG)/$(LIBNAME)@EXEEXT@ | |
| 324 | -endif | |
| 325 | - | |
| 326 | - | |
| 327 | -$(BINDBG)/$(LIBNAME)@DLLEXT@: \ | |
| 328 | - $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 329 | - | |
| 330 | - @echo $< ... | |
| 331 | - @rm -f $@ | |
| 332 | - @$(LN_S) \ | |
| 333 | - $^ \ | |
| 334 | - $@ | |
| 335 | - | |
| 336 | -$(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@: \ | |
| 337 | - $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 338 | - | |
| 339 | - @rm -f $@ | |
| 340 | - @$(LN_S) \ | |
| 341 | - $^ \ | |
| 342 | - $@ | |
| 343 | - | |
| 344 | -$(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ | |
| 345 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) | |
| 346 | - | |
| 347 | - @$(MKDIR) `dirname $@` | |
| 348 | - @echo $< ... | |
| 349 | - @$(LD) \ | |
| 350 | - -shared \ | |
| 351 | - -Wl,-soname,$(@F) \ | |
| 352 | - -Wl,--rpath,$(BINDBG) \ | |
| 353 | - -o $@ \ | |
| 354 | - $(LDFLAGS) \ | |
| 355 | - $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
| 356 | - -L$(BINDBG) \ | |
| 357 | - $(LIBS) \ | |
| 358 | - -l@LIB3270_NAME@ | |
| 359 | - | |
| 360 | -#---[ Clean Targets ]-------------------------------------------------------------------- | |
| 361 | - | |
| 362 | -clean: \ | |
| 363 | - cleanDebug \ | |
| 364 | - cleanRelease | |
| 365 | - | |
| 366 | - @rm -fr $(BASEDIR)/.tmp/$(LIBNAME) | |
| 367 | - @rm -fr $(POTDIR)/$(LIBNAME) | |
| 368 | - | |
| 369 | -cleanDebug: | |
| 370 | - | |
| 371 | - @rm -fr $(OBJDBG) | |
| 372 | - @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 373 | - @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 374 | - @rm -f $(BINDBG)/$(LIBNAME)@DLLEXT@ | |
| 375 | - | |
| 376 | -cleanRelease: | |
| 377 | - | |
| 378 | - @rm -fr $(OBJRLS) | |
| 379 | - | |
| 380 | - @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 381 | - @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | |
| 382 | - @rm -f $(BINRLS)/$(LIBNAME)@DLLEXT@ | |
| 383 | - | |
| 384 | - @rm -fr $(POTDIR) | |
| 385 | - @rm -f lib$(LIBNAME).pot | |
| 386 | - | |
| 387 | -clean: \ | |
| 388 | - cleanDebug \ | |
| 389 | - cleanRelease | |
| 390 | - | |
| 391 | - |
src/client/src/core/abstract.cc
| ... | ... | @@ -1,153 +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 - 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 | -/** | |
| 31 | - * @file src/core/abstract.cc | |
| 32 | - * | |
| 33 | - * @brief Implements abstract session object. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "private.h" | |
| 40 | - #include <cstring> | |
| 41 | - | |
| 42 | - | |
| 43 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | - namespace TN3270 { | |
| 46 | - | |
| 47 | - Abstract::Session::Session() { | |
| 48 | - | |
| 49 | -#ifdef HAVE_ICONV | |
| 50 | - this->converter.local = (iconv_t) (-1); | |
| 51 | - this->converter.host = (iconv_t) (-1); | |
| 52 | -#endif | |
| 53 | - | |
| 54 | - this->baddr = 0; | |
| 55 | - | |
| 56 | - } | |
| 57 | - | |
| 58 | - Abstract::Session::~Session() { | |
| 59 | - | |
| 60 | -#ifdef HAVE_ICONV | |
| 61 | - | |
| 62 | - if(this->converter.local != (iconv_t) (-1)) | |
| 63 | - iconv_close(this->converter.local); | |
| 64 | - | |
| 65 | - if(this->converter.host != (iconv_t) (-1)) | |
| 66 | - iconv_close(this->converter.host); | |
| 67 | - | |
| 68 | -#endif | |
| 69 | - | |
| 70 | - } | |
| 71 | - | |
| 72 | - /// @brief Setup charsets | |
| 73 | - void Abstract::Session::setCharSet(const char *remote, const char *local) { | |
| 74 | - | |
| 75 | -#ifdef HAVE_ICONV | |
| 76 | - | |
| 77 | - if(this->converter.local != (iconv_t) (-1)) | |
| 78 | - iconv_close(converter.local); | |
| 79 | - | |
| 80 | - if(this->converter.host != (iconv_t) (-1)) | |
| 81 | - iconv_close(converter.host); | |
| 82 | - | |
| 83 | - if(strcmp(local,remote)) { | |
| 84 | - | |
| 85 | - // Local and remote charsets aren't the same, setup conversion | |
| 86 | - converter.local = iconv_open(local, remote); | |
| 87 | - converter.host = iconv_open(remote,local); | |
| 88 | - | |
| 89 | - } else { | |
| 90 | - // Same charset, doesn't convert | |
| 91 | - converter.local = converter.host = (iconv_t)(-1); | |
| 92 | - } | |
| 93 | - | |
| 94 | -#else | |
| 95 | - | |
| 96 | - throw std::runtime_error("No ICONV Support"); | |
| 97 | - | |
| 98 | -#endif | |
| 99 | - | |
| 100 | - | |
| 101 | - } | |
| 102 | - | |
| 103 | - /// @brief Converte charset. | |
| 104 | - std::string Abstract::Session::convertCharset(iconv_t &converter, const char *str) { | |
| 105 | - | |
| 106 | - std::string rc; | |
| 107 | - | |
| 108 | -#ifdef HAVE_ICONV | |
| 109 | - size_t in = strlen(str); | |
| 110 | - | |
| 111 | - if(in && converter != (iconv_t)(-1)) { | |
| 112 | - | |
| 113 | - size_t out = (in << 1); | |
| 114 | - char * ptr; | |
| 115 | - char * outBuffer = (char *) malloc(out); | |
| 116 | - ICONV_CONST char * inBuffer = (ICONV_CONST char *) str; | |
| 117 | - | |
| 118 | - memset(ptr=outBuffer,0,out); | |
| 119 | - | |
| 120 | - iconv(converter,NULL,NULL,NULL,NULL); // Reset state | |
| 121 | - | |
| 122 | - if(iconv(converter,&inBuffer,&in,&ptr,&out) != ((size_t) -1)) | |
| 123 | - rc.assign(outBuffer); | |
| 124 | - | |
| 125 | - free(outBuffer); | |
| 126 | - | |
| 127 | - } | |
| 128 | - | |
| 129 | -#else | |
| 130 | - | |
| 131 | - rc = str; | |
| 132 | - | |
| 133 | -#endif // HAVE_ICONV | |
| 134 | - | |
| 135 | - return rc; | |
| 136 | - } | |
| 137 | - | |
| 138 | - /// @brief Converte string recebida do host para o charset atual. | |
| 139 | - std::string Abstract::Session::convertFromHost(const char *str) const { | |
| 140 | - return convertCharset(const_cast<Abstract::Session *>(this)->converter.local,str); | |
| 141 | - } | |
| 142 | - | |
| 143 | - /// @brief Converte string do charset atual para o charset do host. | |
| 144 | - std::string Abstract::Session::convertToHost(const char *str) const { | |
| 145 | - return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,str); | |
| 146 | - } | |
| 147 | - | |
| 148 | - | |
| 149 | - } | |
| 150 | - | |
| 151 | - | |
| 152 | - | |
| 153 | - |
src/client/src/core/events.cc
| ... | ... | @@ -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., 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 | - */ | |
| 29 | - | |
| 30 | -/** | |
| 31 | - * @file src/core/events.cc | |
| 32 | - * | |
| 33 | - * @brief Implements event object. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "private.h" | |
| 40 | - | |
| 41 | - | |
| 42 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | - | |
| 44 | - namespace TN3270 { | |
| 45 | - | |
| 46 | - Event::Event(enum Event::Type type) { | |
| 47 | - this->type = type; | |
| 48 | - } | |
| 49 | - | |
| 50 | - Event::~Event() { | |
| 51 | - } | |
| 52 | - | |
| 53 | - } | |
| 54 | - | |
| 55 | - | |
| 56 | - |
src/client/src/core/host.cc
| ... | ... | @@ -1,180 +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 - 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 | -/** | |
| 31 | - * @file src/core/host.cc | |
| 32 | - * | |
| 33 | - * @brief Implements host object. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "private.h" | |
| 40 | - | |
| 41 | - | |
| 42 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | - | |
| 44 | - namespace TN3270 { | |
| 45 | - | |
| 46 | - Host::Host(const char *id, const char *url, time_t timeout) { | |
| 47 | - this->timeout = timeout; | |
| 48 | - this->session = Session::create(id); | |
| 49 | - if(url) { | |
| 50 | - this->connect(url); | |
| 51 | - } | |
| 52 | - } | |
| 53 | - | |
| 54 | - Host::~Host() { | |
| 55 | - delete this->session; | |
| 56 | - this->session = nullptr; | |
| 57 | - } | |
| 58 | - | |
| 59 | - void Host::connect(const char *url, bool sync) { | |
| 60 | - this->session->connect(url); | |
| 61 | - if(sync) { | |
| 62 | - this->sync(); | |
| 63 | - } | |
| 64 | - } | |
| 65 | - | |
| 66 | - | |
| 67 | - /// @brief Writes characters to the associated file from the put area | |
| 68 | - int Host::sync() { | |
| 69 | - this->session->waitForReady(this->timeout); | |
| 70 | - return 0; | |
| 71 | - } | |
| 72 | - | |
| 73 | - /// @brief Writes characters to the associated output sequence from the put area. | |
| 74 | - int Host::overflow(int c) { | |
| 75 | - | |
| 76 | - if (c != EOF) { | |
| 77 | - char str[] = { static_cast<char>(c), 0 }; | |
| 78 | - this->session->push((const char *) str); | |
| 79 | - } else { | |
| 80 | - sync(); | |
| 81 | - } | |
| 82 | - | |
| 83 | - return c; | |
| 84 | - | |
| 85 | - } | |
| 86 | - | |
| 87 | - Host & Host::push(const Action action) { | |
| 88 | - session->push(action); | |
| 89 | - sync(); | |
| 90 | - return *this; | |
| 91 | - } | |
| 92 | - | |
| 93 | - bool Host::isReady() const { | |
| 94 | - this->session->waitForReady(this->timeout); | |
| 95 | - return getProgramMessage() == MESSAGE_NONE; | |
| 96 | - } | |
| 97 | - | |
| 98 | - bool Host::isConnected() const { | |
| 99 | - this->session->waitForReady(this->timeout); | |
| 100 | - return getConnectionState() == CONNECTED_TN3270E; | |
| 101 | - } | |
| 102 | - | |
| 103 | - std::string Host::toString() const { | |
| 104 | - | |
| 105 | - this->session->waitForReady(this->timeout); | |
| 106 | - | |
| 107 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 108 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 109 | - } | |
| 110 | - | |
| 111 | - return this->session->toString(); | |
| 112 | - } | |
| 113 | - | |
| 114 | - std::string Host::toString(int baddr, size_t len, char lf) const { | |
| 115 | - | |
| 116 | - this->session->waitForReady(this->timeout); | |
| 117 | - | |
| 118 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 119 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 120 | - } | |
| 121 | - | |
| 122 | - return this->session->toString(baddr,len,lf); | |
| 123 | - | |
| 124 | - } | |
| 125 | - | |
| 126 | - std::string Host::toString(int row, int col, size_t sz, char lf) const { | |
| 127 | - | |
| 128 | - this->session->waitForReady(this->timeout); | |
| 129 | - | |
| 130 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 131 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 132 | - } | |
| 133 | - | |
| 134 | - return this->session->toString(row,col,sz,lf); | |
| 135 | - | |
| 136 | - | |
| 137 | - } | |
| 138 | - | |
| 139 | - Host & Host::pop(int baddr, std::string &text) { | |
| 140 | - | |
| 141 | - this->session->waitForReady(this->timeout); | |
| 142 | - | |
| 143 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 144 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 145 | - } | |
| 146 | - | |
| 147 | - session->pop(baddr, text); | |
| 148 | - | |
| 149 | - return *this; | |
| 150 | - } | |
| 151 | - | |
| 152 | - Host & Host::pop(int row, int col, std::string &text) { | |
| 153 | - | |
| 154 | - this->session->waitForReady(this->timeout); | |
| 155 | - | |
| 156 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 157 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 158 | - } | |
| 159 | - | |
| 160 | - session->pop(row,col,text); | |
| 161 | - | |
| 162 | - return *this; | |
| 163 | - } | |
| 164 | - | |
| 165 | - Host & Host::pop(std::string &text) { | |
| 166 | - | |
| 167 | - this->session->waitForReady(this->timeout); | |
| 168 | - | |
| 169 | - if(this->session->getConnectionState() == TN3270::DISCONNECTED) { | |
| 170 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 171 | - } | |
| 172 | - | |
| 173 | - session->pop(text); | |
| 174 | - | |
| 175 | - return *this; | |
| 176 | - } | |
| 177 | - | |
| 178 | - | |
| 179 | - } | |
| 180 | - |
src/client/src/core/session.cc
| ... | ... | @@ -1,78 +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 - 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 | -/** | |
| 31 | - * @file src/core/session.cc | |
| 32 | - * | |
| 33 | - * @brief Implements common session object. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "private.h" | |
| 40 | - | |
| 41 | - | |
| 42 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 43 | - | |
| 44 | - namespace TN3270 { | |
| 45 | - | |
| 46 | - /// @brief Create a tn3270 session. | |
| 47 | - Session * Session::create(const char *id) { | |
| 48 | - | |
| 49 | - if(!id) { | |
| 50 | - return new Local::Session(); | |
| 51 | - } | |
| 52 | - | |
| 53 | - return new IPC::Session(id); | |
| 54 | - | |
| 55 | - } | |
| 56 | - | |
| 57 | - | |
| 58 | - Session::Session() { | |
| 59 | - | |
| 60 | - } | |
| 61 | - | |
| 62 | - Session::~Session() { | |
| 63 | - | |
| 64 | - } | |
| 65 | - | |
| 66 | - void Session::insert(Event::Type type, std::function <void(const Event &event)> listener) { | |
| 67 | - } | |
| 68 | - | |
| 69 | - /// @brief Fire event. | |
| 70 | - void Session::fire(const Event &event) { | |
| 71 | - | |
| 72 | - | |
| 73 | - } | |
| 74 | - | |
| 75 | - } | |
| 76 | - | |
| 77 | - | |
| 78 | - |
src/client/src/os/linux/request.cc
| ... | ... | @@ -1,267 +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 - 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 | -/** | |
| 31 | - * @file src/os/linux/request.cc | |
| 32 | - * | |
| 33 | - * @brief Implements linux request methods for remote session. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - | |
| 41 | - using std::string; | |
| 42 | - | |
| 43 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | - namespace TN3270 { | |
| 46 | - | |
| 47 | - IPC::Request::Request(const Session &session) { | |
| 48 | - this->conn = session.conn; | |
| 49 | - this->msg.in = nullptr; | |
| 50 | - this->msg.out = nullptr; | |
| 51 | - } | |
| 52 | - | |
| 53 | - IPC::Request::Request(const Session &session, const char *method) : Request(session) { | |
| 54 | - | |
| 55 | - this->msg.out = dbus_message_new_method_call( | |
| 56 | - session.name.c_str(), // Destination | |
| 57 | - session.path.c_str(), // Path | |
| 58 | - session.interface.c_str(), // Interface | |
| 59 | - method // Method | |
| 60 | - ); | |
| 61 | - | |
| 62 | - if(!msg.out) { | |
| 63 | - throw std::runtime_error("Can't create D-Bus Method Call"); | |
| 64 | - } | |
| 65 | - | |
| 66 | - } | |
| 67 | - | |
| 68 | - IPC::Request::Request(const Session &session, bool isSet, const char *property) : Request(session) { | |
| 69 | - | |
| 70 | -/* | |
| 71 | - dbus-send \ | |
| 72 | - --session \ | |
| 73 | - --dest=br.com.bb.pw3270.a\ | |
| 74 | - --print-reply \ | |
| 75 | - "/br/com/bb/tn3270/session" \ | |
| 76 | - "org.freedesktop.DBus.Properties.Get" \ | |
| 77 | - string:br.com.bb.tn3270.session \ | |
| 78 | - string:${1} | |
| 79 | -*/ | |
| 80 | - this->msg.out = dbus_message_new_method_call( | |
| 81 | - session.name.c_str(), // Destination | |
| 82 | - session.path.c_str(), // Path | |
| 83 | - "org.freedesktop.DBus.Properties", // Interface | |
| 84 | - (isSet ? "Set" : "Get") | |
| 85 | - ); | |
| 86 | - | |
| 87 | - if(!msg.out) { | |
| 88 | - throw std::runtime_error("Can't create D-Bus Property Call"); | |
| 89 | - } | |
| 90 | - | |
| 91 | - // | |
| 92 | - // https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties | |
| 93 | - // org.freedesktop.DBus.Properties.Get (in STRING interface_name, | |
| 94 | - // in STRING property_name, | |
| 95 | - // out VARIANT value); | |
| 96 | - // org.freedesktop.DBus.Properties.Set (in STRING interface_name, | |
| 97 | - // in STRING property_name, | |
| 98 | - // | |
| 99 | - const char *interface_name = session.interface.c_str(); | |
| 100 | - | |
| 101 | - dbus_message_append_args( | |
| 102 | - this->msg.out, | |
| 103 | - DBUS_TYPE_STRING,&interface_name, | |
| 104 | - DBUS_TYPE_STRING,&property, | |
| 105 | - DBUS_TYPE_INVALID | |
| 106 | - ); | |
| 107 | - | |
| 108 | - } | |
| 109 | - | |
| 110 | - IPC::Request::~Request() { | |
| 111 | - if(msg.out) { | |
| 112 | - dbus_message_unref(msg.out); | |
| 113 | - } | |
| 114 | - if(msg.in) { | |
| 115 | - dbus_message_unref(msg.in); | |
| 116 | - } | |
| 117 | - } | |
| 118 | - | |
| 119 | - IPC::Request & IPC::Request::call() { | |
| 120 | - | |
| 121 | - if(msg.in) { | |
| 122 | - dbus_message_unref(msg.in); | |
| 123 | - msg.in = nullptr; | |
| 124 | - } | |
| 125 | - | |
| 126 | - DBusError error; | |
| 127 | - dbus_error_init(&error); | |
| 128 | - this->msg.in = dbus_connection_send_with_reply_and_block(this->conn,this->msg.out,10000,&error); | |
| 129 | - | |
| 130 | - if(!this->msg.in) { | |
| 131 | - string message = error.message; | |
| 132 | - dbus_error_free(&error); | |
| 133 | - throw std::runtime_error(message.c_str()); | |
| 134 | - } | |
| 135 | - | |
| 136 | - dbus_message_iter_init(msg.in, &msg.iter); | |
| 137 | - | |
| 138 | - debug(__FUNCTION__," got a valid response"); | |
| 139 | - | |
| 140 | - return *this; | |
| 141 | - | |
| 142 | - } | |
| 143 | - | |
| 144 | - IPC::Request & IPC::Request::push(const char *arg) { | |
| 145 | - dbus_message_append_args(this->msg.out,DBUS_TYPE_STRING,&arg,DBUS_TYPE_INVALID); | |
| 146 | - return *this; | |
| 147 | - } | |
| 148 | - | |
| 149 | - IPC::Request & IPC::Request::push(const bool arg) { | |
| 150 | - dbus_message_append_args(this->msg.out,DBUS_TYPE_BOOLEAN,&arg,DBUS_TYPE_INVALID); | |
| 151 | - return *this; | |
| 152 | - } | |
| 153 | - | |
| 154 | - IPC::Request & IPC::Request::push(const uint8_t arg) { | |
| 155 | - dbus_message_append_args(this->msg.out,DBUS_TYPE_BYTE,&arg,DBUS_TYPE_INVALID); | |
| 156 | - return *this; | |
| 157 | - } | |
| 158 | - | |
| 159 | - IPC::Request & IPC::Request::push(const int32_t arg) { | |
| 160 | - dbus_message_append_args(this->msg.out,DBUS_TYPE_INT32,&arg,DBUS_TYPE_INVALID); | |
| 161 | - return *this; | |
| 162 | - } | |
| 163 | - | |
| 164 | - IPC::Request & IPC::Request::push(const uint32_t arg) { | |
| 165 | - dbus_message_append_args(this->msg.out,DBUS_TYPE_UINT32,&arg,DBUS_TYPE_INVALID); | |
| 166 | - return *this; | |
| 167 | - } | |
| 168 | - | |
| 169 | - | |
| 170 | - IPC::Request & IPC::Request::pop(std::string &value) { | |
| 171 | - | |
| 172 | - const char * str = ""; | |
| 173 | - | |
| 174 | - if(dbus_message_iter_get_arg_type(&msg.iter) == DBUS_TYPE_STRING) { | |
| 175 | - | |
| 176 | - dbus_message_iter_get_basic(&msg.iter, &str); | |
| 177 | - | |
| 178 | - } else if(dbus_message_iter_get_arg_type(&msg.iter) == DBUS_TYPE_VARIANT) { | |
| 179 | - | |
| 180 | - DBusMessageIter sub; | |
| 181 | - int current_type; | |
| 182 | - | |
| 183 | - dbus_message_iter_recurse(&msg.iter, &sub); | |
| 184 | - | |
| 185 | - while ((current_type = dbus_message_iter_get_arg_type(&sub)) != DBUS_TYPE_INVALID) { | |
| 186 | - | |
| 187 | - if (current_type == DBUS_TYPE_STRING) { | |
| 188 | - dbus_message_iter_get_basic(&sub, &str); | |
| 189 | - break; | |
| 190 | - } | |
| 191 | - dbus_message_iter_next(&sub); | |
| 192 | - } | |
| 193 | - | |
| 194 | - } else { | |
| 195 | - | |
| 196 | - debug("Argument type is ", ((char) dbus_message_iter_get_arg_type(&msg.iter)) ); | |
| 197 | - throw std::runtime_error("Expected an string data type"); | |
| 198 | - | |
| 199 | - } | |
| 200 | - | |
| 201 | - dbus_message_iter_next(&msg.iter); | |
| 202 | - | |
| 203 | - value.assign(str); | |
| 204 | - | |
| 205 | - debug(__FUNCTION__,"= \"",str,"\""); | |
| 206 | - | |
| 207 | - return *this; | |
| 208 | - } | |
| 209 | - | |
| 210 | - static int getIntValue(DBusMessageIter &iter) { | |
| 211 | - | |
| 212 | - if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) { | |
| 213 | - | |
| 214 | - dbus_int32_t rc = 0; | |
| 215 | - dbus_message_iter_get_basic(&iter, &rc); | |
| 216 | - return (int) rc; | |
| 217 | - | |
| 218 | - } else if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT16) { | |
| 219 | - | |
| 220 | - dbus_int16_t rc = 0; | |
| 221 | - dbus_message_iter_get_basic(&iter, &rc); | |
| 222 | - return (int) rc; | |
| 223 | - | |
| 224 | - } else if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) { | |
| 225 | - | |
| 226 | - DBusMessageIter sub; | |
| 227 | - int current_type; | |
| 228 | - | |
| 229 | - dbus_message_iter_recurse(&iter, &sub); | |
| 230 | - | |
| 231 | - while ((current_type = dbus_message_iter_get_arg_type(&sub)) != DBUS_TYPE_INVALID) { | |
| 232 | - | |
| 233 | - if (current_type == DBUS_TYPE_INT32) { | |
| 234 | - | |
| 235 | - dbus_int32_t rc = 0; | |
| 236 | - dbus_message_iter_get_basic(&sub, &rc); | |
| 237 | - return (int) rc; | |
| 238 | - | |
| 239 | - } else if (current_type == DBUS_TYPE_INT16) { | |
| 240 | - dbus_int16_t rc = 0; | |
| 241 | - dbus_message_iter_get_basic(&sub, &rc); | |
| 242 | - return (int) rc; | |
| 243 | - | |
| 244 | - } | |
| 245 | - dbus_message_iter_next(&sub); | |
| 246 | - } | |
| 247 | - | |
| 248 | - } | |
| 249 | - | |
| 250 | - debug("Argument type is ", ((char) dbus_message_iter_get_arg_type(&iter)) ); | |
| 251 | - throw std::runtime_error("Expected an integer data type"); | |
| 252 | - | |
| 253 | - } | |
| 254 | - | |
| 255 | - IPC::Request & IPC::Request::Request::pop(int &value) { | |
| 256 | - | |
| 257 | - value = getIntValue(msg.iter); | |
| 258 | - dbus_message_iter_next(&msg.iter); | |
| 259 | - debug(__FUNCTION__,"= \"",value,"\""); | |
| 260 | - | |
| 261 | - return *this; | |
| 262 | - | |
| 263 | - } | |
| 264 | - | |
| 265 | - } | |
| 266 | - | |
| 267 | - |
src/client/src/os/linux/session.cc
| ... | ... | @@ -1,98 +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 - 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 | -/** | |
| 31 | - * @file src/os/linux/linux/session.cc | |
| 32 | - * | |
| 33 | - * @brief Implements Linux session methods. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <cstring> | |
| 41 | - #include <lib3270/trace.h> | |
| 42 | - | |
| 43 | - using std::string; | |
| 44 | - | |
| 45 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | - static void throws_if_error(DBusError &err) { | |
| 48 | - | |
| 49 | - if(dbus_error_is_set(&err)) { | |
| 50 | - string message = err.message; | |
| 51 | - dbus_error_free(&err); | |
| 52 | - throw std::runtime_error(message.c_str()); | |
| 53 | - } | |
| 54 | - | |
| 55 | - return; | |
| 56 | - | |
| 57 | - } | |
| 58 | - | |
| 59 | - namespace TN3270 { | |
| 60 | - | |
| 61 | - IPC::Session::Session(const char *id) : Abstract::Session() { | |
| 62 | - | |
| 63 | - // Create D-Bus session. | |
| 64 | - DBusError err; | |
| 65 | - | |
| 66 | - dbus_error_init(&err); | |
| 67 | - this->conn = dbus_bus_get(DBUS_BUS_SESSION, &err); | |
| 68 | - | |
| 69 | - debug("dbus_bus_get conn=",conn); | |
| 70 | - | |
| 71 | - throws_if_error(err); | |
| 72 | - | |
| 73 | - if(!conn) | |
| 74 | - throw std::runtime_error("DBUS Connection failed"); | |
| 75 | - | |
| 76 | - auto sep = strchr(id,':'); | |
| 77 | - if(!sep) { | |
| 78 | - throw std::system_error(EINVAL, std::system_category()); | |
| 79 | - } | |
| 80 | - | |
| 81 | - this->name = "br.com.bb."; | |
| 82 | - this->name += string(id,(sep - id)); | |
| 83 | - this->name += "."; | |
| 84 | - this->name += (sep+1); | |
| 85 | - this->path = "/br/com/bb/tn3270/session"; | |
| 86 | - this->interface = "br.com.bb.tn3270.session"; | |
| 87 | - | |
| 88 | - debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\""); | |
| 89 | - | |
| 90 | - } | |
| 91 | - | |
| 92 | - IPC::Session::~Session() { | |
| 93 | - | |
| 94 | - } | |
| 95 | - | |
| 96 | - } | |
| 97 | - | |
| 98 | - |
src/client/src/os/windows/request.cc
| ... | ... | @@ -1,191 +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 - 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 | -/** | |
| 31 | - * @file src/os/windows/request.cc | |
| 32 | - * | |
| 33 | - * @brief Implements WIN32 request methods. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - | |
| 41 | - using std::string; | |
| 42 | - | |
| 43 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | - namespace TN3270 { | |
| 46 | - | |
| 47 | - #define PIPE_BUFFER_LENGTH 8192 | |
| 48 | - | |
| 49 | - IPC::Request::Request(const Session &session) { | |
| 50 | - | |
| 51 | - this->hPipe = session.hPipe; | |
| 52 | - | |
| 53 | - in.length = PIPE_BUFFER_LENGTH; | |
| 54 | - in.used = 0; | |
| 55 | - in.block = new uint8_t[in.length]; | |
| 56 | - | |
| 57 | - out.length = PIPE_BUFFER_LENGTH; | |
| 58 | - out.used = 0; | |
| 59 | - out.block = new uint8_t[out.length]; | |
| 60 | - | |
| 61 | - } | |
| 62 | - | |
| 63 | - IPC::Request::Request(const Session &session, const char *method) : Request(session) { | |
| 64 | - | |
| 65 | - // Add name | |
| 66 | - strcpy((char *) out.block, method); | |
| 67 | - out.used += strlen((char *) method) + 1; | |
| 68 | - | |
| 69 | - // Add ID | |
| 70 | - *((uint16_t *) (out.block + out.used)) = (uint16_t) 3; | |
| 71 | - out.used += sizeof(uint16_t); | |
| 72 | - | |
| 73 | - } | |
| 74 | - | |
| 75 | - IPC::Request::Request(const Session &session, bool isSet, const char *property) : Request(session) { | |
| 76 | - | |
| 77 | - // Add name | |
| 78 | - strcpy((char *) out.block, property); | |
| 79 | - out.used += strlen((char *) property) + 1; | |
| 80 | - | |
| 81 | - // Add ID (SetProperty = 2, getProperty = 1) | |
| 82 | - *((uint16_t *) (out.block + out.used)) = (uint16_t) (isSet ? 2 : 1); | |
| 83 | - out.used += sizeof(uint16_t); | |
| 84 | - | |
| 85 | - } | |
| 86 | - | |
| 87 | - IPC::Request::~Request() { | |
| 88 | - | |
| 89 | - delete[] ((uint8_t *) in.block); | |
| 90 | - delete[] ((uint8_t *) out.block); | |
| 91 | - | |
| 92 | - } | |
| 93 | - | |
| 94 | - /// @brief Store value on data block. | |
| 95 | - IPC::Request::DataBlock * IPC::Request::pushBlock(const void *ptr, size_t length) { | |
| 96 | - | |
| 97 | - if((out.used + length + sizeof(IPC::Request::DataBlock)) >= out.length) { | |
| 98 | - throw std::runtime_error("Too big"); | |
| 99 | - } | |
| 100 | - | |
| 101 | - IPC::Request::DataBlock * rc = (IPC::Request::DataBlock *) (out.block + out.used); | |
| 102 | - memcpy(((uint8_t *) (rc+1)), ((uint8_t *) ptr), length); | |
| 103 | - | |
| 104 | - out.used += (sizeof(IPC::Request::DataBlock) + length); | |
| 105 | - | |
| 106 | - return rc; | |
| 107 | - | |
| 108 | - } | |
| 109 | - | |
| 110 | - /// @brief Get next argument. | |
| 111 | - IPC::Request::DataBlock * IPC::Request::getNextBlock() const { | |
| 112 | - | |
| 113 | - if((in.current + sizeof(IPC::Request::DataBlock)) >= in.used) { | |
| 114 | - throw std::runtime_error("Out of range"); | |
| 115 | - } | |
| 116 | - | |
| 117 | - return (IPC::Request::DataBlock *) (in.block + in.current); | |
| 118 | - | |
| 119 | - } | |
| 120 | - | |
| 121 | - IPC::Request & IPC::Request::push(const char *arg) { | |
| 122 | - pushBlock(arg, strlen(arg)+1)->type = IPC::Request::String; | |
| 123 | - return *this; | |
| 124 | - } | |
| 125 | - | |
| 126 | - IPC::Request & IPC::Request::push(const bool arg) { | |
| 127 | - uint8_t value = (uint8_t) (arg ? 0xff : 0); | |
| 128 | - pushBlock(&value, sizeof(value))->type = IPC::Request::Boolean; | |
| 129 | - return *this; | |
| 130 | - } | |
| 131 | - | |
| 132 | - IPC::Request & IPC::Request::push(const uint8_t arg) { | |
| 133 | - pushBlock(&arg, sizeof(arg))->type = IPC::Request::Uchar; | |
| 134 | - return *this; | |
| 135 | - } | |
| 136 | - | |
| 137 | - IPC::Request & IPC::Request::push(const int32_t arg) { | |
| 138 | - pushBlock(&arg, sizeof(arg))->type = IPC::Request::Int32; | |
| 139 | - return *this; | |
| 140 | - } | |
| 141 | - | |
| 142 | - IPC::Request & IPC::Request::push(const uint32_t arg) { | |
| 143 | - pushBlock(&arg, sizeof(arg))->type = IPC::Request::Uint32; | |
| 144 | - return *this; | |
| 145 | - } | |
| 146 | - | |
| 147 | - IPC::Request & IPC::Request::pop(std::string &value) { | |
| 148 | - DataBlock * block = getNextBlock(); | |
| 149 | - | |
| 150 | - if(block->type != IPC::Request::String) | |
| 151 | - throw std::runtime_error("Invalid format"); | |
| 152 | - | |
| 153 | - const char *ptr = (const char *) (block+1); | |
| 154 | - | |
| 155 | - in.current += (strlen(ptr)+1+sizeof(DataBlock)); | |
| 156 | - | |
| 157 | - value.assign(ptr); | |
| 158 | - | |
| 159 | - return *this; | |
| 160 | - } | |
| 161 | - | |
| 162 | - IPC::Request & IPC::Request::Request::pop(int &value) { | |
| 163 | - | |
| 164 | - DataBlock * block = getNextBlock(); | |
| 165 | - | |
| 166 | - switch(block->type) { | |
| 167 | - case IPC::Request::Int16: | |
| 168 | - value = * ((int16_t *) (block+1)); | |
| 169 | - in.current += sizeof(int16_t) + sizeof(DataBlock); | |
| 170 | - break; | |
| 171 | - | |
| 172 | - case IPC::Request::Int32: | |
| 173 | - value = * ((int32_t *) (block+1)); | |
| 174 | - in.current += sizeof(int32_t) + sizeof(DataBlock); | |
| 175 | - break; | |
| 176 | - | |
| 177 | - case IPC::Request::Int64: | |
| 178 | - value = * ((int64_t *) (block+1)); | |
| 179 | - in.current += sizeof(int64_t) + sizeof(DataBlock); | |
| 180 | - break; | |
| 181 | - | |
| 182 | - default: | |
| 183 | - throw std::runtime_error("Invalid format"); | |
| 184 | - } | |
| 185 | - | |
| 186 | - return *this; | |
| 187 | - } | |
| 188 | - | |
| 189 | - } | |
| 190 | - | |
| 191 | - |
src/client/src/os/windows/resources.rc.in
| ... | ... | @@ -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", "3270 C++ Access Library\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", "@PACKAGE_TARNAME@@DLLEXT@\0" | |
| 18 | - VALUE "ProductName", "@PACKAGE_NAME@\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/client/src/os/windows/session.cc
| ... | ... | @@ -1,142 +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 - 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 | -/** | |
| 31 | - * @file src/os/windows/session.cc | |
| 32 | - * | |
| 33 | - * @brief Implements WIN32 remote session methods. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <cstring> | |
| 41 | - #include <lib3270/trace.h> | |
| 42 | - #include <algorithm> | |
| 43 | - | |
| 44 | - using std::string; | |
| 45 | - | |
| 46 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 47 | - | |
| 48 | - namespace TN3270 { | |
| 49 | - | |
| 50 | - IPC::Session::Session(const char *id) : Abstract::Session() { | |
| 51 | - | |
| 52 | - char *ptr = strchr(id,':'); | |
| 53 | - | |
| 54 | - if(!ptr) | |
| 55 | - throw std::system_error(EINVAL, std::system_category()); | |
| 56 | - | |
| 57 | - string pipename{"\\\\.\\pipe\\"}; | |
| 58 | - | |
| 59 | - pipename += string(id,ptr - id); | |
| 60 | - pipename += "\\"; | |
| 61 | - pipename += (ptr+1); | |
| 62 | - | |
| 63 | - std::transform(pipename.begin(), pipename.end(), pipename.begin(), ::tolower); | |
| 64 | - | |
| 65 | - debug("pipename: \"%s\"",pipename.c_str()); | |
| 66 | - | |
| 67 | - this->hPipe = CreateFile( | |
| 68 | - TEXT(pipename.c_str()), // pipe name | |
| 69 | - GENERIC_READ | // read and write access | |
| 70 | - GENERIC_WRITE, | |
| 71 | - 0, // no sharing | |
| 72 | - NULL, // default security attributes | |
| 73 | - OPEN_EXISTING, // opens existing pipe | |
| 74 | - 0, // default attributes | |
| 75 | - NULL // no template file | |
| 76 | - ); | |
| 77 | - | |
| 78 | - if (hPipe == INVALID_HANDLE_VALUE) { | |
| 79 | - throw std::runtime_error("Can't open IPC Channel"); | |
| 80 | - } | |
| 81 | - | |
| 82 | - // The pipe connected; change to message-read mode. | |
| 83 | - DWORD dwMode = PIPE_READMODE_MESSAGE; | |
| 84 | - if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) { | |
| 85 | - throw std::runtime_error("Can't set IPC Channel mode"); | |
| 86 | - } | |
| 87 | - | |
| 88 | - } | |
| 89 | - | |
| 90 | - IPC::Session::~Session() { | |
| 91 | - CloseHandle(this->hPipe); | |
| 92 | - } | |
| 93 | - | |
| 94 | - | |
| 95 | - IPC::Request & IPC::Request::call() { | |
| 96 | - | |
| 97 | -#ifdef DEBUG | |
| 98 | - // lib3270_trace_data(NULL,"Request block",(const char *) this->out.block, this->out.used); | |
| 99 | -#endif // DEBUG | |
| 100 | - | |
| 101 | - in.current = 0; | |
| 102 | - | |
| 103 | - if(!TransactNamedPipe( | |
| 104 | - this->hPipe, | |
| 105 | - this->out.block, | |
| 106 | - this->out.used, | |
| 107 | - this->in.block, | |
| 108 | - this->in.length, | |
| 109 | - &this->in.used, | |
| 110 | - NULL) | |
| 111 | - ) { | |
| 112 | - | |
| 113 | - throw std::runtime_error("Can't transact on IPC Channel"); | |
| 114 | - | |
| 115 | - } | |
| 116 | - | |
| 117 | - debug("Received response \"", in.block, "\" with ", in.used, " bytes"); | |
| 118 | -#ifdef DEBUG | |
| 119 | - // lib3270_trace_data(NULL,"Response block",(const char *) this->in.block, this->in.used); | |
| 120 | -#endif // DEBUG | |
| 121 | - | |
| 122 | - // Extract response name | |
| 123 | - in.current = strlen((const char *) in.block)+1; | |
| 124 | - | |
| 125 | - // Extract return code | |
| 126 | - uint16_t rc = *((uint16_t *) (in.block + in.current)); | |
| 127 | - in.current += sizeof(uint16_t); | |
| 128 | - | |
| 129 | - // Extract argc | |
| 130 | - uint16_t argc = *((uint16_t *) (in.block + in.current)); | |
| 131 | - in.current += sizeof(uint16_t); | |
| 132 | - | |
| 133 | - debug("Received response \"", ((const char *) in.block), "\" with rc=", rc, " and ", argc, " arguments"); | |
| 134 | - | |
| 135 | - return *this; | |
| 136 | - } | |
| 137 | - | |
| 138 | - | |
| 139 | - | |
| 140 | - } | |
| 141 | - | |
| 142 | - |
src/client/src/session/local/events.cc
| ... | ... | @@ -1,175 +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 - 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 | -/** | |
| 31 | - * @file src/session/local/events.cc | |
| 32 | - * | |
| 33 | - * @brief Implement lib3270 direct access events. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <stdio.h> | |
| 41 | - | |
| 42 | - extern "C" { | |
| 43 | - #include <lib3270/actions.h> | |
| 44 | - #include <lib3270/session.h> | |
| 45 | - } | |
| 46 | - | |
| 47 | - using std::string; | |
| 48 | - | |
| 49 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 50 | - | |
| 51 | -#ifndef HAVE_VASPRINTF | |
| 52 | - int vasprintf(char **strp, const char *fmt, va_list ap) { | |
| 53 | - char buf[1024]; | |
| 54 | - | |
| 55 | - int nc = vsnprintf(buf, sizeof(buf), fmt, args); | |
| 56 | - | |
| 57 | - if(nc < 0) { | |
| 58 | - | |
| 59 | - *strp = strdup(_("Error in vasprintf")); | |
| 60 | - | |
| 61 | - } else if (nc < sizeof(buf)) { | |
| 62 | - | |
| 63 | - *strp = malloc(nc+1); | |
| 64 | - strcpy(*strp, buf); | |
| 65 | - | |
| 66 | - } else { | |
| 67 | - | |
| 68 | - *strp = malloc(nc + 1); | |
| 69 | - if(vsnprintf(*strp, nc, fmt, args) < 0) { | |
| 70 | - free(*strp); | |
| 71 | - *strp = strdup(NULL,_( "Out of memory in vasprintf" ) ); | |
| 72 | - } | |
| 73 | - | |
| 74 | - } | |
| 75 | - | |
| 76 | - return nc; | |
| 77 | - } | |
| 78 | -#endif // !HAVE_VASPRINTF | |
| 79 | - | |
| 80 | - namespace TN3270 { | |
| 81 | - | |
| 82 | - /// @brief Popup Handler. | |
| 83 | - void Local::Session::popupHandler(H3270 *h3270, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) { | |
| 84 | - | |
| 85 | - Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); | |
| 86 | - | |
| 87 | - if(!session) { | |
| 88 | - throw std::runtime_error(_( "Invalid session handler" )); | |
| 89 | - } | |
| 90 | - | |
| 91 | - class PopupEvent : public TN3270::Event { | |
| 92 | - private: | |
| 93 | - LIB3270_NOTIFY type; | |
| 94 | - string title; | |
| 95 | - string msg; | |
| 96 | - string description; | |
| 97 | - | |
| 98 | - public: | |
| 99 | - PopupEvent(LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) : Event(Event::Popup) { | |
| 100 | - | |
| 101 | - this->type = type; | |
| 102 | - this->title = title; | |
| 103 | - this->msg = msg; | |
| 104 | - | |
| 105 | - char * buffer = NULL; | |
| 106 | - if(vasprintf(&buffer,fmt,arg) != -1) { | |
| 107 | - this->description = buffer; | |
| 108 | - free(buffer); | |
| 109 | - } | |
| 110 | - | |
| 111 | -#ifdef DEBUG | |
| 112 | - std::cerr << "Popup:" << std::endl | |
| 113 | - << "\t" << title << std::endl | |
| 114 | - << "\t" << msg << std::endl | |
| 115 | - << "\t" << description << std::endl; | |
| 116 | -#endif // DEBUG | |
| 117 | - | |
| 118 | - } | |
| 119 | - | |
| 120 | - virtual ~PopupEvent() { | |
| 121 | - } | |
| 122 | - | |
| 123 | - /// @brief Get event description. | |
| 124 | - std::string toString() const override { | |
| 125 | - return msg; | |
| 126 | - } | |
| 127 | - | |
| 128 | - | |
| 129 | - }; | |
| 130 | - | |
| 131 | - session->fire(PopupEvent(type,title,msg,fmt,arg)); | |
| 132 | - | |
| 133 | - } | |
| 134 | - | |
| 135 | - /// @brief Connect Handler. | |
| 136 | - void Local::Session::connectHandler(H3270 *h3270, unsigned char connected) { | |
| 137 | - | |
| 138 | - Local::Session * session = (Local::Session *) lib3270_get_user_data(h3270); | |
| 139 | - | |
| 140 | - if(!session) { | |
| 141 | - throw std::runtime_error(_("Invalid session handler")); | |
| 142 | - } | |
| 143 | - | |
| 144 | - class ConnectionEvent : public TN3270::Event { | |
| 145 | - private: | |
| 146 | - bool connected; | |
| 147 | - | |
| 148 | - public: | |
| 149 | - ConnectionEvent(unsigned char connected) : Event(Event::Connection) { | |
| 150 | - this->connected = (connected != 0); | |
| 151 | - | |
| 152 | -#ifdef DEBUG | |
| 153 | - std::cerr << "Session is " << this->toString().c_str() << std::endl; | |
| 154 | -#endif // DEBUG | |
| 155 | - | |
| 156 | - } | |
| 157 | - | |
| 158 | - virtual ~ConnectionEvent() { | |
| 159 | - } | |
| 160 | - | |
| 161 | - /// @brief Get event description. | |
| 162 | - std::string toString() const override { | |
| 163 | - return this->connected ? _("connected") : _("disconnected"); | |
| 164 | - } | |
| 165 | - | |
| 166 | - }; | |
| 167 | - | |
| 168 | - session->fire(ConnectionEvent(connected)); | |
| 169 | - | |
| 170 | - } | |
| 171 | - | |
| 172 | - | |
| 173 | - } | |
| 174 | - | |
| 175 | - |
src/client/src/session/local/session.cc
| ... | ... | @@ -1,389 +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 - 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 | -/** | |
| 31 | - * @file src/session/local/session.cc | |
| 32 | - * | |
| 33 | - * @brief Implement lib3270 direct access layout (NO IPC). | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <lib3270/actions.h> | |
| 41 | - #include <lib3270/properties.h> | |
| 42 | - #include <cstring> | |
| 43 | - | |
| 44 | - extern "C" { | |
| 45 | - #include <lib3270/session.h> | |
| 46 | - } | |
| 47 | - | |
| 48 | - using std::string; | |
| 49 | - | |
| 50 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 51 | - | |
| 52 | - namespace TN3270 { | |
| 53 | - | |
| 54 | - Local::Session::Session() : Abstract::Session() { | |
| 55 | - | |
| 56 | - std::lock_guard<std::mutex> lock(sync); | |
| 57 | - | |
| 58 | - this->hSession = lib3270_session_new(""); | |
| 59 | - lib3270_set_user_data(this->hSession,(void *) this); | |
| 60 | - setCharSet(lib3270_get_display_charset(this->hSession)); | |
| 61 | - | |
| 62 | - lib3270_set_popup_handler(this->hSession, popupHandler); | |
| 63 | - | |
| 64 | - // Setup callbacks | |
| 65 | - struct lib3270_session_callbacks *cbk; | |
| 66 | - | |
| 67 | - cbk = lib3270_get_session_callbacks(this->hSession,sizeof(struct lib3270_session_callbacks)); | |
| 68 | - if(!cbk) { | |
| 69 | - throw std::runtime_error( _("Invalid callback table, possible version mismatch in lib3270") ); | |
| 70 | - } | |
| 71 | - | |
| 72 | - cbk->update_connect = connectHandler; | |
| 73 | - | |
| 74 | - | |
| 75 | - } | |
| 76 | - | |
| 77 | - Local::Session::~Session() { | |
| 78 | - | |
| 79 | - std::lock_guard<std::mutex> lock(sync); | |
| 80 | - | |
| 81 | - lib3270_session_free(this->hSession); | |
| 82 | - this->hSession = nullptr; | |
| 83 | - } | |
| 84 | - | |
| 85 | - void Local::Session::wait(time_t timeout) { | |
| 86 | - | |
| 87 | - std::lock_guard<std::mutex> lock(sync); | |
| 88 | - | |
| 89 | - int rc = lib3270_wait_for_ready(this->hSession, timeout); | |
| 90 | - | |
| 91 | - if(rc) { | |
| 92 | - throw std::system_error(rc, std::system_category()); | |
| 93 | - } | |
| 94 | - | |
| 95 | - } | |
| 96 | - | |
| 97 | - void Local::Session::connect(const char *url) { | |
| 98 | - std::lock_guard<std::mutex> lock(sync); | |
| 99 | - int rc = lib3270_connect_url(hSession,url,0); | |
| 100 | - | |
| 101 | - if(rc) { | |
| 102 | - throw std::system_error(rc, std::system_category()); | |
| 103 | - } | |
| 104 | - | |
| 105 | - } | |
| 106 | - | |
| 107 | - void Local::Session::disconnect() { | |
| 108 | - std::lock_guard<std::mutex> lock(sync); | |
| 109 | - lib3270_disconnect(hSession); | |
| 110 | - } | |
| 111 | - | |
| 112 | - // Wait for session state. | |
| 113 | - void Local::Session::waitForReady(time_t timeout) throw() { | |
| 114 | - this->wait(timeout); | |
| 115 | - } | |
| 116 | - | |
| 117 | - std::string Local::Session::toString(int baddr, size_t len, char lf) const { | |
| 118 | - | |
| 119 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 120 | - | |
| 121 | - char * text = lib3270_get_string_at_address(hSession, baddr, len, lf); | |
| 122 | - | |
| 123 | - if(!text) { | |
| 124 | - throw std::runtime_error( _("Can't get screen contents") ); | |
| 125 | - } | |
| 126 | - | |
| 127 | - string rc = convertFromHost(text); | |
| 128 | - | |
| 129 | - lib3270_free(text); | |
| 130 | - | |
| 131 | - return rc; | |
| 132 | - | |
| 133 | - } | |
| 134 | - | |
| 135 | - std::string Local::Session::toString(int row, int col, size_t sz, char lf) const { | |
| 136 | - | |
| 137 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 138 | - | |
| 139 | - char * text = lib3270_get_string_at(hSession, row, col, sz, lf); | |
| 140 | - | |
| 141 | - if(!text) { | |
| 142 | - throw std::runtime_error( _("Can't get screen contents") ); | |
| 143 | - } | |
| 144 | - | |
| 145 | - string rc = convertFromHost(text); | |
| 146 | - | |
| 147 | - lib3270_free(text); | |
| 148 | - | |
| 149 | - return rc; | |
| 150 | - } | |
| 151 | - | |
| 152 | - void Local::Session::getProperty(const char *name, int &value) const { | |
| 153 | - | |
| 154 | - const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
| 155 | - for(size_t ix = 0; intprop[ix].name; ix++) { | |
| 156 | - | |
| 157 | - if(!strcasecmp(name,intprop[ix].name)) { | |
| 158 | - | |
| 159 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 160 | - | |
| 161 | - value = intprop[ix].get(hSession); | |
| 162 | - | |
| 163 | - if(value < 0 && errno != 0) { | |
| 164 | - throw std::system_error(errno, std::system_category()); | |
| 165 | - } | |
| 166 | - | |
| 167 | - | |
| 168 | - } | |
| 169 | - | |
| 170 | - } | |
| 171 | - | |
| 172 | - throw std::system_error(ENOENT, std::system_category()); | |
| 173 | - | |
| 174 | - } | |
| 175 | - | |
| 176 | - void Local::Session::getProperty(const char *name, std::string &value) const { | |
| 177 | - | |
| 178 | - const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
| 179 | - | |
| 180 | - for(size_t ix = 0; strprop[ix].name; ix++) { | |
| 181 | - | |
| 182 | - if(!strcasecmp(name,strprop[ix].name)) { | |
| 183 | - | |
| 184 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 185 | - | |
| 186 | - // Found it! | |
| 187 | - const char * str = strprop[ix].get(hSession); | |
| 188 | - | |
| 189 | - if(str) { | |
| 190 | - value.assign(str); | |
| 191 | - return; | |
| 192 | - } | |
| 193 | - | |
| 194 | - throw std::system_error(errno, std::system_category()); | |
| 195 | - | |
| 196 | - } | |
| 197 | - | |
| 198 | - } | |
| 199 | - | |
| 200 | - throw std::system_error(ENOENT, std::system_category()); | |
| 201 | - } | |
| 202 | - | |
| 203 | - void Local::Session::getProperty(const char *name, bool &value) const { | |
| 204 | - | |
| 205 | - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(name); | |
| 206 | - if(toggle != (LIB3270_TOGGLE) -1) { | |
| 207 | - | |
| 208 | - // Is a Tn3270 toggle, get it! | |
| 209 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 210 | - value = lib3270_get_toggle(hSession,toggle); | |
| 211 | - | |
| 212 | - } | |
| 213 | - | |
| 214 | - throw std::system_error(ENOENT, std::system_category()); | |
| 215 | - } | |
| 216 | - | |
| 217 | - ProgramMessage Local::Session::getProgramMessage() const { | |
| 218 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 219 | - return (ProgramMessage) lib3270_get_program_message(this->hSession); | |
| 220 | - } | |
| 221 | - | |
| 222 | - ConnectionState Local::Session::getConnectionState() const { | |
| 223 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 224 | - return (ConnectionState) lib3270_get_connection_state(this->hSession); | |
| 225 | - } | |
| 226 | - | |
| 227 | - /// @brief Set field at current position, jumps to next writable field. | |
| 228 | - TN3270::Session & Local::Session::push(const char *text) { | |
| 229 | - std::lock_guard<std::mutex> lock(sync); | |
| 230 | - return *this; | |
| 231 | - } | |
| 232 | - | |
| 233 | - TN3270::Session & Local::Session::push(int baddr, const std::string &text) { | |
| 234 | - std::lock_guard<std::mutex> lock(sync); | |
| 235 | - return *this; | |
| 236 | - } | |
| 237 | - | |
| 238 | - TN3270::Session & Local::Session::push(int row, int col, const std::string &text) { | |
| 239 | - std::lock_guard<std::mutex> lock(sync); | |
| 240 | - return *this; | |
| 241 | - } | |
| 242 | - | |
| 243 | - TN3270::Session & Local::Session::push(const PFKey key) { | |
| 244 | - std::lock_guard<std::mutex> lock(sync); | |
| 245 | - lib3270_pfkey(hSession,(int) key); | |
| 246 | - return *this; | |
| 247 | - } | |
| 248 | - | |
| 249 | - TN3270::Session & Local::Session::push(const PAKey key) { | |
| 250 | - std::lock_guard<std::mutex> lock(sync); | |
| 251 | - lib3270_pakey(hSession,(int) key); | |
| 252 | - return *this; | |
| 253 | - } | |
| 254 | - | |
| 255 | - TN3270::Session & Local::Session::push(const Action action) { | |
| 256 | - | |
| 257 | - typedef int (*ActionCallback)(H3270 *); | |
| 258 | - | |
| 259 | - static const ActionCallback actions[] = { | |
| 260 | - lib3270_enter, | |
| 261 | - lib3270_erase, | |
| 262 | - lib3270_eraseeof, | |
| 263 | - lib3270_eraseeol, | |
| 264 | - lib3270_eraseinput | |
| 265 | - }; | |
| 266 | - | |
| 267 | - if( ((size_t) action) > (sizeof(actions)/sizeof(actions[0]))) { | |
| 268 | - throw std::system_error(EINVAL, std::system_category()); | |
| 269 | - } | |
| 270 | - | |
| 271 | - std::lock_guard<std::mutex> lock(sync); | |
| 272 | - | |
| 273 | - int rc = actions[(size_t) action](hSession); | |
| 274 | - | |
| 275 | - if(rc) { | |
| 276 | - throw std::system_error(errno, std::system_category()); | |
| 277 | - } | |
| 278 | - | |
| 279 | - return *this; | |
| 280 | - } | |
| 281 | - | |
| 282 | - TN3270::Session & Local::Session::pop(int baddr, std::string &text) { | |
| 283 | - | |
| 284 | - std::lock_guard<std::mutex> lock(sync); | |
| 285 | - | |
| 286 | - if(!lib3270_is_connected(hSession)) { | |
| 287 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 288 | - } | |
| 289 | - | |
| 290 | - char *contents = lib3270_get_field_text_at(hSession, baddr); | |
| 291 | - | |
| 292 | - if(!contents) { | |
| 293 | - throw std::system_error(errno, std::system_category()); | |
| 294 | - } | |
| 295 | - | |
| 296 | - text.assign(convertFromHost(contents).c_str()); | |
| 297 | - | |
| 298 | - lib3270_free(contents); | |
| 299 | - | |
| 300 | - return *this; | |
| 301 | - } | |
| 302 | - | |
| 303 | - TN3270::Session & Local::Session::pop(int row, int col, std::string &text) { | |
| 304 | - return this->pop(lib3270_translate_to_address(hSession,row,col),text); | |
| 305 | - } | |
| 306 | - | |
| 307 | - TN3270::Session & Local::Session::pop(std::string &text) { | |
| 308 | - | |
| 309 | - std::lock_guard<std::mutex> lock(sync); | |
| 310 | - | |
| 311 | - if(!lib3270_is_connected(hSession)) { | |
| 312 | - throw std::system_error(ENOTCONN, std::system_category()); | |
| 313 | - } | |
| 314 | - | |
| 315 | - int baddr = lib3270_get_cursor_address(hSession); | |
| 316 | - if(baddr < 0) { | |
| 317 | - throw std::system_error(errno, std::system_category()); | |
| 318 | - } | |
| 319 | - | |
| 320 | - char *contents = lib3270_get_field_text_at(hSession, baddr); | |
| 321 | - | |
| 322 | - if(!contents) { | |
| 323 | - throw std::system_error(errno, std::system_category()); | |
| 324 | - } | |
| 325 | - | |
| 326 | - text.assign(convertFromHost(contents).c_str()); | |
| 327 | - | |
| 328 | - lib3270_free(contents); | |
| 329 | - | |
| 330 | - baddr = lib3270_get_next_unprotected(hSession,baddr); | |
| 331 | - if(!baddr) { | |
| 332 | - baddr = lib3270_get_next_unprotected(hSession,0); | |
| 333 | - } | |
| 334 | - | |
| 335 | - if(lib3270_set_cursor_address(hSession,baddr)) { | |
| 336 | - throw std::system_error(errno, std::system_category()); | |
| 337 | - } | |
| 338 | - | |
| 339 | - return *this; | |
| 340 | - } | |
| 341 | - | |
| 342 | - /// @brief Set cursor address. | |
| 343 | - /// | |
| 344 | - /// @param addr Cursor address. | |
| 345 | - TN3270::Session & Local::Session::setCursorPosition(unsigned short addr) { | |
| 346 | - | |
| 347 | - if(lib3270_set_cursor_address(hSession,addr) < 0) { | |
| 348 | - throw std::system_error(errno, std::system_category()); | |
| 349 | - } | |
| 350 | - | |
| 351 | - return *this; | |
| 352 | - } | |
| 353 | - | |
| 354 | - /// @brief Set cursor position. | |
| 355 | - /// | |
| 356 | - /// @param row New cursor row. | |
| 357 | - /// @param col New cursor column. | |
| 358 | - TN3270::Session & Local::Session::setCursorPosition(unsigned short row, unsigned short col) { | |
| 359 | - | |
| 360 | - if(lib3270_set_cursor_position(hSession,row,col)) { | |
| 361 | - throw std::system_error(errno, std::system_category()); | |
| 362 | - } | |
| 363 | - | |
| 364 | - return *this; | |
| 365 | - | |
| 366 | - } | |
| 367 | - | |
| 368 | - // Get properties. | |
| 369 | - std::string Local::Session::getVersion() const { | |
| 370 | - return lib3270_get_version(); | |
| 371 | - } | |
| 372 | - | |
| 373 | - std::string Local::Session::getRevision() const { | |
| 374 | - return lib3270_get_revision(); | |
| 375 | - } | |
| 376 | - | |
| 377 | - /// @brief Execute action by name. | |
| 378 | - TN3270::Session & Local::Session::action(const char *action_name) { | |
| 379 | - | |
| 380 | - if(lib3270_action(hSession,action_name)) { | |
| 381 | - throw std::system_error(errno, std::system_category()); | |
| 382 | - } | |
| 383 | - | |
| 384 | - return *this; | |
| 385 | - } | |
| 386 | - | |
| 387 | - } | |
| 388 | - | |
| 389 | - |
src/client/src/session/remote/session.cc
| ... | ... | @@ -1,365 +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 - 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 | -/** | |
| 31 | - * @file src/session/remote/session.cc | |
| 32 | - * | |
| 33 | - * @brief Implements lib3270 access using IPC calls. | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <cstring> | |
| 41 | - | |
| 42 | - using std::string; | |
| 43 | - | |
| 44 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 45 | - | |
| 46 | - namespace TN3270 { | |
| 47 | - | |
| 48 | - void IPC::Session::connect(const char *url) { | |
| 49 | - Request request(*this,"connect"); | |
| 50 | - request.push(url).call(); | |
| 51 | - } | |
| 52 | - | |
| 53 | - void IPC::Session::disconnect() { | |
| 54 | - Request(*this,"disconnect").call(); | |
| 55 | - } | |
| 56 | - | |
| 57 | - // Wait for session state. | |
| 58 | - void IPC::Session::waitForReady(time_t timeout) { | |
| 59 | - | |
| 60 | - int rc; | |
| 61 | - | |
| 62 | - time_t end = time(nullptr) + timeout; | |
| 63 | - | |
| 64 | - while(time(nullptr) < end) { | |
| 65 | - | |
| 66 | - debug("Running waitForReady request..."); | |
| 67 | - | |
| 68 | - Request(*this,"waitForReady") | |
| 69 | - .push((uint32_t) 1) | |
| 70 | - .call() | |
| 71 | - .pop(rc); | |
| 72 | - | |
| 73 | - debug("Wait for ready returned ",rc); | |
| 74 | - | |
| 75 | - if(rc == 0) | |
| 76 | - return; | |
| 77 | - | |
| 78 | - } | |
| 79 | - | |
| 80 | - throw std::system_error(ETIMEDOUT, std::system_category()); | |
| 81 | - } | |
| 82 | - | |
| 83 | - std::string IPC::Session::toString(int baddr, size_t len, char lf) const { | |
| 84 | - | |
| 85 | - std::string rc; | |
| 86 | - | |
| 87 | - Request(*this,"getStringAtAddress") | |
| 88 | - .push((uint32_t) baddr) | |
| 89 | - .push((uint32_t) len) | |
| 90 | - .push((uint8_t) lf) | |
| 91 | - .call() | |
| 92 | - .pop(rc); | |
| 93 | - | |
| 94 | - return rc; | |
| 95 | - } | |
| 96 | - | |
| 97 | - std::string IPC::Session::toString(int row, int col, size_t sz, char lf) const { | |
| 98 | - | |
| 99 | - std::string rc; | |
| 100 | - | |
| 101 | - Request(*this,"getStringAt") | |
| 102 | - .push((uint32_t) row) | |
| 103 | - .push((uint32_t) col) | |
| 104 | - .push((uint32_t) sz) | |
| 105 | - .push((uint8_t) lf) | |
| 106 | - .call() | |
| 107 | - .pop(rc); | |
| 108 | - | |
| 109 | - return rc; | |
| 110 | - } | |
| 111 | - | |
| 112 | - ProgramMessage IPC::Session::getProgramMessage() const { | |
| 113 | - | |
| 114 | - int program_message; | |
| 115 | - getProperty("program_message",program_message); | |
| 116 | - return (ProgramMessage) program_message; | |
| 117 | - | |
| 118 | - } | |
| 119 | - | |
| 120 | - ConnectionState IPC::Session::getConnectionState() const { | |
| 121 | - | |
| 122 | - int cstate; | |
| 123 | - getProperty("cstate",cstate); | |
| 124 | - return (ConnectionState) cstate; | |
| 125 | - | |
| 126 | - } | |
| 127 | - | |
| 128 | - /// @brief Set field at current position, jumps to next writable field. | |
| 129 | - TN3270::Session & IPC::Session::push(const char *text) { | |
| 130 | - | |
| 131 | - int rc; | |
| 132 | - | |
| 133 | - Request(*this,"setString") | |
| 134 | - .push(text) | |
| 135 | - .call() | |
| 136 | - .pop(rc); | |
| 137 | - | |
| 138 | - if(rc) { | |
| 139 | - throw std::system_error((int) rc, std::system_category()); | |
| 140 | - } | |
| 141 | - | |
| 142 | - return *this; | |
| 143 | - | |
| 144 | - } | |
| 145 | - | |
| 146 | - TN3270::Session & IPC::Session::push(int baddr, const std::string &text) { | |
| 147 | - | |
| 148 | - int rc; | |
| 149 | - | |
| 150 | - Request(*this,"setStringAtAddress") | |
| 151 | - .push((uint32_t) baddr) | |
| 152 | - .push(text.c_str()) | |
| 153 | - .call() | |
| 154 | - .pop(rc); | |
| 155 | - | |
| 156 | - if(rc) { | |
| 157 | - throw std::system_error((int) rc, std::system_category()); | |
| 158 | - } | |
| 159 | - | |
| 160 | - return *this; | |
| 161 | - | |
| 162 | - } | |
| 163 | - | |
| 164 | - TN3270::Session & IPC::Session::push(int row, int col, const std::string &text) { | |
| 165 | - | |
| 166 | - int32_t rc; | |
| 167 | - | |
| 168 | - Request(*this,"setStringAt") | |
| 169 | - .push((uint32_t) row) | |
| 170 | - .push((uint32_t) col) | |
| 171 | - .push(text.c_str()) | |
| 172 | - .call() | |
| 173 | - .pop(rc); | |
| 174 | - | |
| 175 | - if(rc) { | |
| 176 | - throw std::system_error((int) rc, std::system_category()); | |
| 177 | - } | |
| 178 | - | |
| 179 | - return *this; | |
| 180 | - | |
| 181 | - } | |
| 182 | - | |
| 183 | - TN3270::Session & IPC::Session::push(const PFKey key) { | |
| 184 | - | |
| 185 | - int32_t rc; | |
| 186 | - | |
| 187 | - Request(*this,"pfkey") | |
| 188 | - .push((uint32_t) key) | |
| 189 | - .call() | |
| 190 | - .pop(rc); | |
| 191 | - | |
| 192 | - if(rc) { | |
| 193 | - throw std::system_error((int) rc, std::system_category()); | |
| 194 | - } | |
| 195 | - | |
| 196 | - return *this; | |
| 197 | - | |
| 198 | - } | |
| 199 | - | |
| 200 | - TN3270::Session & IPC::Session::push(const PAKey key) { | |
| 201 | - | |
| 202 | - int32_t rc; | |
| 203 | - | |
| 204 | - Request(*this,"pakey") | |
| 205 | - .push((uint32_t) key) | |
| 206 | - .call() | |
| 207 | - .pop(rc); | |
| 208 | - | |
| 209 | - if(rc) { | |
| 210 | - throw std::system_error((int) rc, std::system_category()); | |
| 211 | - } | |
| 212 | - | |
| 213 | - return *this; | |
| 214 | - | |
| 215 | - } | |
| 216 | - | |
| 217 | - TN3270::Session & IPC::Session::push(const Action action) { | |
| 218 | - | |
| 219 | - const char * actions[] = { | |
| 220 | - "enter", | |
| 221 | - "erase", | |
| 222 | - "eraseeof", | |
| 223 | - "eraseeol", | |
| 224 | - "eraseinput" | |
| 225 | - }; | |
| 226 | - | |
| 227 | - if( ((size_t) action) > (sizeof(actions)/sizeof(actions[0]))) { | |
| 228 | - throw std::system_error(EINVAL, std::system_category()); | |
| 229 | - } | |
| 230 | - | |
| 231 | - return this->action(actions[action]); | |
| 232 | - | |
| 233 | - } | |
| 234 | - | |
| 235 | - TN3270::Session & IPC::Session::pop(int baddr, std::string &text) { | |
| 236 | - | |
| 237 | - Request(*this,"getFieldAtAddress") | |
| 238 | - .push((uint32_t) baddr) | |
| 239 | - .call() | |
| 240 | - .pop(text); | |
| 241 | - | |
| 242 | - return *this; | |
| 243 | - } | |
| 244 | - | |
| 245 | - TN3270::Session & IPC::Session::pop(int row, int col, std::string &text) { | |
| 246 | - | |
| 247 | - Request(*this,"getFieldAt") | |
| 248 | - .push((uint32_t) row) | |
| 249 | - .push((uint32_t) col) | |
| 250 | - .call() | |
| 251 | - .pop(text); | |
| 252 | - | |
| 253 | - return *this; | |
| 254 | - } | |
| 255 | - | |
| 256 | - TN3270::Session & IPC::Session::pop(std::string &text) { | |
| 257 | - | |
| 258 | - Request(*this,"getFieldAtCursor") | |
| 259 | - .call() | |
| 260 | - .pop(text); | |
| 261 | - | |
| 262 | - return *this; | |
| 263 | - | |
| 264 | - } | |
| 265 | - | |
| 266 | - /// @brief Set cursor address. | |
| 267 | - /// | |
| 268 | - /// @param addr Cursor address. | |
| 269 | - TN3270::Session & IPC::Session::setCursorPosition(unsigned short addr) { | |
| 270 | - | |
| 271 | - int32_t rc; | |
| 272 | - | |
| 273 | - Request(*this,"setCursorAddress") | |
| 274 | - .push((uint32_t) addr) | |
| 275 | - .call() | |
| 276 | - .pop(rc); | |
| 277 | - | |
| 278 | - if(rc) { | |
| 279 | - throw std::system_error((int) rc, std::system_category()); | |
| 280 | - } | |
| 281 | - | |
| 282 | - return *this; | |
| 283 | - | |
| 284 | - } | |
| 285 | - | |
| 286 | - /// @brief Set cursor position. | |
| 287 | - /// | |
| 288 | - /// @param row New cursor row. | |
| 289 | - /// @param col New cursor column. | |
| 290 | - TN3270::Session & IPC::Session::setCursorPosition(unsigned short row, unsigned short col) { | |
| 291 | - | |
| 292 | - int32_t rc; | |
| 293 | - | |
| 294 | - Request(*this,"setCursorPosition") | |
| 295 | - .push((uint32_t) row) | |
| 296 | - .push((uint32_t) col) | |
| 297 | - .call() | |
| 298 | - .pop(rc); | |
| 299 | - | |
| 300 | - if(rc) { | |
| 301 | - throw std::system_error((int) rc, std::system_category()); | |
| 302 | - } | |
| 303 | - | |
| 304 | - return *this; | |
| 305 | - | |
| 306 | - } | |
| 307 | - | |
| 308 | - void IPC::Session::getProperty(const char *name, int &value) const { | |
| 309 | - | |
| 310 | - Request(*this,false,name) | |
| 311 | - .call() | |
| 312 | - .pop(value); | |
| 313 | - | |
| 314 | - } | |
| 315 | - | |
| 316 | - void IPC::Session::getProperty(const char *name, std::string &value) const { | |
| 317 | - | |
| 318 | - Request(*this,false,name) | |
| 319 | - .call() | |
| 320 | - .pop(value); | |
| 321 | - | |
| 322 | - } | |
| 323 | - | |
| 324 | - void IPC::Session::getProperty(const char *name, bool &value) const { | |
| 325 | - throw std::system_error(ENOENT, std::system_category()); | |
| 326 | - } | |
| 327 | - | |
| 328 | - /// @brief Get lib3270 version. | |
| 329 | - std::string IPC::Session::getVersion() const { | |
| 330 | - | |
| 331 | - string rc; | |
| 332 | - getProperty("version",rc); | |
| 333 | - return rc; | |
| 334 | - | |
| 335 | - } | |
| 336 | - | |
| 337 | - /// @brief Get lib3270 revision. | |
| 338 | - std::string IPC::Session::getRevision() const { | |
| 339 | - | |
| 340 | - string rc; | |
| 341 | - getProperty("revision",rc); | |
| 342 | - return rc; | |
| 343 | - | |
| 344 | - } | |
| 345 | - | |
| 346 | - /// @brief Execute action by name. | |
| 347 | - TN3270::Session & IPC::Session::action(const char *action_name) { | |
| 348 | - | |
| 349 | - int32_t rc; | |
| 350 | - | |
| 351 | - Request(*this,"action") | |
| 352 | - .push(action_name) | |
| 353 | - .call() | |
| 354 | - .pop(rc); | |
| 355 | - | |
| 356 | - if(rc) { | |
| 357 | - throw std::system_error((int) rc, std::system_category()); | |
| 358 | - } | |
| 359 | - | |
| 360 | - return *this; | |
| 361 | - } | |
| 362 | - | |
| 363 | - } | |
| 364 | - | |
| 365 | - |
src/client/src/testprogram/testprogram.cc
| ... | ... | @@ -1,103 +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 - 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 | -/** | |
| 31 | - * @file src/lib3270++/testprogram/testprogram.cc | |
| 32 | - * | |
| 33 | - * @brief | |
| 34 | - * | |
| 35 | - * @author perry.werneck@gmail.com | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include <getopt.h> | |
| 40 | - #include <cstdlib> | |
| 41 | - #include <lib3270++.h> | |
| 42 | - | |
| 43 | - using namespace std; | |
| 44 | - | |
| 45 | -/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | - int main(int argc, char **argv) { | |
| 48 | - | |
| 49 | - const char * session = "pw3270:a"; | |
| 50 | - | |
| 51 | - #pragma GCC diagnostic push | |
| 52 | - #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | |
| 53 | - static struct option options[] = { | |
| 54 | - { "session", required_argument, 0, 's' }, | |
| 55 | - { 0, 0, 0, 0} | |
| 56 | - | |
| 57 | - }; | |
| 58 | - #pragma GCC diagnostic pop | |
| 59 | - | |
| 60 | - int long_index =0; | |
| 61 | - int opt; | |
| 62 | - while((opt = getopt_long(argc, argv, "s:", options, &long_index )) != -1) { | |
| 63 | - | |
| 64 | - switch(opt) { | |
| 65 | - case 's': | |
| 66 | - session = optarg; | |
| 67 | - break; | |
| 68 | - | |
| 69 | - } | |
| 70 | - | |
| 71 | - } | |
| 72 | - | |
| 73 | - TN3270::Host host{session}; | |
| 74 | - | |
| 75 | - try { | |
| 76 | - | |
| 77 | - cout | |
| 78 | - << "Version: " << host.getVersion() | |
| 79 | - << "\tRevision: " << host.getRevision() | |
| 80 | - << std::endl; | |
| 81 | - | |
| 82 | - cout | |
| 83 | - << "Connection state is " << host.getConnectionState() | |
| 84 | - << "\tProgram message is " << host.getProgramMessage() | |
| 85 | - << std::endl; | |
| 86 | - | |
| 87 | - // host.connect(getenv("LIB3270_DEFAULT_HOST")); | |
| 88 | - | |
| 89 | - if(host) { | |
| 90 | - cout << host << endl; | |
| 91 | - } | |
| 92 | - | |
| 93 | - } catch(const std::exception &e) { | |
| 94 | - | |
| 95 | - cerr << std::endl << e.what() << std::endl << std::endl; | |
| 96 | - | |
| 97 | - } | |
| 98 | - | |
| 99 | - | |
| 100 | - return 0; | |
| 101 | - } | |
| 102 | - | |
| 103 | - |
src/client/valgrind.suppression