ft_nm/src/header.c

27 lines
569 B
C
Raw Normal View History

2024-03-15 14:58:57 +00:00
#include "ft_nm.h"
int check_magic_number(Elf64_Ehdr *header) {
if (ft_strncmp((void *)&header->e_ident[EI_MAG0], "\x7f""ELF", 4)) {
return FT_NM_FAILURE;
}
return FT_NM_SUCCESS;
}
int check_format(Elf64_Ehdr *header) {
if (header->e_ident[EI_CLASS] == ELFCLASSNONE) {
printf("problem\n");
return FT_NM_FAILURE;
}
return FT_NM_SUCCESS;
}
int check_header(Elf64_Ehdr *header) {
if (check_magic_number(header) == FT_NM_FAILURE) {
return FT_NM_FAILURE;
}
if (check_format(header) == FT_NM_FAILURE) {
return FT_NM_FAILURE;
}
return FT_NM_SUCCESS;
}