Skip to content

Commit 0589db3

Browse files
committed
new messages
1 parent 595ba25 commit 0589db3

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

client/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ int _get(int sockfd, int datafd, char *input){
421421
printf("Server Control Response: %s\n", recvline);
422422
temp = strtok(recvline, " ");
423423
if(atoi(temp) != 200){
424-
printf("File Error...\nExiting...\n");
424+
printf("File Error.\n");
425425
break;
426426
}
427427
control_finished = TRUE;

server/helpers.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int get_client_ip_port(char *str, char *client_ip, int *client_port){
7171
x6 = atoi(n6);
7272
*client_port = (256*x5)+x6;
7373

74-
printf("client_ip: %s client_port: %d\n", client_ip, *client_port);
74+
printf("Client's IP: %s Port: %d\n", client_ip, *client_port);
7575
return 1;
7676
}
7777

@@ -80,7 +80,7 @@ int setup_data_connection(int *fd, char *client_ip, int client_port, int server_
8080
struct sockaddr_in cliaddr, tempaddr;
8181

8282
if ( (*fd = socket(AF_INET, SOCK_STREAM, 0)) < 0){
83-
perror("socket error");
83+
perror("err: socket error");
8484
return -1;
8585
}
8686

@@ -102,12 +102,12 @@ int setup_data_connection(int *fd, char *client_ip, int client_port, int server_
102102
cliaddr.sin_family = AF_INET;
103103
cliaddr.sin_port = htons(client_port);
104104
if (inet_pton(AF_INET, client_ip, &cliaddr.sin_addr) <= 0){
105-
perror("inet_pton error");
105+
perror("err: inet_pton error");
106106
return -1;
107107
}
108108

109109
if (connect(*fd, (struct sockaddr *) &cliaddr, sizeof(cliaddr)) < 0){
110-
perror("connect error");
110+
perror("err: connect error");
111111
return -1;
112112
}
113113

@@ -147,21 +147,13 @@ int _ls(int controlfd, int datafd, char *input){
147147
memset(filelist, '\0', (int)sizeof(filelist));
148148

149149
if(get_filename(input, filelist) > 0){
150-
printf("Filelist Detected\n");
150+
151151
sprintf(str, "ls %s", filelist);
152152
printf("Filelist: %s\n", filelist);
153153
rm_lt_spaces(filelist);
154-
//verify that given input is valid
155-
/*struct stat statbuf;
156-
stat(filelist, &statbuf);
157-
if(!(S_ISDIR(statbuf.st_mode))) {
158-
sprintf(sendline, "550 No Such File or Directory\n");
159-
write(controlfd, sendline, strlen(sendline));
160-
return -1;
161-
}*/
162154
DIR *dir = opendir(filelist);
163155
if(!dir){
164-
sprintf(sendline, "550 No Such File or Directory\n");
156+
sprintf(sendline, "No such file or directory\n");
165157
write(controlfd, sendline, strlen(sendline));
166158
return -1;
167159
}else{closedir(dir);}
@@ -170,12 +162,12 @@ int _ls(int controlfd, int datafd, char *input){
170162
sprintf(str, "ls");
171163
}
172164

173-
//initiate file pointer for popen()
165+
// initiate file pointer for popen()
174166
FILE *in;
175167
extern FILE *popen();
176168

177169
if (!(in = popen(str, "r"))) {
178-
sprintf(sendline, "451 Requested action aborted. Local error in processing\n");
170+
sprintf(sendline, "Abort action. Local error in processing\n");
179171
write(controlfd, sendline, strlen(sendline));
180172
return -1;
181173
}
@@ -186,7 +178,7 @@ int _ls(int controlfd, int datafd, char *input){
186178
memset(sendline, '\0', (int)sizeof(sendline));
187179
}
188180

189-
sprintf(sendline, "200 Command OK");
181+
sprintf(sendline, "status: successful");
190182
write(controlfd, sendline, strlen(sendline));
191183
pclose(in);
192184

@@ -210,7 +202,7 @@ int _get(int controlfd, int datafd, char *input){
210202
}
211203
}else{
212204
printf("Filename Not Detected\n");
213-
sprintf(sendline, "450 Requested file action not taken.\nFilename Not Detected\n");
205+
sprintf(sendline, "Abort action. Local error in processing\n");
214206
write(controlfd, sendline, strlen(sendline));
215207
return -1;
216208
}
@@ -219,18 +211,17 @@ int _get(int controlfd, int datafd, char *input){
219211
extern FILE *popen();
220212

221213
if (!(in = popen(str, "r"))) {
222-
sprintf(sendline, "451 Requested action aborted. Local error in processing\n");
214+
sprintf(sendline, "Abort action. Local error in processing\n");
223215
write(controlfd, sendline, strlen(sendline));
224216
return -1;
225217
}
226218

227219
while (fgets(sendline, MAXLINE, in) != NULL) {
228220
write(datafd, sendline, strlen(sendline));
229-
//printf("%s", sendline);
230221
memset(sendline, '\0', (int)sizeof(sendline));
231222
}
232223

233-
sprintf(sendline, "200 Command OK");
224+
sprintf(sendline, "status: successful");
234225
write(controlfd, sendline, strlen(sendline));
235226
pclose(in);
236227
return 1;

server/server.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ int main(int argc, char **argv){
6666
if((x = read(connfd, recvline, MAXLINE)) < 0){
6767
break;
6868
}
69-
printf("*****************\n%s \n", recvline);
69+
printf("========================================================================\n%s \n", recvline);
7070
if(strcmp(recvline, "QUIT") == 0){
71-
printf("Quitting...\n");
71+
printf("Exiting.\n");
7272
char goodbye[1024];
73-
sprintf(goodbye,"221 Goodbye");
73+
sprintf(goodbye,"Exit successful\n");
7474
write(connfd, goodbye, strlen(goodbye));
7575
close(connfd);
7676
break;
@@ -85,7 +85,7 @@ int main(int argc, char **argv){
8585
break;
8686
}
8787

88-
printf("-----------------\n%s \n", command);
88+
printf("______________________________________________________________________\n%s \n", command);
8989

9090
code = get_cmd_code(command);
9191
if(code == 1){
@@ -94,7 +94,7 @@ int main(int argc, char **argv){
9494
_get(connfd, datafd, command);
9595
}else if(code == 4){
9696
char reply[1024];
97-
sprintf(reply, "550 Filename Does Not Exist");
97+
sprintf(reply, RED "err: File not found\n" RESET);
9898
write(connfd, reply, strlen(reply));
9999
close(datafd);
100100
continue;
@@ -104,7 +104,7 @@ int main(int argc, char **argv){
104104

105105

106106
}
107-
printf("Exiting Child Process...\n");
107+
printf("Disconnect Client.\n");
108108
close(connfd);
109109
_exit(1);
110110
}

0 commit comments

Comments
 (0)