Finishing ann documentation

This commit is contained in:
Sagi Dayan 2014-03-30 21:20:26 +03:00
parent c44f7bf82d
commit e0b8e9ddc5

16
main.c
View file

@ -257,14 +257,28 @@ int main()
free(tokens);
}
/**
* returns the index of the File name to redirect output to.
* @param args - an array of all the arguments
* @return int - index whare the fileName is in
*/
int getFileNameIndex(char** args)
{
int i = 0;
while(args[i] != NULL)
i++;
return i-1;
//we are at the end of the array.
return i-1; //the last arg must be the file name
}
/**
* this function will modify th args array, in case of redirecting.
* in that case, the 2 last args are ">" -> "filename"
* so, the function will put Null insted of ">", and will free
* the unneeded array cells.
* @param args - the array of arguments
* @param beforLast - the index of ">"
*/
void freeRemainderInArr(char** args, int beforLast)
{
free(args[beforLast+1]);