1 /* @(#)mkstemp.c 1.2 14/05/15 Copyright 2011-2014 J. Schilling */ 2 /* 3 * Copyright (c) 2011-2014 J. Schilling 4 */ 5 /* 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * See the file CDDL.Schily.txt in this distribution for details. 12 * A copy of the CDDL is also available via the Internet at 13 * http://www.opensource.org/licenses/cddl1.txt 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file CDDL.Schily.txt from this distribution. 17 */ 18 19 #include <schily/mconfig.h> 20 #include <schily/standard.h> 21 #include <schily/stdlib.h> 22 #include <schily/types.h> 23 #include <schily/fcntl.h> 24 #include <schily/stat.h> 25 #include <schily/errno.h> 26 27 #ifndef HAVE_MKSTEMP 28 EXPORT int mkstemp(path)29mkstemp(path) 30 char *path; 31 { 32 #ifdef HAVE_MKTEMP 33 mktemp(path); 34 return (open(path, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR)); 35 #else 36 #ifdef ENOSYS 37 seterrno(ENOSYS); 38 #else 39 seterrno(EINVAL); 40 #endif 41 return (-1); 42 #endif 43 } 44 #endif 45