From 0b2a74c32c0c2cbd0d8ea054dd23d1dacf171939 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 10 Mar 2014 17:34:24 +0000 Subject: [PATCH] Incluindo opção para incluir o nome da LU na URL de conexão --- src/include/lib3270/session.h | 1 - src/lib3270/host.c | 33 +++++++++++++++++++++++++++++++++ src/lib3270/telnet.c | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index f96e125..10889cc 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -126,7 +126,6 @@ } toggle[LIB3270_TOGGLE_COUNT]; // Network & Termtype -// char * hostname; char * connected_type; char * connected_lu; char luname[LIB3270_LUNAME_LENGTH+1]; diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 3f86d31..0d4d3f7 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -573,6 +573,39 @@ LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) Replace(h->host.current,strdup(hostname)); Replace(h->host.srvc,strdup(srvc)); + // Verifica parâmetros + if(query && *query) + { + char *str = strdup(query); + char *saveptr = NULL; + char *ptr; + + for(ptr = strtok_r(str,"&",&saveptr);ptr;ptr=strtok_r(NULL,"&",&saveptr)) + { + char *var = ptr; + char *val = strchr(ptr,'='); + if(val) + { + *(val++) = 0; + + if(!(strcasecmp(var,"lu") && strcasecmp(var,"luname"))) + { + strncpy(h->luname,val,LIB3270_LUNAME_LENGTH); + } + else + { + lib3270_write_log(h,"","Ignoring invalid URL attribute \"%s\"",var); + } + + + } + + } + + free(str); + } + + // Notifica atualização update_host(h); free(str); diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 829f0ee..299fd4d 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -1441,7 +1441,7 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) if (hSession->lus != (char **)NULL && hSession->try_lu == CN) { /* None of the LUs worked. */ - popup_an_error(NULL,"Cannot connect to specified LU"); + popup_an_error(hSession, _( "Cannot connect to specified LU" ) ); return -1; } -- libgit2 0.21.2