diff --git a/po/pt_BR.po b/po/pt_BR.po index d073096..762872b 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-09-17 09:45-0300\n" +"POT-Creation-Date: 2012-09-17 14:31-0300\n" "PO-Revision-Date: 2012-09-14 14:32-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português \n" diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index e1e4abc..9ccbbd6 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -41,11 +41,14 @@ extern "C" { #define HLLAPI_REQUEST_ID 0x01 #define HLLAPI_MAXLENGTH 32768 - #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ - #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ - #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ - #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ - #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ + #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ + #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ + #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ + #define HLLAPI_CMD_WAIT 4 /**< Wait if the session is waiting for a host response */ + + #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ + #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ + #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ #pragma pack(1) typedef struct _hllapi_data diff --git a/src/plugins/remotectl/hllapi.c b/src/plugins/remotectl/hllapi.c index b9d61d5..aaf74c6 100644 --- a/src/plugins/remotectl/hllapi.c +++ b/src/plugins/remotectl/hllapi.c @@ -51,6 +51,9 @@ if(length < 0 && string) length = strlen(string); + if(!session_name) + session_name = strdup("pw3270A"); + snprintf(PipeName,4095,"\\\\.\\pipe\\%s",session_name); if(!WaitNamedPipe(PipeName,NMPWAIT_USE_DEFAULT_WAIT)) @@ -114,7 +117,6 @@ if(!session_name) free(session_name); session_name = strdup(name); - return 0; } @@ -152,15 +154,22 @@ result = run_query(*func, arg, str, *length, rc); break; - default: - if(!session_name) + case HLLAPI_CMD_DISCONNECTPS: + if(session_name) { - if(set_session_name("pw3270A")) - return ENOENT; + result = run_query(*func, arg, str, *length, rc); + free(session_name); + session_name = NULL; } + break; + + default: result = run_query(*func, arg, str, *length, rc); } + if(result && length && *length && str) + strncpy(str,strerror(result),*length); + free(arg); return result; } diff --git a/src/plugins/remotectl/remotectl.c b/src/plugins/remotectl/remotectl.c index 32b6d04..517fe8b 100644 --- a/src/plugins/remotectl/remotectl.c +++ b/src/plugins/remotectl/remotectl.c @@ -133,22 +133,26 @@ return 0; } - static int cmd_connectps(unsigned short rc, char *string, unsigned short length) + static int cmd_connectps(H3270 *hSession, unsigned short rc, char *string, unsigned short length) { g_message("%s","HLLAPI ConnectPS request received"); return 0; } - static int cmd_getrevision(unsigned short rc, char *string, unsigned short length) + static int cmd_disconnectps(H3270 *hSession, unsigned short rc, char *string, unsigned short length) { - strncpy(string,lib3270_get_revision(),length); + g_message("%s","HLLAPI DisconnectPS request received"); return 0; } - static int cmd_setcursor(unsigned short rc, char *string, unsigned short length) + static int cmd_getrevision(H3270 *hSession, unsigned short rc, char *string, unsigned short length) { - H3270 *hSession = lib3270_get_default_session_handle(); + strncpy(string,lib3270_get_revision(),length); + return 0; + } + static int cmd_setcursor(H3270 *hSession, unsigned short rc, char *string, unsigned short length) + { if(!lib3270_connected(hSession)) return ENOTCONN; @@ -156,10 +160,8 @@ return 0; } - static int cmd_sendstring(unsigned short rc, char *text, unsigned short length) + static int cmd_sendstring(H3270 *hSession, unsigned short rc, char *text, unsigned short length) { - H3270 *hSession = lib3270_get_default_session_handle(); - if(!lib3270_connected(hSession)) return ENOTCONN; @@ -169,18 +171,25 @@ return 0; } + static int cmd_wait(H3270 *hSession, unsigned short rc, char *text, unsigned short length) + { + return lib3270_wait_for_ready(hSession,60); + } + int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc) { static const struct _cmd { unsigned long function; - int (*exec)(unsigned short rc, char *string, unsigned short length); + int (*exec)(H3270 *hSession, unsigned short rc, char *string, unsigned short length); } cmd[] = { - { HLLAPI_CMD_CONNECTPS, cmd_connectps }, - { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, - { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, - { HLLAPI_CMD_GETREVISION, cmd_getrevision } + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, + { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, + { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, + { HLLAPI_CMD_WAIT, cmd_wait }, + { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, + { HLLAPI_CMD_GETREVISION, cmd_getrevision } }; int f; @@ -189,7 +198,7 @@ for(f=0;f