Commit fef61d68e973e76788c8cb354e4906ba37b52f09
1 parent
9fac04ff
Exists in
master
and in
3 other branches
Incluindo métodos para obter informações da conexão ativa.
Showing
1 changed file
with
31 additions
and
1 deletions
Show diff stats
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 | + } |