/[svn]/hopm/branches/1.0.x/src/libopm/src/compat.c
ViewVC logotype

Diff of /hopm/branches/1.0.x/src/libopm/src/compat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5170 by michael, Thu Dec 25 19:44:15 2014 UTC revision 5171 by michael, Fri Dec 26 20:53:32 2014 UTC
# Line 27  Line 27 
27  # include <string.h>  # include <string.h>
28  #endif  #endif
29    
 #ifndef HAVE_INET_ATON  
 # include <netinet/in.h>  
 #endif  
   
30  #include "compat.h"  #include "compat.h"
31  #include "opm.h"  #include "opm.h"
   
   
 #ifndef HAVE_INET_ATON  
 /*  
  * An implementation of inet_aton for those systems that don't have it  
  * (Solaris, ...)  
  */  
 int libopm_inet_aton(const char *cp, struct in_addr *inp)  
 {  
         unsigned int a1, a2, a3, a4;  
         unsigned long ret;  
   
         if (strcmp(cp, "255.255.255.255") == 0) {  
                 inp->s_addr = (unsigned) -1;  
                 return 0;  
         }  
   
         if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||  
             a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {  
                 return 0;  
         }  
   
         ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;  
   
         inp->s_addr = htonl(ret);  
           
         if (inp->s_addr == (unsigned) -1) {  
                 return 0;  
         }  
         return 1;  
 }  
 #endif  

Legend:
Removed from v.5170  
changed lines
  Added in v.5171

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26