Skip to content

Commit

Permalink
Adding user-input-prompt functionality to the client. Intermediate co…
Browse files Browse the repository at this point in the history
…mmit 5.
  • Loading branch information
rovinbhandari committed Mar 6, 2012
1 parent 165c78f commit 88fb1ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ int main(int argc, char* argv[])
//END: initialization


//int command = -1;
char lpwd[LENBUFFER], pwd[LENBUFFER], path[LENBUFFER];
struct command* cmd;
char lpwd[LENBUFFER], pwd[LENBUFFER];
char userinput[LENUSERINPUT];
char* paths[LENBUFFER];
while(1)
{
printf("\t> ");
fgets(userinput, LENUSERINPUT, stdin);
cmd = userinputtocommand(userinput);
if(!cmd)
continue;
printcommand(cmd);
// switch case on command
if(cmd->id == EXIT)
break;
}

/*
Expand Down
2 changes: 2 additions & 0 deletions client_ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ struct command

struct command* userinputtocommand(char [LENUSERINPUT]);

void printcommand(struct command*);

15 changes: 15 additions & 0 deletions client_ftp_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,18 @@ struct command* userinputtocommand(char s[LENUSERINPUT])
}
}

void printcommand(struct command* c)
{
if(!DEBUG)
return;

printf("\t\tPrinting contents of the above command...\n");
printf("\t\tid = %d\n", c->id);
printf("\t\tnpaths = %d\n", c->npaths);
printf("\t\tpaths =\n");
int i;
for(i = 0; i < c->npaths; i++)
printf("\t\t\t%s\n", c->paths[i]);
printf("\n");
}

0 comments on commit 88fb1ab

Please sign in to comment.