From e0b8e9ddc5ed1f86109454be46bd89aef0c549a4 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 30 Mar 2014 21:20:26 +0300 Subject: [PATCH] Finishing ann documentation --- main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 3859f1d..51a8b26 100644 --- a/main.c +++ b/main.c @@ -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]);