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/Int64.h>
|
||||||
#include <Cytoplasm/UInt64.h>
|
#include <Cytoplasm/UInt64.h>
|
||||||
|
|
||||||
|
#include <Parser.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct User
|
struct User
|
||||||
|
@ -907,26 +909,29 @@ UserIdParse(char *id, char *defaultServer)
|
||||||
/* Fully-qualified user ID */
|
/* Fully-qualified user ID */
|
||||||
if (*id == '@')
|
if (*id == '@')
|
||||||
{
|
{
|
||||||
char *localStart = id + 1;
|
CommonID commonID;
|
||||||
char *serverStart = localStart;
|
commonID.sigil = '\0';
|
||||||
|
commonID.local = NULL;
|
||||||
while (*serverStart != ':' && *serverStart != '\0')
|
commonID.server = NULL;
|
||||||
{
|
if (!ParseCommonID(id, &commonID) || !commonID.server)
|
||||||
serverStart++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*serverStart == '\0')
|
|
||||||
{
|
{
|
||||||
Free(userId);
|
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;
|
userId = NULL;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
*serverStart = '\0';
|
userId->localpart = commonID.local;
|
||||||
serverStart++;
|
userId->server = commonID.server;
|
||||||
|
|
||||||
userId->localpart = StrDuplicate(localStart);
|
|
||||||
userId->server = StrDuplicate(serverStart);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue