diff options
| author | Cabergs Charles <cacharle@e-r6-p7.s19.be> | 2019-07-17 19:30:52 +0200 |
|---|---|---|
| committer | Cabergs Charles <cacharle@e-r6-p7.s19.be> | 2019-07-17 19:30:52 +0200 |
| commit | cffe7f69cf28ab0889bee54a18c3f39101b33f16 (patch) | |
| tree | b5929722cf123e7c1701f4bc164a905f79510bf5 | |
| parent | cb9179cf990257927b7d259ee3e0fcbd3d892049 (diff) | |
| download | piscine-cffe7f69cf28ab0889bee54a18c3f39101b33f16.tar.gz piscine-cffe7f69cf28ab0889bee54a18c3f39101b33f16.tar.bz2 piscine-cffe7f69cf28ab0889bee54a18c3f39101b33f16.zip | |
c10 tail stuff, c11 start, c12/c13 files
53 files changed, 237037 insertions, 74 deletions
@@ -1,4 +1,5 @@ #include <stdio.h> +#include <limits.h> #include <stdlib.h> #include <string.h> #include "ex00/ft_strdup.c" @@ -30,7 +31,7 @@ int main() printf("---------------\n"); int *rult; - int len = ft_ultimate_range(&rult, -4, 15); + int len = ft_ultimate_range(&rult, 0, INT_MAX); printf("len(%d): ", len); for (int i = 0; i < len; i++) printf("%d ", rult[i]); diff --git a/c10/ex00/Makefile b/c10/ex00/Makefile index 6ee330b..341cdf3 100644 --- a/c10/ex00/Makefile +++ b/c10/ex00/Makefile @@ -1,17 +1,37 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2019/07/17 08:40:22 by cacharle #+# #+# # +# Updated: 2019/07/17 08:45:51 by cacharle ### ########.fr # +# # +# **************************************************************************** # + OUT = ft_display_file CC = gcc CCFLAGS = -Wall -Wextra -Werror .PHONY: all all: $(OUT) + $(CC) $(CCFLAGS) -o $(OUT) main.o + + +$(OUT): main.o + $(CC) $(CCFLAGS) -o $(OUT) main.o -$(OUT): main.c - $(CC) $(CCFLAGS) -o $(OUT) main.c +main.o: main.c + $(CC) $(CCFLAGS) -c main.c -o main.o .PHONY: clean clean: + rm -f main.o .PHONY: clean fclean: clean rm -f $(OUT) +.PHONY: re +re: fclean all diff --git a/c10/ex00/main.c b/c10/ex00/main.c index bcf9e68..afde099 100644 --- a/c10/ex00/main.c +++ b/c10/ex00/main.c @@ -6,26 +6,26 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/11 18:06:43 by cacharle #+# #+# */ -/* Updated: 2019/07/15 13:45:33 by cacharle ### ########.fr */ +/* Updated: 2019/07/17 08:44:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> #include <fcntl.h> -#define BUFFER_SIZE 1 #include <stdio.h> +#define BUFFER_SIZE 1 -void read_write_file(int fildes) +void read_write_file(int fildes) { - int i; - int writing; + int i; + int writing; char buf[BUFFER_SIZE]; writing = 1; while (writing) { if (read(fildes, buf, BUFFER_SIZE) == 0) - break; + break ; i = 0; while (buf[i]) { @@ -37,10 +37,9 @@ void read_write_file(int fildes) } } -int main(int argc, char **argv) +int main(int argc, char **argv) { int fildes; - int reading; if (argc == 1) { diff --git a/c10/ex01/Makefile b/c10/ex01/Makefile index 362d434..862705c 100644 --- a/c10/ex01/Makefile +++ b/c10/ex01/Makefile @@ -1 +1,35 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2019/07/16 14:50:14 by cacharle #+# #+# # +# Updated: 2019/07/16 14:50:19 by cacharle ### ########.fr # +# # +# **************************************************************************** # + OUT = ft_cat +CC = gcc +CCFLAGS = -Wall -Wextra -Werror +SRC = main.c io.c helper.c +OBJ = $(SRC:.c=.o) + +.PHONY: all +all: $(OUT) + +$(OUT): $(OBJ) + $(CC) $(CCFLAGS) -o $@ $^ + +%.o: %.c include.h + $(CC) $(CCFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + rm -f $(OBJ) + +.PHONY: clean +fclean: clean + rm -f $(OUT) + diff --git a/c10/ex01/helper.c b/c10/ex01/helper.c index 8a1c13e..a6a9acd 100644 --- a/c10/ex01/helper.c +++ b/c10/ex01/helper.c @@ -6,13 +6,14 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/16 10:14:16 by cacharle #+# #+# */ -/* Updated: 2019/07/16 10:26:44 by cacharle ### ########.fr */ +/* Updated: 2019/07/16 13:42:08 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> #include <errno.h> #include <string.h> +#include <libgen.h> #include "include.h" void ft_putstr_err(char *str) @@ -25,7 +26,7 @@ void handle_error(char *program_name, char *arg) { char *error_msg; - ft_putstr_err(program_name); + ft_putstr_err(basename(program_name)); ft_putstr_err(": "); ft_putstr_err(arg); ft_putstr_err(": "); diff --git a/c10/ex01/include.h b/c10/ex01/include.h index fed49e8..3a48093 100644 --- a/c10/ex01/include.h +++ b/c10/ex01/include.h @@ -5,8 +5,8 @@ /* +:+ +:+ +:+ */ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2019/07/15 16:49:28 by cacharle #+# #+# */ -/* Updated: 2019/07/16 10:23:45 by cacharle ### ########.fr */ +/* Created: 2019/07/16 14:07:19 by cacharle #+# #+# */ +/* Updated: 2019/07/17 08:47:08 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,7 @@ int read_in_buf(int fildes, char buf[BUF_SIZE]); int write_buf(char buf[BUF_SIZE], int size); int read_write_fildes(int fildes); +void read_stdin(void); int print_file(char *filename); /* diff --git a/c10/ex01/io.c b/c10/ex01/io.c index a6c0b01..b753902 100644 --- a/c10/ex01/io.c +++ b/c10/ex01/io.c @@ -6,7 +6,7 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/15 19:05:32 by cacharle #+# #+# */ -/* Updated: 2019/07/16 10:52:03 by cacharle ### ########.fr */ +/* Updated: 2019/07/17 11:19:51 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,12 +14,12 @@ #include <fcntl.h> #include "include.h" -int read_in_buf(int fildes, char buf[BUF_SIZE]) +int read_in_buf(int fildes, char buf[BUF_SIZE]) { - return (read(fildes, buf, BUF_SIZE - 1)); + return (read(fildes, buf, BUF_SIZE)); } -int write_buf(char buf[BUF_SIZE], int size) +int write_buf(char buf[BUF_SIZE], int size) { return (write(1, buf, size)); } @@ -29,10 +29,15 @@ int read_write_fildes(int fildes) int size; char buf[BUF_SIZE]; - size = BUF_SIZE - 1; - while (size == BUF_SIZE - 1 || fildes == STDOUT_FILENO ) + size = BUF_SIZE; + if (fildes == STDIN_FILENO) { - if ((size = read_in_buf(fildes, buf)) == -1) + read_stdin(); + return (0); + } + while (size != 0) + { + if ((size = read_in_buf(fildes, buf)) < 0) return (-1); if (write_buf(buf, size) == -1) return (-1); @@ -40,7 +45,15 @@ int read_write_fildes(int fildes) return (0); } -int print_file(char *filename) +void read_stdin(void) +{ + char buf[32]; + + while (read(STDIN_FILENO, buf, 1)) + write(STDOUT_FILENO, buf, 1); +} + +int print_file(char *filename) { int fildes; diff --git a/c10/ex01/main.c b/c10/ex01/main.c index b5fb416..3ff790b 100644 --- a/c10/ex01/main.c +++ b/c10/ex01/main.c @@ -6,7 +6,7 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/15 16:45:20 by cacharle #+# #+# */ -/* Updated: 2019/07/16 10:20:39 by cacharle ### ########.fr */ +/* Updated: 2019/07/16 14:10:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,10 +16,14 @@ int main(int argc, char **argv) { int i; - int fildes; int status; status = 0; + if (argc == 1) + { + read_stdin(); + return (0); + } i = 1; while (i < argc) { diff --git a/c10/ex02/Makefile b/c10/ex02/Makefile new file mode 100644 index 0000000..d36a1f8 --- /dev/null +++ b/c10/ex02/Makefile @@ -0,0 +1,35 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2019/07/16 14:50:02 by cacharle #+# #+# # +# Updated: 2019/07/17 13:05:52 by cacharle ### ########.fr # +# # +# **************************************************************************** # + +OUT = ft_tail +CC = gcc +CCFLAGS = -Wall -Wextra #-Werror +SRC = main.c file.c handle_error.c helper.c +OBJ = $(SRC:.c=.o) + +.PHONY: all +all: $(OUT) + +$(OUT): $(OBJ) + $(CC) $(CCFLAGS) -o $@ $^ + +%.o: %.c include.h + $(CC) $(CCFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + rm -f $(OBJ) + +.PHONY: clean +fclean: clean + rm -f $(OUT) + diff --git a/c10/ex02/bonjour.txt b/c10/ex02/bonjour.txt new file mode 100644 index 0000000..951bc56 --- /dev/null +++ b/c10/ex02/bonjour.txt @@ -0,0 +1 @@ +bonjourjeusuislefilebonjour.txetjesuiscontentdeletre diff --git a/c10/ex02/dict b/c10/ex02/dict new file mode 100644 index 0000000..4be557e --- /dev/null +++ b/c10/ex02/dict @@ -0,0 +1,235886 @@ +A +a +aa +aal +aalii +aam +Aani +aardvark +aardwolf +Aaron +Aaronic +Aaronical +Aaronite +Aaronitic +Aaru +Ab +aba +Ababdeh +Ababua +abac +abaca +abacate +abacay +abacinate +abacination +abaciscus +abacist +aback +abactinal +abactinally +abaction +abactor +abaculus +abacus +Abadite +abaff +abaft +abaisance +abaiser +abaissed +abalienate +abalienation +abalone +Abama +abampere +abandon +abandonable +abandoned +abandonedly +abandonee +abandoner +abandonment +Abanic +Abantes +abaptiston +Abarambo +Abaris +abarthrosis +abarticular +abarticulation +abas +abase +abased +abasedly +abasedness +abasement +abaser +Abasgi +abash +abashed +abashedly +abashedness +abashless +abashlessly +abashment +abasia +abasic +abask +Abassin +abastardize +abatable +abate +abatement +abater +abatis +abatised +abaton +abator +abattoir +Abatua +abature +abave +abaxial +abaxile +abaze +abb +Abba +abbacomes +abbacy +Abbadide +abbas +abbasi +abbassi +Abbasside +abbatial +abbatical +abbess +abbey +abbeystede +Abbie +abbot +abbotcy +abbotnullius +abbotship +abbreviate +abbreviately +abbreviation +abbreviator +abbreviatory +abbreviature +Abby +abcoulomb +abdal +abdat +Abderian +Abderite +abdest +abdicable +abdicant +abdicate +abdication +abdicative +abdicator +Abdiel +abditive +abditory +abdomen +abdominal +Abdominales +abdominalian +abdominally +abdominoanterior +abdominocardiac +abdominocentesis +abdominocystic +abdominogenital +abdominohysterectomy +abdominohysterotomy +abdominoposterior +abdominoscope +abdominoscopy +abdominothoracic +abdominous +abdominovaginal +abdominovesical +abduce +abducens +abducent +abduct +abduction +abductor +Abe +abeam +abear +abearance +abecedarian +abecedarium +abecedary +abed +abeigh +Abel +abele +Abelia +Abelian +Abelicea +Abelite +abelite +Abelmoschus +abelmosk +Abelonian +abeltree +Abencerrages +abenteric +abepithymia +Aberdeen +aberdevine +Aberdonian +Aberia +aberrance +aberrancy +aberrant +aberrate +aberration +aberrational +aberrator +aberrometer +aberroscope +aberuncator +abet +abetment +abettal +abettor +abevacuation +abey +abeyance +abeyancy +abeyant +abfarad +abhenry +abhiseka +abhominable +abhor +abhorrence +abhorrency +abhorrent +abhorrently +abhorrer +abhorrible +abhorring +Abhorson +abidal +abidance +abide +abider +abidi +abiding +abidingly +abidingness +Abie +Abies +abietate +abietene +abietic +abietin +Abietineae +abietineous +abietinic +Abiezer +Abigail +abigail +abigailship +abigeat +abigeus +abilao +ability +abilla +abilo +abintestate +abiogenesis +abiogenesist +abiogenetic +abiogenetical +abiogenetically +abiogenist +abiogenous +abiogeny +abiological +abiologically +abiology +abiosis +abiotic +abiotrophic +abiotrophy +Abipon +abir +abirritant +abirritate +abirritation +abirritative +abiston +Abitibi +abiuret +abject +abjectedness +abjection +abjective +abjectly +abjectness +abjoint +abjudge +abjudicate +abjudication +abjunction +abjunctive +abjuration +abjuratory +abjure +abjurement +abjurer +abkar +abkari +Abkhas +Abkhasian +ablach +ablactate +ablactation +ablare +ablastemic +ablastous +ablate +ablation +ablatitious +ablatival +ablative +ablator +ablaut +ablaze +able +ableeze +ablegate +ableness +ablepharia +ablepharon +ablepharous +Ablepharus +ablepsia +ableptical +ableptically +abler +ablest +ablewhackets +ablins +abloom +ablow +ablude +abluent +ablush +ablution +ablutionary +abluvion +ably +abmho +Abnaki +abnegate +abnegation +abnegative +abnegator +Abner +abnerval +abnet +abneural +abnormal +abnormalism +abnormalist +abnormality +abnormalize +abnormally +abnormalness +abnormity +abnormous +abnumerable +Abo +aboard +Abobra +abode +abodement +abody +abohm +aboil +abolish +abolisher +abolishment +abolition +abolitionary +abolitionism +abolitionist +abolitionize +abolla +aboma +abomasum +abomasus +abominable +abominableness +abominably +abominate +abomination +abominator +abomine +Abongo +aboon +aborad +aboral +aborally +abord +aboriginal +aboriginality +aboriginally +aboriginary +aborigine +abort +aborted +aborticide +abortient +abortifacient +abortin +abortion +abortional +abortionist +abortive +abortively +abortiveness +abortus +abouchement +abound +abounder +abounding +aboundingly +about +abouts +above +aboveboard +abovedeck +aboveground +aboveproof +abovestairs +abox +abracadabra +abrachia +abradant +abrade +abrader +Abraham +Abrahamic +Abrahamidae +Abrahamite +Abrahamitic +abraid +Abram +Abramis +abranchial +abranchialism +abranchian +Abranchiata +abranchiate +abranchious +abrasax +abrase +abrash +abrasiometer +abrasion +abrasive +abrastol +abraum +abraxas +abreact +abreaction +abreast +abrenounce +abret +abrico +abridge +abridgeable +abridged +abridgedly +abridger +abridgment +abrim +abrin +abristle +abroach +abroad +Abrocoma +abrocome +abrogable +abrogate +abrogation +abrogative +abrogator +Abroma +Abronia +abrook +abrotanum +abrotine +abrupt +abruptedly +abruption +abruptly +abruptness +Abrus +Absalom +absampere +Absaroka +absarokite +abscess +abscessed +abscession +abscessroot +abscind +abscise +abscision +absciss +abscissa +abscissae +abscisse +abscission +absconce +abscond +absconded +abscondedly +abscondence +absconder +absconsa +abscoulomb +absence +absent +absentation +absentee +absenteeism +absenteeship +absenter +absently +absentment +absentmindedly +absentness +absfarad +abshenry +Absi +absinthe +absinthial +absinthian +absinthiate +absinthic +absinthin +absinthine +absinthism +absinthismic +absinthium +absinthol +absit +absmho +absohm +absolute +absolutely +absoluteness +absolution +absolutism +absolutist +absolutistic +absolutistically +absolutive +absolutization +absolutize +absolutory +absolvable +absolvatory |
