Commit 2be8012abe9f2e706593fba960d377ab46cd4a3c
1 parent
545d9579
Exists in
master
and in
3 other branches
+ Adding "set_luname" method.
Showing
4 changed files
with
36 additions
and
4 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -862,7 +862,9 @@ |
862 | 862 | * @return conected LU name or NULL if not connected. |
863 | 863 | * |
864 | 864 | */ |
865 | - LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); | |
865 | + LIB3270_EXPORT const char * lib3270_get_luname(H3270 *hSession); | |
866 | + | |
867 | + LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname); | |
866 | 868 | |
867 | 869 | LIB3270_EXPORT int lib3270_has_active_script(H3270 *h); |
868 | 870 | LIB3270_EXPORT int lib3270_get_typeahead(H3270 *h); | ... | ... |
src/lib3270/host.c
... | ... | @@ -238,9 +238,16 @@ LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) |
238 | 238 | return hSession->host.full; |
239 | 239 | } |
240 | 240 | |
241 | +LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) | |
242 | +{ | |
243 | + FAIL_IF_ONLINE(hSession); | |
244 | + strncpy(hSession->luname,luname,LIB3270_LUNAME_LENGTH); | |
245 | + return 0; | |
246 | +} | |
247 | + | |
241 | 248 | LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
242 | 249 | { |
243 | - CHECK_SESSION_HANDLE(h); | |
250 | + FAIL_IF_ONLINE(h); | |
244 | 251 | |
245 | 252 | if(n && n != h->host.full) |
246 | 253 | { |
... | ... | @@ -326,14 +333,14 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
326 | 333 | |
327 | 334 | if(!(strcasecmp(var,"lu") && strcasecmp(var,"luname"))) |
328 | 335 | { |
329 | - strncpy(h->luname,val,LIB3270_LUNAME_LENGTH); | |
336 | + lib3270_set_luname(h, val); | |
337 | + // strncpy(h->luname,val,LIB3270_LUNAME_LENGTH); | |
330 | 338 | } |
331 | 339 | else |
332 | 340 | { |
333 | 341 | lib3270_write_log(h,"","Ignoring invalid URL attribute \"%s\"",var); |
334 | 342 | } |
335 | 343 | |
336 | - | |
337 | 344 | } |
338 | 345 | |
339 | 346 | } | ... | ... |
src/lib3270/private.h
... | ... | @@ -637,10 +637,14 @@ LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block |
637 | 637 | #endif // DEBUG |
638 | 638 | |
639 | 639 | LIB3270_INTERNAL int check_online_session(H3270 *hSession); |
640 | +LIB3270_INTERNAL int check_offline_session(H3270 *hSession); | |
640 | 641 | |
641 | 642 | /// @brief Returns -1 if the session is invalid or not online (sets errno). |
642 | 643 | #define FAIL_IF_NOT_ONLINE(x) if(check_online_session(x)) return -1; |
643 | 644 | |
645 | +/// @brief Returns -1 if the session is invalid or online (sets errno). | |
646 | +#define FAIL_IF_ONLINE(x) if(check_offline_session(x)) return -1; | |
647 | + | |
644 | 648 | LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); |
645 | 649 | |
646 | 650 | #if defined(HAVE_LIBSSL) /*[*/ | ... | ... |
src/lib3270/session.c
... | ... | @@ -408,6 +408,25 @@ LIB3270_INTERNAL int check_online_session(H3270 *hSession) { |
408 | 408 | return 0; |
409 | 409 | } |
410 | 410 | |
411 | +LIB3270_INTERNAL int check_offline_session(H3270 *hSession) { | |
412 | + | |
413 | + // Is the session valid? | |
414 | + if(!hSession) | |
415 | + { | |
416 | + errno = EINVAL; | |
417 | + return -1; | |
418 | + } | |
419 | + | |
420 | + // Is it connected? | |
421 | + if((int) hSession->cstate >= (int)LIB3270_CONNECTED_INITIAL) | |
422 | + { | |
423 | + errno = EBUSY; | |
424 | + return -1; | |
425 | + } | |
426 | + | |
427 | + return 0; | |
428 | +} | |
429 | + | |
411 | 430 | LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void) |
412 | 431 | { |
413 | 432 | if(default_session) | ... | ... |