Blame lib/tempname.h

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