Commit dc07439ba2b72792dee695858e1f26fe61a8485a

Authored by Perry Werneck
1 parent 89fe8c23

Color type should be an unsigned int.

src/core/options.c
... ... @@ -85,17 +85,14 @@ LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt)
85 85 return 0;
86 86 }
87 87  
88   -LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession)
  88 +LIB3270_EXPORT unsigned int lib3270_get_color_type(const H3270 *hSession)
89 89 {
90   - return (int) (hSession->mono ? 2 : hSession->colors);
  90 + return (unsigned int) (hSession->mono ? 2 : hSession->colors);
91 91 }
92 92  
93   -LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype)
  93 +LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned int colortype)
94 94 {
95   - CHECK_SESSION_HANDLE(hSession);
96   -
97   - if(hSession->connection.state != LIB3270_NOT_CONNECTED)
98   - return errno = EISCONN;
  95 + FAIL_IF_ONLINE(hSession);
99 96  
100 97 switch(colortype)
101 98 {
... ... @@ -122,7 +119,6 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype)
122 119 return errno = EINVAL;
123 120 }
124 121  
125   -
126 122 return 0;
127 123 }
128 124  
... ...
src/core/properties/signed.c
... ... @@ -55,13 +55,6 @@
55 55 static const LIB3270_INT_PROPERTY properties[] = {
56 56  
57 57 {
58   - .name = "color_type", // Property name.
59   - .description = N_( "The color type" ), // Property description.
60   - .get = lib3270_get_color_type, // Get value.
61   - .set = lib3270_set_color_type // Set value.
62   - },
63   -
64   - {
65 58 .name = "cstate", // Property name.
66 59 .description = N_( "Connection state" ), // Property description.
67 60 .get = lib3270_get_connection_state_as_int, // Get value.
... ...
src/core/properties/unsigned.c
... ... @@ -60,6 +60,13 @@
60 60 static const LIB3270_UINT_PROPERTY properties[] = {
61 61  
62 62 {
  63 + .name = "color_type", // Property name.
  64 + .description = N_( "The color type" ), // Property description.
  65 + .get = lib3270_get_color_type, // Get value.
  66 + .set = lib3270_set_color_type // Set value.
  67 + },
  68 +
  69 + {
63 70 .name = "model_number", // Property name.
64 71 .description = N_( "The model number" ), // Property description.
65 72 .min = 2, // Minimum allowable value.
... ...
src/include/lib3270.h
... ... @@ -1412,7 +1412,7 @@
1412 1412 /**
1413 1413 * Get source code revision.
1414 1414 *
1415   - * @return SVN revision of the current source code.
  1415 + * @return The revision of the current source code.
1416 1416 *
1417 1417 */
1418 1418 LIB3270_EXPORT const char * lib3270_get_revision(void);
... ... @@ -1422,9 +1422,21 @@
1422 1422  
1423 1423 LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession);
1424 1424  
  1425 + /**
  1426 + * @brief Set the terminal color type.
  1427 + *
  1428 + * @param hSession Session handle.
  1429 + * @param colortype The color type for the emulator (2, 8, 16 or 0 to lib3270's default).
  1430 + *
  1431 + * @return 0 if ok, error code if failed (sets errno).
  1432 + *
  1433 + * @retval EINVAL Invalid color type value.
  1434 + * @retval EISCONN The session is active.
  1435 + *
  1436 + */
  1437 + LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned int colortype);
1425 1438  
1426   - LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype);
1427   - LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession);
  1439 + LIB3270_EXPORT unsigned int lib3270_get_color_type(const H3270 *hSession);
1428 1440  
1429 1441 LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *name);
1430 1442 LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt);
... ...