git-svn: trunk@543
Nigel Horne authored on 2004/05/07 03:01:25... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.54 2004/05/06 18:01:25 nigelhorne |
|
21 |
+ * Force attachments marked as RFC822 messages to be scanned |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.53 2004/04/29 08:59:24 nigelhorne |
21 | 24 |
* Tidied up SetDispositionType |
22 | 25 |
* |
... | ... |
@@ -156,7 +159,7 @@ |
156 | 156 |
* uuencodebegin() no longer static |
157 | 157 |
* |
158 | 158 |
*/ |
159 |
-static char const rcsid[] = "$Id: message.c,v 1.53 2004/04/29 08:59:24 nigelhorne Exp $"; |
|
159 |
+static char const rcsid[] = "$Id: message.c,v 1.54 2004/05/06 18:01:25 nigelhorne Exp $"; |
|
160 | 160 |
|
161 | 161 |
#if HAVE_CONFIG_H |
162 | 162 |
#include "clamav-config.h" |
... | ... |
@@ -694,9 +697,9 @@ messageGetEncoding(const message *m) |
694 | 694 |
} |
695 | 695 |
|
696 | 696 |
/* |
697 |
- * Add the given line to the current message |
|
697 |
+ * Add the given line to the end of the given message |
|
698 | 698 |
* If needed a copy of the given line is taken which the caller must free |
699 |
- * Line should not be terminated by a \n |
|
699 |
+ * Line must not be terminated by a \n |
|
700 | 700 |
*/ |
701 | 701 |
int |
702 | 702 |
messageAddLine(message *m, const char *line, int takeCopy) |
... | ... |
@@ -729,8 +732,6 @@ messageAddLine(message *m, const char *line, int takeCopy) |
729 | 729 |
m->body_last->t_text = (char *)line; |
730 | 730 |
} |
731 | 731 |
|
732 |
- assert(m->body_first != NULL); |
|
733 |
- |
|
734 | 732 |
/* |
735 | 733 |
* See if this line marks the start of a non MIME inclusion that |
736 | 734 |
* will need to be scanned |
... | ... |
@@ -758,6 +759,38 @@ messageAddLine(message *m, const char *line, int takeCopy) |
758 | 758 |
} |
759 | 759 |
|
760 | 760 |
/* |
761 |
+ * Add the given line to the start of the given message |
|
762 |
+ * A copy of the given line is taken which the caller must free |
|
763 |
+ * Line must not be terminated by a \n |
|
764 |
+ */ |
|
765 |
+int |
|
766 |
+messageAddLineAtTop(message *m, const char *line) |
|
767 |
+{ |
|
768 |
+ text *oldfirst; |
|
769 |
+ |
|
770 |
+ assert(m != NULL); |
|
771 |
+ |
|
772 |
+ if(m->body_first == NULL) |
|
773 |
+ return messageAddLine(m, line, 1); |
|
774 |
+ |
|
775 |
+ oldfirst = m->body_first; |
|
776 |
+ m->body_first = (text *)cli_malloc(sizeof(text)); |
|
777 |
+ if(m->body_first == NULL) { |
|
778 |
+ m->body_first = oldfirst; |
|
779 |
+ return -1; |
|
780 |
+ } |
|
781 |
+ |
|
782 |
+ m->body_first->t_next = oldfirst; |
|
783 |
+ m->body_first->t_text = strdup((line) ? line : ""); |
|
784 |
+ |
|
785 |
+ if(m->body_first->t_text == NULL) { |
|
786 |
+ cli_errmsg("messageAddLineAtTop: out of memory\n"); |
|
787 |
+ return -1; |
|
788 |
+ } |
|
789 |
+ return 1; |
|
790 |
+} |
|
791 |
+ |
|
792 |
+/* |
|
761 | 793 |
* Returns a pointer to the body of the message. Note that it does NOT return |
762 | 794 |
* a copy of the data |
763 | 795 |
*/ |
... | ... |
@@ -16,6 +16,9 @@ |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
* |
18 | 18 |
* $Log: message.h,v $ |
19 |
+ * Revision 1.11 2004/05/06 18:01:25 nigelhorne |
|
20 |
+ * Force attachments marked as RFC822 messages to be scanned |
|
21 |
+ * |
|
19 | 22 |
* Revision 1.10 2004/04/05 12:04:56 nigelhorne |
20 | 23 |
* Scan attachments with no filename |
21 | 24 |
* |
... | ... |
@@ -75,6 +78,7 @@ const char *messageFindArgument(const message *m, const char *variable); |
75 | 75 |
void messageSetEncoding(message *m, const char *enctype); |
76 | 76 |
encoding_type messageGetEncoding(const message *m); |
77 | 77 |
int messageAddLine(message *m, const char *line, int takeCopy); |
78 |
+int messageAddLineAtTop(message *m, const char *line); |
|
78 | 79 |
const text *messageGetBody(const message *m); |
79 | 80 |
void messageClean(message *m); |
80 | 81 |
blob *messageToBlob(message *m); |