Commit a7148ff49c7df704b89a394332f5035d61260798

Authored by perry.werneck@gmail.com
1 parent 0fe8634c

Migrando plugin rexx para a classe de apoio

Showing 2 changed files with 34 additions and 60 deletions   Show diff stats
@@ -291,10 +291,7 @@ @@ -291,10 +291,7 @@
291 <Option compilerVar="CC" /> 291 <Option compilerVar="CC" />
292 </Unit> 292 </Unit>
293 <Unit filename="src/plugins/rx3270/Makefile.in" /> 293 <Unit filename="src/plugins/rx3270/Makefile.in" />
294 - <Unit filename="src/plugins/rx3270/exception.cc" />  
295 - <Unit filename="src/plugins/rx3270/local.cc" />  
296 <Unit filename="src/plugins/rx3270/pluginmain.cc" /> 294 <Unit filename="src/plugins/rx3270/pluginmain.cc" />
297 - <Unit filename="src/plugins/rx3270/remote.cc" />  
298 <Unit filename="src/plugins/rx3270/rexx_methods.cc" /> 295 <Unit filename="src/plugins/rx3270/rexx_methods.cc" />
299 <Unit filename="src/plugins/rx3270/rx3270.cc" /> 296 <Unit filename="src/plugins/rx3270/rx3270.cc" />
300 <Unit filename="src/plugins/rx3270/rx3270.cls" /> 297 <Unit filename="src/plugins/rx3270/rx3270.cls" />
src/plugins/rx3270/typed_routines.cc
@@ -133,47 +133,37 @@ RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds) @@ -133,47 +133,37 @@ RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds)
133 133
134 RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout) 134 RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout)
135 { 135 {
136 - #warning REIMPLEMENTAR  
137 -/*  
138 - session * session = session::get_default();  
139 - time_t end = time(0) + timeout;  
140 - char * text = session->get_3270_string(key);  
141 -  
142 - while(time(0) < end) 136 + try
143 { 137 {
144 - if(!session->is_connected())  
145 - {  
146 - return ENOTCONN;  
147 - }  
148 - else if( !(session->wait_for_ready(1) || session->cmp_text_at(row,col,text)) )  
149 - {  
150 - free(text);  
151 - return 0;  
152 - } 138 + return session::get_default()->wait_for_string_at(row,col,key,timeout);
  139 + }
  140 + catch(std::exception &e)
  141 + {
  142 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
153 } 143 }
154 144
155 - free(text);  
156 -*/  
157 return ETIMEDOUT; 145 return ETIMEDOUT;
158 146
159 } 147 }
160 148
161 RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz) 149 RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
162 { 150 {
163 - #warning REIMPLEMENTAR  
164 -/*  
165 - rx3270 * session = rx3270::get_default();  
166 - char * str = session->get_text_at(row,col,sz); 151 + try
  152 + {
  153 + string *str = session::get_default()->get_string_at(row,col,(int) sz);
167 154
168 - if(str) 155 + if(str)
  156 + {
  157 + RexxStringObject ret = context->String((CSTRING) str->c_str());
  158 + delete str;
  159 + return ret;
  160 + }
  161 + }
  162 + catch(std::exception &e)
169 { 163 {
170 - char * text = session->get_local_string(str);  
171 - RexxStringObject ret = context->String((CSTRING) text);  
172 - free(str);  
173 - free(text);  
174 - return ret; 164 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
175 } 165 }
176 -*/ 166 +
177 return context->String(""); 167 return context->String("");
178 } 168 }
179 169
@@ -184,23 +174,15 @@ RexxRoutine0(int, rx3270IsTerminalReady) @@ -184,23 +174,15 @@ RexxRoutine0(int, rx3270IsTerminalReady)
184 174
185 RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key) 175 RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
186 { 176 {
187 - #warning Reimplementar  
188 -/*  
189 - int rc = 0;  
190 - rx3270 * session = rx3270::get_default();  
191 - char * str = session->get_text_at(row,col,strlen(key));  
192 -  
193 - if(str) 177 + try
194 { 178 {
195 - char * text = session->get_3270_string(key);  
196 - rc = strcasecmp(str,text);  
197 - free(text); 179 + return session::get_default()->cmp_string_at(row,col,key);
  180 + }
  181 + catch(std::exception &e)
  182 + {
  183 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
198 } 184 }
199 185
200 - free(str);  
201 -  
202 - return rc;  
203 -*/  
204 return -1; 186 return -1;
205 } 187 }
206 188
@@ -220,23 +202,18 @@ RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col) @@ -220,23 +202,18 @@ RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
220 202
221 RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text) 203 RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
222 { 204 {
223 - #warning Reimplementar  
224 -/*  
225 - rx3270 * session = rx3270::get_default();  
226 - char * str = session->get_3270_string(text);  
227 - int rc;  
228 -  
229 - rc = session->set_text_at(row,col,str);  
230 -  
231 - free(str);  
232 -  
233 - return rc;  
234 -*/ 205 + try
  206 + {
  207 + return session::get_default()->set_string_at(row,col,text);
  208 + }
  209 + catch(std::exception &e)
  210 + {
  211 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
  212 + }
235 return -1; 213 return -1;
236 } 214 }
237 215
238 RexxRoutine0(int, rx3270CloseApplication) 216 RexxRoutine0(int, rx3270CloseApplication)
239 { 217 {
240 - session * session = session::get_default();  
241 - return session->quit(); 218 + return session::get_default()->quit();
242 } 219 }