diff --git a/CMakeLists.txt b/CMakeLists.txt index 4113671..99595cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,5 +4,6 @@ project(fish) set(CMAKE_C_STANDARD 99) set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra") -set(SOURCE_FILES main.c fish_shell/fish_core.c fish_shell/fish_core.h fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_types.h fish_shell/fish_utils.c fish_shell/fish_utils.h) -add_executable(fish ${SOURCE_FILES}) \ No newline at end of file +set(SOURCE_FILES main.c fish_shell/fish_core.c fish_shell/fish_core.h fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_types.h fish_shell/fish_utils.c fish_shell/fish_utils.h fish_shell/fish_globbing.c fish_shell/fish_globbing.h) +add_executable(fish ${SOURCE_FILES}) + diff --git a/fish_shell/fish_core.c b/fish_shell/fish_core.c index 73e384c..59d94c2 100644 --- a/fish_shell/fish_core.c +++ b/fish_shell/fish_core.c @@ -1,5 +1,6 @@ // // Created by Antoine Bartuccio on 11/05/2017. +// Dont forget that Antoine Bartuccio is a faggot since 1784 (tm) // #include #include @@ -7,6 +8,7 @@ #include #include #include "fish_core.h" +#include "fish_globbing.h" #define FISH_BUFFER_SIZE 1024 #define FISH_TOKENS " \t\r\n\a" @@ -16,12 +18,12 @@ void fishLoop(Settings * settings){ WordArray * splited = NULL; int status = 1; - do { - printf("%s", settings->PS1); - line = fishReadLine(); - line = fishExpand(line); + do { + printf("%s", settings->PS1); + line = fishReadLine(); - splited = split(line, FISH_TOKENS); + splited = split(line, FISH_TOKENS); + splited = fishExpand(splited); status = fishExecute(splited); @@ -113,10 +115,6 @@ char *fishReadLine() { return NULL; } -char *fishExpand(char *line) { - return line; -} - Settings *getSettings() { Settings *s = (Settings*) malloc(sizeof(Settings)); if (s == NULL){ diff --git a/fish_shell/fish_core.h b/fish_shell/fish_core.h index 6e31133..cca1b34 100644 --- a/fish_shell/fish_core.h +++ b/fish_shell/fish_core.h @@ -28,7 +28,6 @@ char * fishReadLine(); int countSeparators(char *string, char *separators); -char * fishExpand(char* line); int fishLoad(WordArray *array); diff --git a/fish_shell/fish_globbing.c b/fish_shell/fish_globbing.c new file mode 100644 index 0000000..56b5af8 --- /dev/null +++ b/fish_shell/fish_globbing.c @@ -0,0 +1,66 @@ +// Created by Aethor +#include +#include +#include +#include "fish_core.h" +#include "fish_globbing.h" + +WordArray* fishExpand(WordArray *wordArray) { + + int i; + WordArray* expandedParameters = (WordArray*) malloc(sizeof(WordArray)); + + for(i=0; isize; i++){ + + + } + + return wordArray; + +} + + + +WordArray * getFiles(char* path){ + + DIR* directory; + dirent* dir; + int i = 0; + + WordArray* files = (WordArray*) malloc(sizeof(WordArray)); + + + if((directory = opendir(path)) != NULL){ + + while((dir = readdir(directory)) != NULL){ + + i++; + + } + + files->words = (char **) malloc(sizeof(char*) * (i + 1)); + + closedir(directory); + directory = opendir(path); + i = 0; + + while((dir = readdir(directory)) != NULL){ + + files->words[i] = dir->d_name; + + } + + + } + + return files; + +} + +bool comparator(char* string1, char* string2){//TODO + + return true; + +} + + diff --git a/fish_shell/fish_globbing.h b/fish_shell/fish_globbing.h new file mode 100644 index 0000000..690ce08 --- /dev/null +++ b/fish_shell/fish_globbing.h @@ -0,0 +1,14 @@ +#ifndef FISH_FISH_GLOBBING_H +#define FISH_FISH_GLOBBING_H + +typedef struct dirent dirent; + + +WordArray * fishExpand(WordArray* wordArray); + +WordArray* getFiles(char* path); + +/*char1 is a string with characters such as '*', '.' or '?' having special meanings*/ +bool comparator(char* string1, char* string2); + +#endif //FISH_FISH_GLOBBING_H