Commit e59a573a7d814c1a5ef73417231e7003dad9c663
1 parent
c3d86fdc
Exists in
master
and in
5 other branches
Incluindo métodos para obter informações da conexão ativa.
Showing
3 changed files
with
34 additions
and
2 deletions
Show diff stats
src/include/lib3270.h
| @@ -1133,7 +1133,6 @@ | @@ -1133,7 +1133,6 @@ | ||
| 1133 | 1133 | ||
| 1134 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr); | 1134 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr); |
| 1135 | 1135 | ||
| 1136 | - | ||
| 1137 | /** | 1136 | /** |
| 1138 | * The host is TSO? | 1137 | * The host is TSO? |
| 1139 | * | 1138 | * |
src/include/lib3270/session.h
| @@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
| 31 | 31 | ||
| 32 | #define LIB3270_SESSION_H_INCLUDED 1 | 32 | #define LIB3270_SESSION_H_INCLUDED 1 |
| 33 | 33 | ||
| 34 | + #include <sys/socket.h> | ||
| 34 | #include <lib3270/popup.h> | 35 | #include <lib3270/popup.h> |
| 35 | 36 | ||
| 36 | struct lib3270_session_callbacks | 37 | struct lib3270_session_callbacks |
| @@ -78,6 +79,8 @@ | @@ -78,6 +79,8 @@ | ||
| 78 | */ | 79 | */ |
| 79 | int LIB3270_EXPORT lib3270_set_session_callbacks(const struct lib3270_callbacks *cbk); | 80 | int LIB3270_EXPORT lib3270_set_session_callbacks(const struct lib3270_callbacks *cbk); |
| 80 | 81 | ||
| 82 | + LIB3270_EXPORT int lib3270_getpeername(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen); | ||
| 83 | + LIB3270_EXPORT int lib3270_getsockname(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen); | ||
| 81 | 84 | ||
| 82 | LIB3270_EXPORT struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *session, unsigned short sz); | 85 | LIB3270_EXPORT struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *session, unsigned short sz); |
| 83 | 86 |
src/lib3270/util.c
| @@ -75,11 +75,12 @@ | @@ -75,11 +75,12 @@ | ||
| 75 | #include "utilc.h" | 75 | #include "utilc.h" |
| 76 | #include "popupsc.h" | 76 | #include "popupsc.h" |
| 77 | #include "api.h" | 77 | #include "api.h" |
| 78 | + | ||
| 79 | +#include <lib3270/session.h> | ||
| 78 | #include <lib3270/selection.h> | 80 | #include <lib3270/selection.h> |
| 79 | 81 | ||
| 80 | #define my_isspace(c) isspace((unsigned char)c) | 82 | #define my_isspace(c) isspace((unsigned char)c) |
| 81 | 83 | ||
| 82 | - | ||
| 83 | #if defined(_WIN32) | 84 | #if defined(_WIN32) |
| 84 | 85 | ||
| 85 | int is_nt = 1; | 86 | int is_nt = 1; |
| @@ -1048,3 +1049,32 @@ int gettimeofday(struct timeval *tv, void *ignored) | @@ -1048,3 +1049,32 @@ int gettimeofday(struct timeval *tv, void *ignored) | ||
| 1048 | return hSession->pointer; | 1049 | return hSession->pointer; |
| 1049 | 1050 | ||
| 1050 | } | 1051 | } |
| 1052 | + | ||
| 1053 | + LIB3270_EXPORT int lib3270_getpeername(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) | ||
| 1054 | + { | ||
| 1055 | + CHECK_SESSION_HANDLE(hSession); | ||
| 1056 | + | ||
| 1057 | + memset(addr,0,*addrlen); | ||
| 1058 | + | ||
| 1059 | + if(hSession->sock < 0) { | ||
| 1060 | + errno = ENOTCONN; | ||
| 1061 | + return -1; | ||
| 1062 | + } | ||
| 1063 | + | ||
| 1064 | + return getpeername(hSession->sock, addr, addrlen); | ||
| 1065 | + | ||
| 1066 | + } | ||
| 1067 | + | ||
| 1068 | + LIB3270_EXPORT int lib3270_getsockname(H3270 *hSession, struct sockaddr *addr, socklen_t *addrlen) | ||
| 1069 | + { | ||
| 1070 | + CHECK_SESSION_HANDLE(hSession); | ||
| 1071 | + | ||
| 1072 | + memset(addr,0,*addrlen); | ||
| 1073 | + | ||
| 1074 | + if(hSession->sock < 0) { | ||
| 1075 | + errno = ENOTCONN; | ||
| 1076 | + return -1; | ||
| 1077 | + } | ||
| 1078 | + | ||
| 1079 | + return getsockname(hSession->sock, addr, addrlen); | ||
| 1080 | + } |