annotate lib/mkdtemp.c @ 11583:dc80f2cc1327

Second attempt to work around an AIX 5.3, 6.1 compiler bug with include_next.
author Eric Blake <ebb9@byu.net>
date Thu, 21 May 2009 16:48:12 +0200
parents bbbbbf4cd1c5
children 52791eb62094
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8192
b9003c1ee8fa mkdtemp.h is replaced with <stdlib.h>.
Bruno Haible <bruno@clisp.org>
parents: 7588
diff changeset
1 /* Copyright (C) 1999, 2001-2003, 2006-2007 Free Software Foundation, Inc.
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 This file is part of the GNU C Library.
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8192
diff changeset
4 This program is free software: you can redistribute it and/or modify
4440
e58a1c05a6ba Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4237
diff changeset
5 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: 8192
diff changeset
6 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: 8192
diff changeset
7 (at your option) any later version.
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
4440
e58a1c05a6ba Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4237
diff changeset
9 This program is distributed in the hope that it will be useful,
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
4440
e58a1c05a6ba Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4237
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e58a1c05a6ba Update gettext source files from gettext automatically, using srclist-update.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4237
diff changeset
12 GNU General Public License for more details.
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8192
diff changeset
14 You should have received a copy of the GNU General Public License
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8192
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
7588
66be60b7a727 * modules/tmpdir (Depends-on): Add sys_stat.
Eric Blake <ebb9@byu.net>
parents: 7342
diff changeset
17 /* Extracted from misc/mkdtemp.c. */
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
7304
1c4ed7637c24 Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 7293
diff changeset
19 #include <config.h>
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 /* Specification. */
8192
b9003c1ee8fa mkdtemp.h is replaced with <stdlib.h>.
Bruno Haible <bruno@clisp.org>
parents: 7588
diff changeset
22 #include <stdlib.h>
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
7588
66be60b7a727 * modules/tmpdir (Depends-on): Add sys_stat.
Eric Blake <ebb9@byu.net>
parents: 7342
diff changeset
24 #include "tempname.h"
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 /* Generate a unique temporary directory from TEMPLATE.
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 The last six characters of TEMPLATE must be "XXXXXX";
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 they are replaced with a string that makes the filename unique.
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 The directory is created, mode 700, and its name is returned.
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 (This function comes from OpenBSD.) */
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 char *
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 mkdtemp (char *template)
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
7588
66be60b7a727 * modules/tmpdir (Depends-on): Add sys_stat.
Eric Blake <ebb9@byu.net>
parents: 7342
diff changeset
34 if (gen_tempname (template, GT_DIR))
4237
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 return NULL;
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 else
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 return template;
723deab1223e mkdtemp() function: create a private temporary directory.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 }