From 76a99d97ed7e6da880ef8c4ccbf5ca8785abd3ac Mon Sep 17 00:00:00 2001 From: esterfreyja Date: Wed, 23 Oct 2024 09:10:30 +0200 Subject: [PATCH] =?UTF-8?q?rectifs=20=C3=A0=20la=20con?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TP1/ex1 | Bin 16776 -> 18056 bytes TP1/ex1.c | 47 ++++++++++++-- TP1/ex2 | Bin 16784 -> 16056 bytes TP1/ex2.c | 1 - TP2/test/file0 | 0 TP2/test/file1 | 0 TP2/test/file2 | 0 TP2/test/file3 | 0 TP2/test/file4 | 0 TP2/test/file5 | 0 TP2/test/file6 | 0 TP2/test/file7 | 0 TP2/test/file8 | 0 TP2/test/file9 | 0 TP2/tp2 | Bin 0 -> 16624 bytes TP2/tp2.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++ tubes/tp3 | Bin 0 -> 16392 bytes tubes/tp3.c | 65 +++++++++++++++++++ 18 files changed, 276 insertions(+), 7 deletions(-) create mode 100644 TP2/test/file0 create mode 100644 TP2/test/file1 create mode 100644 TP2/test/file2 create mode 100644 TP2/test/file3 create mode 100644 TP2/test/file4 create mode 100644 TP2/test/file5 create mode 100644 TP2/test/file6 create mode 100644 TP2/test/file7 create mode 100644 TP2/test/file8 create mode 100644 TP2/test/file9 create mode 100755 TP2/tp2 create mode 100644 TP2/tp2.c create mode 100755 tubes/tp3 create mode 100644 tubes/tp3.c diff --git a/TP1/ex1 b/TP1/ex1 index 3c345260b753e27250f69ba4d5f14854cd477d63..adcbe53264ccdac8e76a9fee7e1caeeea138bc58 100755 GIT binary patch literal 18056 zcmeHPeQX@Zb)Vh4C6D6AQC}7%x#3E-V#zU&q%5hnCE7<(CoNscQY@*p6T9o<-SX~I za*w&&vq-^mq*6|NP~}Ex(k7_@D?x%736dCS8w6@olk$gT!!4-%5euzautg11wUR1M z+Q^CG>+kK(J1*B`isp|10d9z!H}AdQn|b?Yc6VlXho4C7-l-~z;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On8l|70cv)XZdLFk~Z$cp?9u}(%L#lY(*(dcd+R->HE8+AxIM6RY2U!0lD1^i^ zcU))v51~*l{#Wmy|AlO4sc8JD0j1egt{wbFBLt(kf1G+tLYKJvM7X6tN&ANckMFF% z0R_yppDH0C<@Bwf*Wf8qO?hM7+B?`k4*Ce#bDr6LE82&v1owN^Zzp?y`%i#gVq*QVI72l*h=Q}$wAA`I{86yFrVzRt#q-kZxA3J$-*IfmZ?1ugJBvXv$JU#Z0p{p zoe3+kYrAC$Yx}2mHSKI~fkxn2X(dcc)tcM)3ahPScXLyRwY#;oGqKOw*VNpRuxPJ~ z!JAvujuzjB7`GO-zQ{c@u0opI>7kqt0$RF_rk85_T6BW z&Sb4(!A=Xv1Dw*mmV6E+9UGf~=aSW*!5unXg#xuHH|XHboY^s0`*yZ)4lrdx=!L;P zC)owu$t&K&rA!uXW53YlA@_xP~6F@nrH2NA(P9_5-g~Lt4bn(O8vc#&}EpqV-G+XI|S6_WF~dHhq^#d8n7%W zgz5_l!DVPT*_TOy*BrD3CtW&FjX~;!4qdVjdYaH_wj(bc^msM$O7*1U<;_-`h?NIRI`T2Q*Ch{5^68Gbu0{uT=j?M9pQ~cwE=j)$Gcz^s!(Bqnd@sos~ zB>Zv0VT>U-7|-+n4Cv65@w|@dr$Bk#0w$8M4KIBb1Y9#Pp4SQI2+!*=j-TzAe*y5g z24R`kA(sdrC1?KlIfi3UKvTxM>mGV=FrNMUum78bZ>9!$9o0y9lk|wkwU!_MJ #include +int my_strlen(char *str) +{ + int len; + + len = 0; + while (str[len] != '\0') + len++; + return (len); +} + +void my_putnbr(int nb) +{ + char c; + + if (nb < 0) + { + if (nb == -2147483648) + { + write(1, "-", 1); + write(1, "2", 1); + my_putnbr(147483648); + return ; + } + nb = nb * -1; + write(1, "-", 1); + } + if (nb >= 0 && nb < 10) + { + c = nb + '0'; + write(1, &c, 1); + } + if (nb >= 10) + { + my_putnbr(nb / 10); + my_putnbr(nb % 10); + } +} + int main(int argc, char *argv[]) { int i; int j; - char c; char *path = getenv("PATH"); + i = 0; j = 0; if(!path) @@ -16,13 +54,10 @@ int main(int argc, char *argv[]) } while (i < argc) { - c = i + '0'; write(1, "arg[", 4); - write(1, &c, 1); + my_putnbr(i); write(1, "]=", 2); - j = 0; - while (argv[i][j]) - j++; + j = my_strlen(argv[i]); write(1, argv[i], j); write(1, "\n", 1); i++; diff --git a/TP1/ex2 b/TP1/ex2 index 62eb1bf96f57b26dc2de0656a5f88c5922055576..4050dfae60526cf14fb973ab693fa6f67211209b 100755 GIT binary patch literal 16056 zcmeHOZEPGz8J@c|iJK<2lP2IK5N|_DlNMj>d{}8p$T|MVx;P(A97s{y?b^4tPr5Je z)`=Ze;1G%$Re?}J`v(d450&^36+#uHNOhVJT2xgIs)P|#ScpiDL_;D93a!ZTzBBK0 zS#QoDf#@H0EblY#$1^kg&g|ao?#vfEd%EJWm_nMTKBZVH)EiAw4A)yFLy%P4)Dk*2 zsx@i>$+u~pu_q0X)ugHTY^)LeJVNF*aHa}=#HbYzEo5ZgTMuqVcMy-IT?;+wz*NVr# z26XcQsc)`+XqNZ`C9G;=Cf(P%Wn(7Qlu74?N18^qwKlbGNtE)5O}b)k7uUgKYWLnl zDn6zrSO-4mm(xFomF-{KzUb4vGgoS_o&D|m?tRz3`qnqrK7%rt!#X&|}BC<0Lgq6mDj5wK7Esm6YK{?9imWj{IL$IFxUiSsq* zDvc;_{Uw>ocfUc$y2d2sSRP{g<>@k|yI*CQr<|83wS0zUo@!p6(DE^o2Tn7AQ_DNu zCoeu`pZtS;;*VGN_ja~Sw7hPg+VLit$}2XK>$?Mqy2dYSU#^dA$4P6Sn$P9f_h0u{ zP;+ZJPtCo(JYCl~#?I#i$^Rkkzx6?e4L9tQSM9S`cG_pJ&$D9}?29-24j1NMB02Ub z)m^Ed`InE9@epy&+{@fk^S@ooMO=7=qcn5oM!8J7m$dE|GcS{P=6>V%!=T?YWcVrR zxqwM+c$IRm8yCvGVhZ>PyUaXE&N}xfb)D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QxuA6)lb)exm?zz<##Rnd25x%!jM6T75@uwU;OR> literal 0 HcmV?d00001 diff --git a/TP2/tp2.c b/TP2/tp2.c new file mode 100644 index 0000000..d239fdc --- /dev/null +++ b/TP2/tp2.c @@ -0,0 +1,170 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +void my_putnbr(int nb) +{ + char c; + + if (nb < 0) + { + if (nb == -2147483648) + { + write(1, "-", 1); + write(1, "2", 1); + my_putnbr(147483648); + return ; + } + nb = nb * -1; + write(1, "-", 1); + } + if (nb >= 0 && nb < 10) + { + c = nb + '0'; + write(1, &c, 1); + } + if (nb >= 10) + { + my_putnbr(nb / 10); + my_putnbr(nb % 10); + } +} + +void my_putnbrUnsignedLong(long nb) +{ + char c; + + if (nb >= 0 && nb < 10) + { + c = nb + '0'; + write(1, &c, 1); + } + if (nb >= 10) + { + my_putnbr(nb / 10); + my_putnbr(nb % 10); + } +} + +int my_strlen(char *str) +{ + int len; + + len = 0; + while (str[len] != '\0') + len++; + return (len); +} + +char *my_strcat(char *dest, char *src, int len) +{ + int i; + int j; + char *final; + + i = 0; + j = 0; + final = (char*)malloc(len); + while (dest[i] != '\0') + { + final[i] = dest[i]; + i++; + } + final[i] = '/'; + i++; + while (src[j] != '\0') + { + final[i] = src[j]; + i++; + j++; + } + final[i] = '\0'; + return (final); +} + +void showFileInfos(char *fileName) +{ + struct stat fileStat; + + if(lstat(fileName, &fileStat) == -1) + { + write(1, "Foirage du statage\n", 20); + exit(1); + } + write(1, fileName, my_strlen(fileName)); + write(1, " ", 1); + my_putnbr(fileStat.st_size); + write(1, " ", 1); + my_putnbrUnsignedLong(fileStat.st_mtim.tv_sec); + write(1, "\n", 2); +} + +int my_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i]) + { + if (s1[i] != s2[i]) + return (s1[i] - s2[i]); + i++; + } + return (s1[i] - s2[i]); +} + +void listDirContent(char *leDossier) +{ + DIR *dir; + struct dirent *lesEntrees; + char *fileAbsolPath; + size_t path_length; + + dir = opendir(leDossier); + if(!dir) + { + if(errno == ENOTDIR) //C'est quand meme pas mal errno, je decouvre + { + write(1, "t'es bourré, on veut le nom d'un dossier et pas autre chose\n", 61); + exit(1); + } + write(1, "Probleme ouverture dossier, droit d'acces ?\n", 45); + return; + } + path_length = my_strlen(leDossier) + NAME_MAX + 2; + fileAbsolPath = (char*)malloc(path_length); + while((lesEntrees = readdir(dir))) + { + if(lesEntrees->d_type == DT_DIR && my_strcmp(lesEntrees->d_name,".") && my_strcmp(lesEntrees->d_name,"..")) + { + fileAbsolPath = my_strcat((char *)leDossier, lesEntrees->d_name, path_length); + showFileInfos(fileAbsolPath); + listDirContent(fileAbsolPath); + } + else + { + + fileAbsolPath = my_strcat((char *)leDossier, lesEntrees->d_name, path_length); + showFileInfos(fileAbsolPath); + } + } + free(fileAbsolPath); + closedir(dir); +} + +int main(int argc, char **argv) +{ + if(argc != 2) + { + write(1, "t'es bourré, on veut le nom d'un dossier qu'on t'dis\n", 54); + exit(1); + } + listDirContent(argv[1]); + return 0; +} + diff --git a/tubes/tp3 b/tubes/tp3 new file mode 100755 index 0000000000000000000000000000000000000000..e6586ef8a65142338ae50d07df48bd88d879c501 GIT binary patch literal 16392 zcmeHOYiu0V6~1dH#6XChkd!=t43wy(l{Zde@&E-K$D53i^B_2FN(eo)mypsoe9pwh;rA=~fVd(U`w zx>lCTS$_4v!&^I%ED6Ueh_ainY131 z-_`A4$#$<#caoUXw~RrkqS+pmAW+hQuUZ_05@<1(**#k`L70kdC-~kemj@T=7c@qxFVU&eN`k1{p*BfVZ8KM zc{iSOt#sVU0O=WsTS+GqPdT^Sq9>Kj+oC_`WZWcdPCnbSd9#)8iD#1Hww&X_=JeZw zN})lvLG0*gZ{23Ci*EFC>!MeA`Ss1hYVX`>CG4Et>*QTK*ST|BDx0x8Hb*!bD=c@;rBR#L`p>>`KZa?I zxC=TZe(v$}=Ga1opVH4Y#``tCr$yNrXT5lx!s#BMF~R8tAMU?zCVV)TMVwPUd_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R+_iOQ`!>MX?P0}CZ8h8W3TsEl?$)gx*6!`wZ;W+Xom*QwVwOk`VhMjPWz%kg z!2W_3-XHK^b^^$~1)ei)A+YR3+>Hy_J-KGB{b?`Ml=JtrKdCMW6!zjtS4SQSQU=RM|ZX zJ0UpYv_+!ozK6=)8I=Xl#gtn+Dqs=K52oFCH>8_WvX67v)M4lPMKqIj?PzbN5be)p z(Fu3Z2Xz-5Y$kFN8rs_0-bjO2y7$HNeIl9|%%BP--JG)AYUlD!HdCQku;uJjoCrGC zpK?W1wmXV!v^NXYwFhvfK@6v?yyj86PY>I^1PWnIQPucW49=s5c-rYf^;wrnM&oGg zL~+4H6n9V>H^$7p{Bd$L&%`4Lzu77+)xYyBd7i1w(wFljKaGRtcFfeTS#te6e-5@k4nEDD zna}fUmU4wA?9@hzGxK?#>j0xJGoR<{EMI}mpQsFf`Wh6P3p1bRzbt7!Mv2?cek|{V zjpo*@8`_a&3z3n6?N_J}W5`fUnct=PEQ{Ka>ksz-JDT6B{S2xIi6y^Z5T9Ze_%DpNu^JT(UeG;1{)lCAXK0VV&i%0H5a>ET87U z>H@f4F7L?zpXX&PY5wj{!Tvu5BlX{_#?anc(zio@3i6+W(a-NNlsC&}KNt$b>=2zpd-l#m52M7UG{2QTUW`F +#include +#include + +#define MAX_MSG_LEN 2048 +#define MAX_PROC 10 + +int my_strlen(char *str) +{ + int len; + + len = 0; + while (str[len] != '\0') + len++; + return (len); +} + +int main(void) +{ + const int N = MAX_PROC; + int fd[MAX_PROC][2]; + pid_t pid[MAX_PROC]; + int dest; + char msg[MAX_MSG_LEN]; + int i; + + i = 0; + dest = 0; + while(i < N) + { + if(pipe(fd[i]) == -1) + { + perror("foirage du pipage"); + exit(EXIT_FAILURE); + } + pid[i] = fork(); + if (pid[i] == -1) + { + perror("foirage du forkage"); + exit(EXIT_FAILURE); + } + if(pid[i] == 0) + { + dup2(fd[i][1], 1); + close(fd[i][0]); + } + i++; + } + while(scanf("%d %[^\n]", &dest, msg) != EOF) + { + if(dest >= 0 && dest < N) + { + printf("Processus %d a reçu: %s\n", dest, msg); + write(fd[dest][1], msg, my_strlen(msg) + 1); + } + } + i = 0; + while(i < N) + { + close(fd[i][1]); + i++; + } + return 0; +} +