diff --git a/src/Parser.c b/src/Parser.c index f120578..fbb6851 100644 --- a/src/Parser.c +++ b/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; +} diff --git a/src/include/Parser.h b/src/include/Parser.h index fb9ede5..405caf1 100644 --- a/src/include/Parser.h +++ b/src/include/Parser.h @@ -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 */