Commit b6e92ddd2c62a23f57ac641e55d2fe14730f74bd

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

Adding snippet.

Refactoring hllapi module.
@@ -94,6 +94,8 @@ CFLAGS= \ @@ -94,6 +94,8 @@ CFLAGS= \
94 -DBUILD_DATE=`date +%Y%m%d` \ 94 -DBUILD_DATE=`date +%Y%m%d` \
95 @IPC3270_CFLAGS@ 95 @IPC3270_CFLAGS@
96 96
  97 +LDFLAGS=@LDFLAGS@
  98 +
97 LIBS= \ 99 LIBS= \
98 @LIBS@ \ 100 @LIBS@ \
99 @IPC3270_LIBS@ 101 @IPC3270_LIBS@
@@ -72,17 +72,14 @@ dnl --------------------------------------------------------------------------- @@ -72,17 +72,14 @@ dnl ---------------------------------------------------------------------------
72 dnl Check for OS specifics 72 dnl Check for OS specifics
73 dnl --------------------------------------------------------------------------- 73 dnl ---------------------------------------------------------------------------
74 74
75 -DLLPREFIX="lib"  
76 -  
77 case "$host" in 75 case "$host" in
78 *-mingw32|*-pc-msys) 76 *-mingw32|*-pc-msys)
79 app_cv_osname="windows" 77 app_cv_osname="windows"
80 78
81 CFLAGS="$CFLAGS -pthread -D_WIN32_WINNT=0x0600" 79 CFLAGS="$CFLAGS -pthread -D_WIN32_WINNT=0x0600"
82 LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32" 80 LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32"
83 - STATIC_LDFLAGS="-static-libgcc -static-libstdc++" 81 + LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
84 DLLEXT=".dll" 82 DLLEXT=".dll"
85 - DLLPREFIX=""  
86 83
87 app_win32_revision=$(date +%-y.%-m.%-d.%-H) 84 app_win32_revision=$(date +%-y.%-m.%-d.%-H)
88 AC_SUBST(WIN32_VERSION,$app_win32_revision) 85 AC_SUBST(WIN32_VERSION,$app_win32_revision)
@@ -90,7 +87,7 @@ case "$host" in @@ -90,7 +87,7 @@ case "$host" in
90 app_win32_file_version=$(date +%-y,%-m,%-d,%-H) 87 app_win32_file_version=$(date +%-y,%-m,%-d,%-H)
91 AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version) 88 AC_SUBST(WIN32_FILE_VERSION,$app_win32_file_version)
92 89
93 - AC_CONFIG_FILES(src/hllapi/windows/resources.rc) 90 + AC_CONFIG_FILES(src/core/windows/resources.rc)
94 ;; 91 ;;
95 92
96 *) 93 *)
@@ -205,7 +202,32 @@ dnl --------------------------------------------------------------------------- @@ -205,7 +202,32 @@ dnl ---------------------------------------------------------------------------
205 dnl Check for IPC3270 202 dnl Check for IPC3270
206 dnl --------------------------------------------------------------------------- 203 dnl ---------------------------------------------------------------------------
207 204
208 -PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(HAVE_IPC3270), AC_MSG_ERROR([LIB3270 not present.])) 205 +AC_ARG_WITH([static-ipc3270],
  206 + [AS_HELP_STRING([--with-static-ipc3270], [Uses static version of ipc3270])],
  207 +[
  208 + app_cv_static_ipc3270=$withval
  209 +],[
  210 + app_cv_static_ipc3270="auto"
  211 +])
  212 +
  213 +if test "$app_cv_static_ipc3270" == "auto"; then
  214 + case "$host" in
  215 + *-mingw32|*-pc-msys)
  216 + app_cv_static_ipc3270="yes"
  217 + ;;
  218 +
  219 + *)
  220 + app_cv_static_ipc3270="no"
  221 +
  222 + esac
  223 +
  224 +fi
  225 +
  226 +if test "$app_cv_static_ipc3270" == "yes"; then
  227 + PKG_CHECK_MODULES( [IPC3270], [ipc3270-static], AC_DEFINE(USING_STATIC_IPC3270), AC_MSG_ERROR([IPC3270 not present.]))
  228 +else
  229 + PKG_CHECK_MODULES( [IPC3270], [ipc3270], AC_DEFINE(USING_SHARED_IPC3270), AC_MSG_ERROR([IPC3270 not present.]))
  230 +fi
209 231
210 AC_SUBST(IPC3270_LIBS) 232 AC_SUBST(IPC3270_LIBS)
211 AC_SUBST(IPC3270_CFLAGS) 233 AC_SUBST(IPC3270_CFLAGS)
@@ -39,21 +39,10 @@ @@ -39,21 +39,10 @@
39 <Unit filename="src/core/get.cc" /> 39 <Unit filename="src/core/get.cc" />
40 <Unit filename="src/core/hllapi.cc" /> 40 <Unit filename="src/core/hllapi.cc" />
41 <Unit filename="src/core/private.h" /> 41 <Unit filename="src/core/private.h" />
  42 + <Unit filename="src/core/set.cc" />
42 <Unit filename="src/core/windows/resources.rc" /> 43 <Unit filename="src/core/windows/resources.rc" />
43 <Unit filename="src/include/config.h" /> 44 <Unit filename="src/include/config.h" />
44 <Unit filename="src/include/lib3270/hllapi.h" /> 45 <Unit filename="src/include/lib3270/hllapi.h" />
45 - <Unit filename="src/ipc3270c/linux/gobject.c">  
46 - <Option compilerVar="CC" />  
47 - </Unit>  
48 - <Unit filename="src/ipc3270c/linux/main.c">  
49 - <Option compilerVar="CC" />  
50 - </Unit>  
51 - <Unit filename="src/ipc3270c/linux/misc.c">  
52 - <Option compilerVar="CC" />  
53 - </Unit>  
54 - <Unit filename="src/ipc3270c/windows/main.c">  
55 - <Option compilerVar="CC" />  
56 - </Unit>  
57 <Unit filename="src/testprogram/testprogram.cc" /> 46 <Unit filename="src/testprogram/testprogram.cc" />
58 <Extensions> 47 <Extensions>
59 <code_completion /> 48 <code_completion />
snippets/sample.vbs 0 → 100644
@@ -0,0 +1,250 @@ @@ -0,0 +1,250 @@
  1 +REM Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  2 +REM (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  3 +REM aplicativos mainframe. Registro no INPI sob o nome G3270.
  4 +REM
  5 +REM Copyright (C) <2008> <Banco do Brasil S.A.>
  6 +REM
  7 +REM Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  8 +REM os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  9 +REM Free Software Foundation.
  10 +REM
  11 +REM Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  12 +REM GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  13 +REM A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  14 +REM obter mais detalhes.
  15 +REM
  16 +REM Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  17 +REM programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  18 +REM St, Fifth Floor, Boston, MA 02110-1301 USA
  19 +REM
  20 +REM Contatos:
  21 +REM
  22 +REM perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  23 +REM erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  24 +REM
  25 +
  26 +REM Inicializa a biblioteca
  27 +
  28 +rem hllapi_init() - Inicia uma sessão 3270
  29 +rem
  30 +rem hllapi_init pode receber como argumento o nome de uma janela já aberta,
  31 +rem por exemplo, "pw3270:a" para com que atue direto sobre ela, ou,
  32 +rem com uma string vazia ("") para tentar criar uma sessão sem janela.
  33 +rem
  34 +Declare Function hllapi_init Lib "libhllapi.dll" (ByVal tp as string) as Long
  35 +
  36 +rem hllapi_deinit() - Encerra uma sessão 3270
  37 +rem
  38 +rem Finaliza a sessão 3270 liberando os recursos usados.
  39 +rem
  40 +Declare Function hllapi_deinit Lib "libhllapi.dll" () as Long
  41 +
  42 +rem hllapi_get_revision - Obtém a revisão do pw3270 que está sendo usada.
  43 +rem
  44 +Declare Function hllapi_get_revision Lib "libhllapi.dll" () as Long
  45 +
  46 +rem hllapi_connect() - Conecta a um host 3270
  47 +rem
  48 +rem Efetua a conexão ao host 3270, recebe 2 parâmetros
  49 +rem
  50 +rem uri - URI com o endereço de conexão ao host
  51 +rem wait - Quantos segundos a função deve esperar até o estabelecimento da sessão
  52 +rem
  53 +Declare Function hllapi_connect Lib "libhllapi.dll" (ByVal uri as string, ByVal wait as Integer) as Long
  54 +
  55 +rem hllapi_disconnect() - Desconecta do host 3270
  56 +rem
  57 +Declare Function hllapi_disconnect Lib "libhllapi.dll" () as Long
  58 +
  59 +rem hllapi_wait_for_ready() - Aguarda que o terminal fique disponível
  60 +rem
  61 +rem Suspende a atividade até que o terminal esteja pronto para receber comandos.
  62 +rem
  63 +rem Recebe apenas um valor numérico com o tempo em segundos a esperar; caso esse
  64 +rem tempo seja atingido sem o terminal ficar disponível a função retorna erro.
  65 +rem
  66 +Declare Function hllapi_wait_for_ready Lib "libhllapi.dll" (ByVal timeout as Integer) as Long
  67 +
  68 +rem hllapi_wait() - Aguarda por "x" segundos
  69 +rem
  70 +rem Suspende a atividade do script mantendo a comunicação com o host ativa; pode ser usada
  71 +rem para parar por um tempo específico enquanto o host executa algum processo.
  72 +rem
  73 +rem Recebe apenas um valor numérico com o tempo em segundos a esperar.
  74 +rem
  75 +Declare Function hllapi_wait Lib "libhllapi.dll" (ByVal timeout as Integer) as Long
  76 +
  77 +rem hllapi_get_message_id() - Obtém o código da mensagem atual da OIA
  78 +rem
  79 +rem Obtém o código numérico correspondente à mensagem de status da OIA.
  80 +rem
  81 +Declare Function hllapi_get_message_id Lib "libhllapi.dll" () as Long
  82 +
  83 +rem hllapi_is_connected() - Verifica se existe uma conexão com o host
  84 +rem
  85 +Declare Function hllapi_is_connected Lib "libhllapi.dll" () as Long
  86 +
  87 +rem hllapi_get_screen() - Obtém conteúdo de uma parte do terminal pelo endereço
  88 +rem
  89 +rem Preenche a string com o conteúdo do termina na posição desejada
  90 +rem
  91 +rem Recebe 3 parâmetros:
  92 +rem
  93 +rem - Posição na tela
  94 +rem - String com espaço suficiente
  95 +rem - Tamanho desejado (se for -1 usa o tamanho da string)
  96 +rem
  97 +Declare Function hllapi_get_screen Lib "libhllapi.dll" (ByVal offset as Integer, ByVal text as String, ByVal length as Integer) as Long
  98 +
  99 +rem hllapi_get_screen_at() - Obtém o conteúdo de uma parte da tela do terminal.
  100 +rem
  101 +rem Preenche a string com o conteúdo do terminal a partir da linha e coluna
  102 +rem desejadas.
  103 +rem
  104 +rem Recebe 3 parâmetros:
  105 +rem
  106 +rem - Linha da posição inicial
  107 +rem - Coluna da posição inicial
  108 +rem - String já com o tamanho desejado
  109 +rem
  110 +Declare Function hllapi_get_screen_at Lib "libhllapi.dll" (ByVal row as Integer, ByVal col as Integer, ByVal text as String) as Long
  111 +
  112 +rem hllapi_set_text_at() - Aplica string na tela do terminal.
  113 +rem
  114 +rem Aplica a string na linha e coluna informadas; atentar para o fato de que
  115 +rem a posição deve estar disponível para escrita.
  116 +rem
  117 +rem Recebe 3 parâmetros:
  118 +rem
  119 +rem - Linha da posição inicial
  120 +rem - Coluna da posição inicial
  121 +rem - String que será aplicada
  122 +rem
  123 +Declare Function hllapi_set_text_at Lib "libhllapi.dll" (ByVal row as Integer, ByVal col as Integer, ByVal text as String) as Long
  124 +
  125 +rem hllapi_cmp_text_at() - Compara conteúdo da tela.
  126 +rem
  127 +rem Compara o conteúdo da tela na posição informada, recebe 3 parâmetros.
  128 +rem
  129 +rem - Linha da posição inicial
  130 +rem - Coluna da posição inicial
  131 +rem - String a comparar
  132 +rem
  133 +rem Retorna 0 se o valor contido na tela é igual ao informado, diferente de zero se não for.
  134 +rem
  135 +Declare Function hllapi_cmp_text_at Lib "libhllapi.dll" (ByVal row as Integer, ByVal col as Integer, ByVal text as String) as Long
  136 +
  137 +rem hllapi_find_text
  138 +rem
  139 +rem Obtém a posição da string na tela.
  140 +rem
  141 +rem - String a pesquisar
  142 +rem
  143 +rem 0 se a string não foi encontrada, a posição na tela se encontrar.
  144 +rem
  145 +Declare Function hllapi_find_text Lib "libhllapi.dll" (ByVal text as String) as Long
  146 +
  147 +rem hllapi_enter()
  148 +rem
  149 +rem Envia um [ENTER] para o host.
  150 +rem
  151 +Declare Function hllapi_enter Lib "libhllapi.dll" () as Long
  152 +
  153 +rem hllapi_pfkey()
  154 +rem
  155 +rem Envia uma [PF] para o host.
  156 +rem
  157 +rem Recebe como argumento o número da PF que será enviada.
  158 +rem
  159 +Declare Function hllapi_pfkey Lib "libhllapi.dll" (ByVal keycode as Integer) as Long
  160 +
  161 +rem hllapi_pakey()
  162 +rem
  163 +rem Envia uma [PA] para o host.
  164 +rem
  165 +rem Recebe como argumento o número da PA que será enviada.
  166 +rem
  167 +Declare Function hllapi_pakey Lib "libhllapi.dll" (ByVal keycode as Integer) as Long
  168 +
  169 +rem hllapi_set_session_parameter()
  170 +rem
  171 +rem Configura um parâmetro da sessão
  172 +rem
  173 +rem Recebe como argumentos:
  174 +rem
  175 +rem 1. Nome do parâmetro a ser ajustado
  176 +rem 2. Tamanho do nome do parâmetro (ou 0)
  177 +rem 3. Valor a atribuir
  178 +rem
  179 +Declare Function hllapi_set_session_parameter Lib "libhllapi.dll" (ByVal text as String, ByVal len as Integer, ByVal value as Integer) as Long
  180 +
  181 +rem hllapi_set_charset()
  182 +rem
  183 +rem Configura a página de código
  184 +rem
  185 +rem Recebe como argumentos:
  186 +rem
  187 +rem 1. Nome da página de código desejada (UTF-8, CP1252, ISO-8859-1, etc).
  188 +rem
  189 +Declare Function hllapi_set_charset Lib "libhllapi.dll" (ByVal text as String, ByVal len as Integer, ByVal value as Integer) as Long
  190 +
  191 +rem hllapi_set_unlock_delay()
  192 +rem
  193 +rem Define o tempo (em milisegundos) que o terminal
  194 +rem espera para desbloquear a sessão após um comando.
  195 +rem
  196 +rem Recebe como argumento o valor do delay em milisegundos.
  197 +rem
  198 +Declare Function hllapi_set_unlock_delay Lib "libhllapi.dll" (ByVal delay as Integer) as Long
  199 +
  200 +rem hllapi_get_cursor_address() - Obtém a posição atual do cursor
  201 +rem
  202 +rem Obtém a posição atual do cursor dentro da tela do terminal
  203 +rem
  204 +Declare Function hllapi_get_cursor_address Lib "libhllapi.dll" () as Long
  205 +
  206 +rem hllapi_set_cursor_address()
  207 +rem
  208 +rem Define a posição atual do cursor
  209 +rem
  210 +rem Recebe 1 argumento:
  211 +rem
  212 +rem Novo endereço do cursor dentro da tela do terminal.
  213 +rem
  214 +Declare Function hllapi_set_cursor_address Lib "libhllapi.dll" (ByVal addr) as Long
  215 +
  216 +Sub Main
  217 +
  218 + if hllapi_init("") <> 0 then
  219 + print "Erro ao inicializar a biblioteca"
  220 + Exit Sub
  221 + End If
  222 +
  223 + hllapi_connect("fandezhi.efglobe.com:23",0)
  224 +
  225 + Do While hllapi_is_connected() = 0
  226 +
  227 + hllapi_wait(1)
  228 +
  229 + Loop
  230 +
  231 + if hllapi_wait_for_ready(60) <> 0 then
  232 + print "Conexão não se estabilizou no tempo esperado"
  233 + Exit Sub
  234 + End If
  235 +
  236 + Dim text as string
  237 + text = space(2000)
  238 +
  239 + if hllapi_get_screen_at(1,1,text) <> 0 then
  240 + print "Erro ao tentar obter conteudo do terminal"
  241 + Exit Sub
  242 + End If
  243 +
  244 + print text
  245 +
  246 + hllapi_disconnect()
  247 + hllapi_deinit()
  248 +
  249 +End Sub
  250 +
src/core/calls.cc
@@ -76,7 +76,8 @@ @@ -76,7 +76,8 @@
76 hllapi_lasterror = e.what(); 76 hllapi_lasterror = e.what();
77 } 77 }
78 78
79 - return 0; 79 + return HLLAPI_STATUS_SUCCESS;
  80 +
80 } 81 }
81 82
82 HLLAPI_API_CALL hllapi_get_state(void) { 83 HLLAPI_API_CALL hllapi_get_state(void) {
@@ -137,7 +138,7 @@ @@ -137,7 +138,7 @@
137 138
138 } 139 }
139 140
140 - return 0; 141 + return HLLAPI_STATUS_SUCCESS;
141 142
142 } 143 }
143 144
@@ -190,7 +191,7 @@ @@ -190,7 +191,7 @@
190 191
191 host.pfkey((unsigned short) key); 192 host.pfkey((unsigned short) key);
192 193
193 - return 0; 194 + return HLLAPI_STATUS_SUCCESS;
194 195
195 } catch(std::exception &e) { 196 } catch(std::exception &e) {
196 197
@@ -213,7 +214,7 @@ @@ -213,7 +214,7 @@
213 214
214 host.pakey((unsigned short) key); 215 host.pakey((unsigned short) key);
215 216
216 - return 0; 217 + return HLLAPI_STATUS_SUCCESS;
217 218
218 } catch(std::exception &e) { 219 } catch(std::exception &e) {
219 220
@@ -225,87 +226,40 @@ @@ -225,87 +226,40 @@
225 226
226 } 227 }
227 228
228 - /* 229 + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms) {
229 230
230 - HLLAPI_API_CALL hllapi_wait(WORD seconds)  
231 - {  
232 - if(!hllapi_is_connected())  
233 - return HLLAPI_STATUS_DISCONNECTED; 231 + try {
234 232
235 - session::get_default()->wait(seconds); 233 + getSession().setUnlockDelay((unsigned short) ms);
  234 + return HLLAPI_STATUS_SUCCESS;
236 235
237 - return hllapi_get_state();  
238 - } 236 + } catch(std::exception &e) {
239 237
240 - HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text)  
241 - {  
242 - if(!hllapi_is_connected())  
243 - return HLLAPI_STATUS_DISCONNECTED; 238 + hllapi_lasterror = e.what();
244 239
245 - try  
246 - {  
247 - session::get_default()->set_string_at(row,col,text);  
248 - }  
249 - catch(std::exception &e)  
250 - {  
251 - return HLLAPI_STATUS_SYSTEM_ERROR;  
252 } 240 }
253 241
254 - return HLLAPI_STATUS_SUCCESS; 242 + return HLLAPI_STATUS_SYSTEM_ERROR;
255 } 243 }
256 244
257 - HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)  
258 - { 245 + HLLAPI_API_CALL hllapi_set_charset(LPSTR text) {
259 246
260 - if(!hllapi_is_connected())  
261 - return HLLAPI_STATUS_DISCONNECTED;  
262 -  
263 - int rc = HLLAPI_STATUS_SYSTEM_ERROR;  
264 -  
265 - try  
266 - {  
267 - rc = session::get_default()->cmp_string_at(row,col,text);  
268 - }  
269 - catch(std::exception &e)  
270 - {  
271 - return HLLAPI_STATUS_SYSTEM_ERROR;  
272 - } 247 + try {
273 248
274 - return rc;  
275 - } 249 + getSession().setCharSet((const char *) text);
  250 + return HLLAPI_STATUS_SUCCESS;
276 251
277 - HLLAPI_API_CALL hllapi_find_text(LPSTR text)  
278 - {  
279 - if(!hllapi_is_connected())  
280 - return HLLAPI_STATUS_DISCONNECTED;  
281 -  
282 - return (int) session::get_default()->find_string((const char *) text, false);  
283 - }  
284 -  
285 - HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms)  
286 - {  
287 - session::get_default()->set_unlock_delay(ms);  
288 - return 0;  
289 - }  
290 -  
291 - HLLAPI_API_CALL hllapi_set_charset(LPSTR text)  
292 - {  
293 - try  
294 - { 252 + } catch(std::exception &e) {
295 253
296 - session::get_default()->set_display_charset(NULL, (const char *) text); 254 + hllapi_lasterror = e.what();
297 255
298 - }  
299 - catch(std::exception &e)  
300 - {  
301 - return HLLAPI_STATUS_SYSTEM_ERROR;  
302 } 256 }
303 257
304 - return 0; 258 + return HLLAPI_STATUS_SYSTEM_ERROR;
305 } 259 }
306 260
307 - HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir)  
308 - { 261 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) {
  262 +
309 #ifdef _WIN32 263 #ifdef _WIN32
310 HKEY hKey = 0; 264 HKEY hKey = 0;
311 unsigned long datalen = strlen(datadir); 265 unsigned long datalen = strlen(datadir);
@@ -324,332 +278,51 @@ @@ -324,332 +278,51 @@
324 return *datadir; 278 return *datadir;
325 } 279 }
326 280
327 - HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting) 281 + /*
  282 +
  283 + HLLAPI_API_CALL hllapi_wait(WORD seconds)
328 { 284 {
329 if(!hllapi_is_connected()) 285 if(!hllapi_is_connected())
330 return HLLAPI_STATUS_DISCONNECTED; 286 return HLLAPI_STATUS_DISCONNECTED;
331 287
332 - try  
333 - {  
334 - session::get_default()->input_string(buffer);  
335 - }  
336 - catch(std::exception &e)  
337 - {  
338 - return HLLAPI_STATUS_SYSTEM_ERROR;  
339 - } 288 + session::get_default()->wait(seconds);
340 289
341 - return HLLAPI_STATUS_SUCCESS; 290 + return hllapi_get_state();
342 } 291 }
343 292
344 - char * hllapi_get_string(int offset, size_t len) 293 + HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
345 { 294 {
  295 +
  296 + if(!hllapi_is_connected())
  297 + return HLLAPI_STATUS_DISCONNECTED;
  298 +
  299 + int rc = HLLAPI_STATUS_SYSTEM_ERROR;
  300 +
346 try 301 try
347 { 302 {
348 - string str = session::get_default()->get_string(offset-1,len);  
349 - char * ret = strdup(str.c_str());  
350 - return ret; 303 + rc = session::get_default()->cmp_string_at(row,col,text);
351 } 304 }
352 catch(std::exception &e) 305 catch(std::exception &e)
353 { 306 {
  307 + return HLLAPI_STATUS_SYSTEM_ERROR;
354 } 308 }
355 309
356 - return NULL;  
357 - }  
358 -  
359 - void hllapi_free(void *p)  
360 - {  
361 - free(p); 310 + return rc;
362 } 311 }
363 312
364 - HLLAPI_API_CALL hllapi_input_string(LPSTR input, WORD length) 313 + HLLAPI_API_CALL hllapi_find_text(LPSTR text)
365 { 314 {
366 - static const char control_char = '@';  
367 -  
368 - size_t szText;  
369 - char * text;  
370 - int rc = 0;  
371 -  
372 - if(!hllapi_is_connected()) { 315 + if(!hllapi_is_connected())
373 return HLLAPI_STATUS_DISCONNECTED; 316 return HLLAPI_STATUS_DISCONNECTED;
374 - }  
375 -  
376 - if(!input)  
377 - {  
378 - return HLLAPI_STATUS_BAD_PARAMETER;  
379 - }  
380 -  
381 - if(length > 0 )  
382 - szText = length;  
383 - else  
384 - szText = strlen(input);  
385 -  
386 - text = (char *) malloc(szText+2);  
387 - memcpy(text,input,szText);  
388 - text[szText] = 0;  
389 -  
390 - trace("input[%s]",text);  
391 -  
392 - if(strchr(text,control_char))  
393 - {  
394 - // Convert control char  
395 - char * buffer = text;  
396 - char * ptr;  
397 -  
398 - for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))  
399 - {  
400 - *(ptr++) = 0;  
401 -  
402 - trace("input[%s]",buffer);  
403 - hllapi_emulate_input(buffer,-1,0);  
404 -  
405 - switch(*(ptr++))  
406 - {  
407 - case 'P': // Print  
408 - rc = hllapi_print();  
409 - break;  
410 -  
411 - case 'E': // Enter  
412 - hllapi_enter();  
413 - break;  
414 -  
415 - case 'F': // Erase EOF  
416 - hllapi_erase_eof();  
417 - break;  
418 -  
419 - case '1': // PF1  
420 - hllapi_pfkey(1);  
421 - break;  
422 -  
423 - case '2': // PF2  
424 - hllapi_pfkey(2);  
425 - break;  
426 -  
427 - case '3': // PF3  
428 - hllapi_pfkey(3);  
429 - break;  
430 -  
431 - case '4': // PF4  
432 - hllapi_pfkey(4);  
433 - break;  
434 -  
435 - case '5': // PF5  
436 - hllapi_pfkey(5);  
437 - break;  
438 -  
439 - case '6': // PF6  
440 - hllapi_pfkey(6);  
441 - break;  
442 -  
443 - case '7': // PF7  
444 - hllapi_pfkey(7);  
445 - break;  
446 -  
447 - case '8': // PF8  
448 - hllapi_pfkey(8);  
449 - break;  
450 -  
451 - case '9': // PF9  
452 - hllapi_pfkey(9);  
453 - break;  
454 -  
455 - case 'a': // PF10  
456 - hllapi_pfkey(10);  
457 - break;  
458 -  
459 - case 'b': // PF11  
460 - hllapi_pfkey(11);  
461 - break;  
462 -  
463 - case 'c': // PF12  
464 - hllapi_pfkey(12);  
465 - break;  
466 -  
467 - case 'd': // PF13  
468 - hllapi_pfkey(13);  
469 - break;  
470 -  
471 - case 'e': // PF14  
472 - hllapi_pfkey(14);  
473 - break;  
474 -  
475 - case 'f': // PF15  
476 - hllapi_pfkey(15);  
477 - break;  
478 -  
479 - case 'g': // PF16  
480 - hllapi_pfkey(16);  
481 - break;  
482 -  
483 - case 'h': // PF17  
484 - hllapi_pfkey(17);  
485 - break;  
486 -  
487 - case 'i': // PF18  
488 - hllapi_pfkey(18);  
489 - break;  
490 -  
491 - case 'j': // PF19  
492 - hllapi_pfkey(19);  
493 - break;  
494 -  
495 - case 'k': // PF20  
496 - hllapi_pfkey(20);  
497 - break;  
498 -  
499 - case 'l': // PF21  
500 - hllapi_pfkey(21);  
501 - break;  
502 -  
503 - case 'm': // PF22  
504 - hllapi_pfkey(22);  
505 - break;  
506 -  
507 - case 'n': // PF23  
508 - hllapi_pfkey(23);  
509 - break;  
510 -  
511 - case 'o': // PF24  
512 - hllapi_pfkey(24);  
513 - break;  
514 -  
515 - case '@': // Send '@' character  
516 - hllapi_emulate_input((LPSTR) "@",-1,0);  
517 - break;  
518 317
519 - case 'x': // PA1  
520 - hllapi_pakey(1);  
521 - break;  
522 -  
523 - case 'y': // PA2  
524 - hllapi_pakey(2);  
525 - break;  
526 -  
527 - case 'z': // PA3  
528 - hllapi_pakey(3);  
529 - break;  
530 -  
531 - case 'B': // PC_LEFTTAB = "@B"  
532 - break;  
533 -  
534 - case 'T': // PC_RIGHTTAB = "@T"  
535 - break;  
536 -  
537 - case 'N': // PC_NEWLINE = "@N"  
538 - break;  
539 -  
540 - case 'C': // PC_CLEAR = "@C"  
541 - hllapi_erase_input();  
542 - break;  
543 -  
544 - case 'D': // PC_DELETE = "@D"  
545 - break;  
546 -  
547 - case 'H': // PC_HELP = "@H"  
548 - break;  
549 -  
550 - case 'I': // PC_INSERT = "@I"  
551 - break;  
552 -  
553 - case 'L': // PC_CURSORLEFT = "@L"  
554 - break;  
555 -  
556 - case 'R': // PC_RESET = "@R"  
557 - hllapi_reset();  
558 - break;  
559 -  
560 - case 'U': // PC_CURSORUP = "@U"  
561 - break;  
562 -  
563 - case 'V': // PC_CURSORDOWN = "@V"  
564 - break;  
565 -  
566 - case 'Z': // PC_CURSORRIGHT = "@Z"  
567 - break;  
568 -  
569 - case '0': // PC_HOME = "@0"  
570 - break;  
571 -  
572 - case 'p': // PC_PLUSKEY = "@p"  
573 - break;  
574 -  
575 - case 'q': // PC_END = "@q"  
576 - break;  
577 -  
578 - case 's': // PC_SCRLK = "@s"  
579 - break;  
580 -  
581 - case 't': // PC_NUMLOCK = "@t"  
582 - break;  
583 -  
584 - case 'u': // PC_PAGEUP = "@u"  
585 - break;  
586 -  
587 - case 'v': // PC_PAGEDOWN = "@v"  
588 - break;  
589 -  
590 - case '/': // PC_OVERRUNOFQUEUE = "@/" ' Queue overflow, used in Get Key only  
591 - break;  
592 -  
593 - case '$': // PC_ALTCURSOR = "@$" ' Presentation Manager only, unused in VB environment  
594 - break;  
595 -  
596 - case '<': // PC_BACKSPACE = "@<"  
597 - break;  
598 -  
599 -  
600 -// Global Const PC_TEST = "@A@C"  
601 -// Global Const PC_WORDDELETE = "@A@D"  
602 -// Global Const PC_FIELDEXIT = "@A@E"  
603 -// Global Const PC_ERASEINPUT = "@A@F"  
604 -// Global Const PC_SYSTEMREQUEST = "@A@H"  
605 -// Global Const PC_INSERTTOGGLE = "@A@I"  
606 -// Global Const PC_CURSORSELECT = "@A@J"  
607 -// Global Const PC_CURSLEFTFAST = "@A@L"  
608 -// Global Const PC_GETCURSOR = "@A@N"  
609 -// Global Const PC_LOCATECURSOR = "@A@O"  
610 -// Global Const PC_ATTENTION = "@A@Q"  
611 -// Global Const PC_DEVICECANCEL = "@A@R"  
612 -// Global Const PC_PRINTPS = "@A@T"  
613 -// Global Const PC_CURSUPFAST = "@A@U"  
614 -// Global Const PC_CURSDOWNFAST = "@A@V"  
615 -// Global Const PC_HEX = "@A@X"  
616 -// Global Const PC_FUNCTIONKEY = "@A@Y"  
617 -// Global Const PC_CURSRIGHTFAST = "@A@Z"  
618 -  
619 -// Global Const PC_REVERSEVIDEO = "@A@9"  
620 -// Global Const PC_UNDERSCORE = "@A@b"  
621 -// Global Const PC_BLINK = "@A@c"  
622 -// Global Const PC_RED = "@A@d"  
623 -// Global Const PC_PINK = "@A@e"  
624 -// Global Const PC_GREEN = "@A@f"  
625 -// Global Const PC_YELLOW = "@A@g"  
626 -// Global Const PC_BLUE = "@A@h"  
627 -// Global Const PC_TURQOISE = "@A@i"  
628 -// Global Const PC_WHITE = "@A@j"  
629 -// Global Const PC_RSTHOSTCOLORS = "@A@l"  
630 -// Global Const PC_PRINTPC = "@A@t"  
631 -  
632 -// Global Const PC_FIELDMINUS = "@A@-"  
633 -// Global Const PC_FIELDPLUS = "@A@+"  
634 -  
635 - }  
636 -  
637 - buffer = ptr;  
638 -  
639 - }  
640 -  
641 - if(*buffer)  
642 - hllapi_emulate_input(buffer,-1,0);  
643 -  
644 - }  
645 - else  
646 - {  
647 - hllapi_emulate_input(text,szText,0);  
648 - } 318 + return (int) session::get_default()->find_string((const char *) text, false);
  319 + }
649 320
650 - free(text);  
651 321
652 - return rc; 322 + void hllapi_free(void *p)
  323 + {
  324 + free(p);
653 } 325 }
654 326
  327 +
655 */ 328 */
src/core/cursor.cc
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 if(!host.isConnected()) 40 if(!host.isConnected())
41 return HLLAPI_STATUS_DISCONNECTED; 41 return HLLAPI_STATUS_DISCONNECTED;
42 42
43 - host.setCursorPosition((unsigned short) pos -1); 43 + host.setCursor((unsigned short) pos -1);
44 44
45 return 0; 45 return 0;
46 46
@@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
67 if(!host.isConnected()) 67 if(!host.isConnected())
68 return 0; 68 return 0;
69 69
70 - return (DWORD) (host.getCursorPosition()+1); 70 + return (DWORD) (host.getCursorAddress()+1);
71 71
72 } catch(std::exception &e) { 72 } catch(std::exception &e) {
73 73
src/core/get.cc
@@ -90,3 +90,52 @@ @@ -90,3 +90,52 @@
90 90
91 } 91 }
92 92
  93 + HLLAPI_API_CALL hllapi_get_lu_name(LPSTR buffer, WORD len) {
  94 +
  95 + try {
  96 +
  97 + TN3270::Host &host = getSession();
  98 +
  99 + if(!host.isConnected())
  100 + return HLLAPI_STATUS_DISCONNECTED;
  101 +
  102 + if(!(buffer && *buffer))
  103 + return HLLAPI_STATUS_BAD_PARAMETER;
  104 +
  105 +
  106 + if(len == 0)
  107 + return HLLAPI_STATUS_BAD_PARAMETER;
  108 +
  109 + string luname = host.getLUName();
  110 +
  111 + memset(buffer,' ',len);
  112 + strncpy((char *) buffer, luname.c_str(), std::min((size_t) len,luname.size()));
  113 +
  114 + } catch(std::exception &e) {
  115 +
  116 + hllapi_lasterror = e.what();
  117 + return HLLAPI_STATUS_SYSTEM_ERROR;
  118 +
  119 + }
  120 +
  121 + return HLLAPI_STATUS_SUCCESS;
  122 +
  123 + }
  124 +
  125 +
  126 + /*
  127 + char * hllapi_get_string(int offset, size_t len)
  128 + {
  129 + try
  130 + {
  131 + string str = session::get_default()->get_string(offset-1,len);
  132 + char * ret = strdup(str.c_str());
  133 + return ret;
  134 + }
  135 + catch(std::exception &e)
  136 + {
  137 + }
  138 +
  139 + return NULL;
  140 + }
  141 + */
src/core/hllapi.cc
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
27 * 27 *
28 */ 28 */
29 29
  30 + #include "private.h"
30 #include <lib3270/hllapi.h> 31 #include <lib3270/hllapi.h>
31 32
32 /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ 33 /*--[ Prototipes ]-----------------------------------------------------------------------------------*/
@@ -84,21 +85,26 @@ @@ -84,21 +85,26 @@
84 85
85 /*--[ Implement ]------------------------------------------------------------------------------------*/ 86 /*--[ Implement ]------------------------------------------------------------------------------------*/
86 87
87 -/*  
88 -HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)  
89 -{  
90 - unsigned int f; 88 +HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc) {
91 89
92 - trace("%s(%d)",__FUNCTION__,*func); 90 + for(unsigned int f=0;f < (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++) {
  91 +
  92 + if(hllapi_call[f].func == *func) {
  93 +
  94 + try {
  95 +
  96 + return hllapi_call[f].exec(buffer,length,rc);
  97 +
  98 + } catch(std::exception &e) {
  99 +
  100 + hllapi_lasterror = e.what();
  101 + *rc = HLLAPI_STATUS_SYSTEM_ERROR;
  102 + return *rc;
  103 +
  104 + }
93 105
94 - for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++)  
95 - {  
96 - if(hllapi_call[f].func == *func)  
97 - {  
98 - int status = hllapi_call[f].exec(buffer,length,rc);  
99 - trace("hllapi(%d) exits with rc=%d",*func,status);  
100 - return status;  
101 } 106 }
  107 +
102 } 108 }
103 109
104 trace("hllapi(%d) failed",*func); 110 trace("hllapi(%d) failed",*func);
@@ -108,14 +114,13 @@ HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc @@ -108,14 +114,13 @@ HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc
108 114
109 } 115 }
110 116
111 -static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc)  
112 -{ 117 +static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc) {
113 *rc = HLLAPI_STATUS_BAD_PARAMETER; 118 *rc = HLLAPI_STATUS_BAD_PARAMETER;
114 return *rc; 119 return *rc;
115 } 120 }
116 121
117 -static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)  
118 -{ 122 +static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) {
  123 +
119 char *tempbuffer = NULL; 124 char *tempbuffer = NULL;
120 125
121 trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer)); 126 trace("%s: len=%d buflen=%d",__FUNCTION__,*length,(int) strlen(buffer));
@@ -140,64 +145,87 @@ static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) @@ -140,64 +145,87 @@ static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)
140 if(tempbuffer) 145 if(tempbuffer)
141 free(tempbuffer); 146 free(tempbuffer);
142 147
143 - return 0; 148 + return HLLAPI_STATUS_SUCCESS;
  149 +
144 } 150 }
145 151
146 -static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc)  
147 -{ 152 +static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc) {
148 *rc = hllapi_deinit(); 153 *rc = hllapi_deinit();
149 - return 0; 154 + return HLLAPI_STATUS_SUCCESS;
150 } 155 }
151 156
152 -static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc)  
153 -{ 157 +static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc) {
154 *rc = hllapi_get_revision(); 158 *rc = hllapi_get_revision();
155 - return 0; 159 + return HLLAPI_STATUS_SUCCESS;
156 } 160 }
157 161
158 -static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)  
159 -{  
160 - int pos = hllapi_getcursor(); 162 +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) {
  163 +
  164 + try {
  165 +
  166 + TN3270::Host &host = getSession();
  167 +
  168 + if(!host.isConnected())
  169 + return HLLAPI_STATUS_DISCONNECTED;
  170 +
  171 + *rc = (unsigned short) (host.getCursorAddress()+1);
  172 +
  173 + } catch(std::exception &e) {
  174 +
  175 + hllapi_lasterror = e.what();
  176 + return HLLAPI_STATUS_SYSTEM_ERROR;
161 177
162 - trace("%s(%d)",__FUNCTION__,pos); 178 + }
163 179
164 - if(pos < 0)  
165 - return -1; 180 + return HLLAPI_STATUS_SUCCESS;
166 181
167 - *rc = pos;  
168 - return 0;  
169 } 182 }
170 183
171 -static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)  
172 -{  
173 - trace("%s(%d)",__FUNCTION__,*rc);  
174 - *rc = hllapi_setcursor(*rc);  
175 - return 0; 184 +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) {
  185 +
  186 + try {
  187 +
  188 + TN3270::Host &host = getSession();
  189 +
  190 + if(!host.isConnected())
  191 + return HLLAPI_STATUS_DISCONNECTED;
  192 +
  193 + host.setCursor((unsigned short) *rc -1);
  194 +
  195 + return HLLAPI_STATUS_SUCCESS;
  196 +
  197 + } catch(std::exception &e) {
  198 +
  199 + hllapi_lasterror = e.what();
  200 +
  201 + }
  202 +
  203 + return HLLAPI_STATUS_SYSTEM_ERROR;
  204 +
176 } 205 }
177 206
178 -static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc)  
179 -{ 207 +static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc) {
180 208
181 // Length Length of the target data string. 209 // Length Length of the target data string.
182 // PS Position Position within the host presentation space of the first byte in your target data string. 210 // PS Position Position within the host presentation space of the first byte in your target data string.
183 *rc = hllapi_get_screen(*rc,buffer,*length); 211 *rc = hllapi_get_screen(*rc,buffer,*length);
184 212
185 - return 0; 213 + return HLLAPI_STATUS_SUCCESS;
186 } 214 }
187 215
188 -static int input_string(char *buffer, unsigned short *length, unsigned short *rc)  
189 -{ 216 +static int input_string(char *buffer, unsigned short *length, unsigned short *rc) {
190 *rc = hllapi_input_string(buffer,*length); 217 *rc = hllapi_input_string(buffer,*length);
191 - return 0; 218 + return HLLAPI_STATUS_SUCCESS;
192 } 219 }
193 220
194 -static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)  
195 -{ 221 +static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) {
  222 +
196 // 223 //
197 // Data String Target string for search. 224 // Data String Target string for search.
198 // Length Length of the target data string. Overridden in EOT mode. 225 // Length Length of the target data string. Overridden in EOT mode.
199 - // PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end  
200 - // (SRCHBKWD option). Overridden in SRCHALL (default) mode. 226 + //
  227 + // PS Position Position within the host presentation space where the search is to begin (SRCHFRWD option) or to end
  228 + // (SRCHBKWD option). Overridden in SRCHALL (default) mode.
201 // 229 //
202 // Return in *ps: 230 // Return in *ps:
203 // 231 //
@@ -206,65 +234,95 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) @@ -206,65 +234,95 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps)
206 // 234 //
207 // Return code: 235 // Return code:
208 // 236 //
209 - // 0 The Search Presentation Space function was successful.  
210 - // 1 Your program is not connected to a host session.  
211 - // 2 An error was made in specifying parameters.  
212 - // 7 The host presentation space position is not valid.  
213 - // 9 A system error was encountered.  
214 - // 24 The search string was not found. 237 + // 0 HLLAPI_STATUS_SUCCESS The Search Presentation Space function was successful.
  238 + // 1 HLLAPI_STATUS_DISCONNECTED Your program is not connected to a host session.
  239 + // 2 HLLAPI_STATUS_BAD_PARAMETER An error was made in specifying parameters.
  240 + // 7 HLLAPI_STATUS_BAD_POSITION The host presentation space position is not valid.
  241 + // 9 HLLAPI_STATUS_SYSTEM_ERROR A system error was encountered.
  242 + // 24 HLLAPI_STATUS_NOT_FOUND The search string was not found.
215 // 243 //
216 // 244 //
217 - size_t szBuffer = strlen(buffer);  
218 - char * text;  
219 - int rc = HLLAPI_STATUS_SYSTEM_ERROR;  
220 245
221 - if(!hllapi_is_connected())  
222 - return HLLAPI_STATUS_DISCONNECTED; 246 + try {
223 247
224 - if(*length < szBuffer)  
225 - szBuffer = *length; 248 + TN3270::Host &host = getSession();
226 249
  250 + if(!host.isConnected())
  251 + return HLLAPI_STATUS_DISCONNECTED;
227 252
228 - text = hllapi_get_string(*ps,szBuffer);  
229 - if(!text)  
230 - return HLLAPI_STATUS_SYSTEM_ERROR; 253 + string contents = host.toString(0,-1,0);
  254 +
  255 + if( ((size_t) *ps) >= contents.size())
  256 + return HLLAPI_STATUS_BAD_POSITION;
  257 +
  258 + size_t pos = contents.find(buffer, ((size_t) *ps));
  259 +
  260 + if(pos == string::npos) {
  261 + *ps = 0;
  262 + return HLLAPI_STATUS_NOT_FOUND;
  263 + }
  264 +
  265 + *ps = pos;
  266 +
  267 + return HLLAPI_STATUS_SUCCESS;
  268 +
  269 + } catch(std::exception &e) {
  270 +
  271 + hllapi_lasterror = e.what();
231 272
232 - if(strncmp(text,buffer,szBuffer))  
233 - {  
234 - // String not found  
235 - *ps = 0;  
236 - rc = HLLAPI_STATUS_NOT_FOUND;  
237 - }  
238 - else  
239 - {  
240 - // String found  
241 - *ps = 1;  
242 - rc = HLLAPI_STATUS_SUCCESS;  
243 } 273 }
244 274
245 - hllapi_free(text); 275 + return HLLAPI_STATUS_SYSTEM_ERROR;
246 276
247 - return rc;  
248 } 277 }
249 278
250 -static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)  
251 -{ 279 +static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) {
  280 +
252 // 281 //
253 - // Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be at least twice the length of the presentation space.  
254 - // DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times the length of the presentation space. 282 + // Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space
  283 + // is configured. When the Set Session Parameters (9) function with the EAB option is issued, the length of the data string must be
  284 + // at least twice the length of the presentation space.
  285 + // DBCS Only: When the EAD option is specified, the length of the data string must be at least three times the length of the
  286 + // presentation space. When both the EAB and EAD options are specified, the length of the data string must be at least four times
  287 + // the length of the presentation space.
255 // 288 //
256 // Length NA (the length of the host presentation space is implied). 289 // Length NA (the length of the host presentation space is implied).
257 // PS Position NA. 290 // PS Position NA.
258 // 291 //
259 // Return values: 292 // Return values:
260 // 293 //
261 - // 0 The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.  
262 - // 1 Your program is not connected to a host session.  
263 - // 4 The host presentation space contents were copied. The connected host presentation space was waiting for host response.  
264 - // 5 The host presentation space was copied. The keyboard was locked.  
265 - // 9 A system error was encountered. 294 + // 0 HLLAPI_STATUS_SUCCESS The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.
  295 + // 1 HLLAPI_STATUS_DISCONNECTED Your program is not connected to a host session.
  296 + // 4 HLLAPI_STATUS_TIMEOUT The host presentation space contents were copied. The connected host presentation space was waiting for host response.
  297 + // 5 HLLAPI_STATUS_KEYBOARD_LOCKED The host presentation space was copied. The keyboard was locked.
  298 + // 9 HLLAPI_STATUS_SYSTEM_ERROR A system error was encountered.
266 // 299 //
267 // 300 //
  301 + try {
  302 +
  303 + TN3270::Host &host = getSession();
  304 +
  305 + if(!host.isConnected())
  306 + return HLLAPI_STATUS_DISCONNECTED;
  307 +
  308 + string contents = host.toString(0,-1,0);
  309 +
  310 + size_t szBuffer = std::min(contents.size(), ((size_t) *length));
  311 + *length = (unsigned short) szBuffer;
  312 +
  313 + strncpy(buffer,contents.c_str(),szBuffer);
  314 +
  315 + return hllapi_get_state();
  316 +
  317 + } catch(std::exception &e) {
  318 +
  319 + hllapi_lasterror = e.what();
  320 +
  321 + }
  322 +
  323 + return HLLAPI_STATUS_SYSTEM_ERROR;
  324 +
  325 + /*
268 size_t szBuffer = strlen(buffer); 326 size_t szBuffer = strlen(buffer);
269 char * text; 327 char * text;
270 328
@@ -281,10 +339,13 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) @@ -281,10 +339,13 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc)
281 hllapi_free(text); 339 hllapi_free(text);
282 340
283 return hllapi_get_state(); 341 return hllapi_get_state();
  342 + */
  343 +
  344 + return HLLAPI_STATUS_SYSTEM_ERROR;
284 } 345 }
285 346
286 -static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)  
287 -{ 347 +static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) {
  348 +
288 // 349 //
289 // Checks the status of the host-connected presentation space. If the session is 350 // Checks the status of the host-connected presentation space. If the session is
290 // waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait 351 // waiting for a host response (indicated by XCLOCK (X []) or XSYSTEM), the Wait
@@ -303,13 +364,13 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) @@ -303,13 +364,13 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
303 // 364 //
304 // 365 //
305 366
306 - int state = hllapi_wait_for_ready(60);  
307 - return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); 367 + int state = hllapi_wait_for_ready(60);
  368 + return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);
308 369
309 } 370 }
310 371
311 -static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps)  
312 -{ 372 +static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps) {
  373 + /*
313 // 374 //
314 // Call Parameters 375 // Call Parameters
315 // 376 //
@@ -357,16 +418,17 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps @@ -357,16 +418,17 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps
357 } 418 }
358 419
359 return hllapi_emulate_input(text,szText,0); 420 return hllapi_emulate_input(text,szText,0);
  421 + */
360 } 422 }
361 423
362 -static int reset_system(char *buffer, unsigned short *length, unsigned short *rc)  
363 -{  
364 - return hllapi_reset(); 424 +static int reset_system(char *buffer, unsigned short *length, unsigned short *rc) {
  425 + return hllapi_kybdreset();
365 } 426 }
366 427
367 428
368 -static int pause_system(char *buffer, unsigned short *length, unsigned short *rc)  
369 -{ 429 +static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) {
  430 +
  431 + /*
370 if(!*length) 432 if(!*length)
371 { 433 {
372 // If you use the IPAUSE option and the pause value is zero, then the function 434 // If you use the IPAUSE option and the pause value is zero, then the function
@@ -392,6 +454,7 @@ static int pause_system(char *buffer, unsigned short *length, unsigned short *rc @@ -392,6 +454,7 @@ static int pause_system(char *buffer, unsigned short *length, unsigned short *rc
392 // #warning Mudar comportamento na lib! 454 // #warning Mudar comportamento na lib!
393 455
394 return hllapi_wait_for_ready((*length) / 2); 456 return hllapi_wait_for_ready((*length) / 2);
  457 + */
395 } 458 }
396 459
397 static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc) 460 static int set_session_parameters(char *buffer, unsigned short *length, unsigned short *rc)
@@ -403,41 +466,38 @@ static int set_session_parameters(char *buffer, unsigned short *length, unsigned @@ -403,41 +466,38 @@ static int set_session_parameters(char *buffer, unsigned short *length, unsigned
403 466
404 *rc = hllapi_set_session_parameter(buffer, *length, *rc); 467 *rc = hllapi_set_session_parameter(buffer, *length, *rc);
405 468
406 - return 0; 469 + return HLLAPI_STATUS_SUCCESS;
407 } 470 }
408 471
409 HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value) 472 HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value)
410 { 473 {
411 if(!param) 474 if(!param)
412 - {  
413 return HLLAPI_STATUS_BAD_PARAMETER; 475 return HLLAPI_STATUS_BAD_PARAMETER;
414 - }  
415 476
416 if(!len) 477 if(!len)
417 - {  
418 len = strlen(param); 478 len = strlen(param);
419 - }  
420 479
421 - if(!strncasecmp(param,"IPAUSE",len))  
422 - { 480 + if(!strncasecmp(param,"IPAUSE",len)) {
  481 +
423 // IPAUSE 482 // IPAUSE
424 pause_mode = PAUSE_MODE_IPAUSE; 483 pause_mode = PAUSE_MODE_IPAUSE;
425 - }  
426 - else if(!strncasecmp(param,"FPAUSE",len))  
427 - { 484 +
  485 + } else if(!strncasecmp(param,"FPAUSE",len)) {
  486 +
428 // FPAUSE 487 // FPAUSE
429 pause_mode = PAUSE_MODE_FPAUSE; 488 pause_mode = PAUSE_MODE_FPAUSE;
430 - }  
431 - else if(!strncasecmp(param,"UNLOCKDELAY",len))  
432 - { 489 +
  490 + } else if(!strncasecmp(param,"UNLOCKDELAY",len)) {
  491 +
433 // UNLOCKDELAY 492 // UNLOCKDELAY
434 hllapi_set_unlock_delay(value); 493 hllapi_set_unlock_delay(value);
435 - }  
436 - else  
437 - { 494 +
  495 + } else {
  496 +
438 return HLLAPI_STATUS_BAD_PARAMETER; 497 return HLLAPI_STATUS_BAD_PARAMETER;
  498 +
439 } 499 }
440 500
441 return HLLAPI_STATUS_SUCCESS; 501 return HLLAPI_STATUS_SUCCESS;
442 } 502 }
443 -*/ 503 +
src/core/set.cc 0 → 100644
@@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
  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 - 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 + #include "private.h"
  31 +
  32 + #include <string>
  33 +
  34 +
  35 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  36 +
  37 + HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text) {
  38 +
  39 + try {
  40 +
  41 + TN3270::Host &host = getSession();
  42 +
  43 + if(!host.isConnected())
  44 + return HLLAPI_STATUS_DISCONNECTED;
  45 +
  46 + if(!(text && *text))
  47 + return HLLAPI_STATUS_BAD_PARAMETER;
  48 +
  49 + host.push(row,col,(const char *) text);
  50 +
  51 +
  52 + } catch(std::exception &e) {
  53 +
  54 + hllapi_lasterror = e.what();
  55 + return HLLAPI_STATUS_SYSTEM_ERROR;
  56 +
  57 + }
  58 +
  59 + return HLLAPI_STATUS_SUCCESS;
  60 +
  61 + }
  62 +
  63 + HLLAPI_API_CALL hllapi_input_string(LPSTR text, WORD length)
  64 + {
  65 +
  66 + try {
  67 +
  68 + TN3270::Host &host = getSession();
  69 +
  70 + if(!host.isConnected())
  71 + return HLLAPI_STATUS_DISCONNECTED;
  72 +
  73 + if(!(text && *text))
  74 + return HLLAPI_STATUS_BAD_PARAMETER;
  75 +
  76 + if(!length)
  77 + length = strlen(text);
  78 +
  79 + host.input((const char *) text, (size_t) length);
  80 +
  81 + } catch(std::exception &e) {
  82 +
  83 + hllapi_lasterror = e.what();
  84 + return HLLAPI_STATUS_SYSTEM_ERROR;
  85 +
  86 + }
  87 +
  88 + return HLLAPI_STATUS_SUCCESS;
  89 +
  90 +
  91 + }
  92 +
  93 +
  94 +
  95 + /*
  96 + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting)
  97 + {
  98 + if(!hllapi_is_connected())
  99 + return HLLAPI_STATUS_DISCONNECTED;
  100 +
  101 + try
  102 + {
  103 + session::get_default()->input_string(buffer);
  104 + }
  105 + catch(std::exception &e)
  106 + {
  107 + return HLLAPI_STATUS_SYSTEM_ERROR;
  108 + }
  109 +
  110 + return HLLAPI_STATUS_SUCCESS;
  111 + }
  112 +
  113 +
  114 + */
src/include/lib3270/hllapi.h
@@ -27,142 +27,149 @@ @@ -27,142 +27,149 @@
27 * 27 *
28 */ 28 */
29 29
30 - #ifdef __cplusplus  
31 - extern "C" {  
32 - #endif  
33 -  
34 - #define HLLAPI_MAXLENGTH 4096  
35 -  
36 - /**  
37 - * @brief Function codes  
38 - *  
39 - * Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm  
40 - *  
41 - */  
42 - typedef enum hllapi_cmd {  
43 - HLLAPI_CMD_CONNECTPS = 1, /// @brief connect presentation space  
44 - HLLAPI_CMD_DISCONNECTPS = 2, /// @brief disconnect presentation space  
45 - HLLAPI_CMD_INPUTSTRING = 3, /// @brief send string  
46 - HLLAPI_CMD_WAIT = 4, /// @brief Wait if the session is waiting for a host response  
47 - HLLAPI_CMD_COPYPS = 5, /// @brief Copies the contents of the presentation space into a string buffer.  
48 - HLLAPI_CMD_SEARCHPS = 6, /// @brief Search the presentation space for a specified string.  
49 - HLLAPI_CMD_QUERYCURSOR = 7, /// @brief Determines the location of the cursor in the presentation space.  
50 - HLLAPI_CMD_COPYPSTOSTR = 8, /// @brief Copy presentation space to string  
51 - HLLAPI_SET_SESSION_PARAMETERS = 9, /// @brief Lets you change certain default session options in EHLLAPI for all sessions.  
52 - HLLAPI_CMD_COPYSTRTOPS = 15, /// @brief Copies an ASCII string directly to a specified position in the presentation space.  
53 - HLLAPI_CMD_PAUSE = 18, /// @brief Waits for a specified amount of time.  
54 - HLLAPI_RESET_SYSTEM = 21, /// @brief Reinitializes EHLLAPI to its starting state.  
55 - HLLAPI_CMD_SETCURSOR = 40, /// @brief Places the cursor at a specified position in presentation space.  
56 - HLLAPI_CMD_SENDFILE = 90, /// @brief Send file to the host  
57 - HLLAPI_CMD_RECEIVEFILE = 91, /// @brief Receive a file from the host  
58 -  
59 - HLLAPI_CMD_GETREVISION = 2000 /// @brief Get lib3270 revision  
60 - } HLLAPI_CMD;  
61 -  
62 -  
63 - /**  
64 - * @brief Standard Return Codes  
65 - *  
66 - * http://ps-2.kev009.com/tl/techlib/manuals/adoclib/3270hcon/hconugd/retrncod.htm#C20819C058kmar  
67 - */  
68 - typedef enum hllapi_status {  
69 -  
70 - /// @brief Good return code.  
71 - ///  
72 - /// Either the function was successfully executed, or there were no host updates since the last call was issued.  
73 - HLLAPI_STATUS_SUCCESS = 0,  
74 -  
75 - /// @brief The presentation space was not valid or not connected.  
76 - ///  
77 - /// Either the presentation space short session ID was invalid, or the application is not connected.  
78 - HLLAPI_STATUS_DISCONNECTED = 1,  
79 -  
80 - /// @brief An incorrect option was specified.  
81 - HLLAPI_STATUS_BAD_PARAMETER = 2,  
82 -  
83 - /// @brief The execution of the function was inhibited because the target presentation space was busy.  
84 - ///  
85 - /// For example, X or XSYSTEM is displayed in the OIA for the 3270 terminal emulation.  
86 - HLLAPI_STATUS_TIMEOUT = 4,  
87 -  
88 - /// @brief The execution of the function was inhibited for some reason other than the reasons stated in return code 4.  
89 - HLLAPI_STATUS_KEYBOARD_LOCKED = 5,  
90 -  
91 - // 06 A data error occurred due to specification of an invalid parameter (for example, a length error causing truncation).  
92 - // 07 The specified presentation space position was invalid.  
93 - // 08 No prerequisite function was issued.  
94 -  
95 - /// @brief A system error occurred.  
96 - HLLAPI_STATUS_SYSTEM_ERROR = 9,  
97 -  
98 - /// @brief The function number is not supported by the emulation program.  
99 - HLLAPI_STATUS_UNSUPPORTED = 10,  
100 -  
101 - /// @brief Resource unavailable at this time.  
102 - ///  
103 - /// The resource that you requested is unavailable (for example, too many attempts have been made to connect to the same presentation space (PS) or another application is connected to the PS).  
104 - HLLAPI_STATUS_UNAVAILABLE = 11,  
105 -  
106 - // 20 Invalid keystroke caused by ESC= option.  
107 - // 21 OIA was updated.  
108 - // 22 PS was updated.  
109 - // 23 Both OIA and PS were updated.  
110 -  
111 - /// @brief Either the string was not found, or the presentation space is unformatted.  
112 - HLLAPI_STATUS_NOT_FOUND = 24,  
113 -  
114 - // 25 Keystrokes were not available on input queue.  
115 - // 26 A host event occurred. See QUERY HOST UPDATE (24) for details.  
116 - // 28 Field length was 0.  
117 - // 31 Keystroke queue overflow. Keystrokes were lost.  
118 -  
119 - } HLLAPI_STATUS;  
120 -  
121 - #define HLLAPI_STATUS_WAITING HLLAPI_STATUS_TIMEOUT  
122 -  
123 - #if defined(_WIN32)  
124 -  
125 - #include <windows.h>  
126 -  
127 - // http://www.mingw.org/wiki/Visual_Basic_DLL  
128 - #define HLLAPI_API_CALL __declspec (dllexport) DWORD __stdcall  
129 - #define HLLAPI_API_CSTR __declspec (dllexport) const char * __stdcall  
130 -  
131 - #else  
132 -  
133 - #include <cstdint>  
134 -  
135 - // From wtypesbase.h  
136 - typedef uint8_t BYTE;  
137 - typedef uint16_t WORD;  
138 - typedef unsigned int UINT;  
139 - typedef int INT;  
140 - typedef uint32_t LONG;  
141 - typedef LONG WINBOOL;  
142 - typedef uint32_t DWORD;  
143 - typedef void *HANDLE;  
144 - typedef WORD *LPWORD;  
145 - typedef DWORD *LPDWORD;  
146 - typedef char CHAR;  
147 - typedef CHAR *LPSTR;  
148 - typedef const CHAR *LPCSTR;  
149 - typedef char WCHAR;  
150 - typedef WCHAR TCHAR;  
151 - typedef WCHAR *LPWSTR;  
152 - typedef TCHAR *LPTSTR;  
153 - typedef const WCHAR *LPCWSTR;  
154 - typedef const TCHAR *LPCTSTR;  
155 - typedef HANDLE *LPHANDLE; 30 +#ifndef HLLAPI_H_INCLUDED
156 31
157 - #define LPWORD uint16_t * 32 + #define HLLAPI_H_INCLUDED 1
158 33
159 - #define LPSTR char *  
160 - #define HANDLE int 34 + #ifdef __cplusplus
  35 + extern "C" {
  36 + #endif
161 37
162 - #define HLLAPI_API_CALL __attribute__((visibility("default"))) extern DWORD  
163 - #define HLLAPI_API_CSTR __attribute__((visibility("default"))) extern const char * 38 + #define HLLAPI_MAXLENGTH 4096
164 39
165 - #endif // _WIN32 40 + /**
  41 + * @brief Function codes
  42 + *
  43 + * Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm
  44 + *
  45 + */
  46 + typedef enum hllapi_cmd {
  47 + HLLAPI_CMD_CONNECTPS = 1, /// @brief connect presentation space
  48 + HLLAPI_CMD_DISCONNECTPS = 2, /// @brief disconnect presentation space
  49 + HLLAPI_CMD_INPUTSTRING = 3, /// @brief send string
  50 + HLLAPI_CMD_WAIT = 4, /// @brief Wait if the session is waiting for a host response
  51 + HLLAPI_CMD_COPYPS = 5, /// @brief Copies the contents of the presentation space into a string buffer.
  52 + HLLAPI_CMD_SEARCHPS = 6, /// @brief Search the presentation space for a specified string.
  53 + HLLAPI_CMD_QUERYCURSOR = 7, /// @brief Determines the location of the cursor in the presentation space.
  54 + HLLAPI_CMD_COPYPSTOSTR = 8, /// @brief Copy presentation space to string
  55 + HLLAPI_SET_SESSION_PARAMETERS = 9, /// @brief Lets you change certain default session options in EHLLAPI for all sessions.
  56 + HLLAPI_CMD_COPYSTRTOPS = 15, /// @brief Copies an ASCII string directly to a specified position in the presentation space.
  57 + HLLAPI_CMD_PAUSE = 18, /// @brief Waits for a specified amount of time.
  58 + HLLAPI_RESET_SYSTEM = 21, /// @brief Reinitializes EHLLAPI to its starting state.
  59 + HLLAPI_CMD_SETCURSOR = 40, /// @brief Places the cursor at a specified position in presentation space.
  60 + HLLAPI_CMD_SENDFILE = 90, /// @brief Send file to the host
  61 + HLLAPI_CMD_RECEIVEFILE = 91, /// @brief Receive a file from the host
  62 +
  63 + HLLAPI_CMD_GETREVISION = 2000 /// @brief Get lib3270 revision
  64 + } HLLAPI_CMD;
  65 +
  66 +
  67 + /**
  68 + * @brief Standard Return Codes
  69 + *
  70 + * http://ps-2.kev009.com/tl/techlib/manuals/adoclib/3270hcon/hconugd/retrncod.htm#C20819C058kmar
  71 + */
  72 + typedef enum hllapi_status {
  73 +
  74 + /// @brief Good return code.
  75 + ///
  76 + /// Either the function was successfully executed, or there were no host updates since the last call was issued.
  77 + HLLAPI_STATUS_SUCCESS = 0,
  78 +
  79 + /// @brief The presentation space was not valid or not connected.
  80 + ///
  81 + /// Either the presentation space short session ID was invalid, or the application is not connected.
  82 + HLLAPI_STATUS_DISCONNECTED = 1,
  83 +
  84 + /// @brief An incorrect option was specified.
  85 + HLLAPI_STATUS_BAD_PARAMETER = 2,
  86 +
  87 + /// @brief The execution of the function was inhibited because the target presentation space was busy.
  88 + ///
  89 + /// For example, X or XSYSTEM is displayed in the OIA for the 3270 terminal emulation.
  90 + HLLAPI_STATUS_TIMEOUT = 4,
  91 +
  92 + /// @brief The execution of the function was inhibited for some reason other than the reasons stated in return code 4.
  93 + HLLAPI_STATUS_KEYBOARD_LOCKED = 5,
  94 +
  95 + // 06 A data error occurred due to specification of an invalid parameter (for example, a length error causing truncation).
  96 +
  97 + /// @brief The specified presentation space position was invalid.
  98 + HLLAPI_STATUS_BAD_POSITION = 7,
  99 +
  100 + // 08 No prerequisite function was issued.
  101 +
  102 + /// @brief A system error occurred.
  103 + HLLAPI_STATUS_SYSTEM_ERROR = 9,
  104 +
  105 + /// @brief The function number is not supported by the emulation program.
  106 + HLLAPI_STATUS_UNSUPPORTED = 10,
  107 +
  108 + /// @brief Resource unavailable at this time.
  109 + ///
  110 + /// The resource that you requested is unavailable (for example, too many attempts have been made to connect to the same presentation space (PS) or another application is connected to the PS).
  111 + HLLAPI_STATUS_UNAVAILABLE = 11,
  112 +
  113 + // 20 Invalid keystroke caused by ESC= option.
  114 + // 21 OIA was updated.
  115 + // 22 PS was updated.
  116 + // 23 Both OIA and PS were updated.
  117 +
  118 + /// @brief Either the string was not found, or the presentation space is unformatted.
  119 + HLLAPI_STATUS_NOT_FOUND = 24,
  120 +
  121 + // 25 Keystrokes were not available on input queue.
  122 + // 26 A host event occurred. See QUERY HOST UPDATE (24) for details.
  123 + // 28 Field length was 0.
  124 + // 31 Keystroke queue overflow. Keystrokes were lost.
  125 +
  126 + } HLLAPI_STATUS;
  127 +
  128 + #define HLLAPI_STATUS_WAITING HLLAPI_STATUS_TIMEOUT
  129 +
  130 + #if defined(_WIN32)
  131 +
  132 + #include <windows.h>
  133 +
  134 + // http://www.mingw.org/wiki/Visual_Basic_DLL
  135 + #define HLLAPI_API_CALL __declspec (dllexport) DWORD __stdcall
  136 + #define HLLAPI_API_CSTR __declspec (dllexport) const char * __stdcall
  137 +
  138 + #else
  139 +
  140 + #include <cstdint>
  141 +
  142 + // From wtypesbase.h
  143 + typedef uint8_t BYTE;
  144 + typedef uint16_t WORD;
  145 + typedef unsigned int UINT;
  146 + typedef int INT;
  147 + typedef uint32_t LONG;
  148 + typedef LONG WINBOOL;
  149 + typedef uint32_t DWORD;
  150 + typedef void *HANDLE;
  151 + typedef WORD *LPWORD;
  152 + typedef DWORD *LPDWORD;
  153 + typedef char CHAR;
  154 + typedef CHAR *LPSTR;
  155 + typedef const CHAR *LPCSTR;
  156 + typedef char WCHAR;
  157 + typedef WCHAR TCHAR;
  158 + typedef WCHAR *LPWSTR;
  159 + typedef TCHAR *LPTSTR;
  160 + typedef const WCHAR *LPCWSTR;
  161 + typedef const TCHAR *LPCTSTR;
  162 + typedef HANDLE *LPHANDLE;
  163 +
  164 + #define LPWORD uint16_t *
  165 +
  166 + #define LPSTR char *
  167 + #define HANDLE int
  168 +
  169 + #define HLLAPI_API_CALL __attribute__((visibility("default"))) extern DWORD
  170 + #define HLLAPI_API_CSTR __attribute__((visibility("default"))) extern const char *
  171 +
  172 + #endif // _WIN32
166 173
167 HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc); 174 HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
168 175
@@ -196,15 +203,15 @@ @@ -196,15 +203,15 @@
196 HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text); 203 HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
197 HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text); 204 HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
198 HLLAPI_API_CALL hllapi_find_text(LPSTR text); 205 HLLAPI_API_CALL hllapi_find_text(LPSTR text);
199 - HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting);  
200 - HLLAPI_API_CALL hllapi_input_string(LPSTR buffer, WORD len); 206 + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting);
  207 + HLLAPI_API_CALL hllapi_input_string(LPSTR buffer, WORD len);
201 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds); 208 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
202 HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds); 209 HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds);
203 HLLAPI_API_CALL hllapi_wait(WORD seconds); 210 HLLAPI_API_CALL hllapi_wait(WORD seconds);
204 HLLAPI_API_CALL hllapi_pfkey(WORD key); 211 HLLAPI_API_CALL hllapi_pfkey(WORD key);
205 HLLAPI_API_CALL hllapi_pakey(WORD key); 212 HLLAPI_API_CALL hllapi_pakey(WORD key);
206 213
207 - HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value); 214 + HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value);
208 215
209 HLLAPI_API_CALL hllapi_erase(void); 216 HLLAPI_API_CALL hllapi_erase(void);
210 HLLAPI_API_CALL hllapi_erase_eof(void); 217 HLLAPI_API_CALL hllapi_erase_eof(void);
@@ -220,8 +227,25 @@ @@ -220,8 +227,25 @@
220 227
221 HLLAPI_API_CSTR hllapi_get_last_error(); 228 HLLAPI_API_CSTR hllapi_get_last_error();
222 229
223 - #ifdef __cplusplus  
224 - } /* end of extern "C" */  
225 - #endif 230 + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms);
  231 +
  232 + /**
  233 + * @brief Get cursor address.
  234 + *
  235 + * @return Cursor address.
  236 + *
  237 + */
  238 + HLLAPI_API_CALL hllapi_get_cursor_address();
  239 +
  240 + /**
  241 + * @brief Get LU Name.
  242 + *
  243 + */
  244 + HLLAPI_API_CALL hllapi_get_lu_name(LPSTR buffer, WORD len);
  245 +
  246 + #ifdef __cplusplus
  247 + } /* end of extern "C" */
  248 + #endif
226 249
227 250
  251 +#endif // HLLAPI_H_INCLUDED