mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-22 00:33:20 +00:00
globbing ( lel It do not work )
This commit is contained in:
parent
4228071f6d
commit
fa6964d421
@ -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)
|
||||
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})
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 11/05/2017.
|
||||
// Dont forget that Antoine Bartuccio is a faggot since 1784 (tm)
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -7,6 +8,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#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);
|
||||
|
||||
@ -125,10 +127,6 @@ char *fishReadLine() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *fishExpand(char *line) {
|
||||
return line;
|
||||
}
|
||||
|
||||
Settings *getSettings() {
|
||||
Settings *s = (Settings*) malloc(sizeof(Settings));
|
||||
if (s == NULL){
|
||||
|
@ -29,7 +29,6 @@ char * fishReadLine();
|
||||
|
||||
int countSeparators(char *string, char *separators);
|
||||
|
||||
char * fishExpand(char* line);
|
||||
|
||||
int fishLoad(WordArray *array);
|
||||
|
||||
|
66
fish_shell/fish_globbing.c
Normal file
66
fish_shell/fish_globbing.c
Normal file
@ -0,0 +1,66 @@
|
||||
// Created by Aethor
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
#include "fish_core.h"
|
||||
#include "fish_globbing.h"
|
||||
|
||||
WordArray* fishExpand(WordArray *wordArray) {
|
||||
|
||||
int i;
|
||||
WordArray* expandedParameters = (WordArray*) malloc(sizeof(WordArray));
|
||||
|
||||
for(i=0; i<wordArray->size; 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;
|
||||
|
||||
}
|
||||
|
||||
|
14
fish_shell/fish_globbing.h
Normal file
14
fish_shell/fish_globbing.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user