2024-03-12 19:24:48 +00:00
|
|
|
#ifndef _FT_NM_H
|
|
|
|
# define _FT_NM_H
|
|
|
|
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <sys/mman.h>
|
|
|
|
# include <fcntl.h>
|
|
|
|
# include <stdio.h>
|
2024-03-20 20:47:46 +00:00
|
|
|
# include <elf.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <stdbool.h>
|
|
|
|
# include <stdarg.h>
|
2024-03-12 19:24:48 +00:00
|
|
|
|
2024-03-13 14:41:03 +00:00
|
|
|
# include "libft.h"
|
|
|
|
|
2024-03-15 14:58:57 +00:00
|
|
|
# define FT_NM_SUCCESS 0
|
|
|
|
# define FT_NM_FAILURE -1
|
|
|
|
|
2024-10-13 17:13:00 +00:00
|
|
|
typedef enum e_verbosity {
|
|
|
|
ALL,
|
2024-10-14 19:56:32 +00:00
|
|
|
DEFAULT_VERBOSITY,
|
2024-10-13 17:13:00 +00:00
|
|
|
GLOBAL,
|
|
|
|
UNDEFINED
|
|
|
|
} t_verbosity;
|
|
|
|
|
|
|
|
typedef enum e_ordering {
|
|
|
|
DEFAULT_ORDERING,
|
|
|
|
REVERSE,
|
|
|
|
NOSORT
|
|
|
|
} t_ordering;
|
|
|
|
|
2024-10-14 19:56:32 +00:00
|
|
|
typedef struct s_entry {
|
|
|
|
t_verbosity verbosity;
|
|
|
|
char *string;
|
|
|
|
char *symbol;
|
|
|
|
} t_entry;
|
|
|
|
|
2024-10-13 17:13:00 +00:00
|
|
|
typedef struct s_env {
|
|
|
|
char *bin_name;
|
|
|
|
t_verbosity verbosity;
|
|
|
|
t_ordering ordering;
|
|
|
|
t_list *list;
|
|
|
|
int list_len;
|
|
|
|
bool has_multiple_files;
|
|
|
|
} t_env;
|
|
|
|
|
2024-03-20 20:47:46 +00:00
|
|
|
typedef struct s_mapped_file {
|
|
|
|
void *ptr;
|
|
|
|
off_t size;
|
|
|
|
} t_mapped_file;
|
|
|
|
|
|
|
|
void ft_printf(const char *format, ...);
|
2024-03-15 14:58:57 +00:00
|
|
|
void ft_nm_error(const char *path);
|
2024-03-20 20:47:46 +00:00
|
|
|
|
2024-03-19 10:22:37 +00:00
|
|
|
int check_ident(unsigned char ident[EI_NIDENT]);
|
2024-03-20 20:47:46 +00:00
|
|
|
void *fetch(t_mapped_file mapped_file, size_t offset, size_t fetch_size);
|
|
|
|
|
2024-10-25 10:36:52 +00:00
|
|
|
int nm32(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering);
|
|
|
|
int get_header32(t_mapped_file mapped_file, Elf32_Ehdr *header);
|
2024-03-25 10:06:09 +00:00
|
|
|
|
2024-10-14 19:56:32 +00:00
|
|
|
int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering);
|
2024-03-25 10:06:09 +00:00
|
|
|
int get_header64(t_mapped_file mapped_file, Elf64_Ehdr *header);
|
2024-03-15 14:58:57 +00:00
|
|
|
|
2024-10-25 10:36:52 +00:00
|
|
|
int strcmp_nm(void *a, void *b);
|
|
|
|
int reverse(void *a, void *b);
|
|
|
|
int nosort(void *a, void *b);
|
|
|
|
void put_entry(void *data);
|
2024-10-25 12:47:21 +00:00
|
|
|
void free_entry(void *data);
|
2024-10-25 10:36:52 +00:00
|
|
|
|
2024-10-14 19:56:32 +00:00
|
|
|
char ft_get_hex_digit(char c);
|
|
|
|
|
2024-03-12 19:24:48 +00:00
|
|
|
#endif
|
2024-03-19 10:22:37 +00:00
|
|
|
|