Update of win32 files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@470 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
405451e34c
commit
0080c080cd
@ -1,103 +1,100 @@
|
|||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
#ifndef INET_PTON
|
#ifndef INET_PTON
|
||||||
#define INET_PTON
|
#define INET_PTON
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
|
||||||
|
#include "unixutil.h"
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
typedef int socklen_t;
|
|
||||||
#define EAFNOSUPPORT 97
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WARNING: Don't even consider trying to compile this on a system where
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \author: Paul Vixie, 1996.
|
||||||
|
*
|
||||||
|
* \brief Network support routines missing in WIN32.
|
||||||
|
*
|
||||||
|
* \warning Don't even consider trying to compile this on a system where
|
||||||
* sizeof(int) < 4. sizeof(int) 4 is fine; all the world's not a VAX.
|
* sizeof(int) < 4. sizeof(int) 4 is fine; all the world's not a VAX.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* const char *
|
/*!
|
||||||
* inet_ntop4(src, dst, size)
|
* \brief format an IPv4 address
|
||||||
* format an IPv4 address
|
*
|
||||||
* return:
|
* \return `dst' (as a const)
|
||||||
* `dst' (as a const)
|
*
|
||||||
* notes:
|
* \note
|
||||||
* (1) uses no statics
|
* \li (1) uses no statics
|
||||||
* (2) takes a u_char* not an in_addr as input
|
* \li (2) takes a u_char* not an in_addr as input
|
||||||
* author:
|
*
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
extern const char * inet_ntop4(const u_char src, char *dst, socklen_t size);
|
extern const char *inet_ntop4(const u_char src, char *dst, socklen_t size);
|
||||||
|
|
||||||
/* const char *
|
|
||||||
* inet_ntop6(src, dst, size)
|
/*!
|
||||||
* convert IPv6 binary address into presentation (printable) format
|
* \brief convert IPv6 binary address into presentation (printable) format
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef INET_IPV6
|
#ifdef INET_IPV6
|
||||||
|
extern const char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
|
||||||
extern const char * inet_ntop6(src, dst, size);
|
|
||||||
|
|
||||||
#endif /* INET_IPV6 */
|
#endif /* INET_IPV6 */
|
||||||
|
|
||||||
/* int
|
|
||||||
* inet_pton4(src, dst)
|
/*!
|
||||||
* like inet_aton() but without all the hexadecimal and shorthand.
|
* \brief like inet_aton() but without all the hexadecimal and shorthand.
|
||||||
* return:
|
*
|
||||||
* 1 if `src' is a valid dotted quad, else 0.
|
* \return 1 if `src' is a valid dotted quad, else 0.
|
||||||
* notice:
|
*
|
||||||
* does not touch `dst' unless it's returning 1.
|
* \note does not touch `dst' unless it's returning 1.
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
extern inet_pton4(const char *src,u_char *dst);
|
extern inet_pton4(const char *src,u_char *dst);
|
||||||
|
|
||||||
/* int
|
|
||||||
* inet_pton6(src, dst)
|
/*!
|
||||||
* convert presentation level address to network order binary form.
|
* \brief convert presentation level address to network order binary form.
|
||||||
* return:
|
*
|
||||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
* \return 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||||
* notice:
|
*
|
||||||
* (1) does not touch `dst' unless it's returning 1.
|
* \note
|
||||||
* (2) :: in a full address is silently ignored.
|
* \li (1) does not touch `dst' unless it's returning 1.
|
||||||
* credit:
|
* \li (2) :: in a full address is silently ignored.
|
||||||
* inspired by Mark Andrews.
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef INET_IPV6
|
#ifdef INET_IPV6
|
||||||
|
extern int inet_pton6(const char *src, u_char *dst);
|
||||||
extern int inet_pton6(src, dst);
|
|
||||||
|
|
||||||
#endif /* INET_IPV6 */
|
#endif /* INET_IPV6 */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
/* char *
|
* \brief convert a network format address to presentation format.
|
||||||
* inet_ntop(af, src, dst, size)
|
*
|
||||||
* convert a network format address to presentation format.
|
* \return
|
||||||
* return:
|
|
||||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
extern const char *inet_ntop(int af,const void *src,char *dst,socklen_t size);
|
extern const char *inet_ntop(int af,const void *src,char *dst,socklen_t size);
|
||||||
|
|
||||||
|
|
||||||
/* int
|
/*!
|
||||||
* inet_pton(af, src, dst)
|
* \brief convert from presentation format (which usually means ASCII printable)
|
||||||
* convert from presentation format (which usually means ASCII printable)
|
* to network format (which is usually some kind of binary format).
|
||||||
* to network format (which is usually some kind of binary format).
|
*
|
||||||
* return:
|
* \return
|
||||||
* 1 if the address was valid for the specified address family
|
* \li 1 if the address was valid for the specified address family
|
||||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
* \li 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
* \li -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
*/
|
||||||
extern int inet_pton(int af,const char *src,void *dst);
|
extern int inet_pton(int af,const char *src,void *dst);
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INET_PTON */
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#ifdef WIN32
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||||
*
|
*
|
||||||
@ -16,39 +15,15 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*#include <sys/param.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
/* This file is WIN32 only */
|
||||||
#include <arpa/inet.h>
|
#ifdef WIN32
|
||||||
#include <arpa/nameser.h>*/
|
|
||||||
#include <winsock2.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
typedef int socklen_t;
|
|
||||||
#define EAFNOSUPPORT 97
|
|
||||||
/*
|
|
||||||
* WARNING: Don't even consider trying to compile this on a system where
|
|
||||||
* sizeof(int) < 4. sizeof(int) 4 is fine; all the world's not a VAX.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* const char *
|
#include "inet_pton.h"
|
||||||
* inet_ntop4(src, dst, size)
|
|
||||||
* format an IPv4 address
|
|
||||||
* return:
|
static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size)
|
||||||
* `dst' (as a const)
|
|
||||||
* notes:
|
|
||||||
* (1) uses no statics
|
|
||||||
* (2) takes a u_char* not an in_addr as input
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
static const char *
|
|
||||||
inet_ntop4(const u_char *src, char *dst, socklen_t size)
|
|
||||||
{
|
{
|
||||||
char tmp[sizeof ("255.255.255.255") + 1] = "\0";
|
char tmp[sizeof ("255.255.255.255") + 1] = "\0";
|
||||||
int octet;
|
int octet;
|
||||||
@ -82,20 +57,8 @@ inet_ntop4(const u_char *src, char *dst, socklen_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* const char *
|
|
||||||
* inet_ntop6(src, dst, size)
|
|
||||||
* convert IPv6 binary address into presentation (printable) format
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef INET_IPV6
|
#ifdef INET_IPV6
|
||||||
|
static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size)
|
||||||
static const char *
|
|
||||||
inet_ntop6(src, dst, size)
|
|
||||||
const u_char *src;
|
|
||||||
char *dst;
|
|
||||||
socklen_t size;
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note that int32_t and int16_t need only be "at least" large enough
|
* Note that int32_t and int16_t need only be "at least" large enough
|
||||||
@ -182,18 +145,7 @@ inet_ntop6(src, dst, size)
|
|||||||
#endif /* INET_IPV6 */
|
#endif /* INET_IPV6 */
|
||||||
|
|
||||||
|
|
||||||
/* int
|
static int inet_pton4(const char *src,u_char *dst)
|
||||||
* inet_pton4(src, dst)
|
|
||||||
* like inet_aton() but without all the hexadecimal and shorthand.
|
|
||||||
* return:
|
|
||||||
* 1 if `src' is a valid dotted quad, else 0.
|
|
||||||
* notice:
|
|
||||||
* does not touch `dst' unless it's returning 1.
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
inet_pton4(const char *src,u_char *dst)
|
|
||||||
{
|
{
|
||||||
int saw_digit, octets, ch;
|
int saw_digit, octets, ch;
|
||||||
u_char tmp[4], *tp;
|
u_char tmp[4], *tp;
|
||||||
@ -225,29 +177,12 @@ inet_pton4(const char *src,u_char *dst)
|
|||||||
if (octets < 4)
|
if (octets < 4)
|
||||||
return (0);
|
return (0);
|
||||||
memcpy(dst, tmp, 4);
|
memcpy(dst, tmp, 4);
|
||||||
return (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int
|
|
||||||
* inet_pton6(src, dst)
|
|
||||||
* convert presentation level address to network order binary form.
|
|
||||||
* return:
|
|
||||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
|
||||||
* notice:
|
|
||||||
* (1) does not touch `dst' unless it's returning 1.
|
|
||||||
* (2) :: in a full address is silently ignored.
|
|
||||||
* credit:
|
|
||||||
* inspired by Mark Andrews.
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef INET_IPV6
|
#ifdef INET_IPV6
|
||||||
|
static int inet_pton6(const char *src, u_char *dst)
|
||||||
static int
|
|
||||||
inet_pton6(src, dst)
|
|
||||||
const char *src;
|
|
||||||
u_char *dst;
|
|
||||||
{
|
{
|
||||||
static const char xdigits[] = "0123456789abcdef";
|
static const char xdigits[] = "0123456789abcdef";
|
||||||
u_char tmp[16], *tp, *endp, *colonp;
|
u_char tmp[16], *tp, *endp, *colonp;
|
||||||
@ -330,20 +265,10 @@ inet_pton6(src, dst)
|
|||||||
memcpy(dst, tmp, 16);
|
memcpy(dst, tmp, 16);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* INET_IPV6 */
|
#endif /* INET_IPV6 */
|
||||||
|
|
||||||
|
|
||||||
|
const char *inet_ntop(int af,const void *src,char *dst,socklen_t size)
|
||||||
/* char *
|
|
||||||
* inet_ntop(af, src, dst, size)
|
|
||||||
* convert a network format address to presentation format.
|
|
||||||
* return:
|
|
||||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
extern const char *inet_ntop(int af,const void *src,char *dst,socklen_t size)
|
|
||||||
{
|
{
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
@ -353,24 +278,13 @@ extern const char *inet_ntop(int af,const void *src,char *dst,socklen_t size)
|
|||||||
return (inet_ntop6(src, dst, size));
|
return (inet_ntop6(src, dst, size));
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
//__set_errno (EAFNOSUPPORT);
|
/*__set_errno(EAFNOSUPPORT);*/
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* int
|
|
||||||
* inet_pton(af, src, dst)
|
|
||||||
* convert from presentation format (which usually means ASCII printable)
|
|
||||||
* to network format (which is usually some kind of binary format).
|
|
||||||
* return:
|
|
||||||
* 1 if the address was valid for the specified address family
|
|
||||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
|
||||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
|
||||||
* author:
|
|
||||||
* Paul Vixie, 1996.
|
|
||||||
*/
|
|
||||||
int inet_pton(int af,const char *src,void *dst)
|
int inet_pton(int af,const char *src,void *dst)
|
||||||
{
|
{
|
||||||
switch (af) {
|
switch (af) {
|
||||||
@ -381,9 +295,12 @@ int inet_pton(int af,const char *src,void *dst)
|
|||||||
return (inet_pton6(src, dst));
|
return (inet_pton6(src, dst));
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
//__set_errno (EAFNOSUPPORT);
|
/*__set_errno(EAFNOSUPPORT);*/
|
||||||
return (-1);
|
return -1;
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user