Compare commits

..

3 commits
dev ... master

Author SHA1 Message Date
aa9db0ed4a
fixed bonus issue 2024-02-15 19:10:12 +01:00
980dff66be
fixed headers 2024-02-15 18:02:41 +01:00
92796351f3
first push ? 2024-02-15 17:59:03 +01:00
209 changed files with 7044 additions and 1299 deletions

View file

@ -1,9 +0,0 @@
BasedOnStyle: Microsoft
IndentWidth: 4
ColumnLimit: 80
UseTab: Always
SortIncludes: CaseInsensitive
IndentPPDirectives: AfterHash
PPIndentWidth: 1
AllowShortIfStatementsOnASingleLine: false
AlignConsecutiveDeclarations: true

16
.clangd
View file

@ -1,16 +0,0 @@
CompileFlags: # Tweak the parse settings
Add:
- "-I/usr/include/"
- "-I/home/maix/school/push_swap/mecstd/include/"
- "-I/home/maix/school/push_swap/mecstd/output/include/"
- "-I/home/maix/school/push_swap/mecstd/generic_sources/header/"
- "-I/home/maix/school/push_swap/include/"
- "-I/home/maix/school/push_swap/output/include/"
- "-I/home/maix/school/push_swap/generic_sources/header/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/mecstd/include/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/mecstd/output/include/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/mecstd/generic_sources/header/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/include/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/output/include/"
- "-I/home/maiboyer/Documents/ring-1/push_swap/generic_sources/header/"

1
.envrc
View file

@ -1 +0,0 @@
use flake

65
.gitignore vendored
View file

@ -1,61 +1,6 @@
# Prerequisites
*.d
# Object files
build
/checker
/push_swap
*.list
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
./generic
.direnv
test
# /output/
push_swap
push_swap_visualizer
Push-Swap-Tester
checker
*.d

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "mecstd"]
path = mecstd
url = git@github.com:Maix0/mecstd.git

151
Makefile
View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
# Updated: 2024/02/09 15:27:44 by maiboyer ### ########.fr #
# Updated: 2024/02/15 17:58:38 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
@ -16,8 +16,8 @@ BUILD_DIR = build
SRC_DIR = src
INCLUDE_DIR = include
LIBS_DIR = .
GENERIC_DIR = output/src
GENERIC_INCLUDE = output/include
GENERIC_DIR =
GENERIC_INCLUDE =
NAME = push_swap
@ -30,13 +30,150 @@ endif
LIB_NAME ?=
TARGET = $(NAME)
CC ?= clang
CFLAGS += -Wall -Werror -Wextra -g2 -lme -L$(BUILD_DIR) -Wno-unused-command-line-argument -MMD
CFLAGS += -Wall -Werror -Wextra -g3 -L$(BUILD_DIR) -Wno-unused-command-line-argument -MMD
BONUS_FILES =
LIBS_NAME = mecstd
LIBS_NAME =
SUBJECT_URL = 'https://cdn.intra.42.fr/pdf/pdf/118610/en.subject.pdf'
GENERIC_FILES = $(shell cat ./gen.list)
SRC_FILES = $(shell cat ./src.list)
GENERIC_FILES =
SRC_FILES = \
app/actual_main \
app/best_index_to_move \
app/best_move \
app/do_move \
app/find_place \
app/iter_find \
app/main \
app/main_bonus \
app/moves \
app/moves/push \
app/moves/rev_rotate \
app/moves/rotate \
app/moves/swap \
app/rotate \
app/run_with_items \
app/sort2 \
app/sort3 \
app/sort5 \
app/state \
app/target \
bonus/move1 \
buffered_str/mod \
char/isalnum \
char/isalpha \
char/isascii \
char/isdigit \
char/islower \
char/isprint \
char/isspace \
char/isupper \
char/tolower \
char/toupper \
convert/atoi \
convert/itoa \
convert/str_to_i16 \
convert/str_to_i16_utils \
convert/str_to_i32 \
convert/str_to_i32_utils \
convert/str_to_i64 \
convert/str_to_i64_utils \
convert/str_to_i8 \
convert/str_to_i8_utils \
convert/str_to_u16 \
convert/str_to_u16_utils \
convert/str_to_u32 \
convert/str_to_u32_utils \
convert/str_to_u64 \
convert/str_to_u64_utils \
convert/str_to_u8 \
convert/str_to_u8_utils \
fs/close \
fs/open \
fs/putchar_fd \
fs/putendl_fd \
fs/putnbr_fd \
fs/putstr_fd \
fs/read \
fs/read_to_vec \
fs/write \
gnl/get_next_line \
hash/hasher \
hash/hash_signed \
hash/hash_unsigned \
hash/sip/sip13 \
hash/sip/sip_utils \
hash/sip/sip_utils2 \
img/qoi/qoi_decode \
img/qoi/qoi_encode \
img/qoi/qoi_fs \
img/qoi/qoi_utils \
list/list_add_back \
list/list_add_front \
list/list_alloc_node \
list/list_free_all \
list/list_free_one \
list/list_get_last \
list/list_iter \
list/list_map \
list/list_size \
mem/mem_alloc \
mem/mem_alloc_array \
mem/mem_compare \
mem/mem_copy \
mem/mem_find \
mem/mem_find_bytes \
mem/mem_move \
mem/mem_set \
mem/mem_set_zero \
num/u16/rotate \
num/u32/rotate \
num/u64/from_bytes \
num/u64/rotate \
num/u8/rotate \
num/usize/rotate \
printf/formatter/char \
printf/formatter/decimal \
printf/formatter/hex \
printf/formatter/oct \
printf/formatter/ptr \
printf/formatter/unsigned_decimal \
printf/formatter/utils \
printf/formatter/utils2 \
printf/formatter/utils3 \
printf/formatter/utils_numbers \
printf/matchers \
printf/printf \
printf/vprintf \
string/str_clone \
string/str_find_chr \
string/str_find_rev_chr \
string/str_find_str \
string/str_iter \
string/str_join \
string/str_l_cat \
string/str_l_copy \
string/str_len \
string/str_map \
string/str_n_compare \
string/str_n_find_str \
string/str_split \
string/str_substring \
string/str_trim \
vec/vec_buf_str \
vec/vec_buf_str_functions2 \
vec/vec_buf_str_functions3 \
vec/vec_i64 \
vec/vec_i64_bool \
vec/vec_i64_bool_functions2 \
vec/vec_i64_bool_functions3 \
vec/vec_i64_bool_sort \
vec/vec_i64_functions2 \
vec/vec_i64_functions3 \
vec/vec_i64_sort \
vec/vec_u8 \
vec/vec_u8_functions2 \
vec/vec_u8_functions3
BONUS = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(BONUS_FILES)))
SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES))) \
$(addsuffix .c,$(addprefix $(GENERIC_DIR)/,$(GENERIC_FILES)))

View file

@ -1,8 +0,0 @@
#!/bin/sh
ARGS="133 193 -16 -234 239 85 -223 -100 178 212 -202 -102 -199 -233 227 86 -166 224 160 -21 -56 102 -62 62 -127 89 127 -246 1 140 38 157 179 220 154 -1 125 240 -238 78 -175 222 -145 -60 115 67 -220 80 -136 -134 -159 35 136 192 47 117 -51 -140 37 6 -26 -188 213 -204 -210 14 -70 112 201 -191 -22 219 15 -143 -131 -41 -152 -187 24 215 235 -147 170 -168 12 107 105 130 -91 230 -174 -176 -224 -35 5 -110 -180 60 -59 -24 94 -196 -39 21 131 -18 165 -2 -219 -198 -19 -11 244 -151 -80 43 -17 -244 -65 124 9 -153 118 -6 -235 81 225 121 217 -43 30 218 -111 163 -9 23 214 166 207 238 -217 -161 -165 116 -170 26 -44 -106 245 -155 48 -177 75 -66 -89 109 22 56 58 -53 203 -79 39 184 -94 -231 45 246 93 13 -128 -179 -236 -139 114 63 -32 196 -205 57 249 -243 233 247 -46 -90 -47 -201 -144 221 -172 66 -38 -101 -232 175 164 -215 -195 -126 209 -108 -64 126 134 -77 -69 113 146 -211 2 88 -28 -132 -250 77 -181 191 198 183 -239 -52 -118 187 -109 4 -208 73 -96 -81 87 188 122 -120 -29 83 18 92 -83 100 -68 -221 -186 189 41 68 -150 129 -49 -137 -99 -123 -42 150 -192 -82 -158 104 -61 145 16 96 -115 -27 -119 97 -203 -240 -173 -185 -227 -98 72 -237 -7 -105 -76 149 -218 -182 54 76 61 211 173 7 185 -10 19 -15 -84 -48 36 53 -67 -63 155 -169 -138 -141 -78 33 -85 234 138 -146 223 158 135 91 108 55 32 90 226 -230 -40 177 -34 -112 -190 144 -104 -241 71 237 -226 95 208 -31 180 59 52 151 153 -135 46 -50 -154 204 132 119 70 110 199 -225 169 194 -148 148 241 -37 27 -23 176 232 -156 206 200 -167 -14 3 -209 159 -75 -248 111 -73 34 -113 -184 25 -86 -122 106 11 162 -133 -88 -245 147 -178 -197 190 -117 84 210 -54 -247 98 -157 64 -95 -129 10 -207 -72 182 -71 181 51 79 -87 242 20 123 82 99 -130 49 101 216 -216 -93 -97 172 -125 -163 -200 -8 -206 197 -242 -194 -212 168 161 -45 103 -160 195 -249 -25 69 137 167 152 -20 -142 243 -55 -171 -36 156 -12 -149 29 28 -183 50 120 -222 17 174 -4 -74 143 236 -189 44 -228 -162 40 229 228 -124 248 231 -5 -193 65 -13 139 128 -92 31 -103 142 -3 -33 205 -164 186 -121 -57 0 -229 42 -114 -213 202 -58 141 -107 -30 -116 171 -214 74 8"
echo -n "Mine: "
./push_swap $ARGS | valgrind --track-origins=yes ./checker $ARGS
echo -n "Their: "
./push_swap $ARGS | ./Push-Swap-Tester/checker_linux $ARGS

351
flake.lock generated
View file

@ -1,351 +0,0 @@
{
"nodes": {
"c_formatter_42": {
"inputs": {
"c_formatter_42_src": "c_formatter_42_src",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1700259489,
"narHash": "sha256-Ye2zwphDUY/eDjyFCPFt0r9RyqMr4ZQprCE4bydNdpw=",
"owner": "maix0",
"repo": "c_formatter_42-flake",
"rev": "3d4f6a40bd1edf9fdb4959051edc172473d9544d",
"type": "github"
},
"original": {
"owner": "maix0",
"repo": "c_formatter_42-flake",
"type": "github"
}
},
"c_formatter_42_src": {
"flake": false,
"locked": {
"lastModified": 1696506114,
"narHash": "sha256-jUScF2lAHhjTWOWZsIAocE6FN8+HG+kLdpbYsEA1SZs=",
"owner": "dawnbeen",
"repo": "c_formatter_42",
"rev": "ef91ff383966885374695c327fa6015f9cfbc364",
"type": "github"
},
"original": {
"owner": "dawnbeen",
"repo": "c_formatter_42",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_5": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"generic_c": {
"inputs": {
"flake-utils": "flake-utils_3",
"naersk": "naersk",
"nixpkgs": "nixpkgs_3",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1706829609,
"narHash": "sha256-A0imQ9AIJafdL1/+j/1b3G7bm2j+N+VhzTsvKikKjz4=",
"owner": "maix0",
"repo": "generic_c",
"rev": "a470c2c5a8c8aadc852a7a50d72853f2a3873595",
"type": "github"
},
"original": {
"owner": "maix0",
"repo": "generic_c",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"owner": "nix-community",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixGL": {
"inputs": {
"flake-utils": "flake-utils_5",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1685908677,
"narHash": "sha256-E4zUPEUFyVWjVm45zICaHRpfGepfkE9Z2OECV9HXfA4=",
"owner": "guibou",
"repo": "nixGL",
"rev": "489d6b095ab9d289fe11af0219a9ff00fe87c7c5",
"type": "github"
},
"original": {
"owner": "guibou",
"repo": "nixGL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1700108881,
"narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1706683685,
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1706683685,
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1706925685,
"narHash": "sha256-hVInjWMmgH4yZgA4ZtbgJM1qEAel72SYhP5nOWX4UIM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "79a13f1437e149dc7be2d1290c74d378dad60814",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"c_formatter_42": "c_formatter_42",
"flake-utils": "flake-utils_2",
"generic_c": "generic_c",
"nixGL": "nixGL",
"nixpkgs": "nixpkgs_5"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1706753617,
"narHash": "sha256-ZKqTFzhFwSWFEpQTJ0uXnfJBs5Y/po9/8TK4bzssdbs=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "58be43ae223034217ea1bd58c73210644031b687",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,46 +0,0 @@
{
description = "Flake utils demo";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
generic_c.url = "github:maix0/generic_c";
c_formatter_42.url = "github:maix0/c_formatter_42-flake";
nixGL.url = "github:guibou/nixGL";
nixGL.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
flake-utils,
generic_c,
c_formatter_42,
nixGL,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [nixGL.overlay];
};
in {
devShell = pkgs.mkShell {
packages = [
pkgs.xorg.libXext
pkgs.xorg.libX11
pkgs.clang
pkgs.clang-tools
pkgs.norminette
pkgs.poppler_utils
pkgs.minilibx
pkgs.valgrind
pkgs.libbsd
pkgs.tree
pkgs.fastmod
generic_c.packages.${system}.default
c_formatter_42.packages.${system}.default
pkgs.nixgl.nixGLIntel
];
};
}
);
}

View file

@ -1,24 +0,0 @@
convert/str_to_i16
convert/str_to_i16_utils
convert/str_to_i32
convert/str_to_i32_utils
convert/str_to_i64
convert/str_to_i64_utils
convert/str_to_i8
convert/str_to_i8_utils
convert/str_to_u16
convert/str_to_u16_utils
convert/str_to_u32
convert/str_to_u32_utils
convert/str_to_u64
convert/str_to_u64_utils
convert/str_to_u8
convert/str_to_u8_utils
vec/vec_i64
vec/vec_i64_bool
vec/vec_i64_bool_functions2
vec/vec_i64_bool_functions3
vec/vec_i64_bool_sort
vec/vec_i64_functions2
vec/vec_i64_functions3
vec/vec_i64_sort

View file

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* buf_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:54:28 by maiboyer #+# #+# */
/* Updated: 2023/12/31 15:34:29 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BUF_STR_H
# define BUF_STR_H
# include "me/types.h"
typedef struct s_buffer_str
{
t_str buf;
t_usize capacity;
t_usize len;
} t_buffer_str;
bool push_str_buffer(t_buffer_str *buf, t_const_str to_push);
bool push_str_char(t_buffer_str *buf, char to_push);
void str_clear(t_buffer_str *buf);
t_buffer_str alloc_new_buffer(t_usize capacity);
static inline void str_free(t_buffer_str buf)
{
void free(void *);
free(buf.buf);
}
static inline char str_pop(t_buffer_str *buf)
{
char c;
c = '\0';
if (buf->buf && buf->len)
{
c = buf->buf[buf->len - 1];
buf->buf[buf->len - 1] = '\0';
}
return (c);
}
#endif

20
include/me/char/isalnum.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isalnum.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:39:39 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISALNUM_H
# define ISALNUM_H
# include "me/types.h"
bool me_isalnum(char chr);
#endif

20
include/me/char/isalpha.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isalpha.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:39:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISALPHA_H
# define ISALPHA_H
# include "me/types.h"
bool me_isalpha(char chr);
#endif

20
include/me/char/isascii.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isascii.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 17:51:01 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:39:33 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISASCII_H
# define ISASCII_H
# include "me/types.h"
bool me_isascii(char chr);
#endif

20
include/me/char/isdigit.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isdigit.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:41:55 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISDIGIT_H
# define ISDIGIT_H
# include "me/types.h"
bool me_isdigit(char chr);
#endif

20
include/me/char/islower.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* islower.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:48:25 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISLOWER_H
# define ISLOWER_H
# include "me/types.h"
bool me_islower(char chr);
#endif

20
include/me/char/isprint.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isprint.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:44:49 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISPRINT_H
# define ISPRINT_H
# include "me/types.h"
bool me_isprint(char chr);
#endif

20
include/me/char/isspace.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isspace.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 14:26:25 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:45:02 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISSPACE_H
# define ISSPACE_H
# include "me/types.h"
bool me_isspace(char chr);
#endif

20
include/me/char/isupper.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isupper.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:45:16 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ISUPPER_H
# define ISUPPER_H
# include "me/types.h"
bool me_isupper(char chr);
#endif

20
include/me/char/tolower.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tolower.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:47:50 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:45:33 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TOLOWER_H
# define TOLOWER_H
# include "me/types.h"
bool me_tolower(char chr);
#endif

20
include/me/char/toupper.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* toupper.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:47:50 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:45:52 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TOUPPER_H
# define TOUPPER_H
# include "me/types.h"
bool me_toupper(char chr);
#endif

21
include/me/convert/atoi.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* atoi.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 14:14:00 by maiboyer #+# #+# */
/* Updated: 2024/01/11 15:36:12 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ATOI_H
# define ATOI_H
# include "me/types.h"
t_i32 me_atoi(t_const_str str);
t_i64 me_atoi_64(t_const_str str);
#endif

20
include/me/convert/itoa.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* itoa.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/03 21:05:46 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:48:37 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ITOA_H
# define ITOA_H
# include "me/types.h"
t_str me_itoa(t_i32 nb);
#endif

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/01 21:08:13 by maiboyer #+# #+# */
/* Updated: 2024/02/02 00:22:50 by maiboyer ### ########.fr */
/* Updated: 2024/02/15 18:02:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */

20
include/me/fs/close.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* close.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 15:56:56 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:49:22 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CLOSE_H
# define CLOSE_H
# include "me/types.h"
bool me_close(t_file file, t_i32 *error);
#endif

22
include/me/fs/open.h Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* open.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:29:38 by maiboyer #+# #+# */
/* Updated: 2024/01/05 16:43:37 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef OPEN_H
# define OPEN_H
# include "me/types.h"
t_error me_open(t_const_str path, bool read, bool write, t_file *file_out);
t_error me_open_truncate(t_const_str path, t_file *file_out);
t_error me_open_create(t_const_str path, t_file *file_out);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putchar_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:49:06 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTCHAR_FD_H
# define PUTCHAR_FD_H
# include "me/types.h"
void me_putchar_fd(char chr, t_file file);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putendl_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:31:54 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTENDL_FD_H
# define PUTENDL_FD_H
# include "me/types.h"
void me_putendl_fd(t_str str, t_file file);
#endif

20
include/me/fs/putnbr_fd.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putnbr_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:45:06 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:32:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTNBR_FD_H
# define PUTNBR_FD_H
# include "me/types.h"
void me_putnbr_fd(t_i32 n, t_file file);
#endif

20
include/me/fs/putstr_fd.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putstr_fd.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 04:42:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:35:53 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUTSTR_FD_H
# define PUTSTR_FD_H
# include "me/types.h"
void me_putstr_fd(t_str str, t_file file);
#endif

20
include/me/fs/read.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:21:19 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:37:03 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef READ_H
# define READ_H
# include "me/types.h"
t_usize me_read(t_file fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out);
#endif

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read_to_vec.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 18:50:37 by maiboyer #+# #+# */
/* Updated: 2023/12/24 18:57:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef READ_TO_VEC_H
# define READ_TO_VEC_H
# include "me/types.h"
# include "me/vec/vec_u8.h"
# ifndef READ_BUFFER_SIZE
# define READ_BUFFER_SIZE 4096
# endif
bool read_to_vec(t_const_str path, t_vec_u8 *out);
#endif

20
include/me/fs/write.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* write.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:27:33 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:36:48 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef WRITE_H
# define WRITE_H
# include "me/types.h"
bool me_write(t_file fd, t_u8 *buffer, t_i64 size);
#endif

43
include/me/gnl/gnl.h Normal file
View file

@ -0,0 +1,43 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* gnl.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer42@students.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/23 14:40:15 by maiboyer #+# #+# */
/* Updated: 2023/12/11 19:21:56 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef GNL_H
# define GNL_H
# ifndef BUFFER_SIZE
# define BUFFER_SIZE 128
# endif
# ifndef BUFFER_LENGTH
# define BUFFER_LENGTH 512
# endif
# include "me/buffered_str/buf_str.h"
# include "me/types.h"
typedef struct s_static_buffer
{
t_file fd;
bool used;
char buf[BUFFER_SIZE + 1];
bool init;
} t_static_buffer;
typedef struct s_copy_flags
{
bool error;
bool empty_read;
} t_copy_flags;
t_buffer_str get_next_line(t_file fd, bool *error);
#endif

52
include/me/hash/hasher.h Normal file
View file

@ -0,0 +1,52 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hasher.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maix <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/10 19:50:39 by maix #+# #+# */
/* Updated: 2023/12/27 16:44:09 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef HASHER_H
# define HASHER_H
# include "me/types.h"
typedef void (*t_hash_bytes)(void *hasher, t_u8 *bytes,
t_usize count);
typedef t_u64 (*t_hasher_finish)(void *hasher);
typedef t_u64 (*t_hasher_reset_and_finish)(void *hasher);
typedef struct s_hasher
{
void *hasher;
t_hash_bytes hash_bytes;
t_hasher_finish finish;
t_hasher_reset_and_finish reset_and_finish;
} t_hasher;
void hasher_write_bytes(t_hasher *hasher,
t_u8 *bytes, t_usize count);
void hasher_write_u8(t_hasher *hasher, t_u8 n);
void hasher_write_u16(t_hasher *hasher, t_u16 n);
void hasher_write_u32(t_hasher *hasher, t_u32 n);
void hasher_write_u64(t_hasher *hasher, t_u64 n);
void hasher_write_usize(t_hasher *hasher, t_usize n);
void hasher_write_i8(t_hasher *hasher, t_i8 n);
void hasher_write_i16(t_hasher *hasher, t_i16 n);
void hasher_write_i32(t_hasher *hasher, t_i32 n);
void hasher_write_i64(t_hasher *hasher, t_i64 n);
void hasher_write_isize(t_hasher *hasher, t_isize n);
void hasher_write_str(t_hasher *hasher, t_str str);
t_u64 hasher_finish(t_hasher *hasher);
t_u64 hasher_reset_and_finish(t_hasher *hasher);
#endif

38
include/me/hash/sip.h Normal file
View file

@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sip.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maix <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/10 19:33:46 by maix #+# #+# */
/* Updated: 2023/12/11 15:10:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SIP_H
# define SIP_H
# include "me/hash/hasher.h"
# include "me/types.h"
typedef struct s_sip_state
{
t_u64 v0;
t_u64 v2;
t_u64 v1;
t_u64 v3;
} t_sip_state;
typedef struct s_sip13
{
t_u64 k0;
t_u64 k1;
t_usize length;
t_u64 tail;
t_usize ntail;
t_sip_state state;
} t_sip13;
t_hasher hasher_sip13_new(void);
#endif

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sip_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maix <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/10 19:34:10 by maix #+# #+# */
/* Updated: 2023/12/27 16:48:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SIP_UTILS_H
# define SIP_UTILS_H
# include "me/hash/sip.h"
# include "me/types.h"
void compress(t_sip_state *state);
t_sip_state create_state_with_key(t_u64 k0, t_u64 k1);
t_u64 sip13_finish(t_sip13 *hasher);
t_u64 sip13_reset_and_finish(t_sip13 *hasher);
void sip13_write_bytes(t_sip13 *self, t_u8 *msg, t_usize count);
#endif

305
include/me/img/qoi.h Normal file
View file

@ -0,0 +1,305 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qoi.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 17:39:36 by maiboyer #+# #+# */
/* Updated: 2023/12/25 18:35:05 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
/*
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
SPDX-License-Identifier: MIT
QOI - The "Quite OK Image" format for fast, lossless image compression
-- About
QOI encodes and decodes images in a lossless format. Compared to stb_image and
stb_image_write QOI offers 20x-50x faster encoding, 3x-4x faster decoding and
20% better compression.
-- Synopsis
// Define `QOI_IMPLEMENTATION` in *one* C/C++ file before including this
// library to create the implementation.
#define QOI_IMPLEMENTATION
#include "qoi.h"
// Encode and store an RGBA buffer to the file system. The t_qoi_desc describes
// the input pixel data.
qoi_write("image_new.qoi", rgba_pixels, &(t_qoi_desc){
.width = 1920,
.height = 1080,
.channels = 4,
.colorspace = QOI_SRGB
});
// Load and decode a QOI image from the file system t_i32o a 32bbp RGBA buffer.
// The t_qoi_desc struct will be filled with the width, height,
number of channels
// and colorspace read from the file header.
t_qoi_desc desc;
void *rgba_pixels = qoi_read("image.qoi", &desc, 4);
-- Documentation
This library provides the following functions;
- qoi_read -- read and decode a QOI file
- qoi_decode -- decode the raw bytes of a QOI image from memory
- qoi_write -- encode and write a QOI file
- qoi_encode -- encode an rgba buffer t_i32o a QOI image in memory
See the function declaration below for the signature and more information.
If you don't want/need the qoi_read and qoi_write functions, you can define
QOI_NO_STDIO before including this library.
This library uses malloc() and free(). To supply your own malloc implementation
you can define QOI_MALLOC and QOI_FREE before including this library.
This library uses memset() to zero-initialize the index. To supply your own
implementation you can define QOI_ZEROARR before including this library.
-- Data Format
A QOI file has a 14 byte header, followed by any number of data "chunks" and an
8-byte end marker.
struct qoi_header_t {
char magic[4]; // magic bytes "qoif"
ut_i3232_t width; // image width in pixels (BE)
ut_i3232_t height; // sprite.height in pixels (BE)
ut_i328_t channels; // 3 = RGB, 4 = RGBA
ut_i328_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels
linear
};
Images are encoded row by row, left to right, top to bottom. The decoder and
encoder start with {r: 0, g: 0, b: 0, a: 255} as the previous pixel value. An
image is complete when all pixels specified by width * height have been covered.
Pixels are encoded as
- a run of the previous pixel
- an index t_i32o an array of previously seen pixels
- a difference to the previous pixel value in r,g,b
- full r,g,b or r,g,b,a values
The color channels are assumed to not be premultiplied with the alpha channel
("un-premultiplied alpha").
A running array[64] (zero-initialized) of previously seen pixel values is
mat_i32ained by the encoder and decoder. Each pixel that is seen by the encoder
and decoder is put t_i32o this array at the position formed by a hash function
of the color value. In the encoder, if the pixel value at the index matches the
current pixel, this index position is written to the stream as QOI_OP_INDEX.
The hash function for the index is:
index_position = (r * 3 + g * 5 + b * 7 + a * 11) % 64
Each chunk starts with a 2- or 8-bit tag, followed by a number of data bits. The
bit length of chunks is divisible by 8 - i.e. all chunks are byte aligned. All
values encoded in these data bits have the most significant bit on the left.
The 8-bit tags have precedence over the 2-bit tags. A decoder must check for the
presence of an 8-bit tag first.
The byte stream's end is marked with 7 0x00 bytes followed a single 0x01 byte.
The possible chunks are:
.- QOI_OP_INDEX ----------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----------------|
| 0 0 | index |
`-------------------------`
2-bit tag b00
6-bit index t_i32o the color index array: 0..63
A valid encoder must not issue 2 or more consecutive QOI_OP_INDEX chunks to the
same index. QOI_OP_RUN should be used instead.
.- QOI_OP_DIFF -----------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----+-----+-----|
| 0 1 | dr | dg | db |
`-------------------------`
2-bit tag b01
2-bit red channel difference from the previous pixel between -2..1
2-bit green channel difference from the previous pixel between -2..1
2-bit blue channel difference from the previous pixel between -2..1
The difference to the current channel values are using a wraparound operation,
so "1 - 2" will result in 255, while "255 + 1" will result in 0.
Values are stored as unsigned t_i32egers with a bias of 2. E.g. -2 is stored as
0 (b00). 1 is stored as 3 (b11).
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_LUMA -------------------------------------.
| Byte[0] | Byte[1] |
| 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
|-------+-----------------+-------------+-----------|
| 1 0 | green diff | dr - dg | db - dg |
`---------------------------------------------------`
2-bit tag b10
6-bit green channel difference from the previous pixel -32..31
4-bit red channel difference minus green channel difference -8..7
4-bit blue channel difference minus green channel difference -8..7
The green channel is used to indicate the general direction of change and is
encoded in 6 bits. The red and blue channels (dr and db) base their diffs off
of the green channel difference and are encoded in 4 bits. I.e.:
dr_dg = (cur_px.r - prev_px.r) - (cur_px.g - prev_px.g)
db_dg = (cur_px.b - prev_px.b) - (cur_px.g - prev_px.g)
The difference to the current channel values are using a wraparound operation,
so "10 - 13" will result in 253, while "250 + 7" will result in 1.
Values are stored as unsigned t_i32egers with a bias of 32 for the green channel
and a bias of 8 for the red and blue channel.
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_RUN ------------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----------------|
| 1 1 | run |
`-------------------------`
2-bit tag b11
6-bit run-length repeating the previous pixel: 1..62
The run-length is stored with a bias of -1. Note that the run-lengths 63 and 64
(b111110 and b111111) are illegal as they are occupied by the QOI_OP_RGB and
QOI_OP_RGBA tags.
.- QOI_OP_RGB ------------------------------------------.
| Byte[0] | Byte[1] | Byte[2] | Byte[3] |
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|-------------------------+---------+---------+---------|
| 1 1 1 1 1 1 1 0 | red | green | blue |
`-------------------------------------------------------`
8-bit tag b11111110
8-bit red channel value
8-bit green channel value
8-bit blue channel value
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_RGBA ---------------------------------------------------.
| Byte[0] | Byte[1] | Byte[2] | Byte[3] | Byte[4] |
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|-------------------------+---------+---------+---------+---------|
| 1 1 1 1 1 1 1 1 | red | green | blue | alpha |
`-----------------------------------------------------------------`
8-bit tag b11111111
8-bit red channel value
8-bit green channel value
8-bit blue channel value
8-bit alpha channel value
*/
/* -----------------------------------------------------------------------------
Header - Public functions */
#ifndef QOI_H
# define QOI_H
# include "me/mem/mem_alloc.h"
# include "me/mem/mem_set_zero.h"
# include "me/types.h"
/* A pot_i32er to a t_qoi_desc struct has to be supplied to all of qoi's
functions. It describes either the input format (for qoi_write and qoi_encode),
or is filled with the description read from the file header (for qoi_read and
qoi_decode).
The colorspace in this t_qoi_desc is an enum where
0 = sRGB, i.e. gamma scaled RGB channels and a linear alpha channel
1 = all channels are linear
You may use the constants QOI_SRGB or QOI_LINEAR. The colorspace is purely
informative. It will be saved to the file header, but does not affect
how chunks are en-/decoded. */
# define QOI_SRGB 0
# define QOI_LINEAR 1
typedef struct s_t_qoi_desc
{
t_u32 width;
t_u32 height;
t_u8 channels;
t_u8 colorspace;
} t_qoi_desc;
# ifndef QOI_NO_STDIO
/* Encode raw RGB or RGBA pixels t_i32o a QOI image and write it to the file
system. The t_qoi_desc struct must be filled with the image width, height,
number of channels (3 = RGB, 4 = RGBA) and the colorspace.
The function returns 0 on failure (invalid parameters, or fopen or malloc
failed) or the number of bytes written on success. */
t_i32 qoi_write(t_const_str filename, const void *data,
const t_qoi_desc *desc);
/* Read and decode a QOI image from the file system. If channels is 0, the
number of channels from the file header is used. If channels is 3 or 4 the
output format will be forced t_i32o this number of channels.
The function either returns NULL on failure (invalid data, or malloc or fopen
failed) or a pot_i32er to the decoded pixels. On success, the t_qoi_desc struct
will be filled with the description from the file header.
The returned pixel data should be free()d after use. */
void *qoi_read(t_const_str filename, t_qoi_desc *desc,
t_i32 channels);
# endif /* QOI_NO_STDIO */
/* Encode raw RGB or RGBA pixels t_i32o a QOI image in memory.
The function either returns NULL on failure (invalid parameters or malloc
failed) or a pot_i32er to the encoded data on success. On success the out_len
is set to the size in bytes of the encoded data.
The returned qoi data should be free()d after use. */
void *qoi_encode(const void *data, const t_qoi_desc *desc,
t_i32 *out_len);
/* Decode a QOI image from memory.
The function either returns NULL on failure (invalid parameters or malloc
failed) or a pot_i32er to the decoded pixels. On success, the t_qoi_desc struct
is filled with the description from the file header.
The returned pixel data should be free()d after use. */
void *qoi_decode(const void *data, t_i32 size, t_qoi_desc *desc,
t_i32 channels);
#endif /* QOI_H */

View file

@ -0,0 +1,86 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qoi_decode.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/25 22:33:19 by maiboyer #+# #+# */
/* Updated: 2023/12/25 22:58:27 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef QOI_DECODE_H
# define QOI_DECODE_H
# include "me/img/qoi.h"
# include "me/img/qoi/qoi_utils.h"
typedef struct s_decode_vals
{
t_i32 px_len;
t_i32 chunks_len;
t_i32 px_pos;
t_i32 p;
t_i32 run;
t_i32 b1;
t_i32 b2;
t_i32 vg;
t_u32 header_magic;
t_qoi_rgba index[64];
t_qoi_rgba px;
} t_decode_vals;
static inline void qoi_op_luma_decode(t_decode_vals *vals, const t_u8 *bytes)
{
vals->b2 = bytes[vals->p++];
vals->vg = (vals->b1 & 0x3f) - 32;
vals->px.rgba.r += vals->vg - 8 + ((vals->b2 >> 4) & 0x0f);
vals->px.rgba.g += vals->vg;
vals->px.rgba.b += vals->vg - 8 + (vals->b2 & 0x0f);
}
static inline void qoi_op_diff_decode(t_decode_vals *vals, const t_u8 *bytes)
{
(void)(bytes);
vals->px.rgba.r += ((vals->b1 >> 4) & 0x03) - 2;
vals->px.rgba.g += ((vals->b1 >> 2) & 0x03) - 2;
vals->px.rgba.b += (vals->b1 & 0x03) - 2;
}
static inline void qoi_op_rgba_decode(t_decode_vals *vals, const t_u8 *bytes)
{
vals->px.rgba.r = bytes[vals->p++];
vals->px.rgba.g = bytes[vals->p++];
vals->px.rgba.b = bytes[vals->p++];
vals->px.rgba.a = bytes[vals->p++];
}
static inline void qoi_op_rgb_decode(t_decode_vals *vals, const t_u8 *bytes)
{
vals->px.rgba.r = bytes[vals->p++];
vals->px.rgba.g = bytes[vals->p++];
vals->px.rgba.b = bytes[vals->p++];
}
static inline void qoi_decode_inner_inner(t_decode_vals *vals, \
const t_u8 *bytes)
{
vals->b1 = bytes[vals->p++];
if (vals->b1 == QOI_OP_RGB)
qoi_op_rgb_decode(vals, bytes);
else if (vals->b1 == QOI_OP_RGBA)
qoi_op_rgba_decode(vals, bytes);
else if ((vals->b1 & QOI_MASK_2) == QOI_OP_INDEX)
vals->px = vals->index[vals->b1];
else if ((vals->b1 & QOI_MASK_2) == QOI_OP_DIFF)
qoi_op_diff_decode(vals, bytes);
else if ((vals->b1 & QOI_MASK_2) == QOI_OP_LUMA)
qoi_op_luma_decode(vals, bytes);
else if ((vals->b1 & QOI_MASK_2) == QOI_OP_RUN)
vals->run = (vals->b1 & 0x3f);
vals->index[qoi_color_hash(vals->px) % 64] = vals->px;
}
#endif /* QOI_DECODE_H */

View file

@ -0,0 +1,155 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qoi_encode.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/25 22:36:06 by maiboyer #+# #+# */
/* Updated: 2023/12/25 22:56:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef QOI_ENCODE_H
# define QOI_ENCODE_H
# include "me/img/qoi.h"
# include "me/img/qoi/qoi_utils.h"
typedef struct s_encode_vals
{
t_i32 i;
t_i32 max_size;
t_i32 p;
t_i32 run;
t_i32 px_len;
t_i32 px_end;
t_i32 px_pos;
t_i32 channels;
t_i32 index_pos;
t_qoi_rgba index[64];
t_qoi_rgba px;
t_qoi_rgba px_prev;
} t_encode_vals;
typedef struct s_v
{
t_i8 r;
t_i8 g;
t_i8 b;
t_i8 g_r;
t_i8 g_b;
} t_v;
static inline void qoi_encode_if_thingy1(t_encode_vals *vals,
t_v *v, t_u8 *bytes)
{
v->r = vals->px.rgba.r - vals->px_prev.rgba.r;
v->g = vals->px.rgba.g - vals->px_prev.rgba.g;
v->b = vals->px.rgba.b - vals->px_prev.rgba.b;
v->g_r = v->r - v->g;
v->g_b = v->b - v->g;
if (v->r > -3 && v->r < 2 && v->g > -3 && v->g < 2 && v->b > -3
&& v->b < 2)
bytes[vals->p++] = QOI_OP_DIFF | (v->r + 2) << 4 | (v->g
+ 2) << 2 | (v->b + 2);
else if (v->g_r > -9 && v->g_r < 8 && v->g > -33 && v->g < 32
&& v->g_b > -9 && v->g_b < 8)
{
bytes[vals->p++] = QOI_OP_LUMA | (v->g + 32);
bytes[vals->p++] = (v->g_r + 8) << 4 | (v->g_b + 8);
}
else
{
bytes[vals->p++] = QOI_OP_RGB;
bytes[vals->p++] = vals->px.rgba.r;
bytes[vals->p++] = vals->px.rgba.g;
bytes[vals->p++] = vals->px.rgba.b;
}
}
static inline void qoi_encode_inner_inner_inner(t_encode_vals *vals,
t_v *v, t_u8 *bytes)
{
if (vals->run > 0)
{
bytes[vals->p++] = QOI_OP_RUN | (vals->run - 1);
vals->run = 0;
}
vals->index_pos = qoi_color_hash(vals->px) % 64;
if (vals->index[vals->index_pos].v == vals->px.v)
bytes[vals->p++] = QOI_OP_INDEX | vals->index_pos;
else
{
vals->index[vals->index_pos] = vals->px;
if (vals->px.rgba.a == vals->px_prev.rgba.a)
qoi_encode_if_thingy1(vals, v, bytes);
else
{
bytes[vals->p++] = QOI_OP_RGBA;
bytes[vals->p++] = vals->px.rgba.r;
bytes[vals->p++] = vals->px.rgba.g;
bytes[vals->p++] = vals->px.rgba.b;
bytes[vals->p++] = vals->px.rgba.a;
}
}
}
static inline void qoi_encode_inner_inner(t_encode_vals *vals,
const t_u8 *pixels, t_u8 *bytes)
{
t_v v;
v = (t_v){0};
while (vals->px_pos < vals->px_len)
{
vals->px.rgba.r = pixels[vals->px_pos + 0];
vals->px.rgba.g = pixels[vals->px_pos + 1];
vals->px.rgba.b = pixels[vals->px_pos + 2];
if (vals->channels == 4)
vals->px.rgba.a = pixels[vals->px_pos + 3];
if (vals->px.v == vals->px_prev.v)
{
vals->run++;
if (vals->run == 62 || vals->px_pos == vals->px_end)
{
bytes[vals->p++] = QOI_OP_RUN | (vals->run - 1);
vals->run = 0;
}
}
else
qoi_encode_inner_inner_inner(vals, &v, bytes);
vals->px_prev = vals->px;
vals->px_pos += vals->channels;
}
}
static inline void *qoi_encode_inner(t_encode_vals *vals,
const t_qoi_desc *desc,
const t_u8 *pixels, t_i32 *out_len)
{
t_u8 *bytes;
bytes = (t_u8 *)mem_alloc(vals->max_size);
if (!bytes)
return (NULL);
qoi_write_32(bytes, &vals->p, QOI_MAGIC);
qoi_write_32(bytes, &vals->p, desc->width);
qoi_write_32(bytes, &vals->p, desc->height);
bytes[vals->p++] = desc->channels;
bytes[vals->p++] = desc->colorspace;
mem_set_zero(vals->index, sizeof(vals->index));
vals->px_prev.rgba.a = 255;
vals->px = vals->px_prev;
vals->px_len = desc->width * desc->height * desc->channels;
vals->px_end = vals->px_len - desc->channels;
vals->channels = desc->channels;
qoi_encode_inner_inner(vals, pixels, bytes);
vals->i = 0;
while (vals->i < (t_i32) sizeof(t_u8[8]))
bytes[vals->p++] = ((t_u8[8]){0, 0, 0, 0, 0, 0, 0, 1})[vals->i++];
*out_len = vals->p;
return (bytes);
}
#endif /* QOI_ENCODE_H */

View file

@ -0,0 +1,56 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qoi_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/24 18:59:56 by maiboyer #+# #+# */
/* Updated: 2023/12/25 22:33:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef QOI_UTILS_H
# define QOI_UTILS_H
# include "me/img/qoi.h"
# include "me/types.h"
# define QOI_OP_INDEX 0x00 /* 00xxxxxx */
# define QOI_OP_DIFF 0x40 /* 01xxxxxx */
# define QOI_OP_LUMA 0x80 /* 10xxxxxx */
# define QOI_OP_RUN 0xc0 /* 11xxxxxx */
# define QOI_OP_RGB 0xfe /* 11111110 */
# define QOI_OP_RGBA 0xff /* 11111111 */
# define QOI_MASK_2 0xc0 /* 11000000 */
# define QOI_MAGIC 0x716f6966u
//(((t_u32)'q') << 24 | ((t_u32)'o') << 16 | ((t_u32)'i') << 8 | ((t_u32)'f'))
# define QOI_HEADER_SIZE 14
/* 2GB is the max file size that this implementation can safely handle. We guard
against anything larger than that, assuming the worst case with 5 bytes per
pixel, rounded down to a nice clean value. 400 million pixels ought to be
enough for anybody. */
# define QOI_PIXELS_MAX 400000000u
typedef union u_qoi_rgba
{
struct s_qoi_rgba
{
t_u8 r;
t_u8 g;
t_u8 b;
t_u8 a;
} rgba;
t_u32 v;
} t_qoi_rgba;
void qoi_write_32(t_u8 *bytes, t_i32 *p, t_u32 v);
t_u32 qoi_read_32(const t_u8 *bytes, t_i32 *p);
static inline t_u32 qoi_color_hash(t_qoi_rgba c)
{
return (c.rgba.r * 3 + c.rgba.g * 5 + c.rgba.b * 7 + c.rgba.a * 11);
}
#endif /* QOI_UTILS_H */

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_add_back.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 20:38:45 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:27:56 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_ADD_BACK_H
# define LIST_ADD_BACK_H
# include "me/types.h"
void list_add_back(t_list **list, t_list *new);
#endif

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_add_front.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 20:15:23 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:28:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_ADD_FRONT_H
# define LIST_ADD_FRONT_H
# include "me/types.h"
void list_add_front(t_list **lst, t_list *new);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_alloc_node.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 19:57:28 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:28:30 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_ALLOC_NODE_H
# define LIST_ALLOC_NODE_H
# include "me/types.h"
t_list *list_alloc_node(void *content);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_free_all.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 21:35:20 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:28:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_FREE_ALL_H
# define LIST_FREE_ALL_H
# include "me/types.h"
void list_free_all(t_list **lst, void (*del)(void *));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_free_one.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 21:30:20 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:29:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_FREE_ONE_H
# define LIST_FREE_ONE_H
# include "me/types.h"
void list_free_one(t_list *lst, void (*del)(void *));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_get_last.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 20:37:08 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:29:37 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_GET_LAST_H
# define LIST_GET_LAST_H
# include "me/types.h"
t_list *list_get_last(t_list *list);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_iter.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 21:39:05 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:29:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_ITER_H
# define LIST_ITER_H
# include "me/types.h"
void list_iter(t_list *list, void (*f)(void *));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 21:40:24 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:30:08 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_MAP_H
# define LIST_MAP_H
# include "me/types.h"
t_list *list_map(t_list *lst, void *(*f)(void *), void (*del)(void *));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_size.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 20:23:19 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:30:23 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIST_SIZE_H
# define LIST_SIZE_H
# include "me/types.h"
t_usize list_size(t_list *lst);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_alloc.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/06 14:47:49 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:41:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_ALLOC_H
# define MEM_ALLOC_H
# include "me/types.h"
void *mem_alloc(t_usize size);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_alloc_array.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 15:53:21 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:19:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_ALLOC_ARRAY_H
# define MEM_ALLOC_ARRAY_H
# include "me/types.h"
void *mem_alloc_array(t_usize item_count, t_usize item_size);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_compare.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:21:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_COMPARE_H
# define MEM_COMPARE_H
# include "me/types.h"
t_i32 mem_compare(const void *lhs, const void *rhs, t_usize count);
#endif

20
include/me/mem/mem_copy.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_copy.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:21:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_COPY_H
# define MEM_COPY_H
# include "me/types.h"
void *mem_copy(void *destination, const void *source, t_usize count);
#endif

20
include/me/mem/mem_find.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_find.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:03 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_FIND_H
# define MEM_FIND_H
# include "me/types.h"
void *mem_find(void *buf, t_u8 find, t_usize count);
#endif

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_find_bytes.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2024/01/06 18:24:04 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_FIND_BYTES_H
# define MEM_FIND_BYTES_H
# include "me/types.h"
void *mem_find_bytes(void *buf, t_u8 *find, t_usize find_count,
t_usize count);
#endif

20
include/me/mem/mem_move.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_move.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:26 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_MOVE_H
# define MEM_MOVE_H
# include "me/types.h"
void *mem_move(void *destination, const void *source, t_usize count);
#endif

20
include/me/mem/mem_set.h Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_set.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:25:19 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_SET_H
# define MEM_SET_H
# include "me/types.h"
void mem_set(void *buf, t_u8 byte, t_usize count);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_set_zero.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:58:11 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:24:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MEM_SET_ZERO_H
# define MEM_SET_ZERO_H
# include "me/types.h"
void mem_set_zero(void *buf, t_usize count);
#endif

21
include/me/num/u16.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* u16.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/11 14:10:03 by maiboyer #+# #+# */
/* Updated: 2023/12/11 14:16:58 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef U16_H
# define U16_H
# include "me/types.h"
t_u16 u16_rotate_left(t_u16 n, t_usize by);
t_u16 u16_rotate_right(t_u16 n, t_usize by);
#endif

21
include/me/num/u32.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* u32.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/11 14:10:03 by maiboyer #+# #+# */
/* Updated: 2023/12/11 14:17:08 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef U32_H
# define U32_H
# include "me/types.h"
t_u32 u32_rotate_left(t_u32 n, t_usize by);
t_u32 u32_rotate_right(t_u32 n, t_usize by);
#endif

24
include/me/num/u64.h Normal file
View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* u64.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/11 14:10:03 by maiboyer #+# #+# */
/* Updated: 2023/12/11 17:59:34 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef U64_H
# define U64_H
# include "me/types.h"
t_u64 u64_rotate_left(t_u64 n, t_usize by);
t_u64 u64_rotate_right(t_u64 n, t_usize by);
t_u64 u64_from_7bytes(t_u8 *bytes, t_usize start, t_usize len);
t_u64 u64_from_bytes(t_u8 *bytes, t_usize len);
#endif

21
include/me/num/u8.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* u8.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/11 14:10:03 by maiboyer #+# #+# */
/* Updated: 2023/12/11 14:17:24 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef U8_H
# define U8_H
# include "me/types.h"
t_u8 u8_rotate_left(t_u8 n, t_usize by);
t_u8 u8_rotate_right(t_u8 n, t_usize by);
#endif

21
include/me/num/usize.h Normal file
View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* usize.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/11 14:10:03 by maiboyer #+# #+# */
/* Updated: 2023/12/11 14:17:32 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef USIZE_H
# define USIZE_H
# include "me/types.h"
t_usize usize_rotate_left(t_usize n, t_usize by);
t_usize usize_rotate_right(t_usize n, t_usize by);
#endif

View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* formatter.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:18:19 by maiboyer #+# #+# */
/* Updated: 2023/11/18 19:11:23 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FORMATTER_H
# define FORMATTER_H
# include "me/printf/printf.h"
# include "me/types.h"
void printf_x_low(t_printf_arg data, t_printf_func f);
void printf_x_up(t_printf_arg data, t_printf_func f);
void printf_o(t_printf_arg data, t_printf_func f);
void printf_d(t_printf_arg data, t_printf_func f);
void printf_u(t_printf_arg data, t_printf_func f);
void printf_c(t_printf_arg data, t_printf_func f);
void printf_s(t_printf_arg data, t_printf_func f);
void printf_p(t_printf_arg data, t_printf_func f);
#endif

View file

@ -0,0 +1,76 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:58:41 by maiboyer #+# #+# */
/* Updated: 2023/12/01 21:24:21 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef UTILS_H
# define UTILS_H
# include "me/printf/matchers/matchers.h"
# include "me/printf/printf.h"
# include "me/types.h"
# include <stdarg.h>
typedef struct s_prec_strs
{
t_str *out;
t_str *pretty;
bool free_out;
} t_prec_strs;
typedef struct s_pad_and_stuff_args
{
t_usize fill_zero;
t_usize fill;
t_usize len;
t_usize pretty_len;
t_usize sign_len;
t_str pretty;
t_str str;
t_str sign;
bool allow_zero_fill;
} t_pad_and_stuff_args;
typedef struct s_pad_inner_args
{
void *p_args;
t_usize fmt_len;
t_printf_func f;
va_list *arguments;
t_matcher_list *matchers;
} t_pad_inner_args;
void set_var_for_pad_and_stuff(t_pad_and_stuff_args *a,
t_printf_arg *d);
void print_with_func(t_pad_and_stuff_args *a, t_printf_arg *d,
t_printf_func f, t_const_str t);
void pad_and_stuff(t_pad_and_stuff_args a, t_printf_arg d,
t_printf_func f);
void handle_prec_and_align(t_const_str fmt, t_usize *c_idx,
t_printf_arg *c_arg);
bool handle_atoi_stuff(t_const_str fmt, t_usize *c_idx,
t_usize *nxt, t_printf_arg *c_arg);
void set_params2(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
t_printf_arg *c_arg);
bool set_params(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
t_printf_arg *c_arg);
void ret_reset(t_usize *c_idx, t_usize *nxt, t_const_str fmt);
t_printf_arg print_substr(t_usize *c_idx, t_usize *nxt, t_const_str fmt,
t_pad_inner_args extra);
void pad_inner(t_const_str fmt, t_usize *c_idx, t_usize *nxt,
t_pad_inner_args extra);
void advance_atoi(t_const_str fmt, t_usize *idx);
void me_printf_str_inner(t_const_str fmt, t_printf_func f,
va_list *arguments, void *p_args);
void print_sign_if_needed(t_pad_and_stuff_args a, t_printf_arg d,
t_printf_func f);
void handle_weird_precision_stuff(t_printf_arg *data,
t_prec_strs strs, t_usize value);
#endif

View file

@ -0,0 +1,52 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* matchers.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:09:07 by maiboyer #+# #+# */
/* Updated: 2023/11/18 18:10:33 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MATCHERS_H
# define MATCHERS_H
# include "me/printf/printf.h"
# include "me/types.h"
# include <stdarg.h>
# define PRINTF_BUFFER_CHUNK 20
typedef struct s_matcher_tmp
{
char chr_val;
t_i64 i64_val;
t_u64 u64_val;
} t_matcher_tmp_val;
typedef void (*t_matcher_func)(t_printf_arg data,
t_printf_func f);
typedef struct s_matcher
{
t_const_str matcher;
t_usize matcher_len;
t_printf_type arg_type;
t_matcher_func f;
} t_matcher;
typedef struct s_matcher_list
{
t_matcher data[PRINTF_BUFFER_CHUNK];
struct s_matcher_list *next;
} t_matcher_list;
t_matcher_list *get_matchers(void);
bool insert_matcher(t_matcher matcher);
t_matcher *find_matcher(t_const_str fmt,
t_matcher_list *matchers, t_usize *c_idx);
void call_matcher(t_matcher *matcher,
t_printf_arg matcher_arguments, va_list args,
t_printf_func f);
#endif

View file

@ -0,0 +1,69 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:10:27 by maiboyer #+# #+# */
/* Updated: 2024/02/09 15:06:53 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PRINTF_H
# define PRINTF_H
# include "me/types.h"
# include <stdarg.h>
typedef struct s_fprintf_arg
{
t_usize total_print;
t_file fd;
} t_fprintf_arg;
typedef enum e_printf_flags
{
PRECISION = 1 << 1,
ALIGN = 1 << 2,
ZERO_ALIGN = 1 << 3,
SIGN = 1 << 4,
} t_printf_flags;
typedef enum e_printf_type
{
CHAR = 1 << 0,
STR = 1 << 1,
U64 = 1 << 2,
I64 = 1 << 3,
VOID_PTR = 1 << 4,
I32 = 1 << 5,
U32 = 1 << 6,
} t_printf_type;
typedef struct s_printf_extra_args
{
t_u64 precision;
t_u64 align;
bool left_align;
bool space_align;
bool pretty;
} t_printf_extra_args;
typedef struct s_printf_args
{
void *argument;
void *p_args;
t_printf_extra_args extra;
t_printf_flags flags;
} t_printf_arg;
typedef void (*t_printf_func)(t_const_str to_write,
t_usize to_write_len, void *p_args);
t_usize me_printf(t_const_str fmt, ...);
t_usize me_eprintf(t_const_str fmt, ...);
t_usize me_vprintf(t_const_str fmt, va_list *args);
t_usize me_veprintf(t_const_str fmt, va_list *args);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_clone.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 16:05:48 by maiboyer #+# #+# */
/* Updated: 2023/12/11 17:30:19 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_CLONE_H
# define STR_CLONE_H
# include "me/types.h"
t_str str_clone(t_const_str source);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_chr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:29:13 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:07:01 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_CHR_H
# define STR_FIND_CHR_H
# include "me/types.h"
char *str_find_chr(t_const_str str, char chr);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_rev_chr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:29:13 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:07:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_REV_CHR_H
# define STR_FIND_REV_CHR_H
# include "me/types.h"
char *str_find_rev_chr(t_const_str str, char chr);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/10 11:11:01 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:53:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_STR_H
# define STR_FIND_STR_H
# include "me/types.h"
const char *str_find_str(t_const_str str, t_const_str to_find);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_iter.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 18:26:00 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:08:09 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_ITER_H
# define STR_ITER_H
# include "me/types.h"
void str_iter(t_str s, void (*f)(t_usize, char *));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_join.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 23:02:58 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:08:32 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_JOIN_H
# define STR_JOIN_H
# include "me/types.h"
t_str str_join(t_const_str s1, t_const_str s2);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_l_cat.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/09 18:01:09 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:09:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_L_CAT_H
# define STR_L_CAT_H
# include "me/types.h"
t_usize str_l_cat(t_str dest, t_const_str src, t_usize buffer_size);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_l_copy.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/09 18:01:09 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:09:38 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_L_COPY_H
# define STR_L_COPY_H
# include "me/types.h"
t_usize str_l_copy(t_str dest, t_const_str src, t_usize buffer_size);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_len.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:07:41 by maiboyer #+# #+# */
/* Updated: 2023/12/11 16:08:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_LEN_H
# define STR_LEN_H
# include "me/types.h"
t_usize str_len(t_const_str str);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 18:26:00 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:11:40 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_MAP_H
# define STR_MAP_H
# include "me/types.h"
t_str str_map(t_const_str s, char (*f)(t_usize, char));
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_n_compare.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 18:53:47 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:17:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_N_COMPARE_H
# define STR_N_COMPARE_H
# include "me/types.h"
t_i32 str_n_compare(t_const_str lhs, t_const_str rhs, t_usize n);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_n_find_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/10 11:11:01 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:53:35 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_N_FIND_STR_H
# define STR_N_FIND_STR_H
# include "me/types.h"
const char *str_n_find_str(t_const_str str, t_const_str to_find, t_usize len);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_split.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/17 15:56:59 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:18:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_SPLIT_H
# define STR_SPLIT_H
# include "me/types.h"
t_str *str_split(t_const_str str, char chr);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_substring.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 22:42:55 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:18:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_SUBSTRING_H
# define STR_SUBSTRING_H
# include "me/types.h"
t_str str_substring(t_const_str str, t_usize start, t_usize len);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_trim.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 23:43:42 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:19:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_TRIM_H
# define STR_TRIM_H
# include "me/types.h"
t_str str_trim(t_const_str str, t_const_str charset);
#endif

49
include/me/types.h Normal file
View file

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 14:31:12 by maiboyer #+# #+# */
/* Updated: 2024/01/05 00:08:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_H
# define TYPES_H
# include <stdbool.h>
# include <stddef.h>
# include <unistd.h>
typedef char *t_str;
typedef const char *t_const_str;
typedef unsigned char t_u8;
typedef char t_i8;
typedef unsigned short t_u16;
typedef short t_i16;
typedef int t_i32;
typedef unsigned int t_u32;
typedef unsigned long long t_u64;
typedef long long t_i64;
typedef ssize_t t_isize;
typedef size_t t_usize;
typedef float t_f32;
typedef double t_f64;
typedef int t_file;
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;
typedef bool t_error;
# define ERROR 1
# define NO_ERROR 0
#endif

View file

@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_buf_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2024/02/15 18:02:08 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_BUF_STR_H
# define VEC_BUF_STR_H
# include "me/buffered_str/buf_str.h"
# include "me/types.h"
typedef bool (*t_vec_buf_str_sort_fn)(t_buffer_str *,
t_buffer_str *);
typedef void (*t_free_buf_str_item)(t_buffer_str);
typedef struct s_vec_buf_str
{
t_free_buf_str_item free_func;
t_usize len;
t_usize capacity;
t_buffer_str *buffer;
} t_vec_buf_str;
t_vec_buf_str vec_buf_str_new(t_usize capacity,
t_free_buf_str_item free_function);
t_error vec_buf_str_push(t_vec_buf_str *vec,
t_buffer_str element);
t_error vec_buf_str_push_front(t_vec_buf_str *vec,
t_buffer_str element);
t_error vec_buf_str_pop(t_vec_buf_str *vec,
t_buffer_str *value);
t_error vec_buf_str_pop_front(t_vec_buf_str *vec,
t_buffer_str *value);
void vec_buf_str_free(t_vec_buf_str vec);
t_error vec_buf_str_reserve(t_vec_buf_str *vec,
t_usize wanted_capacity);
t_error vec_buf_str_find(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), t_usize *index);
t_error vec_buf_str_find_starting(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *),
t_usize starting_index, t_usize *index);
t_error vec_buf_str_all(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), bool *result);
t_error vec_buf_str_any(t_vec_buf_str *vec,
bool (*fn)(const t_buffer_str *), bool *result);
void vec_buf_str_iter(t_vec_buf_str *vec,
void (*fn)(t_usize index, t_buffer_str *value,
void *state), void *state);
void vec_buf_str_reverse(t_vec_buf_str *vec);
void vec_buf_str_sort(t_vec_buf_str *vec,
t_vec_buf_str_sort_fn is_sorted);
#endif

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_i64.h :+: :+: :+: */
/* vec_i64.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* Updated: 2024/02/15 18:02:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_i64_bool.h :+: :+: :+: */
/* vec_i64_bool.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* Updated: 2024/02/15 18:02:10 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */

50
include/me/vec/vec_u8.h Normal file
View file

@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_u8.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2024/02/15 18:02:19 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_U8_H
# define VEC_U8_H
# include "me/types.h"
typedef bool (*t_vec_u8_sort_fn)(t_u8 *, t_u8 *);
typedef void (*t_free_u8_item)(t_u8);
typedef struct s_vec_u8
{
t_free_u8_item free_func;
t_usize len;
t_usize capacity;
t_u8 *buffer;
} t_vec_u8;
t_vec_u8 vec_u8_new(t_usize capacity, t_free_u8_item free_function);
t_error vec_u8_push(t_vec_u8 *vec, t_u8 element);
t_error vec_u8_push_front(t_vec_u8 *vec, t_u8 element);
t_error vec_u8_pop(t_vec_u8 *vec, t_u8 *value);
t_error vec_u8_pop_front(t_vec_u8 *vec, t_u8 *value);
void vec_u8_free(t_vec_u8 vec);
t_error vec_u8_reserve(t_vec_u8 *vec, t_usize wanted_capacity);
t_error vec_u8_find(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
t_usize *index);
t_error vec_u8_find_starting(t_vec_u8 *vec,
bool (*fn)(const t_u8 *), t_usize starting_index,
t_usize *index);
t_error vec_u8_all(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
bool *result);
t_error vec_u8_any(t_vec_u8 *vec, bool (*fn)(const t_u8 *),
bool *result);
void vec_u8_iter(t_vec_u8 *vec, void (*fn)(t_usize index,
t_u8 *value, void *state), void *state);
void vec_u8_reverse(t_vec_u8 *vec);
void vec_u8_sort(t_vec_u8 *vec, t_vec_u8_sort_fn is_sorted);
#endif

60
include/me/vec2/vec2.h Normal file
View file

@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec2.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/31 14:54:39 by maiboyer #+# #+# */
/* Updated: 2023/12/31 15:07:54 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC2_H
# define VEC2_H
# include "me/types.h"
typedef struct s_vi2d
{
t_i32 x;
t_i32 y;
} t_vi2d;
typedef struct s_vu2d
{
t_u32 x;
t_u32 y;
} t_vu2d;
typedef struct s_vf2d
{
t_f32 x;
t_f32 y;
} t_vf2d;
static inline t_vf2d vf2d(t_f32 x, t_f32 y)
{
return ((t_vf2d){.x = x, .y = y});
}
static inline t_vi2d vi2d(t_i32 x, t_i32 y)
{
return ((t_vi2d){.x = x, .y = y});
}
static inline t_vu2d vu2d(t_u32 x, t_u32 y)
{
return ((t_vu2d){.x = x, .y = y});
}
static inline t_vi2d vi2d_add(t_vi2d lhs, t_vi2d rhs)
{
return ((t_vi2d){.x = lhs.x + rhs.x, .y = lhs.y + rhs.y});
}
static inline t_vi2d vi2d_sub(t_vi2d lhs, t_vi2d rhs)
{
return ((t_vi2d){.x = lhs.x - rhs.x, .y = lhs.y - rhs.y});
}
#endif /* VEC2_H */

View file

@ -1,144 +0,0 @@
[definition.vec]
headers = ["mecstd/generic_sources/header/vec_C__PREFIX__.h__TEMPLATE__"]
sources = [
"mecstd/generic_sources/src/vec_C__PREFIX__.c__TEMPLATE__",
"mecstd/generic_sources/src/vec_C__PREFIX___functions2.c__TEMPLATE__",
"mecstd/generic_sources/src/vec_C__PREFIX___functions3.c__TEMPLATE__",
"mecstd/generic_sources/src/vec_C__PREFIX___sort.c__TEMPLATE__",
]
replace.C__TYPENAME__ = "type"
replace.C__TYPEHEADER__ = "header_include"
replace.C__PREFIX__ = "prefix"
replace.C__PREFIXUP__ = "prefix"
[definition.hashmap]
headers = ["mecstd/generic_sources/header/hashmap_C__PREFIX__.h__TEMPLATE__"]
sources = [
"mecstd/generic_sources/src/hashmap_C__PREFIX__.c__TEMPLATE__",
"mecstd/generic_sources/src/hashmap_C__PREFIX___utils.c__TEMPLATE__",
]
replace.C__VALTYPE__ = "type"
replace.C__KEYTYPE__ = "type"
replace.C__TYPEHEADER__ = "header_include"
replace.C__PREFIX__ = "prefix"
replace.C__PREFIXUP__ = "prefix"
[definition.str_to_num]
headers = []
sources = [
"mecstd/generic_sources/src/str_to_C__PREFIX__.c__TEMPLATE__",
"mecstd/generic_sources/src/str_to_C__PREFIX___utils.c__TEMPLATE__",
]
replace.C__TYPE__ = "type"
replace.C__UNSIGNED_TYPE__ = "type"
replace.C__PREFIX__ = "prefix"
replace.C__MAX__ = "value"
replace.C__MIN__ = "value"
replace.C__ZERO__ = "value"
replace.C__SIGNED_TYPE__ = "bool"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_i64"
replace.C__UNSIGNED_TYPE__ = "t_u64"
replace.C__PREFIX__ = "i64"
replace.C__MAX__ = "9223372036854775807ll"
replace.C__MIN__ = "-(~9223372036854775807ll + 1)"
replace.C__ZERO__ = "0ll"
replace.C__SIGNED_TYPE__ = "true"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_i32"
replace.C__UNSIGNED_TYPE__ = "t_u32"
replace.C__PREFIX__ = "i32"
replace.C__MAX__ = "2147483647"
replace.C__MIN__ = "-2147483648"
replace.C__ZERO__ = "0"
replace.C__SIGNED_TYPE__ = "true"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_i16"
replace.C__UNSIGNED_TYPE__ = "t_u16"
replace.C__PREFIX__ = "i16"
replace.C__MAX__ = "32767"
replace.C__MIN__ = "-32768"
replace.C__ZERO__ = "0"
replace.C__SIGNED_TYPE__ = "true"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_i8"
replace.C__UNSIGNED_TYPE__ = "t_u8"
replace.C__PREFIX__ = "i8"
replace.C__MAX__ = "127"
replace.C__MIN__ = "-128"
replace.C__ZERO__ = "0"
replace.C__SIGNED_TYPE__ = "true"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_u64"
replace.C__UNSIGNED_TYPE__ = "t_u64"
replace.C__PREFIX__ = "u64"
replace.C__MAX__ = "18446744073709551615llu"
replace.C__MIN__ = "0llu"
replace.C__ZERO__ = "0llu"
replace.C__SIGNED_TYPE__ = "false"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_u32"
replace.C__UNSIGNED_TYPE__ = "t_u32"
replace.C__PREFIX__ = "u32"
replace.C__MAX__ = "4294967295u"
replace.C__MIN__ = "0u"
replace.C__ZERO__ = "0u"
replace.C__SIGNED_TYPE__ = "false"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_u16"
replace.C__UNSIGNED_TYPE__ = "t_u16"
replace.C__PREFIX__ = "u16"
replace.C__MAX__ = "65535u"
replace.C__MIN__ = "0u"
replace.C__ZERO__ = "0u"
replace.C__SIGNED_TYPE__ = "false"
[[create.str_to_num]]
sources_output = "src/convert/"
headers_output = ""
replace.C__TYPE__ = "t_u8"
replace.C__UNSIGNED_TYPE__ = "t_u8"
replace.C__PREFIX__ = "u8"
replace.C__MAX__ = "128u"
replace.C__MIN__ = "0u"
replace.C__ZERO__ = "0u"
replace.C__SIGNED_TYPE__ = "false"
[[create.vec]]
sources_output = "src/vec/"
headers_output = "include/me/vec/"
replace.C__TYPENAME__ = "t_i64"
replace.C__TYPEHEADER__ = ''
replace.C__PREFIX__ = "i64"
replace.C__PREFIXUP__ = "I64"
[[create.vec]]
sources_output = "src/vec/"
headers_output = "include/me/vec/"
replace.C__TYPENAME__ = "t_i64_bool"
replace.C__TYPEHEADER__ = '#include "app/types/type_i64_bool.h"'
replace.C__PREFIX__ = "i64_bool"
replace.C__PREFIXUP__ = "I64_BOOL"

1
mecstd

@ -1 +0,0 @@
Subproject commit 07ea9679e2413366502a73ea9391d89847d6b3c2

View file

@ -1,21 +0,0 @@
app/actual_main
app/best_index_to_move
app/best_move
app/do_move
app/find_place
app/iter_find
app/main
app/main_bonus
app/moves
app/moves/push
app/moves/rev_rotate
app/moves/rotate
app/moves/swap
app/rotate
app/run_with_items
app/sort2
app/sort3
app/sort5
app/state
app/target
bonus/move1

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/08 18:59:33 by maiboyer #+# #+# */
/* Updated: 2024/02/15 17:47:33 by maiboyer ### ########.fr */
/* Updated: 2024/02/15 19:09:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -81,9 +81,10 @@ int main_checker(t_i32 argc, t_str argv[])
bool err;
(void)(argc--, argv++);
s.buf = "";
err = false;
state = parses_arguments(argc, argv);
if (state.stack_a.len == 0)
return (free_state(state), 0);
while (!err)
{
s = get_next_line(0, &err);
@ -94,7 +95,7 @@ int main_checker(t_i32 argc, t_str argv[])
if (s.buf[0] == '\0')
continue ;
if (handle_operation(s, &state))
return (me_printf("KO\n"), str_free(s), free_state(state), 1);
return (me_printf("Error\n"), str_free(s), free_state(state), 1);
if (s.buf != NULL)
str_free(s);
}

82
src/buffered_str/mod.c Normal file
View file

@ -0,0 +1,82 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mod.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:52:12 by maiboyer #+# #+# */
/* Updated: 2023/12/26 19:54:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/buffered_str/buf_str.h"
#include "me/mem/mem_alloc.h"
#include "me/mem/mem_set_zero.h"
#include "me/string/str_l_cat.h"
#include "me/string/str_l_copy.h"
#include "me/string/str_len.h"
#include "me/types.h"
#include <stdlib.h>
bool push_str_buffer(t_buffer_str *buf, t_const_str to_push)
{
t_usize to_push_len;
t_str temp_buffer;
t_usize new_capacity;
if (buf == NULL || to_push == NULL)
return (true);
to_push_len = str_len(to_push);
while (buf->len + to_push_len + 2 > buf->capacity)
{
new_capacity = (buf->capacity * 3) / 2 + 1;
temp_buffer = mem_alloc(new_capacity);
if (temp_buffer == NULL)
return (true);
str_l_copy(temp_buffer, buf->buf, new_capacity);
free(buf->buf);
buf->buf = temp_buffer;
buf->capacity = new_capacity;
}
buf->len += to_push_len;
str_l_cat(buf->buf, to_push, buf->capacity);
return (false);
}
bool push_str_char(t_buffer_str *buf, char to_push)
{
char push_str[2];
push_str[0] = to_push;
push_str[1] = 0;
return (push_str_buffer(buf, push_str));
}
void str_clear(t_buffer_str *buf)
{
mem_set_zero(buf->buf, buf->capacity);
buf->len = 0;
return ;
}
t_buffer_str alloc_new_buffer(t_usize capacity)
{
t_buffer_str out;
t_str buf;
if (capacity == 0)
capacity = 16;
buf = mem_alloc(sizeof(char) * capacity);
if (buf == NULL)
{
out.buf = NULL;
out.capacity = 0;
out.len = 0;
return (out);
}
out.buf = buf;
out.capacity = capacity;
out.len = 0;
return (out);
}

20
src/char/isalnum.c Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/11/09 19:38:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/isalnum.h"
#include "me/char/isalpha.h"
#include "me/char/isdigit.h"
bool me_isalnum(char chr)
{
return (me_isalpha(chr) || me_isdigit(chr));
}

18
src/char/isalpha.c Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/11/08 04:01:25 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/isalpha.h"
bool me_isalpha(char chr)
{
return (('z' >= chr && chr >= 'a') || ('Z' >= chr && chr >= 'A'));
}

18
src/char/isascii.c Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 17:51:01 by maiboyer #+# #+# */
/* Updated: 2023/11/09 18:25:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/isascii.h"
bool me_isascii(char chr)
{
return (0 <= chr && chr <= 127);
}

18
src/char/isdigit.c Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/11/04 16:59:06 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/isdigit.h"
bool me_isdigit(char chr)
{
return (chr >= '0' && chr <= '9');
}

18
src/char/islower.c Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* islower.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/11/04 16:58:56 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/islower.h"
bool me_islower(char chr)
{
return (chr >= 'a' && chr <= 'z');
}

18
src/char/isprint.c Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 16:19:40 by maiboyer #+# #+# */
/* Updated: 2023/11/04 16:42:38 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/char/isprint.h"
bool me_isprint(char chr)
{
return (chr >= ' ' && chr <= '~');
}

Some files were not shown because too many files have changed in this diff Show more