00001 #ifdef WIN32 00002 #ifndef INET_PTON 00003 #define INET_PTON 00004 00005 #include <winsock2.h> 00006 00007 #include <errno.h> 00008 #include <stdio.h> 00009 #include <string.h> 00010 typedef int socklen_t; 00011 #define EAFNOSUPPORT 97 00012 00013 /* 00014 * WARNING: Don't even consider trying to compile this on a system where 00015 * sizeof(int) < 4. sizeof(int) 4 is fine; all the world's not a VAX. 00016 */ 00017 00018 /* const char * 00019 * inet_ntop4(src, dst, size) 00020 * format an IPv4 address 00021 * return: 00022 * `dst' (as a const) 00023 * notes: 00024 * (1) uses no statics 00025 * (2) takes a u_char* not an in_addr as input 00026 * author: 00027 * Paul Vixie, 1996. 00028 */ 00029 extern const char * inet_ntop4(const u_char src, char *dst, socklen_t size); 00030 00031 /* const char * 00032 * inet_ntop6(src, dst, size) 00033 * convert IPv6 binary address into presentation (printable) format 00034 * author: 00035 * Paul Vixie, 1996. 00036 */ 00037 00038 #ifdef INET_IPV6 00039 00040 extern const char * inet_ntop6(src, dst, size); 00041 00042 #endif /* INET_IPV6 */ 00043 00044 /* int 00045 * inet_pton4(src, dst) 00046 * like inet_aton() but without all the hexadecimal and shorthand. 00047 * return: 00048 * 1 if `src' is a valid dotted quad, else 0. 00049 * notice: 00050 * does not touch `dst' unless it's returning 1. 00051 * author: 00052 * Paul Vixie, 1996. 00053 */ 00054 extern inet_pton4(const char *src,u_char *dst); 00055 00056 /* int 00057 * inet_pton6(src, dst) 00058 * convert presentation level address to network order binary form. 00059 * return: 00060 * 1 if `src' is a valid [RFC1884 2.2] address, else 0. 00061 * notice: 00062 * (1) does not touch `dst' unless it's returning 1. 00063 * (2) :: in a full address is silently ignored. 00064 * credit: 00065 * inspired by Mark Andrews. 00066 * author: 00067 * Paul Vixie, 1996. 00068 */ 00069 00070 #ifdef INET_IPV6 00071 00072 extern int inet_pton6(src, dst); 00073 00074 #endif /* INET_IPV6 */ 00075 00076 00077 00078 /* char * 00079 * inet_ntop(af, src, dst, size) 00080 * convert a network format address to presentation format. 00081 * return: 00082 * pointer to presentation format address (`dst'), or NULL (see errno). 00083 * author: 00084 * Paul Vixie, 1996. 00085 */ 00086 extern const char *inet_ntop(int af,const void *src,char *dst,socklen_t size); 00087 00088 00089 /* int 00090 * inet_pton(af, src, dst) 00091 * convert from presentation format (which usually means ASCII printable) 00092 * to network format (which is usually some kind of binary format). 00093 * return: 00094 * 1 if the address was valid for the specified address family 00095 * 0 if the address wasn't valid (`dst' is untouched in this case) 00096 * -1 if some other error occurred (`dst' is untouched in this case, too) 00097 * author: 00098 * Paul Vixie, 1996. 00099 */ 00100 extern int inet_pton(int af,const char *src,void *dst); 00101 00102 #endif 00103 #endif
1.6.1