httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/network_io/beos sockopt.c
Date Fri, 03 Nov 2000 19:24:20 GMT
dreid       00/11/03 11:24:18

  Modified:    src/lib/apr/include apr_network_io.h
               src/lib/apr/network_io/unix sockopt.c
               src/lib/apr/network_io/beos sockopt.c
  Log:
  I'm not sure I really like this as it smacks of code duplication with
  apr_get_remote_hostname, so maybe they should be combined?  Anyway, I haven't
  added the function to Win32/OS2 as I can't test there, but it shouldn't
  be hard!
  
  Once all platforms have this we can remove another of the raw sockaddr
  references in http_core.
  
  Revision  Changes    Path
  1.60      +7 -0      apache-2.0/src/lib/apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- apr_network_io.h	2000/11/03 18:04:59	1.59
  +++ apr_network_io.h	2000/11/03 19:24:05	1.60
  @@ -222,6 +222,13 @@
   apr_status_t apr_get_remote_hostname(char **name, apr_socket_t *sock);
   
   /**
  + * Get name of the local machine via it's ip address.
  + * @param name A buffer to store the hostname in.
  + * @param sock The socket to examine.
  + */
  +apr_status_t apr_get_local_hostname(char **name, apr_socket_t *sock);
  +
  +/**
    * Get name of the current machine
    * @param buf A buffer to store the hostname in.
    * @param len The maximum length of the hostname that can be stored in the
  
  
  
  1.35      +18 -0     apache-2.0/src/lib/apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- sockopt.c	2000/08/22 21:20:10	1.34
  +++ sockopt.c	2000/11/03 19:24:12	1.35
  @@ -220,3 +220,21 @@
       return (h_errno + APR_OS_START_SYSERR);
   }
   
  +apr_status_t apr_get_local_hostname(char **name, apr_socket_t *sock)
  +{
  +    struct hostent *hptr;
  +    
  +    hptr = gethostbyaddr((char *)&(sock->local_addr->sin_addr), 
  +                         sizeof(struct in_addr), AF_INET);
  +    if (hptr != NULL) {
  +        *name = apr_pstrdup(sock->cntxt, hptr->h_name);
  +        if (*name) {
  +            return APR_SUCCESS;
  +        }
  +        return APR_ENOMEM;
  +    }
  +
  +    /* XXX - Is referencing h_errno threadsafe? */
  +    return (h_errno + APR_OS_START_SYSERR);
  +}
  +
  
  
  
  1.25      +19 -0     apache-2.0/src/lib/apr/network_io/beos/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockopt.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- sockopt.c	2000/08/26 09:57:41	1.24
  +++ sockopt.c	2000/11/03 19:24:16	1.25
  @@ -144,6 +144,25 @@
   	}
   }
   
  +apr_status_t apr_get_local_hostname(char **name, apr_socket_t *sock)
  +{
  +    struct hostent *hptr;
  +    
  +    hptr = gethostbyaddr((char *)&(sock->local_addr->sin_addr), 
  +                         sizeof(struct in_addr), AF_INET);
  +    if (hptr != NULL) {
  +        *name = apr_pstrdup(sock->cntxt, hptr->h_name);
  +        if (*name) {
  +            return APR_SUCCESS;
  +        }
  +        return APR_ENOMEM;
  +    }
  +
  +    /* XXX - Is this threadsafe? - manoj */
  +    /* on BeOS h_errno is a global... */
  +    return h_errno;
  +}
  +
   apr_status_t apr_get_remote_hostname(char **name, apr_socket_t *sock)
   {
       struct hostent *hptr;
  
  
  

Mime
View raw message