1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-12-25 23:00:07 +05:30

always use name file instead of f

This commit is contained in:
Intel A80486DX2-66 2024-07-11 20:43:23 +03:00
parent 0833f7a4d2
commit 6d0e05de44
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B
2 changed files with 10 additions and 10 deletions

View File

@ -23,7 +23,7 @@ enum file_types {
typedef enum file_types file_type_t;
/* function definitions */
file_type_t determine_file_type(FILE* f, const char* file_name);
file_type_t determine_file_type(FILE* file, const char* file_name);
const char* file_type_to_string(file_type_t type);
#endif /* _FILE_TYPE_H */

View File

@ -5,23 +5,23 @@
if (ends_with_casefold(file_name, ext) && is_valid_file(file, type)) \
return true
#define FILE_TYPE_FREAD_ERROR_HANDLING \
if (feof(f)) \
if (feof(file)) \
return false; \
\
PERROR_MACRO("fread"); \
exit(EXIT_FAILURE)
/* function definitions */
static bool header_check(FILE* f, const char* id, size_t length);
static bool is_valid_file(FILE* f, file_type_t type);
static bool header_check(FILE* file, const char* id, size_t length);
static bool is_valid_file(FILE* file, file_type_t type);
/* function implementations */
static bool header_check(FILE* f, const char* id, size_t length) {
rewind(f);
static bool header_check(FILE* file, const char* id, size_t length) {
rewind(file);
for (size_t i = 0; i < length; i++) {
char c;
if (fread(&c, sizeof(char), 1, f) != 1) {
if (fread(&c, sizeof(char), 1, file) != 1) {
FILE_TYPE_FREAD_ERROR_HANDLING;
}
@ -32,10 +32,10 @@ static bool header_check(FILE* f, const char* id, size_t length) {
return true;
}
static bool is_valid_file(FILE* f, file_type_t type) {
static bool is_valid_file(FILE* file, file_type_t type) {
switch (type) {
case FILE_TYPE_BMP: return header_check(f, "BM", 2);
case FILE_TYPE_WAV: return header_check(f, "RIFF", 4);
case FILE_TYPE_BMP: return header_check(file, "BM", 2);
case FILE_TYPE_WAV: return header_check(file, "RIFF", 4);
default:
return true;
}