Blame gnulib/lib/tempname.h

Packit Service a2ae7a
/* Create a temporary file or directory.
Packit Service a2ae7a
Packit Service a2ae7a
   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
Packit Service a2ae7a
Packit Service a2ae7a
   This program is free software: you can redistribute it and/or modify
Packit Service a2ae7a
   it under the terms of the GNU Lesser General Public License as published by
Packit Service a2ae7a
   the Free Software Foundation; either version 2.1 of the License, or
Packit Service a2ae7a
   (at your option) any later version.
Packit Service a2ae7a
Packit Service a2ae7a
   This program is distributed in the hope that it will be useful,
Packit Service a2ae7a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a2ae7a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service a2ae7a
   GNU Lesser General Public License for more details.
Packit Service a2ae7a
Packit Service a2ae7a
   You should have received a copy of the GNU Lesser General Public License
Packit Service a2ae7a
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service a2ae7a
Packit Service a2ae7a
/* header written by Eric Blake */
Packit Service a2ae7a
Packit Service a2ae7a
#ifndef GL_TEMPNAME_H
Packit Service a2ae7a
# define GL_TEMPNAME_H
Packit Service a2ae7a
Packit Service a2ae7a
# include <stdio.h>
Packit Service a2ae7a
Packit Service a2ae7a
# ifdef __GT_FILE
Packit Service a2ae7a
#  define GT_FILE     __GT_FILE
Packit Service a2ae7a
#  define GT_DIR      __GT_DIR
Packit Service a2ae7a
#  define GT_NOCREATE __GT_NOCREATE
Packit Service a2ae7a
# else
Packit Service a2ae7a
#  define GT_FILE     0
Packit Service a2ae7a
#  define GT_DIR      1
Packit Service a2ae7a
#  define GT_NOCREATE 2
Packit Service a2ae7a
# endif
Packit Service a2ae7a
Packit Service a2ae7a
#ifdef __cplusplus
Packit Service a2ae7a
extern "C" {
Packit Service a2ae7a
#endif
Packit Service a2ae7a
Packit Service a2ae7a
/* Generate a temporary file name based on TMPL.  TMPL must match the
Packit Service a2ae7a
   rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
Packit Service a2ae7a
   The name constructed does not exist at the time of the call to
Packit Service a2ae7a
   gen_tempname.  TMPL is overwritten with the result.
Packit Service a2ae7a
Packit Service a2ae7a
   KIND may be one of:
Packit Service a2ae7a
   GT_NOCREATE:         simply verify that the name does not exist
Packit Service a2ae7a
                        at the time of the call.
Packit Service a2ae7a
   GT_FILE:             create a large file using open(O_CREAT|O_EXCL)
Packit Service a2ae7a
                        and return a read-write fd.  The file is mode 0600.
Packit Service a2ae7a
   GT_DIR:              create a directory, which will be mode 0700.
Packit Service a2ae7a
Packit Service a2ae7a
   We use a clever algorithm to get hard-to-predict names. */
Packit Service a2ae7a
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
Packit Service a2ae7a
Packit Service a2ae7a
/* Similar to gen_tempname, but TRYFUNC is called for each temporary
Packit Service a2ae7a
   name to try.  If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
Packit Service a2ae7a
   returns with this value.  Otherwise, if errno is set to EEXIST, another
Packit Service a2ae7a
   name is tried, or else TRY_GEN_TEMPNAME returns -1. */
Packit Service a2ae7a
extern int try_tempname (char *tmpl, int suffixlen, void *args,
Packit Service a2ae7a
                         int (*tryfunc) (char *, void *));
Packit Service a2ae7a
Packit Service a2ae7a
#ifdef __cplusplus
Packit Service a2ae7a
}
Packit Service a2ae7a
#endif
Packit Service a2ae7a
Packit Service a2ae7a
#endif /* GL_TEMPNAME_H */