2 * fontconfig/src/fccompat.c
4 * Copyright © 2012 Red Hat, Inc.
9 * Permission to use, copy, modify, distribute, and sell this software and its
10 * documentation for any purpose is hereby granted without fee, provided that
11 * the above copyright notice appear in all copies and that both that
12 * copyright notice and this permission notice appear in supporting
13 * documentation, and that the name of the author(s) not be used in
14 * advertising or publicity pertaining to distribution of the software without
15 * specific, written prior permission. The authors make no
16 * representations about the suitability of this software for any purpose. It
17 * is provided "as is" without express or implied warranty.
19 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
21 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 * PERFORMANCE OF THIS SOFTWARE.
41 #define FC_O_CLOEXEC O_CLOEXEC
43 #define FC_O_CLOEXEC 0
46 #define FC_O_LARGEFILE O_LARGEFILE
48 #define FC_O_LARGEFILE 0
52 FcOpen(const char *pathname, int flags, ...)
62 mode = (mode_t) va_arg(ap, int);
65 fd = open(pathname, flags | FC_O_CLOEXEC | FC_O_LARGEFILE, mode);
69 fd = open(pathname, flags | FC_O_CLOEXEC | FC_O_LARGEFILE);
76 FcMakeTempfile (char *template)
81 fd = mkostemp (template, FC_O_CLOEXEC);
83 fd = mkstemp (template);
84 # ifdef F_DUPFD_CLOEXEC
87 int newfd = fcntl(fd, F_DUPFD_CLOEXEC);
92 # elif defined(FD_CLOEXEC)
95 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
99 if (_mktemp_s(template, strlen(template) + 1) != 0)
101 fd = FcOpen(template, O_RDWR | O_EXCL | O_CREAT, 0600);
103 #error no secure functions to create a temporary file