From 46d99e6836dff42c169731645fb46b9184506235 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 19 Jun 2017 13:45:06 +0200 Subject: [PATCH] Commentaires --- fish_shell/fish_commands.c | 3 ++- fish_shell/fish_commands.h | 11 +++++++++++ fish_shell/fish_core.h | 7 +++++++ fish_shell/fish_settings.h | 7 +++++++ fish_shell/fish_utils.h | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/fish_shell/fish_commands.c b/fish_shell/fish_commands.c index e1a7a36..d7bbf2f 100644 --- a/fish_shell/fish_commands.c +++ b/fish_shell/fish_commands.c @@ -8,7 +8,7 @@ #include "fish_types.h" #include "fish_settings.h" -/* Necessary global variables */ +/* Necessary global variable */ char * builtinCommandsStr[] = { (char *) "clear", (char *) "kek", @@ -17,6 +17,7 @@ char * builtinCommandsStr[] = { (char *) "exit" }; +/* Necessary global variable */ builtinCommand *builtinCommands[] = { &fishClear, &fishKek, diff --git a/fish_shell/fish_commands.h b/fish_shell/fish_commands.h index 961f1b6..930befa 100644 --- a/fish_shell/fish_commands.h +++ b/fish_shell/fish_commands.h @@ -9,22 +9,33 @@ /* Getters */ +/* Getter for global variable in external files */ char ** getBuiltinCommandsStr (); + +/* Getter for global variable in external files */ builtinCommand **getBuiltinCommands(); + +/* Get size of the two global variable array */ int getNbBuiltins(); /* Built in shell commands */ +/* Change Dir internal command */ int fishCd(WordArray * args); +/* Help internal command */ int fishHelp(WordArray * args); +/* Exit internal command */ int fishExit(WordArray * args); +/* Kek internal command */ int fishKek(WordArray *args); +/* Clear the terninal (internal command) */ int fishClear(WordArray *args); +/* Handle signal from the user (such as ctrl+c */ void fishSignalHandler(int s); #endif //FISH_FISH_COMMANDS_H diff --git a/fish_shell/fish_core.h b/fish_shell/fish_core.h index 8c07c6e..e660268 100644 --- a/fish_shell/fish_core.h +++ b/fish_shell/fish_core.h @@ -23,18 +23,25 @@ WordList * split(char *string, char *separator); // Tested /* General purpose functions */ +/* Main loop of the project */ void fishLoop(Settings * settings); +/* Get the user input */ char * fishReadLine(); +/* Count the number of occurrences of a given regex pattern */ int countSeparators(char *string, char *regex); // Tested +/* Execute an external command */ int fishLoad(WordArray *array); +/* Handle operators in the user input */ int fishExecute(WordList *list); +/* Cut a WordList at the given operator regex pattern */ WordList *parseWordList(WordList *list, shell_operator *an_operator); +/* Choose between internal and external command */ int loadRightCommand(WordArray *array); /* IN/OUT functions */ diff --git a/fish_shell/fish_settings.h b/fish_shell/fish_settings.h index e941427..991be6b 100644 --- a/fish_shell/fish_settings.h +++ b/fish_shell/fish_settings.h @@ -6,9 +6,16 @@ #define FISH_RC_FILE "/.fishrc" #define FISH_RC_FILE_SIZE 8 +/* Get settings */ Settings * getSettings(); //TESTEDssssss + +/* Free settings */ void freeSettings(Settings *settings); //TESTED + +/* Extract a given variable from a given file */ char* extractVariable(char* filename, char* var);//TESTED + +/* Correctly print PS1 and PS2 variable */ void printPS(char* PS, Settings* s); #endif //FISH_FISH_SETTINGS_H diff --git a/fish_shell/fish_utils.h b/fish_shell/fish_utils.h index 35dd374..835aaa0 100644 --- a/fish_shell/fish_utils.h +++ b/fish_shell/fish_utils.h @@ -7,42 +7,62 @@ #include "fish_types.h" +/* Crash the application and throw a random error message in english */ void crash(); // Tested +/* Get a random french insult for the user */ char *getInsult(); // Tested +/* Free a WordArray */ void freeWordArray(WordArray *array); // Tested +/* Create a new WordList */ WordList * createWordList(); // Tested +/* Cut a WordList and throw every word contained between the two index */ WordList * sliceWordList(WordList *list, int min_index, int max_index); +/* Add a world at the end of a WordList */ void addEndWordList(WordList *list, char *word); // Tested +/* Add a word at the beginning of a WordList */ void addBeginWordList(WordList *list, char *word); + +/* Delete an entire WordList */ void removeWordList(WordList *list); // Tested +/* Remove an element from a WordList */ void removeWordListElem(WordList *list, WordListElement *elem); +/* Free an entire WordList */ void freeWordList(WordList *list); // Tested +/* Convert a WordList into a WordArray */ WordArray * wordListToWordArray(WordList *list); // Tested +/* Convert a WordArray into a WordList */ WordList * wordArrayToWordList(WordArray * array); // Tested +/* Split a WordList according to a given regex */ WordList * splitWordList(WordList *list, char *regex); +/* Split a word from a given index removing parts according to the size to delete */ char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tested +/* Put the second WordList into the first one */ void concatWordList(WordList* list1, WordList* list2); +/* Print a WordList for debug */ void printWordList(WordList* list); +/* Detect if a string contains a given character */ int stringContains(char* string, char charToTest); +/* Better than Strcat */ char* trueStrcat(char* string1, char* string2); +/* Check if the given path is a directory */ int isDirectory(char* path);