- Timestamp:
- 2007-10-18T19:03:02Z (17 years ago)
- Branches:
- master
- Children:
- 2231302
- Parents:
- e9b755e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
re9b755e r7435ccf 46 46 irc_t *irc; 47 47 struct sockaddr_storage sock; 48 socklen_t socklen = sizeof( sock);48 socklen_t socklen = sizeof( sock ); 49 49 50 50 irc = g_new0( irc_t, 1 ); … … 67 67 if( global.conf->hostname ) 68 68 irc->myhost = g_strdup( global.conf->hostname ); 69 else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )70 { 71 irc->myhost = g_new0( char, NI_MAXHOST);72 73 if (getnameinfo( (struct sockaddr *)&sock, socklen, irc->myhost,74 NI_MAXHOST, NULL, -1, 0) ) {69 else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) 70 { 71 irc->myhost = g_new0( char, NI_MAXHOST ); 72 73 if (getnameinfo( (struct sockaddr *) &sock, socklen, irc->myhost, 74 NI_MAXHOST, NULL, -1, 0) ) { 75 75 /* Rare, but possible. */ 76 strncpy( irc->myhost, "localhost.", NI_MAXHOST);77 } 78 } 79 80 if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )81 { 82 irc->host = g_new0( char, NI_MAXHOST);83 84 if ( getnameinfo((struct sockaddr *)&sock, socklen, irc->host,85 NI_MAXHOST, NULL, -1, 0 )) {76 strncpy( irc->myhost, "localhost.", NI_MAXHOST ); 77 } 78 } 79 80 if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) 81 { 82 irc->host = g_new0( char, NI_MAXHOST ); 83 84 if ( getnameinfo( (struct sockaddr *)&sock, socklen, irc->host, 85 NI_MAXHOST, NULL, -1, 0 ) ) { 86 86 /* Rare, but possible. */ 87 strncpy( irc->myhost, "localhost.", NI_MAXHOST);87 strncpy( irc->myhost, "localhost.", NI_MAXHOST ); 88 88 } 89 89 }
Note: See TracChangeset
for help on using the changeset viewer.