diff --git a/README b/README index 3fed39e..77664c8 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ Andrew Coleman CSC-4200 To compile: - gcc -o cftp -lm -Wall server.c client.c filesystem.c cftp.c + gcc -o cftp -Wall server.c client.c filesystem.c cftp.c For explanation on running: ./cftp -h diff --git a/filesystem.c b/filesystem.c index e1889ee..ef5c003 100644 --- a/filesystem.c +++ b/filesystem.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "cftp.h" #include "filesystem.h" @@ -57,7 +56,7 @@ void send_file(int skt, const char *filename) memset(errmsg, '\0', ERRMSGLEN); memset(cmd, '\0', CMDLEN); memset(arg, '\0', MSGLEN); - memset(msg, (unsigned char)0, MSGLEN); + memset(msg, '\0', MSGLEN); /* file must exist */ if(!exist(filename)) @@ -73,7 +72,7 @@ void send_file(int skt, const char *filename) error("That file is inappropriately sized!"); return; } - segments = ceil(MAXFILE / MSGLEN); + segments = MAXFILE / MSGLEN; /* make a copy then figure out just the filename */ strcpy(msg, filename); @@ -94,7 +93,7 @@ void send_file(int skt, const char *filename) error(errmsg); return; } - else if(strcmp(cmd, "cts") != 0) + else if(strcmp(cmd, "cts")) { sprintf(errmsg, "ERROR invalid reponse from remote: %s", msg); error(errmsg); @@ -111,10 +110,11 @@ void send_file(int skt, const char *filename) for(cur_segment = 0; cur_segment < segments; cur_segment++) { fread(msg, MSGLEN, 1, infile); - sprintf(errmsg, "\rSending File: %.2f%%", floor(cur_segment / segments * 100.0)); - debug("Filesystem", errmsg); + sprintf(errmsg, "\rFilesystem: Sending file %.2f%%", (cur_segment / segments * 100.0)); + printf(errmsg); send_message(skt, msg); } + debug("Filesystem", "File sent successfully"); } /* diff --git a/filesystem.h b/filesystem.h index d370247..5f4f5ab 100644 --- a/filesystem.h +++ b/filesystem.h @@ -11,7 +11,7 @@ /* * The MAXFILE size is calculated to be the largest integer in CMDLEN - 1 - * characters times MSGLEN. + * characters times MSGLEN. MAXFILE must be a multiple of MSGLEN. * * 9999 * 128 bytes = 1279872 bytes maximum *