Commit 4f6698343ecec5634cc12966a72350d554f9aaf4
1 parent
7b727cb5
Exists in
master
and in
5 other branches
Iniciando ajustes na extensão rexx para usar carga dinâmica igual à biblioteca de hllapi
Showing
5 changed files
with
263 additions
and
210 deletions
Show diff stats
src/plugins/rx3270/pluginmain.cc
... | ... | @@ -28,18 +28,149 @@ |
28 | 28 | */ |
29 | 29 | |
30 | 30 | #include <pw3270/plugin.h> |
31 | + #include <lib3270/actions.h> | |
31 | 32 | #include "rx3270.h" |
32 | 33 | |
34 | +/*--[ Plugin session object ]--------------------------------------------------------------------------------*/ | |
35 | + | |
36 | + class plugin : public rx3270 | |
37 | + { | |
38 | + public: | |
39 | + plugin(H3270 *hSession); | |
40 | + | |
41 | + const char * get_version(void); | |
42 | + LIB3270_CSTATE get_cstate(void); | |
43 | + int disconnect(void); | |
44 | + int connect(const char *uri, bool wait = true); | |
45 | + int is_connected(void); | |
46 | + int is_ready(void); | |
47 | + | |
48 | + int iterate(void); | |
49 | + int wait(int seconds); | |
50 | + int wait_for_ready(int seconds); | |
51 | + | |
52 | + char * get_text_at(int row, int col, size_t sz); | |
53 | + int cmp_text_at(int row, int col, const char *text); | |
54 | + int set_text_at(int row, int col, const char *str); | |
55 | + | |
56 | + int set_cursor_position(int row, int col); | |
57 | + | |
58 | + int enter(void); | |
59 | + int pfkey(int key); | |
60 | + int pakey(int key); | |
61 | + | |
62 | + private: | |
63 | + H3270 *hSession; | |
64 | + | |
65 | + }; | |
66 | + | |
67 | + static plugin * session = NULL; | |
68 | + | |
33 | 69 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
34 | 70 | |
35 | 71 | LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window) |
36 | 72 | { |
37 | - rx3270_set_mode(RX3270_MODE_PLUGIN); | |
73 | + session = new plugin(lib3270_get_default_session_handle()); | |
38 | 74 | return 0; |
39 | 75 | } |
40 | 76 | |
41 | 77 | LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window) |
42 | 78 | { |
43 | - rx3270_set_mode(RX3270_MODE_UNDEFINED); | |
79 | + if(session) | |
80 | + { | |
81 | + delete session; | |
82 | + session = NULL; | |
83 | + } | |
84 | + return 0; | |
85 | + } | |
86 | + | |
87 | + plugin::plugin(H3270 *hSession) : rx3270() | |
88 | + { | |
89 | + this->hSession = hSession; | |
90 | + } | |
91 | + | |
92 | + const char * plugin::get_version(void) | |
93 | + { | |
94 | + return lib3270_get_version(); | |
95 | + } | |
96 | + | |
97 | + LIB3270_CSTATE plugin::get_cstate(void) | |
98 | + { | |
99 | + return lib3270_get_connection_state(hSession); | |
100 | + } | |
101 | + | |
102 | + int plugin::disconnect(void) | |
103 | + { | |
104 | + lib3270_disconnect(hSession); | |
105 | + return 0; | |
106 | + } | |
107 | + | |
108 | + int plugin::connect(const char *uri, bool wait) | |
109 | + { | |
110 | + return lib3270_connect(hSession,uri,wait); | |
111 | + } | |
112 | + | |
113 | + int plugin::is_connected(void) | |
114 | + { | |
115 | + return lib3270_is_connected(hSession) ? 1 : 0; | |
116 | + } | |
117 | + | |
118 | + int plugin::iterate(void) | |
119 | + { | |
120 | + if(!lib3270_is_connected(hSession)) | |
121 | + return ENOTCONN; | |
122 | + | |
123 | + lib3270_main_iterate(hSession,1); | |
124 | + | |
44 | 125 | return 0; |
45 | 126 | } |
127 | + | |
128 | + int plugin::wait(int seconds) | |
129 | + { | |
130 | + return lib3270_wait(hSession,seconds); | |
131 | + } | |
132 | + | |
133 | + int plugin::enter(void) | |
134 | + { | |
135 | + return lib3270_enter(hSession); | |
136 | + } | |
137 | + | |
138 | + int plugin::pfkey(int key) | |
139 | + { | |
140 | + return lib3270_pfkey(hSession,key); | |
141 | + } | |
142 | + | |
143 | + int plugin::pakey(int key) | |
144 | + { | |
145 | + return lib3270_pakey(hSession,key); | |
146 | + } | |
147 | + | |
148 | + int plugin::wait_for_ready(int seconds) | |
149 | + { | |
150 | + return lib3270_wait_for_ready(hSession,seconds); | |
151 | + } | |
152 | + | |
153 | + char * plugin::get_text_at(int row, int col, size_t sz) | |
154 | + { | |
155 | + return lib3270_get_text_at(hSession,row,col,(int) sz); | |
156 | + } | |
157 | + | |
158 | + int plugin::cmp_text_at(int row, int col, const char *text) | |
159 | + { | |
160 | + return lib3270_cmp_text_at(hSession,row,col,text); | |
161 | + } | |
162 | + | |
163 | + int plugin::set_text_at(int row, int col, const char *str) | |
164 | + { | |
165 | + return lib3270_set_text_at(hSession,row,col,(const unsigned char *) str); | |
166 | + } | |
167 | + | |
168 | + int plugin::is_ready(void) | |
169 | + { | |
170 | + return lib3270_is_ready(hSession); | |
171 | + } | |
172 | + | |
173 | + int plugin::set_cursor_position(int row, int col) | |
174 | + { | |
175 | + return lib3270_set_cursor_position(hSession,row,col); | |
176 | + } | ... | ... |
src/plugins/rx3270/rx3270.h
... | ... | @@ -67,32 +67,58 @@ |
67 | 67 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270WaitForStringAt); |
68 | 68 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270GetStringAt); |
69 | 69 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsTerminalReady); |
70 | - REXX_TYPED_ROUTINE_PROTOTYPE(rx3270ReadScreen); | |
71 | 70 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270queryStringAt); |
72 | 71 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270SetStringAt); |
73 | 72 | |
74 | 73 | /*---[ Globals ]---------------------------------------------------------------------------------------------*/ |
75 | 74 | |
76 | - enum rx3270mode | |
77 | - { | |
78 | - RX3270_MODE_STANDALONE, /**< Running outside pw3270's main process */ | |
79 | - RX3270_MODE_PLUGIN, /**< Running inside pw3270's main process */ | |
80 | - | |
81 | - RX3270_MODE_UNDEFINED | |
82 | - }; | |
75 | +/*--[ 3270 Session ]-----------------------------------------------------------------------------------------*/ | |
83 | 76 | |
84 | - #define RX3270SESSION lib3270_get_default_session_handle() | |
77 | +#if defined (HAVE_GNUC_VISIBILITY) | |
78 | + class __attribute__((visibility("default"))) rx3270 | |
79 | +#else | |
80 | + #error NOT_IMPLEMENTED | |
81 | +#endif | |
82 | + { | |
85 | 83 | |
84 | + protected: | |
86 | 85 | #ifdef HAVE_ICONV |
87 | - extern iconv_t outputConv; | |
88 | - extern iconv_t inputConv; | |
86 | + iconv_t conv2Local; | |
87 | + iconv_t conv2Host; | |
89 | 88 | #endif |
90 | 89 | |
91 | -/*--[ Prototipes ]-------------------------------------------------------------------------------------------*/ | |
90 | + public: | |
91 | + | |
92 | + rx3270(); | |
93 | + virtual ~rx3270(); | |
94 | + | |
95 | + static rx3270 * get_default(void); | |
92 | 96 | |
93 | - char * get_contents(H3270 *hSession, int start, int sz); | |
94 | - char * set_contents(H3270 *hSession, const char *text); | |
97 | + char * get_3270_string(const char *str); | |
98 | + char * get_local_string(const char *str); | |
95 | 99 | |
96 | - LIB3270_EXPORT void rx3270_set_mode(enum rx3270mode mode); | |
100 | + virtual const char * get_version(void) = 0; | |
101 | + virtual LIB3270_CSTATE get_cstate(void) = 0; | |
102 | + | |
103 | + virtual int connect(const char *uri, bool wait = true) = 0; | |
104 | + virtual int disconnect(void) = 0; | |
105 | + virtual int is_connected(void) = 0; | |
106 | + virtual int is_ready(void) = 0; | |
107 | + virtual int iterate(void) = 0; | |
108 | + virtual int wait(int seconds) = 0; | |
109 | + virtual int wait_for_ready(int seconds) = 0; | |
110 | + virtual int set_cursor_position(int row, int col) = 0; | |
111 | + | |
112 | + virtual int enter(void) = 0; | |
113 | + virtual int pfkey(int key) = 0; | |
114 | + virtual int pakey(int key) = 0; | |
115 | + | |
116 | + virtual char * get_text_at(int row, int col, size_t sz) = 0; | |
117 | + virtual int cmp_text_at(int row, int col, const char *text) = 0; | |
118 | + virtual int set_text_at(int row, int col, const char *str) = 0; | |
119 | + | |
120 | + | |
121 | + | |
122 | + }; | |
97 | 123 | |
98 | 124 | #endif // RX3270_H_INCLUDED | ... | ... |
src/plugins/rx3270/rxapimain.cc
... | ... | @@ -38,10 +38,6 @@ |
38 | 38 | #include "rx3270.h" |
39 | 39 | #include <lib3270/actions.h> |
40 | 40 | |
41 | -#ifdef HAVE_ICONV | |
42 | - #include <iconv.h> | |
43 | -#endif | |
44 | - | |
45 | 41 | #include <string.h> |
46 | 42 | |
47 | 43 | #if defined WIN32 |
... | ... | @@ -63,7 +59,7 @@ |
63 | 59 | LIB3270_EXPORT RexxPackageEntry rx3270_package_entry; |
64 | 60 | |
65 | 61 | |
66 | - static enum rx3270mode active_mode = RX3270_MODE_UNDEFINED; | |
62 | + static rx3270 * hSession = NULL; | |
67 | 63 | |
68 | 64 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
69 | 65 | |
... | ... | @@ -86,36 +82,15 @@ BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd) |
86 | 82 | } |
87 | 83 | #endif |
88 | 84 | |
89 | -void rx3270_set_mode(enum rx3270mode mode) | |
90 | -{ | |
91 | - active_mode = mode; | |
92 | -} | |
93 | - | |
94 | 85 | int librx3270_loaded(void) |
95 | 86 | { |
96 | - active_mode = RX3270_MODE_STANDALONE; | |
97 | - | |
98 | -#ifdef HAVE_ICONV | |
99 | - outputConv = iconv_open(REXX_DEFAULT_CHARSET, lib3270_get_default_charset()); | |
100 | - inputConv = iconv_open(lib3270_get_default_charset(), REXX_DEFAULT_CHARSET); | |
101 | -#endif | |
102 | - | |
103 | 87 | return 0; |
104 | 88 | } |
105 | 89 | |
106 | 90 | int librx3270_unloaded(void) |
107 | 91 | { |
108 | - active_mode = RX3270_MODE_UNDEFINED; | |
109 | - | |
110 | -#ifdef HAVE_ICONV | |
111 | - | |
112 | - if(outputConv != (iconv_t) (-1)) | |
113 | - iconv_close(outputConv); | |
114 | - | |
115 | - if(inputConv != (iconv_t) (-1)) | |
116 | - iconv_close(inputConv); | |
117 | -#endif | |
118 | - | |
92 | + if(hSession) | |
93 | + delete hSession; | |
119 | 94 | return 0; |
120 | 95 | } |
121 | 96 | |
... | ... | @@ -136,7 +111,6 @@ RexxRoutineEntry rx3270_functions[] = |
136 | 111 | REXX_TYPED_ROUTINE(rx3270WaitForStringAt, rx3270WaitForStringAt), |
137 | 112 | REXX_TYPED_ROUTINE(rx3270GetStringAt, rx3270GetStringAt), |
138 | 113 | REXX_TYPED_ROUTINE(rx3270IsTerminalReady, rx3270IsTerminalReady), |
139 | - REXX_TYPED_ROUTINE(rx3270ReadScreen, rx3270ReadScreen), | |
140 | 114 | REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt), |
141 | 115 | REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt), |
142 | 116 | |
... | ... | @@ -168,4 +142,35 @@ LIB3270_EXPORT RexxPackageEntry * RexxEntry RexxGetPackage(void) |
168 | 142 | END_EXTERN_C() |
169 | 143 | |
170 | 144 | |
145 | +rx3270 * rx3270::get_default(void) | |
146 | +{ | |
147 | + return hSession; | |
148 | +} | |
149 | + | |
150 | +rx3270::rx3270() | |
151 | +{ | |
152 | +#ifdef HAVE_ICONV | |
153 | + this->conv2Local = iconv_open(REXX_DEFAULT_CHARSET, "ISO-8859-1"); | |
154 | + this->conv2Host = iconv_open("ISO-8859-1",REXX_DEFAULT_CHARSET); | |
155 | +#endif | |
156 | + | |
157 | + if(!hSession) | |
158 | + hSession = this; | |
159 | +} | |
160 | + | |
161 | +rx3270::~rx3270() | |
162 | +{ | |
163 | +#ifdef HAVE_ICONV | |
164 | + | |
165 | + if(conv2Local != (iconv_t) (-1)) | |
166 | + iconv_close(conv2Local); | |
167 | + | |
168 | + if(conv2Host != (iconv_t) (-1)) | |
169 | + iconv_close(conv2Host); | |
170 | +#endif | |
171 | + | |
172 | + | |
173 | + if(hSession == this) | |
174 | + hSession = NULL; | |
175 | +} | |
171 | 176 | ... | ... |
src/plugins/rx3270/text.cc
... | ... | @@ -32,27 +32,12 @@ |
32 | 32 | |
33 | 33 | #include <string.h> |
34 | 34 | |
35 | - | |
36 | -/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
37 | - | |
38 | -#ifdef HAVE_ICONV | |
39 | - iconv_t outputConv = (iconv_t) (-1); | |
40 | - iconv_t inputConv = (iconv_t) (-1); | |
41 | -#endif | |
42 | - | |
43 | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
44 | 36 | |
45 | -char * get_contents(H3270 *hSession, int start, int sz) | |
37 | +char * rx3270::get_3270_string(const char *str) | |
46 | 38 | { |
47 | - unsigned char str[sz+1]; | |
48 | - unsigned short attr[sz+1]; | |
49 | - | |
50 | - if(!lib3270_get_contents(hSession,start,start+sz,str,attr)) | |
51 | - return NULL; | |
52 | - | |
53 | 39 | #ifdef HAVE_ICONV |
54 | - // Convert received string to rexx encoding | |
55 | - if(outputConv != (iconv_t)(-1)) | |
40 | + if(conv2Host != (iconv_t)(-1)) | |
56 | 41 | { |
57 | 42 | size_t in = strlen((char *) str); |
58 | 43 | size_t out = (in << 1); |
... | ... | @@ -62,9 +47,9 @@ char * get_contents(H3270 *hSession, int start, int sz) |
62 | 47 | |
63 | 48 | memset(ptr=buffer,0,out); |
64 | 49 | |
65 | - iconv(outputConv,NULL,NULL,NULL,NULL); // Reset state | |
50 | + iconv(conv2Host,NULL,NULL,NULL,NULL); // Reset state | |
66 | 51 | |
67 | - if(iconv(outputConv,(char **) &str,&in,&ptr,&out) == ((size_t) -1)) | |
52 | + if(iconv(conv2Host,(char **) &str,&in,&ptr,&out) == ((size_t) -1)) | |
68 | 53 | ret = strdup((char *) str); |
69 | 54 | else |
70 | 55 | ret = strdup(buffer); |
... | ... | @@ -73,30 +58,28 @@ char * get_contents(H3270 *hSession, int start, int sz) |
73 | 58 | |
74 | 59 | return ret; |
75 | 60 | } |
76 | - | |
77 | 61 | #endif // HAVE_ICONV |
78 | 62 | |
79 | - return strdup((char *) str); | |
63 | + return strdup(str); | |
80 | 64 | } |
81 | 65 | |
82 | -char * set_contents(H3270 *hSession, const char *str) | |
66 | +char * rx3270::get_local_string(const char *str) | |
83 | 67 | { |
84 | 68 | #ifdef HAVE_ICONV |
85 | - // Convert received string to 3270 encoding | |
86 | - if(inputConv != (iconv_t)(-1)) | |
69 | + if(conv2Local != (iconv_t)(-1)) | |
87 | 70 | { |
88 | - size_t in = strlen(str); | |
89 | - size_t out = (in << 1); | |
90 | - char * ptr; | |
91 | - char * buffer = (char *) malloc(out); | |
92 | - char * ret; | |
71 | + size_t in = strlen((char *) str); | |
72 | + size_t out = (in << 1); | |
73 | + char *ptr; | |
74 | + char *buffer = (char *) malloc(out); | |
75 | + char *ret; | |
93 | 76 | |
94 | 77 | memset(ptr=buffer,0,out); |
95 | 78 | |
96 | - iconv(inputConv,NULL,NULL,NULL,NULL); // Reset state | |
79 | + iconv(conv2Local,NULL,NULL,NULL,NULL); // Reset state | |
97 | 80 | |
98 | - if(iconv(inputConv,(char **) &str,&in,&ptr,&out) == ((size_t) -1)) | |
99 | - ret = strdup(str); | |
81 | + if(iconv(conv2Local,(char **) &str,&in,&ptr,&out) == ((size_t) -1)) | |
82 | + ret = strdup((char *) str); | |
100 | 83 | else |
101 | 84 | ret = strdup(buffer); |
102 | 85 | |
... | ... | @@ -106,8 +89,7 @@ char * set_contents(H3270 *hSession, const char *str) |
106 | 89 | } |
107 | 90 | #endif // HAVE_ICONV |
108 | 91 | |
109 | - return strdup((char *) str); | |
110 | - | |
92 | + return strdup(str); | |
111 | 93 | } |
112 | 94 | |
113 | 95 | ... | ... |
src/plugins/rx3270/typed_routines.cc
... | ... | @@ -31,14 +31,13 @@ |
31 | 31 | #include <string.h> |
32 | 32 | |
33 | 33 | #include "rx3270.h" |
34 | - #include <lib3270/actions.h> | |
35 | 34 | |
36 | 35 | |
37 | 36 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
38 | 37 | |
39 | 38 | RexxRoutine0(CSTRING, rx3270version) |
40 | 39 | { |
41 | - return lib3270_get_version(); | |
40 | + return rx3270::get_default()->get_version(); | |
42 | 41 | } |
43 | 42 | |
44 | 43 | RexxRoutine0(CSTRING, rx3270QueryCState) |
... | ... | @@ -64,9 +63,7 @@ RexxRoutine0(CSTRING, rx3270QueryCState) |
64 | 63 | }; |
65 | 64 | |
66 | 65 | size_t f; |
67 | - LIB3270_CSTATE state; | |
68 | - | |
69 | - state = lib3270_get_connection_state(RX3270SESSION); | |
66 | + LIB3270_CSTATE state = rx3270::get_default()->get_cstate(); | |
70 | 67 | |
71 | 68 | for(f=0;f < (sizeof(xlat_state)/sizeof(struct _xlat_state)); f++) |
72 | 69 | { |
... | ... | @@ -79,112 +76,84 @@ RexxRoutine0(CSTRING, rx3270QueryCState) |
79 | 76 | |
80 | 77 | RexxRoutine0(int, rx3270Disconnect) |
81 | 78 | { |
82 | - lib3270_disconnect(RX3270SESSION); | |
83 | - return 0; | |
79 | + return rx3270::get_default()->disconnect(); | |
84 | 80 | } |
85 | 81 | |
86 | 82 | RexxRoutine2(int, rx3270Connect, CSTRING, hostname, int, wait) |
87 | 83 | { |
88 | - return lib3270_connect(RX3270SESSION, hostname, wait); | |
84 | + return rx3270::get_default()->connect(hostname,wait); | |
89 | 85 | } |
90 | 86 | |
91 | 87 | RexxRoutine0(int, rx3270isConnected) |
92 | 88 | { |
93 | - return lib3270_is_connected(RX3270SESSION) ? 1 : 0; | |
89 | + return rx3270::get_default()->is_connected(); | |
94 | 90 | } |
95 | 91 | |
96 | 92 | RexxRoutine0(int, rx3270WaitForEvents) |
97 | 93 | { |
98 | - H3270 * hSession = RX3270SESSION; | |
99 | - | |
100 | - if(!lib3270_is_connected(hSession)) | |
101 | - return ENOTCONN; | |
102 | - | |
103 | - lib3270_main_iterate(hSession,1); | |
104 | - | |
105 | - return 0; | |
94 | + return rx3270::get_default()->iterate(); | |
106 | 95 | } |
107 | 96 | |
108 | 97 | RexxRoutine1(int, rx3270Sleep, int, seconds) |
109 | 98 | { |
110 | - return lib3270_wait(RX3270SESSION,seconds); | |
99 | + return rx3270::get_default()->wait(seconds); | |
111 | 100 | } |
112 | 101 | |
113 | 102 | RexxRoutine0(int, rx3270SendENTERKey) |
114 | 103 | { |
115 | - return lib3270_enter(RX3270SESSION); | |
104 | + return rx3270::get_default()->enter(); | |
116 | 105 | } |
117 | 106 | |
118 | 107 | RexxRoutine1(int, rx3270SendPFKey, int, key) |
119 | 108 | { |
120 | - return lib3270_pfkey(RX3270SESSION,key); | |
109 | + return rx3270::get_default()->pfkey(key); | |
121 | 110 | } |
122 | 111 | |
123 | 112 | RexxRoutine1(int, rx3270SendPAKey, int, key) |
124 | 113 | { |
125 | - return lib3270_pakey(RX3270SESSION,key); | |
114 | + return rx3270::get_default()->pakey(key); | |
126 | 115 | } |
127 | 116 | |
128 | 117 | RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds) |
129 | 118 | { |
130 | - return lib3270_wait_for_ready(RX3270SESSION,seconds); | |
119 | + return rx3270::get_default()->wait_for_ready(seconds); | |
131 | 120 | } |
132 | 121 | |
133 | 122 | RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout) |
134 | 123 | { |
135 | - H3270 * hSession = RX3270SESSION; | |
124 | + rx3270 * session = rx3270::get_default(); | |
136 | 125 | time_t end = time(0) + timeout; |
137 | - int sz = strlen(key); | |
138 | - int rows; | |
139 | - int cols; | |
140 | - int start; | |
141 | - | |
142 | - lib3270_get_screen_size(hSession,&rows,&cols); | |
143 | - | |
144 | - if(row < 0 || row > rows || col < 0 || col > cols) | |
145 | - return EINVAL; | |
146 | - | |
147 | - start = ((row) * cols) + col; | |
126 | + char * text = session->get_3270_string(key); | |
148 | 127 | |
149 | 128 | while(time(0) < end) |
150 | 129 | { |
151 | - if(!lib3270_is_connected(hSession)) | |
130 | + if(!session->is_connected()) | |
152 | 131 | { |
153 | 132 | return ENOTCONN; |
154 | 133 | } |
155 | - else if(lib3270_is_ready(hSession)) | |
134 | + else if( !(session->wait_for_ready(1) || session->cmp_text_at(row,col,text)) ) | |
156 | 135 | { |
157 | - char *buffer = get_contents(hSession, start, start+sz); | |
158 | - if(buffer) | |
159 | - { | |
160 | - int rc = strncasecmp((const char *) buffer,key,sz); | |
161 | - free(buffer); | |
162 | - if(rc == 0) | |
163 | - return 0; | |
164 | - } | |
136 | + free(text); | |
137 | + return 0; | |
165 | 138 | } |
166 | - | |
167 | - lib3270_main_iterate(hSession,1); | |
168 | - | |
169 | 139 | } |
170 | 140 | |
141 | + free(text); | |
142 | + | |
171 | 143 | return ETIMEDOUT; |
172 | 144 | |
173 | 145 | } |
174 | 146 | |
175 | 147 | RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz) |
176 | 148 | { |
177 | - H3270 * hSession = RX3270SESSION; | |
178 | - int rows; | |
179 | - int cols; | |
180 | - char * text; | |
181 | - | |
182 | - lib3270_get_screen_size(hSession,&rows,&cols); | |
149 | + rx3270 * session = rx3270::get_default(); | |
150 | + char * str = session->get_text_at(row,col,sz); | |
183 | 151 | |
184 | - text = get_contents(hSession, ((row) * cols) + col, sz); | |
185 | - if(text) | |
152 | + if(str) | |
186 | 153 | { |
187 | - RexxStringObject ret = context->String((CSTRING) text); | |
154 | + char * text = session->get_local_string(str); | |
155 | + RexxStringObject ret = context->String((CSTRING) text); | |
156 | + free(str); | |
188 | 157 | free(text); |
189 | 158 | return ret; |
190 | 159 | } |
... | ... | @@ -194,102 +163,42 @@ RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz) |
194 | 163 | |
195 | 164 | RexxRoutine0(int, rx3270IsTerminalReady) |
196 | 165 | { |
197 | - return lib3270_is_ready(RX3270SESSION); | |
198 | -} | |
199 | - | |
200 | -RexxRoutine3(RexxStringObject, rx3270ReadScreen, OPTIONAL_int, row, OPTIONAL_int, col, OPTIONAL_int, sz) | |
201 | -{ | |
202 | - H3270 * hSession = RX3270SESSION; | |
203 | - int rows; | |
204 | - int cols; | |
205 | - char * text; | |
206 | - int start; | |
207 | - | |
208 | - lib3270_get_screen_size(hSession,&rows,&cols); | |
209 | - | |
210 | - start = (row * cols) + col; | |
211 | - | |
212 | - if(sz == 0) | |
213 | - sz = (rows*cols) - start; | |
214 | - | |
215 | - text = get_contents(hSession, start, sz); | |
216 | - if(text) | |
217 | - { | |
218 | - RexxStringObject ret = context->String((CSTRING) text); | |
219 | - free(text); | |
220 | - return ret; | |
221 | - } | |
222 | - | |
223 | - return context->String(""); | |
166 | + return rx3270::get_default()->is_ready(); | |
224 | 167 | } |
225 | 168 | |
226 | 169 | RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key) |
227 | 170 | { |
228 | - H3270 * hSession = RX3270SESSION; | |
229 | - int rows; | |
230 | - int cols; | |
231 | - char * text; | |
232 | - size_t sz = strlen(key); | |
233 | - | |
234 | - lib3270_get_screen_size(hSession,&rows,&cols); | |
171 | + int rc = 0; | |
172 | + rx3270 * session = rx3270::get_default(); | |
173 | + char * str = session->get_text_at(row,col,strlen(key)); | |
235 | 174 | |
236 | - text = get_contents(hSession, (row * cols) + col, sz); | |
237 | - if(text) | |
175 | + if(str) | |
238 | 176 | { |
239 | - int rc = strncasecmp(text,key,sz); | |
177 | + char * text = session->get_3270_string(key); | |
178 | + rc = strcasecmp(str,text); | |
240 | 179 | free(text); |
241 | - return rc; | |
242 | 180 | } |
243 | 181 | |
244 | - return 0; | |
182 | + free(str); | |
183 | + | |
184 | + return rc; | |
245 | 185 | } |
246 | 186 | |
247 | 187 | RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col) |
248 | 188 | { |
249 | - return lib3270_set_cursor_position(RX3270SESSION,row,col); | |
189 | + return rx3270::get_default()->set_cursor_position(row,col); | |
250 | 190 | } |
251 | 191 | |
252 | 192 | RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text) |
253 | 193 | { |
194 | + rx3270 * session = rx3270::get_default(); | |
195 | + char * str = session->get_3270_string(text); | |
254 | 196 | int rc; |
255 | - H3270 * hSession = RX3270SESSION; | |
256 | - char * str = set_contents(hSession,text); | |
257 | 197 | |
258 | - if(str) | |
259 | - rc = lib3270_set_string_at(hSession,row,col,(const unsigned char *) str); | |
260 | - else | |
261 | - rc = -1; | |
198 | + rc = session->set_text_at(row,col,str); | |
262 | 199 | |
263 | 200 | free(str); |
264 | 201 | |
265 | 202 | return rc; |
266 | 203 | } |
267 | 204 | |
268 | -/* | |
269 | -::method RunMode | |
270 | -return rx3270QueryRunMode() | |
271 | - | |
272 | -::method 'encoding=' | |
273 | - use arg ptr | |
274 | -return rx3270SetCharset(ptr) | |
275 | - | |
276 | -::method sendfile | |
277 | - use arg from, tostrncasecmp | |
278 | - | |
279 | - status = rx3270BeginFileSend(from,to) | |
280 | - if status <> 0 | |
281 | - then return status | |
282 | - | |
283 | -return rx3270WaitForFTComplete() | |
284 | - | |
285 | -::method recvfile | |
286 | - use arg from, to | |
287 | - | |
288 | - status = rx3270BeginFileRecv(from,to) | |
289 | - if status <> 0 | |
290 | - then return status | |
291 | - | |
292 | -return rx3270WaitForFTComplete() | |
293 | -*/ | |
294 | - | |
295 | - | ... | ... |