Mercurial > hg > octave-kai > gnulib-hg
annotate lib/getsockopt.c @ 17160:72f4bab621be
fts: introduce FTS_VERBATIM
This gives clients the option to disable stripping of trailing slashes
from input path names during fts_open initialization.
The recent change v0.0-7611-g3a9002d that made fts_open strip trailing
slashes from input path names had a negative impact on findutils that
relies on the old fts_open behavior to implement POSIX requirement that
each path operand of the find utility shall be evaluated unaltered as it
was provided, including all trailing slash characters.
* lib/fts_.h (FTS_VERBATIM): New bit flag.
(FTS_OPTIONMASK, FTS_NAMEONLY, FTS_STOP): Adjust.
* lib/fts.c (fts_open): Honor it.
author | Dmitry V. Levin <ldv@altlinux.org> |
---|---|
date | Sun, 18 Nov 2012 04:40:18 +0400 |
parents | 8250f2777afc |
children | e542fd46ad6f |
rev | line source |
---|---|
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
1 /* getsockopt.c --- wrappers for Windows getsockopt function |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
2 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15727
diff
changeset
|
3 Copyright (C) 2008-2012 Free Software Foundation, Inc. |
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
4 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
8 (at your option) any later version. |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
9 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
14 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
17 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
18 /* Written by Paolo Bonzini */ |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
19 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
20 #include <config.h> |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
21 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
22 #define WIN32_LEAN_AND_MEAN |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
23 /* Get winsock2.h. */ |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
24 #include <sys/socket.h> |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
25 |
11244
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
26 /* Get struct timeval. */ |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
27 #include <sys/time.h> |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
28 |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
29 /* Get memcpy. */ |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
30 #include <string.h> |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
31 |
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
32 /* Get set_winsock_errno, FD_TO_SOCKET etc. */ |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
33 #include "w32sock.h" |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
34 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
35 #undef getsockopt |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
36 |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
37 int |
11250
c02a0fe7bcc4
Use socklen_t in the native Windows replacements prototypes.
Bruno Haible <bruno@clisp.org>
parents:
11244
diff
changeset
|
38 rpl_getsockopt (int fd, int level, int optname, void *optval, socklen_t *optlen) |
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
39 { |
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
40 SOCKET sock = FD_TO_SOCKET (fd); |
11244
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
41 |
15727
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
42 if (sock == INVALID_SOCKET) |
11244
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
43 { |
15727
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
44 errno = EBADF; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
45 return -1; |
11244
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
46 } |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
47 else |
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
48 { |
15727
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
49 int r; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
50 |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
51 if (level == SOL_SOCKET |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
52 && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
53 { |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
54 int milliseconds; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
55 int milliseconds_len = sizeof (int); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
56 struct timeval tv; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
57 size_t n; |
11244
e8ad1520586c
setsockopt: Add support for timeouts on W32
Martin Lambers <marlam@marlam.de>
parents:
10690
diff
changeset
|
58 |
15727
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
59 r = getsockopt (sock, level, optname, (char *) &milliseconds, |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
60 &milliseconds_len); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
61 tv.tv_sec = milliseconds / 1000; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
62 tv.tv_usec = (milliseconds - 1000 * tv.tv_sec) * 1000; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
63 n = sizeof (struct timeval); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
64 if (n > *optlen) |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
65 n = *optlen; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
66 memcpy (optval, &tv, n); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
67 *optlen = n; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
68 } |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
69 else |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
70 { |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
71 r = getsockopt (sock, level, optname, optval, optlen); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
72 } |
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
73 |
15727
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
74 if (r < 0) |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
75 set_winsock_errno (); |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
76 |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
77 return r; |
144db791c6fa
Ensure EBADF returns for socket functions on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14646
diff
changeset
|
78 } |
10690
01f3623813da
Split winsock.c into many smaller files.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
79 } |