OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [tmpfile.c] - Diff between revs 1010 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/*
/*
FUNCTION
FUNCTION
<<tmpfile>>---create a temporary file
<<tmpfile>>---create a temporary file
 
 
INDEX
INDEX
        tmpfile
        tmpfile
INDEX
INDEX
        _tmpfile_r
        _tmpfile_r
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        FILE *tmpfile(void);
        FILE *tmpfile(void);
 
 
        FILE *_tmpfile_r(void *<[reent]>);
        FILE *_tmpfile_r(void *<[reent]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        FILE *tmpfile();
        FILE *tmpfile();
 
 
        FILE *_tmpfile_r(<[reent]>)
        FILE *_tmpfile_r(<[reent]>)
        char *<[reent]>;
        char *<[reent]>;
 
 
DESCRIPTION
DESCRIPTION
Create a temporary file (a file which will be deleted automatically),
Create a temporary file (a file which will be deleted automatically),
using a name generated by <<tmpnam>>.  The temporary file is opened with
using a name generated by <<tmpnam>>.  The temporary file is opened with
the mode <<"wb+">>, permitting you to read and write anywhere in it
the mode <<"wb+">>, permitting you to read and write anywhere in it
as a binary file (without any data transformations the host system may
as a binary file (without any data transformations the host system may
perform for text files).
perform for text files).
 
 
The alternate function <<_tmpfile_r>> is a reentrant version.  The
The alternate function <<_tmpfile_r>> is a reentrant version.  The
argument <[reent]> is a pointer to a reentrancy structure.
argument <[reent]> is a pointer to a reentrancy structure.
 
 
RETURNS
RETURNS
<<tmpfile>> normally returns a pointer to the temporary file.  If no
<<tmpfile>> normally returns a pointer to the temporary file.  If no
temporary file could be created, the result is NULL, and <<errno>>
temporary file could be created, the result is NULL, and <<errno>>
records the reason for failure.
records the reason for failure.
 
 
PORTABILITY
PORTABILITY
Both ANSI C and the System V Interface Definition (Issue 2) require
Both ANSI C and the System V Interface Definition (Issue 2) require
<<tmpfile>>.
<<tmpfile>>.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>,
<<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>.
<<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>.
 
 
<<tmpfile>> also requires the global pointer <<environ>>.
<<tmpfile>> also requires the global pointer <<environ>>.
*/
*/
 
 
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
#include <errno.h>
 
 
FILE *
FILE *
_DEFUN (_tmpfile_r, (ptr),
_DEFUN (_tmpfile_r, (ptr),
        struct _reent *ptr)
        struct _reent *ptr)
{
{
  FILE *fp;
  FILE *fp;
  int e;
  int e;
  char *f;
  char *f;
  char buf[L_tmpnam];
  char buf[L_tmpnam];
 
 
  if ((f = _tmpnam_r (ptr, buf)) == NULL)
  if ((f = _tmpnam_r (ptr, buf)) == NULL)
    return NULL;
    return NULL;
  fp = fopen (f, "wb+");
  fp = fopen (f, "wb+");
  e = ptr->_errno;
  e = ptr->_errno;
  _CAST_VOID remove (f);
  _CAST_VOID remove (f);
  ptr->_errno = e;
  ptr->_errno = e;
  return fp;
  return fp;
}
}
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
FILE *
FILE *
_DEFUN_VOID (tmpfile)
_DEFUN_VOID (tmpfile)
{
{
  return _tmpfile_r (_REENT);
  return _tmpfile_r (_REENT);
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.