forked from Telodendria/Telodendria
[ADD/WIP] Add ParserRecomposeCommonID
This commit is contained in:
parent
8e177baef7
commit
288ab5da54
2 changed files with 34 additions and 0 deletions
27
src/Parser.c
27
src/Parser.c
|
@ -343,3 +343,30 @@ ValidCommonID(char *str, char sigil)
|
|||
CommonIDFree(id);
|
||||
return ret;
|
||||
}
|
||||
char *
|
||||
ParserRecomposeCommonID(CommonID id)
|
||||
{
|
||||
char *ret = Malloc(2);
|
||||
ret[0] = id.sigil;
|
||||
ret[1] = '\0';
|
||||
|
||||
if (id.local)
|
||||
{
|
||||
char *tmp = StrConcat(2, ret, id.local);
|
||||
Free(ret);
|
||||
ret = tmp;
|
||||
}
|
||||
if (id.server.hostname)
|
||||
{
|
||||
char *tmp = StrConcat(3, ret, ":", id.server.hostname);
|
||||
Free(ret);
|
||||
ret = tmp;
|
||||
}
|
||||
if (id.server.port)
|
||||
{
|
||||
char *tmp = StrConcat(3, ret, ":", id.server.port);
|
||||
Free(ret);
|
||||
ret = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -68,5 +68,12 @@ extern int ValidCommonID(char *, char);
|
|||
*/
|
||||
extern void CommonIDFree(CommonID id);
|
||||
|
||||
/**
|
||||
* Recompose a Common ID into a string which lives in the heap, and must
|
||||
* therefore be freed with
|
||||
* .Fn Free .
|
||||
*/
|
||||
extern char * ParserRecomposeCommonID(CommonID);
|
||||
|
||||
|
||||
#endif /* TELODENDRIA_PARSER_H */
|
||||
|
|
Loading…
Reference in a new issue