Finishing ann documentation
This commit is contained in:
parent
c44f7bf82d
commit
e0b8e9ddc5
1 changed files with 15 additions and 1 deletions
16
main.c
16
main.c
|
@ -257,14 +257,28 @@ int main()
|
||||||
free(tokens);
|
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 getFileNameIndex(char** args)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(args[i] != NULL)
|
while(args[i] != NULL)
|
||||||
i++;
|
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)
|
void freeRemainderInArr(char** args, int beforLast)
|
||||||
{
|
{
|
||||||
free(args[beforLast+1]);
|
free(args[beforLast+1]);
|
||||||
|
|
Loading…
Reference in a new issue