Commit d58165ff939d2add1d8a435e52948a97273c102c
1 parent
8321dde6
Exists in
master
and in
3 other branches
Fixing windows build.
Showing
2 changed files
with
16 additions
and
30 deletions
Show diff stats
src/core/iocalls.c
| @@ -531,7 +531,7 @@ int non_blocking(H3270 *hSession, Boolean on) | @@ -531,7 +531,7 @@ int non_blocking(H3270 *hSession, Boolean on) | ||
| 531 | WSASetLastError(0); | 531 | WSASetLastError(0); |
| 532 | u_long iMode= on ? 1 : 0; | 532 | u_long iMode= on ? 1 : 0; |
| 533 | 533 | ||
| 534 | - if(ioctlsocket(hSession->sock,FIONBIO,&iMode)) | 534 | + if(ioctlsocket(hSession->connection.sock,FIONBIO,&iMode)) |
| 535 | { | 535 | { |
| 536 | lib3270_popup_dialog( hSession, | 536 | lib3270_popup_dialog( hSession, |
| 537 | LIB3270_NOTIFY_ERROR, | 537 | LIB3270_NOTIFY_ERROR, |
src/core/windows/connect.c
| @@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
| 47 | #include <iconv.h> | 47 | #include <iconv.h> |
| 48 | #endif // HAVE_ICONV | 48 | #endif // HAVE_ICONV |
| 49 | 49 | ||
| 50 | -#define SOCK_CLOSE(s) closesocket(s->sock); s->sock = -1; | 50 | +#define SOCK_CLOSE(s) closesocket(s->connection.sock); s->connection.sock = -1; |
| 51 | 51 | ||
| 52 | #include "hostc.h" | 52 | #include "hostc.h" |
| 53 | #include "trace_dsc.h" | 53 | #include "trace_dsc.h" |
| @@ -70,7 +70,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | @@ -70,7 +70,7 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | ||
| 70 | hSession->xio.write = NULL; | 70 | hSession->xio.write = NULL; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | - if(getsockopt(hSession->sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) | 73 | + if(getsockopt(hSession->connection.sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) |
| 74 | { | 74 | { |
| 75 | lib3270_disconnect(hSession); | 75 | lib3270_disconnect(hSession); |
| 76 | lib3270_popup_dialog( hSession, | 76 | lib3270_popup_dialog( hSession, |
| @@ -97,8 +97,8 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | @@ -97,8 +97,8 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | ||
| 97 | return; | 97 | return; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); | ||
| 101 | - hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_READ,net_input,0); | 100 | + hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); |
| 101 | + hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_READ,net_input,0); | ||
| 102 | 102 | ||
| 103 | #if defined(HAVE_LIBSSL) | 103 | #if defined(HAVE_LIBSSL) |
| 104 | if(hSession->ssl.con && hSession->ssl.state == LIB3270_SSL_UNDEFINED) | 104 | if(hSession->ssl.con && hSession->ssl.state == LIB3270_SSL_UNDEFINED) |
| @@ -187,10 +187,10 @@ static void sockstart(H3270 *session) | @@ -187,10 +187,10 @@ static void sockstart(H3270 *session) | ||
| 187 | 187 | ||
| 188 | status_connecting(hSession); | 188 | status_connecting(hSession); |
| 189 | 189 | ||
| 190 | - for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next) | 190 | + for(rp = result; hSession->connection.sock < 0 && rp != NULL; rp = rp->ai_next) |
| 191 | { | 191 | { |
| 192 | - hSession->sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); | ||
| 193 | - if(hSession->sock < 0) | 192 | + hSession->connection.sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); |
| 193 | + if(hSession->connection.sock < 0) | ||
| 194 | { | 194 | { |
| 195 | ((struct resolver *) host)->rc = errno; | 195 | ((struct resolver *) host)->rc = errno; |
| 196 | ((struct resolver *) host)->message = strerror(errno); | 196 | ((struct resolver *) host)->message = strerror(errno); |
| @@ -198,7 +198,7 @@ static void sockstart(H3270 *session) | @@ -198,7 +198,7 @@ static void sockstart(H3270 *session) | ||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | // Connected! | 200 | // Connected! |
| 201 | - if(connect(hSession->sock, rp->ai_addr, rp->ai_addrlen)) | 201 | + if(connect(hSession->connection.sock, rp->ai_addr, rp->ai_addrlen)) |
| 202 | { | 202 | { |
| 203 | SOCK_CLOSE(hSession); | 203 | SOCK_CLOSE(hSession); |
| 204 | ((struct resolver *) host)->rc = errno; | 204 | ((struct resolver *) host)->rc = errno; |
| @@ -222,7 +222,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -222,7 +222,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 222 | 222 | ||
| 223 | sockstart(hSession); | 223 | sockstart(hSession); |
| 224 | 224 | ||
| 225 | - if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) | 225 | + if(lib3270_run_task(hSession, background_connect, &host) || hSession->connection.sock < 0) |
| 226 | { | 226 | { |
| 227 | lib3270_autoptr(char) message = lib3270_strdup_printf(_( "Can't connect to %s"), lib3270_get_url(hSession)); | 227 | lib3270_autoptr(char) message = lib3270_strdup_printf(_( "Can't connect to %s"), lib3270_get_url(hSession)); |
| 228 | 228 | ||
| @@ -326,7 +326,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -326,7 +326,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 326 | WSASetLastError(0); | 326 | WSASetLastError(0); |
| 327 | 327 | ||
| 328 | int optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | 328 | int optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; |
| 329 | - if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) | 329 | + if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) |
| 330 | { | 330 | { |
| 331 | char buffer[4096]; | 331 | char buffer[4096]; |
| 332 | snprintf(buffer,4095,N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); | 332 | snprintf(buffer,4095,N_( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); |
| @@ -345,7 +345,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -345,7 +345,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | optval = 1; | 347 | optval = 1; |
| 348 | - if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) | 348 | + if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) |
| 349 | { | 349 | { |
| 350 | lib3270_popup_dialog( hSession, | 350 | lib3270_popup_dialog( hSession, |
| 351 | LIB3270_NOTIFY_ERROR, | 351 | LIB3270_NOTIFY_ERROR, |
| @@ -356,25 +356,11 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -356,25 +356,11 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 356 | return errno = ENOTCONN; | 356 | return errno = ENOTCONN; |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | - // set options for inline out-of-band data and keepalives | ||
| 360 | - | ||
| 361 | - /* | ||
| 362 | -#if defined(OMTU) | ||
| 363 | - else if (setsockopt(hSession->sock, SOL_SOCKET, SO_SNDBUF, (char *)&mtu,sizeof(mtu)) < 0) | ||
| 364 | - { | ||
| 365 | - popup_a_sockerr(hSession, N_( "setsockopt(%s)" ), "SO_SNDBUF"); | ||
| 366 | - SOCK_CLOSE(hSession); | ||
| 367 | - } | ||
| 368 | -#endif | ||
| 369 | - | ||
| 370 | - */ | ||
| 371 | - | ||
| 372 | // Connecting, set callbacks, wait for connection | 359 | // Connecting, set callbacks, wait for connection |
| 373 | - hSession->cstate = LIB3270_PENDING; | 360 | + lib3270_set_cstate(hSession, LIB3270_PENDING); |
| 374 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); | 361 | lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); |
| 375 | 362 | ||
| 376 | - hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_WRITE,net_connected,0); | ||
| 377 | - // hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); | 363 | + hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_WRITE,net_connected,0); |
| 378 | 364 | ||
| 379 | trace("%s: Connection in progress",__FUNCTION__); | 365 | trace("%s: Connection in progress",__FUNCTION__); |
| 380 | 366 | ||
| @@ -386,7 +372,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -386,7 +372,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 386 | { | 372 | { |
| 387 | lib3270_main_iterate(hSession,1); | 373 | lib3270_main_iterate(hSession,1); |
| 388 | 374 | ||
| 389 | - switch(hSession->cstate) | 375 | + switch(hSession->connection.state) |
| 390 | { | 376 | { |
| 391 | case LIB3270_PENDING: | 377 | case LIB3270_PENDING: |
| 392 | case LIB3270_CONNECTED_INITIAL: | 378 | case LIB3270_CONNECTED_INITIAL: |
| @@ -405,7 +391,7 @@ int net_reconnect(H3270 *hSession, int seconds) | @@ -405,7 +391,7 @@ int net_reconnect(H3270 *hSession, int seconds) | ||
| 405 | return 0; | 391 | return 0; |
| 406 | 392 | ||
| 407 | default: | 393 | default: |
| 408 | - lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->cstate); | 394 | + lib3270_write_log(hSession,"connect", "%s: State changed to unexpected state %d",__FUNCTION__,hSession->connection.state); |
| 409 | return -1; | 395 | return -1; |
| 410 | } | 396 | } |
| 411 | 397 |