diff --git a/src/include/config.h.in b/src/include/config.h.in index 91d1424..563d5e1 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -36,11 +36,17 @@ #undef PACKAGE_VERSION #undef PACKAGE_RELEASE - /* Defaults */ + /* Default settings */ + + /** @brief The lib3270's default host URL */ #undef LIB3270_DEFAULT_HOST + #undef LIB3270_DATADIR - /* Libraries */ + /** @brief the delay, in miliseconds, between the host unlocking the keyboard and lib3270 actually performing the unlock */ + #define UNLOCK_MS 350 + + /* Library options */ #undef HAVE_GNUC_VISIBILITY #undef HAVE_LIBINTL #undef HAVE_GETADDRINFO diff --git a/src/include/lib3270.h b/src/include/lib3270.h index e2f4c66..f5261b7 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1234,7 +1234,7 @@ * The value is in milliseconds; use 0 to turn off the delay completely. * * @param session lib3270 session. - * @param Delay in milliseconds. + * @param delay Delay in milliseconds. * */ LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, unsigned int delay); @@ -1256,7 +1256,6 @@ LIB3270_EXPORT void * lib3270_malloc(int len); LIB3270_EXPORT void * lib3270_realloc(void *p, int len); -// LIB3270_EXPORT void * lib3270_replace(void **p, void *ptr); LIB3270_EXPORT void * lib3270_strdup(const char *str); #define LIB3270_AUTOPTR_FUNC_NAME(TypeName) lib3270_autoptr_cleanup_##TypeName @@ -1287,17 +1286,6 @@ LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void); /** - * Get resource string. - * - * @param first_element First element of resource path - * @param ... Resource path (ends with NULL) - * - * @return Resource string (Release with lib3270_free()) - * - */ - LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...); - - /** * Get library version. * * @return Version of active library as string. @@ -1371,6 +1359,17 @@ #ifdef WIN32 LIB3270_EXPORT const char * lib3270_win32_strerror(int e); LIB3270_EXPORT const char * lib3270_win32_local_charset(void); + + /** + * @brief Translate windows error code. + * + * @param lasterror Windows error code (from GetLastError()). + * + * @return String with translated message (release it with lib3270_free). + * + */ + LIB3270_EXPORT char * lib3270_win32_translate_error_code(int lasterror); + #endif // WIn32 /** diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 09d2d8a..6023698 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -113,7 +113,6 @@ static const unsigned char pa_xlate[] = }; #define PF_SZ (sizeof(pf_xlate)/sizeof(pf_xlate[0])) #define PA_SZ (sizeof(pa_xlate)/sizeof(pa_xlate[0])) -#define UNLOCK_MS 350 /* 0.35s after last unlock */ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean pasting,Boolean *skipped); static int flush_ta(H3270 *hSession); diff --git a/src/lib3270/paste.c b/src/lib3270/paste.c index 8776af7..34d9dca 100644 --- a/src/lib3270/paste.c +++ b/src/lib3270/paste.c @@ -209,7 +209,7 @@ static int set_string(H3270 *hSession, const unsigned char *str) } str++; - if(IN_3270 && lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < data.orig_col) + if(IN_3270 && lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < ((unsigned int) data.orig_col)) { if(!remargin(hSession,data.orig_col)) last = 0; diff --git a/src/lib3270/session.c b/src/lib3270/session.c index dc29481..a457730 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -337,9 +337,15 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char hSession->host_type = LIB3270_HOSTTYPE_DEFAULT; hSession->colors = 16; hSession->m3279 = 1; - hSession->unlock_delay_ms = 350; // 0.35s after last unlock hSession->pointer = (unsigned short) LIB3270_POINTER_LOCKED; +#ifdef UNLOCK_MS + hSession->unlock_delay_ms = UNLOCK_MS; +#else + #error aqui + hSession->unlock_delay_ms = 350; +#endif // UNLOCK_MS + // CSD for(f=0;f<4;f++) hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; diff --git a/src/lib3270/windows/util.c b/src/lib3270/windows/util.c index 5644efa..56e0ff6 100644 --- a/src/lib3270/windows/util.c +++ b/src/lib3270/windows/util.c @@ -121,6 +121,54 @@ const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt) } #endif // HAVE_INET_NTOP +LIB3270_EXPORT char * lib3270_win32_translate_error_code(int lasterror) +{ + char * buffer = lib3270_malloc(4096); + + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,lasterror,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),buffer,4096,NULL) == 0) + { + snprintf(buffer, 4095, _( "Windows error %d" ), e); + } + +#ifdef HAVE_ICONV + { + // Convert from windows codepage to UTF-8 pw3270´s default charset + iconv_t hConv = iconv_open("UTF-8",lib3270_win32_local_charset()); + + trace("[%s]",buffer); + + if(hConv == (iconv_t) -1) + { + lib3270_write_log(NULL,"iconv","%s: Error creating charset conversion",__FUNCTION__); + } + else + { + size_t in = strlen(buffer); + size_t out = (in << 1); + char * ptr; + char * outBuffer = (char *) malloc(out); + ICONV_CONST char * inBuffer = (ICONV_CONST char *) buffer; + + memset(ptr=outBuffer,0,out); + + iconv(hConv,NULL,NULL,NULL,NULL); // Reset state + + if(iconv(hConv,&inBuffer,&in,&ptr,&out) != ((size_t) -1)) + { + strncpy(buffer,outBuffer,4095); + } + + free(outBuffer); + + iconv_close(hConv); + } + + } +#endif // HAVE_ICONV + + return buffer; +} + // Decode a Win32 error number. LIB3270_EXPORT const char * lib3270_win32_strerror(int e) { -- libgit2 0.21.2