[MOD] Make the User API use a bit of the parser

This commit is contained in:
lda 2023-11-26 13:35:12 +01:00
parent 4298ee469a
commit 30679d7999

View file

@ -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
{