Commit e78760681ebc7c453f98930112e7f8c200f3049d
1 parent
73f75e3f
Exists in
master
and in
3 other branches
Updating method for get/set URL.
Showing
4 changed files
with
18 additions
and
17 deletions
Show diff stats
.gitignore
src/include/lib3270.h
| ... | ... | @@ -459,10 +459,10 @@ |
| 459 | 459 | * @param h Session handle. |
| 460 | 460 | * @param url URL of host to set in the format tn3270://hostname:service or tn3270s://hostname:service . |
| 461 | 461 | * |
| 462 | - * @return Processed host url | |
| 462 | + * @return 0 | |
| 463 | 463 | * |
| 464 | 464 | */ |
| 465 | - LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *url); | |
| 465 | + LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *url); | |
| 466 | 466 | |
| 467 | 467 | /** |
| 468 | 468 | * @brief Get hostname for the connect/reconnect operations. |
| ... | ... | @@ -489,7 +489,13 @@ |
| 489 | 489 | |
| 490 | 490 | LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc); |
| 491 | 491 | |
| 492 | - LIB3270_EXPORT const char * lib3270_get_url(H3270 *h, char *buffer, int len); | |
| 492 | + /** | |
| 493 | + * @brief Get HOST URL. | |
| 494 | + * | |
| 495 | + * @return TN3270 Connection URL. | |
| 496 | + * | |
| 497 | + */ | |
| 498 | + LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession); | |
| 493 | 499 | |
| 494 | 500 | /** |
| 495 | 501 | * @brief Get session options. | ... | ... |
src/lib3270/host.c
| ... | ... | @@ -169,6 +169,7 @@ LIB3270_EXPORT void lib3270_register_schange(H3270 *h, LIB3270_STATE tx, void (* |
| 169 | 169 | |
| 170 | 170 | st = (struct lib3270_state_callback *) lib3270_malloc(sizeof(struct lib3270_state_callback)); |
| 171 | 171 | st->func = func; |
| 172 | + st->data = data; | |
| 172 | 173 | |
| 173 | 174 | if (h->st_last[tx]) |
| 174 | 175 | h->st_last[tx]->next = st; |
| ... | ... | @@ -231,20 +232,13 @@ static void update_host(H3270 *h) |
| 231 | 232 | |
| 232 | 233 | } |
| 233 | 234 | |
| 234 | -LIB3270_EXPORT const char * lib3270_get_url(H3270 *h, char *buffer, int len) | |
| 235 | +LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) | |
| 235 | 236 | { |
| 236 | - CHECK_SESSION_HANDLE(h); | |
| 237 | - | |
| 238 | - snprintf(buffer,len,"%s://%s:%s", | |
| 239 | - ((h->options & LIB3270_OPTION_SSL) == 0) ? "tn3270" : "tn3270s", | |
| 240 | - h->host.current, | |
| 241 | - h->host.srvc | |
| 242 | - ); | |
| 243 | - | |
| 244 | - return buffer; | |
| 237 | + CHECK_SESSION_HANDLE(hSession); | |
| 238 | + return hSession->host.full; | |
| 245 | 239 | } |
| 246 | 240 | |
| 247 | -LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) | |
| 241 | +LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) | |
| 248 | 242 | { |
| 249 | 243 | CHECK_SESSION_HANDLE(h); |
| 250 | 244 | |
| ... | ... | @@ -289,7 +283,7 @@ LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) |
| 289 | 283 | } |
| 290 | 284 | |
| 291 | 285 | if(!*hostname) |
| 292 | - return h->host.current; | |
| 286 | + return 0; | |
| 293 | 287 | |
| 294 | 288 | ptr = strchr(hostname,':'); |
| 295 | 289 | if(ptr) |
| ... | ... | @@ -353,7 +347,7 @@ LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) |
| 353 | 347 | free(str); |
| 354 | 348 | } |
| 355 | 349 | |
| 356 | - return h->host.current; | |
| 350 | + return 0; | |
| 357 | 351 | } |
| 358 | 352 | |
| 359 | 353 | LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) | ... | ... |
src/lib3270/testprogram/testprogram.c
| ... | ... | @@ -22,7 +22,7 @@ int main(int numpar, char *param[]) |
| 22 | 22 | lib3270_set_url(h,url ? url : "tn3270://fandezhi.efglobe.com"); |
| 23 | 23 | rc = lib3270_connect(h,120); |
| 24 | 24 | |
| 25 | - printf("\nConnect exits with rc=%d\n",rc); | |
| 25 | + printf("\nConnect %s exits with rc=%d\n",lib3270_get_url(h),rc); | |
| 26 | 26 | |
| 27 | 27 | lib3270_wait_for_ready(h,10); |
| 28 | 28 | ... | ... |