diff --git a/src/core/options.c b/src/core/options.c index bec0b57..60cb94f 100644 --- a/src/core/options.c +++ b/src/core/options.c @@ -85,17 +85,14 @@ LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt) return 0; } -LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession) +LIB3270_EXPORT unsigned int lib3270_get_color_type(const H3270 *hSession) { - return (int) (hSession->mono ? 2 : hSession->colors); + return (unsigned int) (hSession->mono ? 2 : hSession->colors); } -LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype) +LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned int colortype) { - CHECK_SESSION_HANDLE(hSession); - - if(hSession->connection.state != LIB3270_NOT_CONNECTED) - return errno = EISCONN; + FAIL_IF_ONLINE(hSession); switch(colortype) { @@ -122,7 +119,6 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype) return errno = EINVAL; } - return 0; } diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c index 4a69374..aa658c7 100644 --- a/src/core/properties/signed.c +++ b/src/core/properties/signed.c @@ -55,13 +55,6 @@ static const LIB3270_INT_PROPERTY properties[] = { { - .name = "color_type", // Property name. - .description = N_( "The color type" ), // Property description. - .get = lib3270_get_color_type, // Get value. - .set = lib3270_set_color_type // Set value. - }, - - { .name = "cstate", // Property name. .description = N_( "Connection state" ), // Property description. .get = lib3270_get_connection_state_as_int, // Get value. diff --git a/src/core/properties/unsigned.c b/src/core/properties/unsigned.c index 0bf530b..45fa80c 100644 --- a/src/core/properties/unsigned.c +++ b/src/core/properties/unsigned.c @@ -60,6 +60,13 @@ static const LIB3270_UINT_PROPERTY properties[] = { { + .name = "color_type", // Property name. + .description = N_( "The color type" ), // Property description. + .get = lib3270_get_color_type, // Get value. + .set = lib3270_set_color_type // Set value. + }, + + { .name = "model_number", // Property name. .description = N_( "The model number" ), // Property description. .min = 2, // Minimum allowable value. diff --git a/src/include/lib3270.h b/src/include/lib3270.h index afdb7ee..0300dcf 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1412,7 +1412,7 @@ /** * Get source code revision. * - * @return SVN revision of the current source code. + * @return The revision of the current source code. * */ LIB3270_EXPORT const char * lib3270_get_revision(void); @@ -1422,9 +1422,21 @@ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); + /** + * @brief Set the terminal color type. + * + * @param hSession Session handle. + * @param colortype The color type for the emulator (2, 8, 16 or 0 to lib3270's default). + * + * @return 0 if ok, error code if failed (sets errno). + * + * @retval EINVAL Invalid color type value. + * @retval EISCONN The session is active. + * + */ + LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned int colortype); - LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype); - LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession); + LIB3270_EXPORT unsigned int lib3270_get_color_type(const H3270 *hSession); LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *name); LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt); -- libgit2 0.21.2