mkostemp.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2023 Free Software
  2. Foundation, Inc.
  3. This file is derived from the one in the GNU C Library.
  4. This file is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. This file is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  14. #if !_LIBC
  15. # include <config.h>
  16. #endif
  17. #include <stdlib.h>
  18. #if !_LIBC
  19. # include "tempname.h"
  20. # define __gen_tempname gen_tempname
  21. # ifndef __GTFILE
  22. # define __GT_FILE GT_FILE
  23. # endif
  24. #endif
  25. #include <stdio.h>
  26. #ifndef __GT_FILE
  27. # define __GT_FILE 0
  28. #endif
  29. /* Generate a unique temporary file name from XTEMPLATE.
  30. The last six characters of XTEMPLATE must be "XXXXXX";
  31. they are replaced with a string that makes the file name unique.
  32. Then open the file and return a fd. */
  33. int
  34. mkostemp (char *xtemplate, int flags)
  35. {
  36. return __gen_tempname (xtemplate, 0, flags, __GT_FILE);
  37. }