git-svn: trunk@1143
Nigel Horne authored on 2004/11/29 07:06:40... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: binhex.c,v $ |
20 |
+ * Revision 1.9 2004/11/28 22:06:39 nigelhorne |
|
21 |
+ * Tidy space only headers code |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.8 2004/11/28 21:05:50 nigelhorne |
21 | 24 |
* Handle headers with only spaces |
22 | 25 |
* |
... | ... |
@@ -39,7 +42,7 @@ |
39 | 39 |
* First draft of binhex.c |
40 | 40 |
* |
41 | 41 |
*/ |
42 |
-static char const rcsid[] = "$Id: binhex.c,v 1.8 2004/11/28 21:05:50 nigelhorne Exp $"; |
|
42 |
+static char const rcsid[] = "$Id: binhex.c,v 1.9 2004/11/28 22:06:39 nigelhorne Exp $"; |
|
43 | 43 |
|
44 | 44 |
#include "clamav.h" |
45 | 45 |
|
... | ... |
@@ -127,7 +130,7 @@ cli_binhex(const char *dir, int desc) |
127 | 127 |
|
128 | 128 |
/*puts(line);*/ |
129 | 129 |
|
130 |
- if(messageAddStr(m, line, 1) < 0) |
|
130 |
+ if(messageAddStr(m, line) < 0) |
|
131 | 131 |
break; |
132 | 132 |
|
133 | 133 |
buf = ++ptr; |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.194 2004/11/28 22:06:38 nigelhorne |
|
21 |
+ * Tidy space only headers code |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.193 2004/11/28 21:05:50 nigelhorne |
21 | 24 |
* Handle headers with only spaces |
22 | 25 |
* |
... | ... |
@@ -567,7 +570,7 @@ |
567 | 567 |
* Compilable under SCO; removed duplicate code with message.c |
568 | 568 |
* |
569 | 569 |
*/ |
570 |
-static char const rcsid[] = "$Id: mbox.c,v 1.193 2004/11/28 21:05:50 nigelhorne Exp $"; |
|
570 |
+static char const rcsid[] = "$Id: mbox.c,v 1.194 2004/11/28 22:06:38 nigelhorne Exp $"; |
|
571 | 571 |
|
572 | 572 |
#if HAVE_CONFIG_H |
573 | 573 |
#include "clamav-config.h" |
... | ... |
@@ -955,7 +958,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
955 | 955 |
cli_dbgmsg("Finished processing message\n"); |
956 | 956 |
} else |
957 | 957 |
lastLineWasEmpty = (bool)(buffer[0] == '\0'); |
958 |
- if(messageAddStr(m, buffer, 1) < 0) |
|
958 |
+ if(messageAddStr(m, buffer) < 0) |
|
959 | 959 |
break; |
960 | 960 |
} while(fgets(buffer, sizeof(buffer) - 1, fd) != NULL); |
961 | 961 |
|
... | ... |
@@ -1011,9 +1014,9 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1011 | 1011 |
* headers, otherwise they'll be treated as the end of |
1012 | 1012 |
* header marker |
1013 | 1013 |
*/ |
1014 |
- if(messageAddStr(m, ptr, !inHeader) < 0) |
|
1014 |
+ if(messageAddStr(m, ptr) < 0) |
|
1015 | 1015 |
break; |
1016 |
- if(*ptr == '\n') |
|
1016 |
+ if(*ptr == '\0') |
|
1017 | 1017 |
inHeader = 0; |
1018 | 1018 |
} while(fgets(buffer, sizeof(buffer) - 1, fd) != NULL); |
1019 | 1019 |
} |
... | ... |
@@ -1905,7 +1908,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1905 | 1905 |
/* |
1906 | 1906 |
* No plain text version |
1907 | 1907 |
*/ |
1908 |
- messageAddStr(aMessage, "No plain text alternative", 0); |
|
1908 |
+ messageAddStr(aMessage, "No plain text alternative"); |
|
1909 | 1909 |
assert(messageGetBody(aMessage) != NULL); |
1910 | 1910 |
break; |
1911 | 1911 |
case TEXT: |
... | ... |
@@ -2966,7 +2969,7 @@ rfc2047(const char *in) |
2966 | 2966 |
m = messageCreate(); |
2967 | 2967 |
if(m == NULL) |
2968 | 2968 |
break; |
2969 |
- messageAddStr(m, enctext, 0); |
|
2969 |
+ messageAddStr(m, enctext); |
|
2970 | 2970 |
free(enctext); |
2971 | 2971 |
switch(encoding) { |
2972 | 2972 |
case 'q': |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.126 2004/11/28 22:06:39 nigelhorne |
|
21 |
+ * Tidy space only headers code |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.125 2004/11/28 21:05:49 nigelhorne |
21 | 24 |
* Handle headers with only spaces |
22 | 25 |
* |
... | ... |
@@ -372,7 +375,7 @@ |
372 | 372 |
* uuencodebegin() no longer static |
373 | 373 |
* |
374 | 374 |
*/ |
375 |
-static char const rcsid[] = "$Id: message.c,v 1.125 2004/11/28 21:05:49 nigelhorne Exp $"; |
|
375 |
+static char const rcsid[] = "$Id: message.c,v 1.126 2004/11/28 22:06:39 nigelhorne Exp $"; |
|
376 | 376 |
|
377 | 377 |
#if HAVE_CONFIG_H |
378 | 378 |
#include "clamav-config.h" |
... | ... |
@@ -1128,43 +1131,35 @@ messageAddLine(message *m, line_t *line) |
1128 | 1128 |
* Line must not be terminated by a \n |
1129 | 1129 |
*/ |
1130 | 1130 |
int |
1131 |
-messageAddStr(message *m, const char *data, int stripSpaces) |
|
1131 |
+messageAddStr(message *m, const char *data) |
|
1132 | 1132 |
{ |
1133 | 1133 |
line_t *repeat = NULL; |
1134 | 1134 |
|
1135 | 1135 |
assert(m != NULL); |
1136 | 1136 |
|
1137 |
-#if 0 /* Not sure why this doesn't work, it would save some RAM */ |
|
1138 | 1137 |
if(data) { |
1139 |
- int iswhite = 1; |
|
1140 |
- const char *p; |
|
1141 |
- |
|
1142 |
- for(p = data; *p != '\0'; p++) |
|
1143 |
- if(!isspace(*p)) { |
|
1144 |
- iswhite = 0; |
|
1145 |
- break; |
|
1146 |
- } |
|
1147 |
- if(iswhite) { |
|
1148 |
- /*cli_dbgmsg("messageAddStr: empty line: '%s'\n", data);*/ |
|
1149 |
- data = (stripSpaces) ? NULL : " "; |
|
1150 |
- } |
|
1151 |
- } |
|
1152 |
-#else |
|
1153 |
- if(stripSpaces && data) { |
|
1154 |
- int iswhite = 1; |
|
1155 |
- const char *p; |
|
1138 |
+ if(*data == '\0') |
|
1139 |
+ data = NULL; |
|
1140 |
+ else { |
|
1141 |
+ /* |
|
1142 |
+ * If it's only white space, just store one space to |
|
1143 |
+ * save memory. You must store something since it may |
|
1144 |
+ * be a header line |
|
1145 |
+ */ |
|
1146 |
+ int iswhite = 1; |
|
1147 |
+ const char *p; |
|
1156 | 1148 |
|
1157 |
- for(p = data; *p != '\0'; p++) |
|
1158 |
- if(!isspace(*p)) { |
|
1159 |
- iswhite = 0; |
|
1160 |
- break; |
|
1149 |
+ for(p = data; *p; p++) |
|
1150 |
+ if(!isspace(*p)) { |
|
1151 |
+ iswhite = 0; |
|
1152 |
+ break; |
|
1153 |
+ } |
|
1154 |
+ if(iswhite) { |
|
1155 |
+ /*cli_dbgmsg("messageAddStr: empty line: '%s'\n", data);*/ |
|
1156 |
+ data = " "; |
|
1161 | 1157 |
} |
1162 |
- if(iswhite) { |
|
1163 |
- /*cli_dbgmsg("messageAddStr: empty line: '%s'\n", data);*/ |
|
1164 |
- data = NULL; |
|
1165 | 1158 |
} |
1166 | 1159 |
} |
1167 |
-#endif |
|
1168 | 1160 |
|
1169 | 1161 |
if(m->body_first == NULL) |
1170 | 1162 |
m->body_last = m->body_first = (text *)cli_malloc(sizeof(text)); |
... | ... |
@@ -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.24 2004/11/28 22:06:40 nigelhorne |
|
20 |
+ * Tidy space only headers code |
|
21 |
+ * |
|
19 | 22 |
* Revision 1.23 2004/11/28 21:05:50 nigelhorne |
20 | 23 |
* Handle headers with only spaces |
21 | 24 |
* |
... | ... |
@@ -120,7 +123,7 @@ const char *messageFindArgument(const message *m, const char *variable); |
120 | 120 |
void messageSetEncoding(message *m, const char *enctype); |
121 | 121 |
encoding_type messageGetEncoding(const message *m); |
122 | 122 |
int messageAddLine(message *m, line_t *line); |
123 |
-int messageAddStr(message *m, const char *data, int stripSpaces); |
|
123 |
+int messageAddStr(message *m, const char *data); |
|
124 | 124 |
int messageAddStrAtTop(message *m, const char *data); |
125 | 125 |
const text *messageGetBody(const message *m); |
126 | 126 |
void messageClean(message *m); |