2017-05-11 15:16:06 +00:00
|
|
|
//
|
|
|
|
// Created by Antoine Bartuccio on 11/05/2017.
|
|
|
|
//
|
|
|
|
|
2017-05-14 18:54:39 +00:00
|
|
|
#ifndef FISH_FISH_CORE_H
|
|
|
|
#define FISH_FISH_CORE_H
|
2017-05-11 15:16:06 +00:00
|
|
|
|
2017-05-16 00:58:16 +00:00
|
|
|
#define FISH_BUFFER_SIZE 1024
|
|
|
|
#define FISH_TOKENS " \t\r\n\a"
|
|
|
|
|
|
|
|
|
2017-05-11 15:16:06 +00:00
|
|
|
|
2017-05-14 18:54:39 +00:00
|
|
|
#include "fish_types.h"
|
|
|
|
#include "fish_commands.h"
|
2017-05-15 12:08:10 +00:00
|
|
|
#include "fish_utils.h"
|
2017-05-29 14:19:42 +00:00
|
|
|
#include "fish_settings.h"
|
2017-05-11 15:16:06 +00:00
|
|
|
|
2017-05-13 20:40:41 +00:00
|
|
|
/* WordArray functions */
|
|
|
|
|
2017-05-16 00:58:16 +00:00
|
|
|
WordList * split(char *string, char *separator); // Tested
|
2017-05-13 20:40:41 +00:00
|
|
|
|
2017-05-11 15:16:06 +00:00
|
|
|
|
|
|
|
|
2017-05-13 20:40:41 +00:00
|
|
|
/* General purpose functions */
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Main loop of the project */
|
2017-05-13 20:40:41 +00:00
|
|
|
void fishLoop(Settings * settings);
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Get the user input */
|
2017-05-13 20:40:41 +00:00
|
|
|
char * fishReadLine();
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Count the number of occurrences of a given regex pattern */
|
2017-06-11 00:10:11 +00:00
|
|
|
int countSeparators(char *string, char *regex); // Tested
|
2017-05-11 15:16:06 +00:00
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Execute an external command */
|
2017-05-14 18:54:39 +00:00
|
|
|
int fishLoad(WordArray *array);
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Handle operators in the user input */
|
2017-05-16 17:15:51 +00:00
|
|
|
int fishExecute(WordList *list);
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Cut a WordList at the given operator regex pattern */
|
2017-05-16 17:15:51 +00:00
|
|
|
WordList *parseWordList(WordList *list, shell_operator *an_operator);
|
|
|
|
|
2017-06-19 11:45:06 +00:00
|
|
|
/* Choose between internal and external command */
|
2017-05-16 17:15:51 +00:00
|
|
|
int loadRightCommand(WordArray *array);
|
2017-05-14 18:54:39 +00:00
|
|
|
|
2017-06-11 00:10:11 +00:00
|
|
|
/* IN/OUT functions */
|
|
|
|
|
|
|
|
/* Get a global pipe_redirection structure */
|
|
|
|
pipe_redirection * getRedirection();
|
|
|
|
|
|
|
|
/* Free redirection structure DO NOT TRY TO GET REDIRECTION AFTER */
|
|
|
|
void freeRedirection();
|
|
|
|
|
2017-05-14 18:54:39 +00:00
|
|
|
#endif //FISH_FISH_CORE_H
|