Moved the remaining help files for the text client out of the server and into the...
[citadel.git] / textclient / src / messages.c
index 515203a27d37ef6278d1e9af9b6e379daafb05d1..1337b029c968f4be1d7778c8a78b89a6fd587124 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Text client functions for reading and writing of messages
  *
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2017 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
 
 #include <stdarg.h>
 #include <libcitadel.h>
-///#include "citadel.h"
 #include "citadel_ipc.h"
 #include "citadel_decls.h"
 #include "messages.h"
 #include "commands.h"
 #include "tuiconfig.h"
 #include "rooms.h"
-//#ifndef HAVE_SNPRINTF
-///#include "snprintf.h"
-//#endif
 #include "screen.h"
 
 #define MAXWORDBUF SIZ
@@ -439,7 +435,7 @@ int read_message(CtdlIPC *ipc,
        FILE *dest) /* Destination file, NULL for screen */
 {
        char buf[SIZ];
-       char now[SIZ];
+       char now[256];
        int format_type = 0;
        int fr = 0;
        int nhdr = 0;
@@ -542,7 +538,9 @@ int read_message(CtdlIPC *ipc,
                        scr_printf(" ****");
                }
        } else {
-               fmt_date(now, sizeof now, message->time, 0);
+               struct tm thetime;
+               localtime_r(&message->time, &thetime);
+               strftime(now, sizeof now, "%F %R", &thetime);
                if (dest) {
                        fprintf(dest, "%s from %s ", now, message->author);
                        if (!IsEmptyStr(message->email)) {
@@ -687,22 +685,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;
                }
        }
 
@@ -874,7 +880,7 @@ int client_make_message(CtdlIPC *ipc,
        FILE *fp;
        int a, b, e_ex_code;
        long beg;
-       char datestr[SIZ];
+       char datestr[256];
        char header[SIZ];
        int cksum = 0;
 
@@ -883,7 +889,10 @@ int client_make_message(CtdlIPC *ipc,
                mode = 0;
        }
 
-       fmt_date(datestr, sizeof datestr, time(NULL), 0);
+       struct tm thetime;
+       time_t now = time(NULL);
+       localtime_r(&now, &thetime);
+       strftime(datestr, sizeof datestr, "%F %R", &thetime);
        header[0] = 0;
 
        if (room_flags & QR_ANONONLY && !recipient) {
@@ -1202,7 +1211,9 @@ int entmsg(CtdlIPC *ipc,
 
        /* If the user is a dumbass, tell them how to type. */
        if ((userflags & US_EXPERT) == 0) {
-               formout(ipc, "entermsg");
+               scr_printf("Entering message.  Word wrap will give you soft linebreaks.  Pressing the\n");
+               scr_printf("'enter' key will give you a hard linebreak and an indent.  Press 'enter' twice\n");
+               scr_printf("when finished.\n");
        }
 
        /* Handle the selection of a recipient, if necessary. */