version 1.1, 2018/09/19 05:45:08 |
version 1.5, 2021/03/24 14:03:09 |
|
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2018/io/sio.c,v 1.4 2020/10/06 06:31:20 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include <setjmp.h> |
#include <setjmp.h> |
Line 79 struct IOFP iofp[MAXIOFP]; |
|
Line 79 struct IOFP iofp[MAXIOFP]; |
|
|
|
void init_socket(void); |
void init_socket(void); |
|
|
|
#if defined(VISUAL) |
|
typedef int socklen_t; |
|
#endif |
#if !defined(VISUAL) && !defined(__MINGW32__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
#define closesocket(s) (close((s))) |
#define closesocket(s) (close((s))) |
#endif |
#endif |
Line 95 void getremotename(int s,char *name) |
|
Line 98 void getremotename(int s,char *name) |
|
int peerlen; |
int peerlen; |
|
|
peerlen = sizeof(peer); |
peerlen = sizeof(peer); |
getpeername(getremotesocket(s),(struct sockaddr *)&peer,&peerlen); |
getpeername(getremotesocket(s),(struct sockaddr *)&peer,(socklen_t *)&peerlen); |
hp = gethostbyaddr((char *)&peer.sin_addr,sizeof(struct in_addr),AF_INET); |
hp = gethostbyaddr((char *)&peer.sin_addr,sizeof(struct in_addr),AF_INET); |
if ( hp ) |
if ( hp ) |
strcpy(name,hp->h_name); |
strcpy(name,hp->h_name); |
Line 109 void generate_port(int use_unix,char *port_str) |
|
Line 112 void generate_port(int use_unix,char *port_str) |
|
unsigned long mt_genrand(); |
unsigned long mt_genrand(); |
unsigned int port; |
unsigned int port; |
static int count=0; |
static int count=0; |
|
int fd; |
|
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( use_unix ) { |
if ( use_unix ) { |
|
#if defined(ANDROID) |
|
sprintf(port_str,"/data/data/com.termux/files/usr/tmp/ox%02x.XXXXXX",count); |
|
#else |
sprintf(port_str,"/tmp/ox%02x.XXXXXX",count); |
sprintf(port_str,"/tmp/ox%02x.XXXXXX",count); |
|
#endif |
count++; |
count++; |
mktemp(port_str); |
fd = mkstemp(port_str); |
|
unlink(port_str); |
} else |
} else |
#endif |
#endif |
{ |
{ |
Line 166 int try_bind_listen(int use_unix,char *port_str) |
|
Line 175 int try_bind_listen(int use_unix,char *port_str) |
|
closesocket(service); |
closesocket(service); |
return -1; |
return -1; |
} |
} |
if (getsockname(service,saddr, &len) < 0) { |
if (getsockname(service,saddr, (socklen_t *)&len) < 0) { |
perror("in getsockname"); |
perror("in getsockname"); |
closesocket(service); |
closesocket(service); |
return -1; |
return -1; |
Line 203 int try_accept(int af_unix,int s) |
|
Line 212 int try_accept(int af_unix,int s) |
|
if ( af_unix ) { |
if ( af_unix ) { |
len = sizeof(s_un); |
len = sizeof(s_un); |
for ( c = -1, i = 0; (c < 0)&&(i = 10) ; i++ ) |
for ( c = -1, i = 0; (c < 0)&&(i = 10) ; i++ ) |
c = accept(s, (struct sockaddr *) &s_un, &len); |
c = accept(s, (struct sockaddr *) &s_un, (socklen_t *)&len); |
} else |
} else |
#endif |
#endif |
{ |
{ |
|
|
len = sizeof(sin); |
len = sizeof(sin); |
for ( c = -1, i = 0; (c < 0)&&(i = 10) ; i++ ) |
for ( c = -1, i = 0; (c < 0)&&(i = 10) ; i++ ) |
c = accept(s, (struct sockaddr *) &sin, &len); |
c = accept(s, (struct sockaddr *) &sin, (socklen_t *)&len); |
} |
} |
if ( i == 10 ) |
if ( i == 10 ) |
c = -1; |
c = -1; |