Browse code

Now compiles in machines with libcurl but without threads

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@913 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/09/21 17:16:29
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Sep 21 09:15:48 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Now compiles in machines with libcurl but without
4
+				posix threads
5
+
1 6
 Tue Sep 21 03:25:59 CEST 2004 (tk)
2 7
 ----------------------------------
3 8
   * libclamav/filetypes.c: fix JPEG rule
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.135  2004/09/21 08:14:00  nigelhorne
21
+ * Now compiles in machines with libcurl but without threads
22
+ *
20 23
  * Revision 1.134  2004/09/20 17:08:43  nigelhorne
21 24
  * Some performance enhancements
22 25
  *
... ...
@@ -390,14 +393,14 @@
390 390
  * Compilable under SCO; removed duplicate code with message.c
391 391
  *
392 392
  */
393
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.134 2004/09/20 17:08:43 nigelhorne Exp $";
393
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.135 2004/09/21 08:14:00 nigelhorne Exp $";
394 394
 
395 395
 #if HAVE_CONFIG_H
396 396
 #include "clamav-config.h"
397 397
 #endif
398 398
 
399 399
 #ifndef	CL_DEBUG
400
-/*#define	NDEBUG	/* map CLAMAV debug onto standard */
400
+#define	NDEBUG	/* map CLAMAV debug onto standard */
401 401
 #endif
402 402
 
403 403
 #ifdef CL_THREAD_SAFE
... ...
@@ -858,9 +861,15 @@ parseEmailHeaders(const message *m, const table_t *rfc821)
858 858
 				const char *ptr;
859 859
 				char *copy = strdup(buffer);
860 860
 
861
+#ifdef	CL_THREAD_SAFE
861 862
 				for(ptr = strtok_r(copy, ";", &strptr); ptr; ptr = strtok_r(NULL, ":", &strptr))
862 863
 					if(strchr(ptr, '='))
863 864
 						messageAddArguments(ret, ptr);
865
+#else
866
+				for(ptr = strtok(copy, ";"); ptr; ptr = strtok(NULL, ":"))
867
+					if(strchr(ptr, '='))
868
+						messageAddArguments(ret, ptr);
869
+#endif
864 870
 				free(copy);
865 871
 			} else {
866 872
 				Xheader = (bool)(buffer[0] == 'X');
... ...
@@ -930,10 +939,18 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821)
930 930
 	tokenseparater[0] = *separater;
931 931
 	tokenseparater[1] = '\0';
932 932
 
933
+#ifdef	CL_THREAD_SAFE
933 934
 	cmd = strtok_r(copy, tokenseparater, &strptr);
935
+#else
936
+	cmd = strtok(copy, tokenseparater);
937
+#endif
934 938
 
935 939
 	if(cmd && (strstrip(cmd) > 0)) {
940
+#ifdef	CL_THREAD_SAFE
936 941
 		char *arg = strtok_r(NULL, "", &strptr);
942
+#else
943
+		char *arg = strtok(NULL, "");
944
+#endif
937 945
 
938 946
 		if(arg)
939 947
 			/*
... ...
@@ -2213,7 +2230,11 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c
2213 2213
 						 * Content-Type: multipart/mixed foo/bar
2214 2214
 						 */
2215 2215
 						for(;;) {
2216
+#ifdef	CL_THREAD_SAFE
2216 2217
 							int set = messageSetMimeType(m, strtok_r(s, "/", &strptr));
2218
+#else
2219
+							int set = messageSetMimeType(m, strtok(s, "/"));
2220
+#endif
2217 2221
 
2218 2222
 
2219 2223
 							/*
... ...
@@ -2222,7 +2243,11 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c
2222 2222
 							 * the mime type but before
2223 2223
 							 * the ;
2224 2224
 							 */
2225
+#ifdef	CL_THREAD_SAFE
2225 2226
 							s = strtok_r(NULL, ";", &strptr);
2227
+#else
2228
+							s = strtok(NULL, ";");
2229
+#endif
2226 2230
 							if(s == NULL)
2227 2231
 								break;
2228 2232
 							if(set) {
... ...
@@ -2272,11 +2297,19 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c
2272 2272
 			messageSetEncoding(m, copy);
2273 2273
 			break;
2274 2274
 		case CONTENT_DISPOSITION:
2275
+#ifdef	CL_THREAD_SAFE
2275 2276
 			arg = strtok_r(copy, ";", &strptr);
2276 2277
 			if(arg && *arg) {
2277 2278
 				messageSetDispositionType(m, arg);
2278 2279
 				messageAddArgument(m, strtok_r(NULL, "\r\n", &strptr));
2279 2280
 			}
2281
+#else
2282
+			arg = strtok(copy, ";");
2283
+			if(arg && *arg) {
2284
+				messageSetDispositionType(m, arg);
2285
+				messageAddArgument(m, strtok(NULL, "\r\n"));
2286
+			}
2287
+#endif
2280 2288
 	}
2281 2289
 	free(ptr);
2282 2290
 
... ...
@@ -2606,7 +2639,6 @@ static void *
2606 2606
 #ifdef	CL_THREAD_SAFE
2607 2607
 getURL(void *a)
2608 2608
 #else
2609
-static void
2610 2609
 getURL(struct arg *arg)
2611 2610
 #endif
2612 2611
 {