* cygwin.din: Add recvmsg and sendmsg.
* net.cc: Add cygwin_recvmsg and cygwin_sendmsg. * /usr/include/sys/socket.h: Add recvmsg and sendmsg.
This commit is contained in:
parent
2d3dab2ea5
commit
7d6be0d616
|
@ -1,3 +1,9 @@
|
|||
2002-01-19 Mark Bradshaw <bradshaw@staff.crosswalk.com>
|
||||
|
||||
* cygwin.din: Add recvmsg and sendmsg.
|
||||
* net.cc: Add cygwin_recvmsg and cygwin_sendmsg.
|
||||
* /usr/include/sys/socket.h: Add recvmsg and sendmsg.
|
||||
|
||||
2002-01-19 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* security.cc (create_token): Close processes token handle as soon
|
||||
|
|
|
@ -1036,6 +1036,8 @@ setsockopt = cygwin_setsockopt
|
|||
inet_aton = cygwin_inet_aton
|
||||
inet_ntoa = cygwin_inet_ntoa
|
||||
recvfrom = cygwin_recvfrom
|
||||
recvmsg = cygwin_recvmsg
|
||||
sendmsg = cygwin_sendmsg
|
||||
sendto = cygwin_sendto
|
||||
shutdown = cygwin_shutdown
|
||||
sethostent
|
||||
|
|
|
@ -35,7 +35,9 @@ extern "C"
|
|||
int recv (int, void *__buff, int __len, unsigned int __flags);
|
||||
int recvfrom (int, char *__buff, int __len, int __flags,
|
||||
struct sockaddr *__from, int *__fromlen);
|
||||
int recvmsg(int s, struct msghdr *msg, int flags);
|
||||
int send (int, const void *__buff, int __len, unsigned int __flags);
|
||||
int sendmsg(int s, const struct msghdr *msg, int flags);
|
||||
int sendto (int, const void *, int, unsigned int, const struct sockaddr *, int);
|
||||
int setsockopt (int __s, int __level, int __optname, const void *optval, int __optlen);
|
||||
int getsockopt (int __s, int __level, int __optname, void *__optval, int *__optlen);
|
||||
|
|
|
@ -34,6 +34,7 @@ details. */
|
|||
#include "sigproc.h"
|
||||
#include "pinfo.h"
|
||||
#include "registry.h"
|
||||
#include <sys/uio.h>
|
||||
|
||||
extern "C" {
|
||||
int h_errno;
|
||||
|
@ -2519,3 +2520,63 @@ extern "C" void
|
|||
endhostent (void)
|
||||
{
|
||||
}
|
||||
|
||||
/* exported as recvmsg: standards? */
|
||||
extern "C" int
|
||||
cygwin_recvmsg(int s, struct msghdr *msg, int flags)
|
||||
{
|
||||
int ret, nb;
|
||||
size_t tot = 0;
|
||||
int i;
|
||||
char *buf, *p;
|
||||
struct iovec *iov = msg->msg_iov;
|
||||
|
||||
for(i = 0; i < msg->msg_iovlen; ++i)
|
||||
tot += iov[i].iov_len;
|
||||
buf = (char *) malloc(tot);
|
||||
if (tot != 0 && buf == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
nb = ret = cygwin_recvfrom (s, buf, tot, flags,
|
||||
(struct sockaddr *) msg->msg_name, (int *) &msg->msg_namelen);
|
||||
p = buf;
|
||||
while (nb > 0) {
|
||||
ssize_t cnt = min(nb, iov->iov_len);
|
||||
|
||||
memcpy (iov->iov_base, p, cnt);
|
||||
p += cnt;
|
||||
nb -= cnt;
|
||||
++iov;
|
||||
}
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* exported as sendmsg: standards? */
|
||||
extern "C" int
|
||||
cygwin_sendmsg(int s, const struct msghdr *msg, int flags)
|
||||
{
|
||||
int ret;
|
||||
size_t tot = 0;
|
||||
int i;
|
||||
char *buf, *p;
|
||||
struct iovec *iov = msg->msg_iov;
|
||||
|
||||
for(i = 0; i < msg->msg_iovlen; ++i)
|
||||
tot += iov[i].iov_len;
|
||||
buf = (char *) malloc(tot);
|
||||
if (tot != 0 && buf == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
p = buf;
|
||||
for (i = 0; i < msg->msg_iovlen; ++i) {
|
||||
memcpy (p, iov[i].iov_base, iov[i].iov_len);
|
||||
p += iov[i].iov_len;
|
||||
}
|
||||
ret = cygwin_sendto (s, buf, tot, flags,
|
||||
(struct sockaddr *) msg->msg_name, msg->msg_namelen);
|
||||
free (buf);
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue