Semester's final Project assignment for "Operating Systems" course at AUTH University
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.8 KiB

7 years ago
#ifndef APOSTOLOFSHELLFUNCTIONS_H_ /* Include guard */
#define APOSTOLOFSHELLFUNCTIONS_H_
//Read buffer size is the maximum number of characters (512) plus the newline character and the null
//terminator
#define BUFFER_SIZE 512 + 1 + 1
#define QUIT_CALLED 11880
//Cool colors
#define GRN "\x1B[32m"
#define RESET "\x1B[0m"
const char semicolonDelimeter[2];
const char ampersandDelimeter[2];
//Function interactiveMode implements an interactive shell
void interactiveMode();
//Function batchFileMode runs a script file
void batchFileMode(char *filename); //Filename and path of the script
//Function unconditionalRun splits a string on semicolon character (";") and runs each chunk
//unconditionally
void unconditionalRun(char *input, //String to be split
int *quit_called); //A flag indicating if quit command was called
//Function conditionalRun splits a string on the and character ("&"), runs each chunk conditionally
//if the first character of the next chunk is also the and character and unconditionally otherwise
void conditionalRun(char *input, //String to be split
int *quit_called); //A flag indicating if quit command was called
//Function execute creates a fork and runs a command using execvp
int execute(char *command, //String containing the command
char **argv); //NULL terminated string array containing command's arguments
//Function parseCommand parses a command and its arguments out of a string
void parseCommand(char *input, //String to be parsed
char **command, //String containing the command
char ***argv, //NULL terminated string array containing command's arguments
int *argc); //Number of arguments
//Function trimWhitespaces trims leading and trailing whitespaces of a string
char *trimWhitespaces(char *string); //String to be trimmed
#endif // APOSTOLOFSHELLFUNCTIONS_H_