Commit eb5a1d119aca547e1c73dd6c5729c261437d5b17
1 parent
713a618b
Exists in
master
and in
3 other branches
Boolean and integer properties aren't the same.
Showing
2 changed files
with
71 additions
and
12 deletions
Show diff stats
src/include/lib3270/properties.h
@@ -60,6 +60,13 @@ | @@ -60,6 +60,13 @@ | ||
60 | 60 | ||
61 | } LIB3270_STRING_PROPERTY; | 61 | } LIB3270_STRING_PROPERTY; |
62 | 62 | ||
63 | + /** | ||
64 | + * @brief Get lib3270 integer properties table. | ||
65 | + * | ||
66 | + * @return The properties table. | ||
67 | + * | ||
68 | + */ | ||
69 | + LIB3270_EXPORT const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void); | ||
63 | 70 | ||
64 | /** | 71 | /** |
65 | * @brief Get lib3270 integer properties table. | 72 | * @brief Get lib3270 integer properties table. |
src/lib3270/properties.c
@@ -48,10 +48,9 @@ | @@ -48,10 +48,9 @@ | ||
48 | return (int) lib3270_get_program_message(hSession); | 48 | return (int) lib3270_get_program_message(hSession); |
49 | } | 49 | } |
50 | 50 | ||
51 | - const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { | ||
52 | - | ||
53 | - static const LIB3270_INT_PROPERTY properties[] = { | 51 | + const LIB3270_INT_PROPERTY * lib3270_get_boolean_properties_list(void) { |
54 | 52 | ||
53 | + static const LIB3270_INT_PROPERTY properties[] = { | ||
55 | { | 54 | { |
56 | "ready", // Property name. | 55 | "ready", // Property name. |
57 | N_( "" ), // Property description. | 56 | N_( "" ), // Property description. |
@@ -137,6 +136,23 @@ | @@ -137,6 +136,23 @@ | ||
137 | }, | 136 | }, |
138 | 137 | ||
139 | { | 138 | { |
139 | + "has_selection", // Property name. | ||
140 | + N_( "Has selected area" ), // Property description. | ||
141 | + lib3270_has_selection, // Get value. | ||
142 | + NULL // Set value. | ||
143 | + }, | ||
144 | + | ||
145 | + }; | ||
146 | + | ||
147 | + return properties; | ||
148 | + | ||
149 | + } | ||
150 | + | ||
151 | + const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { | ||
152 | + | ||
153 | + static const LIB3270_INT_PROPERTY properties[] = { | ||
154 | + | ||
155 | + { | ||
140 | "cursor_address", // Property name. | 156 | "cursor_address", // Property name. |
141 | N_( "Cursor address" ), // Property description. | 157 | N_( "Cursor address" ), // Property description. |
142 | lib3270_get_cursor_address, // Get value. | 158 | lib3270_get_cursor_address, // Get value. |
@@ -144,13 +160,6 @@ | @@ -144,13 +160,6 @@ | ||
144 | }, | 160 | }, |
145 | 161 | ||
146 | { | 162 | { |
147 | - "has_selection", // Property name. | ||
148 | - N_( "Has selected aread" ), // Property description. | ||
149 | - lib3270_has_selection, // Get value. | ||
150 | - NULL // Set value. | ||
151 | - }, | ||
152 | - | ||
153 | - { | ||
154 | "model_number", // Property name. | 163 | "model_number", // Property name. |
155 | N_( "The model number" ), // Property description. | 164 | N_( "The model number" ), // Property description. |
156 | lib3270_get_model_number, // Get value. | 165 | lib3270_get_model_number, // Get value. |
@@ -292,13 +301,35 @@ | @@ -292,13 +301,35 @@ | ||
292 | int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) | 301 | int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) |
293 | { | 302 | { |
294 | size_t ix; | 303 | size_t ix; |
304 | + const LIB3270_INT_PROPERTY * properties; | ||
295 | 305 | ||
296 | if(seconds) | 306 | if(seconds) |
297 | { | 307 | { |
298 | lib3270_wait_for_ready(hSession, seconds); | 308 | lib3270_wait_for_ready(hSession, seconds); |
299 | } | 309 | } |
300 | 310 | ||
301 | - const LIB3270_INT_PROPERTY * properties = lib3270_get_int_properties_list(); | 311 | + // Check for boolean properties |
312 | + properties = lib3270_get_boolean_properties_list(); | ||
313 | + for(ix = 0; ix < (sizeof(properties)/sizeof(properties[0])); ix++) | ||
314 | + { | ||
315 | + if(!strcasecmp(name,properties[ix].name)) | ||
316 | + { | ||
317 | + if(properties[ix].get) | ||
318 | + { | ||
319 | + return properties[ix].get(hSession); | ||
320 | + } | ||
321 | + else | ||
322 | + { | ||
323 | + errno = EPERM; | ||
324 | + return -1; | ||
325 | + } | ||
326 | + } | ||
327 | + | ||
328 | + | ||
329 | + } | ||
330 | + | ||
331 | + // Check for int properties | ||
332 | + properties = lib3270_get_int_properties_list(); | ||
302 | for(ix = 0; ix < (sizeof(properties)/sizeof(properties[0])); ix++) | 333 | for(ix = 0; ix < (sizeof(properties)/sizeof(properties[0])); ix++) |
303 | { | 334 | { |
304 | if(!strcasecmp(name,properties[ix].name)) | 335 | if(!strcasecmp(name,properties[ix].name)) |
@@ -324,13 +355,34 @@ int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) | @@ -324,13 +355,34 @@ int lib3270_get_int_property(H3270 *hSession, const char *name, int seconds) | ||
324 | int lib3270_set_int_property(H3270 *hSession, const char *name, int value, int seconds) | 355 | int lib3270_set_int_property(H3270 *hSession, const char *name, int value, int seconds) |
325 | { | 356 | { |
326 | size_t ix; | 357 | size_t ix; |
358 | + const LIB3270_INT_PROPERTY * properties; | ||
327 | 359 | ||
328 | if(seconds) | 360 | if(seconds) |
329 | { | 361 | { |
330 | lib3270_wait_for_ready(hSession, seconds); | 362 | lib3270_wait_for_ready(hSession, seconds); |
331 | } | 363 | } |
332 | 364 | ||
333 | - const LIB3270_INT_PROPERTY * properties = lib3270_get_int_properties_list(); | 365 | + // Check for boolean properties |
366 | + properties = lib3270_get_boolean_properties_list(); | ||
367 | + for(ix = 0; properties[ix].name; ix++) | ||
368 | + { | ||
369 | + if(!strcasecmp(name,properties[ix].name)) | ||
370 | + { | ||
371 | + if(properties[ix].set) | ||
372 | + { | ||
373 | + return properties[ix].set(hSession, value); | ||
374 | + } | ||
375 | + else | ||
376 | + { | ||
377 | + errno = EPERM; | ||
378 | + return -1; | ||
379 | + } | ||
380 | + } | ||
381 | + | ||
382 | + } | ||
383 | + | ||
384 | + // Check for INT Properties | ||
385 | + properties = lib3270_get_int_properties_list(); | ||
334 | for(ix = 0; properties[ix].name; ix++) | 386 | for(ix = 0; properties[ix].name; ix++) |
335 | { | 387 | { |
336 | if(!strcasecmp(name,properties[ix].name)) | 388 | if(!strcasecmp(name,properties[ix].name)) |