safec  3.0
Safe C Library - ISO TR24731 Bounds Checking Interface
tmpfile_s.c File Reference
#include "safe_lib.h"
+ Include dependency graph for tmpfile_s.c:

Functions

EXPORT errno_t tmpfile_s (FILE *restrict *restrict streamptr)
 The tmpfile_s function creates a temporary binary file that is different from any other existing file and that will automatically be removed when it is closed or at program termination. More...
 

Function Documentation

◆ tmpfile_s()

EXPORT errno_t tmpfile_s ( FILE *restrict *restrict  streamptr)

The tmpfile_s function creates a temporary binary file that is different from any other existing file and that will automatically be removed when it is closed or at program termination.

If the program terminates abnormally, whether an open temporary file is removed is implementation-defined. The file is opened for update with "wb+" mode with the meaning that mode has in the fopen_s function (including the mode’s effect on exclusive access and file permissions).

Remarks
SPECIFIED IN
Parameters
streamptrpointer to a pointer that will be updated by this function call
Precondition
streamptr shall not be a null pointer.
No more than TMP_MAX_S files may be opened

If the file was created successfully, then the pointer to FILE pointed to by streamptr will be set to the pointer to the object controlling the opened file. Otherwise, the pointer to FILE pointed to by streamptr will be set to a null pointer.

Returns
The tmpfile_s function returns zero if it created the file. If it did not create the file or there was a runtime-constraint violation, tmpfile_s returns a nonzero value. If there is a runtime-constraint violation, tmpfile_s does not attempt to create a file. Sets the streamptr on success.
Return values
EOKon success
ESNULLPwhen streamptr is a NULL pointer
ESLEMAXwhen more than TMP_MAX_S files were opened.
errno()when tmpfile() failed, typically ENOENT