diff --git a/src/core/ctlr.c b/src/core/ctlr.c index a84b093..530e945 100644 --- a/src/core/ctlr.c +++ b/src/core/ctlr.c @@ -429,6 +429,14 @@ static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UN hSession->crm_nattr = 0; } +LIB3270_EXPORT int lib3270_get_is_formatted(H3270 *hSession) +{ + if(check_online_session(hSession)) + return -1; + + return hSession->formatted ? 1 : 0; +} + /** * @brief Get field address. * @@ -531,7 +539,7 @@ LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSessi if(!hSession->formatted) { errno = ENOTCONN; - return (LIB3270_FIELD_ATTRIBUTE) 0; + return LIB3270_FIELD_ATTRIBUTE_INVALID; } if(baddr < 0) @@ -547,7 +555,7 @@ LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSessi } while (baddr != sbaddr); errno = EINVAL; - return (LIB3270_FIELD_ATTRIBUTE) 0; + return LIB3270_FIELD_ATTRIBUTE_INVALID; } @@ -646,26 +654,9 @@ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) 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/core/properties.c b/src/core/properties.c index 617a855..18abae6 100644 --- a/src/core/properties.c +++ b/src/core/properties.c @@ -56,11 +56,6 @@ return hSession->starting != 0; } - int lib3270_get_formatted(H3270 *hSession) - { - return hSession->formatted != 0; - } - const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void) { @@ -173,7 +168,7 @@ { "formatted", // Property name. N_( "Formatted screen" ), // Property description. - lib3270_get_formatted, // Get value. + lib3270_get_is_formatted, // Get value. NULL // Set value. }, @@ -212,7 +207,7 @@ }, { - "width",// Property name. + "width", // Property name. N_( "Current screen width in columns" ), // Property description. lib3270_get_width, // Get value. NULL // Set value. diff --git a/src/include/lib3270.h b/src/include/lib3270.h index ba5652a..de5f779 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -296,6 +296,7 @@ */ typedef enum lib3270_field_attribute { + LIB3270_FIELD_ATTRIBUTE_INVALID = 0x00, ///< @brief Attribute is invalid. LIB3270_FIELD_ATTRIBUTE_PRINTABLE = 0xc0, ///< @brief these make the character "printable" LIB3270_FIELD_ATTRIBUTE_PROTECT = 0x20, ///< @brief unprotected (0) / protected (1) LIB3270_FIELD_ATTRIBUTE_NUMERIC = 0x10, ///< @brief alphanumeric (0) / numeric (1) @@ -309,15 +310,14 @@ } LIB3270_FIELD_ATTRIBUTE; /** - * @brief Host options + * @brief Host types. * */ typedef enum lib3270_host_type { - // Host types - LIB3270_HOST_AS400 = 0x0001, ///< AS400 host - Prefix every PF with PA1 - LIB3270_HOST_TSO = 0x0002, ///< Host is TSO? - LIB3270_HOST_S390 = 0x0006, ///< Host is S390? (TSO included) + LIB3270_HOST_AS400 = 0x0001, ///< @brief AS400 host - Prefix every PF with PA1 + LIB3270_HOST_TSO = 0x0002, ///< @brief Host is TSO + LIB3270_HOST_S390 = 0x0006, ///< @brief Host is S390 (TSO included) } LIB3270_HOST_TYPE; @@ -332,7 +332,7 @@ } LIB3270_HOST_TYPE_ENTRY; /** - * SSL state + * @brief SSL state * */ typedef enum lib3270_ssl_state @@ -1147,6 +1147,16 @@ LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_is_protected(H3270 *h, unsigned int baddr)); /** + * @brief Check if the screen is formatted. + * + * @param hSession Session handle. + * + * @return -1 when failed 1 if the session is formatted and 0 if not. + * + */ + LIB3270_EXPORT int lib3270_get_is_formatted(H3270 *hSession); + + /** * @brief Get Check if the screen position is protected. * * @param h Session Handle. @@ -1186,7 +1196,7 @@ * @param hSession Session handle. * @param addr Buffer address of the field (-1 to use the cursor address). * - * @return field attribute or 0 when failed (sets errno). + * @return field attribute or LIB3270_FIELD_ATTRIBUTE_INVALID when failed (sets errno). */ LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSession, int baddr); -- libgit2 0.21.2