file_util.c File Reference

File utility module implementation file. More...

#include "file_util.h"
#include "log_util.h"
#include "definitions.h"
Include dependency graph for file_util.c:

Go to the source code of this file.

Functions

E_MCL_ERROR_CODE file_util_fopen (const char *file_name, const char *mode, void **file_descriptor)
 
E_MCL_ERROR_CODE file_util_fopen_without_log (const char *file_name, const char *mode, void **file_descriptor)
 
E_MCL_ERROR_CODE file_util_fclose (void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fclose_without_log (void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fwrite (const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fwrite_without_log (const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor)
 
void file_util_fread (void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor, mcl_size_t *actual_count)
 
E_MCL_ERROR_CODE file_util_fputs (const char *data, void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fgets (char *data, mcl_size_t data_size, void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fstat (void *file_descriptor, struct stat *file_attributes)
 
E_MCL_ERROR_CODE file_util_fflush (void *file_descriptor)
 
E_MCL_ERROR_CODE file_util_fflush_without_log (void *file_descriptor)
 
mcl_bool_t file_util_check_if_regular_file (const mcl_stat_t *file_attributes)
 

Detailed Description

File utility module implementation file.


Date
Oct 5, 2016

Definition in file file_util.c.

Function Documentation

mcl_bool_t file_util_check_if_regular_file ( const mcl_stat_t file_attributes)

This function is used to check if file is a regular file.

Parameters
[in]file_attributesStructure holding the file attributes.
Returns

Definition at line 216 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and MCL_FALSE.

Referenced by file_initialize().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fclose ( void *  file_descriptor)

This function is used to close the file opened beforehand.

Parameters
[in]file_descriptorFile descriptor of the file to close.
Returns

Definition at line 52 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and file_util_fclose_without_log().

Referenced by _check_file_path(), file_destroy(), storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), storage_save_rsa_registration_information(), and storage_save_shared_secret_registration_information().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fclose_without_log ( void *  file_descriptor)

This function is used to close the file opened beforehand. It has the same functionality as file_util_fclose except that it does not log any debug messages.

Parameters
[in]file_descriptorFile descriptor of the file to close.
Returns

Definition at line 62 of file file_util.c.

References MCL_FAIL, MCL_NULL, and MCL_OK.

Referenced by file_util_fclose(), and mcl_log_util_finalize().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fflush ( void *  file_descriptor)

This function flushes pending content to file_descriptor.

Parameters
[in]file_descriptorFile descriptor obtained by opening the file.
Returns

Definition at line 182 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and file_util_fflush_without_log().

Here is the call graph for this function:

E_MCL_ERROR_CODE file_util_fflush_without_log ( void *  file_descriptor)

This function flushes pending content to file_descriptor.

Note
There are no debug entry and debug leave functions in this function.
Parameters
[in]file_descriptorFile descriptor obtained by opening the file.
Returns

Definition at line 192 of file file_util.c.

References MCL_ERROR, MCL_FAIL, and MCL_OK.

Referenced by file_util_fflush(), and log_util_default_callback().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fgets ( char *  data,
mcl_size_t  data_size,
void *  file_descriptor 
)

This function is used to read a string from a file. A maximum of data_size - 1 characters are read from the file and a terminating null character is immediately added after the last character of data. No additional characters are read after the new line character of after end of file.

Parameters
[out]dataPointer to the string to read from file.
[in]data_sizeMaximum number of characters to read from file including the null terminator.
[in]file_descriptorFile descriptor of the file to read from.
Returns

Definition at line 135 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_FAIL, MCL_NULL, and MCL_OK.

Referenced by _get_private_key(), _get_public_key(), storage_load_rsa_registration_information(), and storage_load_shared_secret_registration_information().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fopen ( const char *  file_name,
const char *  mode,
void **  file_descriptor 
)

This function is used to open a file.

Parameters
[in]file_nameFile name to open.
[in]modeMode of the file to open. Please refer to the modes of fopen() function in ANSI standard.
[out]file_descriptorFile descriptor for the file opened. This descriptor is used to process the file.
Returns
  • MCL_OK in case of success.
  • MCL_FAIL in case the file can not be opened.

Definition at line 22 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and file_util_fopen_without_log().

Referenced by _check_file_path(), file_initialize(), storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), storage_save_rsa_registration_information(), and storage_save_shared_secret_registration_information().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fopen_without_log ( const char *  file_name,
const char *  mode,
void **  file_descriptor 
)

This function is used to open a file.

Note
There are no debug entry and debug leave functions in this function.
Parameters
[in]file_nameFile name to open.
[in]modeMode of the file to open. Please refer to the modes of fopen() function in ANSI standard.
[out]file_descriptorFile descriptor for the file opened. This descriptor is used to process the file.
Returns
  • MCL_OK in case of success.
  • MCL_FAIL in case the file can not be opened.

Definition at line 32 of file file_util.c.

References MCL_FAIL, MCL_NULL, and MCL_OK.

Referenced by file_util_fopen(), and mcl_log_util_initialize().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fputs ( const char *  data,
void *  file_descriptor 
)

This function is used to write a string to a file. The terminating null character is not written.

Parameters
[in]dataPointer to the string to write to file.
[in]file_descriptorFile descriptor of the file to write to.
Returns

Definition at line 115 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_ERROR, MCL_FAIL, and MCL_OK.

Referenced by storage_save_rsa_registration_information(), and storage_save_shared_secret_registration_information().

Here is the caller graph for this function:

void file_util_fread ( void *  data,
mcl_size_t  size,
mcl_size_t  count,
void *  file_descriptor,
mcl_size_t actual_count 
)

This function is used to read data from a file into memory.

Parameters
[in]dataPointer to the memory (size x count bytes allocated a priori) to store the data from the file.
[in]sizeSize of each element requested.
[in]countNumber of elements requested.
[in]file_descriptorFile descriptor of the file to read from.
[out]actual_countNumber of elements actually read from file.

Definition at line 105 of file file_util.c.

References DEBUG_ENTRY, and DEBUG_LEAVE.

Referenced by _get_payload_from_file().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fstat ( void *  file_descriptor,
struct stat *  file_attributes 
)

Definition at line 155 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, MCL_ERROR, MCL_FAIL, and MCL_OK.

Referenced by file_initialize().

Here is the caller graph for this function:

E_MCL_ERROR_CODE file_util_fwrite ( const void *  data,
mcl_size_t  size,
mcl_size_t  count,
void *  file_descriptor 
)

This function is used to write data in memory to a file.

Parameters
[in]dataPointer to the data to write to file.
[in]sizeSize of each element in data.
[in]countNumber of elements in data.
[in]file_descriptorFile descriptor of the file to write to.
Returns

Definition at line 78 of file file_util.c.

References DEBUG_ENTRY, DEBUG_LEAVE, and file_util_fwrite_without_log().

Here is the call graph for this function:

E_MCL_ERROR_CODE file_util_fwrite_without_log ( const void *  data,
mcl_size_t  size,
mcl_size_t  count,
void *  file_descriptor 
)

This function is used to write data in memory to a file.

Note
There are no debug entry and debug leave functions in this function.
Parameters
[in]dataPointer to the data to write to file.
[in]sizeSize of each element in data.
[in]countNumber of elements in data.
[in]file_descriptorFile descriptor of the file to write to.
Returns

Definition at line 88 of file file_util.c.

References MCL_ERROR, MCL_FAIL, and MCL_OK.

Referenced by file_util_fwrite(), and log_util_default_callback().

Here is the caller graph for this function: