Compare commits

..

701 commits

Author SHA1 Message Date
a0d4344b67
Merge kernel-rs with full history 2026-01-29 18:05:36 -03:00
ca7b712d4f
Merge unikernel-demo with full history 2026-01-29 18:05:33 -03:00
3074220f45
Merge libft with full history 2026-01-29 18:05:30 -03:00
af4f50ad40
Merge traceroute with full history 2026-01-29 18:05:27 -03:00
4320bc5460
Merge ping with full history 2026-01-29 18:05:24 -03:00
274f4a2719
Merge libftasm with full history 2026-01-29 18:05:21 -03:00
c02e721353
Merge ftp with full history 2026-01-29 18:05:18 -03:00
0b34a414c5
Merge nm-otool with full history 2026-01-29 18:05:14 -03:00
a11706a074
Merge nmap with full history 2026-01-29 18:05:11 -03:00
257498d4f6
Merge malloc with full history 2026-01-29 18:05:07 -03:00
26093882f5 new repo 2019-08-17 02:24:41 +02:00
Louis Solofrizzo
6a1c3734e6 fs: Add stat example
Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
2019-04-25 11:30:39 +02:00
Louis Solofrizzo
021914386e Makefile: Enable ukl-hybrid mode by default for examples
See
b4d6cab6f6
for more information

Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
2019-04-25 09:35:10 +02:00
Louis Solofrizzo
e7c0133eac io1: Add printf examples
Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
2019-04-24 12:08:25 +02:00
Louis Solofrizzo
4cf27f5081 build: New makefiles and stdio example
Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
2019-04-24 08:31:17 +02:00
69b2dc41d7 network1 2019-04-23 22:05:13 +02:00
df34cecb16 readme 2019-04-23 19:51:15 +02:00
80e86f4ec0 first commit 2019-04-23 19:47:29 +02:00
Jack Halford
3d167f26d5 pci, ide stuff 2019-02-02 18:46:41 +01:00
Jack Halford
c9ad4e9e58 lspci, console refactor 2019-01-20 22:11:14 +01:00
Jack Halford
85afa2b437 pci first commit 2019-01-16 22:30:06 +01:00
Jack Halford
381b86d5e0 console moved out of vga 2019-01-16 20:53:40 +01:00
Jack Halford
3e49ec75d3 it compiles, update for rust 2018 2019-01-15 23:16:36 +01:00
Jack Halford
911d9c8ae2 readme 2018-11-28 23:27:31 +01:00
Jack Halford
ea87e5a453 Merge branch 'KFS-5' of https://github.com/jzck/kernel into KFS-5 2018-11-28 23:21:54 +01:00
Jack Halford
f02df6577e some stuff 2018-11-28 23:21:48 +01:00
Jack Halford
8e1927dc7d modules https 2018-08-24 23:53:00 +02:00
Jack Halford
ba108d9e3e scheduling 2018-06-06 18:16:50 +02:00
Jack Halford
b75d97b11e timer done 2018-06-06 16:59:16 +02:00
Jack Halford
15a7f53bc2 no more warnings! 2018-06-05 18:05:18 +02:00
Jack Halford
e48c3fc680 Does it compile? no. Do I know what Im doing? maybe. Am I making progress? Yes. 2018-05-31 18:32:52 +02:00
Jack Halford
983c5d6e27 qemu i386 hardcoded 2018-05-17 17:07:15 +02:00
Jack Halford
df163a4349 reverted back 2018-05-17 16:54:42 +02:00
Jack Halford
02d0ddaf02 changed name x86 to i386 2018-05-17 16:48:47 +02:00
Jack Halford
91d6d126e8 switched qemu to qemu-system-i386, even though it doesnt change anything useful 2018-05-17 16:46:02 +02:00
Jack Halford
e2cf54877e some stuff 2018-05-17 13:17:39 +02:00
Jack Halford
0aae87eda3 i'm just trying to figure out this mess.. fml 2018-05-03 20:27:52 +02:00
Jack Halford
d3eb0e5138 gdt stuff 2018-04-25 21:37:58 +02:00
Jack Halford
4a13eb1c15 bp doesnt block 2018-04-17 12:28:04 +02:00
Jack Halford
203ddd9780 cleanup up for handing in 2018-04-17 12:26:47 +02:00
Jack Halford
7e150e081b now we have 2 tss's, still doesnt work properly 2018-04-16 16:34:20 +02:00
wescande
b3a1c5194a add some 2018-04-15 21:00:53 +02:00
Jack Halford
e1f8c3f9ca stack stuff for willy wonka 2018-04-15 18:12:51 +02:00
Jack Halford
700b8a4e00 rustfmt 2018-04-15 11:50:13 +02:00
Jack Halford
5befd11f8d Merge branch 'KFS-4' of github.com:jzck/kernel into KFS-4 2018-04-15 11:49:44 +02:00
Jack Halford
d64c01d2b1 nothing important 2018-04-15 11:48:51 +02:00
wescande
d15fa664f2 No more cpuio, juste pio in io module. (change in acpi for that => need refactor) 2018-04-15 11:31:40 +02:00
wescande
cdf09f9869 keyboard use Pio 2018-04-12 19:37:43 +02:00
Jack Halford
ffcb85dd5b prettier asm 2018-04-12 18:06:50 +02:00
Jack Halford
fd0915048d removed unused segments selectors in assembly 2018-04-12 18:01:13 +02:00
Jack Halford
f138d77e4d gdt support in rust 2018-04-12 17:59:14 +02:00
Jack Halford
8a3e3a2324 cursor.rs, no more cpuio in vga 2018-04-12 15:49:37 +02:00
Jack Halford
b0548384e7 context gone 2018-04-12 15:32:11 +02:00
Jack Halford
0849f24628 close #2 2018-04-12 15:13:02 +02:00
Jack Halford
5f40aeeae5 grub.mk mdr 2018-04-12 14:49:52 +02:00
Jack Halford
ee5f2780e5 multiboot crate update 2018-04-12 14:31:58 +02:00
Jack Halford
e574d11aa2 Merge branch 'KFS-4' of github.com:jzck/kernel into KFS-4 2018-04-12 14:28:24 +02:00
Jack Halford
ae7c97a77d massive memory problem averted: we were just being stupid like usual 2018-04-12 14:27:41 +02:00
wescande
1c606561a1 keyboard input is now in irq compliant mode 2018-04-10 21:43:40 +02:00
Jack Halford
d382b623a4 nope 2018-04-09 20:46:42 +02:00
Jack Halford
1744c523d7 makefile refactor 2018-04-09 20:45:28 +02:00
Jack Halford
93e48044f5 makefile refactor 2018-04-09 20:26:45 +02:00
Jack Halford
9f1c31f298 this commit should work but there's something VERY broken with the stack atm, all focus on this until understood better 2018-04-09 17:11:46 +02:00
Jack Halford
b51fe947f0 asm 2018-04-09 14:55:06 +02:00
Jack Halford
7fb7d9d460 x86 updated for gdt 2018-04-09 13:34:02 +02:00
Jack Halford
a0ad3689f3 code doesnt work anymore but i'm commiting anyway, shoot me 2018-04-09 13:33:16 +02:00
Jack Halford
bea6a729fe gdt in place but triple faults because of spin::Once for now 2018-04-06 17:43:58 +02:00
Jack Halford
1b7ddd12d9 pti file, doesnt work yet 2018-04-05 19:04:44 +02:00
Jack Halford
b7855ae56c @gz merged rust-cpuid PR so i can get rid of my fork 2018-04-05 19:04:05 +02:00
Jack Halford
24fa39d45c cpu as a console command 2018-04-05 13:49:47 +02:00
Jack Halford
4885defefa keyboard now works with interrupts, cool 2018-04-05 13:16:38 +02:00
Jack Halford
0f79f2843c cpuid support 2018-04-05 12:25:53 +02:00
Jack Halford
19bf69bb29 readme 2018-03-29 20:41:36 +02:00
Jack Halford
42e06809ac x86lib update 2018-03-29 20:32:23 +02:00
Jack Halford
c24ac47698 pio and x86/pic 2018-03-29 20:29:04 +02:00
Jack Halford
6d8c31b42c major refactoring for upcoming cross platform, also recycle allocator for the physical frames 2018-03-29 17:10:42 +02:00
Jack Halford
095c369061 x86 tss 2018-03-26 15:22:27 +02:00
Jack Halford
9d69b7a82a stack allocator, keyboard doesnt work with interrupts yet, i think i need to tell 0x20 and 0x21 to shift interrupt by 32 because of intel bug. tomorrow 2018-03-26 15:22:27 +02:00
Jack Halford
30a8daf1a3 first interrupts works 2018-03-26 15:19:07 +02:00
Jack Halford
098d222fc1 int 2018-03-26 15:18:28 +02:00
wescande
5c7daabdd0 little correctif 2018-03-20 13:37:51 +01:00
Jack Halford
0526b88859 merge done, x86 is now a module 2018-03-19 12:23:42 +01:00
Jack Halford
ed03d247c7 it works:))) 2018-03-19 12:14:30 +01:00
wescande
519ce623fe Merge branch 'KFS-2' into KFS-3 2018-03-19 11:44:09 +01:00
wescande
cdea287ecd acpi can run in kfs-3 2018-03-19 11:23:53 +01:00
wescande
4863945042 multiboot update 2018-03-19 10:58:54 +01:00
wescande
904e7158d8 acpi in static not in reference 2018-03-16 15:03:00 +01:00
Jack Halford
5c2b5f723b yuesterdays problem solved, now i triple fault on write to CR3, fun 2018-03-15 17:16:01 +01:00
Jack Halford
8cf793260c it compiles now with the new x86 lib, triple faults when setting temp page to zero though 2018-03-14 18:59:17 +01:00
Jack Halford
0b38f701ed WIP 2018-03-13 20:06:25 +01:00
Jack Halford
e73d3e175a Merge branch 'KFS-3' of github.com:jzck/kernel into KFS-3 2018-03-13 15:43:05 +01:00
Jack Halford
99f0ec0b7d stuff 2018-03-13 15:42:30 +01:00
wescande
0c3589655f scroll is cleaning color 2018-03-13 13:30:00 +01:00
Jack Halford
3dfc440d20 heap allocator in place, no free yet 2018-03-12 17:48:24 +01:00
Jack Halford
36b51236b3 with the remap line 2018-03-12 14:53:48 +01:00
Jack Halford
ec1e7c8a5b tlb added, acpi still faults with the new memory 2018-03-12 14:53:26 +01:00
Jack Halford
f0456aa7fd i must have done something right becuase now 0xffff_f000 points to p2 as expected, hurray 2018-03-11 18:41:34 +01:00
Jack Halford
bbe2b8b1e6 still no debug symbols 2018-03-10 17:35:51 +01:00
Jack Halford
1f5a361870 some changes 2018-03-09 13:12:21 +01:00
wescande
0d8ecdf191 remove log 2018-03-08 15:10:32 +01:00
wescande
11c3614060 oop multiboot 2018-03-08 14:59:59 +01:00
wescande
9ba59d5858 Set ready for KFS-2 2018-03-08 14:50:25 +01:00
Jack Halford
3041cec87d mmu code mostly written, needs a lot of debugging still 2018-03-07 19:15:19 +01:00
Jack Halford
d491624274 rut stable, going to do some assembly now 2018-03-05 13:29:44 +01:00
Jack Halford
5412334168 it runs 2018-03-05 13:12:02 +01:00
Jack Halford
3d532a5a7a memory stuff 2018-03-05 11:29:07 +01:00
Jack Halford
120292566d context works fianlly 2018-03-05 11:29:07 +01:00
Jack Halford
edfffc3b13 this shit compiles but crashes after fighting for eternity with the borrow checker 2018-03-05 11:28:20 +01:00
Jack Halford
0f5bf89493 -amend 2018-03-05 11:24:23 +01:00
Jack Halford
2a2f377b9f first commit for kfs3 2018-03-05 11:24:23 +01:00
wescande
2ca356340a some minor fix 2018-03-02 18:44:41 +01:00
wescande
6e2456d2f8 Merge branch 'ACPI' into KFS-2 + add help function 2018-03-02 17:09:42 +01:00
wescande
614da57de3 Add FULL ACPI support, change exec mode 2018-03-02 15:48:06 +01:00
Jack Halford
bcf58de7ac some sweet commands to finish up kfs2, gonna start the frame allocator now 2018-02-28 19:28:48 +01:00
Jack Halford
52af278a91 added multiboot as a local crate 2018-02-28 15:10:17 +01:00
Jack Halford
7d08ddf53c stack printed, but is it really the stack ? 2018-02-26 16:14:59 +01:00
Jack Halford
063cab66f2 rudimentary hexdump 2018-02-26 13:15:12 +01:00
Jack Halford
0877ac2cc6 linker script again 2018-02-22 19:17:52 +01:00
Jack Halford
fc3c60d970 use objdump -h build/kernel-x86.bin to show sections, linker scripts squishes relevant ones together 2018-02-22 18:54:08 +01:00
Jack Halford
3ee7508331 doc comment testing 2018-02-21 15:56:27 +01:00
Jack Halford
4a12411aa8 travis and readme 2018-02-21 15:52:44 +01:00
Jack Halford
32616c2497 ok it compiles 2018-02-21 14:09:31 +01:00
Jack Halford
3c2b7f3f75 doesnt compile, 2 sec 2018-02-21 14:07:26 +01:00
Jack Halford
4f809497ca cargo toml 2018-02-21 13:41:23 +01:00
Jack Halford
554872c8fa added console.rs to group commands, refactored the command buffer and command matching code 2018-02-21 13:28:59 +01:00
wescande
0e7b73e2fa mini-shell for 3 cmd. we have to implemente it now 2018-02-15 19:38:27 +01:00
wescande
e72afcd086 Merge branch 'KFS-2' of https://github.com/jzck/kernel into KFS-2 2018-02-15 17:56:01 +01:00
wescande
c3f7c123f6 gdt rocks 2018-02-15 17:55:41 +01:00
Jack Halford
f6384015d6 starting to convert vga buffer to a terminal 2018-02-15 11:09:27 +01:00
Jack Halford
13005548ee merged kfs-1 changes 2018-02-13 14:37:22 +01:00
Jack Halford
6598cbe3eb cursor is now the real VGA buffer cursor 2018-02-13 14:35:17 +01:00
Jack Halford
d6423d5a78 cleanup 2018-02-13 09:40:26 +01:00
Jack Halford
864d2dca4e cleanup 2018-02-13 09:38:25 +01:00
wescande
9bb408b77a lol 2018-02-12 18:19:01 +01:00
Jack Halford
bd86aae536 lol 2018-02-12 18:00:15 +01:00
Jack Halford
1e278eebe3 colors at startup 2018-02-12 17:49:39 +01:00
wescande
37d51d2afe init kfs_2 2018-02-12 17:08:06 +01:00
wescande
097dfd7ddc yolo 2018-02-12 16:49:30 +01:00
wescande
b730734cef Merge branch 'master' of https://github.com/jzck/kernel 2018-02-12 16:25:45 +01:00
wescande
d8e0647153 Merge branch 'master' of https://github.com/jzck/kernel 2018-02-12 16:17:26 +01:00
Jack Halford
3f2068de99 print[ln] macros in place 2018-02-12 16:16:42 +01:00
wescande
27589f5d2c Merge remote-tracking branch 'origin/keyboard_handle' 2018-02-12 16:14:47 +01:00
Jack Halford
2503fdb96d CONTEXT is instanciated at compile time now 2018-02-12 16:11:47 +01:00
Jack Halford
c1cb1e5620 greatly simplified Writer by removing T generic, 0xb8000 is now hardcoded in flush() 2018-02-12 16:06:00 +01:00
Jack Halford
67dbf5d9b3 context::Context handles multiple Writers, Writer handles cursor 2018-02-12 15:22:35 +01:00
wescande
6dd33393df keyboard handle maj 2018-02-12 12:55:23 +01:00
Jack Halford
66d75c0895 starting to make vga more modular, keyboard controls which screen is in scope 2018-02-10 18:18:58 +01:00
Jack Halford
7429ab83c8 better panic formatting 2018-02-09 18:56:10 +01:00
Jack Halford
8f2f89eae6 ignore 2018-02-09 17:53:03 +01:00
Jack Halford
f53468a1f5 cursor support :) 2018-02-09 17:51:38 +01:00
Jack Halford
c2df8effbe it compiles 2018-02-09 17:36:36 +01:00
Jack Halford
698a859b7c merge 2018-02-09 17:30:33 +01:00
Jack Halford
44e6787e2e makefile gdb 2018-02-09 17:28:53 +01:00
wescande
1476c49f2b Gdb enabled 2018-02-09 17:25:36 +01:00
Jack Halford
01fb8e1667 Merge branch 'master' of https://github.com/jzck/kernel 2018-02-09 17:10:44 +01:00
Jack Halford
15b0890ad3 stuff 2018-02-09 17:07:47 +01:00
wescande
f2405aaa58 makefile over 9000 2018-02-09 17:00:41 +01:00
wescande
be1b0def36 rectif port telnet 2018-02-09 14:54:01 +01:00
Jack Halford
56c937e620 vga 2018-02-09 14:50:07 +01:00
Jack Halford
4c12c768dc vga_buffer code first commit 2018-02-08 23:02:32 +01:00
wescande
69299bda2d basic rust call in 32b 2018-02-08 19:18:14 +01:00
wescande
612662870c make split tmux screen 2018-02-07 20:01:36 +01:00
Jack Halford
aec4b53e53 stuff 2018-02-06 23:39:33 +01:00
Jack Halford
6c252fb5da Update README.md 2018-02-06 14:44:29 +01:00
Jack Halford
1bfdff2a76 comments 2018-02-05 20:15:08 +01:00
Jack Halford
25a76fce29 Merge branch 'master' of https://github.com/jzck/kernel 2018-02-05 18:13:16 +01:00
Jack Halford
deb033ff50 stuck in the middle of paging 2018-02-05 18:13:10 +01:00
Jack Halford
2b4ee5d846 Update README.md 2018-02-05 11:16:01 +01:00
Jack Halford
aea724a64d Update README.md 2018-02-05 10:28:16 +01:00
Jack Halford
9a6ba1d03d Merge branch 'master' of https://github.com/jzck/kernel 2018-02-04 18:57:29 +00:00
Jack Halford
b347842b8d rust setup stuff 2018-02-04 18:57:20 +00:00
Jack Halford
4c019ca695 Update README.md 2018-02-04 19:48:28 +01:00
Jack Halford
88020a6fc3 Update README.md 2018-02-04 19:48:13 +01:00
Jack Halford
808a111b04 Update README.md 2018-02-04 19:42:19 +01:00
Jack Halford
84b5dcbb8b Update README.md 2018-02-04 19:42:05 +01:00
Jack Halford
a13899fd59 Update README.md 2018-02-04 19:37:15 +01:00
Jack Halford
b77dcc8ee3 Update README.md 2018-02-04 19:17:35 +01:00
Jack Halford
c78d7a06aa Update README.md 2018-02-04 19:17:19 +01:00
Jack Halford
93b06cea11 readme 2018-02-04 18:16:37 +00:00
Jack Halford
68abeabb0f README with blog url 2018-02-04 18:08:45 +00:00
Jack Halford
687b609244 long mode achieved, starting rust 2018-02-04 18:51:25 +01:00
Jack Halford
6411831e67 readme, also paging is enabled 2018-02-04 17:32:46 +00:00
Jack Halford
39e3de544e no more vagrantfile 2018-02-04 15:09:27 +01:00
Jack Halford
cc8a6f6a6f first commit! 2018-02-04 14:37:23 +01:00
Jack Halford
5a0a708e90 refactor like ping, easy to hand in 2017-11-28 16:25:31 +00:00
Jack Halford
0a9d68b981 no more libft 2017-11-28 16:12:18 +00:00
Jack Halford
9d11475d99 added cliopts and -t option, ipv6 next 2017-11-28 15:47:10 +00:00
Jack Halford
ee26baea8a refactor for docker ubuntu, no more libft 2017-11-27 18:15:35 +00:00
Jack Halford
dff0d5f79e libft gone 2017-11-27 17:28:56 +00:00
Jack Halford
da72d6e922 libft submodule commit 2017-11-24 00:48:00 +01:00
Jack Halford
a2ef051d5c makefile linkage 2017-11-23 18:13:48 +01:00
Jack Halford
b2873fd6f6 last commit ? 2017-11-23 17:55:55 +01:00
Jack Halford
cae367e0fc works 2017-11-23 15:43:22 +01:00
Jack Halford
3efbeb3903 stuff 2017-11-20 17:41:23 +01:00
Jack Halford
21c173ff69 USER msg changed 2017-11-20 13:49:04 +01:00
Jack Halford
18d8963f1d client behaves well when server quits 2017-11-20 13:24:24 +01:00
Jack Halford
e7643cc6c7 norme 2017-11-20 13:15:31 +01:00
Jack Halford
e9802e5c00 rs is gone 2017-11-20 12:42:06 +01:00
Jack Halford
71d6e49acb some code 2017-11-19 21:39:41 +01:00
Jack Halford
1bef2f2c68 epoch fix 2017-11-19 21:39:13 +01:00
Jack Halford
76a06c4fc9 more stuff 2017-11-16 21:39:20 +01:00
Jack Halford
8e66148582 puts/putchar stuff 2017-11-16 15:49:59 +01:00
Jack Halford
6d62442fd8 getting back into x86.. painfully 2017-11-15 18:11:53 +01:00
Jack Halford
fe4d06be47 upload/download for big files is much more consistent 2017-11-15 13:30:02 +01:00
Jack Halford
462f8062db Merge branch 'master' of https://github.com/jzck/ping 2017-11-13 16:25:25 +01:00
Jack Halford
26892b9cf7 libft 2017-11-13 16:25:13 +01:00
Jack Halford
1c980a35cc libft: 2017-11-13 16:24:40 +01:00
Jack Halford
2279ad158e Merge branch 'master' into HEAD 2017-11-13 16:22:44 +01:00
Jack Halford
a926031dd0 new rs 2017-11-13 16:21:48 +01:00
Jack Halford
c90606706b stuff 2017-11-13 15:33:42 +01:00
Jack Halford
8922e82aae stuff 2017-11-12 19:19:56 +01:00
Jack Halford
d7d427e902 added sample data for user 'a' 2017-11-12 15:20:51 +01:00
Jack Halford
85d0716fbe epsv/ipv6 done. norme too. 2017-11-12 15:02:56 +01:00
Jack Halford
4cb22f02a7 for valgrind 2017-11-10 19:57:45 +01:00
Jack Halford
fe67dfe17e DELE done, RMD and MKD look ok also 2017-11-10 19:49:11 +01:00
Jack Halford
1b3b422b31 mkdir/rmdir started 2017-11-10 19:36:49 +01:00
Jack Halford
8ec4bc4ff8 stuff 2017-11-10 19:36:29 +01:00
Jack Halford
0c523757c6 client get/put, data transfer transfer is STRU file, TYPE A, and MODE stream only 2017-11-10 17:53:37 +01:00
Jack Halford
bd413e411a client on its way, data transfer doesnt work well. need to define type I/A better 2017-11-09 15:17:35 +01:00
Jack Halford
f24ae0d3a6 started work on client, doesnt compile but I'm going to grab a 🍺 2017-11-08 20:12:24 +01:00
Jack Halford
2213d5fcb9 PASV/PORT work in harmony :thumbs_up: 2017-11-08 17:31:38 +01:00
Jack Halford
5b370b6a43 added client/server sources 2017-11-08 17:23:37 +01:00
Jack Halford
b78cb8431a norme 2017-11-07 16:03:11 +01:00
Jack Halford
3301d5880c okay for corrupted binaries 2017-11-07 15:53:08 +01:00
Jack Halford
21f1af7011 filezilla ok 2017-11-02 17:30:46 +01:00
Jack Halford
2fb808eba5 stuff 2017-11-01 21:39:37 +01:00
Jack Halford
20791a4180 je vais boire une 🍺 2017-11-01 19:30:36 +01:00
Jack Halford
a997e64d17 norme 2017-11-01 13:20:16 +01:00
Jack Halford
7726cd38f9 full format ok 2017-11-01 13:11:36 +01:00
Jack Halford
519b50e304 ppc done 2017-11-01 13:00:12 +01:00
Jack Halford
aecf9be263 fat binaries done, otool doesnt work on object files 2017-10-31 19:59:45 +01:00
Jack Halford
1103db79be 1 days work, still need to sort out archs for universal binaries 2017-10-30 18:38:24 +01:00
Jack Halford
33b7b25abe finished 32 bit stuff 2017-10-30 12:26:50 +01:00
Jack Halford
cd99c04ca5 stuff 2017-10-30 00:27:41 +01:00
Jack Halford
f57c2acc46 sed for mach_32 2017-10-29 17:24:13 +01:00
Jack Halford
a565b7738d lol 2017-10-26 19:15:27 +02:00
Jack Halford
4516dc7bb5 gotta have root machine to test this stuff now 2017-10-26 17:38:00 +02:00
Jack Halford
cc0bc24e90 mre stuff 2017-10-26 17:20:30 +02:00
Jack Halford
d9955513c0 stuff 2017-10-26 00:53:21 +02:00
Jack Halford
7940136560 pcap_test gone 2017-10-25 13:06:57 +02:00
Jack Halford
73b7fbcd2a changed pattern completely, much better 2017-10-24 21:48:39 +02:00
Jack Halford
b8eadccc85 stuff 2017-10-24 18:22:56 +02:00
Jack Halford
773d6d6f8b run is back 2017-10-24 18:20:08 +02:00
Jack Halford
c45d6d53c2 run 2017-10-23 19:45:49 +02:00
Jack Halford
a28c11d35a done 2017-10-23 19:42:30 +02:00
Jack Halford
931cdbe9e5 ignore .bin 2017-10-22 18:46:41 +02:00
Jack Halford
4c789ad847 1 2017-10-22 18:46:01 +02:00
Jack Halford
b1ba5b3f44 auteur test 2017-10-22 18:38:57 +02:00
Jack Halford
8e70deabc3 all good 2017-10-22 17:37:56 +02:00
Jack Halford
3f86775ec2 branching out now to a pipeline design 2017-10-09 17:13:02 +02:00
Jack Halford
14dcfdcafc libft hard copy 2017-10-08 21:30:28 +02:00
Jack Halford
b18fc7924e libft submoduel gone 2017-10-08 21:30:05 +02:00
Jack Halford
a8fe30763e it compiles 2017-10-08 18:17:17 +02:00
Jack Halford
4fc003a0c7 libft hard link 2017-10-08 17:57:08 +02:00
Jack Halford
1ae8cc9b57 libft submodule gone 2017-10-08 17:56:54 +02:00
Jack Halford
3dc179ec01 norme, maybe broken 2017-10-08 17:55:38 +02:00
Jack Halford
ba333562dd norme and net refactor 2017-10-08 16:53:06 +02:00
Jack Halford
07728f5057 norme 2017-10-08 16:38:26 +02:00
Jack Halford
728fc5b296 norme 2017-10-08 14:37:05 +02:00
Jack Halford
80837f0428 libft changes while cleaning ping.c 2017-10-08 14:36:49 +02:00
Jack Halford
ff629391b0 stuff 2017-10-08 14:28:07 +02:00
Jack Halford
e78c41d420 libft hard add 2017-10-08 12:28:04 +02:00
Jack Halford
ada0fcea3a libft submodule gone 2017-10-08 12:27:31 +02:00
Jack Halford
a20a644697 norme 2017-10-08 12:26:10 +02:00
Jack Halford
5be6c47685 norme done 2017-10-08 11:35:05 +02:00
Jack Halford
cfa90b1cd8 some norme 2017-10-07 18:36:09 +02:00
Jack Halford
44b23be0a0 libft norme 2017-10-07 18:24:39 +02:00
Jack Halford
a3f0bb0db8 norme good 2017-10-07 18:19:59 +02:00
Jack Halford
488d622ed1 no more submodule 2017-10-07 17:49:14 +02:00
Jack Halford
555844379d cleanup 2017-10-07 17:13:41 +02:00
Jack Halford
ac5300023b norme ok, still need to fix without ft_ 2017-10-07 17:10:59 +02:00
Jack Halford
a24acfd0a1 minor stuff 2017-09-30 13:24:43 +02:00
Jack Halford
c9be993efd day 2017-09-27 19:34:04 +02:00
Jack Halford
a75160775a coroutines 2017-09-26 18:59:18 +02:00
Jack Halford
8e29c2c26b bugger 2017-09-03 11:55:53 +02:00
Jack Halford
74a22a407c Yep, Steve was right on this one. 2017-09-02 23:49:52 +02:00
Jack Halford
259309fa0d I must enjoy torturing myself 2017-09-01 19:32:06 +02:00
Jack Halford
cc5885aec3 Merge branch 'master' of https://github.com/jzck/libft into HEAD 2017-09-01 19:29:50 +02:00
Jack Halford
6908e10aab packet forging 2017-09-01 19:29:17 +02:00
Jack Halford
4e9160f0dd stopped caring 23 commits ago 2017-09-01 10:39:21 +02:00
Jack Halford
9d24c52edd gitignore 2017-08-27 22:31:04 +02:00
Jack Halford
615434fe0f no readme 2017-08-27 22:30:47 +02:00
Jack Halford
1991ae9b4d first commit for ASM 2017-08-27 22:29:48 +02:00
Jack Halford
c5a9ac9970 stuff 2017-08-25 19:17:46 +02:00
Jack Halford
2d46d00df8 stuff 2017-08-25 13:31:18 +02:00
Jack Halford
ac1def2a8a stuff 2017-08-25 11:06:29 +02:00
ariard
7d1da87ec8 Merge branch 'master' of https://github.com/jzck/libft
"new stuff irc"
2017-08-16 19:53:26 +02:00
ariard
47b19c606b Merge branch 'master' of https://github.com/jzck/libft
"new stuff irc"
2017-08-16 19:53:26 +02:00
ariard
98168e630e ft_lst2str 2017-08-16 19:52:29 +02:00
ariard
5ebb9848b1 ft_lst2str 2017-08-16 19:52:29 +02:00
Jack Halford
c3069f5743 Update README.md 2017-08-03 17:16:06 +02:00
Jack Halford
208b6855b0 Create README.md 2017-08-03 17:14:50 +02:00
Jack Halford
ff5b127303 libft 2017-08-02 19:22:28 +02:00
Jack Halford
8b934533d6 stuff 2017-08-02 19:21:37 +02:00
Jack Halford
6df67a60c7 Merge branch 'master' of https://github.com/jzck/libft 2017-08-02 19:20:58 +02:00
Jack Halford
e65befc5f7 Merge branch 'master' of https://github.com/jzck/libft 2017-08-02 19:20:58 +02:00
Jack Halford
987536015a stuff 2017-08-02 19:20:40 +02:00
Jack Halford
a06f9f10a0 stuff 2017-08-02 19:20:40 +02:00
Jack Halford
e10ab459dc looks good. need to come back for norme and final testing 2017-07-26 18:02:14 +02:00
Jack Halford
99972b4f8e some progress 2017-07-25 18:20:34 +02:00
Jack Halford
1c8189631d strsepjoin 2017-07-25 18:20:06 +02:00
Jack Halford
52c3c2e15b strsepjoin 2017-07-25 18:20:06 +02:00
ariard
91f79ea663 with lst_pop propre 2017-07-04 17:40:24 +02:00
ariard
a0d85d1c71 with lst_pop propre 2017-07-04 17:40:24 +02:00
Antoine Riard
6fdb76b528 with hashtab_del 2017-06-24 01:30:37 +02:00
Antoine Riard
97ea87ec5c with hashtab_del 2017-06-24 01:30:37 +02:00
Antoine Riard
d3ab1f0071 with generator on hashtab 2017-06-21 19:55:15 +02:00
Antoine Riard
0e35e0bd1e with generator on hashtab 2017-06-21 19:55:15 +02:00
Antoine Riard
11dd6dbd12 fix missing seperator on makefile 2017-06-16 18:25:14 +02:00
Antoine Riard
4b35185e8f fix missing seperator on makefile 2017-06-16 18:25:14 +02:00
Jack Halford
8f3da61851 libft update 2017-06-15 10:03:15 +02:00
Jack Halford
9dc57f5cde merged new htb changes 2017-06-15 09:52:36 +02:00
Jack Halford
934be2cf0f merged new htb changes 2017-06-15 09:52:36 +02:00
Jack Halford
9ce0752ca6 removed many sys/ stuff because the design was bad and doesnt compile easily on linux! 2017-06-15 09:48:40 +02:00
Jack Halford
3bf0fbd3cd removed many sys/ stuff because the design was bad and doesnt compile easily on linux! 2017-06-15 09:48:40 +02:00
Jack Halford
5df68055d5 do_help fix 2017-06-14 12:00:27 +02:00
Jack Halford
cd41b16053 compiles on linux platform. GET fixed 2017-06-14 11:53:47 +02:00
Antoine Riard
246376f6df better insert sort 2017-05-20 20:06:38 +02:00
Antoine Riard
61a1acc283 better insert sort 2017-05-20 20:06:38 +02:00
Antoine Riard
a571372cbf lst insert sort 2017-05-19 18:57:48 +02:00
Antoine Riard
6271ccc06e lst insert sort 2017-05-19 18:57:48 +02:00
Antoine Riard
bff3056dbe lst insert sort 2017-05-19 18:57:41 +02:00
Antoine Riard
797a946f69 lst insert sort 2017-05-19 18:57:41 +02:00
Antoine Riard
fe85569a79 Merge branch 'master' of https://github.com/jzck/libft
"merge with hashtab"
2017-05-16 21:41:49 +02:00
Antoine Riard
deb6ea10ee Merge branch 'master' of https://github.com/jzck/libft
"merge with hashtab"
2017-05-16 21:41:49 +02:00
Antoine Riard
584b975ae4 Makefile with hashtab 2017-05-16 21:41:39 +02:00
Antoine Riard
6880a18ff7 Makefile with hashtab 2017-05-16 21:41:39 +02:00
Antoine Riard
bdefb3c7a5 hashtab v0 2017-05-16 21:41:09 +02:00
Antoine Riard
03250988f9 hashtab v0 2017-05-16 21:41:09 +02:00
Jack Halford
b042d94bf6 removed fcntl for non blocking IO: old artefact from the ping copy/paste 2017-05-14 22:30:39 +02:00
Jack Halford
adc4965e38 first commit, seems almost finished. gotta see bonus option and linux compatibility issues 2017-05-14 22:26:43 +02:00
Jack Halford
66d9a2a514 much progress, need to remove non blocking IO because its not allowed 2017-05-13 23:15:50 +02:00
Jack Halford
d3aaedb7a2 much progress, need to remove non blocking IO because its not allowed 2017-05-13 23:15:50 +02:00
Jack Halford
a15dbab18e added runnins stats (rs) and hexdump, normed fucked 2017-05-13 23:14:51 +02:00
Jack Halford
545317e896 added runnins stats (rs) and hexdump, normed fucked 2017-05-13 23:14:51 +02:00
Jack Halford
9f9c662957 first commit 2017-04-23 18:19:00 +02:00
Jack Halford
5cd2bf7039 first commit 2017-04-23 18:19:00 +02:00
Jack Halford
ebb2a5cefc get,debug,help done. net_get/net_send in libft manage data transfer 2017-04-05 00:45:10 +02:00
Jack Halford
df11d70ab4 new net category for server/client stuff 2017-04-05 00:44:32 +02:00
Jack Halford
4ca02be6eb new net category for server/client stuff 2017-04-05 00:44:32 +02:00
Jack Halford
9ba51ed172 Merge branch 'master' of https://github.com/jzck/libft 2017-04-04 14:16:15 +02:00
Jack Halford
d90d8c1b96 Merge branch 'master' of https://github.com/jzck/libft 2017-04-04 14:16:15 +02:00
Jack Halford
0f27d7379b some debug macros 2017-04-04 14:16:07 +02:00
Jack Halford
5d72f40c8c some debug macros 2017-04-04 14:16:07 +02:00
Jack Halford
2772d8d0b3 some client side improvements, started to use readline(3) 2017-04-03 18:43:58 +02:00
Jack Halford
92daf7c8a6 going to add a proper readline to libft next 2017-04-03 17:25:07 +02:00
Jack Halford
932dec2b05 name-->key for stof 2017-04-03 17:24:03 +02:00
Jack Halford
88748933c2 name-->key for stof 2017-04-03 17:24:03 +02:00
Jack Halford
9d86bea9d1 no binaries 2017-04-02 21:47:23 +02:00
Jack Halford
cb353cbe3c first commit 2017-04-02 21:44:59 +02:00
Jack Halford
12b098f9d8 first commit 2017-04-02 21:41:57 +02:00
Jack Halford
5c06038b5f first commit 2017-04-02 21:41:57 +02:00
Jack Halford
ed31e25ad1 lib file removed 2017-04-02 14:57:34 +02:00
Jack Halford
631792b831 new chunk management 2017-04-01 18:49:10 +02:00
Jack Halford
202e63f291 new libft 2017-03-31 23:35:51 +02:00
Jack Halford
d17a428fcd -m done, formatting it cleaner 2017-03-31 21:51:13 +02:00
Jack Halford
0aef582882 merged 42sh stuff that wasnt in the submodule 2017-03-31 21:50:40 +02:00
Jack Halford
1bb30cd814 merged 42sh stuff that wasnt in the submodule 2017-03-31 21:50:40 +02:00
Jack Halford
cb2e66e0c6 42sh stuff 2017-03-31 21:42:02 +02:00
Jack Halford
580c3ecc47 42sh stuff 2017-03-31 21:42:02 +02:00
Jack Halford
56a1cca870 no more makefile 2017-03-31 21:37:07 +02:00
Jack Halford
39b2721eb3 no more makefile 2017-03-31 21:37:07 +02:00
Jack Halford
a5f95274a3 o 2017-03-31 18:41:14 +02:00
Jack Halford
1c522de187 o 2017-03-31 18:41:14 +02:00
Jack Halford
e00afe12b0 src-->srcs 2017-03-31 18:40:30 +02:00
Jack Halford
75171780f7 src-->srcs 2017-03-31 18:40:30 +02:00
Jack Halford
ce100d4c7f stuff 2017-03-31 18:38:57 +02:00
Jack Halford
95a51bc94c stuff 2017-03-31 18:38:57 +02:00
Jack Halford
84732a076d new makefile 2017-03-31 18:21:43 +02:00
Jack Halford
ec247f4c2f new makefile (thx william) and src-->srcs 2017-03-31 18:21:20 +02:00
Jack Halford
7e0b26b886 new makefile (thx william) and src-->srcs 2017-03-31 18:21:20 +02:00
Jack Halford
8caadf0df6 filtering options 2017-03-29 16:39:47 +02:00
Jack Halford
eb7b390a96 __bss symbols OK 2017-03-27 23:07:00 +02:00
Jack Halford
646868b77a local syms 2017-03-27 21:58:49 +02:00
Jack Halford
5eee516d3a day's work 2017-03-27 03:24:34 +02:00
Jack Halford
e42fbd69d7 stuff 2017-03-27 03:24:00 +02:00
Jack Halford
ba772aeb91 stuff 2017-03-27 03:24:00 +02:00
Jack Halford
c472ce8e7c new cliopts from 42sh 2017-03-26 15:27:59 +02:00
Jack Halford
a5ae25cd9d new cliopts from 42sh 2017-03-26 15:27:59 +02:00
Jack Halford
72a6016278 cliopts start 2017-03-26 00:54:00 +01:00
Jack Halford
25362e802e stuff 2017-03-25 22:54:04 +01:00
Jack Halford
fcc8dc3536 some refactoring, separated dumping from fetching 2017-03-24 00:12:59 +01:00
Jack Halford
83c2942694 doesnt compile, changing the architecture 2017-03-23 18:58:08 +01:00
Jack Halford
318c4ded18 no more error_message 2017-03-16 14:20:19 +01:00
Jack Halford
07a27ee936 no more error_message 2017-03-16 14:20:19 +01:00
Jack Halford
ba7353ef2a merge 2017-03-15 21:24:00 +01:00
Jack Halford
679bc81574 merge 2017-03-15 21:24:00 +01:00
Jack Halford
9c31ef534e cliopts testing with getter functions 2017-03-15 21:23:31 +01:00
Jack Halford
72ab154c49 cliopts testing with getter functions 2017-03-15 21:23:31 +01:00
Antoine Riard
a7f23a39aa ft_error_message 2017-03-15 20:52:38 +01:00
Antoine Riard
e9ae0dea8e ft_error_message 2017-03-15 20:52:38 +01:00
Jack Halford
9220a523cb cliopts update 2017-03-14 21:51:19 +01:00
Jack Halford
4ab87feccb cliopts update 2017-03-14 21:51:19 +01:00
Jack Halford
599ca54b5e cliopts now part of libft 2017-03-14 21:11:07 +01:00
Jack Halford
f5c8342a3b cliopts now part of libft 2017-03-14 21:11:07 +01:00
Jack Halford
470e6e3432 strcpy protection 2017-03-13 16:24:11 +01:00
Jack Halford
aa7ad3e798 strcpy protection 2017-03-13 16:24:11 +01:00
Jack Halford
dedd68047c lstiter better usage 2017-03-11 18:33:39 +01:00
Jack Halford
7c0741ea60 lstiter better usage 2017-03-11 18:33:39 +01:00
Jack Halford
89dd2d63f3 {ran} color fix (no black) 2017-03-11 16:06:22 +01:00
Jack Halford
f90983da4d {ran} color fix (no black) 2017-03-11 16:06:22 +01:00
Jack Halford
81c7802c71 random colored PID in DG() 2017-03-10 17:08:34 +01:00
Jack Halford
1bacffef49 random colored PID in DG() 2017-03-10 17:08:34 +01:00
Jack Halford
61f790b8fc makefile update 2017-03-08 12:03:23 +01:00
Jack Halford
3237c8706e makefile update 2017-03-08 12:03:23 +01:00
Jack Halford
7877637c60 merged, use the new lstmap instead of lstdup 2017-03-08 11:59:15 +01:00
Jack Halford
af2db186cc merged, use the new lstmap instead of lstdup 2017-03-08 11:59:15 +01:00
Jack Halford
50bda89219 lstmap change like btree_map 2017-03-08 11:57:52 +01:00
Jack Halford
829740fdea lstmap change like btree_map 2017-03-08 11:57:52 +01:00
Antoine Riard
2425e8e627 modifs 2017-03-08 03:09:51 +01:00
Antoine Riard
286866619e modifs 2017-03-08 03:09:51 +01:00
wescande
7d714e1008 recitf libft,h 2017-03-07 16:43:05 +01:00
wescande
59fa54de4a recitf libft,h 2017-03-07 16:43:05 +01:00
wescande
ee44e7ecb3 change of t_itof 2017-03-07 15:40:12 +01:00
wescande
eed4fe14e6 change of t_itof 2017-03-07 15:40:12 +01:00
Jack Halford
c2ed70a384 merge resolved conflicts 2017-03-07 15:28:14 +01:00
Jack Halford
a10ad36cbf merge resolved conflicts 2017-03-07 15:28:14 +01:00
Jack Halford
d72502c41d struct itof for 42sh 2017-03-07 15:27:46 +01:00
Jack Halford
f3be89390b struct itof for 42sh 2017-03-07 15:27:46 +01:00
Antoine Riard
1fa81ff1be merged ok 2017-03-07 14:29:14 +01:00
Antoine Riard
c99b26ea88 merged ok 2017-03-07 14:29:14 +01:00
Antoine Riard
c8b018dc66 new ft str for math expression 2017-03-07 13:39:11 +01:00
Antoine Riard
48f16ba4cf new ft str for math expression 2017-03-07 13:39:11 +01:00
wescande
e98efda275 rectif de forme 2017-03-07 12:18:31 +01:00
wescande
e928ac423a rectif de forme 2017-03-07 12:18:31 +01:00
Jack Halford
30f3606561 id.c 2017-03-06 20:27:16 +01:00
Jack Halford
defe6b352e id.c 2017-03-06 20:27:16 +01:00
Jack Halford
ee9d9bfabb btree_map 2017-03-06 20:24:05 +01:00
Jack Halford
675c17a22f btree_map 2017-03-06 20:24:05 +01:00
wescande
6836fbf010 Makefile plus propre sur petit écran 2017-03-06 15:42:23 +01:00
wescande
94a62c90a8 Makefile plus propre sur petit écran 2017-03-06 15:42:23 +01:00
Jack Halford
6e60cffad6 __APPLE__ not __DARWIN__ 2017-03-05 16:48:57 +01:00
Jack Halford
8a84583701 __APPLE__ not __DARWIN__ 2017-03-05 16:48:57 +01:00
william
37d6c50eca permet la compilation sous linux des xattr + retrait de certaines variables set but not used [-Wunused-but-set-variable] 2017-03-05 15:21:27 +01:00
william
a2632d412e permet la compilation sous linux des xattr + retrait de certaines variables set but not used [-Wunused-but-set-variable] 2017-03-05 15:21:27 +01:00
Jack Halford
ee6038a4b1 push and pop changed 2017-03-03 16:59:05 +01:00
Jack Halford
fad52efb16 push and pop changed 2017-03-03 16:59:05 +01:00
Jack Halford
0e9ac5bbb9 stris compiles.... 2017-03-02 16:55:07 +01:00
Jack Halford
d962542643 stris compiles.... 2017-03-02 16:55:07 +01:00
ariard@student.42.fr
8488e6b582 ft_str_is 2017-03-02 15:31:04 +01:00
ariard@student.42.fr
cffdb8c72e ft_str_is 2017-03-02 15:31:04 +01:00
Jack Halford
2189c15ce9 added tests, starting parsing dysymtab 2017-03-01 17:56:02 +01:00
Jack Halford
ec9905a75a removed test executables 2017-03-01 12:18:43 +01:00
Jack Halford
829b295aa1 removed debug messages and extra functions 2017-03-01 12:18:03 +01:00
Jack Halford
3822058609 tests 2017-02-21 18:22:11 +01:00
Jack Halford
3f9f6a05f7 gnl change 2017-02-21 15:25:22 +01:00
Jack Halford
2a211640bf gnl change 2017-02-21 15:25:22 +01:00
Jack Halford
7326e33f92 put_endl_fd, deso deso wescande 2017-02-20 18:19:59 +01:00
Jack Halford
eb29b1a762 put_endl_fd, deso deso wescande 2017-02-20 18:19:59 +01:00
Jack Halford
555d3e2cc5 tests/ 2017-02-20 17:12:51 +01:00
Jack Halford
b635e5c158 merge 2017-02-20 17:12:32 +01:00
Jack Halford
0cacbbeb72 tests/ dir 2017-02-20 17:11:59 +01:00
Jack Halford
79234f9ed9 trimmed hexdump.c down 2017-02-20 16:53:03 +01:00
Jack Halford
e181f3bf64 merge fix 2017-02-20 16:44:16 +01:00
Jack Halford
27758bd345 merge fix 2017-02-20 16:44:16 +01:00
Jack Halford
6bfeb0e282 NULL proctect ft_strchr 2017-02-20 16:43:41 +01:00
Jack Halford
81d01f1186 NULL proctect ft_strchr 2017-02-20 16:43:41 +01:00
Jack Halford
d8fe7600a2 ft_otool first working version, need to work on the formatting and usage with libraries and fat binaries 2017-02-20 15:47:57 +01:00
Jack Halford
54425a0aa5 dump_sections done 2017-02-20 01:15:58 +01:00
Jack Halford
0e0fda4740 refatored functions into 'dump' atoms to make for a clearer view of the Mach-O layout 2017-02-20 00:59:42 +01:00
Jack Halford
0f94380f7c putnbr_hex instead of putaddr 2017-02-19 21:22:03 +01:00
Jack Halford
5f7812604f putnbr changes 2017-02-19 21:21:30 +01:00
Jack Halford
7f9413a55a putnbr changes 2017-02-19 21:21:30 +01:00
Jack Halford
6319a23950 32bit if, ft_nm displays all symbols thats it 2017-02-19 05:33:28 +01:00
Jack Halford
480c592c5b removed binary from git repo 2017-02-19 03:59:36 +01:00
Jack Halford
d6732360a1 debut de nm d'apres la video de l'intra 2017-02-19 03:56:59 +01:00
Jack Halford
c395e96cd5 colorful debug framework 2017-02-18 20:11:41 +01:00
Jack Halford
68d10bf7a7 put_addrfd 2017-02-18 20:11:09 +01:00
Jack Halford
c27f025a96 put_addrfd 2017-02-18 20:11:09 +01:00
Jack Halford
a01ceeaaf7 added -fvisibility=hidden for making .so libs 2017-02-18 14:01:09 +01:00
Jack Halford
ac4012cd1d added -fvisibility=hidden for making .so libs 2017-02-18 14:01:09 +01:00
Jack Halford
4d0e4feacf made new header files cleanup 2017-02-18 13:21:38 +01:00
Jack Halford
f375cb3608 made new header files cleanup 2017-02-18 13:21:38 +01:00
Jack Halford
28f582ad7f doing some work on hidding symbols... 2017-02-17 23:38:50 +01:00
Jack Halford
33de3ffa4f make -j 2017-02-17 17:31:48 +01:00
Jack Halford
df438532fe make -j 2017-02-17 17:31:48 +01:00
Jack Halford
dd104edda4 strcspn called strchr not ft_strchr 2017-02-17 17:11:56 +01:00
Jack Halford
72df6d67f4 strcspn called strchr not ft_strchr 2017-02-17 17:11:56 +01:00
Jack Halford
60c1d82186 gnl fixes 2017-02-17 14:10:23 +01:00
Jack Halford
a5c90ba0c5 gnl fixes 2017-02-17 14:10:23 +01:00
Jack Halford
016b3a5e74 Merge branch 'master' of https://github.com/jzck/libft into HEAD 2017-02-17 14:04:24 +01:00
Jack Halford
dd1d286625 Merge branch 'master' of https://github.com/jzck/libft into HEAD 2017-02-17 14:04:24 +01:00
Jack Halford
6e70998249 gnl leak fix 2017-02-17 14:03:55 +01:00
Jack Halford
36f725da8a gnl leak fix 2017-02-17 14:03:55 +01:00
Jack Halford
982fc062f9 fixes bit/byte confusion, also large zones work now 2017-02-17 13:19:28 +01:00
Jack Halford
4482024705 free fixes, gonna do large memory zones next 2017-02-16 19:32:00 +01:00
Jack Halford
1b8b22fbdf free() done, coalescing done 2017-02-16 18:10:01 +01:00
Jack Halford
053c0773de some work done on splitting, free() next 2017-02-16 15:48:29 +01:00
Jack Halford
a0f2bd93b7 strtrim fix 2017-02-16 11:43:31 +01:00
Jack Halford
ae7852577e strtrim fix 2017-02-16 11:43:31 +01:00
Jack Halford
5c78200d8f first commit 2017-02-16 01:26:55 +01:00
Jack Halford
dc01b777e1 re-added strsplit 2017-02-14 01:15:47 +01:00
Jack Halford
60c5eb2975 re-added strsplit 2017-02-14 01:15:47 +01:00
Jack Halford
5ab52f9d14 strcspn done, should use it to reimplement strsplit[_whitespace] cleanly 2017-02-14 00:40:57 +01:00
Jack Halford
a8debcb08a strcspn done, should use it to reimplement strsplit[_whitespace] cleanly 2017-02-14 00:40:57 +01:00
Jack Halford
75b4295d5a strtok, need to rewrite strcspn next 2017-02-13 15:30:49 +01:00
Jack Halford
7d6845a44c strtok, need to rewrite strcspn next 2017-02-13 15:30:49 +01:00
Jack Halford
6ee8d4e4fc push and pop 2017-02-10 00:37:52 +01:00
Jack Halford
18a111051f push and pop 2017-02-10 00:37:52 +01:00
Jack Halford
5d9de2f68a STD[IN|OUT|ERR] macros take from %_FILENO macros instead of hardcoded 0 1 2 2017-02-08 22:48:02 +01:00
Jack Halford
b0c5e6530e STD[IN|OUT|ERR] macros take from %_FILENO macros instead of hardcoded 0 1 2 2017-02-08 22:48:02 +01:00
Jack Halford
06785d73db replaced escape codes with \e 2017-02-07 20:12:51 +01:00
Jack Halford
0c79cfae8b replaced escape codes with \e 2017-02-07 20:12:51 +01:00
Jack Halford
4438a7e1dd dup2_close and makefile charging bar 2017-02-07 16:21:56 +01:00
Jack Halford
a3839c87b2 dup2_close and makefile charging bar 2017-02-07 16:21:56 +01:00
Jack Halford
4a673515ad split_whitespaces de gwojda 2017-02-03 16:13:50 +01:00
Jack Halford
0d732822fd split_whitespaces de gwojda 2017-02-03 16:13:50 +01:00
Jack Halford
e2b7126adc new makefile and update script for libft, thanks wescande@42 :D 2017-01-31 16:36:24 +01:00
Jack Halford
b71b921364 new makefile and update script for libft, thanks wescande@42 :D 2017-01-31 16:36:24 +01:00
Jack Halford
68bc772a26 printf minus for i conversions 2017-01-22 18:22:16 +01:00
Jack Halford
5b078df76d printf minus for i conversions 2017-01-22 18:22:16 +01:00
Jack Halford
fbbe237c14 ft_strreplace and stuff 2017-01-12 18:08:26 +01:00
Jack Halford
a9d24f3685 ft_strreplace and stuff 2017-01-12 18:08:26 +01:00
Jack Halford
f7b9265c1c ft_strbetween duplicates string in between 2 addresses 2017-01-11 18:05:47 +01:00
Jack Halford
a7b039631e ft_strbetween duplicates string in between 2 addresses 2017-01-11 18:05:47 +01:00
Jack Halford
2e1f96a78b lstfind more explicit NULL 2017-01-10 12:34:08 +01:00
Jack Halford
cb1bc84e19 lstfind more explicit NULL 2017-01-10 12:34:08 +01:00
Jack Halford
0a1079aac4 strdup protection for @alao 2017-01-10 10:56:49 +01:00
Jack Halford
084468644e strdup protection for @alao 2017-01-10 10:56:49 +01:00
Jack Halford
417c7c5da9 lst_filter improvement 2017-01-09 16:00:46 +01:00
Jack Halford
39e91f5407 lst_filter improvement 2017-01-09 16:00:46 +01:00
Jack Halford
034c988135 strcmp protection 2017-01-03 15:36:25 +01:00
Jack Halford
c2796fa97c strcmp protection 2017-01-03 15:36:25 +01:00
Jack Halford
81fa664170 printf NULL when null string 2016-12-22 11:44:03 +01:00
Jack Halford
85c8c39077 printf NULL when null string 2016-12-22 11:44:03 +01:00
Jack Halford
adc087a5cf stuff 2016-12-15 18:32:22 +01:00
Jack Halford
2245be7916 stuff 2016-12-15 18:32:22 +01:00
Jack Halford
109bce411c strappend fix 2016-12-13 17:59:26 +01:00
Jack Halford
ed59cc7816 strappend fix 2016-12-13 17:59:26 +01:00
Jack Halford
ebfef066fc ft_strappend 2016-12-13 12:58:51 +01:00
Jack Halford
7fd7d8c23c ft_strappend 2016-12-13 12:58:51 +01:00
Jack Halford
0e6e3ecb22 lst_at from piscine d11 2016-12-12 18:12:37 +01:00
Jack Halford
66e8156235 lst_at from piscine d11 2016-12-12 18:12:37 +01:00
Jack Halford
d1a2d83d21 sstrcat fix 2016-12-12 00:42:20 +01:00
Jack Halford
78390e5d8c sstrcat fix 2016-12-12 00:42:20 +01:00
Jack Halford
e0af98efbd sstrcat 2016-12-10 18:25:36 +01:00
Jack Halford
a60d17a0b9 sstrcat 2016-12-10 18:25:36 +01:00
Jack Halford
15654a8b1a new printf color capabilities 2016-12-09 22:17:42 +01:00
Jack Halford
d7f6f68560 new printf color capabilities 2016-12-09 22:17:42 +01:00
Jack Halford
45505dbca0 printf reallocation for 0x and 0b prefixes 2016-12-09 19:20:56 +01:00
Jack Halford
44cafa4811 printf reallocation for 0x and 0b prefixes 2016-12-09 19:20:56 +01:00
Jack Halford
cf73ec7bd3 added debug features and colors to printf 2016-12-07 18:27:07 +01:00
Jack Halford
a39317f43f added debug features and colors to printf 2016-12-07 18:27:07 +01:00
Jack Halford
8dced91fb3 change 2016-12-01 12:30:29 +01:00
Jack Halford
2c0669115e change 2016-12-01 12:30:29 +01:00
Jack Halford
80b5560b38 Merge branch 'master' of http://github.com/jzck/libft into HEAD 2016-11-29 20:32:35 +01:00
Jack Halford
41645ba663 Merge branch 'master' of http://github.com/jzck/libft into HEAD 2016-11-29 20:32:35 +01:00
Jack Halford
352e715f1d lst updt for minishell 2016-11-29 20:32:12 +01:00
Jack Halford
92b43a9008 lst updt for minishell 2016-11-29 20:32:12 +01:00
Jack Halford
f048ddadec Update README.md 2016-11-29 17:02:40 +01:00
Jack Halford
e7887d0be9 Update README.md 2016-11-29 17:02:40 +01:00
Jack Halford
98c624be7f Update README.md 2016-11-29 17:01:49 +01:00
Jack Halford
7ca62d6e4f Update README.md 2016-11-29 17:01:49 +01:00
Jack Halford
b75cde0ec5 Create README.md 2016-11-29 16:54:45 +01:00
Jack Halford
0d56f70ffd Create README.md 2016-11-29 16:54:45 +01:00
Jack Halford
1e93f8327a some stuff 2016-11-28 19:30:59 +01:00
Jack Halford
e7553d4a2c some stuff 2016-11-28 19:30:59 +01:00
Jack Halford
4902ceeac0 btree fixed and normed, yay 2016-11-26 23:03:17 +01:00
Jack Halford
370dcdd087 btree fixed and normed, yay 2016-11-26 23:03:17 +01:00
Jack Halford
da2f9ab319 libft is normed, maybe i've broken btree_print tho :Oooo 2016-11-25 20:45:32 +01:00
Jack Halford
e242b3daff libft is normed, maybe i've broken btree_print tho :Oooo 2016-11-25 20:45:32 +01:00
Jack Halford
c49d46129d norme 2016-11-25 18:35:19 +01:00
Jack Halford
12d3d9fbdc norme 2016-11-25 18:35:19 +01:00
Jack Halford
60146c6f4c Merge branch 'master' of https://github.com/jzck/libft into HEAD 2016-11-25 18:30:02 +01:00
Jack Halford
e21981ca60 Merge branch 'master' of https://github.com/jzck/libft into HEAD 2016-11-25 18:30:02 +01:00
Jack Halford
ed26039dd2 time and color 2016-11-25 18:29:21 +01:00
Jack Halford
1b6bf738a6 time and color 2016-11-25 18:29:21 +01:00
Jack Halford
b3ba15d1d3 btree print smaller (no compact mode). sstr add duplicates new sring 2016-11-24 23:10:26 +01:00
Jack Halford
ec0d87c840 btree print smaller (no compact mode). sstr add duplicates new sring 2016-11-24 23:10:26 +01:00
Jack Halford
cf8d5f81aa libft updates for ft_ls 2016-11-24 12:15:39 +01:00
Jack Halford
b81c38c8ed libft updates for ft_ls 2016-11-24 12:15:39 +01:00
Jack Halford
8960d54455 norm stuff and delif now dels pointer to lst also...... 2016-11-21 15:51:08 +01:00
Jack Halford
c388c9c7e1 norm stuff and delif now dels pointer to lst also...... 2016-11-21 15:51:08 +01:00
Jack Halford
aca4a52f15 btree print is cool now 2016-11-20 23:32:15 +01:00
Jack Halford
29674a9869 btree print is cool now 2016-11-20 23:32:15 +01:00
Jack Halford
c4ecdf83d3 strsqueeze is in fact useless 2016-11-18 23:15:13 +01:00
Jack Halford
5a6159c224 strsqueeze is in fact useless 2016-11-18 23:15:13 +01:00
Jack Halford
b7d9219fec strinsert and strsqueeze 2016-11-17 23:58:01 +01:00
Jack Halford
63984b13c7 strinsert and strsqueeze 2016-11-17 23:58:01 +01:00
Jack Halford
7953965b16 debug text removed 2016-11-17 17:56:17 +01:00
Jack Halford
021286a605 debug text removed 2016-11-17 17:56:17 +01:00
Jack Halford
bcafea5c46 gnl.h fix 2016-11-17 17:07:08 +01:00
Jack Halford
8c25cc902a gnl.h fix 2016-11-17 17:07:08 +01:00
Jack Halford
fe95fda94d gnl merge 2016-11-17 17:06:09 +01:00
Jack Halford
3be3c721b2 gnl merge 2016-11-17 17:06:09 +01:00
Jack Halford
c554b5d916 new GNL 2016-11-17 17:05:13 +01:00
Jack Halford
b7b5797eb0 new GNL 2016-11-17 17:05:13 +01:00
Jack Halford
ae6401ca05 some printf leaks 2016-11-16 18:33:01 +01:00
Jack Halford
8d1ece5280 some printf leaks 2016-11-16 18:33:01 +01:00
Jack Halford
d5d39e5653 merge fix 2016-11-16 10:58:30 +01:00
Jack Halford
b7ce8460ff merge fix 2016-11-16 10:58:30 +01:00
Jack Halford
12f6e233a2 mergeuhhh 2016-11-16 10:57:45 +01:00
Jack Halford
3f2c70bb04 mergeuhhh 2016-11-16 10:57:45 +01:00
Jack Halford
dd3633f4f7 printf fd 2016-11-16 10:56:06 +01:00
Jack Halford
045906145d printf fd 2016-11-16 10:56:06 +01:00
Jack Halford
dd2e4b8dde btree stuff 2016-11-15 20:21:15 +01:00
Jack Halford
23cf5a7972 btree stuff 2016-11-15 20:21:15 +01:00
Jack Halford
ef60398100 btree new nodes now mallocs and memcpy 2016-11-13 23:59:19 +01:00
Jack Halford
3c58cb010d btree new nodes now mallocs and memcpy 2016-11-13 23:59:19 +01:00
Jack Halford
e635a1be88 naming convention change for dlst, btree functions 2016-11-12 23:54:09 +01:00
Jack Halford
50f9e3d0d0 naming convention change for dlst, btree functions 2016-11-12 23:54:09 +01:00
Jack Halford
42b64ac99b realloc, havent tested it yet :OOOO 2016-11-11 20:57:21 +01:00
Jack Halford
3eef8e3f7b realloc, havent tested it yet :OOOO 2016-11-11 20:57:21 +01:00
Jack Halford
138ffb7a54 env subdir for getenv 2016-11-10 17:07:05 +01:00
Jack Halford
b3e78bb758 env subdir for getenv 2016-11-10 17:07:05 +01:00
Jack Halford
4cb79ae644 sstrfree 2016-11-10 12:28:45 +01:00
Jack Halford
ece5c61bea sstrfree 2016-11-10 12:28:45 +01:00
Jack Halford
99ebd75ca7 lst functions improvements 2016-11-08 16:28:32 +01:00
Jack Halford
d3ec77154d lst functions improvements 2016-11-08 16:28:32 +01:00
Jack Halford
ed8b34bc5d printf fixed for norm, need to migrate all this to real printf repo 2016-11-07 17:54:02 +01:00
Jack Halford
38e491df7a printf fixed for norm, need to migrate all this to real printf repo 2016-11-07 17:54:02 +01:00
Jack Halford
f54e802fa7 some changes for ft_ls, mostly printf norm 2016-11-07 13:57:45 +01:00
Jack Halford
6262db4c31 some changes for ft_ls, mostly printf norm 2016-11-07 13:57:45 +01:00
Jack Halford
3156450a32 norm for ft_printf 2016-11-06 23:41:32 +01:00
Jack Halford
64bde00bb8 norm for ft_printf 2016-11-06 23:41:32 +01:00
Jack Halford
856413ee7c strplit better 2016-11-05 17:58:34 +01:00
Jack Halford
6caf5060ec strplit better 2016-11-05 17:58:34 +01:00
Jack Halford
2f7b7a1b2b some changes ? 2016-11-05 10:59:32 +01:00
Jack Halford
c51fdf65ee some changes ? 2016-11-05 10:59:32 +01:00
Jack Halford
9e19c2856e norm for lst functions done 2016-11-04 12:43:19 +01:00
Jack Halford
0ea04b92f9 norm for lst functions done 2016-11-04 12:43:19 +01:00
Jack Halford
a5ae4d94ed some norm changes for lst functions 2016-11-04 11:17:02 +01:00
Jack Halford
e4a7afd78b some norm changes for lst functions 2016-11-04 11:17:02 +01:00
Jack Halford
01a92f8c6e some norm changes 2016-11-03 19:07:43 +01:00
Jack Halford
47d7271b7f some norm changes 2016-11-03 19:07:43 +01:00
Jack Halford
8b89d3cd49 libft rendu norm fixes and moulitest fixes are here 2016-11-03 17:57:17 +01:00
Jack Halford
fa965ec5ec libft rendu norm fixes and moulitest fixes are here 2016-11-03 17:57:17 +01:00
Jack Halford
26652ca579 new dlst for minishell project 2016-10-28 21:23:13 +02:00
Jack Halford
999f5b820a new dlst for minishell project 2016-10-28 21:23:13 +02:00
Jack Halford
a22dd81d2a Merge branch 'master' of http://github.com/jzck/libft 2016-10-14 21:13:25 +02:00
Jack Halford
a69ce5f9ff Merge branch 'master' of http://github.com/jzck/libft 2016-10-14 21:13:25 +02:00
Jack Halford
7e272dadd3 some new functions, sstr and str 2016-10-14 21:13:10 +02:00
Jack Halford
580ef2c432 some new functions, sstr and str 2016-10-14 21:13:10 +02:00
Jack Halford
729e28d6b9 prexifed printf parsing functions for double naming, must really not include the printf header... 2016-09-28 22:07:20 +02:00
Jack Halford
ae9b8de89a prexifed printf parsing functions for double naming, must really not include the printf header... 2016-09-28 22:07:20 +02:00
Jack Halford
96075b130d get nextline no longer a module 2016-09-27 05:31:55 +02:00
Jack Halford
6e45d91e6b get nextline no longer a module 2016-09-27 05:31:55 +02:00
Jack Halford
14d8f7c1b6 modules 2016-09-27 05:19:21 +02:00
Jack Halford
c64fa4b786 modules 2016-09-27 05:19:21 +02:00
Jack Halford
aa34dc1c54 split whitespaces 2016-09-27 05:14:32 +02:00
Jack Halford
ddb24369c9 split whitespaces 2016-09-27 05:14:32 +02:00
Jack Halford
c05514fa41 added getnextline 2016-09-26 18:38:28 +02:00
Jack Halford
c754d1f1bb added getnextline 2016-09-26 18:38:28 +02:00
Jack Halford
d55abac64b new printf version, path manipulation 2016-09-25 21:54:48 +02:00
Jack Halford
a2a7e34621 new printf version, path manipulation 2016-09-25 21:54:48 +02:00
Jack Halford
d71c3f8b8a xattr, ilen, uilen, etc 2016-09-25 02:29:37 +02:00
Jack Halford
bbb24b6407 xattr, ilen, uilen, etc 2016-09-25 02:29:37 +02:00
Jack Halford
3280ed74b4 lst merge, reverse 2016-09-24 17:46:39 +02:00
Jack Halford
70457d744a lst merge, reverse 2016-09-24 17:46:39 +02:00
Jack Halford
b200ff6268 pdf have their own dir 2016-09-23 00:54:50 +02:00
Jack Halford
76ce1747bc pdf have their own dir 2016-09-23 00:54:50 +02:00
Jack Halford
cf23d5c653 new shiny project architecture 2016-09-23 00:52:35 +02:00
Jack Halford
74351cc3de new shiny project architecture 2016-09-23 00:52:35 +02:00
Jack Halford
34ef810b21 fixed errors with macro FT_ prefix 2016-09-22 14:07:20 +02:00
Jack Halford
8c1cadbb75 fixed errors with macro FT_ prefix 2016-09-22 14:07:20 +02:00
Jack Halford
a6e771b406 changed back header 2016-09-21 23:05:28 +02:00
Jack Halford
9e0c10794f changed back header 2016-09-21 23:05:28 +02:00
Jack Halford
a237413ad7 moved lstnew back 2016-09-21 23:05:16 +02:00
Jack Halford
7f5d6e6aa5 moved lstnew back 2016-09-21 23:05:16 +02:00
Jack Halford
ffa67e16b9 moved lstnew to folder 2016-09-21 23:03:47 +02:00
Jack Halford
4bc1abefdb moved lstnew to folder 2016-09-21 23:03:47 +02:00
Jack Halford
4947c8f097 testng branch stuff 2016-09-21 22:59:20 +02:00
Jack Halford
4d7a7bd447 testng branch stuff 2016-09-21 22:59:20 +02:00
Jack Halford
80b64fb832 macros prefixed with FT_ 2016-09-21 21:27:23 +02:00
Jack Halford
04e8f71d4b macros prefixed with FT_ 2016-09-21 21:27:23 +02:00
Jack Halford
c04af61063 added itoa, lltoa, uitoa, ulltoa functions 2016-09-21 21:21:02 +02:00
Jack Halford
070e9fae98 added itoa, lltoa, uitoa, ulltoa functions 2016-09-21 21:21:02 +02:00
Jack Halford
38bb4e6d6f forgot ft_ prefix for strchr and strrchr 2016-09-18 19:11:41 +02:00
Jack Halford
2696f69d10 forgot ft_ prefix for strchr and strrchr 2016-09-18 19:11:41 +02:00
Jack Halford
f65b74dcb3 ft_lstpop 2016-09-16 03:10:41 +02:00
Jack Halford
66900228ee ft_lstpop 2016-09-16 03:10:41 +02:00
Jack Halford
0d10f17f9d lst sort 2016-09-14 22:41:44 +02:00
Jack Halford
9ce1c209cc lst sort 2016-09-14 22:41:44 +02:00
Jack Halford
10ffa678ac some lst changes 2016-09-12 01:51:07 +02:00
Jack Halford
e078fcbdd4 some lst changes 2016-09-12 01:51:07 +02:00
Jack Halford
e590988c7d some name changes 2016-09-10 15:25:47 +02:00
Jack Halford
ffe53b159f some name changes 2016-09-10 15:25:47 +02:00
Jack Halford
258a00cfeb new lst functions and extras 2016-09-08 01:12:42 +02:00
Jack Halford
f4c729cf36 new lst functions and extras 2016-09-08 01:12:42 +02:00
Jack Halford
a8da79f3c1 added a few lst functions for fillit 2016-09-05 12:50:52 +02:00
Jack Halford
70ca753440 added a few lst functions for fillit 2016-09-05 12:50:52 +02:00
Jack Halford
f74b6a0410 .gitignore for libft.a 2016-09-01 17:43:23 +02:00
Jack Halford
65129411e2 .gitignore for libft.a 2016-09-01 17:43:23 +02:00
Jack Halford
5f76351438 strlen 0 if NULL strng 2016-08-30 00:40:33 +02:00
Jack Halford
edb265b68e strlen 0 if NULL strng 2016-08-30 00:40:33 +02:00
Jack Halford
bb70477db2 update, and ft_debug first try 2016-08-29 00:35:42 +02:00
Jack Halford
1252d77e02 update, and ft_debug first try 2016-08-29 00:35:42 +02:00
Jack Halford
fdeff2ca9b bonus: ft_lstadd 2016-08-28 20:24:18 +02:00
Jack Halford
da29c5e823 bonus: ft_lstadd 2016-08-28 20:24:18 +02:00
Jack Halford
572a71e68b lstnew 2016-08-28 20:15:26 +02:00
Jack Halford
944fbdbef5 lstnew 2016-08-28 20:15:26 +02:00
Jack Halford
a9d02d597e bonus: ft_lstnew.c 2016-08-28 19:21:33 +02:00
Jack Halford
f45eac8b2f bonus: ft_lstnew.c 2016-08-28 19:21:33 +02:00
Jack Halford
182fa5576b ft_strlen not strlen 2016-08-28 18:25:00 +02:00
Jack Halford
0ba571afc9 ft_strlen not strlen 2016-08-28 18:25:00 +02:00
Jack Halford
f47c522343 part 2, needs testing 2016-08-28 16:33:44 +02:00
Jack Halford
481c8641ed part 2, needs testing 2016-08-28 16:33:44 +02:00
Jack Halford
7a528ecf11 part 1 done, not tested 2016-08-27 22:57:08 +02:00
Jack Halford
85c77f916c part 1 done, not tested 2016-08-27 22:57:08 +02:00
Jack Halford
3a4ce47442 first commit, pdf 2016-08-27 13:00:16 +02:00
Jack Halford
0fd4a1fe7e first commit, pdf 2016-08-27 13:00:16 +02:00
1073 changed files with 41805 additions and 0 deletions

4
ftp/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
client
server
!srcs/client
!srcs/server

0
ftp/.gitmodules vendored Normal file
View file

141
ftp/Makefile Normal file
View file

@ -0,0 +1,141 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/11/08 19:53:04 by jhalford ### ########.fr #
# #
# **************************************************************************** #
SHELL := bash
NAME = server client
CC = gcc
W_FLAGS = -Wall -Wextra -Werror
D_FLAGS =
FLAGS = $(W_FLAGS) $(D_FLAGS)
LEN_NAME = `printf "%s" $(NAME) |wc -c`
DELTA = $$(echo "$$(tput cols)-31-$(LEN_NAME)"|bc)
LIBFT_DIR = libft/
LIBFT_LIB = $(LIBFT_DIR)libft.a
LIBFT_INC = $(LIBFT_DIR)includes/
SRC_DIR = srcs/
INC_DIR = includes/
OBJ_DIR = objs/
SRC_BASE = \
client/cli_cd.c\
client/cli_debug.c\
client/cli_dele.c\
client/cli_get.c\
client/cli_help.c\
client/cli_ls.c\
client/cli_mkd.c\
client/cli_pasv.c\
client/cli_put.c\
client/cli_pwd.c\
client/cli_rmd.c\
client/cli_user.c\
client/client.c\
client/console_msg.c\
client/crlf.c\
client/dconn.c\
client/ftp_crlf.c\
server/cmd_cwd.c\
server/cmd_dele.c\
server/cmd_epsv.c\
server/cmd_list.c\
server/cmd_mkd.c\
server/cmd_pasv.c\
server/cmd_port.c\
server/cmd_pwd.c\
server/cmd_quit.c\
server/cmd_retr.c\
server/cmd_rmd.c\
server/cmd_stor.c\
server/cmd_type.c\
server/cmd_user.c\
server/console_msg.c\
server/crlf.c\
server/dconn.c\
server/server.c
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
OBJS = $(addprefix $(OBJ_DIR), $($(notdir SRC_BASE):.c=.o))
NB = $(words $(SRC_BASE))
INDEX = 0
SERVER_OBJ := $(filter-out $(OBJ_DIR)client/%,$(OBJS))
CLIENT_OBJ := $(filter-out $(OBJ_DIR)server/%,$(OBJS))
all :
@make -C $(LIBFT_DIR)
@make $(NAME)
server: $(LIBFT_LIB) $(OBJ_DIR) $(SERVER_OBJ)
@$(CC) $(FLAGS) -o $@ \
-I $(INC_DIR) \
-I $(LIBFT_INC) \
$(SERVER_OBJ) $(LIBFT_LIB)
@printf "\r\033[38;5;117m✓ MAKE $@ \033[0m\033[K\n"
client: $(LIBFT_LIB) $(OBJ_DIR) $(CLIENT_OBJ)
@$(CC) $(FLAGS) -o $@ \
-I $(INC_DIR) \
-I $(LIBFT_INC) \
$(CLIENT_OBJ) $(LIBFT_LIB) \
-lreadline
@printf "\r\033[38;5;117m✓ MAKE $@ \033[0m\033[K\n"
$(LIBFT_LIB):
@make -C $(LIBFT_DIR)
$(OBJ_DIR) :
@mkdir -p $@
@mkdir -p $(dir $(OBJS))
$(OBJ_DIR)%.o : $(SRC_DIR)%.c | $(OBJ_DIR)
@$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB)))))
@$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB)))))
@$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB) - 1))))
@$(eval COLOR=$(shell list=(160 196 202 208 215 221 226 227 190 154 118 82 46); index=$$(($(PERCENT) * $${#list[@]} / 100)); echo "$${list[$$index]}"))
@printf "\r\033[38;5;%dm⌛ [%s]: %2d%% `printf '█%.0s' {0..$(DONE)}`%*s❙%*.*s\033[0m\033[K" $(COLOR) ftp $(PERCENT) $(TO_DO) "" $(DELTA) $(DELTA) "$(shell echo "$@" | sed 's/^.*\///')"
@$(CC) $(FLAGS) $(OBJ_FLAG) -MMD -c $< -o $@\
-I $(INC_DIR)\
-I $(LIBFT_INC)
@$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
clean: cleanlib
@if [ -e $(OBJ_DIR) ]; then \
rm -rf $(OBJ_DIR); \
printf "\r\033[38;5;202m✗ clean $(NAME) \033[0m\033[K\n"; \
fi;
cleanlib:
@make -C $(LIBFT_DIR) clean
fclean: clean fcleanlib
@for file in $(NAME); do \
if [ -e $$file ]; then \
rm -f $$file ; \
printf "\r\033[38;5;196m✗ fclean $$file\033[0m\033[K\n"; \
fi; \
done;
fcleanlib: cleanlib
@make -C $(LIBFT_DIR) fclean
re: fclean all
relib: fcleanlib $(LIBFT_LIB)
.PHONY : fclean clean re relib cleanlib fcleanlib
-include $(OBJS:.o=.d)

2
ftp/README.md Normal file
View file

@ -0,0 +1,2 @@
# ftp
:open_file_folder: ftp-like server and client

1
ftp/auteur Normal file
View file

@ -0,0 +1 @@
jhalford

94
ftp/includes/ftp_client.h Normal file
View file

@ -0,0 +1,94 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ftp_client.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/01 15:50:56 by jhalford #+# #+# */
/* Updated: 2017/11/12 19:04:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FTP_CLIENT_H
# define FTP_CLIENT_H
# include "libft.h"
# include <stdio.h>
# include <termios.h>
# include <readline/readline.h>
# include <sys/mman.h>
# include <sys/wait.h>
# include <limits.h>
# include <signal.h>
# define FTP_CLIENT_USAGE "%s <addr> <port>"
# define FTP_CMD(ftp, ...) ftp_send((ftp)->cmd_sock, ##__VA_ARGS__)
typedef struct s_cmd_map t_cmd_map;
typedef struct s_ftp t_ftp;
struct s_cmd_map
{
char *key;
int (*f)();
char *help;
};
enum e_dstate
{
DATA_NONE,
DATA_PASV,
DATA_ACTV,
};
union u_conn
{
struct sockaddr_in sin;
int sock;
};
struct s_ftp
{
int cmd_sock;
enum e_dstate data_state;
union u_conn dconn;
int d_sock;
};
extern t_cmd_map g_cli_cmd[];
extern int g_debug;
t_cmd_map *get_cmd(char *cmd);
int ftp_msg(t_ftp *ftp, char **msg);
int ftp_code(t_ftp *ftp);
int ftp_send(int sock, char *msg, ...);
int ftp_sendraw(int sock, char *file, off_t size);
int ftp_recv(int sock, char **msg);
int ftp_recvraw(int sock, char **msg);
int dconn_init(t_ftp *ftp);
int dconn_open(t_ftp *ftp);
int dconn_close(t_ftp *ftp);
int console_msg(int level, char *str, ...);
int cli_debug(t_ftp *ftp, char **av);
int cli_user(t_ftp *ftp, char **av);
int cli_ls(t_ftp *ftp, char **av);
int cli_pwd(t_ftp *ftp, char **av);
int cli_sh(t_ftp *ftp, char **av);
int cli_get(t_ftp *ftp, char **av);
int cli_put(t_ftp *ftp, char **av);
int cli_cd(t_ftp *ftp, char **av);
int cli_help(t_ftp *ftp, char **av);
int cli_debug(t_ftp *ftp, char **av);
int cli_local(t_ftp *ftp, char **av);
int cli_rmd(t_ftp *ftp, char **av);
int cli_mkd(t_ftp *ftp, char **av);
int cli_dele(t_ftp *ftp, char **av);
int cli_pasv(t_ftp *ftp);
#endif

97
ftp/includes/ftp_server.h Normal file
View file

@ -0,0 +1,97 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ftp_server.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/01 15:56:59 by jhalford #+# #+# */
/* Updated: 2017/11/12 19:02:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FTP_SERVER_H
# define FTP_SERVER_H
# include "libft.h"
# include <stdio.h>
# include <sys/mman.h>
# include <limits.h>
# include <pwd.h>
# include <arpa/inet.h>
# define FTP_SERVER_USAGE "%s <port>"
# define FTP_RET(ftp, ...) ftp_send((ftp)->cmd_sock, ##__VA_ARGS__)
typedef struct s_ftp t_ftp;
typedef struct s_ftp_cmd t_ftp_cmd;
enum e_dstate
{
DATA_NONE,
DATA_PASV,
DATA_ACTV,
DATA_EPSV,
DATA_EACTV,
};
enum e_lstate
{
LOG_NONE,
LOG_YES,
};
union u_conn
{
struct sockaddr_in sin;
int sock;
};
struct s_ftp
{
int cmd_sock;
enum e_lstate log_state;
char username[100];
char path[100];
enum e_dstate data_state;
union u_conn dconn;
int d_sock;
};
struct s_ftp_cmd
{
char *name;
int (*f)();
enum e_lstate statelock;
};
extern char **g_av;
extern int g_debug;
extern char g_rootdir[PATH_MAX];
int ftp_send(int sock, char *msg, ...);
int ftp_recv(int sock, char **msg);
int ftp_recvraw(int sock, char **msg);
int dconn_open(t_ftp *ftp);
int dconn_close(t_ftp *ftp);
int console_msg(int level, char *str, ...);
int cmd_user(t_ftp *ftp, char **av);
int cmd_quit(t_ftp *ftp, char **av);
int cmd_retr(t_ftp *ftp, char **av);
int cmd_stor(t_ftp *ftp, char **av);
int cmd_cwd(t_ftp *ftp, char **av);
int cmd_pwd(t_ftp *ftp, char **av);
int cmd_pasv(t_ftp *ftp, char **av);
int cmd_epsv(t_ftp *ftp, char **av);
int cmd_port(t_ftp *ftp, char **av);
int cmd_type(t_ftp *ftp, char **av);
int cmd_list(t_ftp *ftp, char **av);
int cmd_mkd(t_ftp *ftp, char **av);
int cmd_mkd(t_ftp *ftp, char **av);
int cmd_mkd(t_ftp *ftp, char **av);
int cmd_rmd(t_ftp *ftp, char **av);
int cmd_dele(t_ftp *ftp, char **av);
#endif

1
ftp/libft/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
libft.a

256
ftp/libft/Makefile Normal file
View file

@ -0,0 +1,256 @@
#* ************************************************************************** *#
#* *#
#* ::: :::::::: *#
#* Makefile :+: :+: :+: *#
#* +:+ +:+ +:+ *#
#* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ *#
#* +#+#+#+#+#+ +#+ *#
#* Created: 2016/08/29 21:32:58 by wescande #+# #+# *#
#* Updated: 2016/12/24 02:14:21 by wescande ### ########.fr *#
#* *#
#* ************************************************************************** *#
NAME = libft.a
CC = gcc
FLAGS = -Wall -Wextra -Werror -O3
LEN_NAME = `printf "%s" $(NAME) |wc -c`
DELTA = $$(echo "$$(tput cols)-31-$(LEN_NAME)"|bc)
SRC_DIR = srcs/
INC_DIR = includes/
OBJ_DIR = objs/
SRC_BASE = \
btree/btree_apply_by_level.c\
btree/btree_apply_infix.c\
btree/btree_apply_prefix.c\
btree/btree_apply_suffix.c\
btree/btree_create_node.c\
btree/btree_del.c\
btree/btree_delone.c\
btree/btree_insert_data.c\
btree/btree_level_count.c\
btree/btree_map.c\
btree/btree_print.c\
btree/btree_search_item.c\
char/ft_isalnum.c\
char/ft_isalpha.c\
char/ft_isascii.c\
char/ft_isdigit.c\
char/ft_isprint.c\
char/ft_tolower.c\
char/ft_toupper.c\
cliopts/cliopts_get.c\
cliopts/cliopts_getmap.c\
color/ft_color_mk.c\
color/ft_color_mkif.c\
color/ft_color_reset.c\
color/ft_color_set.c\
dlst/ft_dlstadd_after.c\
dlst/ft_dlstadd_before.c\
dlst/ft_dlstdel.c\
dlst/ft_dlstdelone.c\
dlst/ft_dlstlast.c\
dlst/ft_dlstnew.c\
dlst/ft_dlstrtostr.c\
dlst/ft_dlstsize.c\
error/error.c\
error/ft_usage.c\
ft_printf/ft_conversion.c\
ft_printf/ft_fmt_simplify.c\
ft_printf/ft_fmt_validate_conv.c\
ft_printf/ft_fmt_validate_flags.c\
ft_printf/ft_fmt_validate_mod.c\
ft_printf/ft_printf.c\
ft_printf/ft_printf_color.c\
ft_printf/ft_printf_parse.c\
ft_printf/ft_transform.c\
ft_printf/ft_vprintf.c\
ft_printf/lib_fmt.c\
ft_printf/lib_fmt_error.c\
ft_printf/lib_pad.c\
ft_printf/lib_pad_sharp.c\
get_next_line/get_next_line.c\
lst/ft_id.c\
lst/ft_lst2str.c\
lst/ft_lst_at.c\
lst/ft_lst_bfree.c\
lst/ft_lst_cfree.c\
lst/ft_lst_delif.c\
lst/ft_lst_delsub.c\
lst/ft_lst_filter.c\
lst/ft_lst_filterout.c\
lst/ft_lst_find.c\
lst/ft_lst_merge.c\
lst/ft_lst_order_delsub.c\
lst/ft_lst_pop.c\
lst/ft_lst_print.c\
lst/ft_lst_print2.c\
lst/ft_lst_removeif.c\
lst/ft_lst_reverse.c\
lst/ft_lst_size.c\
lst/ft_lst_sorted_insert.c\
lst/ft_lst_sorted_merge.c\
lst/ft_lstadd.c\
lst/ft_lstdel.c\
lst/ft_lstdelone.c\
lst/ft_lsteadd.c\
lst/ft_lstiter.c\
lst/ft_lstlast.c\
lst/ft_lstmap.c\
lst/ft_lstnadd.c\
lst/ft_lstnew.c\
lst/ft_lstnew_range.c\
lst/ft_lstsort.c\
lst/lst_insert_sort.c\
lst/pop.c\
lst/push.c\
lst/top.c\
math/ft_addrcmp.c\
math/ft_ilen.c\
math/ft_ilen_base.c\
math/ft_itoa.c\
math/ft_itoa_base.c\
math/ft_lllen.c\
math/ft_lllen_base.c\
math/ft_lltoa_base.c\
math/ft_uilen.c\
math/ft_uitoa_base.c\
math/ft_ulltoa_base.c\
math/id.c\
mem/ft_bzero.c\
mem/ft_malloc.c\
mem/ft_memalloc.c\
mem/ft_memccpy.c\
mem/ft_memchr.c\
mem/ft_memcmp.c\
mem/ft_memcpy.c\
mem/ft_memdel.c\
mem/ft_memmove.c\
mem/ft_memset.c\
mem/ft_realloc.c\
net/create_client.c\
net/create_server.c\
net/forge_ip.c\
net/forge_tcp.c\
net/net_get.c\
net/net_send.c\
net/reserve_port.c\
path/ft_path_notdir.c\
printing/ft_putchar.c\
printing/ft_putendl.c\
printing/ft_putnbr.c\
printing/ft_putstr.c\
printing/hexdump.c\
sstr/ft_sstradd.c\
sstr/ft_sstrcat.c\
sstr/ft_sstrdel.c\
sstr/ft_sstrdup.c\
sstr/ft_sstrfree.c\
sstr/ft_sstrmerge.c\
sstr/ft_sstrprint.c\
sstr/ft_sstrprint_fd.c\
sstr/ft_sstrsort.c\
sstr/ft_sstrstr.c\
str/ft_atoi.c\
str/ft_convert_base.c\
str/ft_putaddr_fd.c\
str/ft_split_whitespaces.c\
str/ft_str3join.c\
str/ft_strappend.c\
str/ft_strbetween.c\
str/ft_strcat.c\
str/ft_strcatf.c\
str/ft_strchr.c\
str/ft_strchrcpy.c\
str/ft_strclr.c\
str/ft_strcmp.c\
str/ft_strcpy.c\
str/ft_strcspn.c\
str/ft_strcut.c\
str/ft_strdel.c\
str/ft_strdup.c\
str/ft_strdupchr.c\
str/ft_strduptr.c\
str/ft_strequ.c\
str/ft_strinsert.c\
str/ft_stris.c\
str/ft_striter.c\
str/ft_striteri.c\
str/ft_strjoin.c\
str/ft_strlcat.c\
str/ft_strlen.c\
str/ft_strlenchr.c\
str/ft_strmap.c\
str/ft_strmapi.c\
str/ft_strncat.c\
str/ft_strncmp.c\
str/ft_strncpy.c\
str/ft_strndup.c\
str/ft_strnequ.c\
str/ft_strnew.c\
str/ft_strnstr.c\
str/ft_strpbrk.c\
str/ft_strrchr.c\
str/ft_strreplace.c\
str/ft_strrev.c\
str/ft_strsepjoin.c\
str/ft_strsplit.c\
str/ft_strstr.c\
str/ft_strsub.c\
str/ft_strtok.c\
str/ft_strtrim.c\
sys/open_new.c\
time/epoch.c\
time/ft_mytime_free.c\
time/ft_mytime_get.c\
time/ft_time_isrecent.c
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
NB = $(words $(SRC_BASE))
INDEX = 0
SHELL := /bin/bash
all :
@$(MAKE) -j $(NAME)
$(NAME) : $(OBJ_DIR) $(OBJS)
@ar rcs $(NAME) $(OBJS)
@printf "\r\033[38;5;117m✓ MAKE $(NAME)\033[0m\033[K\n"
$(OBJ_DIR) :
@mkdir -p $(OBJ_DIR)
@mkdir -p $(dir $(OBJS))
$(OBJ_DIR)%.o : $(SRC_DIR)%.c | $(OBJ_DIR)
@$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB)))))
@$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB)))))
@$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB) - 1))))
@$(eval COLOR=$(shell list=(160 196 202 208 215 221 226 227 190 154 118 82 46); index=$$(($(PERCENT) * $${#list[@]} / 100)); echo "$${list[$$index]}"))
@printf "\r\033[38;5;%dm⌛ [%s]: %2d%% `printf '█%.0s' {0..$(DONE)}`%*s❙%*.*s\033[0m\033[K" $(COLOR) $(NAME) $(PERCENT) $(TO_DO) "" $(DELTA) $(DELTA) "$(shell echo "$@" | sed 's/^.*\///')"
@$(CC) $(FLAGS) -MMD -c $< -o $@\
-I $(INC_DIR)
@$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
clean :
@if [ -e $(OBJ_DIR) ]; \
then \
rm -rf $(OBJ_DIR); \
printf "\r\033[38;5;202m✗ clean $(NAME).\033[0m\033[K\n"; \
fi;
fclean : clean
@if [ -e $(NAME) ]; \
then \
rm -rf $(NAME); \
printf "\r\033[38;5;196m✗ fclean $(NAME).\033[0m\033[K\n"; \
fi;
re : fclean all
.PHONY : fclean clean re
-include $(OBJS:.o=.d)

22
ftp/libft/README.md Normal file
View file

@ -0,0 +1,22 @@
# libft
## libc
malloc interface functions, string manipulation
## data structures
- string anipulation (`char *`)
- string array manipulation (`char **`)
- linked list (`t_list`)
- double linked list (`t_dlist`)
- binary trees (`t_btree`)
- time struct (`t_mytime`)
## ft_printf
printf rewrite
## get_next_line
read one line from a file descriptor, supports calls between multiple file descriptors.

View file

@ -0,0 +1,55 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/16 11:13:15 by jhalford #+# #+# */
/* Updated: 2017/05/16 17:31:13 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BTREE_H
# define BTREE_H
# include "libft.h"
struct s_btree
{
void *item;
size_t content_size;
struct s_btree *left;
struct s_btree *right;
};
struct s_printdata
{
int is_left;
int offset;
int depth;
int left;
int right;
};
typedef struct s_btree t_btree;
typedef struct s_printdata t_printdata;
t_btree *btree_create_node(void const *item, size_t content_size);
t_btree *btree_map(t_btree *root, void *(*f)(void *));
void btree_insert_data(
t_btree **root,
void *item,
size_t content_size,
int (*cmpf)(void *, void *));
void *btree_search_item(t_btree *root,
void *data_ref, int (*cmpf)(void *, void *));
int btree_level_count(t_btree *root);
void btree_apply_prefix(t_btree *root, void (*applyf)(void *));
void btree_apply_infix(t_btree *root, void (*applyf)(void *));
void btree_apply_suffix(t_btree *root, void (*applyf)(void *));
void btree_print(int fd, t_btree *tree, char *(*printer)(void *));
void btree_del(t_btree **root, void (*del)(void *, size_t));
void btree_delone(t_btree **root, void (*del)(void *, size_t));
#endif

View file

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cliopts.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */
/* Updated: 2017/10/07 18:04:53 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CLIOPTS_H
# define CLIOPTS_H
# include "libft.h"
# include "error.h"
typedef struct s_cliopts t_cliopts;
typedef struct s_data_template t_data_template;
typedef long long t_flag;
struct s_cliopts
{
char c;
char *str;
t_flag flag_on;
t_flag flag_off;
int (*get)();
int arg_required:1;
};
struct s_data_template
{
t_flag flag;
char **av_data;
};
int cliopts_get(char **av, t_cliopts opt_map[], void *data);
t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg);
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg);
int cliopts_has(char **av, char c);
#endif

View file

@ -0,0 +1,56 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* color.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/25 13:36:48 by jhalford #+# #+# */
/* Updated: 2017/02/18 20:01:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef COLOR_H
# define COLOR_H
# include "libft.h"
struct s_color
{
char fg[7];
char bg[7];
};
typedef struct s_color t_color;
# define FG_DEFAULT "\e[0m"
# define ON_BOLD "\e[1m"
# define ON_UNDERLINED "\e[4m"
# define ON_INVERTED "\e[7m"
# define FG_BLACK "\e[30m"
# define FG_RED "\e[31m"
# define FG_GREEN "\e[32m"
# define FG_YELLOW "\e[33m"
# define FG_BLUE "\e[34m"
# define FG_MAGENTA "\e[35m"
# define FG_CYAN "\e[36m"
# define BG_BLACK "\e[40m"
# define BG_RED "\e[41m"
# define BG_GREEN "\e[42m"
# define BG_YELLOW "\e[43m"
# define BG_BLUE "\e[44m"
# define BG_MAGENTA "\e[45m"
# define BG_CYAN "\e[46m"
# define BG_DEFAULT "\e[49m"
# define FBG_DEFAULT FG_DEFAULT BG_DEFAULT
void ft_color_reset(void);
void ft_color_set(t_color color);
void ft_color_mk(t_color *color, char fg[7], char bg[7]);
void ft_color_mkif(t_color *color, int cond, char fg[7], char bg[7]);
#endif

35
ftp/libft/includes/dlst.h Normal file
View file

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dlst.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:21:04 by jhalford #+# #+# */
/* Updated: 2017/05/16 17:30:42 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef DLST_H
# define DLST_H
struct s_dlist
{
void *content;
size_t content_size;
struct s_dlist *next;
struct s_dlist *prev;
};
typedef struct s_dlist t_dlist;
void ft_dlstadd_after(t_dlist **alst, t_dlist *new);
void ft_dlstadd_before(t_dlist **alst, t_dlist *new);
void ft_dlstdel(t_dlist **alst, void (*del)(void *, size_t));
void ft_dlstdelone(t_dlist **alst, void (*del)(void *, size_t));
int ft_dlstsize(t_dlist *list);
t_dlist *ft_dlstnew(void const *content, size_t content_size);
t_dlist *ft_dlstlast(t_dlist *list);
char *ft_dlsttostr(t_dlist *list);
#endif

View file

@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */
/* Updated: 2017/11/01 16:29:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ERROR_H
# define ERROR_H
# include "libft.h"
# include <stdarg.h>
/*
** DEBUG with malloc
*/
# define DG_MSG "{inv}{ran}%5i{yel}%21s {bol}{blu}%-3d{eoc}"
# define DG_ARGS getpid(), getpid(), ft_path_notdir(__FILE__), __LINE__
# define DG(s, ...) ft_dprintf(STDERR,DG_MSG s "{eoc}\n",DG_ARGS,##__VA_ARGS__)
/*
** DEBUG with no malloc
*/
# define DG2 ft_putstr(__FILE__"\t");ft_putnbr(__LINE__)
# define DGW(d) DG2;d;ft_putchar('\n')
# define DGS(s) DGW(ft_putstr(": "s"="))
# define DGSN(s, n) DGW(ft_putstr(": "s"=");ft_putnbr(n))
# define DGSH(s, n) DGW(ft_putstr(": "s"=");ft_putnbr_hex(n))
# define ERR_PROTO(u, m) "{red}%s: %s{eoc}\n", u, m
# define ERR_MSG(u, m) ft_dprintf(2, ERR_PROTO(u, m))
# define ERR_SET(n, ...) error_set(n, ##__VA_ARGS__)
# define ERRMSG_MAX_SIZE 150
enum e_errors
{
E_NOERR,
E_CO_INV,
E_CO_INVL,
E_CO_MULT,
E_CO_MISS,
E_CO_MISSL,
E_SYS_NOFILE,
E_SYS_ISDIR,
E_SYS_NOPERM,
E_MAX,
};
extern char g_error_msg[E_MAX][ERRMSG_MAX_SIZE];
extern char *g_errmsg;
extern int g_errnum;
extern char **g_argv;
int error_set(int n, ...);
int ft_perror(char *utility);
void ft_usage(char *format, ...);
#endif

View file

@ -0,0 +1,80 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ftprintf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:22:54 by jhalford #+# #+# */
/* Updated: 2017/03/20 09:23:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
# include "libft.h"
# include <stdarg.h>
# define ALL_FLAGS "#0- +"
# define ALL_CONVERSIONS "sSpdDioOuUxXcCb"
typedef struct s_fmt t_fmt;
typedef struct s_conv t_conv;
typedef char *(t_converter)(t_fmt *fmt, va_list ap);
typedef void (t_pad_func)(char *str, t_fmt *fmt);
struct s_conv
{
char id;
char allowed_flags[6];
char base[20];
t_converter *converter;
t_pad_func *sharp_func;
};
struct s_fmt
{
char flags[6];
int width;
int precision;
char modifier[3];
char conversion;
int valid;
t_conv conv;
};
int ft_vdprintf(int fd, const char *format, va_list ap);
int ft_fmtcalc(char **final, char **str, va_list ap);
extern t_conv g_convs[];
t_fmt *ft_fmt_init(void);
void ft_fmt_print(t_fmt *fmt);
void ft_printf_color(char **final, char **str, va_list ap);
t_fmt *ft_printf_parse(char **format, va_list ap);
char *ft_transform(t_fmt *fmt, va_list ap);
void ft_fmt_error_conv(char conv);
void ft_fmt_error_mod_conv(char *mod, char conv);
void ft_fmt_error_flag_conv(char flag, char conv);
void ft_fmt_error_flag_flag(char flag1, char flag2);
void ft_fmt_simplify(t_fmt *fmt);
int ft_fmt_validate_conv(t_fmt *fmt);
void ft_fmt_validate_flags(t_fmt *fmt);
void ft_fmt_validate_mod(t_fmt *fmt);
char *ft_signed_conversion(t_fmt *fmt, va_list ap);
char *ft_unsigned_conversion(t_fmt *fmt, va_list ap);
char *ft_str_conversion(t_fmt *fmt, va_list ap);
char *ft_char_conversion(t_fmt *fmt, va_list ap);
void ft_pad_sharp_o(char *str, t_fmt *fmt);
void ft_pad_sharp_xb(char *str, t_fmt *fmt);
void ft_pad_left(char *str, t_fmt *fmt);
void ft_pad_right(char *str, t_fmt *fmt);
#endif

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_types.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 01:56:58 by jhalford #+# #+# */
/* Updated: 2017/03/25 02:02:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_TYPES_H
# define FT_TYPES_H
typedef struct s_stos t_stos;
typedef struct s_stof t_stof;
typedef struct s_itof t_itof;
typedef long long int t_flag;
typedef long long int t_type;
#endif

View file

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/05 12:21:36 by jhalford #+# #+# */
/* Updated: 2016/12/15 13:07:58 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef GET_NEXT_LINE_H
# define GET_NEXT_LINE_H
# define BUFF_SIZE 32
# include "libft.h"
# include <sys/types.h>
# include <sys/uio.h>
typedef struct s_save t_save;
struct s_save
{
int fd;
char *str;
};
int get_next_line(int const fd, char **line);
#endif

View file

@ -0,0 +1,95 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
/* Updated: 2017/11/20 12:41:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFT_H
# define LIBFT_H
# define FT_TRY(a,b) ((a) ? (a) : (b))
# include <string.h>
# include <errno.h>
# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
# include "ft_types.h"
# include "error.h"
# include "color.h"
# include "cliopts.h"
# include "lst.h"
# include "dlst.h"
# include "btree.h"
# include "str.h"
# include "sstr.h"
# include "math.h"
# include "mytime.h"
# include "get_next_line.h"
# include "net.h"
# include "sys.h"
struct s_stos
{
char *key;
char *val;
};
struct s_stof
{
char *key;
int (*f)();
};
struct s_itof
{
int id;
int (*f)();
};
int ft_printf(const char *format, ...);
int ft_dprintf(int fd, const char *format, ...);
int ft_vdprintf(int fd, const char *format, va_list ap);
int ft_asprintf(char **ret, const char *format, ...);
int ft_vasprintf(char **ret, const char *format, va_list ap);
void *ft_malloc(size_t size);
void *ft_memset(void *b, int c, size_t len);
void ft_bzero(void *s, size_t n);
void *ft_memcpy(void *dst, const void *src, size_t n);
void *ft_memccpy(void *dst, const void *src, int c, size_t n);
void *ft_memmove(void *dst, const void *src, size_t len);
void *ft_memchr(const void *s, int c, size_t n);
int ft_memcmp(const void *s1, const void *s2, size_t n);
void *ft_memalloc(size_t size);
void ft_memdel(void **ap);
int ft_putchar(int c);
int ft_putstr(char const *s);
int ft_putendl(char const *s);
int ft_putnbr(long n);
int ft_putnbr_hex(long n);
int ft_error_message(char *message);
int ft_putchar_fd(int c, int fd);
int ft_putstr_fd(char const *s, int fd);
int ft_putendl_fd(char const *s, int fd);
int ft_putnbr_fd(long n, int fd);
int ft_putnbr_hex_fd(long n, int fd);
void *hexdump(void *addr, unsigned int offset, unsigned int size);
void *ft_realloc(void *data, int size);
#endif

94
ftp/libft/includes/lst.h Normal file
View file

@ -0,0 +1,94 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lst.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
/* Updated: 2017/05/20 20:01:20 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LST_H
# define LST_H
# include "libft.h"
struct s_list
{
void *content;
size_t content_size;
struct s_list *next;
};
typedef struct s_list t_list;
int pop(t_list **lst);
t_list *push(t_list **stack, int elem);
t_list *ft_lstnew(void const *content, size_t content_size);
void ft_lstdel(t_list **alst, void (*del)(void *, size_t));
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
void ft_lstadd(t_list **alst, t_list *new);
int ft_lstiter(t_list *lst, int (*f)(), void *data);
t_list *ft_lstmap(t_list *lst, void *(*f)(void *));
t_list *ft_lstnew_range(int a, int b);
void ft_lsteadd(t_list **alst, t_list *new);
void ft_lstnadd(t_list **alst, t_list *new, int n);
void ft_lstsort(t_list **begin_list, int (*cmp)());
void ft_lst_print(t_list *list, void (*printer)());
int ft_lstsize(t_list *lst);
t_list *ft_lstlast(t_list *lst);
void ft_lst_sorted_merge(
t_list **begin_list1,
t_list *begin_list2,
int (*cmp)());
void ft_lst_sorted_insert(
t_list **begin_list,
t_list *insert,
int (*cmp)());
void ft_lst_delif(
t_list **alist,
void *data_ref,
int (*cmp)(),
void (*del)(void *, size_t));
void ft_lst_delsub(
t_list **alst,
t_list *sub, int (*cmp)(),
void (*del)(void *, size_t));
void ft_lst_cfree(void *ptr, size_t size);
void ft_lst_bfree(void *ptr, size_t size);
t_list *ft_lst_filter(
t_list *lst,
void const *data_ref,
t_list *(*f)(t_list *elem, void const *));
t_list *ft_lst_removeif(
t_list **alst,
void *data_ref,
int (*cmp)());
t_list *ft_lst_find(
t_list *begin_list,
void *data_ref,
int (*cmp)());
t_list *ft_lstpop(t_list **lst);
void ft_lst_merge(t_list **begin_list1, t_list *begin_list2);
void ft_lst_reverse(t_list **begin_list);
void ft_lst_filterout(
t_list **alst,
void *data_ref,
int (*cmp)(),
void (*del)(void *, size_t));
int ft_diff(void *a, void *b);
t_list *ft_id(t_list *a);
t_list *ft_lst_at(t_list *list, unsigned int nbr);
void lst_insert_sort(t_list **head,
int (cmp)());
t_list *ft_lst_pop(t_list **lst);
char *ft_lst2str(t_list *list);
#endif

38
ftp/libft/includes/math.h Normal file
View file

@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* math.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 15:41:59 by jhalford #+# #+# */
/* Updated: 2017/05/16 17:30:35 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MATH_H
# define MATH_H
# define FT_WS(x) (x == ' ' || x == '\t' || x == '\n')
# define FT_ABS(x) (((x) < 0) ? -(x) : (x))
# define FT_NEG(x) ((x) < 0)
# define FT_POS(x) ((x) > 0)
# define FT_MIN(a, b) ((a) < (b) ? (a) : (b))
# define FT_MAX(a, b) ((a) > (b) ? (a) : (b))
# define FT_DIST(a, b) FT_ABS((a) - (b))
char *ft_itoa(int n);
char *ft_itoa_base(int nbr, char *base, char *flags);
char *ft_lltoa_base(long long nbr, char *base, char *flags);
char *ft_ulltoa_base(unsigned long long nbr, char *base);
char *ft_uitoa_base(unsigned int nbr, char *base);
size_t ft_ilen(int n);
size_t ft_ilen_base(int n, int base);
size_t ft_uilen(unsigned int n);
size_t ft_lllen(long long n);
size_t ft_lllen_base(long long n, int base);
int ft_addrcmp(void *a, void *b);
void *id(void *data);
#endif

View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mytime.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/25 11:43:12 by jhalford #+# #+# */
/* Updated: 2017/02/18 13:11:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MYTIME_H
# define MYTIME_H
# include <sys/time.h>
# include "libft.h"
struct s_mytime
{
char *year;
char *month;
char *day;
char *hour;
char *min;
char *sec;
};
typedef struct s_mytime t_mytime;
int ft_time_isrecent(time_t event);
t_mytime *ft_mytime_get(time_t epoch);
void ft_mytime_free(t_mytime **time);
size_t epoch_micro(void);
#endif

47
ftp/libft/includes/net.h Normal file
View file

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* net.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/07 18:06:12 by jhalford #+# #+# */
/* Updated: 2017/11/12 12:21:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef NET_H
# define NET_H
# define ACK 2
# define NACK 3
# define NET_MAXSIZE 512
# include <sys/socket.h>
# include <netdb.h>
# include <net/if.h>
# include <netinet/in.h>
# include <netinet/ip.h>
# include <netinet/tcp.h>
# include <netinet/ip_icmp.h>
# include <arpa/inet.h>
# include "mytime.h"
int create_server(int port, int backlog, char *protoname);
int create_tcpclient(char *host, char *port);
void listener(int domain, int sock, int proto,
void (*handler)(void *buf, int bytes, struct sockaddr_in *addr));
int net_send(int sock, char *msg, int size);
int net_send_large(int sock, char *msg, int size);
int net_get(int sock, char *msg, int size);
int net_get_fd(int sock, int fd, int size);
int net_get_large(int sock, int fd);
int reserve_port(int *port);
void tcphdr_init(struct tcphdr *header);
void iphdr_init(struct ip *header);
#endif

27
ftp/libft/includes/sstr.h Normal file
View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sstr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 13:16:25 by jhalford #+# #+# */
/* Updated: 2017/03/24 17:46:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SSTR_H
# define SSTR_H
char **ft_sstradd(char **list, char *new);
void ft_sstrsort(char **list, int (*cmp)());
void ft_sstrprint(char **list, char sep);
void ft_sstrprint_fd(int fd, char **list, char sep);
char **ft_sstrdup(char **list);
char **ft_sstrmerge(char **s1, char **s2);
void ft_sstrdel(char **sstr, int index);
void ft_sstrfree(char **sstr);
char *ft_sstrcat(char **sstr, char sep);
char *ft_sstrstr(char **sstr, char *find);
#endif

81
ftp/libft/includes/str.h Normal file
View file

@ -0,0 +1,81 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 13:05:53 by jhalford #+# #+# */
/* Updated: 2017/11/10 15:58:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_H
# define STR_H
int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);
int ft_isascii(int c);
int ft_isprint(int c);
int ft_toupper(int c);
int ft_tolower(int c);
size_t ft_strlen(const char *s);
size_t ft_strlenchr(const char *s, char c);
char *ft_strdup(const char *s1);
char *ft_strdupchr(const char *str, char c);
char *ft_strduptr(char *str, int (*is)(int c));
char *ft_strcpy(char *dst, const char *src);
char *ft_strncpy(char *dst, const char *src, size_t len);
char *ft_strchrcpy(char *dst, const char *str, char c);
char *ft_strcat(char *s1, const char *s2);
char *ft_strncat(char *s1, const char *s2, size_t n);
size_t ft_strlcat(char *dst, const char *src, size_t size);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
char *ft_strstr(const char *big, const char *little);
char *ft_strnstr(const char *big, const char *little, size_t len);
int ft_strcmp(const char *s1, const char *s2);
int ft_strncmp(const char *s1, const char *s2, size_t n);
int ft_atoi(const char *str);
char *ft_strnew(size_t size);
void ft_strdel(char **as);
void ft_strclr(char *s);
void ft_striter(char *s, void (*f)(char *));
void ft_striteri(char *s, void (*f)(unsigned int, char *));
char *ft_strmap(char const *s, char (*f)(char));
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
int ft_strequ(char const *s1, char const *s2);
int ft_strnequ(char const *s1, char const *s2, size_t n);
char *ft_strsub(char const *s, unsigned int start, size_t len);
char *ft_strjoin(char const *s1, char const *s2);
char *ft_strsepjoin(char **tab, char sep);
char *ft_strtrim(char const *s);
char **ft_strsplit(char const *s, char c);
char *ft_strrev(char *str);
char **ft_strsplit(char const *s, char c);
char *ft_str3join(char const *s1, char const *s2, char const *s3);
char *ft_strcut(char *str, char *cut);
char **ft_split_whitespaces(char const *str);
char *ft_convert_base(
char *str, char *base_from, char *base_to, char *flags);
char *ft_strcatf(char *s1, const char *s2);
char *ft_strinsert(char *str, char c, int n);
int ft_strappend(char **dst, char *src);
char *ft_strbetween(char *start, char *end);
char *ft_strreplace(char **str, char *start, char *end, char *new);
char *ft_strtok(char *s, const char *delim);
char *ft_strtok_single(char *s, const char *delim);
size_t ft_strcspn(char *s, const char *delim);
char *ft_strpbrk(const char *s1, const char *s2);
char *ft_path_notdir(char *path);
int ft_stris(char *str, int (*f)());
char *ft_strndup(const char *s1, size_t n);
#endif

32
ftp/libft/includes/sys.h Normal file
View file

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sys.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 17:24:23 by jhalford #+# #+# */
/* Updated: 2017/10/07 18:10:34 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SYS_H
# define SYS_H
# define FT_XATTR_SIZE 10000
# define STDIN STDIN_FILENO
# define STDOUT STDOUT_FILENO
# define STDERR STDERR_FILENO
# define STDBUG 9
# define PIPE_READ 0
# define PIPE_WRITE 1
# include <sys/types.h>
# include <sys/xattr.h>
# include <sys/stat.h>
# include <fcntl.h>
int open_new(char *filename, int oflag);
#endif

BIN
ftp/libft/pdf/ft_printf.pdf Normal file

Binary file not shown.

Binary file not shown.

BIN
ftp/libft/pdf/libft.fr.pdf Normal file

Binary file not shown.

View file

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_apply_by_level.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/19 12:06:15 by jhalford #+# #+# */
/* Updated: 2017/03/14 17:25:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
int g_level = 0;
static void btree_apply_to_level(
t_btree *root,
int level,
int is_first_elem,
void (*applyf)(void *item, int current_level, int is_first_elem))
{
if (level == g_level)
{
(*applyf)(root->item, level, is_first_elem);
return ;
}
if (root->left)
btree_apply_to_level(root->left, level + 1, is_first_elem, applyf);
if (root->right)
btree_apply_to_level(root->right, level + 1, 0, applyf);
}
void btree_apply_by_level(
t_btree *root,
void (*applyf)(void *item, int current_level, int is_first_elem))
{
int height;
height = btree_level_count(root);
while (g_level < height)
{
btree_apply_to_level(root, 0, 1, applyf);
g_level++;
}
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2017/03/06 18:22:31 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_apply_infix(t_btree *root, void (*applyf)(void *))
{
if (root->left)
btree_apply_infix(root->left, applyf);
(*applyf)(root->item);
if (root->right)
btree_apply_infix(root->right, applyf);
return ;
}

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2016/08/18 21:06:44 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_apply_prefix(t_btree *root, void (*applyf)(void *))
{
(*applyf)(root->item);
if (root->left)
btree_apply_prefix(root->left, applyf);
if (root->right)
btree_apply_prefix(root->right, applyf);
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_apply_suffix.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/05 11:43:08 by jhalford #+# #+# */
/* Updated: 2016/12/05 11:43:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_apply_suffix(t_btree *root, void (*applyf)(void *))
{
if (root->left)
btree_apply_suffix(root->left, applyf);
if (root->right)
btree_apply_suffix(root->right, applyf);
(*applyf)(root->item);
return ;
}

View file

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
t_btree *btree_create_node(void const *item, size_t content_size)
{
t_btree *new;
if (!(new = (t_btree *)ft_malloc(sizeof(t_btree))))
return (NULL);
new->left = 0;
new->right = 0;
if (!item)
{
new->content_size = 0;
new->item = NULL;
}
else
{
new->content_size = content_size;
new->item = ft_memalloc(content_size + 1);
ft_memcpy(new->item, item, content_size);
}
return (new);
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_del.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/05 11:43:03 by jhalford #+# #+# */
/* Updated: 2017/03/21 19:43:51 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_del(t_btree **root, void (*del)(void *, size_t))
{
if (root && *root && del)
{
btree_del(&(*root)->left, del);
btree_del(&(*root)->right, del);
btree_delone(root, del);
}
}

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_delone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/05 11:45:51 by jhalford #+# #+# */
/* Updated: 2016/12/15 12:48:55 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_delone(t_btree **root, void (*del)(void *, size_t))
{
if (root && *root)
{
if (del)
(*del)((*root)->item, (*root)->content_size);
free(*root);
*root = NULL;
}
}

View file

@ -0,0 +1,43 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2016/11/14 16:12:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void btree_insert_data(
t_btree **root,
void *item,
size_t content_size,
int (*cmpf)(void *, void *))
{
t_btree *node;
if (!*root)
{
*root = btree_create_node(item, content_size);
return ;
}
node = *root;
if ((*cmpf)(item, node->item) < 0)
{
if (node->left)
btree_insert_data(&node->left, item, content_size, cmpf);
else
node->left = btree_create_node(item, content_size);
}
else
{
if (node->right)
btree_insert_data(&node->right, item, content_size, cmpf);
else
node->right = btree_create_node(item, content_size);
}
}

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2016/08/25 17:46:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
int btree_level_count(t_btree *root)
{
return (root
? 1 + FT_MAX(btree_level_count(root->left),
btree_level_count(root->right))
: 0);
}

View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */
/* Updated: 2017/03/24 15:49:42 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
t_btree *btree_map(t_btree *root, void *(*f)(void *))
{
t_btree *new;
if (!root)
return (NULL);
if (!(new = (t_btree *)ft_malloc(sizeof(*new))))
return (NULL);
new->item = (*f)(root->item);
new->left = btree_map(root->left, f);
new->right = btree_map(root->right, f);
return (new);
}

View file

@ -0,0 +1,82 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */
/* Updated: 2017/05/15 19:08:35 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
static int print_t2(t_printdata data, char s[20][255], char b[20])
{
int width;
int i;
width = 5;
i = -1;
while (++i < width)
s[2 * data.depth][data.offset + data.left + i] = b[i];
i = -1;
if (data.depth && data.is_left)
{
while (++i < width + data.right)
s[2 * data.depth - 1]
[data.offset + data.left + width / 2 + i] = '-';
s[2 * data.depth - 1][data.offset + data.left + width / 2] = '+';
s[2 * data.depth - 1]
[data.offset + data.left + data.right + 3 * width / 2] = '+';
}
else if (data.depth && !data.is_left)
{
while (++i < width + data.left)
s[2 * data.depth - 1][data.offset - width / 2 + i] = '-';
s[2 * data.depth - 1][data.offset + data.left + width / 2] = '+';
s[2 * data.depth - 1][data.offset - width / 2 - 1] = '+';
}
return (data.left + width + data.right);
}
static int print_t(t_btree *tree,
t_printdata data, char s[20][255], char *(*printer)(void *))
{
char b[20];
int width;
width = 5;
if (!tree)
return (0);
sprintf(b, "%5s", printer(tree->item));
data.left = print_t(tree->left, (t_printdata){
1, data.offset, data.depth + 1, data.left, data.right}, s, printer);
data.right = print_t(tree->right, (t_printdata){
0, data.offset + data.left + width, data.depth + 1,
data.left, data.right}, s, printer);
return (print_t2(data, s, b));
}
void btree_print(int fd, t_btree *tree, char *(*printer)(void *))
{
char s[20][255];
char empty[255];
int i;
i = -1;
while (++i < 20)
sprintf(s[i], "%80s", " ");
sprintf(empty, "%80s", " ");
print_t(tree, (t_printdata){0, 0, 0, 0, 0}, s, printer);
i = -1;
while (++i < 20)
{
if (ft_strcmp(s[i], empty) == 0)
break ;
if (i == 0 && ft_strcmp(s[1], empty) == 0)
break ;
ft_dprintf(fd, "%s\n", s[i]);
}
}

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_create_node.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
/* Updated: 2016/08/23 19:04:56 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
void *btree_search_item(t_btree *root,
void *data_ref, int (*cmpf)(void *, void *))
{
void *out;
out = NULL;
if (root)
{
out = btree_search_item(root->left, data_ref, cmpf);
if (!out && ((*cmpf)(root->item, data_ref) == 0))
out = root->item;
if (!out)
out = btree_search_item(root->right, data_ref, cmpf);
}
return (out);
}

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:18 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:31:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalnum(int c)
{
if ((c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9'))
return (c);
return (0);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:24 by jhalford #+# #+# */
/* Updated: 2017/03/07 11:59:16 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalpha(int c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return (c);
return (0);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:28 by jhalford #+# #+# */
/* Updated: 2017/11/12 18:12:56 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isascii(int c)
{
if (c >= 0 && c <= 127)
return (1);
return (0);
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:33 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:56:34 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isdigit(int c)
{
unsigned char a;
a = (unsigned char)c;
if (a >= '0' && a <= '9')
return (a);
return (0);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:38 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:32:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isprint(int c)
{
if (c >= 32 && c <= 126)
return (c);
return (0);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tolower.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:46 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:24:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_tolower(int c)
{
if (c >= 'A' && c <= 'Z')
return (c + 32);
return (c);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_toupper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:53:58 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:24:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
{
if (c >= 'a' && c <= 'z')
return (c - 32);
return (c);
}

View file

@ -0,0 +1,110 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cliopts_get.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */
/* Updated: 2017/04/02 20:45:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
/*
** void *data must be a structure starting with `int flag`
** to do polymorphism with t_data_template !
*/
#include "cliopts.h"
static char *check_required(char ***av, char *arg)
{
char *ret;
if (!av || !*av)
return (NULL);
if (!arg || !*arg || !*(arg + 1))
return (*++(*av));
ret = arg + 1;
return (ret);
}
static int cliopts_parse_short(
char ***av, t_cliopts opt_map[], void *data)
{
t_cliopts *map;
char *arg;
int i;
char *tmp;
arg = **av + 1;
i = -1;
while (arg[++i] && !(tmp = NULL))
{
if (!(map = cliopts_getmap_short(opt_map, arg[i])))
return (ERR_SET(E_CO_INV, arg[i]));
((t_data_template*)data)->flag |= map->flag_on;
((t_data_template*)data)->flag &= ~map->flag_off;
if (map->get)
{
if (map->arg_required && !(tmp = check_required(av, arg + i)))
return (ERR_SET(E_CO_MISS, *arg));
tmp = tmp ? tmp : **av;
if ((map->get)(tmp, data))
return (ERR_SET(E_CO_MISS, *arg));
if (map->arg_required)
break ;
}
}
return (++(*av) ? 0 : 0);
}
static int cliopts_parse_long(
char ***av, t_cliopts opt_map[], void *data)
{
t_cliopts *map;
char *arg;
char *tmp;
arg = **av + 2;
tmp = NULL;
if (!(map = cliopts_getmap_long(opt_map, arg)))
return (ERR_SET(E_CO_INVL, arg));
((t_data_template*)data)->flag |= map->flag_on;
((t_data_template*)data)->flag &= ~map->flag_off;
if (map->get)
{
if (map->arg_required && !(tmp = check_required(av, NULL)))
return (ERR_SET(E_CO_MISS, *arg));
if ((map->get)(tmp, data))
return (ERR_SET(E_CO_MISSL, arg));
}
++(*av);
return (0);
}
int cliopts_get(char **av, t_cliopts opt_map[], void *data)
{
if (!av)
return (1);
av++;
while (av && *av)
{
if (ft_strcmp(*av, "-") == 0 || (ft_strcmp(*av, "--") == 0 && av++))
break ;
else if ((*av)[0] == '-' && (*av)[1] == '-')
{
if (cliopts_parse_long(&av, opt_map, data))
return (1);
}
else if ((*av)[0] == '-')
{
if (cliopts_parse_short(&av, opt_map, data))
return (1);
}
else
break ;
}
((t_data_template*)data)->av_data = av;
return (0);
}

View file

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cliopts_getmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 14:59:03 by jhalford #+# #+# */
/* Updated: 2017/03/25 15:01:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "cliopts.h"
t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg)
{
int i;
i = -1;
while (opt_map[++i].c)
if (!ft_strcmp(opt_map[i].str, arg))
return (&opt_map[i]);
return (NULL);
}
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg)
{
int i;
i = -1;
while (opt_map[++i].c)
if (opt_map[i].c == arg)
return (&opt_map[i]);
return (NULL);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_color_mk.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 11:35:18 by jhalford #+# #+# */
/* Updated: 2016/12/12 11:54:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_color_mk(t_color *color, char fg[7], char bg[7])
{
ft_strcpy(color->fg, fg);
ft_strcpy(color->bg, bg);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_color_mk.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 11:35:18 by jhalford #+# #+# */
/* Updated: 2016/12/03 12:17:14 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_color_mkif(t_color *color, int cond, char fg[7], char bg[7])
{
if (cond)
ft_color_mk(color, fg, bg);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_color_reset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/25 13:48:05 by jhalford #+# #+# */
/* Updated: 2016/11/25 14:06:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_color_reset(void)
{
ft_putstr(FG_DEFAULT);
ft_putstr(BG_DEFAULT);
}

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_color_set.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/25 13:53:46 by jhalford #+# #+# */
/* Updated: 2016/12/12 11:55:03 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_color_set(t_color color)
{
char out[20];
ft_strcpy(out, color.fg);
ft_strcat(out, color.bg);
ft_putstr(out);
}

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_add_after.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:04 by jhalford #+# #+# */
/* Updated: 2016/11/07 13:27:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_dlstadd_after(t_dlist **alst, t_dlist *new)
{
if (new)
{
new->prev = (*alst);
if (*alst)
new->next = (*alst)->next;
else
new->next = NULL;
if (new->next)
new->next->prev = new;
if (new->prev)
new->prev->next = new;
*alst = new;
}
}

View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_add_before.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:09 by jhalford #+# #+# */
/* Updated: 2016/11/07 13:27:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_dlstadd_before(t_dlist **alst, t_dlist *new)
{
if (new)
{
new->next = (*alst);
if (*alst)
new->prev = (*alst)->prev;
if (new->next)
new->next->prev = new;
if (new->prev)
new->prev->next = new;
*alst = new;
}
}

View file

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlstdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:55:40 by jhalford #+# #+# */
/* Updated: 2016/12/07 17:29:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_dlstdelback(t_dlist **alst, void (*del)(void *, size_t))
{
if (alst && *alst && del)
{
ft_dlstdelback(&(*alst)->prev, del);
ft_dlstdelone(alst, del);
}
}
static void ft_dlstdelfront(t_dlist **alst, void (*del)(void *, size_t))
{
if (alst && *alst && del)
{
ft_dlstdelfront(&(*alst)->next, del);
ft_dlstdelone(alst, del);
}
}
void ft_dlstdel(t_dlist **alst, void (*del)(void *, size_t))
{
if (alst && *alst && del)
{
ft_dlstdelback(&(*alst)->prev, del);
ft_dlstdelfront(&(*alst)->next, del);
ft_dlstdelone(alst, del);
}
}

View file

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_delone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:13 by jhalford #+# #+# */
/* Updated: 2016/11/14 17:52:58 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_dlstdelone(t_dlist **alst, void (*del)(void *, size_t))
{
t_dlist *tmp;
tmp = *alst;
if (tmp)
{
if (del)
(*del)(tmp->content, tmp->content_size);
if (tmp->next)
tmp->next->prev = tmp->prev;
if (tmp->prev)
tmp->prev->next = tmp->next;
if (tmp->prev)
*alst = tmp->prev;
else
*alst = tmp->next;
free(tmp);
}
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_last.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:15 by jhalford #+# #+# */
/* Updated: 2016/11/07 13:27:15 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_dlist *ft_dlstlast(t_dlist *list)
{
while (list && list->next)
list = list->next;
return (list);
}

View file

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:20 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:43:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_dlist *ft_dlstnew(void const *content, size_t content_size)
{
t_dlist *new;
if (!content)
{
new = ft_malloc(sizeof(*new));
if (!new)
return (NULL);
new->content_size = 0;
new->content = NULL;
}
else
{
new = (t_dlist *)ft_malloc(sizeof(*new));
if (!new)
return (NULL);
new->content_size = content_size;
new->content = ft_memalloc(content_size + 1);
ft_memcpy(new->content, content, content_size);
}
new->next = NULL;
new->prev = NULL;
return (new);
}

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlstrtostr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:29 by jhalford #+# #+# */
/* Updated: 2016/11/14 16:13:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_dlsttostr(t_dlist *list)
{
char *str;
if (!list)
return (NULL);
while (list->prev)
list = list->prev;
str = (char *)ft_strnew(sizeof(char) * (ft_dlstsize(list) + 2));
while (list)
{
ft_strcat(str, (char *)list->content);
list = list->next;
}
return (str);
}

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_size.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:23 by jhalford #+# #+# */
/* Updated: 2016/11/07 13:27:23 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_dlstsize(t_dlist *list)
{
int size;
t_dlist *tmp;
size = 0;
if (list)
size++;
tmp = list;
while (tmp->next)
{
size++;
tmp = tmp->next;
}
tmp = list;
while (tmp->prev)
{
size++;
tmp = tmp->prev;
}
return (size);
}

View file

@ -0,0 +1,48 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */
/* Updated: 2017/03/25 01:53:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "error.h"
char g_error_msglist[E_MAX][ERRMSG_MAX_SIZE] =
{
"unknown error 0",
"invalid option -%c",
"invalid option --%s",
"option '%c' awaits argument(s): please don't combine",
"option '%c': missing argument",
"option '%s': missing argument",
"%s: no such file or directory",
"%s: Is a directory",
"%s: Permission denied",
};
int g_errnum = 0;
char *g_errmsg = NULL;
char **g_argv;
int error_set(int n, ...)
{
va_list ap;
g_errnum = n;
va_start(ap, n);
ft_strdel(&g_errmsg);
ft_vasprintf(&g_errmsg, g_error_msglist[n], ap);
return (g_errnum);
}
int ft_perror(char *utility)
{
utility = utility ? utility : g_argv[0];
ERR_MSG(utility, g_errmsg);
return (g_errnum);
}

View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_usage.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/02 15:08:56 by jhalford #+# #+# */
/* Updated: 2017/04/02 20:05:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_usage(char *format, ...)
{
va_list ap;
char *usage;
va_start(ap, format);
usage = NULL;
ft_vasprintf(&usage, format, ap);
ft_dprintf(2, "usage: %s\n", usage);
ft_strdel(&usage);
exit(-1);
}

View file

@ -0,0 +1,69 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_conversion.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_signed_conversion(t_fmt *fmt, va_list ap)
{
static char base10[] = "0123456789";
long long arg;
arg = va_arg(ap, int);
(void)fmt;
return (ft_lltoa_base(arg, base10, fmt->flags));
}
char *ft_unsigned_conversion(t_fmt *fmt, va_list ap)
{
unsigned int uiarg;
unsigned long long ullarg;
int i;
i = 0;
while (fmt->conversion != g_convs[i].id)
i++;
if (!*fmt->modifier
|| ft_strequ(fmt->modifier, "hh")
|| ft_strequ(fmt->modifier, "h")
|| ft_strequ(fmt->modifier, "z"))
{
uiarg = va_arg(ap, int);
return (ft_uitoa_base(uiarg, g_convs[i].base));
}
ullarg = va_arg(ap, long long);
return (ft_ulltoa_base(ullarg, g_convs[i].base));
}
char *ft_char_conversion(t_fmt *fmt, va_list ap)
{
char *ret;
(void)fmt;
ret = (char *)ft_malloc(sizeof(char) + 1);
ret[0] = (char)va_arg(ap, int);
ret[1] = '\0';
return (ret);
}
char *ft_str_conversion(t_fmt *fmt, va_list ap)
{
char *ret;
(void)fmt;
ret = va_arg(ap, char *);
if (ret == NULL)
return (ft_strdup("NULL"));
ret = ft_strdup(ret);
if (fmt->precision && fmt->precision < (int)ft_strlen(ret))
ret[fmt->precision] = '\0';
return (ret);
}

View file

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_fmt_validate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:43 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:53:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_fmt_simplify(t_fmt *fmt)
{
char hashtag;
hashtag = '#';
if (fmt->conversion == 'p')
{
fmt->conversion = 'x';
if (!ft_strchr(fmt->flags, '#'))
ft_strncat(fmt->flags, &hashtag, 1);
}
if (ft_strchr("DOUCS", fmt->conversion))
{
fmt->conversion += 32;
ft_strcpy(fmt->modifier, "l");
}
}

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_fmt_validate_conv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:55:36 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:55:37 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_fmt_validate_conv(t_fmt *fmt)
{
if (!ft_strchr(ALL_CONVERSIONS, fmt->conversion))
{
if (fmt->conversion != '%')
ft_fmt_error_conv(fmt->conversion);
return (1);
}
return (0);
}

View file

@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_fmt_validate_flags.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:19:35 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void ft_fmt_validate_flag_flag(t_fmt *fmt)
{
char *flag_ptr;
if (ft_strchr(fmt->flags, '+') && (flag_ptr = ft_strchr(fmt->flags, ' ')))
{
ft_fmt_error_flag_flag(' ', '+');
*flag_ptr = '.';
}
if (ft_strchr(fmt->flags, '-') && (flag_ptr = ft_strchr(fmt->flags, '0')))
{
ft_fmt_error_flag_flag('0', '-');
*flag_ptr = '.';
}
if (fmt->precision && (flag_ptr = ft_strchr(fmt->flags, '0')))
*flag_ptr = '.';
}
static void ft_fmt_validate_flag_conv(t_fmt *fmt)
{
char *flag_ptr;
char flag;
int i;
i = 0;
flag_ptr = fmt->flags;
while (fmt->conversion != g_convs[i].id)
i++;
while (*flag_ptr)
{
flag = *flag_ptr;
if (!ft_strchr(g_convs[i].allowed_flags, flag))
{
ft_fmt_error_flag_conv(flag, fmt->conversion);
if (flag == '#')
*flag_ptr = '.';
}
flag_ptr++;
}
}
void ft_fmt_validate_flags(t_fmt *fmt)
{
ft_fmt_validate_flag_conv(fmt);
ft_fmt_validate_flag_flag(fmt);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_fmt_validate_conv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:53:42 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:53:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_fmt_validate_mod(t_fmt *fmt)
{
if (fmt->conversion == 's' || fmt->conversion == 'c')
if (fmt->modifier[0] && ft_strcmp(fmt->modifier, "l"))
ft_fmt_error_mod_conv(fmt->modifier, fmt->conversion);
}

View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2017/11/01 17:50:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
return (ft_vdprintf(1, format, ap));
}
int ft_dprintf(int fd, const char *format, ...)
{
va_list ap;
va_start(ap, format);
return (ft_vdprintf(fd, format, ap));
}
int ft_asprintf(char **ret, const char *format, ...)
{
va_list ap;
va_start(ap, format);
return (ft_vasprintf(ret, format, ap));
}

View file

@ -0,0 +1,53 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_color.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:07:39 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:51:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
t_stos g_colors[] =
{
{"{red}", FG_RED},
{"{gre}", FG_GREEN},
{"{yel}", FG_YELLOW},
{"{blu}", FG_BLUE},
{"{mag}", FG_MAGENTA},
{"{cya}", FG_CYAN},
{"{bla}", FG_BLACK},
{"{eoc}", FG_DEFAULT},
{"{bol}", ON_BOLD},
{"{und}", ON_UNDERLINED},
{"{inv}", ON_INVERTED},
{NULL, NULL},
};
void ft_printf_color(char **final, char **str, va_list ap)
{
int i;
i = 0;
if (ft_strncmp(*str, "{ran}", 5) == 0)
{
i = va_arg(ap, int) % 6;
*final = ft_strjoin(*final, g_colors[i].val);
*str += 5;
return ;
}
while (g_colors[i].key)
{
if (ft_strncmp(*str, g_colors[i].key, 5) == 0)
{
*final = ft_strjoin(*final, g_colors[i].val);
*str += 5;
return ;
}
i++;
}
}

View file

@ -0,0 +1,123 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_parse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:24 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:55:08 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void ft_printf_parse_flags(t_fmt *fmt, char **format)
{
int i;
char *str;
i = 0;
str = *format;
while (str[i])
{
if (ft_strchr(ALL_FLAGS, (int)str[i]))
{
if (!ft_strchr(fmt->flags, (int)str[i]))
ft_strncat(fmt->flags, str + i, 1);
}
else
break ;
i++;
}
*format += i;
}
static void ft_printf_parse_width(t_fmt *fmt, char **format, va_list ap)
{
int i;
char buf[10];
char *str;
i = 0;
str = *format;
if (str[i] == '*')
{
i++;
fmt->width = va_arg(ap, int);
}
else
{
ft_strcpy(buf, "0");
while (ft_isdigit((int)(str[i])))
ft_strncat(buf, str + i++, 1);
fmt->width = ft_atoi(buf);
}
*format += i;
}
static void ft_printf_parse_precision(t_fmt *fmt, char **format, va_list ap)
{
int i;
char buf[10];
char *str;
i = 0;
str = *format;
if (str[i] == '.')
{
if (str[++i] == '*')
{
i++;
fmt->precision = va_arg(ap, int);
}
else
{
ft_strcpy(buf, "0");
while (ft_isdigit(str[i]))
ft_strncat(buf, str + i++, 1);
fmt->precision = ft_atoi(buf);
}
}
*format += i;
}
static void ft_printf_parse_modifiers(t_fmt *fmt, char **format)
{
char *str;
str = *format;
if (str[0] == 'h' && str[1] == 'h')
ft_strcpy(fmt->modifier, "hh");
else if (str[0] == 'h' && str[1] != 'h')
ft_strcpy(fmt->modifier, "h");
else if (str[0] == 'l' && str[1] == 'l')
ft_strcpy(fmt->modifier, "ll");
else if (str[0] == 'l' && str[1] != 'l')
ft_strcpy(fmt->modifier, "l");
else if (str[0] == 'j')
ft_strcpy(fmt->modifier, "j");
else if (str[0] == 'z')
ft_strcpy(fmt->modifier, "z");
else
ft_strcpy(fmt->modifier, "");
*format += ft_strlen(fmt->modifier);
}
t_fmt *ft_printf_parse(char **format, va_list ap)
{
t_fmt *fmt;
fmt = ft_fmt_init();
ft_printf_parse_flags(fmt, format);
ft_printf_parse_width(fmt, format, ap);
ft_printf_parse_precision(fmt, format, ap);
ft_printf_parse_modifiers(fmt, format);
fmt->conversion = **format;
(*format)++;
ft_fmt_validate_mod(fmt);
ft_fmt_validate_flags(fmt);
ft_fmt_simplify(fmt);
fmt->valid = ft_fmt_validate_conv(fmt) ? 0 : 1;
return (fmt);
}

View file

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_transform.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */
/* Updated: 2017/03/20 10:26:37 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_transform(t_fmt *fmt, va_list ap)
{
char *ret;
int i;
i = 0;
while (fmt->conversion != g_convs[i].id)
i++;
fmt->conv = g_convs[i];
ret = (*fmt->conv.converter)(fmt, ap);
if (fmt->width > (int)ft_strlen(ret))
ret = ft_realloc(ret, fmt->width + 5);
else
ret = ft_realloc(ret, ft_strlen(ret) + 3);
if (ft_strchr(fmt->flags, '-'))
ft_pad_right(ret, fmt);
else
ft_pad_left(ret, fmt);
return (ret);
}

View file

@ -0,0 +1,85 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vprintf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 15:52:57 by jhalford #+# #+# */
/* Updated: 2017/11/01 17:45:23 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
t_conv g_convs[] =
{
{'d', "0- +", "0123456789", &ft_signed_conversion, NULL},
{'i', "0- +", "0123456789", &ft_signed_conversion, NULL},
{'u', "0-", "0123456789", &ft_unsigned_conversion, NULL},
{'o', "#0-", "01234567", &ft_unsigned_conversion, &ft_pad_sharp_o},
{'x', "#0-", "0123456789abcdef", &ft_unsigned_conversion, &ft_pad_sharp_xb},
{'X', "#0-", "0123456789ABCDEF", &ft_unsigned_conversion, &ft_pad_sharp_xb},
{'b', "#0-", "01", &ft_unsigned_conversion, &ft_pad_sharp_xb},
{'s', "-", "", &ft_str_conversion, NULL},
{'c', "-", "", &ft_char_conversion, NULL},
};
int ft_vdprintf(int fd, const char *format, va_list ap)
{
char *ret;
char size;
ret = NULL;
size = ft_vasprintf(&ret, format, ap);
if (size != -1)
ft_putstr_fd(ret, fd);
ft_strdel(&ret);
return (size);
}
int ft_vasprintf(char **ret, const char *format, va_list ap)
{
char *str;
char *tmp;
char *final;
str = (char *)format;
final = ft_strnew(1);
while (*str)
{
tmp = final;
if (*str == '{')
ft_printf_color(&final, &str, ap);
else if (*str == '%')
{
if (ft_fmtcalc(&final, &str, ap))
return (-1);
}
else if (!(final = ft_strjoin(final, (char[]){*str++, 0})))
return (-1);
ft_strdel(&tmp);
}
*ret = final;
return (ft_strlen(final));
}
int ft_fmtcalc(char **final, char **str, va_list ap)
{
t_fmt *fmt;
char *transform;
*str += 1;
if (!(fmt = ft_printf_parse(str, ap)))
return (1);
if (!fmt->valid)
ft_strncat(*final, &fmt->conversion, 1);
else
{
transform = ft_transform(fmt, ap);
*final = ft_strjoin(*final, transform);
ft_strdel(&transform);
}
free(fmt);
return (0);
}

View file

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_fmt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
t_fmt *ft_fmt_init(void)
{
t_fmt *fmt;
fmt = (t_fmt *)ft_malloc(sizeof(t_fmt) + 1);
ft_bzero(fmt->flags, 6);
ft_bzero(fmt->modifier, 3);
fmt->conversion = '\0';
fmt->width = 0;
fmt->precision = 0;
fmt->valid = 0;
return (fmt);
}
void ft_fmt_print(t_fmt *fmt)
{
ft_putendl("\n---");
ft_putstr("valid: ");
ft_putnbr(fmt->valid);
ft_putendl("");
ft_putstr("conv.: ");
ft_putchar(fmt->conversion);
ft_putendl("");
ft_putstr("flags: ");
ft_putendl(fmt->flags);
ft_putstr("width: ");
ft_putnbr(fmt->width);
ft_putendl("");
ft_putstr("prec.: ");
ft_putnbr(fmt->precision);
ft_putendl("");
ft_putstr("modifier: ");
ft_putendl(fmt->modifier);
ft_putendl("---");
}

View file

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_fmt_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:38 by jhalford #+# #+# */
/* Updated: 2016/11/07 17:22:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_fmt_error_conv(char conv)
{
ft_putstr("Warning: invalid or unsupported conversion specifier '");
ft_putchar(conv);
ft_putendl("'");
}
void ft_fmt_error_mod_conv(char *mod, char conv)
{
ft_putstr("warning: length modifier '");
ft_putstr(mod);
ft_putstr("' results in undefined behaviour or no effect with '");
ft_putchar(conv);
ft_putendl("' conversion specifier");
}
void ft_fmt_error_flag_conv(char flag, char conv)
{
ft_putstr("warning: flag '");
ft_putchar(flag);
ft_putstr("' results in undefined behaviour with '");
ft_putchar(conv);
ft_putendl("' conversion specifier");
}
void ft_fmt_error_flag_flag(char flag1, char flag2)
{
ft_putstr("warning: flag '");
ft_putchar(flag1);
ft_putstr("' is ignored when flag '");
ft_putchar(flag2);
ft_putendl("' is present");
}

View file

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_pad.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */
/* Updated: 2017/02/18 13:14:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_pad_right(char *str, t_fmt *fmt)
{
if (ft_strchr(fmt->flags, '#'))
(fmt->conv.sharp_func)(str, fmt);
while ((int)ft_strlen(str) < fmt->width)
ft_strcat(str, " ");
}
void ft_pad_left(char *str, t_fmt *fmt)
{
char sign;
sign = 0;
if (str[0] == '-' || str[0] == '+' || str[0] == ' ')
{
sign = str[0];
str++;
}
if (ft_strchr(fmt->flags, '0'))
while ((int)ft_strlen(str) < fmt->width - (sign ? 1 : 0))
ft_strcatf(str, "0");
if (sign)
str--;
if (ft_strchr(fmt->flags, '#'))
(fmt->conv.sharp_func)(str, fmt);
while ((int)ft_strlen(str) < fmt->width)
ft_strcatf(str, " ");
}

View file

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib_pad_sharp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:54:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_pad_sharp_o(char *str, t_fmt *fmt)
{
char buf[100];
(void)fmt;
ft_bzero(buf, 100);
if (str[0] != '0')
ft_strcatf(buf, "0");
}
void ft_pad_sharp_xb(char *str, t_fmt *fmt)
{
char start[3];
start[0] = '0';
start[1] = fmt->conversion;
start[2] = 0;
if (str[0] == '0')
{
if (str[1] == '0')
str[1] = fmt->conversion;
else
{
str[0] = fmt->conversion;
ft_strcatf(str, "0");
}
}
else
ft_strcatf(str, start);
}

View file

@ -0,0 +1,89 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/15 13:12:06 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
static int ft_fdcmp(t_save *a, int *b)
{
return (a->fd - *b);
}
static void ft_gnlfree(void *a, size_t size)
{
(void)size;
ft_strdel(&((t_save*)a)->str);
free(a);
}
static t_list *ft_newfd(t_list **head, int fd)
{
t_save new;
new.fd = fd;
new.str = ft_memalloc((BUFF_SIZE > 0 ? BUFF_SIZE : 0) + 1);
ft_lstadd(head, ft_lstnew(&new, sizeof(t_save)));
return (*head);
}
static int ft_loop_read(int fd, char **line, char *save)
{
char buf[BUFF_SIZE + 1];
char *pos;
char *tmp;
int ret;
while ((ret = read(fd, buf, BUFF_SIZE)) > 0)
{
buf[ret] = 0;
tmp = *line;
if ((pos = ft_strchr(buf, '\n')))
{
ft_strcpy(save, pos + 1);
*pos = 0;
}
if (!(*line = ft_strjoin(*line, buf)))
return (-1);
ft_strdel(&tmp);
if (pos)
return (1);
}
if (ret < 0)
return (-1);
return (**line ? 1 : 0);
}
int get_next_line(int const fd, char **line)
{
static t_list *head;
t_list *tmp;
char *pos;
char *save;
int ret;
if (fd < 0 || !line)
return (-1);
if (!(tmp = ft_lst_find(head, (void *)&fd, &ft_fdcmp)))
tmp = ft_newfd(&head, fd);
save = ((t_save*)tmp->content)->str;
if (!(*line = ft_strdup(save)))
return (-1);
ft_bzero(save, BUFF_SIZE + 1);
if ((pos = ft_strchr(*line, '\n')))
{
ft_strcpy(save, pos + 1);
*pos = 0;
return (1);
}
if (!(ret = ft_loop_read(fd, line, save)))
ft_lst_delif(&head, (int *)&fd, ft_fdcmp, &ft_gnlfree);
return (ret);
}

View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_id.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:08:55 by jhalford #+# #+# */
/* Updated: 2017/03/07 22:43:40 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_id(t_list *a)
{
return (a);
}

View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst2str.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/07 17:53:18 by jhalford #+# #+# */
/* Updated: 2017/10/07 17:53:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_lst2str(t_list *list)
{
size_t size;
t_list *tmp;
char *new;
size = 0;
tmp = list;
while (tmp)
{
size += ft_strlen((char *)tmp->content) + 1;
tmp = tmp->next;
}
new = ft_memalloc(size);
while (list)
{
ft_strcat(new, (char *)list->content);
if (list->next)
ft_strcat(new, " ");
list = list->next;
}
return (new);
}

View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_at.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/14 13:18:48 by jhalford #+# #+# */
/* Updated: 2017/06/21 18:33:52 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "lst.h"
t_list *ft_lst_at(t_list *list, unsigned int nbr)
{
unsigned int i;
if (!list)
return (NULL);
i = 0;
while (i < nbr && list)
{
list = list->next;
i++;
}
return (list);
}

View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_bfree.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 16:55:04 by jhalford #+# #+# */
/* Updated: 2017/05/15 21:35:59 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_bfree(void *ptr, size_t size)
{
t_list *lst;
lst = ptr;
(void)size;
if (lst)
{
ft_strdel((char **)&lst->content);
free(lst);
}
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_cfree.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:10 by jhalford #+# #+# */
/* Updated: 2017/05/15 21:36:03 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_cfree(void *ptr, size_t size)
{
(void)size;
if (ptr)
free(ptr);
}

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_delif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
/* Updated: 2017/06/22 17:16:50 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_delif(
t_list **alst,
void *data_ref,
int (*cmp)(),
void (*del)(void *, size_t))
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, data_ref) == 0)
{
tmp = (*indirect);
(*indirect) = (*indirect)->next;
ft_lstdelone(&tmp, del);
}
else
indirect = &(*indirect)->next;
}
}

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_delsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:15 by jhalford #+# #+# */
/* Updated: 2017/01/12 14:33:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_delsub(
t_list **alst,
t_list *sub,
int (*cmp)(),
void (*del)(void *, size_t))
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, sub->content) == 0)
{
tmp = *indirect;
(*indirect) = (*indirect)->next;
sub = sub->next;
ft_lstdelone(&tmp, del);
}
indirect = &(*indirect)->next;
}
}

View file

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_filter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:17 by jhalford #+# #+# */
/* Updated: 2017/05/16 17:34:15 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lst_filter(
t_list *lst,
void const *data_ref,
t_list *(*f)(t_list *elem, void const *))
{
t_list *out;
t_list *elem;
out = NULL;
while (lst)
{
if (f)
elem = (*f)(lst, data_ref);
else
elem = lst;
elem = ft_lstnew(elem->content, elem->content_size);
ft_lsteadd(&out, elem);
lst = lst->next;
}
return (out);
}

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_filterout.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/26 16:56:02 by jhalford #+# #+# */
/* Updated: 2017/03/26 19:10:03 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_filterout(
t_list **alst,
void *data_ref,
int (*cmp)(),
void (*del)(void *, size_t))
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, data_ref) == 0)
{
tmp = *indirect;
(*indirect) = (*indirect)->next;
ft_lstdelone(&tmp, del);
}
else
indirect = &(*indirect)->next;
}
}

View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_find.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:20 by jhalford #+# #+# */
/* Updated: 2017/06/21 18:20:30 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lst_find(t_list *begin_list, void *data_ref, int (*cmp)())
{
t_list *list_ptr;
list_ptr = begin_list;
while (list_ptr)
{
if ((cmp)(list_ptr->content, data_ref) == 0)
return (list_ptr);
list_ptr = list_ptr->next;
}
return (NULL);
}

View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_merge.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/14 13:50:32 by jhalford #+# #+# */
/* Updated: 2016/11/04 11:09:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_merge(t_list **begin_list1, t_list *begin_list2)
{
t_list *list_ptr;
if (*begin_list1)
{
list_ptr = *begin_list1;
while (list_ptr->next)
list_ptr = list_ptr->next;
list_ptr->next = begin_list2;
}
else
*begin_list1 = begin_list2;
}

View file

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_order_delsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:25 by jhalford #+# #+# */
/* Updated: 2016/11/04 12:01:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_order_delsub(
t_list **alst,
t_list *sub,
int (*cmp)(),
void (*del)(void *, size_t))
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, sub->content) > 0)
{
sub = sub->next;
continue ;
}
if ((*cmp)((*indirect)->content, sub->content) == 0)
{
tmp = *indirect;
(*indirect) = (*indirect)->next;
ft_lstdelone(&tmp, del);
sub = sub->next;
}
indirect = &(*indirect)->next;
}
}

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_pop.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/07 17:53:30 by jhalford #+# #+# */
/* Updated: 2017/10/07 17:53:31 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lst_pop(t_list **lst)
{
t_list *top;
top = *lst;
if (lst && *lst)
*lst = (*lst)->next;
return (top);
}

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:27 by jhalford #+# #+# */
/* Updated: 2017/05/16 21:00:09 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_print(t_list *list, void (*printer)())
{
while (list)
{
ft_putstr("[");
(*printer)(list->content);
ft_putstr("]->");
list = list->next;
}
ft_putendl("X\n");
}

View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_print2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:29 by jhalford #+# #+# */
/* Updated: 2017/05/16 21:00:19 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_print2(t_list *list, void (*printer)())
{
t_list *list2;
while (list)
{
ft_putendl("---");
list2 = *(t_list**)list->content;
while (list2)
{
ft_putstr("[");
(*printer)(*(int *)list2->content);
ft_putstr("]->");
list2 = list2->next;
}
ft_putendl("X");
ft_putendl("---");
ft_putendl(" |");
ft_putendl(" V");
list = list->next;
}
ft_putendl(" X\n");
}

View file

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_removeif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */
/* Updated: 2017/06/22 22:04:23 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)())
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, data_ref) == 0)
{
tmp = (*indirect);
(*indirect) = (*indirect)->next;
tmp->next = NULL;
return (tmp);
}
indirect = &(*indirect)->next;
}
return (NULL);
}

View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_reverse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@43.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/14 13:20:13 by jhalford #+# #+# */
/* Updated: 2017/03/08 00:31:33 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_reverse(t_list **begin_list)
{
t_list *new_start;
t_list *tmp;
new_start = NULL;
while (*begin_list)
{
tmp = (*begin_list)->next;
(*begin_list)->next = new_start;
new_start = *begin_list;
*begin_list = tmp;
}
*begin_list = new_start;
}

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_size.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:35 by jhalford #+# #+# */
/* Updated: 2016/11/04 11:09:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int i;
i = 0;
if (lst)
{
i = 1;
while (lst->next)
{
lst = lst->next;
i++;
}
}
return (i);
}

View file

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_sorted_insert.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:39 by jhalford #+# #+# */
/* Updated: 2016/11/04 11:09:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_sorted_insert(t_list **begin_list, t_list *insert, int (*cmp)())
{
t_list *link;
link = *begin_list;
if (!link || (*cmp)(insert->content, link->content) < 0)
{
*begin_list = insert;
insert->next = link ? link : NULL;
return ;
}
while (link->next)
{
if ((*cmp)(insert->content, link->content) > 0
&& (*cmp)(insert->content, link->next->content) <= 0)
{
insert->next = link->next;
link->next = insert;
return ;
}
link = link->next;
}
link->next = insert;
insert->next = NULL;
}

View file

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_sorted_merge.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:40 by jhalford #+# #+# */
/* Updated: 2016/11/04 11:09:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_sorted_merge(
t_list **begin_list1,
t_list *begin_list2,
int (*cmp)())
{
t_list *tail;
t_list *head1;
t_list *head2;
int comp;
if (!*begin_list1 || !begin_list2)
{
*begin_list1 = begin_list2 ? begin_list2 : *begin_list1;
return ;
}
comp = (*cmp)(begin_list2->content, (*begin_list1)->content);
head1 = (comp < 0) ? *begin_list1 : (*begin_list1)->next;
head2 = (comp < 0) ? begin_list2->next : begin_list2;
*begin_list1 = (comp < 0) ? begin_list2 : *begin_list1;
tail = *begin_list1;
while (head1 && head2)
{
comp = (*cmp)(head2->content, head1->content);
tail->next = (comp < 0 ? head2 : head1);
head1 = comp < 0 ? head1 : head1->next;
head2 = comp < 0 ? head2->next : head2;
tail = tail->next;
}
tail->next = head2 ? head2 : head1;
}

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */
/* Updated: 2017/05/15 19:31:42 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd(t_list **alst, t_list *new)
{
if (new)
{
new->next = *alst;
*alst = new;
}
}

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