From 6fcf52d210b8b1da3652f2e3384f67989b247e33 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 4 Oct 2013 22:03:32 -0400 Subject: [PATCH] Amend the URL View command in the text client to find not only http: but also https: and ftp: as well --- textclient/src/messages.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/textclient/src/messages.c b/textclient/src/messages.c index 515203a27..5b694e85c 100644 --- a/textclient/src/messages.c +++ b/textclient/src/messages.c @@ -687,22 +687,30 @@ int read_message(CtdlIPC *ipc, } /* Extract URL's */ + static char *urlprefixes[] = { + "http://", + "https://", + "ftp://" + }; + int p = 0; num_urls = 0; /* Start with a clean slate */ - searchptr = message->text; - while ( (searchptr != NULL) && (num_urls < MAXURLS) ) { - searchptr = strstr(searchptr, "http://"); - if (searchptr != NULL) { - safestrncpy(urls[num_urls], searchptr, sizeof(urls[num_urls])); - for (i = 0; i < strlen(urls[num_urls]); i++) { - ch = urls[num_urls][i]; - if (ch == '>' || ch == '\"' || ch == ')' || - ch == ' ' || ch == '\n') { - urls[num_urls][i] = 0; - break; + for (p=0; p<(sizeof urlprefixes / sizeof(char *)); ++p) { + searchptr = message->text; + while ( (searchptr != NULL) && (num_urls < MAXURLS) ) { + searchptr = strstr(searchptr, urlprefixes[p]); + if (searchptr != NULL) { + safestrncpy(urls[num_urls], searchptr, sizeof(urls[num_urls])); + for (i = 0; i < strlen(urls[num_urls]); i++) { + ch = urls[num_urls][i]; + if (ch == '>' || ch == '\"' || ch == ')' || + ch == ' ' || ch == '\n') { + urls[num_urls][i] = 0; + break; + } } + num_urls++; + ++searchptr; } - num_urls++; - ++searchptr; } } -- 2.30.2