#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include<sys/wait.h>

char ** parse(char delim, char * word);
void pointerPrint(char ** argv);
char * checkString(char ** parsedInput, char ** path, char * input);
void exec(char * pathToFile, char ** parsedInput);

int main(int argc, char ** argv, char ** envp){

 /* 2.
	- Search through each element of envp to find the string that starts with 'PATH'
		- The environment variable that starts with 'PATH' is the path that is searched for binary executables
		- An example of printing each element of envp is shown in the envp_example.c file on Canvas
		- Do not hard code the index that begins with 'PATH'. You must search for it.
		- You will then need to use the parse function to parse the the string in envp that was found previously. (Hint: the delimiter will be ":")
			- Call pointerPrint on the result of the parse function.
 */
	
	char * input = malloc(200);

 /* 4.
	- Uncomment the following 3 lines
	printf("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n\n");
	printf("SUPER BASH $");
 	scanf("%[^\n]%*c", input); // reads input until a new line symbol, then the newline is discarded
 */

 /* 6.
	- Call the checkString function to find the path to the file that you will need to execute
	- Call the pointerPrint function on the parsedInput passed into the checkString function
 */

 /* 8.
	- Call the exec function 
 */

 /* 9.
	- Put steps 4, 6, and 8 in a loop so you can enter as many commands as you want
 */

}

char ** parse(char delim, char * word){
 /* 1.
	- Copy and paste the parser you wrote from Project Part 1 here
	- You may have to make a few modifictions to make it work with this function
 */
}

void pointerPrint(char ** path){
 /* 3.
	- Here we first want to print the address of the variable path
	- Next, for each string in the variable path, print the address of the string, the pointer value of the string, and the actual string.
	- See the screenshot in the assignment description to see how the result should look.
 */
}

char * checkString(char ** parsedInput, char ** path, char * input){
 /* 5.
	- Here, the variable parsedInput is the result of running the variable input through the parse function with a delimiter of ' '.
	- The variable path is the same that is passed in to the pointerPrint function
	- We want to search through each element in path to see if we can find the file to execute the command given in input.
		- To do this, we need to concatenate the current element in the variable path that we are looking at with a '/' and then with the first element in the variable input.
			- For example, with an input of 'ls -a' the current element in the variable path could be '/bin', then we will need to add '/' and then 'ls',
			  this gives a result of '/bin/ls'. We will use this later on to know exactly what file to execute.
	- After the file is found, you need to print the input and then print the number of pointers, which will be one more than the number of arguments.
		- For example, 'ls -a' would have 3 pointers. See the screenshot in the assignment description to see how the result should look.
	- Return the whole path to the file that you found previously, from this example it would be '/bin/ls'.
 */
}

void exec(char * pathToFile, char ** parsedInput){
 /* 7.
	- Need to call execv, fork, and wait here.
	- fork() returns the pid, which is an integer.
		- If the pid is 0, then you have the child process and will need to call execv
		- Otherwise, you have the parent process and you will need to call wait to wait for the child process to finish. 
 */
}
