Mercurial > hg > octave-shane > gnulib-hg
annotate lib/write-any-file.c @ 13761:a19ace3ba849
Avoid line length limitation from HP NonStop system header files.
* m4/include_next.m4 (gl_INCLUDE_NEXT): Define also PRAGMA_COLUMNS.
* lib/arpa_inet.in.h: Use PRAGMA_COLUMNS.
* lib/ctype.in.h: Likewise.
* lib/dirent.in.h: Likewise.
* lib/errno.in.h: Likewise.
* lib/fcntl.in.h: Likewise.
* lib/float.in.h: Likewise.
* lib/getopt.in.h: Likewise.
* lib/iconv.in.h: Likewise.
* lib/inttypes.in.h: Likewise.
* lib/langinfo.in.h: Likewise.
* lib/locale.in.h: Likewise.
* lib/math.in.h: Likewise.
* lib/netdb.in.h: Likewise.
* lib/netinet_in.in.h: Likewise.
* lib/poll.in.h: Likewise.
* lib/pthread.in.h: Likewise.
* lib/pty.in.h: Likewise.
* lib/sched.in.h: Likewise.
* lib/se-selinux.in.h: Likewise.
* lib/search.in.h: Likewise.
* lib/signal.in.h: Likewise.
* lib/spawn.in.h: Likewise.
* lib/stdarg.in.h: Likewise.
* lib/stddef.in.h: Likewise.
* lib/stdint.in.h: Likewise.
* lib/stdio.in.h: Likewise.
* lib/stdlib.in.h: Likewise.
* lib/string.in.h: Likewise.
* lib/strings.in.h: Likewise.
* lib/sys_file.in.h: Likewise.
* lib/sys_ioctl.in.h: Likewise.
* lib/sys_select.in.h: Likewise.
* lib/sys_socket.in.h: Likewise.
* lib/sys_stat.in.h: Likewise.
* lib/sys_time.in.h: Likewise.
* lib/sys_times.in.h: Likewise.
* lib/sys_utsname.in.h: Likewise.
* lib/sys_wait.in.h: Likewise.
* lib/sysexits.in.h: Likewise.
* lib/termios.in.h: Likewise.
* lib/time.in.h: Likewise.
* lib/unistd.in.h: Likewise.
* lib/wchar.in.h: Likewise.
* lib/wctype.in.h: Likewise.
* modules/arpa_inet (Makefile.am): Substitute PRAGMA_COLUMNS.
* modules/ctype (Makefile.am): Likewise.
* modules/dirent (Makefile.am): Likewise.
* modules/errno (Makefile.am): Likewise.
* modules/fcntl-h (Makefile.am): Likewise.
* modules/float (Makefile.am): Likewise.
* modules/getopt-posix (Makefile.am): Likewise.
* modules/iconv-h (Makefile.am): Likewise.
* modules/inttypes (Makefile.am): Likewise.
* modules/langinfo (Makefile.am): Likewise.
* modules/locale (Makefile.am): Likewise.
* modules/math (Makefile.am): Likewise.
* modules/netdb (Makefile.am): Likewise.
* modules/netinet_in (Makefile.am): Likewise.
* modules/poll-h (Makefile.am): Likewise.
* modules/pthread (Makefile.am): Likewise.
* modules/pty (Makefile.am): Likewise.
* modules/sched (Makefile.am): Likewise.
* modules/search (Makefile.am): Likewise.
* modules/selinux-h (Makefile.am): Likewise.
* modules/signal (Makefile.am): Likewise.
* modules/spawn (Makefile.am): Likewise.
* modules/stdarg (Makefile.am): Likewise.
* modules/stddef (Makefile.am): Likewise.
* modules/stdint (Makefile.am): Likewise.
* modules/stdio (Makefile.am): Likewise.
* modules/stdlib (Makefile.am): Likewise.
* modules/string (Makefile.am): Likewise.
* modules/strings (Makefile.am): Likewise.
* modules/sys_file (Makefile.am): Likewise.
* modules/sys_ioctl (Makefile.am): Likewise.
* modules/sys_select (Makefile.am): Likewise.
* modules/sys_socket (Makefile.am): Likewise.
* modules/sys_stat (Makefile.am): Likewise.
* modules/sys_time (Makefile.am): Likewise.
* modules/sys_times (Makefile.am): Likewise.
* modules/sys_utsname (Makefile.am): Likewise.
* modules/sys_wait (Makefile.am): Likewise.
* modules/sysexits (Makefile.am): Likewise.
* modules/termios (Makefile.am): Likewise.
* modules/time (Makefile.am): Likewise.
* modules/unistd (Makefile.am): Likewise.
* modules/wchar (Makefile.am): Likewise.
* modules/wctype (Makefile.am): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 04 Oct 2010 23:35:51 +0200 |
parents | c2cbabec01dd |
children | 97fc9a21a8fb |
rev | line source |
---|---|
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* Determine whether we can write any file. |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
2 |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8592
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8592
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8592
diff
changeset
|
8 (at your option) any later version. |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8592
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
17 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 /* Written by Paul Eggert. */ |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 #include <config.h> |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
21 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 #include "write-any-file.h" |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
9309
diff
changeset
|
23 #include "priv-set.h" |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
24 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
25 #include <unistd.h> |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
26 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
27 /* Return true if we know that we can write any file, including |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
28 writing directories. */ |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
29 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
30 bool |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
31 can_write_any_file (void) |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
32 { |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
33 static bool initialized; |
8592
e91286e73129
* lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
8504
diff
changeset
|
34 static bool can_write; |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
35 |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
36 if (! initialized) |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
37 { |
8592
e91286e73129
* lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
8504
diff
changeset
|
38 bool can = false; |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
9309
diff
changeset
|
39 #if defined PRIV_FILE_DAC_WRITE |
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
9309
diff
changeset
|
40 can = (priv_set_ismember (PRIV_FILE_DAC_WRITE) == 1); |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
41 #else |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
42 /* In traditional Unix, only root can unlink directories. */ |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
43 can = (geteuid () == 0); |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
44 #endif |
8592
e91286e73129
* lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
8504
diff
changeset
|
45 can_write = can; |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 initialized = true; |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 } |
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
48 |
8592
e91286e73129
* lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents:
8504
diff
changeset
|
49 return can_write; |
8504
24420da38757
* MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
50 } |