1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-21 16:23:20 +00:00

Commentaires

This commit is contained in:
Antoine Bartuccio 2017-06-19 13:45:06 +02:00
parent 3eea812666
commit 46d99e6836
5 changed files with 47 additions and 1 deletions

View File

@ -8,7 +8,7 @@
#include "fish_types.h" #include "fish_types.h"
#include "fish_settings.h" #include "fish_settings.h"
/* Necessary global variables */ /* Necessary global variable */
char * builtinCommandsStr[] = { char * builtinCommandsStr[] = {
(char *) "clear", (char *) "clear",
(char *) "kek", (char *) "kek",
@ -17,6 +17,7 @@ char * builtinCommandsStr[] = {
(char *) "exit" (char *) "exit"
}; };
/* Necessary global variable */
builtinCommand *builtinCommands[] = { builtinCommand *builtinCommands[] = {
&fishClear, &fishClear,
&fishKek, &fishKek,

View File

@ -9,22 +9,33 @@
/* Getters */ /* Getters */
/* Getter for global variable in external files */
char ** getBuiltinCommandsStr (); char ** getBuiltinCommandsStr ();
/* Getter for global variable in external files */
builtinCommand **getBuiltinCommands(); builtinCommand **getBuiltinCommands();
/* Get size of the two global variable array */
int getNbBuiltins(); int getNbBuiltins();
/* Built in shell commands */ /* Built in shell commands */
/* Change Dir internal command */
int fishCd(WordArray * args); int fishCd(WordArray * args);
/* Help internal command */
int fishHelp(WordArray * args); int fishHelp(WordArray * args);
/* Exit internal command */
int fishExit(WordArray * args); int fishExit(WordArray * args);
/* Kek internal command */
int fishKek(WordArray *args); int fishKek(WordArray *args);
/* Clear the terninal (internal command) */
int fishClear(WordArray *args); int fishClear(WordArray *args);
/* Handle signal from the user (such as ctrl+c */
void fishSignalHandler(int s); void fishSignalHandler(int s);
#endif //FISH_FISH_COMMANDS_H #endif //FISH_FISH_COMMANDS_H

View File

@ -23,18 +23,25 @@ WordList * split(char *string, char *separator); // Tested
/* General purpose functions */ /* General purpose functions */
/* Main loop of the project */
void fishLoop(Settings * settings); void fishLoop(Settings * settings);
/* Get the user input */
char * fishReadLine(); char * fishReadLine();
/* Count the number of occurrences of a given regex pattern */
int countSeparators(char *string, char *regex); // Tested int countSeparators(char *string, char *regex); // Tested
/* Execute an external command */
int fishLoad(WordArray *array); int fishLoad(WordArray *array);
/* Handle operators in the user input */
int fishExecute(WordList *list); int fishExecute(WordList *list);
/* Cut a WordList at the given operator regex pattern */
WordList *parseWordList(WordList *list, shell_operator *an_operator); WordList *parseWordList(WordList *list, shell_operator *an_operator);
/* Choose between internal and external command */
int loadRightCommand(WordArray *array); int loadRightCommand(WordArray *array);
/* IN/OUT functions */ /* IN/OUT functions */

View File

@ -6,9 +6,16 @@
#define FISH_RC_FILE "/.fishrc" #define FISH_RC_FILE "/.fishrc"
#define FISH_RC_FILE_SIZE 8 #define FISH_RC_FILE_SIZE 8
/* Get settings */
Settings * getSettings(); //TESTEDssssss Settings * getSettings(); //TESTEDssssss
/* Free settings */
void freeSettings(Settings *settings); //TESTED void freeSettings(Settings *settings); //TESTED
/* Extract a given variable from a given file */
char* extractVariable(char* filename, char* var);//TESTED char* extractVariable(char* filename, char* var);//TESTED
/* Correctly print PS1 and PS2 variable */
void printPS(char* PS, Settings* s); void printPS(char* PS, Settings* s);
#endif //FISH_FISH_SETTINGS_H #endif //FISH_FISH_SETTINGS_H

View File

@ -7,42 +7,62 @@
#include "fish_types.h" #include "fish_types.h"
/* Crash the application and throw a random error message in english */
void crash(); // Tested void crash(); // Tested
/* Get a random french insult for the user */
char *getInsult(); // Tested char *getInsult(); // Tested
/* Free a WordArray */
void freeWordArray(WordArray *array); // Tested void freeWordArray(WordArray *array); // Tested
/* Create a new WordList */
WordList * createWordList(); // Tested 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); 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 void addEndWordList(WordList *list, char *word); // Tested
/* Add a word at the beginning of a WordList */
void addBeginWordList(WordList *list, char *word); void addBeginWordList(WordList *list, char *word);
/* Delete an entire WordList */
void removeWordList(WordList *list); // Tested void removeWordList(WordList *list); // Tested
/* Remove an element from a WordList */
void removeWordListElem(WordList *list, WordListElement *elem); void removeWordListElem(WordList *list, WordListElement *elem);
/* Free an entire WordList */
void freeWordList(WordList *list); // Tested void freeWordList(WordList *list); // Tested
/* Convert a WordList into a WordArray */
WordArray * wordListToWordArray(WordList *list); // Tested WordArray * wordListToWordArray(WordList *list); // Tested
/* Convert a WordArray into a WordList */
WordList * wordArrayToWordList(WordArray * array); // Tested WordList * wordArrayToWordList(WordArray * array); // Tested
/* Split a WordList according to a given regex */
WordList * splitWordList(WordList *list, char *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 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); void concatWordList(WordList* list1, WordList* list2);
/* Print a WordList for debug */
void printWordList(WordList* list); void printWordList(WordList* list);
/* Detect if a string contains a given character */
int stringContains(char* string, char charToTest); int stringContains(char* string, char charToTest);
/* Better than Strcat */
char* trueStrcat(char* string1, char* string2); char* trueStrcat(char* string1, char* string2);
/* Check if the given path is a directory */
int isDirectory(char* path); int isDirectory(char* path);