diff --git a/src/core/properties/boolean.c b/src/core/properties/boolean.c index 7868d2a..97f0516 100644 --- a/src/core/properties/boolean.c +++ b/src/core/properties/boolean.c @@ -222,3 +222,30 @@ } +int lib3270_set_boolean_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); + } + + 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 + return errno = EPERM; + } + + } + + return errno = ENOENT; + +} + diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c index 166895e..96528e3 100644 --- a/src/core/properties/signed.c +++ b/src/core/properties/signed.c @@ -155,50 +155,37 @@ int lib3270_set_int_property(H3270 *hSession, const char *name, int value, int s const LIB3270_INT_PROPERTY * properties; if(seconds) - { lib3270_wait_for_ready(hSession, seconds); - } - // Check for boolean properties - properties = lib3270_get_boolean_properties_list(); + // Check for INT Properties + properties = lib3270_get_int_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; - } + return errno = EPERM; } } - // Check for INT Properties - 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; - } + return errno = EPERM; } } - errno = ENOENT; - return -1; + return errno = ENOENT; } diff --git a/src/core/properties/string.c b/src/core/properties/string.c index 52a6719..608b8fa 100644 --- a/src/core/properties/string.c +++ b/src/core/properties/string.c @@ -224,8 +224,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char * } else { - errno = EPERM; - return -1; + return errno = EPERM; } } @@ -247,8 +246,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char * } else { - errno = EPERM; - return -1; + return errno = EPERM; } } @@ -270,8 +268,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char * } else { - errno = EPERM; - return -1; + return errno = EPERM; } } @@ -293,28 +290,17 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char * } else { - errno = EPERM; - return -1; + return errno = EPERM; } } } } - errno = ENOENT; - return -1; + return errno = ENOENT; } -/* -LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) -{ - FAIL_IF_ONLINE(hSession); - strncpy(hSession->lu.names,luname,LIB3270_LUNAME_LENGTH); - return 0; -} -*/ - LIB3270_EXPORT int lib3270_set_lunames(H3270 *hSession, const char *lunames) { FAIL_IF_ONLINE(hSession); diff --git a/src/core/properties/unsigned.c b/src/core/properties/unsigned.c index 4d690ce..535112d 100644 --- a/src/core/properties/unsigned.c +++ b/src/core/properties/unsigned.c @@ -171,4 +171,30 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession) return properties; } +int lib3270_set_uint_property(H3270 *hSession, const char *name, unsigned int value, int seconds) +{ + size_t ix; + const LIB3270_UINT_PROPERTY * properties; + + if(seconds) + lib3270_wait_for_ready(hSession, seconds); + + // Check for INT Properties + properties = lib3270_get_unsigned_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 + return errno = EPERM; + } + + } + + return errno = ENOENT; + +} diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index 476a504..222d940 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -131,26 +131,62 @@ LIB3270_EXPORT int lib3270_get_int_property(H3270 * hSession, const char *name, int seconds); /** - * @brief Set lib3270 integer property by name. + * @brief Set lib3270 signed int property by name. * * @param name Nome of the property. * @param value New property value. * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none). * - * @return 0 if ok, -1 in case of error (sets errno). + * @return 0 if ok error code if not (sets errno). + * + * @retval EPERM Property is ready only. + * @retval ENOENT Can't find a property with this name. * */ LIB3270_EXPORT int lib3270_set_int_property(H3270 * hSession, const char *name, int value, int seconds); /** - * @brief Set lib3270 integer property by name. + * @brief Set lib3270 unsigned int property by name. + * + * @param name Nome of the property. + * @param value New property value. + * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none). + * + * @return 0 if ok error code if not (sets errno). + * + * @retval EPERM Property is ready only. + * @retval ENOENT Can't find a property with this name. + * + */ + LIB3270_EXPORT int lib3270_set_uint_property(H3270 * hSession, const char *name, unsigned int value, int seconds); + + /** + * @brief Set lib3270 boolean property by name. + * + * @param name Nome of the property. + * @param value New property value. + * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none). + * + * @return 0 if ok error code if not (sets errno). + * + * @retval EPERM Property is ready only. + * @retval ENOENT Can't find a property with this name. + * + */ + LIB3270_EXPORT int lib3270_set_boolean_property(H3270 * hSession, const char *name, int value, int seconds); + + /** + * @brief Set lib3270 string property by name. * * @param hSession Session handle. * @param name Nome of the property. * @param value New property value. * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none). * - * @return 0 if ok, -1 in case of error (sets errno). + * @return 0 if ok error code if not (sets errno). + * + * @retval EPERM Property is ready only. + * @retval ENOENT Can't find a property with this name. * */ LIB3270_EXPORT int lib3270_set_string_property(H3270 * hSession, const char *name, const char * value, int seconds); -- libgit2 0.21.2