Added helper functions for message string manipulation

This commit is contained in:
2023-04-04 08:06:44 -05:00
parent 13858dc352
commit f3f66297c2
2 changed files with 23 additions and 0 deletions

17
message_helpers.c Normal file
View File

@@ -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;
}
}

6
message_helpers.h Normal file
View File

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