Commit 3ca357c4d222eb620a361bcc65babef138714480

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

Trabalhando no HLLAPI

src/plugins/hllapi/calls.c
... ... @@ -436,9 +436,11 @@
436 436 {
437 437  
438 438 if(!(emulate_input && hSession))
439   - return EINVAL;
  439 + return HLLAPI_STATUS_DISCONNECTED;
440 440 trace("%s",__FUNCTION__);
441   - return emulate_input(hSession, buffer, len, pasting);
  441 + emulate_input(hSession, buffer, len, pasting);
  442 +
  443 + return HLLAPI_STATUS_SUCCESS;
442 444 }
443 445  
444 446 __declspec (dllexport) DWORD __stdcall hllapi_erase_eof(void)
... ...
src/plugins/hllapi/hllapi.c
... ... @@ -46,6 +46,7 @@
46 46 static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc);
47 47 static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc);
48 48 static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc);
  49 + static int copy_str_to_ps(char *buffer, unsigned short *length, unsigned short *rc);
49 50 static int search_ps(char *buffer, unsigned short *length, unsigned short *rc);
50 51 static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc);
51 52 static int wait_system(char *buffer, unsigned short *length, unsigned short *rc);
... ... @@ -74,7 +75,7 @@
74 75 { HLLAPI_CMD_WAIT, wait_system },
75 76 { HLLAPI_CMD_COPYPS, copy_ps },
76 77 { HLLAPI_CMD_SEARCHPS, search_ps },
77   - { HLLAPI_CMD_COPYSTRTOPS, invalid_request },
  78 + { HLLAPI_CMD_COPYSTRTOPS, copy_str_to_ps },
78 79 { HLLAPI_CMD_SENDFILE, invalid_request },
79 80 { HLLAPI_CMD_RECEIVEFILE, invalid_request },
80 81  
... ... @@ -355,7 +356,14 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)
355 356 *
356 357 * Length NA (the length of the host presentation space is implied).
357 358 * PS Position NA.
358   - *
  359 + *
  360 + * Return values:
  361 + *
  362 + * 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.
  363 + * 1 Your program is not connected to a host session.
  364 + * 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.
  365 + * 5 The host presentation space was copied. The keyboard was locked.
  366 + * 9 A system error was encountered.
359 367 *
360 368 */
361 369 size_t szBuffer = strlen(buffer);
... ... @@ -417,3 +425,54 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
417 425  
418 426 return HLLAPI_STATUS_TIMEOUT;
419 427 }
  428 +
  429 +static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)
  430 +{
  431 + /*
  432 + * Call Parameters
  433 + *
  434 + * Data String String of ASCII data to be copied into the host presentation space.
  435 + * Length Length, in number of bytes, of the source data string. Overridden if in EOT mode.
  436 + * PS Position Position in the host presentation space to begin the copy, a value between 1 and the configured size of your host presentation space.
  437 + *
  438 + * Return Parameters
  439 + *
  440 + * 0 The Copy String to Presentation Space function was successful.
  441 + * 1 Your program is not connected to a host session.
  442 + * 2 Parameter error or zero length for copy.
  443 + * 5 The target presentation space is protected or inhibited, or incorrect data was sent to the target presentation space (such as a field attribute byte).
  444 + * 6 The copy was completed, but the data was truncated.
  445 + * 7 The host presentation space position is not valid.
  446 + * 9 A system error was encountered.
  447 + *
  448 + */
  449 + size_t szText = strlen(text);
  450 +
  451 + if(*length < szText)
  452 + szText = *length;
  453 +
  454 + if(!szText)
  455 + return 2;
  456 +
  457 + switch(hllapi_get_message_id())
  458 + {
  459 + case LIB3270_MESSAGE_NONE:
  460 + break;
  461 +
  462 + case LIB3270_MESSAGE_DISCONNECTED:
  463 + return HLLAPI_STATUS_DISCONNECTED;
  464 +
  465 + case LIB3270_MESSAGE_MINUS:
  466 + case LIB3270_MESSAGE_PROTECTED:
  467 + case LIB3270_MESSAGE_NUMERIC:
  468 + case LIB3270_MESSAGE_OVERFLOW:
  469 + case LIB3270_MESSAGE_INHIBIT:
  470 + case LIB3270_MESSAGE_KYBDLOCK:
  471 + return HLLAPI_STATUS_KEYBOARD_LOCKED;
  472 +
  473 + default:
  474 + return HLLAPI_STATUS_SYSTEM_ERROR;
  475 + }
  476 +
  477 + return hllapi_emulate_input(text,szText,0);
  478 +}
... ...