Commit 356c57ec17bf340db7a905f563b6460357b82961
1 parent
0459733b
Exists in
master
and in
5 other branches
Implementando IPC na extensao rexx para windows
Showing
7 changed files
with
718 additions
and
464 deletions
Show diff stats
pw3270.cbp
| @@ -73,6 +73,7 @@ | @@ -73,6 +73,7 @@ | ||
| 73 | <Unit filename="src/include/plugin.mak.in" /> | 73 | <Unit filename="src/include/plugin.mak.in" /> |
| 74 | <Unit filename="src/include/pw3270.h" /> | 74 | <Unit filename="src/include/pw3270.h" /> |
| 75 | <Unit filename="src/include/pw3270/hllapi.h" /> | 75 | <Unit filename="src/include/pw3270/hllapi.h" /> |
| 76 | + <Unit filename="src/include/pw3270/ipcpackets.h" /> | ||
| 76 | <Unit filename="src/include/pw3270/plugin.h" /> | 77 | <Unit filename="src/include/pw3270/plugin.h" /> |
| 77 | <Unit filename="src/include/pw3270/v3270.h" /> | 78 | <Unit filename="src/include/pw3270/v3270.h" /> |
| 78 | <Unit filename="src/include/rules.mak.in" /> | 79 | <Unit filename="src/include/rules.mak.in" /> |
| @@ -264,7 +265,6 @@ | @@ -264,7 +265,6 @@ | ||
| 264 | <Unit filename="src/plugins/hllapi/hllapi.c"> | 265 | <Unit filename="src/plugins/hllapi/hllapi.c"> |
| 265 | <Option compilerVar="CC" /> | 266 | <Option compilerVar="CC" /> |
| 266 | </Unit> | 267 | </Unit> |
| 267 | - <Unit filename="src/plugins/hllapi/packets.h" /> | ||
| 268 | <Unit filename="src/plugins/hllapi/pipesource.c"> | 268 | <Unit filename="src/plugins/hllapi/pipesource.c"> |
| 269 | <Option compilerVar="CC" /> | 269 | <Option compilerVar="CC" /> |
| 270 | </Unit> | 270 | </Unit> |
src/include/lib3270/log.h
| @@ -49,6 +49,10 @@ | @@ -49,6 +49,10 @@ | ||
| 49 | #define trace(x, ...) // __VA_ARGS__ | 49 | #define trace(x, ...) // __VA_ARGS__ |
| 50 | 50 | ||
| 51 | #else | 51 | #else |
| 52 | + | ||
| 53 | + #ifdef __cplusplus | ||
| 54 | + extern "C" { | ||
| 55 | + #endif | ||
| 52 | 56 | ||
| 53 | LIB3270_EXPORT void lib3270_set_log_handler(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); | 57 | LIB3270_EXPORT void lib3270_set_log_handler(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); |
| 54 | LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const char *fmt, ...) LIB3270_GNUC_FORMAT(3,4); | 58 | LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const char *fmt, ...) LIB3270_GNUC_FORMAT(3,4); |
| @@ -61,6 +65,10 @@ | @@ -61,6 +65,10 @@ | ||
| 61 | #else | 65 | #else |
| 62 | #define trace(x, ...) // __VA_ARGS__ | 66 | #define trace(x, ...) // __VA_ARGS__ |
| 63 | #endif | 67 | #endif |
| 68 | + | ||
| 69 | + #ifdef __cplusplus | ||
| 70 | + } | ||
| 71 | + #endif | ||
| 64 | 72 | ||
| 65 | #endif // ANDROID | 73 | #endif // ANDROID |
| 66 | 74 |
| @@ -0,0 +1,153 @@ | @@ -0,0 +1,153 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
| 19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como ipcpackets.h e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | + typedef enum _hllapi_packet | ||
| 31 | + { | ||
| 32 | + HLLAPI_PACKET_CONNECT, | ||
| 33 | + HLLAPI_PACKET_DISCONNECT, | ||
| 34 | + HLLAPI_PACKET_GET_PROGRAM_MESSAGE, | ||
| 35 | + HLLAPI_PACKET_GET_TEXT_AT_OFFSET, | ||
| 36 | + HLLAPI_PACKET_GET_TEXT_AT, | ||
| 37 | + HLLAPI_PACKET_SET_TEXT_AT, | ||
| 38 | + HLLAPI_PACKET_CMP_TEXT_AT, | ||
| 39 | + HLLAPI_PACKET_ENTER, | ||
| 40 | + HLLAPI_PACKET_PFKEY, | ||
| 41 | + HLLAPI_PACKET_PAKEY, | ||
| 42 | + HLLAPI_PACKET_SET_CURSOR_POSITION, | ||
| 43 | + HLLAPI_PACKET_GET_CURSOR_POSITION, | ||
| 44 | + HLLAPI_PACKET_INPUT_STRING, | ||
| 45 | + HLLAPI_PACKET_IS_CONNECTED, | ||
| 46 | + HLLAPI_PACKET_SET_CURSOR, | ||
| 47 | + HLLAPI_PACKET_GET_CURSOR, | ||
| 48 | + HLLAPI_PACKET_EMULATE_INPUT, | ||
| 49 | + HLLAPI_PACKET_ERASE_EOF, | ||
| 50 | + HLLAPI_PACKET_PRINT, | ||
| 51 | + | ||
| 52 | + HLLAPI_PACKET_INVALID | ||
| 53 | + | ||
| 54 | + } HLLAPI_PACKET; | ||
| 55 | + | ||
| 56 | +#pragma pack(1) | ||
| 57 | + | ||
| 58 | +struct hllapi_packet_result | ||
| 59 | +{ | ||
| 60 | + int rc; | ||
| 61 | +}; | ||
| 62 | + | ||
| 63 | +struct hllapi_packet_text_result | ||
| 64 | +{ | ||
| 65 | + int rc; | ||
| 66 | + char text[1]; | ||
| 67 | +}; | ||
| 68 | + | ||
| 69 | +struct hllapi_packet_query | ||
| 70 | +{ | ||
| 71 | + unsigned char packet_id; | ||
| 72 | +}; | ||
| 73 | + | ||
| 74 | +struct hllapi_packet_connect | ||
| 75 | +{ | ||
| 76 | + unsigned char packet_id; | ||
| 77 | + unsigned char wait; | ||
| 78 | + char hostname[1]; | ||
| 79 | +}; | ||
| 80 | + | ||
| 81 | +struct hllapi_packet_keycode | ||
| 82 | +{ | ||
| 83 | + unsigned char packet_id; | ||
| 84 | + unsigned short keycode; | ||
| 85 | +}; | ||
| 86 | + | ||
| 87 | +struct hllapi_packet_cursor | ||
| 88 | +{ | ||
| 89 | + unsigned char packet_id; | ||
| 90 | + unsigned short row; | ||
| 91 | + unsigned short col; | ||
| 92 | +}; | ||
| 93 | + | ||
| 94 | +struct hllapi_packet_text | ||
| 95 | +{ | ||
| 96 | + unsigned char packet_id; | ||
| 97 | + char text[1]; | ||
| 98 | +}; | ||
| 99 | + | ||
| 100 | +struct hllapi_packet_at | ||
| 101 | +{ | ||
| 102 | + unsigned char packet_id; | ||
| 103 | + unsigned short row; | ||
| 104 | + unsigned short col; | ||
| 105 | + unsigned short len; | ||
| 106 | +}; | ||
| 107 | + | ||
| 108 | +struct hllapi_packet_text_at | ||
| 109 | +{ | ||
| 110 | + unsigned char packet_id; | ||
| 111 | + unsigned short row; | ||
| 112 | + unsigned short col; | ||
| 113 | + char text[1]; | ||
| 114 | +}; | ||
| 115 | + | ||
| 116 | +struct hllapi_packet_query_at | ||
| 117 | +{ | ||
| 118 | + unsigned char packet_id; | ||
| 119 | + unsigned short row; | ||
| 120 | + unsigned short col; | ||
| 121 | + unsigned short len; | ||
| 122 | +}; | ||
| 123 | + | ||
| 124 | +struct hllapi_packet_wait | ||
| 125 | +{ | ||
| 126 | + unsigned char packet_id; | ||
| 127 | + int timeout; | ||
| 128 | +}; | ||
| 129 | + | ||
| 130 | +struct hllapi_packet_addr | ||
| 131 | +{ | ||
| 132 | + unsigned char packet_id; | ||
| 133 | + unsigned short addr; | ||
| 134 | +}; | ||
| 135 | + | ||
| 136 | +struct hllapi_packet_query_offset | ||
| 137 | +{ | ||
| 138 | + unsigned char packet_id; | ||
| 139 | + unsigned short addr; | ||
| 140 | + unsigned short len; | ||
| 141 | +}; | ||
| 142 | + | ||
| 143 | +struct hllapi_packet_emulate_input | ||
| 144 | +{ | ||
| 145 | + unsigned char packet_id; | ||
| 146 | + unsigned short len; | ||
| 147 | + unsigned char pasting; | ||
| 148 | + char text[1]; | ||
| 149 | +}; | ||
| 150 | + | ||
| 151 | + | ||
| 152 | +#pragma pack() | ||
| 153 | + |
src/plugins/hllapi/packets.h
| @@ -1,153 +0,0 @@ | @@ -1,153 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
| 19 | - * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como packets.h e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | - * | ||
| 28 | - */ | ||
| 29 | - | ||
| 30 | - typedef enum _hllapi_packet | ||
| 31 | - { | ||
| 32 | - HLLAPI_PACKET_CONNECT, | ||
| 33 | - HLLAPI_PACKET_DISCONNECT, | ||
| 34 | - HLLAPI_PACKET_GET_PROGRAM_MESSAGE, | ||
| 35 | - HLLAPI_PACKET_GET_TEXT_AT_OFFSET, | ||
| 36 | - HLLAPI_PACKET_GET_TEXT_AT, | ||
| 37 | - HLLAPI_PACKET_SET_TEXT_AT, | ||
| 38 | - HLLAPI_PACKET_CMP_TEXT_AT, | ||
| 39 | - HLLAPI_PACKET_ENTER, | ||
| 40 | - HLLAPI_PACKET_PFKEY, | ||
| 41 | - HLLAPI_PACKET_PAKEY, | ||
| 42 | - HLLAPI_PACKET_SET_CURSOR_POSITION, | ||
| 43 | - HLLAPI_PACKET_GET_CURSOR_POSITION, | ||
| 44 | - HLLAPI_PACKET_INPUT_STRING, | ||
| 45 | - HLLAPI_PACKET_IS_CONNECTED, | ||
| 46 | - HLLAPI_PACKET_SET_CURSOR, | ||
| 47 | - HLLAPI_PACKET_GET_CURSOR, | ||
| 48 | - HLLAPI_PACKET_EMULATE_INPUT, | ||
| 49 | - HLLAPI_PACKET_ERASE_EOF, | ||
| 50 | - HLLAPI_PACKET_PRINT, | ||
| 51 | - | ||
| 52 | - HLLAPI_PACKET_INVALID | ||
| 53 | - | ||
| 54 | - } HLLAPI_PACKET; | ||
| 55 | - | ||
| 56 | -#pragma pack(1) | ||
| 57 | - | ||
| 58 | -struct hllapi_packet_result | ||
| 59 | -{ | ||
| 60 | - int rc; | ||
| 61 | -}; | ||
| 62 | - | ||
| 63 | -struct hllapi_packet_text_result | ||
| 64 | -{ | ||
| 65 | - int rc; | ||
| 66 | - char text[1]; | ||
| 67 | -}; | ||
| 68 | - | ||
| 69 | -struct hllapi_packet_query | ||
| 70 | -{ | ||
| 71 | - unsigned char packet_id; | ||
| 72 | -}; | ||
| 73 | - | ||
| 74 | -struct hllapi_packet_connect | ||
| 75 | -{ | ||
| 76 | - unsigned char packet_id; | ||
| 77 | - unsigned char wait; | ||
| 78 | - char hostname[1]; | ||
| 79 | -}; | ||
| 80 | - | ||
| 81 | -struct hllapi_packet_keycode | ||
| 82 | -{ | ||
| 83 | - unsigned char packet_id; | ||
| 84 | - unsigned short keycode; | ||
| 85 | -}; | ||
| 86 | - | ||
| 87 | -struct hllapi_packet_cursor | ||
| 88 | -{ | ||
| 89 | - unsigned char packet_id; | ||
| 90 | - unsigned short row; | ||
| 91 | - unsigned short col; | ||
| 92 | -}; | ||
| 93 | - | ||
| 94 | -struct hllapi_packet_text | ||
| 95 | -{ | ||
| 96 | - unsigned char packet_id; | ||
| 97 | - char text[1]; | ||
| 98 | -}; | ||
| 99 | - | ||
| 100 | -struct hllapi_packet_at | ||
| 101 | -{ | ||
| 102 | - unsigned char packet_id; | ||
| 103 | - unsigned short row; | ||
| 104 | - unsigned short col; | ||
| 105 | - unsigned short len; | ||
| 106 | -}; | ||
| 107 | - | ||
| 108 | -struct hllapi_packet_text_at | ||
| 109 | -{ | ||
| 110 | - unsigned char packet_id; | ||
| 111 | - unsigned short row; | ||
| 112 | - unsigned short col; | ||
| 113 | - char text[1]; | ||
| 114 | -}; | ||
| 115 | - | ||
| 116 | -struct hllapi_packet_query_at | ||
| 117 | -{ | ||
| 118 | - unsigned char packet_id; | ||
| 119 | - unsigned short row; | ||
| 120 | - unsigned short col; | ||
| 121 | - unsigned short len; | ||
| 122 | -}; | ||
| 123 | - | ||
| 124 | -struct hllapi_packet_wait | ||
| 125 | -{ | ||
| 126 | - unsigned char packet_id; | ||
| 127 | - int timeout; | ||
| 128 | -}; | ||
| 129 | - | ||
| 130 | -struct hllapi_packet_addr | ||
| 131 | -{ | ||
| 132 | - unsigned char packet_id; | ||
| 133 | - unsigned short addr; | ||
| 134 | -}; | ||
| 135 | - | ||
| 136 | -struct hllapi_packet_query_offset | ||
| 137 | -{ | ||
| 138 | - unsigned char packet_id; | ||
| 139 | - unsigned short addr; | ||
| 140 | - unsigned short len; | ||
| 141 | -}; | ||
| 142 | - | ||
| 143 | -struct hllapi_packet_emulate_input | ||
| 144 | -{ | ||
| 145 | - unsigned char packet_id; | ||
| 146 | - unsigned short len; | ||
| 147 | - unsigned char pasting; | ||
| 148 | - char text[1]; | ||
| 149 | -}; | ||
| 150 | - | ||
| 151 | - | ||
| 152 | -#pragma pack() | ||
| 153 | - |
src/plugins/hllapi/pluginmain.c
| @@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #include "server.h" | 34 | #include "server.h" |
| 35 | - #include "packets.h" | 35 | + #include <pw3270/ipcpackets.h> |
| 36 | #include <lib3270/actions.h> | 36 | #include <lib3270/actions.h> |
| 37 | 37 | ||
| 38 | /*--[ Defines ]--------------------------------------------------------------------------------------*/ | 38 | /*--[ Defines ]--------------------------------------------------------------------------------------*/ |
src/plugins/hllapi/remote.c
| @@ -26,347 +26,347 @@ | @@ -26,347 +26,347 @@ | ||
| 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
| 27 | * | 27 | * |
| 28 | */ | 28 | */ |
| 29 | - | 29 | + |
| 30 | #include <lib3270.h> | 30 | #include <lib3270.h> |
| 31 | #include <malloc.h> | 31 | #include <malloc.h> |
| 32 | #include <string.h> | 32 | #include <string.h> |
| 33 | #include <errno.h> | 33 | #include <errno.h> |
| 34 | - #include <stdio.h> | 34 | + #include <stdio.h> |
| 35 | #include <time.h> | 35 | #include <time.h> |
| 36 | - #include <lib3270/log.h> | ||
| 37 | - | ||
| 38 | - #include "client.h" | ||
| 39 | - #include "packets.h" | ||
| 40 | - | 36 | + #include <lib3270/log.h> |
| 37 | + #include <pw3270/ipcpackets.h> | ||
| 38 | + | ||
| 39 | + #include "client.h" | ||
| 40 | + | ||
| 41 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 41 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
| 42 | - | 42 | + |
| 43 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 43 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 44 | - | ||
| 45 | - void * hllapi_pipe_init(const char *id) | ||
| 46 | - { | 44 | + |
| 45 | + void * hllapi_pipe_init(const char *id) | ||
| 46 | + { | ||
| 47 | HANDLE hPipe = INVALID_HANDLE_VALUE; | 47 | HANDLE hPipe = INVALID_HANDLE_VALUE; |
| 48 | static DWORD dwMode = PIPE_READMODE_MESSAGE; | 48 | static DWORD dwMode = PIPE_READMODE_MESSAGE; |
| 49 | - char buffer[4096]; | ||
| 50 | - char * name = strdup(id); | ||
| 51 | - char * ptr; | ||
| 52 | - | ||
| 53 | - trace("%s(%s)",__FUNCTION__,id); | ||
| 54 | - | ||
| 55 | - for(ptr=name;*ptr;ptr++) | ||
| 56 | - { | ||
| 57 | - if(*ptr == ':') | ||
| 58 | - *ptr = '_'; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - snprintf(buffer,4095,"\\\\.\\pipe\\%s",name); | ||
| 62 | - | ||
| 63 | - free(name); | ||
| 64 | - | ||
| 65 | - trace("Opening \"%s\"",buffer); | ||
| 66 | - | ||
| 67 | - if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) | ||
| 68 | - { | ||
| 69 | - trace("%s: Pipe not found",__FUNCTION__); | ||
| 70 | - errno = ENOENT; | 49 | + char buffer[4096]; |
| 50 | + char * name = strdup(id); | ||
| 51 | + char * ptr; | ||
| 52 | + | ||
| 53 | + trace("%s(%s)",__FUNCTION__,id); | ||
| 54 | + | ||
| 55 | + for(ptr=name;*ptr;ptr++) | ||
| 56 | + { | ||
| 57 | + if(*ptr == ':') | ||
| 58 | + *ptr = '_'; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + snprintf(buffer,4095,"\\\\.\\pipe\\%s",name); | ||
| 62 | + | ||
| 63 | + free(name); | ||
| 64 | + | ||
| 65 | + trace("Opening \"%s\"",buffer); | ||
| 66 | + | ||
| 67 | + if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) | ||
| 68 | + { | ||
| 69 | + trace("%s: Pipe not found",__FUNCTION__); | ||
| 70 | + errno = ENOENT; | ||
| 71 | return NULL; | 71 | return NULL; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); | 74 | hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); |
| 75 | 75 | ||
| 76 | - if(hPipe == INVALID_HANDLE_VALUE) | ||
| 77 | - { | ||
| 78 | - errno = GetLastError(); | 76 | + if(hPipe == INVALID_HANDLE_VALUE) |
| 77 | + { | ||
| 78 | + errno = GetLastError(); | ||
| 79 | return NULL; | 79 | return NULL; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) | 82 | if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) |
| 83 | - { | ||
| 84 | - errno = GetLastError(); | 83 | + { |
| 84 | + errno = GetLastError(); | ||
| 85 | return NULL; | 85 | return NULL; |
| 86 | - } | ||
| 87 | - | ||
| 88 | - trace("hPipe=%p",(void *) hPipe); | ||
| 89 | - return hPipe; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - void hllapi_pipe_deinit(void *h) | ||
| 93 | - { | ||
| 94 | - trace("%s(%p)",__FUNCTION__,h); | ||
| 95 | - | ||
| 96 | - if(!h) | ||
| 97 | - return; | ||
| 98 | - | 86 | + } |
| 87 | + | ||
| 88 | + trace("hPipe=%p",(void *) hPipe); | ||
| 89 | + return hPipe; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + void hllapi_pipe_deinit(void *h) | ||
| 93 | + { | ||
| 94 | + trace("%s(%p)",__FUNCTION__,h); | ||
| 95 | + | ||
| 96 | + if(!h) | ||
| 97 | + return; | ||
| 98 | + | ||
| 99 | CloseHandle((HANDLE) h); | 99 | CloseHandle((HANDLE) h); |
| 100 | - } | ||
| 101 | - | ||
| 102 | - const char * hllapi_pipe_get_revision(void) | ||
| 103 | - { | ||
| 104 | - return PACKAGE_REVISION; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - int hllapi_pipe_connect(void *h, const char *n, int wait) | ||
| 108 | - { | ||
| 109 | - struct hllapi_packet_connect * pkt; | ||
| 110 | - struct hllapi_packet_result response; | ||
| 111 | - DWORD cbSize; | ||
| 112 | - | ||
| 113 | - if(!n) | ||
| 114 | - n = ""; | ||
| 115 | - | ||
| 116 | - cbSize = sizeof(struct hllapi_packet_connect)+strlen(n); | ||
| 117 | - pkt = malloc(cbSize); | ||
| 118 | - | ||
| 119 | - pkt->packet_id = HLLAPI_PACKET_CONNECT; | ||
| 120 | - pkt->wait = (unsigned char) wait; | ||
| 121 | - strcpy(pkt->hostname,n); | ||
| 122 | - | ||
| 123 | - trace("Sending %s",pkt->hostname); | ||
| 124 | - | ||
| 125 | - if(!TransactNamedPipe((HANDLE) h,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL)) | ||
| 126 | - { | ||
| 127 | - errno = GetLastError(); | ||
| 128 | - response.rc = -1; | 100 | + } |
| 101 | + | ||
| 102 | + const char * hllapi_pipe_get_revision(void) | ||
| 103 | + { | ||
| 104 | + return PACKAGE_REVISION; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + int hllapi_pipe_connect(void *h, const char *n, int wait) | ||
| 108 | + { | ||
| 109 | + struct hllapi_packet_connect * pkt; | ||
| 110 | + struct hllapi_packet_result response; | ||
| 111 | + DWORD cbSize; | ||
| 112 | + | ||
| 113 | + if(!n) | ||
| 114 | + n = ""; | ||
| 115 | + | ||
| 116 | + cbSize = sizeof(struct hllapi_packet_connect)+strlen(n); | ||
| 117 | + pkt = malloc(cbSize); | ||
| 118 | + | ||
| 119 | + pkt->packet_id = HLLAPI_PACKET_CONNECT; | ||
| 120 | + pkt->wait = (unsigned char) wait; | ||
| 121 | + strcpy(pkt->hostname,n); | ||
| 122 | + | ||
| 123 | + trace("Sending %s",pkt->hostname); | ||
| 124 | + | ||
| 125 | + if(!TransactNamedPipe((HANDLE) h,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL)) | ||
| 126 | + { | ||
| 127 | + errno = GetLastError(); | ||
| 128 | + response.rc = -1; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + free(pkt); | ||
| 132 | + | ||
| 133 | + return response.rc; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + void hllapi_pipe_disconnect(void *h) | ||
| 137 | + { | ||
| 138 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT }; | ||
| 139 | + struct hllapi_packet_result response; | ||
| 140 | + DWORD cbSize = sizeof(query); | ||
| 141 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + LIB3270_MESSAGE hllapi_pipe_get_message(void *h) | ||
| 145 | + { | ||
| 146 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_PROGRAM_MESSAGE }; | ||
| 147 | + struct hllapi_packet_result response; | ||
| 148 | + DWORD cbSize = sizeof(query); | ||
| 149 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 150 | + return (LIB3270_MESSAGE) response.rc; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + char * hllapi_pipe_get_text_at(void *h, int row, int col, int len) | ||
| 154 | + { | ||
| 155 | + struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, row, col, len }; | ||
| 156 | + struct hllapi_packet_text * response; | ||
| 157 | + DWORD cbSize = sizeof(struct hllapi_packet_text)+len; | ||
| 158 | + char * text = NULL; | ||
| 159 | + | ||
| 160 | + response = malloc(cbSize+2); | ||
| 161 | + memset(response,0,cbSize+2); | ||
| 162 | + | ||
| 163 | + if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL)) | ||
| 164 | + return NULL; | ||
| 165 | + | ||
| 166 | + if(response->packet_id) | ||
| 167 | + errno = response->packet_id; | ||
| 168 | + else | ||
| 169 | + text = strdup(response->text); | ||
| 170 | + | ||
| 171 | + free(response); | ||
| 172 | + return text; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + int hllapi_pipe_enter(void *h) | ||
| 176 | + { | ||
| 177 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER }; | ||
| 178 | + struct hllapi_packet_result response; | ||
| 179 | + DWORD cbSize = sizeof(query); | ||
| 180 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 181 | + return response.rc; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + int hllapi_pipe_erase_eof(void *h) | ||
| 185 | + { | ||
| 186 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_ERASE_EOF }; | ||
| 187 | + struct hllapi_packet_result response; | ||
| 188 | + DWORD cbSize = sizeof(query); | ||
| 189 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 190 | + return response.rc; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + | ||
| 194 | + int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str) | ||
| 195 | + { | ||
| 196 | + struct hllapi_packet_text_at * query; | ||
| 197 | + struct hllapi_packet_result response; | ||
| 198 | + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str); | ||
| 199 | + | ||
| 200 | + query = malloc(cbSize); | ||
| 201 | + query->packet_id = HLLAPI_PACKET_SET_TEXT_AT; | ||
| 202 | + query->row = row; | ||
| 203 | + query->col = col; | ||
| 204 | + strcpy(query->text,(const char *) str); | ||
| 205 | + | ||
| 206 | + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 207 | + | ||
| 208 | + free(query); | ||
| 209 | + | ||
| 210 | + return response.rc; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text) | ||
| 214 | + { | ||
| 215 | + struct hllapi_packet_text_at * query; | ||
| 216 | + struct hllapi_packet_result response; | ||
| 217 | + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text); | ||
| 218 | + | ||
| 219 | + query = malloc(cbSize); | ||
| 220 | + query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT; | ||
| 221 | + query->row = row; | ||
| 222 | + query->col = col; | ||
| 223 | + strcpy(query->text,text); | ||
| 224 | + | ||
| 225 | + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 226 | + | ||
| 227 | + free(query); | ||
| 228 | + | ||
| 229 | + return response.rc; | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + int hllapi_pipe_pfkey(void *h, int key) | ||
| 233 | + { | ||
| 234 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, key }; | ||
| 235 | + struct hllapi_packet_result response; | ||
| 236 | + DWORD cbSize = sizeof(query); | ||
| 237 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 238 | + return response.rc; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + int hllapi_pipe_pakey(void *h, int key) | ||
| 242 | + { | ||
| 243 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, key }; | ||
| 244 | + struct hllapi_packet_result response; | ||
| 245 | + DWORD cbSize = sizeof(query); | ||
| 246 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 247 | + return response.rc; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + void hllapi_pipe_release_memory(void *p) | ||
| 251 | + { | ||
| 252 | + free(p); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + int hllapi_pipe_wait_for_ready(void *h, int seconds) | ||
| 256 | + { | ||
| 257 | + time_t end = time(0)+seconds; | ||
| 258 | + | ||
| 259 | + while(time(0) < end) | ||
| 260 | + { | ||
| 261 | + if(!hllapi_pipe_is_connected(h)) | ||
| 262 | + return ENOTCONN; | ||
| 263 | + | ||
| 264 | + if(hllapi_pipe_get_message(h) == 0) | ||
| 265 | + return 0; | ||
| 266 | + Sleep(250); | ||
| 129 | } | 267 | } |
| 130 | - | ||
| 131 | - free(pkt); | ||
| 132 | - | ||
| 133 | - return response.rc; | 268 | + |
| 269 | + return ETIMEDOUT; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + int hllapi_pipe_is_connected(void *h) | ||
| 273 | + { | ||
| 274 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED }; | ||
| 275 | + struct hllapi_packet_result response; | ||
| 276 | + DWORD cbSize = sizeof(query); | ||
| 277 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 278 | + return (LIB3270_MESSAGE) response.rc; | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + int hllapi_pipe_sleep(void *h, int seconds) | ||
| 282 | + { | ||
| 283 | + time_t end = time(0)+seconds; | ||
| 284 | + | ||
| 285 | + while(time(0) < end) | ||
| 286 | + { | ||
| 287 | + if(!hllapi_pipe_is_connected(h)) | ||
| 288 | + return ENOTCONN; | ||
| 289 | + Sleep(500); | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + return 0; | ||
| 134 | } | 293 | } |
| 135 | - | ||
| 136 | - void hllapi_pipe_disconnect(void *h) | ||
| 137 | - { | ||
| 138 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT }; | ||
| 139 | - struct hllapi_packet_result response; | ||
| 140 | - DWORD cbSize = sizeof(query); | ||
| 141 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - LIB3270_MESSAGE hllapi_pipe_get_message(void *h) | ||
| 145 | - { | ||
| 146 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_PROGRAM_MESSAGE }; | ||
| 147 | - struct hllapi_packet_result response; | ||
| 148 | - DWORD cbSize = sizeof(query); | ||
| 149 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 150 | - return (LIB3270_MESSAGE) response.rc; | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - char * hllapi_pipe_get_text_at(void *h, int row, int col, int len) | ||
| 154 | - { | ||
| 155 | - struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, }; | ||
| 156 | - struct hllapi_packet_text * response; | ||
| 157 | - DWORD cbSize = sizeof(struct hllapi_packet_text)+len; | ||
| 158 | - char * text = NULL; | ||
| 159 | - | ||
| 160 | - response = malloc(cbSize+2); | ||
| 161 | - memset(response,0,cbSize+2); | ||
| 162 | - | ||
| 163 | - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL)) | ||
| 164 | - return NULL; | ||
| 165 | - | ||
| 166 | - if(response->packet_id) | ||
| 167 | - errno = response->packet_id; | ||
| 168 | - else | ||
| 169 | - text = strdup(response->text); | ||
| 170 | - | ||
| 171 | - free(response); | ||
| 172 | - return text; | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - int hllapi_pipe_enter(void *h) | ||
| 176 | - { | ||
| 177 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER }; | ||
| 178 | - struct hllapi_packet_result response; | ||
| 179 | - DWORD cbSize = sizeof(query); | ||
| 180 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 181 | - return response.rc; | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - int hllapi_pipe_erase_eof(void *h) | ||
| 185 | - { | ||
| 186 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_ERASE_EOF }; | ||
| 187 | - struct hllapi_packet_result response; | ||
| 188 | - DWORD cbSize = sizeof(query); | ||
| 189 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 190 | - return response.rc; | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - | ||
| 194 | - int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str) | ||
| 195 | - { | ||
| 196 | - struct hllapi_packet_text_at * query; | ||
| 197 | - struct hllapi_packet_result response; | ||
| 198 | - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str); | ||
| 199 | - | ||
| 200 | - query = malloc(cbSize); | ||
| 201 | - query->packet_id = HLLAPI_PACKET_SET_TEXT_AT; | ||
| 202 | - query->row = row; | ||
| 203 | - query->col = col; | ||
| 204 | - strcpy(query->text,(const char *) str); | ||
| 205 | - | ||
| 206 | - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 207 | - | ||
| 208 | - free(query); | ||
| 209 | - | ||
| 210 | - return response.rc; | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text) | ||
| 214 | - { | ||
| 215 | - struct hllapi_packet_text_at * query; | ||
| 216 | - struct hllapi_packet_result response; | ||
| 217 | - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text); | ||
| 218 | - | ||
| 219 | - query = malloc(cbSize); | ||
| 220 | - query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT; | ||
| 221 | - query->row = row; | ||
| 222 | - query->col = col; | ||
| 223 | - strcpy(query->text,text); | ||
| 224 | - | ||
| 225 | - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 226 | - | ||
| 227 | - free(query); | ||
| 228 | - | ||
| 229 | - return response.rc; | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - int hllapi_pipe_pfkey(void *h, int key) | ||
| 233 | - { | ||
| 234 | - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, key }; | ||
| 235 | - struct hllapi_packet_result response; | ||
| 236 | - DWORD cbSize = sizeof(query); | ||
| 237 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 238 | - return response.rc; | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - int hllapi_pipe_pakey(void *h, int key) | ||
| 242 | - { | ||
| 243 | - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, key }; | ||
| 244 | - struct hllapi_packet_result response; | ||
| 245 | - DWORD cbSize = sizeof(query); | ||
| 246 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 247 | - return response.rc; | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - void hllapi_pipe_release_memory(void *p) | ||
| 251 | - { | ||
| 252 | - free(p); | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - int hllapi_pipe_wait_for_ready(void *h, int seconds) | ||
| 256 | - { | ||
| 257 | - time_t end = time(0)+seconds; | ||
| 258 | - | ||
| 259 | - while(time(0) < end) | ||
| 260 | - { | ||
| 261 | - if(!hllapi_pipe_is_connected(h)) | ||
| 262 | - return ENOTCONN; | ||
| 263 | - | ||
| 264 | - if(hllapi_pipe_get_message(h) == 0) | ||
| 265 | - return 0; | ||
| 266 | - Sleep(250); | ||
| 267 | - } | ||
| 268 | - | ||
| 269 | - return ETIMEDOUT; | ||
| 270 | - } | ||
| 271 | - | ||
| 272 | - int hllapi_pipe_is_connected(void *h) | ||
| 273 | - { | ||
| 274 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED }; | ||
| 275 | - struct hllapi_packet_result response; | ||
| 276 | - DWORD cbSize = sizeof(query); | ||
| 277 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 278 | - return (LIB3270_MESSAGE) response.rc; | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - int hllapi_pipe_sleep(void *h, int seconds) | ||
| 282 | - { | ||
| 283 | - time_t end = time(0)+seconds; | ||
| 284 | - | ||
| 285 | - while(time(0) < end) | ||
| 286 | - { | ||
| 287 | - if(!hllapi_pipe_is_connected(h)) | ||
| 288 | - return ENOTCONN; | ||
| 289 | - Sleep(500); | ||
| 290 | - } | ||
| 291 | - | ||
| 292 | - return 0; | ||
| 293 | - } | ||
| 294 | 294 | ||
| 295 | int hllapi_pipe_getcursor(void *h) | 295 | int hllapi_pipe_getcursor(void *h) |
| 296 | { | 296 | { |
| 297 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; | ||
| 298 | - struct hllapi_packet_result response; | ||
| 299 | - DWORD cbSize = sizeof(query); | ||
| 300 | - | ||
| 301 | - trace("%s",__FUNCTION__); | ||
| 302 | - | ||
| 303 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 304 | - return (LIB3270_MESSAGE) response.rc; | 297 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; |
| 298 | + struct hllapi_packet_result response; | ||
| 299 | + DWORD cbSize = sizeof(query); | ||
| 300 | + | ||
| 301 | + trace("%s",__FUNCTION__); | ||
| 302 | + | ||
| 303 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 304 | + return (LIB3270_MESSAGE) response.rc; | ||
| 305 | 305 | ||
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | int hllapi_pipe_setcursor(void *h, int baddr) | 308 | int hllapi_pipe_setcursor(void *h, int baddr) |
| 309 | { | 309 | { |
| 310 | - struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; | ||
| 311 | - struct hllapi_packet_result response; | ||
| 312 | - DWORD cbSize = sizeof(query); | ||
| 313 | - | ||
| 314 | - trace("%s(%d)",__FUNCTION__,query.addr); | ||
| 315 | - | ||
| 316 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 317 | - return response.rc; | 310 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr }; |
| 311 | + struct hllapi_packet_result response; | ||
| 312 | + DWORD cbSize = sizeof(query); | ||
| 313 | + | ||
| 314 | + trace("%s(%d)",__FUNCTION__,query.addr); | ||
| 315 | + | ||
| 316 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 317 | + return response.rc; | ||
| 318 | } | 318 | } |
| 319 | - | ||
| 320 | - char * hllapi_pipe_get_text(void *h, int offset, int len) | ||
| 321 | - { | ||
| 322 | - struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, offset, len }; | ||
| 323 | - struct hllapi_packet_text * response; | ||
| 324 | - DWORD cbSize = sizeof(struct hllapi_packet_text)+len; | ||
| 325 | - char * text = NULL; | ||
| 326 | - | ||
| 327 | - trace("cbSize=%d",(int) cbSize); | ||
| 328 | - | ||
| 329 | - response = malloc(cbSize+2); | ||
| 330 | - memset(response,0,cbSize+2); | ||
| 331 | - | ||
| 332 | - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(query), response, cbSize, &cbSize,NULL)) | ||
| 333 | - return NULL; | ||
| 334 | - | ||
| 335 | - trace("rc=%d",response->packet_id); | ||
| 336 | - | ||
| 337 | - if(response->packet_id) | ||
| 338 | - errno = response->packet_id; | ||
| 339 | - else | ||
| 340 | - text = strdup(response->text); | ||
| 341 | - | ||
| 342 | - free(response); | ||
| 343 | - return text; | 319 | + |
| 320 | + char * hllapi_pipe_get_text(void *h, int offset, int len) | ||
| 321 | + { | ||
| 322 | + struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, offset, len }; | ||
| 323 | + struct hllapi_packet_text * response; | ||
| 324 | + DWORD cbSize = sizeof(struct hllapi_packet_text)+len; | ||
| 325 | + char * text = NULL; | ||
| 326 | + | ||
| 327 | + trace("cbSize=%d",(int) cbSize); | ||
| 328 | + | ||
| 329 | + response = malloc(cbSize+2); | ||
| 330 | + memset(response,0,cbSize+2); | ||
| 331 | + | ||
| 332 | + if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(query), response, cbSize, &cbSize,NULL)) | ||
| 333 | + return NULL; | ||
| 334 | + | ||
| 335 | + trace("rc=%d",response->packet_id); | ||
| 336 | + | ||
| 337 | + if(response->packet_id) | ||
| 338 | + errno = response->packet_id; | ||
| 339 | + else | ||
| 340 | + text = strdup(response->text); | ||
| 341 | + | ||
| 342 | + free(response); | ||
| 343 | + return text; | ||
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | int hllapi_pipe_emulate_input(void *h, const char *text, int len, int pasting) | 346 | int hllapi_pipe_emulate_input(void *h, const char *text, int len, int pasting) |
| 347 | { | 347 | { |
| 348 | - struct hllapi_packet_emulate_input * query; | ||
| 349 | - struct hllapi_packet_result response; | ||
| 350 | - DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+strlen(text); | ||
| 351 | - | ||
| 352 | - query = malloc(cbSize); | ||
| 353 | - query->packet_id = HLLAPI_PACKET_EMULATE_INPUT; | ||
| 354 | - query->len = len; | ||
| 355 | - query->pasting = pasting; | ||
| 356 | - strcpy(query->text,text); | ||
| 357 | - | ||
| 358 | - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 359 | - | ||
| 360 | - free(query); | ||
| 361 | - | ||
| 362 | - return response.rc; | 348 | + struct hllapi_packet_emulate_input * query; |
| 349 | + struct hllapi_packet_result response; | ||
| 350 | + DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+strlen(text); | ||
| 351 | + | ||
| 352 | + query = malloc(cbSize); | ||
| 353 | + query->packet_id = HLLAPI_PACKET_EMULATE_INPUT; | ||
| 354 | + query->len = len; | ||
| 355 | + query->pasting = pasting; | ||
| 356 | + strcpy(query->text,text); | ||
| 357 | + | ||
| 358 | + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 359 | + | ||
| 360 | + free(query); | ||
| 361 | + | ||
| 362 | + return response.rc; | ||
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | int hllapi_pipe_print(void *h) | 365 | int hllapi_pipe_print(void *h) |
| 366 | { | 366 | { |
| 367 | - static const struct hllapi_packet_query query = { HLLAPI_PACKET_PRINT }; | ||
| 368 | - struct hllapi_packet_result response; | ||
| 369 | - DWORD cbSize = sizeof(query); | ||
| 370 | - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 371 | - return response.rc; | 367 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_PRINT }; |
| 368 | + struct hllapi_packet_result response; | ||
| 369 | + DWORD cbSize = sizeof(query); | ||
| 370 | + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 371 | + return response.rc; | ||
| 372 | } | 372 | } |
src/plugins/rx3270/remote.cc
| @@ -34,6 +34,11 @@ | @@ -34,6 +34,11 @@ | ||
| 34 | #include <dbus/dbus.h> | 34 | #include <dbus/dbus.h> |
| 35 | #endif // HAVE_DBUS | 35 | #endif // HAVE_DBUS |
| 36 | 36 | ||
| 37 | +#if defined(WIN32) | ||
| 38 | + #include <pw3270/ipcpackets.h> | ||
| 39 | +#endif // WIN32 | ||
| 40 | + | ||
| 41 | + #include <time.h> | ||
| 37 | #include <string.h> | 42 | #include <string.h> |
| 38 | 43 | ||
| 39 | /*--[ Class definition ]-----------------------------------------------------------------------------*/ | 44 | /*--[ Class definition ]-----------------------------------------------------------------------------*/ |
| @@ -70,7 +75,10 @@ | @@ -70,7 +75,10 @@ | ||
| 70 | private: | 75 | private: |
| 71 | #if defined(WIN32) | 76 | #if defined(WIN32) |
| 72 | 77 | ||
| 78 | + HANDLE hPipe; | ||
| 79 | + | ||
| 73 | #elif defined(HAVE_DBUS) | 80 | #elif defined(HAVE_DBUS) |
| 81 | + | ||
| 74 | DBusConnection * conn; | 82 | DBusConnection * conn; |
| 75 | char * dest; | 83 | char * dest; |
| 76 | char * path; | 84 | char * path; |
| @@ -79,6 +87,7 @@ | @@ -79,6 +87,7 @@ | ||
| 79 | DBusMessage * call(DBusMessage *msg); | 87 | DBusMessage * call(DBusMessage *msg); |
| 80 | char * query_string(const char *method); | 88 | char * query_string(const char *method); |
| 81 | int query_intval(const char *method); | 89 | int query_intval(const char *method); |
| 90 | + | ||
| 82 | #endif | 91 | #endif |
| 83 | 92 | ||
| 84 | 93 | ||
| @@ -89,8 +98,6 @@ | @@ -89,8 +98,6 @@ | ||
| 89 | #if defined(HAVE_DBUS) | 98 | #if defined(HAVE_DBUS) |
| 90 | static const char * prefix_dest = "br.com.bb."; | 99 | static const char * prefix_dest = "br.com.bb."; |
| 91 | static const char * prefix_path = "/br/com/bb/"; | 100 | static const char * prefix_path = "/br/com/bb/"; |
| 92 | -#else | ||
| 93 | - #error AQUI | ||
| 94 | #endif // HAVE_DBUS | 101 | #endif // HAVE_DBUS |
| 95 | 102 | ||
| 96 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 103 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| @@ -120,6 +127,46 @@ rx3270 * rx3270::create_remote(const char *name) | @@ -120,6 +127,46 @@ rx3270 * rx3270::create_remote(const char *name) | ||
| 120 | remote::remote(const char *name) | 127 | remote::remote(const char *name) |
| 121 | { | 128 | { |
| 122 | #if defined(WIN32) | 129 | #if defined(WIN32) |
| 130 | + static DWORD dwMode = PIPE_READMODE_MESSAGE; | ||
| 131 | + char buffer[4096]; | ||
| 132 | + char * str = strdup(name); | ||
| 133 | + char * ptr; | ||
| 134 | + | ||
| 135 | + hPipe = INVALID_HANDLE_VALUE; | ||
| 136 | + | ||
| 137 | + for(ptr=str;*ptr;ptr++) | ||
| 138 | + { | ||
| 139 | + if(*ptr == ':') | ||
| 140 | + *ptr = '_'; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + snprintf(buffer,4095,"\\\\.\\pipe\\%s",str); | ||
| 144 | + | ||
| 145 | + free(str); | ||
| 146 | + | ||
| 147 | + if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) | ||
| 148 | + { | ||
| 149 | + log("%s","Invalid service instance"); | ||
| 150 | + return; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); | ||
| 154 | + | ||
| 155 | + if(hPipe == INVALID_HANDLE_VALUE) | ||
| 156 | + { | ||
| 157 | + log("%s","Can´t create service pipe"); | ||
| 158 | + return; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) | ||
| 162 | + { | ||
| 163 | + log("%s","Can´t set pipe state"); | ||
| 164 | + CloseHandle(hPipe); | ||
| 165 | + hPipe = INVALID_HANDLE_VALUE; | ||
| 166 | + return; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + // Connected | ||
| 123 | 170 | ||
| 124 | #elif defined(HAVE_DBUS) | 171 | #elif defined(HAVE_DBUS) |
| 125 | DBusError err; | 172 | DBusError err; |
| @@ -209,6 +256,9 @@ remote::~remote() | @@ -209,6 +256,9 @@ remote::~remote() | ||
| 209 | { | 256 | { |
| 210 | #if defined(WIN32) | 257 | #if defined(WIN32) |
| 211 | 258 | ||
| 259 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 260 | + CloseHandle(hPipe); | ||
| 261 | + | ||
| 212 | #elif defined(HAVE_DBUS) | 262 | #elif defined(HAVE_DBUS) |
| 213 | 263 | ||
| 214 | free(dest); | 264 | free(dest); |
| @@ -303,8 +353,7 @@ char * remote::get_revision(void) | @@ -303,8 +353,7 @@ char * remote::get_revision(void) | ||
| 303 | { | 353 | { |
| 304 | #if defined(WIN32) | 354 | #if defined(WIN32) |
| 305 | 355 | ||
| 306 | - return NULL; | ||
| 307 | - | 356 | + return strdup(PACKAGE_REVISION); |
| 308 | 357 | ||
| 309 | #elif defined(HAVE_DBUS) | 358 | #elif defined(HAVE_DBUS) |
| 310 | 359 | ||
| @@ -323,6 +372,11 @@ LIB3270_CSTATE remote::get_cstate(void) | @@ -323,6 +372,11 @@ LIB3270_CSTATE remote::get_cstate(void) | ||
| 323 | { | 372 | { |
| 324 | #if defined(WIN32) | 373 | #if defined(WIN32) |
| 325 | 374 | ||
| 375 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 376 | + { | ||
| 377 | + | ||
| 378 | + } | ||
| 379 | + | ||
| 326 | return (LIB3270_CSTATE) -1; | 380 | return (LIB3270_CSTATE) -1; |
| 327 | 381 | ||
| 328 | #elif defined(HAVE_DBUS) | 382 | #elif defined(HAVE_DBUS) |
| @@ -341,6 +395,16 @@ int remote::disconnect(void) | @@ -341,6 +395,16 @@ int remote::disconnect(void) | ||
| 341 | { | 395 | { |
| 342 | #if defined(WIN32) | 396 | #if defined(WIN32) |
| 343 | 397 | ||
| 398 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 399 | + { | ||
| 400 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT }; | ||
| 401 | + struct hllapi_packet_result response; | ||
| 402 | + DWORD cbSize = sizeof(query); | ||
| 403 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 404 | + return 0; | ||
| 405 | + } | ||
| 406 | + return -1; | ||
| 407 | + | ||
| 344 | #elif defined(HAVE_DBUS) | 408 | #elif defined(HAVE_DBUS) |
| 345 | 409 | ||
| 346 | return query_intval("disconnect"); | 410 | return query_intval("disconnect"); |
| @@ -356,6 +420,32 @@ int remote::disconnect(void) | @@ -356,6 +420,32 @@ int remote::disconnect(void) | ||
| 356 | int remote::connect(const char *uri, bool wait) | 420 | int remote::connect(const char *uri, bool wait) |
| 357 | { | 421 | { |
| 358 | #if defined(WIN32) | 422 | #if defined(WIN32) |
| 423 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 424 | + { | ||
| 425 | + struct hllapi_packet_connect * pkt; | ||
| 426 | + struct hllapi_packet_result response; | ||
| 427 | + DWORD cbSize; | ||
| 428 | + | ||
| 429 | + cbSize = sizeof(struct hllapi_packet_connect)+strlen(uri); | ||
| 430 | + pkt = (struct hllapi_packet_connect *) malloc(cbSize); | ||
| 431 | + | ||
| 432 | + pkt->packet_id = HLLAPI_PACKET_CONNECT; | ||
| 433 | + pkt->wait = (unsigned char) wait; | ||
| 434 | + strcpy(pkt->hostname,uri); | ||
| 435 | + | ||
| 436 | + trace("Sending %s",pkt->hostname); | ||
| 437 | + | ||
| 438 | + if(!TransactNamedPipe(hPipe,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL)) | ||
| 439 | + { | ||
| 440 | + errno = GetLastError(); | ||
| 441 | + response.rc = -1; | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + free(pkt); | ||
| 445 | + | ||
| 446 | + return response.rc; | ||
| 447 | + | ||
| 448 | + } | ||
| 359 | 449 | ||
| 360 | #elif defined(HAVE_DBUS) | 450 | #elif defined(HAVE_DBUS) |
| 361 | 451 | ||
| @@ -368,6 +458,15 @@ bool remote::is_connected(void) | @@ -368,6 +458,15 @@ bool remote::is_connected(void) | ||
| 368 | { | 458 | { |
| 369 | #if defined(WIN32) | 459 | #if defined(WIN32) |
| 370 | 460 | ||
| 461 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 462 | + { | ||
| 463 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED }; | ||
| 464 | + struct hllapi_packet_result response; | ||
| 465 | + DWORD cbSize = sizeof(query); | ||
| 466 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 467 | + return response.rc != 0; | ||
| 468 | + } | ||
| 469 | + | ||
| 371 | #elif defined(HAVE_DBUS) | 470 | #elif defined(HAVE_DBUS) |
| 372 | 471 | ||
| 373 | #endif | 472 | #endif |
| @@ -379,6 +478,11 @@ bool remote::is_ready(void) | @@ -379,6 +478,11 @@ bool remote::is_ready(void) | ||
| 379 | { | 478 | { |
| 380 | #if defined(WIN32) | 479 | #if defined(WIN32) |
| 381 | 480 | ||
| 481 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 482 | + { | ||
| 483 | + | ||
| 484 | + } | ||
| 485 | + | ||
| 382 | #elif defined(HAVE_DBUS) | 486 | #elif defined(HAVE_DBUS) |
| 383 | 487 | ||
| 384 | #endif | 488 | #endif |
| @@ -390,6 +494,8 @@ int remote::iterate(bool wait) | @@ -390,6 +494,8 @@ int remote::iterate(bool wait) | ||
| 390 | { | 494 | { |
| 391 | #if defined(WIN32) | 495 | #if defined(WIN32) |
| 392 | 496 | ||
| 497 | + return 0; | ||
| 498 | + | ||
| 393 | #elif defined(HAVE_DBUS) | 499 | #elif defined(HAVE_DBUS) |
| 394 | 500 | ||
| 395 | return 0; | 501 | return 0; |
| @@ -403,9 +509,28 @@ int remote::wait(int seconds) | @@ -403,9 +509,28 @@ int remote::wait(int seconds) | ||
| 403 | { | 509 | { |
| 404 | #if defined(WIN32) | 510 | #if defined(WIN32) |
| 405 | 511 | ||
| 512 | + time_t end = time(0)+seconds; | ||
| 513 | + | ||
| 514 | + while(time(0) < end) | ||
| 515 | + { | ||
| 516 | + if(!is_connected()) | ||
| 517 | + return ENOTCONN; | ||
| 518 | + Sleep(500); | ||
| 519 | + } | ||
| 520 | + | ||
| 521 | + return 0; | ||
| 522 | + | ||
| 406 | #elif defined(HAVE_DBUS) | 523 | #elif defined(HAVE_DBUS) |
| 407 | 524 | ||
| 408 | - sleep(seconds); | 525 | + time_t end = time(0)+seconds; |
| 526 | + | ||
| 527 | + while(time(0) < end) | ||
| 528 | + { | ||
| 529 | + if(!is_connected()) | ||
| 530 | + return ENOTCONN; | ||
| 531 | + usleep(500); | ||
| 532 | + } | ||
| 533 | + | ||
| 409 | return 0; | 534 | return 0; |
| 410 | 535 | ||
| 411 | #endif | 536 | #endif |
| @@ -417,6 +542,26 @@ int remote::wait_for_ready(int seconds) | @@ -417,6 +542,26 @@ int remote::wait_for_ready(int seconds) | ||
| 417 | { | 542 | { |
| 418 | #if defined(WIN32) | 543 | #if defined(WIN32) |
| 419 | 544 | ||
| 545 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 546 | + { | ||
| 547 | + time_t end = time(0)+seconds; | ||
| 548 | + | ||
| 549 | + while(time(0) < end) | ||
| 550 | + { | ||
| 551 | + if(!is_connected()) | ||
| 552 | + return ENOTCONN; | ||
| 553 | + | ||
| 554 | + if(is_ready()) | ||
| 555 | + return 0; | ||
| 556 | + | ||
| 557 | + Sleep(250); | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | + return ETIMEDOUT; | ||
| 561 | + | ||
| 562 | + } | ||
| 563 | + | ||
| 564 | + | ||
| 420 | #elif defined(HAVE_DBUS) | 565 | #elif defined(HAVE_DBUS) |
| 421 | 566 | ||
| 422 | #endif | 567 | #endif |
| @@ -428,6 +573,29 @@ char * remote::get_text_at(int row, int col, size_t sz) | @@ -428,6 +573,29 @@ char * remote::get_text_at(int row, int col, size_t sz) | ||
| 428 | { | 573 | { |
| 429 | #if defined(WIN32) | 574 | #if defined(WIN32) |
| 430 | 575 | ||
| 576 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 577 | + { | ||
| 578 | + struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz }; | ||
| 579 | + struct hllapi_packet_text * response; | ||
| 580 | + DWORD cbSize = sizeof(struct hllapi_packet_text)+sz; | ||
| 581 | + char * text = NULL; | ||
| 582 | + | ||
| 583 | + response = (struct hllapi_packet_text *) malloc(cbSize+2); | ||
| 584 | + memset(response,0,cbSize+2); | ||
| 585 | + | ||
| 586 | + if(!TransactNamedPipe(hPipe,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL)) | ||
| 587 | + return NULL; | ||
| 588 | + | ||
| 589 | + if(response->packet_id) | ||
| 590 | + errno = response->packet_id; | ||
| 591 | + else | ||
| 592 | + text = strdup(response->text); | ||
| 593 | + | ||
| 594 | + free(response); | ||
| 595 | + return text; | ||
| 596 | + | ||
| 597 | + } | ||
| 598 | + | ||
| 431 | #elif defined(HAVE_DBUS) | 599 | #elif defined(HAVE_DBUS) |
| 432 | 600 | ||
| 433 | #endif | 601 | #endif |
| @@ -439,6 +607,26 @@ int remote::cmp_text_at(int row, int col, const char *text) | @@ -439,6 +607,26 @@ int remote::cmp_text_at(int row, int col, const char *text) | ||
| 439 | { | 607 | { |
| 440 | #if defined(WIN32) | 608 | #if defined(WIN32) |
| 441 | 609 | ||
| 610 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 611 | + { | ||
| 612 | + struct hllapi_packet_text_at * query; | ||
| 613 | + struct hllapi_packet_result response; | ||
| 614 | + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text); | ||
| 615 | + | ||
| 616 | + query = (struct hllapi_packet_text_at *) malloc(cbSize); | ||
| 617 | + query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT; | ||
| 618 | + query->row = row; | ||
| 619 | + query->col = col; | ||
| 620 | + strcpy(query->text,text); | ||
| 621 | + | ||
| 622 | + TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 623 | + | ||
| 624 | + free(query); | ||
| 625 | + | ||
| 626 | + return response.rc; | ||
| 627 | + } | ||
| 628 | + | ||
| 629 | + | ||
| 442 | #elif defined(HAVE_DBUS) | 630 | #elif defined(HAVE_DBUS) |
| 443 | 631 | ||
| 444 | #endif | 632 | #endif |
| @@ -450,6 +638,25 @@ int remote::set_text_at(int row, int col, const char *str) | @@ -450,6 +638,25 @@ int remote::set_text_at(int row, int col, const char *str) | ||
| 450 | { | 638 | { |
| 451 | #if defined(WIN32) | 639 | #if defined(WIN32) |
| 452 | 640 | ||
| 641 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 642 | + { | ||
| 643 | + struct hllapi_packet_text_at * query; | ||
| 644 | + struct hllapi_packet_result response; | ||
| 645 | + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str); | ||
| 646 | + | ||
| 647 | + query = (struct hllapi_packet_text_at *) malloc(cbSize); | ||
| 648 | + query->packet_id = HLLAPI_PACKET_SET_TEXT_AT; | ||
| 649 | + query->row = row; | ||
| 650 | + query->col = col; | ||
| 651 | + strcpy(query->text,(const char *) str); | ||
| 652 | + | ||
| 653 | + TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 654 | + | ||
| 655 | + free(query); | ||
| 656 | + | ||
| 657 | + return response.rc; | ||
| 658 | + } | ||
| 659 | + | ||
| 453 | #elif defined(HAVE_DBUS) | 660 | #elif defined(HAVE_DBUS) |
| 454 | 661 | ||
| 455 | #endif | 662 | #endif |
| @@ -461,6 +668,11 @@ int remote::set_cursor_position(int row, int col) | @@ -461,6 +668,11 @@ int remote::set_cursor_position(int row, int col) | ||
| 461 | { | 668 | { |
| 462 | #if defined(WIN32) | 669 | #if defined(WIN32) |
| 463 | 670 | ||
| 671 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 672 | + { | ||
| 673 | + | ||
| 674 | + } | ||
| 675 | + | ||
| 464 | #elif defined(HAVE_DBUS) | 676 | #elif defined(HAVE_DBUS) |
| 465 | 677 | ||
| 466 | #endif | 678 | #endif |
| @@ -472,6 +684,15 @@ int remote::enter(void) | @@ -472,6 +684,15 @@ int remote::enter(void) | ||
| 472 | { | 684 | { |
| 473 | #if defined(WIN32) | 685 | #if defined(WIN32) |
| 474 | 686 | ||
| 687 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 688 | + { | ||
| 689 | + static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER }; | ||
| 690 | + struct hllapi_packet_result response; | ||
| 691 | + DWORD cbSize = sizeof(query); | ||
| 692 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 693 | + return response.rc; | ||
| 694 | + } | ||
| 695 | + | ||
| 475 | return -1; | 696 | return -1; |
| 476 | 697 | ||
| 477 | #elif defined(HAVE_DBUS) | 698 | #elif defined(HAVE_DBUS) |
| @@ -490,6 +711,15 @@ int remote::pfkey(int key) | @@ -490,6 +711,15 @@ int remote::pfkey(int key) | ||
| 490 | { | 711 | { |
| 491 | #if defined(WIN32) | 712 | #if defined(WIN32) |
| 492 | 713 | ||
| 714 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 715 | + { | ||
| 716 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, (unsigned short) key }; | ||
| 717 | + struct hllapi_packet_result response; | ||
| 718 | + DWORD cbSize = sizeof(query); | ||
| 719 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 720 | + return response.rc; | ||
| 721 | + } | ||
| 722 | + | ||
| 493 | #elif defined(HAVE_DBUS) | 723 | #elif defined(HAVE_DBUS) |
| 494 | 724 | ||
| 495 | #endif | 725 | #endif |
| @@ -501,6 +731,15 @@ int remote::pakey(int key) | @@ -501,6 +731,15 @@ int remote::pakey(int key) | ||
| 501 | { | 731 | { |
| 502 | #if defined(WIN32) | 732 | #if defined(WIN32) |
| 503 | 733 | ||
| 734 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 735 | + { | ||
| 736 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, (unsigned short) key }; | ||
| 737 | + struct hllapi_packet_result response; | ||
| 738 | + DWORD cbSize = sizeof(query); | ||
| 739 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | ||
| 740 | + return response.rc; | ||
| 741 | + } | ||
| 742 | + | ||
| 504 | #elif defined(HAVE_DBUS) | 743 | #elif defined(HAVE_DBUS) |
| 505 | 744 | ||
| 506 | #endif | 745 | #endif |
| @@ -512,7 +751,14 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value) | @@ -512,7 +751,14 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value) | ||
| 512 | { | 751 | { |
| 513 | #if defined(WIN32) | 752 | #if defined(WIN32) |
| 514 | 753 | ||
| 754 | + if(hPipe != INVALID_HANDLE_VALUE) | ||
| 755 | + { | ||
| 756 | + | ||
| 757 | + } | ||
| 758 | + | ||
| 515 | #elif defined(HAVE_DBUS) | 759 | #elif defined(HAVE_DBUS) |
| 516 | 760 | ||
| 517 | #endif | 761 | #endif |
| 762 | + | ||
| 518 | } | 763 | } |
| 764 | + |