diff --git a/includes/cli.h.md b/includes/cli.h.md index edbff2a..d2aa5ef 100644 --- a/includes/cli.h.md +++ b/includes/cli.h.md @@ -1,9 +1,18 @@ +# cli.h + +## Include Guard ```c #ifndef CLI_H # define CLI_H # include +``` +## Types + +### `t_args` +Struct to hold command-line arguments. +```c typedef struct s_args { const char *ext; @@ -12,12 +21,24 @@ typedef struct s_args const char *map_path; uint8_t show_help; } t_args; +``` +## Functions +### [`cli_parse`](/srcs/cli/cli.c.md) +Parses command-line arguments and populates the t_args structure. +```c int8_t cli_parse(t_args *args, int32_t argc, char **argv); +``` +### [`cli_print_help`](/srcs/cli/help.c.md) +Prints help information for the command-line interface. +```c void cli_print_help(const char *progname); +``` +## End Guard +```c #endif ``` diff --git a/includes/internal/map_internal.h.md b/includes/internal/map_internal.h.md index e2d9bba..9b1bf8e 100644 --- a/includes/internal/map_internal.h.md +++ b/includes/internal/map_internal.h.md @@ -1,3 +1,6 @@ +# map_internal.h + +## Include Guard ```c #ifndef MAP_INTERNAL_H # define MAP_INTERNAL_H @@ -5,11 +8,19 @@ # include # include # include "map.h" +# define MAP_INIT_CAP 16 // Default initial capacity for the map +``` -# define MAP_INIT_CAP 16 +## Functions +### [`map_grow`](/srcs/map/core.c.md) +Grows the map's capacity when needed. +```c int8_t map_grow(t_map *map); +``` +## End Guard +```c #endif ``` diff --git a/includes/internal/transpile_internal.h.md b/includes/internal/transpile_internal.h.md index 4916207..22fbad8 100644 --- a/includes/internal/transpile_internal.h.md +++ b/includes/internal/transpile_internal.h.md @@ -1,3 +1,6 @@ +# transpile_internal.h + +## Include Guard ```c #ifndef TRANSPILE_INTERNAL_H # define TRANSPILE_INTERNAL_H @@ -5,7 +8,13 @@ # include # include # include "map.h" +``` +## Types + +### `t_state` +Struct to hold the state of the transpilation process. +```c typedef struct s_state { FILE *in; @@ -19,18 +28,39 @@ typedef struct s_state uint8_t in_block; uint8_t first_block; } t_state; +``` +## Functions + +### [`state_init`](/srcs/transpile/state.c.md) +Initializes the transpilation state. +```c void state_init(t_state *s, FILE *in, FILE *out, const char *ext, t_map *map); +``` +### [`handle_fence_open`](/srcs/transpile/fence.c.md) +Handles the opening of a code fence in the input. +```c int8_t handle_fence_open(t_state *s, char *line); +``` +### [`handle_fence_close`](/srcs/transpile/fence.c.md) +Handles the closing of a code fence in the input. +```c int8_t handle_fence_close(t_state *s); +``` +### [`handle_line`](/srcs/transpile/code.c.md) +Handles a regular line of code in the input. +```c int8_t handle_code_line(t_state *s, char *line); +``` +## End Guard +```c #endif ``` diff --git a/includes/io.h.md b/includes/io.h.md index a5d18a4..df41754 100644 --- a/includes/io.h.md +++ b/includes/io.h.md @@ -1,21 +1,40 @@ +# io.h + +## Include Guard ```c #ifndef IO_H # define IO_H # include # include +``` +## Types +```c typedef struct s_io { FILE *in; FILE *out; } t_io; +``` +## Functions + +### [`io_open`](/srcs/io/streams.c.md) +Opens input and output streams based on provided file paths. +```c int8_t io_open(t_io *io, const char *input_path, const char *output_path); +``` +### [`io_close`](/srcs/io/streams.c.md) +Closes the input and output streams if they are not stdin or stdout. +```c void io_close(t_io *io); +``` +## End Guard +```c #endif ``` diff --git a/includes/map.h.md b/includes/map.h.md index 5576490..b62bcb2 100644 --- a/includes/map.h.md +++ b/includes/map.h.md @@ -1,10 +1,20 @@ +# map.h + +## Include Guard ```c #ifndef MAP_H # define MAP_H # include # include +``` +## Types + +### `t_range` +A structure representing a mapping range between source and destination +addresses. +```c typedef struct s_range { uint32_t src_start; @@ -12,26 +22,51 @@ typedef struct s_range uint32_t dst_start; uint32_t dst_end; } t_range; +``` +### `t_map` +A structure representing a collection of mapping ranges. +```c typedef struct s_map { t_range *ranges; size_t count; size_t capacity; } t_map; +``` +## Functions + +### [`map_init`](/srcs/map/core.c.md) +Initialize a mapping structure. +```c void map_init(t_map *map); +``` +### [`map_add`](/srcs/map/core.c.md) +Add a new mapping range to the mapping structure. +```c void map_add(t_map *map, uint32_t src_start, uint32_t src_end, uint32_t dst_start, uint32_t dst_end); +``` +### [`map_write`](/srcs/map/io.c.md) +Write the mapping information to a file. +```c int8_t map_write(t_map *map, const char *path, const char *source, const char *target); +``` +### [`map_free`](/srcs/map/core.c.md) +Free the resources associated with the mapping structure. +```c void map_free(t_map *map); +``` +## End Guard +```c #endif ``` diff --git a/includes/transpile.h.md b/includes/transpile.h.md index f26b11b..7a103fe 100644 --- a/includes/transpile.h.md +++ b/includes/transpile.h.md @@ -1,3 +1,6 @@ +# transpile.h + +## Include Guard ```c #ifndef TRANSPILE_H # define TRANSPILE_H @@ -5,9 +8,16 @@ # include # include # include "map.h" +``` +## Functions +### [`transpile`](/srcs/transpile/core.c.md) +```c int8_t transpile(FILE *in, FILE *out, const char *ext, t_map *map); +``` +## End Guard +```c #endif ``` diff --git a/includes/utils.h.md b/includes/utils.h.md index 533220b..f10ad71 100644 --- a/includes/utils.h.md +++ b/includes/utils.h.md @@ -1,24 +1,51 @@ +# utils.h + +## Include Guard ```c #ifndef UTILS_H # define UTILS_H # include # include +``` +## Functions +### [`read_line`](/srcs/utils/io/read_line.c.md) +Get a line from a file. +```c char * read_line(FILE *f); +``` +### [`starts_with`](/srcs/utils/string/starts_with.c.md) +Check if a string starts with a given prefix. +```c int8_t starts_with(const char *str, const char *prefix); +``` +### [`extract_fence_ext`](/srcs/utils/string/extract_fence_ext.c.md) +Extract the extension from a fence string. +```c char * extract_fence_ext(const char *fence); +``` +### [`extract_file_ext`](/srcs/utils/string/extract_file_ext.c.md) +Extract the file extension from a file path. +```c const char * extract_file_ext(const char *path); +``` +### [`infer_ext_from_filename`](/srcs/utils/string/infer_ext_from_filename.c.md) +Infer the file extension from a filename. +```c const char * infer_ext_from_filename(const char *path); +``` +## End Guard +```c #endif ``` diff --git a/includes/validator.h.md b/includes/validator.h.md index e18757a..1d33b77 100644 --- a/includes/validator.h.md +++ b/includes/validator.h.md @@ -1,12 +1,23 @@ +# validator.h + +## Include Guard ```c #ifndef VALIDATOR_H # define VALIDATOR_H - # include # include "cli.h" +``` +## Functions + +### [`validator_validate_args`](/srcs/validator/validator.c.md) +This function checks and validates the content of the `t_args` structure, +```c int8_t validator_validate_args(t_args *args); +``` +## End Guard +```c #endif ```