be01c514365191d75ae95de0627ba7acb9d9b043
[deliverable/binutils-gdb.git] / gnulib / import / tempname.h
1 /* Create a temporary file or directory.
2
3 Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 /* header written by Eric Blake */
19
20 #ifndef GL_TEMPNAME_H
21 # define GL_TEMPNAME_H
22
23 # include <stdio.h>
24
25 # ifdef __GT_FILE
26 # define GT_FILE __GT_FILE
27 # define GT_DIR __GT_DIR
28 # define GT_NOCREATE __GT_NOCREATE
29 # else
30 # define GT_FILE 0
31 # define GT_DIR 1
32 # define GT_NOCREATE 2
33 # endif
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /* Generate a temporary file name based on TMPL. TMPL must match the
40 rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
41 The name constructed does not exist at the time of the call to
42 gen_tempname. TMPL is overwritten with the result.
43
44 KIND may be one of:
45 GT_NOCREATE: simply verify that the name does not exist
46 at the time of the call.
47 GT_FILE: create a large file using open(O_CREAT|O_EXCL)
48 and return a read-write fd. The file is mode 0600.
49 GT_DIR: create a directory, which will be mode 0700.
50
51 We use a clever algorithm to get hard-to-predict names. */
52 extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
53
54 /* Similar to gen_tempname, but TRYFUNC is called for each temporary
55 name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
56 returns with this value. Otherwise, if errno is set to EEXIST, another
57 name is tried, or else TRY_GEN_TEMPNAME returns -1. */
58 extern int try_tempname (char *tmpl, int suffixlen, void *args,
59 int (*tryfunc) (char *, void *));
60
61 #ifdef __cplusplus
62 }
63 #endif
64
65 #endif /* GL_TEMPNAME_H */
This page took 0.03148 seconds and 3 git commands to generate.