Mercurial > hg > octave-lyh
diff liboctave/tmpnam.c @ 828:df6d4ae0b46d
[project @ 1994-10-17 04:44:09 by jwe]
Initial revision
author | jwe |
---|---|
date | Mon, 17 Oct 1994 04:44:09 +0000 |
parents | |
children | 5df6426c2f00 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/liboctave/tmpnam.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public +License along with the GNU C Library; see the file COPYING. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef HAVE_TEMPNAM + +#include <stddef.h> +#include <stdio.h> +#include <string.h> + +extern char *__stdio_gen_tempname (const char *dir, const char *pfx, + int dir_search, size_t *lenptr, + FILE **streamptr); + +/* Generate a unique filename in P_tmpdir. */ +char * +tmpnam (register char *s) +{ + register char *t = __stdio_gen_tempname((const char *) NULL, + (const char *) NULL, 0, + (size_t *) NULL, (FILE **) NULL); + + if (t == NULL) + return NULL; + + if (s != NULL) + (void) strcpy(s, t); + else + s = t; + + return s; +} + +#endif