diff --git a/lib3270.cbp b/lib3270.cbp
index 49022e0..c120b40 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -176,6 +176,9 @@
+
+
+
diff --git a/src/core/iocalls.c b/src/core/iocalls.c
index a2088de..4e64eb0 100644
--- a/src/core/iocalls.c
+++ b/src/core/iocalls.c
@@ -473,40 +473,6 @@ LIB3270_EXPORT int lib3270_wait(H3270 *hSession, int seconds)
return 0;
}
-LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds)
-{
- return errno = ENOTSUP;
-}
-
-LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
-{
- time_t end = time(0)+seconds;
-
- FAIL_IF_NOT_ONLINE(hSession);
-
- event_dispatcher(hSession,0);
-
- // Keyboard is locked by operator error, fails!
- if(hSession->kybdlock && KYBDLOCK_IS_OERR(hSession))
- return -1;
-
- do
- {
- if(!lib3270_lock_status(hSession))
- return 0;
-
- if(!lib3270_connected(hSession))
- return ENOTCONN;
-
- event_dispatcher(hSession,1);
-
- }
- while(time(0) < end);
-
- return ETIMEDOUT;
-}
-
-
LIB3270_EXPORT void lib3270_ring_bell(H3270 *session)
{
CHECK_SESSION_HANDLE(session);
diff --git a/src/core/wait.c b/src/core/wait.c
new file mode 100644
index 0000000..2632793
--- /dev/null
+++ b/src/core/wait.c
@@ -0,0 +1,109 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
+ * St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Este programa está nomeado como - e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+#include
+#include
+#include
+#include "kybdc.h"
+
+/*---[ Implement ]------------------------------------------------------------------------------------------*/
+
+LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds)
+{
+ return errno = ENOTSUP;
+}
+
+LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
+{
+ time_t end = time(0)+seconds;
+
+ FAIL_IF_NOT_ONLINE(hSession);
+
+ lib3270_main_iterate(hSession,0);
+
+ // Keyboard is locked by operator error, fails!
+ if(hSession->kybdlock && KYBDLOCK_IS_OERR(hSession))
+ return errno = EPERM;
+
+ do
+ {
+ if(!lib3270_lock_status(hSession))
+ return 0;
+
+ if(!lib3270_connected(hSession))
+ return errno = ENOTCONN;
+
+ lib3270_main_iterate(hSession,1);
+
+ }
+ while(time(0) < end);
+
+ return errno = ETIMEDOUT;
+}
+
+int lib3270_wait_for_string_at_address(H3270 *hSession, int baddr, const char *key, int seconds)
+{
+ time_t end = time(0)+seconds;
+
+ FAIL_IF_NOT_ONLINE(hSession);
+
+ lib3270_main_iterate(hSession,0);
+
+ if(baddr < 0)
+ baddr = lib3270_get_cursor_address(hSession);
+
+ do
+ {
+ // Keyboard is locked by operator error, fails!
+ if(hSession->kybdlock && KYBDLOCK_IS_OERR(hSession))
+ return errno = EPERM;
+
+ if(!lib3270_connected(hSession))
+ return errno = ENOTCONN;
+
+ if(lib3270_cmp_text_at_address(hSession, baddr, key, 0) == 0)
+ return 0;
+
+ lib3270_main_iterate(hSession,1);
+
+ }
+ while(time(0) < end);
+
+ return errno = ETIMEDOUT;
+
+}
+
+int lib3270_wait_for_string_at(H3270 *hSession, unsigned int row, unsigned int col, const char *key, int seconds)
+{
+ int baddr = lib3270_translate_to_address(hSession,row,col);
+ if(baddr < 0)
+ return errno;
+
+ return lib3270_wait_for_string_at_address(hSession,baddr,key,seconds);
+}
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index 842d163..060093b 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -1137,6 +1137,7 @@
*/
LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, unsigned int row, unsigned int col, const char *text, char lf);
+ LIB3270_EXPORT int lib3270_cmp_text_at_address(H3270 *h, int baddr, const char *text, char lf);
/**
* @brief Get contents of the field at position.
@@ -1479,6 +1480,43 @@
LIB3270_EXPORT void lib3270_set_session_id(H3270 *hSession, char id);
LIB3270_EXPORT char lib3270_get_session_id(H3270 *hSession);
+ /**
+ * @brief Wait for string at position.
+ *
+ * @param hSession TN3270 Session.
+ * @param row Row inside the screen.
+ * @param col Col inside the screen.
+ * @param key The string to wait for.
+ * @param seconds Maximum wait time.
+ *
+ * @return 0 if the string was found, error code if not (sets errno).
+ *
+ * @retval ENOTCONN Not connected to host.
+ * @retval EOVERFLOW Invalid position.
+ * @retval ETIMEDOUT Timeout.
+ * @retval EPERM The keyboard is locked.
+ *
+ */
+ LIB3270_EXPORT int lib3270_wait_for_string_at(H3270 *hSession, unsigned int row, unsigned int col, const char *key, int seconds);
+
+ /**
+ * @brief Wait for string at addrress.
+ *
+ * @param hSession TN3270 Session.
+ * @param baddr Start position (-1 to current cursor position).
+ * @param key The string to wait for.
+ * @param seconds Maximum wait time.
+ *
+ * @return 0 if the string was found, error code if not (sets errno).
+ *
+ * @retval ENOTCONN Not connected to host.
+ * @retval EOVERFLOW Invalid position.
+ * @retval ETIMEDOUT Timeout.
+ * @retval EPERM The keyboard is locked.
+ *
+ */
+ LIB3270_EXPORT int lib3270_wait_for_string_at_address(H3270 *hSession, int baddr, const char *key, int seconds);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/selection/selection.c b/src/selection/selection.c
index ed51c05..6285311 100644
--- a/src/selection/selection.c
+++ b/src/selection/selection.c
@@ -347,14 +347,19 @@ LIB3270_EXPORT char * lib3270_get_string_at(H3270 *h, unsigned int row, unsigned
LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, unsigned int row, unsigned int col, const char *text, char lf)
{
- int rc;
- size_t sz = strlen(text);
- char * contents;
-
int baddr = lib3270_translate_to_address(h,row,col);
if(baddr < 0)
return -1;
+ return lib3270_cmp_text_at_address(h,baddr,text,lf);
+}
+
+ LIB3270_EXPORT int lib3270_cmp_text_at_address(H3270 *h, int baddr, const char *text, char lf)
+ {
+ int rc;
+ size_t sz = strlen(text);
+ char * contents;
+
contents = lib3270_get_string_at_address(h,baddr,sz,lf);
if(!contents)
return -1;
@@ -364,7 +369,7 @@ LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, unsigned int row, unsigned int
lib3270_free(contents);
return rc;
-}
+ }
/**
--
libgit2 0.21.2