Commit 3ad93b329442f36f71ebdd74c69a57a8c6eb1c3b

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

Changing 'hllapi_get_last_error' signature to be more compatible with

excel macros.
src/core/controller.cc
... ... @@ -115,7 +115,17 @@
115 115  
116 116 }
117 117  
118   - HLLAPI_API_CSTR hllapi_get_last_error() {
  118 +HLLAPI_API_CALL hllapi_get_last_error(LPSTR lpBuffer, WORD len) {
  119 +
  120 + strncpy(lpBuffer,hllapi_get_last_error_as_cstring(),len-1);
  121 + lpBuffer[len-1] = 0; // Just in case
  122 +
  123 + return strlen(lpBuffer);
  124 +}
  125 +
  126 + HLLAPI_API_CSTR hllapi_get_last_error_as_cstring() {
  127 +
119 128 return hllapi_lasterror.c_str();
  129 +
120 130 }
121 131  
... ...
src/include/lib3270/hllapi.h
... ... @@ -351,7 +351,8 @@
351 351 */
352 352 HLLAPI_API_CALL hllapi_set_charset(LPSTR charset);
353 353  
354   - HLLAPI_API_CSTR hllapi_get_last_error();
  354 + HLLAPI_API_CALL hllapi_get_last_error(LPSTR lpBuffer, WORD len);
  355 + HLLAPI_API_CSTR hllapi_get_last_error_as_cstring();
355 356  
356 357 HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms);
357 358 HLLAPI_API_CALL hllapi_set_timeout(WORD seconds);
... ... @@ -361,7 +362,7 @@
361 362  
362 363 /**
363 364 * @brief Report event to system log
364   - *
  365 + *
365 366 */
366 367 HLLAPI_API_CALL hllapi_report_event(LPSTR message);
367 368  
... ...
src/testprogram/testprogram.cc
... ... @@ -38,9 +38,9 @@
38 38 #pragma comment(lib,"hllapi.lib")
39 39 #define strncasecmp _strnicmp
40 40 #define strcasecmp _stricmp
41   - #else
  41 + #else
42 42 #include <getopt.h>
43   - #endif
  43 + #endif
44 44  
45 45 #define SCREEN_LENGTH 2000
46 46  
... ... @@ -91,7 +91,7 @@
91 91  
92 92 int rc = hllapi_init((char *) session);
93 93 if(rc) {
94   - cout << "hllapi_init returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  94 + cout << "hllapi_init returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
95 95 return rc;
96 96 }
97 97  
... ... @@ -120,7 +120,7 @@
120 120 } else if(strcasecmp(cmdline.c_str(),"wait") == 0) {
121 121  
122 122 rc = hllapi_wait_for_ready(10);
123   - cout << "hllapi_wait_for_ready returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  123 + cout << "hllapi_wait_for_ready returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
124 124  
125 125 } else if(strcasecmp(cmdline.c_str(),"disconnect") == 0) {
126 126  
... ... @@ -137,7 +137,7 @@
137 137 } else if(strcasecmp(cmdline.c_str(),"contents") == 0) {
138 138  
139 139 rc = hllapi_get_screen(0,buffer,SCREEN_LENGTH);
140   - cout << "hllapi_get_screen returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl
  140 + cout << "hllapi_get_screen returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl
141 141 << buffer << endl << endl;
142 142  
143 143 } else if(strncasecmp(cmdline.c_str(),"cursor",6) == 0) {
... ... @@ -263,7 +263,7 @@
263 263 }
264 264  
265 265 if(rc != HLLAPI_STATUS_SUCCESS) {
266   - cout << "rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  266 + cout << "rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
267 267 rc = HLLAPI_STATUS_SUCCESS;
268 268 }
269 269  
... ... @@ -282,7 +282,7 @@
282 282  
283 283 rc = hllapi_wait_for_ready(10);
284 284 if(rc) {
285   - cout << "hllapi_wait_for_ready returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  285 + cout << "hllapi_wait_for_ready returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
286 286 return rc;
287 287 }
288 288  
... ... @@ -294,7 +294,7 @@
294 294 buffer[SCREEN_LENGTH] = 0;
295 295  
296 296 rc = hllapi_get_screen(0,buffer,SCREEN_LENGTH);
297   - cout << "hllapi_get_screen returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  297 + cout << "hllapi_get_screen returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
298 298  
299 299 if(rc == HLLAPI_STATUS_SUCCESS) {
300 300 cout << endl << buffer << endl;
... ... @@ -314,11 +314,11 @@
314 314  
315 315 rc = hllapi_disconnect();
316 316 if(rc) {
317   - cout << "hllapi_disconnect returns with rc=" << rc << " (" << hllapi_get_last_error() << ")" << endl;
  317 + cout << "hllapi_disconnect returns with rc=" << rc << " (" << hllapi_get_last_error_as_cstring() << ")" << endl;
318 318 return rc;
319 319 }
320 320  
321   - cout << "HLLAPI Last error was \"" << hllapi_get_last_error() << "\"" << endl;
  321 + cout << "HLLAPI Last error was \"" << hllapi_get_last_error_as_cstring() << "\"" << endl;
322 322  
323 323 */
324 324  
... ...