Loading ares/Makefile.inc +3 −3 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ ares_gethostbyname.c ares_strerror.c ares_cancel.c ares_init.c \ ares_timeout.c ares_destroy.c ares_mkquery.c ares_version.c \ ares_expand_name.c ares_parse_a_reply.c windows_port.c ares_strdup.c \ ares_expand_string.c ares_parse_ptr_reply.c ares_parse_aaaa_reply.c \ ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c \ ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c ares_writev.c \ ares_parse_ns_reply.c ares_llist.c ares__timeval.c ares_strcasecmp.c HHEADERS = ares.h ares_private.h setup.h ares_dns.h ares_version.h \ nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h \ setup_once.h ares_llist.h ares_strdup.h ares_strcasecmp.h nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h setup_once.h \ ares_llist.h ares_strdup.h ares_strcasecmp.h ares_writev.h MANPAGES= ares_destroy.3 ares_expand_name.3 ares_expand_string.3 ares_fds.3 \ ares_free_hostent.3 ares_free_string.3 ares_gethostbyaddr.3 \ Loading ares/Makefile.vc6 +4 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ OBJECTS = $(OBJ_DIR)\ares_fds.obj \ $(OBJ_DIR)\windows_port.obj \ $(OBJ_DIR)\ares_expand_string.obj \ $(OBJ_DIR)\ares_parse_ptr_reply.obj \ $(OBJ_DIR)\ares_writev.obj \ $(OBJ_DIR)\bitncmp.obj \ $(OBJ_DIR)\inet_net_pton.obj \ $(OBJ_DIR)\inet_ntop.obj Loading Loading @@ -246,3 +247,6 @@ $(OBJ_DIR)\ares_getopt.obj: ares_getopt.c ares_getopt.h $(OBJ_DIR)\ares_llist.obj: ares_llist.c setup.h setup_once.h ares.h \ ares_private.h ares_llist.h $(OBJ_DIR)\ares_writev.obj: ares_writev.c setup.h setup_once.h ares.h \ ares_writev.h ares/ares_private.h +6 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ #undef closesocket #define closesocket(s) close_s(s) #define writev(s,v,c) writev_s(s,v,c) #define HAVE_WRITEV 1 #endif #ifdef NETWARE Loading Loading @@ -109,6 +110,11 @@ # define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n) #endif #ifndef HAVE_WRITEV # include "ares_writev.h" # define writev(s,ptr,cnt) ares_writev(s,ptr,cnt) #endif struct query; struct send_request { Loading ares/ares_writev.c 0 → 100644 +77 −0 Original line number Diff line number Diff line /* $Id$ */ /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "setup.h" #include <limits.h> #include "ares.h" #include "ares_private.h" #ifndef HAVE_WRITEV ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) { char *buffer, *bp; int i; size_t bytes = 0; ssize_t result; /* Validate iovcnt */ if (iovcnt <= 0) { SET_ERRNO(EINVAL); return (-1); } /* Validate and find the sum of the iov_len values in the iov array */ for (i = 0; i < iovcnt; i++) { if (iov[i].iov_len > INT_MAX - bytes) { SET_ERRNO(EINVAL); return (-1); } bytes += iov[i].iov_len; } if (bytes == 0) return (0); /* Allocate a temporary buffer to hold the data */ buffer = malloc(bytes); if (!buffer) { SET_ERRNO(ENOMEM); return (-1); } /* Copy the data into buffer */ for (bp = buffer, i = 0; i < iovcnt; ++i) { memcpy (bp, iov[i].iov_base, iov[i].iov_len); bp += iov[i].iov_len; } /* Send buffer contents */ result = swrite(s, buffer, bytes); free(buffer); return (result); } #endif ares/ares_writev.h 0 → 100644 +37 −0 Original line number Diff line number Diff line #ifndef HEADER_CARES_WRITEV_H #define HEADER_CARES_WRITEV_H /* $Id$ */ /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "setup.h" #include "ares.h" #ifndef HAVE_WRITEV /* Structure for scatter/gather I/O. */ struct iovec { void *iov_base; /* Pointer to data. */ size_t iov_len; /* Length of data. */ }; extern ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); #endif #endif /* HEADER_CARES_WRITEV_H */ Loading
ares/Makefile.inc +3 −3 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ ares_gethostbyname.c ares_strerror.c ares_cancel.c ares_init.c \ ares_timeout.c ares_destroy.c ares_mkquery.c ares_version.c \ ares_expand_name.c ares_parse_a_reply.c windows_port.c ares_strdup.c \ ares_expand_string.c ares_parse_ptr_reply.c ares_parse_aaaa_reply.c \ ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c \ ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c ares_writev.c \ ares_parse_ns_reply.c ares_llist.c ares__timeval.c ares_strcasecmp.c HHEADERS = ares.h ares_private.h setup.h ares_dns.h ares_version.h \ nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h \ setup_once.h ares_llist.h ares_strdup.h ares_strcasecmp.h nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h setup_once.h \ ares_llist.h ares_strdup.h ares_strcasecmp.h ares_writev.h MANPAGES= ares_destroy.3 ares_expand_name.3 ares_expand_string.3 ares_fds.3 \ ares_free_hostent.3 ares_free_string.3 ares_gethostbyaddr.3 \ Loading
ares/Makefile.vc6 +4 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ OBJECTS = $(OBJ_DIR)\ares_fds.obj \ $(OBJ_DIR)\windows_port.obj \ $(OBJ_DIR)\ares_expand_string.obj \ $(OBJ_DIR)\ares_parse_ptr_reply.obj \ $(OBJ_DIR)\ares_writev.obj \ $(OBJ_DIR)\bitncmp.obj \ $(OBJ_DIR)\inet_net_pton.obj \ $(OBJ_DIR)\inet_ntop.obj Loading Loading @@ -246,3 +247,6 @@ $(OBJ_DIR)\ares_getopt.obj: ares_getopt.c ares_getopt.h $(OBJ_DIR)\ares_llist.obj: ares_llist.c setup.h setup_once.h ares.h \ ares_private.h ares_llist.h $(OBJ_DIR)\ares_writev.obj: ares_writev.c setup.h setup_once.h ares.h \ ares_writev.h
ares/ares_private.h +6 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ #undef closesocket #define closesocket(s) close_s(s) #define writev(s,v,c) writev_s(s,v,c) #define HAVE_WRITEV 1 #endif #ifdef NETWARE Loading Loading @@ -109,6 +110,11 @@ # define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n) #endif #ifndef HAVE_WRITEV # include "ares_writev.h" # define writev(s,ptr,cnt) ares_writev(s,ptr,cnt) #endif struct query; struct send_request { Loading
ares/ares_writev.c 0 → 100644 +77 −0 Original line number Diff line number Diff line /* $Id$ */ /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "setup.h" #include <limits.h> #include "ares.h" #include "ares_private.h" #ifndef HAVE_WRITEV ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) { char *buffer, *bp; int i; size_t bytes = 0; ssize_t result; /* Validate iovcnt */ if (iovcnt <= 0) { SET_ERRNO(EINVAL); return (-1); } /* Validate and find the sum of the iov_len values in the iov array */ for (i = 0; i < iovcnt; i++) { if (iov[i].iov_len > INT_MAX - bytes) { SET_ERRNO(EINVAL); return (-1); } bytes += iov[i].iov_len; } if (bytes == 0) return (0); /* Allocate a temporary buffer to hold the data */ buffer = malloc(bytes); if (!buffer) { SET_ERRNO(ENOMEM); return (-1); } /* Copy the data into buffer */ for (bp = buffer, i = 0; i < iovcnt; ++i) { memcpy (bp, iov[i].iov_base, iov[i].iov_len); bp += iov[i].iov_len; } /* Send buffer contents */ result = swrite(s, buffer, bytes); free(buffer); return (result); } #endif
ares/ares_writev.h 0 → 100644 +37 −0 Original line number Diff line number Diff line #ifndef HEADER_CARES_WRITEV_H #define HEADER_CARES_WRITEV_H /* $Id$ */ /* Copyright 1998 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. */ #include "setup.h" #include "ares.h" #ifndef HAVE_WRITEV /* Structure for scatter/gather I/O. */ struct iovec { void *iov_base; /* Pointer to data. */ size_t iov_len; /* Length of data. */ }; extern ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); #endif #endif /* HEADER_CARES_WRITEV_H */