Commit 0e5fef36710bf696c70ad1c0c7228430282f38c3
1 parent
a73d2782
Exists in
develop
Since windows does not have version control in the system a new method
was implemented to check if the lib3270 current revision can work with applications to avoid loading of an incomplete or incompatible version of lib3270. Adding string translation for signed int properties.
Showing
3 changed files
with
105 additions
and
12 deletions
Show diff stats
src/core/properties/signed.c
... | ... | @@ -38,14 +38,86 @@ static int lib3270_get_connection_state_as_int(const H3270 *hSession) { |
38 | 38 | return (int) lib3270_get_connection_state(hSession); |
39 | 39 | } |
40 | 40 | |
41 | +const char * lib3270_get_connection_state_as_string(const H3270 *hSession) { | |
42 | + | |
43 | + static const char * values[] = { | |
44 | + N_("Disconnected"), | |
45 | + N_("Connecting to host"), | |
46 | + N_("Connection pending"), | |
47 | + N_("Connected, no mode yet"), | |
48 | + N_("Connected in NVT ANSI mode"), | |
49 | + N_("Connected in old-style 3270 mode"), | |
50 | + N_("Connected in TN3270E mode, no negotiated"), | |
51 | + N_("Connected in TN3270E mode, NVT mode"), | |
52 | + N_("Connected in TN3270E mode, SSCP-LU mode"), | |
53 | + N_("Connected in TN3270E mode, 3270 mode") | |
54 | + }; | |
55 | + | |
56 | + size_t value = (size_t) lib3270_get_connection_state(hSession); | |
57 | + if(value < (sizeof(value)/sizeof(values[0]))) { | |
58 | + return dgettext(GETTEXT_PACKAGE,values[value]); | |
59 | + } | |
60 | + | |
61 | + return _( "Unknown" ); | |
62 | + | |
63 | +} | |
64 | + | |
41 | 65 | static int lib3270_get_program_message_as_int(const H3270 *hSession) { |
42 | 66 | return (int) lib3270_get_program_message(hSession); |
43 | 67 | } |
44 | 68 | |
69 | +const char * lib3270_get_program_message_as_string(const H3270 *hSession) { | |
70 | + | |
71 | + static const char * values[] = { | |
72 | + "", | |
73 | + N_( "X System" ), | |
74 | + N_( "X Wait" ), | |
75 | + N_( "X Connected" ), | |
76 | + N_( "X Not Connected" ), | |
77 | + N_( "X" ), | |
78 | + N_( "X -f" ), | |
79 | + N_( "X Protected" ), | |
80 | + N_( "X Numeric" ), | |
81 | + N_( "X Overflow" ), | |
82 | + N_( "X Inhibit" ), | |
83 | + N_( "X" ), | |
84 | + N_( "X" ), | |
85 | + N_( "X Resolving" ), | |
86 | + N_( "X Connecting" ) | |
87 | + }; | |
88 | + | |
89 | + size_t value = (size_t) lib3270_get_program_message(hSession); | |
90 | + if(value < (sizeof(value)/sizeof(values[0]))) { | |
91 | + return dgettext(GETTEXT_PACKAGE,values[value]); | |
92 | + } | |
93 | + | |
94 | + return _( "Unknown" ); | |
95 | + | |
96 | +} | |
97 | + | |
45 | 98 | static int lib3270_get_ssl_state_as_int(const H3270 * hSession) { |
46 | 99 | return (int) lib3270_get_ssl_state(hSession); |
47 | 100 | } |
48 | 101 | |
102 | +const char * lib3270_get_ssl_state_as_string(const H3270 * hSession) { | |
103 | + | |
104 | + static const char * values[] = { | |
105 | + N_("No secure connection"), | |
106 | + N_("Connection secure with CA check"), | |
107 | + N_("Connection secure, no CA, self-signed or expired CRL"), | |
108 | + N_("Negotiating SSL"), | |
109 | + N_("Verifying SSL (Getting CRL)"), | |
110 | + N_("Undefined") | |
111 | + }; | |
112 | + | |
113 | + size_t value = (size_t) lib3270_get_ssl_state(hSession); | |
114 | + if(value < (sizeof(value)/sizeof(values[0]))) { | |
115 | + return dgettext(GETTEXT_PACKAGE,values[value]); | |
116 | + } | |
117 | + | |
118 | + return _( "Unknown" ); | |
119 | +} | |
120 | + | |
49 | 121 | const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { |
50 | 122 | |
51 | 123 | static const LIB3270_INT_PROPERTY properties[] = { |
... | ... | @@ -54,7 +126,8 @@ const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { |
54 | 126 | .name = "cstate", // Property name. |
55 | 127 | .description = N_( "Connection state" ), // Property description. |
56 | 128 | .get = lib3270_get_connection_state_as_int, // Get value. |
57 | - .set = NULL // Set value. | |
129 | + .set = NULL, // Set value. | |
130 | + .describe = lib3270_get_connection_state_as_string | |
58 | 131 | }, |
59 | 132 | |
60 | 133 | { |
... | ... | @@ -62,28 +135,32 @@ const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void) { |
62 | 135 | .group = LIB3270_ACTION_GROUP_ONLINE, // Property group. |
63 | 136 | .description = N_( "Cursor address" ), // Property description. |
64 | 137 | .get = lib3270_get_cursor_address, // Get value. |
65 | - .set = lib3270_set_cursor_address // Set value. | |
138 | + .set = lib3270_set_cursor_address, // Set value. | |
139 | + .describe = NULL | |
66 | 140 | }, |
67 | 141 | |
68 | 142 | { |
69 | - .name = "program_message", // Property name. | |
70 | - .description = N_( "Latest program message" ), // Property description. | |
71 | - .get = lib3270_get_program_message_as_int, // Get value. | |
72 | - .set = NULL // Set value. | |
143 | + .name = "program_message", // Property name. | |
144 | + .description = N_( "Latest program message" ), // Property description. | |
145 | + .get = lib3270_get_program_message_as_int, // Get value. | |
146 | + .set = NULL, // Set value. | |
147 | + .describe = lib3270_get_program_message_as_string | |
73 | 148 | }, |
74 | 149 | |
75 | 150 | { |
76 | 151 | .name = "ssl_state", // Property name. |
77 | 152 | .description = N_( "ID of the session security state" ), // Property description. |
78 | 153 | .get = lib3270_get_ssl_state_as_int, // Get value. |
79 | - .set = NULL // Set value. | |
154 | + .set = NULL, // Set value. | |
155 | + .describe = lib3270_get_ssl_state_as_string | |
80 | 156 | }, |
81 | 157 | |
82 | 158 | { |
83 | 159 | .name = NULL, |
84 | 160 | .description = NULL, |
85 | 161 | .get = NULL, |
86 | - .set = NULL | |
162 | + .set = NULL, // Set value. | |
163 | + .describe = NULL | |
87 | 164 | } |
88 | 165 | }; |
89 | 166 | ... | ... |
src/core/util.c
... | ... | @@ -239,6 +239,10 @@ LIB3270_EXPORT const char * lib3270_get_revision(void) { |
239 | 239 | return RPQ_REVISION; |
240 | 240 | } |
241 | 241 | |
242 | +LIB3270_EXPORT int lib3270_check_revision(const char GNUC_UNUSED(*revision)) { | |
243 | + return 0; | |
244 | +} | |
245 | + | |
242 | 246 | LIB3270_EXPORT const char * lib3270_get_product_name(void) { |
243 | 247 | return LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME); |
244 | 248 | } | ... | ... |
src/include/lib3270.h
... | ... | @@ -94,6 +94,9 @@ |
94 | 94 | #define LIB3270_STRINGIZE(x) #x |
95 | 95 | #define LIB3270_STRINGIZE_VALUE_OF(x) LIB3270_STRINGIZE(x) |
96 | 96 | |
97 | +typedef struct _h3270 H3270; | |
98 | +typedef struct _h3270ft H3270FT; | |
99 | + | |
97 | 100 | /** |
98 | 101 | * @brief BIND definitions. |
99 | 102 | */ |
... | ... | @@ -368,7 +371,8 @@ typedef enum _lib3270_action_group { |
368 | 371 | const char * label; \ |
369 | 372 | const char * icon; \ |
370 | 373 | const char * summary; \ |
371 | - const char * description; | |
374 | + const char * description; \ | |
375 | + const char * (*describe)(const H3270 *); | |
372 | 376 | |
373 | 377 | typedef struct _lib3270_property { |
374 | 378 | LIB3270_PROPERTY_HEAD |
... | ... | @@ -393,9 +397,6 @@ typedef enum _lib3270_state { |
393 | 397 | LIB3270_STATE_USER // Always the last one |
394 | 398 | } LIB3270_STATE; |
395 | 399 | |
396 | -typedef struct _h3270 H3270; | |
397 | -typedef struct _h3270ft H3270FT; | |
398 | - | |
399 | 400 | /** |
400 | 401 | * Get current screen size. |
401 | 402 | * |
... | ... | @@ -1490,6 +1491,17 @@ LIB3270_EXPORT const char * lib3270_get_version(void); |
1490 | 1491 | */ |
1491 | 1492 | LIB3270_EXPORT const char * lib3270_get_revision(void); |
1492 | 1493 | |
1494 | +/** | |
1495 | + * @brief Test if the revision is valid. | |
1496 | + * | |
1497 | + * @param revision Revision number to check. | |
1498 | + * | |
1499 | + * @return 0 if the supplied revision is valid to the current library. | |
1500 | + * | |
1501 | + */ | |
1502 | +LIB3270_EXPORT int lib3270_check_revision(const char *revision); | |
1503 | + | |
1504 | + | |
1493 | 1505 | LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); |
1494 | 1506 | LIB3270_EXPORT char * lib3270_strdup_printf(const char *fmt, ...); |
1495 | 1507 | ... | ... |