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

Functions

EXPORT errno_t fopen_s (FILE *restrict *restrict streamptr, const char *restrict filename, const char *restrict mode)
 The fopen_s function opens a file indicated by filename and updates the pointer to the file stream associated with that file. More...
 

Function Documentation

◆ fopen_s()

EXPORT errno_t fopen_s ( FILE *restrict *restrict  streamptr,
const char *restrict  filename,
const char *restrict  mode 
)

The fopen_s function opens a file indicated by filename and updates the pointer to the file stream associated with that file.

mode is used to determine the file access mode.

Remarks
SPECIFIED IN
Parameters
[out]streamptrpointer to a FILE stream that will be updated by this function call
[in]filename
[in]modeas in fopen
Precondition
Neither streamptr, filename nor mode shall be a null pointer.

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

Returns
The fopen_s function returns zero if it created the file. If it did not create the file or there was a runtime-constraint violation, fopen_s returns a nonzero error code, sets streamptr to NULL. If there is a runtime-constraint violation, fopen_s does not attempt to create a file. Sets the streamptr on success.
Return values
EOKon success
ESNULLPwhen any argument is a NULL pointer
>0 any other errno