annotate lib/fdopen.c @ 17463:203c036eb0c6

bootstrap: support checksum utils without a --status option * build-aux/bootstrap: Only look for sha1sum if updating po files. Add sha1 to the list of supported checksum utils since it's now supported through adjustments below. (update_po_files): Remove the use of --status in a way that will suppress all error messages, but since this is only used to minimize updates, it shouldn't cause an issue. Exit early if there is a problem updating the po file checksums. (find_tool): Remove the check for --version support as this is optional as per commit 86186b17. Don't even check for the presence of the command as if that is needed, it's supported through configuring prerequisites in bootstrap.conf. Prompt that when a tool isn't found, one can define an environment variable to add to the hardcoded search list.
author Pádraig Brady <P@draigBrady.com>
date Thu, 08 Aug 2013 11:08:49 +0100 (2013-08-08)
parents e542fd46ad6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15734
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Open a stream with a given file descriptor.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
15734
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <stdio.h>
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <errno.h>
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
15776
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
24 #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
25 # include "msvc-inval.h"
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
26 #endif
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
27
15734
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #undef fdopen
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
15776
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
30 #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
31 static FILE *
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
32 fdopen_nothrow (int fd, const char *mode)
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
33 {
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
34 FILE *result;
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
35
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
36 TRY_MSVC_INVAL
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
37 {
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
38 result = fdopen (fd, mode);
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
39 }
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
40 CATCH_MSVC_INVAL
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
41 {
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
42 result = NULL;
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
43 }
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
44 DONE_MSVC_INVAL;
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
45
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
46 return result;
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
47 }
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
48 #else
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
49 # define fdopen_nothrow fdopen
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
50 #endif
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
51
15734
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 FILE *
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 rpl_fdopen (int fd, const char *mode)
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 {
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 int saved_errno = errno;
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 FILE *fp;
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 errno = 0;
15776
1544d00cbf34 fdopen: Support for MSVC 9.
Bruno Haible <bruno@clisp.org>
parents: 15734
diff changeset
59 fp = fdopen_nothrow (fd, mode);
15734
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 if (fp == NULL)
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 {
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 if (errno == 0)
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 errno = EBADF;
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 }
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 else
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 errno = saved_errno;
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 return fp;
7adcf631d56b New module 'fdopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 }