Commit 6628e983087bd9d91a7c66ab5b8450195edc9800

Authored by perry.werneck@gmail.com
1 parent ad95f222

Implementando carga dinâmica da lib3270 no módulo rexx stand-alone

src/plugins/rx3270/Makefile.in
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 MODULE_NAME=rx3270 29 MODULE_NAME=rx3270
30 DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile 30 DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
31 PLUGIN_SRC=pluginmain.cc 31 PLUGIN_SRC=pluginmain.cc
32 -EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc 32 +EXTAPI_SRC=rxapimain.cc text.cc typed_routines.cc local.cc
33 33
34 #---[ Tools ]------------------------------------------------------------------ 34 #---[ Tools ]------------------------------------------------------------------
35 35
src/plugins/rx3270/local.cc 0 → 100644
@@ -0,0 +1,530 @@ @@ -0,0 +1,530 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como local.cc e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "rx3270.h"
  31 + #include <string.h>
  32 +
  33 +#if defined WIN32
  34 + #define REXX_DEFAULT_CHARSET "CP1252"
  35 +#else
  36 + #include <dlfcn.h>
  37 + #include <stdio.h>
  38 + #define REXX_DEFAULT_CHARSET "UTF-8"
  39 +#endif
  40 +
  41 +#ifdef HAVE_SYSLOG
  42 + #include <syslog.h>
  43 + #include <stdarg.h>
  44 +#endif // HAVE_SYSLOG
  45 +
  46 +
  47 +/*--[ Class definition ]-----------------------------------------------------------------------------*/
  48 +
  49 + class dynamic : public rx3270
  50 + {
  51 + public:
  52 + dynamic();
  53 + ~dynamic();
  54 +
  55 + const char * get_version(void);
  56 + LIB3270_CSTATE get_cstate(void);
  57 + int disconnect(void);
  58 + int connect(const char *uri, bool wait = true);
  59 + int is_connected(void);
  60 + int is_ready(void);
  61 +
  62 + int iterate(void);
  63 + int wait(int seconds);
  64 + int wait_for_ready(int seconds);
  65 +
  66 + char * get_text_at(int row, int col, size_t sz);
  67 + int cmp_text_at(int row, int col, const char *text);
  68 + int set_text_at(int row, int col, const char *str);
  69 +
  70 + int set_cursor_position(int row, int col);
  71 +
  72 + void set_toggle(LIB3270_TOGGLE ix, bool value);
  73 +
  74 + int enter(void);
  75 + int pfkey(int key);
  76 + int pakey(int key);
  77 +
  78 + private:
  79 +
  80 + const char * (*_get_version)(void);
  81 + LIB3270_CSTATE (*_get_connection_state)(H3270 *h);
  82 + int (*_disconnect)(H3270 *h);
  83 + int (*_connect)(H3270 *h,const char *n, int wait);
  84 + int (*_is_connected)(H3270 *h);
  85 + void (*_main_iterate)(H3270 *h, int wait);
  86 + int (*_wait)(H3270 *hSession, int seconds);
  87 + int (*_enter)(H3270 *hSession);
  88 + int (*_pfkey)(H3270 *hSession, int key);
  89 + int (*_pakey)(H3270 *hSession, int key);
  90 + int (*_wait_for_ready)(H3270 *hSession, int seconds);
  91 + char * (*_get_text_at)(H3270 *h, int row, int col, int len);
  92 + int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text);
  93 + int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str);
  94 + int (*_is_ready)(H3270 *h);
  95 + int (*_set_cursor_position)(H3270 *h, int row, int col);
  96 + void (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value);
  97 +
  98 +#ifdef WIN32
  99 + HMODULE hModule
  100 +#else
  101 + void * hModule;
  102 +#endif // WIN32
  103 +
  104 + H3270 * hSession;
  105 +
  106 + };
  107 +
  108 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  109 +
  110 + static bool plugin = false;
  111 + static rx3270 * defSession = NULL;
  112 +
  113 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  114 +
  115 +rx3270::rx3270()
  116 +{
  117 +#ifdef HAVE_ICONV
  118 + this->conv2Local = iconv_open(REXX_DEFAULT_CHARSET, "ISO-8859-1");
  119 + this->conv2Host = iconv_open("ISO-8859-1",REXX_DEFAULT_CHARSET);
  120 +#endif
  121 +
  122 + if(!defSession)
  123 + defSession = this;
  124 +}
  125 +
  126 +rx3270::~rx3270()
  127 +{
  128 +#ifdef HAVE_ICONV
  129 +
  130 + if(conv2Local != (iconv_t) (-1))
  131 + iconv_close(conv2Local);
  132 +
  133 + if(conv2Host != (iconv_t) (-1))
  134 + iconv_close(conv2Host);
  135 +#endif
  136 +
  137 +
  138 + if(defSession == this)
  139 + defSession = NULL;
  140 +}
  141 +
  142 +rx3270 * rx3270::get_default(void)
  143 +{
  144 + if(defSession)
  145 + return defSession;
  146 +
  147 + return new dynamic();
  148 +}
  149 +
  150 +#ifdef WIN32
  151 +static int get_datadir(LPSTR datadir)
  152 +{
  153 + HKEY hKey = 0;
  154 + unsigned long datalen = strlen(datadir);
  155 +
  156 + *datadir = 0;
  157 +
  158 + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
  159 + {
  160 + unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
  161 + if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
  162 + *datadir = 0;
  163 + RegCloseKey(hKey);
  164 + }
  165 +
  166 + return *datadir;
  167 +}
  168 +#endif // WIN32
  169 +
  170 +void rx3270::set_plugin(void)
  171 +{
  172 + trace("%s: Rexx API running as plugin",__FUNCTION__);
  173 + plugin = true;
  174 +}
  175 +
  176 +extern "C"
  177 +{
  178 +
  179 +static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args)
  180 +{
  181 +#ifdef HAVE_SYSLOG
  182 + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
  183 + vsyslog(LOG_INFO,fmt,args);
  184 + closelog();
  185 +#endif // HAVE_SYSLOG
  186 +}
  187 +
  188 +static void tracehandler(H3270 *session, const char *fmt, va_list args)
  189 +{
  190 +#ifdef HAVE_SYSLOG
  191 +
  192 + #define MAX_LOG_LENGTH 200
  193 +
  194 + static char line[MAX_LOG_LENGTH+1];
  195 + char temp[MAX_LOG_LENGTH];
  196 + char * ptr;
  197 + size_t len = strlen(line);
  198 +
  199 + vsnprintf(temp,MAX_LOG_LENGTH-len,fmt,args);
  200 +
  201 + ptr = strchr(temp,'\n');
  202 + if(!ptr)
  203 + {
  204 + strncat(line,temp,MAX_LOG_LENGTH);
  205 + if(strlen(line) >= MAX_LOG_LENGTH)
  206 + {
  207 + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
  208 + syslog(LOG_INFO,line);
  209 + closelog();
  210 + *line = 0;
  211 + }
  212 + return;
  213 + }
  214 +
  215 + *ptr = 0;
  216 + strncat(line,temp,MAX_LOG_LENGTH);
  217 +
  218 + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER);
  219 + syslog(LOG_DEBUG,line);
  220 + closelog();
  221 +
  222 + strncpy(line,ptr+1,MAX_LOG_LENGTH);
  223 +
  224 +#endif // HAVE_SYSLOG
  225 +}
  226 +
  227 +}
  228 +
  229 +dynamic::dynamic()
  230 +{
  231 + H3270 * (*lib3270_new)(const char *);
  232 + void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list));
  233 + void (*set_trace_handler)( void (*handler)(H3270 *session, const char *fmt, va_list args) );
  234 +
  235 + struct _call
  236 + {
  237 + void **entry;
  238 + const char * name;
  239 + } call[] =
  240 + {
  241 + { (void **) & lib3270_new, "lib3270_session_new" },
  242 + { (void **) & set_log_handler, "lib3270_set_log_handler" },
  243 + { (void **) & set_trace_handler, "lib3270_set_trace_handler" },
  244 + { (void **) & _get_version, "lib3270_get_version" },
  245 + { (void **) & _get_connection_state, "lib3270_get_connection_state" },
  246 + { (void **) & _disconnect, "lib3270_disconnect" },
  247 + { (void **) & _connect, "lib3270_connect" },
  248 + { (void **) & _is_connected, "lib3270_in_tn3270e" },
  249 + { (void **) & _main_iterate, "lib3270_main_iterate" },
  250 + { (void **) & _wait, "lib3270_wait" },
  251 + { (void **) & _enter, "lib3270_enter" },
  252 + { (void **) & _pfkey, "lib3270_pfkey" },
  253 + { (void **) & _pakey, "lib3270_pakey" },
  254 + { (void **) & _wait_for_ready, "lib3270_wait_for_ready" },
  255 + { (void **) & _get_text_at, "lib3270_get_text_at" },
  256 + { (void **) & _cmp_text_at, "lib3270_cmp_text_at" },
  257 + { (void **) & _set_text_at, "lib3270_set_string_at" },
  258 + { (void **) & _is_ready, "lib3270_is_ready" },
  259 + { (void **) & _set_cursor_position, "lib3270_set_cursor_position" },
  260 + { (void **) & _set_toggle, "lib3270_set_toggle" },
  261 +
  262 + };
  263 +
  264 +// Load lib3270.dll
  265 +#ifdef WIN32
  266 + static const char *dllname = "lib3270.dll." PACKAGE_VERSION;
  267 +
  268 + int f;
  269 + HMODULE kernel;
  270 + HANDLE cookie = NULL;
  271 + DWORD rc;
  272 + HANDLE (*AddDllDirectory)(PCWSTR NewDirectory);
  273 + BOOL (*RemoveDllDirectory)(HANDLE Cookie);
  274 + UINT errorMode;
  275 + char datadir[4096];
  276 +
  277 + kernel = LoadLibrary("kernel32.dll");
  278 + AddDllDirectory = (HANDLE (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory");
  279 + RemoveDllDirectory = (BOOL (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory");
  280 +
  281 + // Notify user in case of error loading protocol DLL
  282 + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
  283 + errorMode = SetErrorMode(1);
  284 +
  285 + memset(datadir,' ',4095);
  286 + datadir[4095] = 0;
  287 +
  288 + if(get_datadir(datadir))
  289 + {
  290 + char buffer[4096];
  291 + wchar_t path[4096];
  292 +
  293 + mbstowcs(path, datadir, 4095);
  294 + trace("Datadir=[%s] AddDllDirectory=%p RemoveDllDirectory=%p\n",datadir,AddDllDirectory,RemoveDllDirectory);
  295 + if(AddDllDirectory)
  296 + cookie = AddDllDirectory(path);
  297 +
  298 +#ifdef DEBUG
  299 + snprintf(buffer,4096,"%s\\.bin\\Debug\\%s",datadir,dllname);
  300 +#else
  301 + snprintf(buffer,4096,"%s\\%s",datadir,dllname);
  302 +#endif // DEBUG
  303 +
  304 + hModule = LoadLibrary(buffer);
  305 +
  306 + trace("%s hModule=%p rc=%d",buffer,hModule,(int) GetLastError());
  307 +
  308 + if(hModule == NULL)
  309 + {
  310 + // Enable DLL error popup and try again with full path
  311 + SetErrorMode(0);
  312 + hModule = LoadLibraryEx(buffer,NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
  313 + }
  314 +
  315 + rc = GetLastError();
  316 +
  317 + trace("%s hModule=%p rc=%d",buffer,hModule,(int) rc);
  318 + }
  319 + else
  320 + {
  321 + hModule = LoadLibrary(dllname);
  322 + rc = GetLastError();
  323 + }
  324 +
  325 + SetErrorMode(errorMode);
  326 +
  327 + trace("%s hModule=%p rc=%d",dllname,hModule,(int) rc);
  328 +
  329 + if(cookie && RemoveDllDirectory)
  330 + RemoveDllDirectory(cookie);
  331 +
  332 + if(kernel)
  333 + FreeLibrary(kernel);
  334 +
  335 + if(!hModule)
  336 + return;
  337 +
  338 +
  339 +#else
  340 + dlerror();
  341 +
  342 + hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW);
  343 + if(!hModule)
  344 + {
  345 + fprintf(stderr,"Can't load lib3270\n%s\n",dlerror());
  346 + fflush(stderr);
  347 + return;
  348 + }
  349 +
  350 +#endif // WIN32
  351 +
  352 + // Load entry points
  353 + for(unsigned int f = 0; f < (sizeof (call) / sizeof ((call)[0]));f++)
  354 + {
  355 +#ifdef WIN32
  356 + *call[f].entry = (void *) GetProcAddress(hModule,call[f].name);
  357 +#else
  358 + *call[f].entry = dlsym(hModule,call[f].name);
  359 +#endif // WIN32
  360 +
  361 + if(!*call[f].entry)
  362 + {
  363 +#ifndef WIN32
  364 + fprintf(stderr,"Can't load lib3270::%s\n%s\n",call[f].name,dlerror());
  365 + fflush(stderr);
  366 + dlclose(hModule);
  367 +#else
  368 + #error DLL close
  369 +#endif // !WIN32
  370 + hModule = NULL;
  371 + return;
  372 + }
  373 + }
  374 +
  375 + // Get Session handle, setup base callbacks
  376 + set_log_handler(loghandler);
  377 + set_trace_handler(tracehandler);
  378 + this->hSession = lib3270_new("");
  379 +
  380 +}
  381 +
  382 +dynamic::~dynamic()
  383 +{
  384 + static void (*session_free)(void *h);
  385 +
  386 + if(!hModule)
  387 + return;
  388 +
  389 +#ifdef WIN32
  390 +
  391 + session_free = (void (*)(void *h)) GetProcAddress(hModule,"lib3270_session_free");
  392 +
  393 + if(session_free)
  394 + session_free(hSession);
  395 +
  396 + FreeLibrary(hModule);
  397 +
  398 +#else
  399 +
  400 + session_free = (void (*)(void *h)) dlsym(hModule,"lib3270_session_free");
  401 +
  402 + if(session_free)
  403 + session_free(hSession);
  404 +
  405 + dlclose(hModule);
  406 +
  407 +#endif // WIN32
  408 +
  409 +}
  410 +
  411 +const char * dynamic::get_version(void)
  412 +{
  413 + if(!hModule)
  414 + return NULL;
  415 + return _get_version();
  416 +}
  417 +
  418 +LIB3270_CSTATE dynamic::get_cstate(void)
  419 +{
  420 + if(!hModule)
  421 + return (LIB3270_CSTATE) -1;
  422 + return _get_connection_state(hSession);
  423 +}
  424 +
  425 +int dynamic::disconnect(void)
  426 +{
  427 + if(!hModule)
  428 + return -1;
  429 + return _disconnect(hSession);
  430 +}
  431 +
  432 +int dynamic::connect(const char *uri, bool wait)
  433 +{
  434 + if(!hModule)
  435 + return -1;
  436 + return _connect(hSession,uri,(int) wait);
  437 +}
  438 +
  439 +int dynamic::is_connected(void)
  440 +{
  441 + if(!hModule)
  442 + return -1;
  443 + return _is_connected(hSession);
  444 +}
  445 +
  446 +int dynamic::is_ready(void)
  447 +{
  448 + if(!hModule)
  449 + return -1;
  450 + return _is_ready(hSession);
  451 +}
  452 +
  453 +int dynamic::iterate(void)
  454 +{
  455 + if(!hModule)
  456 + return -1;
  457 +
  458 + _main_iterate(hSession,1);
  459 +
  460 + return 0;
  461 +}
  462 +
  463 +int dynamic::wait(int seconds)
  464 +{
  465 + if(!hModule)
  466 + return -1;
  467 + return _wait(hSession,seconds);
  468 +}
  469 +
  470 +int dynamic::wait_for_ready(int seconds)
  471 +{
  472 + if(!hModule)
  473 + return -1;
  474 + return _wait_for_ready(hSession,seconds);
  475 +}
  476 +
  477 +char * dynamic::get_text_at(int row, int col, size_t sz)
  478 +{
  479 + if(!hModule)
  480 + return NULL;
  481 + return _get_text_at(hSession,row,col,sz);
  482 +}
  483 +
  484 +int dynamic::cmp_text_at(int row, int col, const char *text)
  485 +{
  486 + if(!hModule)
  487 + return 0;
  488 + return _cmp_text_at(hSession,row,col,text);
  489 +}
  490 +
  491 +int dynamic::set_text_at(int row, int col, const char *str)
  492 +{
  493 + if(!hModule)
  494 + return -1;
  495 + return _set_text_at(hSession,row,col,(const unsigned char *) str);
  496 +}
  497 +
  498 +int dynamic::set_cursor_position(int row, int col)
  499 +{
  500 + if(!hModule)
  501 + return -1;
  502 + return _set_cursor_position(hSession,row,col);
  503 +}
  504 +
  505 +int dynamic::enter(void)
  506 +{
  507 + if(!hModule)
  508 + return -1;
  509 + return _enter(hSession);
  510 +}
  511 +
  512 +int dynamic::pfkey(int key)
  513 +{
  514 + if(!hModule)
  515 + return -1;
  516 + return _pfkey(hSession,key);
  517 +}
  518 +
  519 +int dynamic::pakey(int key)
  520 +{
  521 + if(!hModule)
  522 + return -1;
  523 + return _pakey(hSession,key);
  524 +}
  525 +
  526 +void dynamic::set_toggle(LIB3270_TOGGLE ix, bool value)
  527 +{
  528 + if(hModule)
  529 + _set_toggle(hSession,ix,(int) value);
  530 +}
src/plugins/rx3270/pluginmain.cc
@@ -55,6 +55,8 @@ @@ -55,6 +55,8 @@
55 55
56 int set_cursor_position(int row, int col); 56 int set_cursor_position(int row, int col);
57 57
  58 + void set_toggle(LIB3270_TOGGLE ix, bool value);
  59 +
58 int enter(void); 60 int enter(void);
59 int pfkey(int key); 61 int pfkey(int key);
60 int pakey(int key); 62 int pakey(int key);
@@ -176,3 +178,8 @@ @@ -176,3 +178,8 @@
176 { 178 {
177 return lib3270_set_cursor_position(hSession,row,col); 179 return lib3270_set_cursor_position(hSession,row,col);
178 } 180 }
  181 +
  182 + void plugin::set_toggle(LIB3270_TOGGLE ix, bool value)
  183 + {
  184 + lib3270_set_toggle(hSession,ix,(int) value);
  185 + }
src/plugins/rx3270/rx3270.h
@@ -101,25 +101,24 @@ @@ -101,25 +101,24 @@
101 virtual const char * get_version(void) = 0; 101 virtual const char * get_version(void) = 0;
102 virtual LIB3270_CSTATE get_cstate(void) = 0; 102 virtual LIB3270_CSTATE get_cstate(void) = 0;
103 103
104 - virtual int connect(const char *uri, bool wait = true) = 0;  
105 - virtual int disconnect(void) = 0;  
106 - virtual int is_connected(void) = 0;  
107 - virtual int is_ready(void) = 0;  
108 - virtual int iterate(void) = 0;  
109 - virtual int wait(int seconds) = 0;  
110 - virtual int wait_for_ready(int seconds) = 0;  
111 - virtual int set_cursor_position(int row, int col) = 0;  
112 -  
113 - virtual int enter(void) = 0;  
114 - virtual int pfkey(int key) = 0;  
115 - virtual int pakey(int key) = 0; 104 + virtual int connect(const char *uri, bool wait = true) = 0;
  105 + virtual int disconnect(void) = 0;
  106 + virtual int is_connected(void) = 0;
  107 + virtual int is_ready(void) = 0;
  108 + virtual int iterate(void) = 0;
  109 + virtual int wait(int seconds) = 0;
  110 + virtual int wait_for_ready(int seconds) = 0;
  111 + virtual int set_cursor_position(int row, int col) = 0;
  112 + virtual void set_toggle(LIB3270_TOGGLE ix, bool value) = 0;
  113 +
  114 + virtual int enter(void) = 0;
  115 + virtual int pfkey(int key) = 0;
  116 + virtual int pakey(int key) = 0;
116 117
117 virtual char * get_text_at(int row, int col, size_t sz) = 0; 118 virtual char * get_text_at(int row, int col, size_t sz) = 0;
118 virtual int cmp_text_at(int row, int col, const char *text) = 0; 119 virtual int cmp_text_at(int row, int col, const char *text) = 0;
119 virtual int set_text_at(int row, int col, const char *str) = 0; 120 virtual int set_text_at(int row, int col, const char *str) = 0;
120 121
121 -  
122 -  
123 }; 122 };
124 123
125 #endif // RX3270_H_INCLUDED 124 #endif // RX3270_H_INCLUDED
src/plugins/rx3270/rxapimain.cc
@@ -41,16 +41,11 @@ @@ -41,16 +41,11 @@
41 #include <string.h> 41 #include <string.h>
42 42
43 #if defined WIN32 43 #if defined WIN32
44 -  
45 - #define REXX_DEFAULT_CHARSET "CP1252"  
46 -  
47 BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd); 44 BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd);
48 static int librx3270_loaded(void); 45 static int librx3270_loaded(void);
49 static int librx3270_unloaded(void); 46 static int librx3270_unloaded(void);
50 #else 47 #else
51 48
52 - #define REXX_DEFAULT_CHARSET "UTF-8"  
53 -  
54 int librx3270_loaded(void) __attribute__((constructor)); 49 int librx3270_loaded(void) __attribute__((constructor));
55 int librx3270_unloaded(void) __attribute__((destructor)); 50 int librx3270_unloaded(void) __attribute__((destructor));
56 #endif 51 #endif
@@ -60,10 +55,6 @@ @@ -60,10 +55,6 @@
60 LIB3270_EXPORT RexxRoutineEntry rx3270_functions[]; 55 LIB3270_EXPORT RexxRoutineEntry rx3270_functions[];
61 LIB3270_EXPORT RexxPackageEntry rx3270_package_entry; 56 LIB3270_EXPORT RexxPackageEntry rx3270_package_entry;
62 57
63 -  
64 - static rx3270 * hSession = NULL;  
65 - static bool plugin = false;  
66 -  
67 /*--[ Implement ]------------------------------------------------------------------------------------*/ 58 /*--[ Implement ]------------------------------------------------------------------------------------*/
68 59
69 #if defined WIN32 60 #if defined WIN32
@@ -92,8 +83,6 @@ int librx3270_loaded(void) @@ -92,8 +83,6 @@ int librx3270_loaded(void)
92 83
93 int librx3270_unloaded(void) 84 int librx3270_unloaded(void)
94 { 85 {
95 - if(hSession)  
96 - delete hSession;  
97 return 0; 86 return 0;
98 } 87 }
99 88
@@ -145,40 +134,3 @@ LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void) @@ -145,40 +134,3 @@ LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void)
145 END_EXTERN_C() 134 END_EXTERN_C()
146 135
147 136
148 -rx3270 * rx3270::get_default(void)  
149 -{  
150 - return hSession;  
151 -}  
152 -  
153 -rx3270::rx3270()  
154 -{  
155 -#ifdef HAVE_ICONV  
156 - this->conv2Local = iconv_open(REXX_DEFAULT_CHARSET, "ISO-8859-1");  
157 - this->conv2Host = iconv_open("ISO-8859-1",REXX_DEFAULT_CHARSET);  
158 -#endif  
159 -  
160 - if(!hSession)  
161 - hSession = this;  
162 -}  
163 -  
164 -rx3270::~rx3270()  
165 -{  
166 -#ifdef HAVE_ICONV  
167 -  
168 - if(conv2Local != (iconv_t) (-1))  
169 - iconv_close(conv2Local);  
170 -  
171 - if(conv2Host != (iconv_t) (-1))  
172 - iconv_close(conv2Host);  
173 -#endif  
174 -  
175 -  
176 - if(hSession == this)  
177 - hSession = NULL;  
178 -}  
179 -  
180 -void rx3270::set_plugin(void)  
181 -{  
182 - trace("%s: Rexx API running as plugin",__FUNCTION__);  
183 - plugin = true;  
184 -}  
src/plugins/rx3270/sample/getversion.rex 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +
  2 +
  3 +say rx3270version()
  4 +
  5 +return 0
  6 +
  7 +::requires "rx3270" library
  8 +