From eb5a1d119aca547e1c73dd6c5729c261437d5b17 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 26 Dec 2018 14:13:29 -0200 Subject: [PATCH] Boolean and integer properties aren't the same. --- src/include/lib3270/properties.h | 7 +++++++ src/lib3270/properties.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index a706bde..bdddf86 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -60,6 +60,13 @@ } LIB3270_STRING_PROPERTY; + /** + * @brief Get lib3270 integer properties table. + * + * @return The properties table. + * + */ + LIB3270_EXPORT const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void); /** * @brief Get lib3270 integer properties table. diff --git a/src/lib3270/properties.c b/src/lib3270/properties.c index cfb837f..8b0b0b1 100644 --- a/src/lib3270/properties.c +++ b/src/lib3270/properties.c @@ -48,10 +48,9 @@ return (int) lib3270_get_program_message(hSession); } - const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { - - static const LIB3270_INT_PROPERTY properties[] = { + const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void) { + static const LIB3270_INT_PROPERTY properties[] = { { "ready", // Property name. N_( "" ), // Property description. @@ -137,6 +136,23 @@ }, { + "has_selection", // Property name. + N_( "Has selected area" ), // Property description. + lib3270_has_selection, // Get value. + NULL // Set value. + }, + + }; + + return properties; + + } + + const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { + + static const LIB3270_INT_PROPERTY properties[] = { + + { "cursor_address", // Property name. N_( "Cursor address" ), // Property description. lib3270_get_cursor_address, // Get value. @@ -144,13 +160,6 @@ }, { - "has_selection", // Property name. - N_( "Has selected aread" ), // Property description. - lib3270_has_selection, // Get value. - NULL // Set value. - }, - - { "model_number", // Property name. N_( "The model number" ), // Property description. lib3270_get_model_number, // Get value. @@ -292,13 +301,35 @@ int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) { size_t ix; + const LIB3270_INT_PROPERTY * properties; if(seconds) { lib3270_wait_for_ready(hSession, seconds); } - const LIB3270_INT_PROPERTY * properties = lib3270_get_int_properties_list(); + // Check for boolean properties + properties = lib3270_get_boolean_properties_list(); + for(ix = 0; ix < (sizeof(properties)/sizeof(properties[0])); ix++) + { + if(!strcasecmp(name,properties[ix].name)) + { + if(properties[ix].get) + { + return properties[ix].get(hSession); + } + else + { + errno = EPERM; + return -1; + } + } + + + } + + // Check for int properties + properties = lib3270_get_int_properties_list(); for(ix = 0; ix < (sizeof(properties)/sizeof(properties[0])); ix++) { if(!strcasecmp(name,properties[ix].name)) @@ -324,13 +355,34 @@ int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) int lib3270_set_int_property(H3270 *hSession, const char *name, int value, int seconds) { size_t ix; + const LIB3270_INT_PROPERTY * properties; if(seconds) { lib3270_wait_for_ready(hSession, seconds); } - const LIB3270_INT_PROPERTY * properties = lib3270_get_int_properties_list(); + // Check for boolean properties + properties = lib3270_get_boolean_properties_list(); + for(ix = 0; properties[ix].name; ix++) + { + if(!strcasecmp(name,properties[ix].name)) + { + if(properties[ix].set) + { + return properties[ix].set(hSession, value); + } + else + { + errno = EPERM; + return -1; + } + } + + } + + // Check for INT Properties + properties = lib3270_get_int_properties_list(); for(ix = 0; properties[ix].name; ix++) { if(!strcasecmp(name,properties[ix].name)) -- libgit2 0.21.2