Added function for retrieving sender, message, and a generic string
This commit is contained in:
@@ -13,3 +13,25 @@ char* fetch_dest_user_string(char* message) {
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
char* fetch_sender_user_string(char* message) {
|
||||
fetch_generic_string("IAM",message);
|
||||
}
|
||||
|
||||
char* fetch_generic_string(char* indicator, char* message) {
|
||||
char* token = malloc (sizeof(char) * strlen(message));
|
||||
|
||||
char* string_to_search = malloc(strlen(indicator) + 1);
|
||||
strcpy(string_to_search,indicator);
|
||||
strcat(string_to_search,":");
|
||||
|
||||
token = strtok(message," r\n");
|
||||
if (strcmp(token,string_to_search) == 0) {
|
||||
token = strtok(NULL," \r\n");
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return token;
|
||||
|
||||
}
|
||||
|
@@ -4,3 +4,18 @@
|
||||
TO: <Username>
|
||||
then return 'Username' */
|
||||
char* fetch_dest_user_string(char* message);
|
||||
|
||||
/* If the message contains a string of the form:
|
||||
IAM: <Username>
|
||||
then return 'Username' */
|
||||
char* fetch_sender_user_string(char* message);
|
||||
|
||||
/* If the message contains a string of the form:
|
||||
<Indicator>: <Value>
|
||||
Then return 'value' */
|
||||
char* fetch_generic_string(char* indicator, char* message);
|
||||
|
||||
/* If the message contains a string of the form:
|
||||
START_OF_MESSAGE
|
||||
<text>
|
||||
END_OF_MESSAGE
|
||||
|
Reference in New Issue
Block a user