version 1.4, 2001/07/09 22:03:18
|
version 1.5, 2001/07/16 22:28:06
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include "slp.h" | #include "slp.h" |
| |
|
#ifdef PEGASUS_OS_TRU64 |
|
# include <unistd.h> |
|
extern "C" void usleep(unsigned int); |
|
#endif |
|
|
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
| |
#endif | #endif |
| |
#ifdef PEGASUS_OS_HPUX |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_TRU64) |
| |
PEGASUS_EXPORT int gethostbyname_r(const char *name, | PEGASUS_EXPORT int gethostbyname_r(const char *name, |
struct hostent *resultbuf, | struct hostent *resultbuf, |
|
|
} | } |
return(0); | return(0); |
} | } |
|
|
#endif | #endif |
| |
PEGASUS_EXPORT void slp_get_addr_string_from_url(const Sint8 *url, String &addr) | PEGASUS_EXPORT void slp_get_addr_string_from_url(const Sint8 *url, String &addr) |
|
|
#ifdef _WIN32 | #ifdef _WIN32 |
_snprintf(name, 254, "%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port) ); | _snprintf(name, 254, "%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port) ); |
#else | #else |
|
|
|
// ATTN: Mike Brasher: Hack to get built of TRU64: |
|
#ifdef PEGASUS_OS_TRU64 |
|
sprintf(name, "%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port) ); |
|
#else |
snprintf(name, 254, "%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port) ); | snprintf(name, 254, "%s:%d", inet_ntoa(a.sin_addr), ntohs(a.sin_port) ); |
#endif | #endif |
|
|
|
#endif |
addr.clear(); | addr.clear(); |
addr = name; | addr = name; |
delete [] name; | delete [] name; |
|
|
temp = (Uint8 *)malloc(hostbuflen); | temp = (Uint8 *)malloc(hostbuflen); |
if(temp != NULL) { | if(temp != NULL) { |
host = NULL; | host = NULL; |
while(temp != NULL && (result = gethostbyname_r(bptr, &hostbuf, (char *)temp, hostbuflen, |
while(temp != NULL && (result = gethostbyname_r(bptr, &hostbuf, |
|
(char *)temp, |
|
hostbuflen, |
&host, (int *)&err)) == ERANGE){ | &host, (int *)&err)) == ERANGE){ |
hostbuflen *= 2; | hostbuflen *= 2; |
temp = (Uint8 *)realloc(temp, hostbuflen); | temp = (Uint8 *)realloc(temp, hostbuflen); |
|
|
if( init == NULL ) | if( init == NULL ) |
_cur = _next; | _cur = _next; |
else { | else { |
assert( init = _cur->_rep ); |
assert( (init = _cur->_rep) != 0 ); |
_cur = _cur->_next; | _cur = _cur->_next; |
} | } |
return(_cur->_rep); | return(_cur->_rep); |
|
|
if(rcv > 0) | if(rcv > 0) |
if(one_only == true) | if(one_only == true) |
return(rcv); | return(rcv); |
|
|
|
#ifdef PEGASUS_OS_TRU64 |
|
usleep(10 * 1000); |
|
#else |
_LSLP_SLEEP(10); | _LSLP_SLEEP(10); |
|
#endif |
} | } |
rcv += service_listener(extra_sock); | rcv += service_listener(extra_sock); |
return(rcv); | return(rcv); |
|
|
if( 0 < err ) { | if( 0 < err ) { |
struct sockaddr_in remote; | struct sockaddr_in remote; |
| |
#ifdef PEGASUS_OS_HPUX |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_TRU64) |
int size = sizeof(remote); | int size = sizeof(remote); |
#else | #else |
socklen_t size = sizeof(remote); | socklen_t size = sizeof(remote); |