From d754d919565946442d0d83da0c88986b166d386d Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 2 Sep 2022 18:09:03 +0100 Subject: Deal with servers only sending a nick rather than nick!user@host as the last token of greeting 001. --- TODO | 4 ++++ functions.c | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 201eaf6..d31dc59 100644 --- a/TODO +++ b/TODO @@ -31,4 +31,8 @@ Support ban list when requesting /mode #channel +b (commands 367 and 368 at leas Or if there are no bans then just 368: :irc.tghost.co.uk 368 l_bratch #foo :End of Channel Ban List +Other IRC clients log stuff like "Mar 31 16:58:15 * #foobar :No topic is set." - can/should we? + +Some servers have a user send ^VERSION^ upon connection - (optionally?) respond to it. + Crash when requesting 30 hour replay. diff --git a/functions.c b/functions.c index 6d0e8a1..6bd8a9c 100644 --- a/functions.c +++ b/functions.c @@ -324,8 +324,13 @@ void updatenickuserhost(char *nickuserhost, char *nick) { } } + // No bang found... if (bangpos == -1) { - debugprint(DEBUG_FULL, "updatenickuserhost(): no bang found in existing nickuserhost, returning!\n"); + // ...assume the old nickuserhost was just the nick (e.g. if the server's greeting + // 001 ended with nick rather than nick!user@host) then just update it directly + debugprint(DEBUG_FULL, "updatenickuserhost(): no bang found in existing nickuserhost, assuming a nick only nickuserhost\n"); + strcpy(nickuserhost, nick); + debugprint(DEBUG_FULL, "updatenickuserhost(): new (nick only) nickuserhost '%s', length '%ld'.\n", nickuserhost, strlen(nickuserhost)); return; } @@ -344,6 +349,13 @@ void updatenickuserhost(char *nickuserhost, char *nick) { void updategreetings(char *greeting001, char *greeting002, char *greeting003, char *greeting004, char *greeting005a, char *greeting005b, char *greeting005c, char *newnickuserhost, char *oldnickuserhost, char *newnick, char *oldnick) { debugprint(DEBUG_FULL, "updategreetings(): updating greetings with new nickuserhost '%s' and nick '%s'.\n", newnickuserhost, newnick); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting001: '%s'.\n", greeting001); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting002: '%s'.\n", greeting002); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting003: '%s'.\n", greeting003); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting004: '%s'.\n", greeting004); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting005a: '%s'.\n", greeting005a); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting005b: '%s'.\n", greeting005b); + debugprint(DEBUG_FULL, "updategreetings(): existing greeting005c: '%s'.\n", greeting005c); // nickuserhost and greeting001's final component first // (final component as in ":servername 001 nick :Blablabla final!com@ponent" @@ -361,6 +373,16 @@ void updategreetings(char *greeting001, char *greeting002, char *greeting003, ch ret = strstr(greeting001, oldnickuserhostcpy); int pos = ret - greeting001; + // Ensure that was the last occurrence in the greeting + debugprint(DEBUG_FULL, "updategreetings(): entering last occurrence check loop...\n"); + while (ret) { + ret = strstr(greeting001 + pos + strlen(oldnickuserhostcpy), oldnickuserhostcpy); + if (!ret) { + break; + } + pos = ret - greeting001; + } + // Terminate greeting001 where the nickuserhost begins greeting001[pos] = '\0'; -- cgit v1.2.3