Commit cd2eb52b761969143b23c8a0e67138fff5ea28b1

Authored by Perry Werneck
1 parent a63e0cc5
Exists in master and in 2 other branches develop, macos

Adding property methods.

src/core/properties/boolean.c
... ... @@ -222,3 +222,30 @@
222 222  
223 223 }
224 224  
  225 +int lib3270_set_boolean_property(H3270 *hSession, const char *name, int value, int seconds)
  226 +{
  227 + size_t ix;
  228 + const LIB3270_INT_PROPERTY * properties;
  229 +
  230 + if(seconds)
  231 + {
  232 + lib3270_wait_for_ready(hSession, seconds);
  233 + }
  234 +
  235 + properties = lib3270_get_boolean_properties_list();
  236 + for(ix = 0; properties[ix].name; ix++)
  237 + {
  238 + if(!strcasecmp(name,properties[ix].name))
  239 + {
  240 + if(properties[ix].set)
  241 + return properties[ix].set(hSession, value);
  242 + else
  243 + return errno = EPERM;
  244 + }
  245 +
  246 + }
  247 +
  248 + return errno = ENOENT;
  249 +
  250 +}
  251 +
... ...
src/core/properties/signed.c
... ... @@ -155,50 +155,37 @@ int lib3270_set_int_property(H3270 *hSession, const char *name, int value, int s
155 155 const LIB3270_INT_PROPERTY * properties;
156 156  
157 157 if(seconds)
158   - {
159 158 lib3270_wait_for_ready(hSession, seconds);
160   - }
161 159  
162   - // Check for boolean properties
163   - properties = lib3270_get_boolean_properties_list();
  160 + // Check for INT Properties
  161 + properties = lib3270_get_int_properties_list();
164 162 for(ix = 0; properties[ix].name; ix++)
165 163 {
166 164 if(!strcasecmp(name,properties[ix].name))
167 165 {
168 166 if(properties[ix].set)
169   - {
170 167 return properties[ix].set(hSession, value);
171   - }
172 168 else
173   - {
174   - errno = EPERM;
175   - return -1;
176   - }
  169 + return errno = EPERM;
177 170 }
178 171  
179 172 }
180 173  
181   - // Check for INT Properties
182   - properties = lib3270_get_int_properties_list();
  174 + // Check for boolean properties
  175 + properties = lib3270_get_boolean_properties_list();
183 176 for(ix = 0; properties[ix].name; ix++)
184 177 {
185 178 if(!strcasecmp(name,properties[ix].name))
186 179 {
187 180 if(properties[ix].set)
188   - {
189 181 return properties[ix].set(hSession, value);
190   - }
191 182 else
192   - {
193   - errno = EPERM;
194   - return -1;
195   - }
  183 + return errno = EPERM;
196 184 }
197 185  
198 186 }
199 187  
200   - errno = ENOENT;
201   - return -1;
  188 + return errno = ENOENT;
202 189  
203 190 }
204 191  
... ...
src/core/properties/string.c
... ... @@ -224,8 +224,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char *
224 224 }
225 225 else
226 226 {
227   - errno = EPERM;
228   - return -1;
  227 + return errno = EPERM;
229 228 }
230 229 }
231 230  
... ... @@ -247,8 +246,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char *
247 246 }
248 247 else
249 248 {
250   - errno = EPERM;
251   - return -1;
  249 + return errno = EPERM;
252 250 }
253 251 }
254 252  
... ... @@ -270,8 +268,7 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char *
270 268 }
271 269 else
272 270 {
273   - errno = EPERM;
274   - return -1;
  271 + return errno = EPERM;
275 272 }
276 273 }
277 274  
... ... @@ -293,28 +290,17 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char *
293 290 }
294 291 else
295 292 {
296   - errno = EPERM;
297   - return -1;
  293 + return errno = EPERM;
298 294 }
299 295 }
300 296  
301 297 }
302 298 }
303 299  
304   - errno = ENOENT;
305   - return -1;
  300 + return errno = ENOENT;
306 301  
307 302 }
308 303  
309   -/*
310   -LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname)
311   -{
312   - FAIL_IF_ONLINE(hSession);
313   - strncpy(hSession->lu.names,luname,LIB3270_LUNAME_LENGTH);
314   - return 0;
315   -}
316   -*/
317   -
318 304 LIB3270_EXPORT int lib3270_set_lunames(H3270 *hSession, const char *lunames)
319 305 {
320 306 FAIL_IF_ONLINE(hSession);
... ...
src/core/properties/unsigned.c
... ... @@ -171,4 +171,30 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession)
171 171 return properties;
172 172 }
173 173  
  174 +int lib3270_set_uint_property(H3270 *hSession, const char *name, unsigned int value, int seconds)
  175 +{
  176 + size_t ix;
  177 + const LIB3270_UINT_PROPERTY * properties;
  178 +
  179 + if(seconds)
  180 + lib3270_wait_for_ready(hSession, seconds);
  181 +
  182 + // Check for INT Properties
  183 + properties = lib3270_get_unsigned_properties_list();
  184 +
  185 + for(ix = 0; properties[ix].name; ix++)
  186 + {
  187 + if(!strcasecmp(name,properties[ix].name))
  188 + {
  189 + if(properties[ix].set)
  190 + return properties[ix].set(hSession, value);
  191 + else
  192 + return errno = EPERM;
  193 + }
  194 +
  195 + }
  196 +
  197 + return errno = ENOENT;
  198 +
  199 +}
174 200  
... ...
src/include/lib3270/properties.h
... ... @@ -131,26 +131,62 @@
131 131 LIB3270_EXPORT int lib3270_get_int_property(H3270 * hSession, const char *name, int seconds);
132 132  
133 133 /**
134   - * @brief Set lib3270 integer property by name.
  134 + * @brief Set lib3270 signed int property by name.
135 135 *
136 136 * @param name Nome of the property.
137 137 * @param value New property value.
138 138 * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
139 139 *
140   - * @return 0 if ok, -1 in case of error (sets errno).
  140 + * @return 0 if ok error code if not (sets errno).
  141 + *
  142 + * @retval EPERM Property is ready only.
  143 + * @retval ENOENT Can't find a property with this name.
141 144 *
142 145 */
143 146 LIB3270_EXPORT int lib3270_set_int_property(H3270 * hSession, const char *name, int value, int seconds);
144 147  
145 148 /**
146   - * @brief Set lib3270 integer property by name.
  149 + * @brief Set lib3270 unsigned int property by name.
  150 + *
  151 + * @param name Nome of the property.
  152 + * @param value New property value.
  153 + * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
  154 + *
  155 + * @return 0 if ok error code if not (sets errno).
  156 + *
  157 + * @retval EPERM Property is ready only.
  158 + * @retval ENOENT Can't find a property with this name.
  159 + *
  160 + */
  161 + LIB3270_EXPORT int lib3270_set_uint_property(H3270 * hSession, const char *name, unsigned int value, int seconds);
  162 +
  163 + /**
  164 + * @brief Set lib3270 boolean property by name.
  165 + *
  166 + * @param name Nome of the property.
  167 + * @param value New property value.
  168 + * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
  169 + *
  170 + * @return 0 if ok error code if not (sets errno).
  171 + *
  172 + * @retval EPERM Property is ready only.
  173 + * @retval ENOENT Can't find a property with this name.
  174 + *
  175 + */
  176 + LIB3270_EXPORT int lib3270_set_boolean_property(H3270 * hSession, const char *name, int value, int seconds);
  177 +
  178 + /**
  179 + * @brief Set lib3270 string property by name.
147 180 *
148 181 * @param hSession Session handle.
149 182 * @param name Nome of the property.
150 183 * @param value New property value.
151 184 * @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
152 185 *
153   - * @return 0 if ok, -1 in case of error (sets errno).
  186 + * @return 0 if ok error code if not (sets errno).
  187 + *
  188 + * @retval EPERM Property is ready only.
  189 + * @retval ENOENT Can't find a property with this name.
154 190 *
155 191 */
156 192 LIB3270_EXPORT int lib3270_set_string_property(H3270 * hSession, const char *name, const char * value, int seconds);
... ...