diff options
author | darin%meer.net <devnull@localhost> | 2003-07-30 17:34:08 +0000 |
---|---|---|
committer | darin%meer.net <devnull@localhost> | 2003-07-30 17:34:08 +0000 |
commit | c812d5520643de3564e6450ef6ca026c6e8ffb7a (patch) | |
tree | 59bb24f797b9e00b3daf80d27c2f585651907e29 | |
parent | 8165ee6e209157f947116a8f5140c43e6661789e (diff) | |
download | nspr-hg-c812d5520643de3564e6450ef6ca026c6e8ffb7a.tar.gz |
interface changes:
1- make PR_GetAddrInfoByName return PRAddrInfo*
2- make PR_GetAddrInfoByName require af=PR_AF_UNSPEC and flags=PR_AI_ADDRCONFIG
3- define PR_AF_UNSPEC
-rw-r--r-- | pr/include/prio.h | 4 | ||||
-rw-r--r-- | pr/include/prnetdb.h | 20 | ||||
-rw-r--r-- | pr/src/misc/prnetdb.c | 48 |
3 files changed, 33 insertions, 39 deletions
diff --git a/pr/include/prio.h b/pr/include/prio.h index 42beca33..bb96c296 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -139,6 +139,10 @@ typedef enum PRTransmitFileFlags { #define PR_AF_INET6 100 #endif +#ifndef PR_AF_UNSPEC +#define PR_AF_UNSPEC 0 +#endif + /* ************************************************************************** ** A network address diff --git a/pr/include/prnetdb.h b/pr/include/prnetdb.h index ec97df82..a2456137 100644 --- a/pr/include/prnetdb.h +++ b/pr/include/prnetdb.h @@ -393,24 +393,20 @@ NSPR_API(PRStatus) PR_GetProtoByNumber( ** ** INPUTS: ** char *hostname Character string defining the host name of interest -** PRUint16 af Reserved for future use. Must pass zero. -** PRIntn flags Reserved for future use. Must pass zero. -** OUTPUTS: -** PRAddrInfo **result -** Handle to a data structure containing the results +** PRUint16 af Must be PR_AF_UNSPEC +** PRIntn flags Must be PR_AI_ADDRCONFIG +** RETURN: +** PRAddrInfo* Handle to a data structure containing the results ** of the host lookup. Use PR_EnumerateAddrInfo to ** inspect the PRNetAddr values stored in this object. ** When no longer needed, this handle must be destroyed -** with a call to PR_FreeAddrInfo. -** RETURN: -** PRStatus PR_SUCCESS if the lookup succeeds. If it fails -** the result will be PR_FAILURE and the reason for -** the failure can be retrieved by PR_GetError(). +** with a call to PR_FreeAddrInfo. If a lookup error +** occurs, then NULL will be returned. ***********************************************************************/ typedef struct PRAddrInfo PRAddrInfo; -NSPR_API(PRStatus) PR_GetAddrInfoByName( - const char *hostname, PRUint16 af, PRIntn flags, PRAddrInfo **result); +NSPR_API(PRAddrInfo*) PR_GetAddrInfoByName( + const char *hostname, PRUint16 af, PRIntn flags); /*********************************************************************** ** FUNCTION: diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c index 9c82e792..d84d4d0d 100644 --- a/pr/src/misc/prnetdb.c +++ b/pr/src/misc/prnetdb.c @@ -2030,11 +2030,10 @@ typedef struct PRAddrInfoFB { PRHostEnt hostent; } PRAddrInfoFB; -static PRStatus +static PRAddrInfo * pr_GetAddrInfoByNameFB(const char *hostname, PRUint16 af, - PRIntn flags, - PRAddrInfo **result) + PRIntn flags) { PRStatus rv; PRAddrInfoFB *ai; @@ -2042,37 +2041,34 @@ pr_GetAddrInfoByNameFB(const char *hostname, ai = PR_NEW(PRAddrInfoFB); if (!ai) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); - return PR_FAILURE; + return NULL; } rv = PR_GetHostByName(hostname, ai->buf, sizeof ai->buf, &ai->hostent); if (rv == PR_FAILURE) { PR_Free(ai); - *result = NULL; - } else { - *result = (PRAddrInfo *) ai; + return NULL; } - return rv; + return (PRAddrInfo *) ai; } -PRStatus PR_GetAddrInfoByName(const char *hostname, - PRUint16 af, - PRIntn flags, - PRAddrInfo **result) +PR_IMPLEMENT(PRAddrInfo *) PR_GetAddrInfoByName(const char *hostname, + PRUint16 af, + PRIntn flags) { /* restrict input to supported values */ - if (af != 0 || flags != 0) { + if (af != PR_AF_UNSPEC || flags != PR_AI_ADDRCONFIG) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); - return PR_FAILURE; + return NULL; } if (!_pr_initialized) _PR_ImplicitInitialization(); #if !defined(_PR_HAVE_GETADDRINFO) - return pr_GetAddrInfoByNameFB(hostname, af, flags, result); + return pr_GetAddrInfoByNameFB(hostname, af, flags); #else #if defined(_PR_INET6_PROBE) if (!_pr_ipv6_is_present) { - return pr_GetAddrInfoByNameFB(hostname, af, flags, result); + return pr_GetAddrInfoByNameFB(hostname, af, flags); } #endif { @@ -2091,18 +2087,16 @@ PRStatus PR_GetAddrInfoByName(const char *hostname, #endif rv = GETADDRINFO(hostname, NULL, &hints, &res); + if (rv == 0) + return (PRAddrInfo *) res; - if (rv == 0) { - *result = (PRAddrInfo *) res; - return PR_SUCCESS; - } PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, rv); } - return PR_FAILURE; + return NULL; #endif } -void PR_FreeAddrInfo(PRAddrInfo *ai) +PR_IMPLEMENT(void) PR_FreeAddrInfo(PRAddrInfo *ai) { #if defined(_PR_HAVE_GETADDRINFO) #if defined(_PR_INET6_PROBE) @@ -2116,10 +2110,10 @@ void PR_FreeAddrInfo(PRAddrInfo *ai) #endif } -void *PR_EnumerateAddrInfo(void *iterPtr, - const PRAddrInfo *base, - PRUint16 port, - PRNetAddr *result) +PR_IMPLEMENT(void *) PR_EnumerateAddrInfo(void *iterPtr, + const PRAddrInfo *base, + PRUint16 port, + PRNetAddr *result) { #if defined(_PR_HAVE_GETADDRINFO) PRADDRINFO *ai; @@ -2160,7 +2154,7 @@ void *PR_EnumerateAddrInfo(void *iterPtr, #endif } -const char *PR_GetCanonNameFromAddrInfo(const PRAddrInfo *ai) +PR_IMPLEMENT(const char *) PR_GetCanonNameFromAddrInfo(const PRAddrInfo *ai) { #if defined(_PR_HAVE_GETADDRINFO) #if defined(_PR_INET6_PROBE) |