diff --git a/lib3270.cbp b/lib3270.cbp
index 5898b7c..9eea33d 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -174,6 +174,9 @@
+
+
+
@@ -277,6 +280,9 @@
+
+
+
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index df62e03..24c6a55 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -1138,9 +1138,16 @@
/**
* @brief Check if the screen position is protected.
*
+ * @param hSession Session handle.
+ * @param baddr0 Search start addr (-1 to use current cursor position).
+ *
+ * @return -1 when failed 1 if the addr is protected and 0 if not.
+ *
*/
LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0);
+ LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_is_protected(H3270 *h, unsigned int baddr));
+
/**
* @brief Get Check if the screen position is protected.
*
@@ -1254,9 +1261,6 @@
LIB3270_EXPORT const char * lib3270_get_model(H3270 *session);
LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession);
- LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr);
- LIB3270_EXPORT int lib3270_is_protected_at(H3270 *h, unsigned int row, unsigned int col);
-
LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name);
/**
diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c
index 9c254a3..46e6bdb 100644
--- a/src/lib3270/ctlr.c
+++ b/src/lib3270/ctlr.c
@@ -629,6 +629,28 @@ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr)
return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa) ? 1 : 0;
}
+LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
+{
+ return lib3270_get_is_protected(h, baddr);
+
+ /*
+ unsigned char fa;
+
+ FAIL_IF_NOT_ONLINE(h);
+
+ if(baddr > (h->rows * h->cols))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ fa = get_field_attribute(h,baddr);
+
+ return FA_IS_PROTECTED(fa);
+ */
+}
+
+
/**
* Perform an erase command, which may include changing the (virtual) screen size.
diff --git a/src/lib3270/linux/log.c b/src/lib3270/linux/log.c
new file mode 100644
index 0000000..32a944d
--- /dev/null
+++ b/src/lib3270/linux/log.c
@@ -0,0 +1,46 @@
+/*
+ * "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. 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 "../private.h"
+#include
+#include
+#include
+#include
+#include
+
+/*---[ Implementacao ]--------------------------------------------------------------------------------------*/
+
+ void default_log_writer(H3270 GNUC_UNUSED(*session), const char *module, int GNUC_UNUSED(rc), const char *fmt, va_list arg_ptr)
+ {
+ printf("%s:\t",module);
+ vprintf(fmt,arg_ptr);
+ printf("\n");
+ fflush(stdout);
+ }
+
diff --git a/src/lib3270/log.c b/src/lib3270/log.c
index e1d7129..a3215fd 100644
--- a/src/lib3270/log.c
+++ b/src/lib3270/log.c
@@ -41,21 +41,16 @@
#include
#include
#include
-// #include "api.h"
-
-/*---[ Prototipes ]-----------------------------------------------------------------------------------------*/
-
- static void defaultlog(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr);
/*---[ Constants ]------------------------------------------------------------------------------------------*/
- static void (*loghandler)(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) = defaultlog;
+ static void (*loghandler)(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr) = default_log_writer;
/*---[ Implementacao ]--------------------------------------------------------------------------------------*/
LIB3270_EXPORT void lib3270_set_log_handler(void (*handler)(H3270 *, const char *, int, const char *, va_list))
{
- loghandler = handler ? handler : defaultlog;
+ loghandler = handler ? handler : default_log_writer;
}
LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const char *fmt, ...)
@@ -80,12 +75,3 @@
{
loghandler(session,module,0,fmt,arg);
}
-
- static void defaultlog(H3270 GNUC_UNUSED(*session), const char *module, int GNUC_UNUSED(rc), const char *fmt, va_list arg_ptr)
- {
- fprintf(stderr,"%s:\t",module);
- vfprintf(stderr,fmt,arg_ptr);
- fprintf(stderr,"\n");
- fflush(stderr);
- }
-
diff --git a/src/lib3270/private.h b/src/lib3270/private.h
index e49de01..9dbcba8 100644
--- a/src/lib3270/private.h
+++ b/src/lib3270/private.h
@@ -674,6 +674,11 @@ struct _h3270
struct lib3270_state_callback * last[LIB3270_STATE_USER];
} st;
+#ifdef _WIN32
+ /// @brief Windows Event Log Handler.
+ HANDLE hEventLog;
+#endif // _WIN32
+
};
#define SELECTION_LEFT 0x01
@@ -770,5 +775,9 @@ LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on);
LIB3270_INTERNAL unsigned char get_field_attribute(H3270 *session, int baddr);
+ /// @brief Default log writer.
+ LIB3270_INTERNAL void default_log_writer(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr);
+
+
#endif
diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c
index e20955f..8a190e9 100644
--- a/src/lib3270/screen.c
+++ b/src/lib3270/screen.c
@@ -997,21 +997,3 @@ LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const c
session->popups--;
}
-
-LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
-{
- unsigned char fa;
-
- FAIL_IF_NOT_ONLINE(h);
-
- if(baddr > (h->rows * h->cols))
- {
- errno = EINVAL;
- return -1;
- }
-
- fa = get_field_attribute(h,baddr);
-
- return FA_IS_PROTECTED(fa);
-}
-
diff --git a/src/lib3270/session.c b/src/lib3270/session.c
index 92aa205..6217885 100644
--- a/src/lib3270/session.c
+++ b/src/lib3270/session.c
@@ -151,6 +151,11 @@ void lib3270_session_free(H3270 *h)
lib3270_free(ip);
}
+#ifdef _WIN32
+ DeregisterEventSource(h->hEventLog);
+ h->hEventLog = 0;
+#endif // _WIN32
+
trace("Releasing session %p",h);
lib3270_free(h);
@@ -408,6 +413,10 @@ H3270 * lib3270_session_new(const char *model)
ft_init(hSession);
#endif
+#ifdef _WIN32
+ hSession->hEventLog = RegisterEventSource(NULL, PACKAGE_NAME);
+#endif // _WIN32
+
trace("%s finished",__FUNCTION__);
errno = 0;
diff --git a/src/lib3270/windows/log.c b/src/lib3270/windows/log.c
new file mode 100644
index 0000000..40ea3bd
--- /dev/null
+++ b/src/lib3270/windows/log.c
@@ -0,0 +1,78 @@
+/*
+ * "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. 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
+
+#include "../private.h"
+#include
+#include
+#include
+#include
+#include
+
+/*---[ Implement ]------------------------------------------------------------------------------------------*/
+
+ void default_log_writer(H3270 *session, const char *module, int rc, const char *fmt, va_list arg_ptr)
+ {
+ char username[UNLEN + 1];
+ DWORD szName = sizeof(username);
+
+ memset(username,0,szName);
+
+ if(!GetUserName(username, &szName)) {
+ strncpy(username,"?",UNLEN);
+ }
+
+ lib3270_autoptr(char) msg = lib3270_vsprintf(fmt,arg_ptr);
+
+ const char *outMsg[] = {
+ username,
+ module,
+ msg
+ };
+
+ if(session->hEventLog) {
+ ReportEvent(
+ session->hEventLog,
+ (rc == 0 ? EVENTLOG_INFORMATION_TYPE : EVENTLOG_ERROR_TYPE),
+ 1,
+ 0,
+ NULL,
+ 3,
+ 0,
+ outMsg,
+ NULL
+ );
+ }
+
+ }
+
--
libgit2 0.21.2