mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:25:11 +00:00
34 lines
675 B
C
34 lines
675 B
C
#include <Matrix.h>
|
|
|
|
#include <Cytoplasm/Memory.h>
|
|
|
|
#include <string.h>
|
|
|
|
UserID *
|
|
MatrixParseID(char *user)
|
|
{
|
|
UserID *ret = NULL;
|
|
char *localstart, *serverstart;
|
|
if (!user || *user != '@')
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
localstart = user + 1;
|
|
serverstart = strchr(user, ':');
|
|
if (!*localstart || !serverstart || localstart == serverstart)
|
|
{
|
|
return NULL;
|
|
}
|
|
if (!*++serverstart)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
ret = Malloc(sizeof(*ret));
|
|
memset(ret, '\0', sizeof(*ret));
|
|
memcpy(ret->localpart, localstart, serverstart - localstart - 1);
|
|
memcpy(ret->server, serverstart, strlen(serverstart));
|
|
|
|
return ret;
|
|
}
|