forked from Telodendria/Telodendria
[MOD] Make the User API use a bit of the parser
This commit is contained in:
parent
4298ee469a
commit
30679d7999
1 changed files with 19 additions and 14 deletions
33
src/User.c
33
src/User.c
|
@ -31,6 +31,8 @@
|
|||
#include <Cytoplasm/Int64.h>
|
||||
#include <Cytoplasm/UInt64.h>
|
||||
|
||||
#include <Parser.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct User
|
||||
|
@ -907,26 +909,29 @@ UserIdParse(char *id, char *defaultServer)
|
|||
/* Fully-qualified user ID */
|
||||
if (*id == '@')
|
||||
{
|
||||
char *localStart = id + 1;
|
||||
char *serverStart = localStart;
|
||||
|
||||
while (*serverStart != ':' && *serverStart != '\0')
|
||||
{
|
||||
serverStart++;
|
||||
}
|
||||
|
||||
if (*serverStart == '\0')
|
||||
CommonID commonID;
|
||||
commonID.sigil = '\0';
|
||||
commonID.local = NULL;
|
||||
commonID.server = NULL;
|
||||
if (!ParseCommonID(id, &commonID) || !commonID.server)
|
||||
{
|
||||
Free(userId);
|
||||
Free(commonID.local);
|
||||
Free(commonID.server);
|
||||
userId = NULL;
|
||||
goto finish;
|
||||
}
|
||||
if (*commonID.server == '\0')
|
||||
{
|
||||
Free(userId);
|
||||
Free(commonID.local);
|
||||
Free(commonID.server);
|
||||
userId = NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
*serverStart = '\0';
|
||||
serverStart++;
|
||||
|
||||
userId->localpart = StrDuplicate(localStart);
|
||||
userId->server = StrDuplicate(serverStart);
|
||||
userId->localpart = commonID.local;
|
||||
userId->server = commonID.server;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue