From 363fc8c5e234c9c04d002ac6e72a8d7fa280cd61 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 7 Mar 2008 07:00:47 +0000 Subject: [PATCH] Fixed display of inline images and truncated ASCII attachments in list mode SVN revision: 2072 --- src/elogd.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index ca030679..01d5c931 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -16455,7 +16455,8 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, char str[NAME_LENGTH], ref[256], *nowrap, sclass[80], format[256], file_name[MAX_PATH_LENGTH], *slist, *svalue, comment[256]; char display[NAME_LENGTH], attr_icon[80]; - int i, j, i_line, index, colspan, n_attachments, line_len, thumb_status, max_line_len; + int i, j, i_line, index, colspan, n_attachments, line_len, thumb_status, max_line_len, n_lines, + max_n_lines; BOOL skip_comma; FILE *f; struct tm *pts; @@ -17034,8 +17035,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, if (show_attachments && attachment[index][0]) { /* check if attachment is inlined */ - sprintf(str, "[img]elog:/%d[/img]", index + 1); - if (strieq(encoding, "ELCode") && stristr(text, str)) + if (is_inline_attachment(encoding, message_id, text, index, attachment[index])) continue; strlcpy(str, attachment[index], sizeof(str)); @@ -17117,23 +17117,53 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, !chkext(attachment[index], ".HTM") && !chkext(attachment[index], ".HTML") && show_attachments) { + rsprintf("\n"); + /* display attachment */ - rsprintf("
", colspan);
+                        rsprintf("\n", colspan);
+
+                        /* anchor for references */
+                        rsprintf("\n", index + 1);
+
+                        /* display attachment */
+
+                        if (!chkext(attachment[index], ".HTML"))
+                           rsprintf("
");
 
                         strlcpy(file_name, lbs->data_dir, sizeof(file_name));
                         strlcat(file_name, attachment[index], sizeof(file_name));
 
                         f = fopen(file_name, "rt");
+                  
+                        n_lines = 0;
+                        if (getcfg(lbs->name, "Attachment lines", str, sizeof(str)))
+                           max_n_lines = atoi(str);
+                        else
+                           max_n_lines = 300;
+
                         if (f != NULL) {
                            while (!feof(f)) {
                               str[0] = 0;
                               fgets(str, sizeof(str), f);
-                              rsputs2(lbs, absolute_link, str);
+
+                              if (n_lines < max_n_lines) {
+                                 if (!chkext(attachment[index], ".HTML"))
+                                    rsputs2(lbs, absolute_link, str);
+                                 else
+                                    rsputs(str);
+                              }
+                              n_lines++;
                            }
                            fclose(f);
                         }
 
-                        rsprintf("
\n"); + if (!chkext(attachment[index], ".HTML")) + rsprintf("
"); + rsprintf("\n"); + if (max_n_lines == 0) + rsprintf("%d lines\n", n_lines); + else if (n_lines > max_n_lines) + rsprintf("... %d more lines ...\n", n_lines - max_n_lines); } rsprintf("\n"); }