docs: add documentation to each .h.md file
This commit is contained in:
parent
20be391329
commit
444d1fc956
8 changed files with 166 additions and 2 deletions
|
|
@ -1,9 +1,18 @@
|
||||||
|
# cli.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef CLI_H
|
#ifndef CLI_H
|
||||||
# define CLI_H
|
# define CLI_H
|
||||||
|
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
### `t_args`
|
||||||
|
Struct to hold command-line arguments.
|
||||||
|
```c
|
||||||
typedef struct s_args
|
typedef struct s_args
|
||||||
{
|
{
|
||||||
const char *ext;
|
const char *ext;
|
||||||
|
|
@ -12,12 +21,24 @@ typedef struct s_args
|
||||||
const char *map_path;
|
const char *map_path;
|
||||||
uint8_t show_help;
|
uint8_t show_help;
|
||||||
} t_args;
|
} t_args;
|
||||||
|
```
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### [`cli_parse`](/srcs/cli/cli.c.md)
|
||||||
|
Parses command-line arguments and populates the t_args structure.
|
||||||
|
```c
|
||||||
int8_t
|
int8_t
|
||||||
cli_parse(t_args *args, int32_t argc, char **argv);
|
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
|
void
|
||||||
cli_print_help(const char *progname);
|
cli_print_help(const char *progname);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
# map_internal.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef MAP_INTERNAL_H
|
#ifndef MAP_INTERNAL_H
|
||||||
# define MAP_INTERNAL_H
|
# define MAP_INTERNAL_H
|
||||||
|
|
@ -5,11 +8,19 @@
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include "map.h"
|
# 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
|
int8_t
|
||||||
map_grow(t_map *map);
|
map_grow(t_map *map);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
# transpile_internal.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef TRANSPILE_INTERNAL_H
|
#ifndef TRANSPILE_INTERNAL_H
|
||||||
# define TRANSPILE_INTERNAL_H
|
# define TRANSPILE_INTERNAL_H
|
||||||
|
|
@ -5,7 +8,13 @@
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include "map.h"
|
# include "map.h"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
### `t_state`
|
||||||
|
Struct to hold the state of the transpilation process.
|
||||||
|
```c
|
||||||
typedef struct s_state
|
typedef struct s_state
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
|
|
@ -19,18 +28,39 @@ typedef struct s_state
|
||||||
uint8_t in_block;
|
uint8_t in_block;
|
||||||
uint8_t first_block;
|
uint8_t first_block;
|
||||||
} t_state;
|
} t_state;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### [`state_init`](/srcs/transpile/state.c.md)
|
||||||
|
Initializes the transpilation state.
|
||||||
|
```c
|
||||||
void
|
void
|
||||||
state_init(t_state *s, FILE *in, FILE *out, const char *ext, t_map *map);
|
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
|
int8_t
|
||||||
handle_fence_open(t_state *s, char *line);
|
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
|
int8_t
|
||||||
handle_fence_close(t_state *s);
|
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
|
int8_t
|
||||||
handle_code_line(t_state *s, char *line);
|
handle_code_line(t_state *s, char *line);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,40 @@
|
||||||
|
# io.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef IO_H
|
#ifndef IO_H
|
||||||
# define IO_H
|
# define IO_H
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Types
|
||||||
|
```c
|
||||||
typedef struct s_io
|
typedef struct s_io
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
} t_io;
|
} t_io;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### [`io_open`](/srcs/io/streams.c.md)
|
||||||
|
Opens input and output streams based on provided file paths.
|
||||||
|
```c
|
||||||
int8_t
|
int8_t
|
||||||
io_open(t_io *io, const char *input_path, const char *output_path);
|
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
|
void
|
||||||
io_close(t_io *io);
|
io_close(t_io *io);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,20 @@
|
||||||
|
# map.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef MAP_H
|
#ifndef MAP_H
|
||||||
# define MAP_H
|
# define MAP_H
|
||||||
|
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Types
|
||||||
|
|
||||||
|
### `t_range`
|
||||||
|
A structure representing a mapping range between source and destination
|
||||||
|
addresses.
|
||||||
|
```c
|
||||||
typedef struct s_range
|
typedef struct s_range
|
||||||
{
|
{
|
||||||
uint32_t src_start;
|
uint32_t src_start;
|
||||||
|
|
@ -12,26 +22,51 @@ typedef struct s_range
|
||||||
uint32_t dst_start;
|
uint32_t dst_start;
|
||||||
uint32_t dst_end;
|
uint32_t dst_end;
|
||||||
} t_range;
|
} t_range;
|
||||||
|
```
|
||||||
|
|
||||||
|
### `t_map`
|
||||||
|
A structure representing a collection of mapping ranges.
|
||||||
|
```c
|
||||||
typedef struct s_map
|
typedef struct s_map
|
||||||
{
|
{
|
||||||
t_range *ranges;
|
t_range *ranges;
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
} t_map;
|
} t_map;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### [`map_init`](/srcs/map/core.c.md)
|
||||||
|
Initialize a mapping structure.
|
||||||
|
```c
|
||||||
void
|
void
|
||||||
map_init(t_map *map);
|
map_init(t_map *map);
|
||||||
|
```
|
||||||
|
|
||||||
|
### [`map_add`](/srcs/map/core.c.md)
|
||||||
|
Add a new mapping range to the mapping structure.
|
||||||
|
```c
|
||||||
void
|
void
|
||||||
map_add(t_map *map, uint32_t src_start, uint32_t src_end,
|
map_add(t_map *map, uint32_t src_start, uint32_t src_end,
|
||||||
uint32_t dst_start, uint32_t dst_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
|
int8_t
|
||||||
map_write(t_map *map, const char *path, const char *source, const char *target);
|
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
|
void
|
||||||
map_free(t_map *map);
|
map_free(t_map *map);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
# transpile.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef TRANSPILE_H
|
#ifndef TRANSPILE_H
|
||||||
# define TRANSPILE_H
|
# define TRANSPILE_H
|
||||||
|
|
@ -5,9 +8,16 @@
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include "map.h"
|
# include "map.h"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
### [`transpile`](/srcs/transpile/core.c.md)
|
||||||
|
```c
|
||||||
int8_t
|
int8_t
|
||||||
transpile(FILE *in, FILE *out, const char *ext, t_map *map);
|
transpile(FILE *in, FILE *out, const char *ext, t_map *map);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,51 @@
|
||||||
|
# utils.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
# define UTILS_H
|
# define UTILS_H
|
||||||
|
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
```
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### [`read_line`](/srcs/utils/io/read_line.c.md)
|
||||||
|
Get a line from a file.
|
||||||
|
```c
|
||||||
char *
|
char *
|
||||||
read_line(FILE *f);
|
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
|
int8_t
|
||||||
starts_with(const char *str, const char *prefix);
|
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 *
|
char *
|
||||||
extract_fence_ext(const char *fence);
|
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 *
|
const char *
|
||||||
extract_file_ext(const char *path);
|
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 *
|
const char *
|
||||||
infer_ext_from_filename(const char *path);
|
infer_ext_from_filename(const char *path);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,23 @@
|
||||||
|
# validator.h
|
||||||
|
|
||||||
|
## Include Guard
|
||||||
```c
|
```c
|
||||||
#ifndef VALIDATOR_H
|
#ifndef VALIDATOR_H
|
||||||
# define VALIDATOR_H
|
# define VALIDATOR_H
|
||||||
|
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include "cli.h"
|
# 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
|
int8_t
|
||||||
validator_validate_args(t_args *args);
|
validator_validate_args(t_args *args);
|
||||||
|
```
|
||||||
|
|
||||||
|
## End Guard
|
||||||
|
```c
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue