From d9c55d41a6c014ef90fe42ffeef5f5b66409b111 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 20 Nov 2022 14:40:56 +0100 Subject: Extract domain from JID with parser function It is mandatory to have an IP address to dial a TCP connection. FOr this purpose the JID which is given by the user has to be converted into a FQDN and then translated to an IP via DNS. The function added with this commit implements this first part. The extraction of the domain (more precisely the FQDN) from the JID. --- xmpp.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xmpp.c b/xmpp.c index be677fc..865b235 100644 --- a/xmpp.c +++ b/xmpp.c @@ -2,16 +2,50 @@ #include #include +#include +#include +#include +/* + * Get the domainpart of the Jabber ID (JID). + * See https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 for details. + */ +char *domainpart(char *jid) +{ + int start = 0; // inclusive + int stop = strlen(jid); // exclusive + + for(int i=0; i