From 9a6020d97c485abce5639b4869a06bc6dbd1444d Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 15 May 2017 15:52:48 +0200 Subject: [PATCH] =?UTF-8?q?Messages=20d'erreur=20al=C3=A9atoires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fish_shell/fish_utils.c | 31 ++++++++++++++++++++++++++++++- fish_shell/fish_utils.h | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/fish_shell/fish_utils.c b/fish_shell/fish_utils.c index 9ee8560..a018a8f 100644 --- a/fish_shell/fish_utils.c +++ b/fish_shell/fish_utils.c @@ -5,13 +5,42 @@ #include #include #include +#include #include "fish_types.h" void crash(){ - fprintf(stderr, "fish: Error allocating fucking pointer !"); + char *crashErrors[] = { + "fish: Fucking malloc always returning NULL pointer !", + "fish: Error allocating fucking pointer !", + "fish: C language exploding again", + "fish: It's not you're fault for this time" + }; + int picked = 0; + + srand((unsigned int) time(NULL)); + picked = rand() % (sizeof(crashErrors) / sizeof(char*)); + + fprintf(stderr, "%s\n", crashErrors[picked]); exit(EXIT_FAILURE); } +char *getInsult(){ + static int init = 0; + int picked = 0; + char *insults[] = { + "Apprend à écrire crétin !", + "Bolos !", + "Mois aussi je sais écrire de la merde, pourtant je le fait pas !" + }; + if (!init){ + srand((unsigned int) time(NULL)); + init = 1; + } + + picked = rand() % (sizeof(insults) / sizeof(char*)); + return insults[picked]; +} + void freeWordArray(WordArray *array) { int i; if (array != NULL) { diff --git a/fish_shell/fish_utils.h b/fish_shell/fish_utils.h index 84ddbea..70e3725 100644 --- a/fish_shell/fish_utils.h +++ b/fish_shell/fish_utils.h @@ -9,6 +9,8 @@ void crash(); +char *getInsult(); + void freeWordArray(WordArray *array); WordList * createWordList();