Blob


1 /*
2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 /* Utilities for opening temporary files. */
19 #ifndef GOT_TMPDIR
20 #define GOT_TMPDIR /tmp
21 #endif
22 #define GOT_STRINGIFY_TMP(x) #x
23 #define GOT_STRINGVAL_TMP(x) GOT_STRINGIFY_TMP(x)
24 #define GOT_TMPDIR_STR GOT_STRINGVAL_TMP(GOT_TMPDIR)
26 /* Open a file descriptor to a new temporary file for writing.
27 * The file is not visible in the filesystem. */
28 int got_opentempfd(void);
30 /* Open a new temporary file for writing.
31 * The file is not visible in the filesystem. */
32 FILE *got_opentemp(void);
34 /* Open a new temporary file for writing.
35 * The file is visible in the filesystem. */
36 const struct got_error *got_opentemp_named(char **, FILE **, const char *);
38 /* Like got_opentemp_named() but returns a file descriptor instead of a FILE. */
39 const struct got_error *got_opentemp_named_fd(char **, int *, const char *);