Skip to content

Commit

Permalink
client is now able to parse filenames with spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
rovinbhandari committed Mar 10, 2012
1 parent 37c526f commit 761b550
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ implement different connections for control and for data.
implement command queueing on client/server.
implement multi-threading on server side.
put the server on port 21.
make the client capable of parsing spaces in filenames.
DONE: make the client capable of parsing spaces in filenames.

9 changes: 7 additions & 2 deletions client_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ int main(int argc, char* argv[])
while(1)
{
printf("\t> ");
fgets(userinput, LENUSERINPUT, stdin);
fgets(userinput, LENUSERINPUT, stdin); // in order to give \
a filename with spaces, put ':' \
instead of ' '. If a command needs \
x paths, and y (y > x) paths are \
provided, y - x paths will be \
ignored.
cmd = userinputtocommand(userinput);
if(!cmd)
continue;
//printcommand(cmd);
printcommand(cmd);
switch(cmd->id)
{
case GET:
Expand Down
4 changes: 3 additions & 1 deletion client_ftp_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ static void append_path(struct command* c, char* s)
memcpy(temppaths, c->paths, (c->npaths - 1) * sizeof(char*));

char* temps = (char*) malloc((strlen(s) + 1) * sizeof(char));
strcpy(temps, s);
int i;
for(i = 0; i < strlen(s); i++)
*(temps + i) = *(s + i) == ':' ? ' ' : *(s + i);

*(temppaths + c->npaths - 1) = temps;

Expand Down

0 comments on commit 761b550

Please sign in to comment.