|
|
|
@ -44,20 +44,30 @@ char* fetch_message_string(char* message) {
|
|
|
|
|
}
|
|
|
|
|
int end_index = end - message;
|
|
|
|
|
|
|
|
|
|
if (*(message+ end_index-2) = '\r') {
|
|
|
|
|
if (*(message + end_index-2) = '\r') {
|
|
|
|
|
num_of_terminators = 2;
|
|
|
|
|
} else {
|
|
|
|
|
num_of_terminators = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end_index -= num_of_terminators;
|
|
|
|
|
|
|
|
|
|
int message_length = end_index - start_index;
|
|
|
|
|
char* message_string = malloc(message_length + 1);
|
|
|
|
|
char* message_string = malloc(message_length + 2);
|
|
|
|
|
|
|
|
|
|
printf("Message length is %d\n",message_length);
|
|
|
|
|
|
|
|
|
|
for (int i=0;i < message_length-num_of_terminators; i++) { /* The reason the upper-bound is message_length-1 is because the last
|
|
|
|
|
for (int i=0; i<message_length; i++) { /* The reason the upper-bound is message_length-1 is because the last
|
|
|
|
|
character is a new-line, which the user would not have typed. */
|
|
|
|
|
|
|
|
|
|
*(message_string + i) = *(message + start_index + i);
|
|
|
|
|
printf("%c",*(message_string + i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*(message_string + (message_length - num_of_terminators)) = '\0';
|
|
|
|
|
strcat(message_string,"\0");
|
|
|
|
|
|
|
|
|
|
// printf("%s\n",message_string);
|
|
|
|
|
|
|
|
|
|
// *(message_string + (message_length - num_of_terminators)) = '\0';
|
|
|
|
|
return message_string;
|
|
|
|
|
}
|
|
|
|
|