Added helper functions for message string manipulation

master
Aadhavan Srinivasan 2 years ago
parent 13858dc352
commit f3f66297c2

@ -0,0 +1,17 @@
#include <easysock.h>
#include "message_helpers.h"
char* fetch_address(char* message) {
char* token = malloc (sizeof(char) * strlen(message));
token = strtok(message," ");
if (strcmp(token,"TO:") == 0) {
token = strtok(NULL,"");
}
if (check_ip_ver(token) == -1) {
return NULL;
} else {
return token;
}
}

@ -0,0 +1,6 @@
/* If the message contains a string of the form:
TO: <Username>
then return 'Username' */
char* fetch_address(char* message);
Loading…
Cancel
Save