Browse code

make regex available in libclamav_internal_utils.la, split others.c instead of using #ifdef CLI_MEMFUNS_ONLY.

git-svn: trunk@4553

Török Edvin authored on 2008/12/12 17:20:16
Showing 5 changed files
... ...
@@ -1,3 +1,10 @@
1
+Fri Dec 12 10:28:04 EET 2008 (edwin)
2
+------------------------------------
3
+ * libclamav/Makefile.am, libclamav/Makefile.in, libclamav/others.c,
4
+ libclamav/others_common.c: make regex available in
5
+ libclamav_internal_utils.la, split others.c instead of using #ifdef
6
+ CLI_MEMFUNS_ONLY.
7
+
1 8
 Thu Dec 11 19:09:36 CET 2008 (acab)
2 9
 -----------------------------------
3 10
  * freshclam/dns.c: small fix to previous commit (bb#1303)
... ...
@@ -75,8 +75,8 @@ IFACEDEP = libclamunrar_iface.la
75 75
 endif
76 76
 
77 77
 
78
-libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@
79
-libclamav_la_DEPENDENCIES =  @LIBLTDL@ $(IFACEDEP)
78
+libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@
79
+libclamav_la_DEPENDENCIES =  @LIBLTDL@ $(IFACEDEP) libclamav_internal_utils.la
80 80
 libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ -no-undefined
81 81
 
82 82
 if VERSIONSCRIPT
... ...
@@ -103,8 +103,6 @@ libclamav_la_SOURCES = \
103 103
 	cvd.h \
104 104
 	dsig.c \
105 105
 	dsig.h \
106
-        str.c \
107
-	str.h \
108 106
 	scanners.c \
109 107
 	scanners.h \
110 108
 	textdet.c \
... ...
@@ -180,16 +178,6 @@ libclamav_la_SOURCES = \
180 180
 	tnef.h \
181 181
 	autoit.c \
182 182
 	autoit.h \
183
-	regex/strlcpy.c \
184
-	regex/regcomp.c \
185
-	regex/regerror.c \
186
-	regex/regexec.c \
187
-	regex/regfree.c \
188
-	regex/cclass.h \
189
-	regex/cname.h \
190
-	regex/regex.h \
191
-	regex/regex2.h \
192
-	regex/utils.h \
193 183
 	unarj.c \
194 184
 	unarj.h \
195 185
 	nsis/bzlib.c \
... ...
@@ -284,11 +272,21 @@ version.h.tmp:
284 284
 
285 285
 libclamav_internal_utils_la_SOURCES=str.c \
286 286
 				    str.h \
287
-				    others.c \
288
-				    others.h
287
+				    others_common.c \
288
+				    others.h \
289
+				    regex/strlcpy.c \
290
+				    regex/regcomp.c \
291
+				    regex/regerror.c \
292
+				    regex/regexec.c \
293
+				    regex/regfree.c \
294
+				    regex/cclass.h \
295
+				    regex/cname.h \
296
+				    regex/regex.h \
297
+				    regex/regex2.h \
298
+				    regex/utils.h
289 299
 
290 300
 libclamav_internal_utils_la_LDFLAGS=-static
291
-libclamav_internal_utils_la_CFLAGS=-DCLI_MEMFUNSONLY
301
+libclamav_internal_utils_la_CFLAGS=  -fPIC -DPIC
292 302
 lib_LTLIBRARIES += libclamav.la
293 303
 noinst_LTLIBRARIES = libclamav_internal_utils.la
294 304
 EXTRA_DIST += regex/engine.c libclamav.map \
... ...
@@ -89,16 +89,15 @@ libLTLIBRARIES_INSTALL = $(INSTALL)
89 89
 LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
90 90
 @ENABLE_UNRAR_TRUE@am__DEPENDENCIES_1 = libclamunrar_iface.la
91 91
 am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
92
-	md5.lo others.lo readdb.lo cvd.lo dsig.lo str.lo scanners.lo \
92
+	md5.lo others.lo readdb.lo cvd.lo dsig.lo scanners.lo \
93 93
 	textdet.lo filetypes.lo rtf.lo blob.lo mbox.lo message.lo \
94 94
 	table.lo text.lo ole2_extract.lo vba_extract.lo msexpand.lo \
95 95
 	pe.lo disasm.lo upx.lo htmlnorm.lo chmunpack.lo rebuildpe.lo \
96 96
 	petite.lo wwunpack.lo unsp.lo aspack.lo packlibs.lo fsg.lo \
97 97
 	mew.lo upack.lo line.lo untar.lo unzip.lo inflate64.lo \
98
-	special.lo binhex.lo is_tar.lo tnef.lo autoit.lo strlcpy.lo \
99
-	regcomp.lo regerror.lo regexec.lo regfree.lo unarj.lo bzlib.lo \
100
-	nulsft.lo infblock.lo pdf.lo spin.lo yc.lo elf.lo sis.lo \
101
-	uuencode.lo phishcheck.lo phish_domaincheck_db.lo \
98
+	special.lo binhex.lo is_tar.lo tnef.lo autoit.lo unarj.lo \
99
+	bzlib.lo nulsft.lo infblock.lo pdf.lo spin.lo yc.lo elf.lo \
100
+	sis.lo uuencode.lo phishcheck.lo phish_domaincheck_db.lo \
102 101
 	phish_whitelist.lo regex_list.lo regex_suffix.lo mspack.lo \
103 102
 	cab.lo entconv.lo hashtab.lo dconf.lo lzma_iface.lo explode.lo \
104 103
 	textnorm.lo dlp.lo js-norm.lo uniq.lo version.lo mpool.lo
... ...
@@ -109,7 +108,12 @@ libclamav_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
109 109
 libclamav_internal_utils_la_LIBADD =
110 110
 am_libclamav_internal_utils_la_OBJECTS =  \
111 111
 	libclamav_internal_utils_la-str.lo \
112
-	libclamav_internal_utils_la-others.lo
112
+	libclamav_internal_utils_la-others_common.lo \
113
+	libclamav_internal_utils_la-strlcpy.lo \
114
+	libclamav_internal_utils_la-regcomp.lo \
115
+	libclamav_internal_utils_la-regerror.lo \
116
+	libclamav_internal_utils_la-regexec.lo \
117
+	libclamav_internal_utils_la-regfree.lo
113 118
 libclamav_internal_utils_la_OBJECTS =  \
114 119
 	$(am_libclamav_internal_utils_la_OBJECTS)
115 120
 libclamav_internal_utils_la_LINK = $(LIBTOOL) --tag=CC \
... ...
@@ -375,7 +379,7 @@ EXTRA_DIST = $(am__append_4) regex/engine.c libclamav.map \
375 375
 
376 376
 @ENABLE_UNRAR_TRUE@IFACELIBADD = -dlopen libclamunrar_iface.la
377 377
 @ENABLE_UNRAR_TRUE@IFACEDEP = libclamunrar_iface.la
378
-libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@
378
+libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@
379 379
 libclamav_la_DEPENDENCIES = @LIBLTDL@ $(IFACEDEP)
380 380
 libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ \
381 381
 	-no-undefined $(am__append_6)
... ...
@@ -398,8 +402,6 @@ libclamav_la_SOURCES = \
398 398
 	cvd.h \
399 399
 	dsig.c \
400 400
 	dsig.h \
401
-        str.c \
402
-	str.h \
403 401
 	scanners.c \
404 402
 	scanners.h \
405 403
 	textdet.c \
... ...
@@ -475,16 +477,6 @@ libclamav_la_SOURCES = \
475 475
 	tnef.h \
476 476
 	autoit.c \
477 477
 	autoit.h \
478
-	regex/strlcpy.c \
479
-	regex/regcomp.c \
480
-	regex/regerror.c \
481
-	regex/regexec.c \
482
-	regex/regfree.c \
483
-	regex/cclass.h \
484
-	regex/cname.h \
485
-	regex/regex.h \
486
-	regex/regex2.h \
487
-	regex/utils.h \
488 478
 	unarj.c \
489 479
 	unarj.h \
490 480
 	nsis/bzlib.c \
... ...
@@ -554,11 +546,21 @@ libclamav_la_SOURCES = \
554 554
 
555 555
 libclamav_internal_utils_la_SOURCES = str.c \
556 556
 				    str.h \
557
-				    others.c \
558
-				    others.h
557
+				    others_common.c \
558
+				    others.h \
559
+				    regex/strlcpy.c \
560
+				    regex/regcomp.c \
561
+				    regex/regerror.c \
562
+				    regex/regexec.c \
563
+				    regex/regfree.c \
564
+				    regex/cclass.h \
565
+				    regex/cname.h \
566
+				    regex/regex.h \
567
+				    regex/regex2.h \
568
+				    regex/utils.h
559 569
 
560 570
 libclamav_internal_utils_la_LDFLAGS = -static
561
-libclamav_internal_utils_la_CFLAGS = -DCLI_MEMFUNSONLY
571
+libclamav_internal_utils_la_CFLAGS = -fPIC -DPIC
562 572
 noinst_LTLIBRARIES = libclamav_internal_utils.la
563 573
 COMMON_CLEANFILES = version.h version.h.tmp *.gcda *.gcno lzma/*.gcda lzma/*.gcno
564 574
 @MAINTAINER_MODE_TRUE@BUILT_SOURCES = jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf
... ...
@@ -673,8 +675,13 @@ distclean-compile:
673 673
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inflate64.Plo@am__quote@
674 674
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@
675 675
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/js-norm.Plo@am__quote@
676
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-others.Plo@am__quote@
676
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-others_common.Plo@am__quote@
677
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regcomp.Plo@am__quote@
678
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regerror.Plo@am__quote@
679
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regexec.Plo@am__quote@
680
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-regfree.Plo@am__quote@
677 681
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-str.Plo@am__quote@
682
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-strlcpy.Plo@am__quote@
678 683
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line.Plo@am__quote@
679 684
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzma_iface.Plo@am__quote@
680 685
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matcher-ac.Plo@am__quote@
... ...
@@ -699,19 +706,13 @@ distclean-compile:
699 699
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phishcheck.Plo@am__quote@
700 700
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdb.Plo@am__quote@
701 701
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rebuildpe.Plo@am__quote@
702
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regcomp.Plo@am__quote@
703
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regerror.Plo@am__quote@
704 702
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_list.Plo@am__quote@
705 703
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_suffix.Plo@am__quote@
706
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Plo@am__quote@
707
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regfree.Plo@am__quote@
708 704
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtf.Plo@am__quote@
709 705
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanners.Plo@am__quote@
710 706
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sis.Plo@am__quote@
711 707
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/special.Plo@am__quote@
712 708
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spin.Plo@am__quote@
713
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Plo@am__quote@
714
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Plo@am__quote@
715 709
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Plo@am__quote@
716 710
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text.Plo@am__quote@
717 711
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textdet.Plo@am__quote@
... ...
@@ -760,41 +761,6 @@ distclean-compile:
760 760
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
761 761
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
762 762
 
763
-strlcpy.lo: regex/strlcpy.c
764
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.lo -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
765
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Plo
766
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/strlcpy.c' object='strlcpy.lo' libtool=yes @AMDEPBACKSLASH@
767
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
768
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
769
-
770
-regcomp.lo: regex/regcomp.c
771
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT regcomp.lo -MD -MP -MF $(DEPDIR)/regcomp.Tpo -c -o regcomp.lo `test -f 'regex/regcomp.c' || echo '$(srcdir)/'`regex/regcomp.c
772
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/regcomp.Tpo $(DEPDIR)/regcomp.Plo
773
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regcomp.c' object='regcomp.lo' libtool=yes @AMDEPBACKSLASH@
774
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
775
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o regcomp.lo `test -f 'regex/regcomp.c' || echo '$(srcdir)/'`regex/regcomp.c
776
-
777
-regerror.lo: regex/regerror.c
778
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT regerror.lo -MD -MP -MF $(DEPDIR)/regerror.Tpo -c -o regerror.lo `test -f 'regex/regerror.c' || echo '$(srcdir)/'`regex/regerror.c
779
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/regerror.Tpo $(DEPDIR)/regerror.Plo
780
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regerror.c' object='regerror.lo' libtool=yes @AMDEPBACKSLASH@
781
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
782
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o regerror.lo `test -f 'regex/regerror.c' || echo '$(srcdir)/'`regex/regerror.c
783
-
784
-regexec.lo: regex/regexec.c
785
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT regexec.lo -MD -MP -MF $(DEPDIR)/regexec.Tpo -c -o regexec.lo `test -f 'regex/regexec.c' || echo '$(srcdir)/'`regex/regexec.c
786
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/regexec.Tpo $(DEPDIR)/regexec.Plo
787
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regexec.c' object='regexec.lo' libtool=yes @AMDEPBACKSLASH@
788
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
789
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o regexec.lo `test -f 'regex/regexec.c' || echo '$(srcdir)/'`regex/regexec.c
790
-
791
-regfree.lo: regex/regfree.c
792
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT regfree.lo -MD -MP -MF $(DEPDIR)/regfree.Tpo -c -o regfree.lo `test -f 'regex/regfree.c' || echo '$(srcdir)/'`regex/regfree.c
793
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/regfree.Tpo $(DEPDIR)/regfree.Plo
794
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regfree.c' object='regfree.lo' libtool=yes @AMDEPBACKSLASH@
795
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
796
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o regfree.lo `test -f 'regex/regfree.c' || echo '$(srcdir)/'`regex/regfree.c
797
-
798 763
 bzlib.lo: nsis/bzlib.c
799 764
 @am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bzlib.lo -MD -MP -MF $(DEPDIR)/bzlib.Tpo -c -o bzlib.lo `test -f 'nsis/bzlib.c' || echo '$(srcdir)/'`nsis/bzlib.c
800 765
 @am__fastdepCC_TRUE@	mv -f $(DEPDIR)/bzlib.Tpo $(DEPDIR)/bzlib.Plo
... ...
@@ -830,12 +796,47 @@ libclamav_internal_utils_la-str.lo: str.c
830 830
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
831 831
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
832 832
 
833
-libclamav_internal_utils_la-others.lo: others.c
834
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-others.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-others.Tpo -c -o libclamav_internal_utils_la-others.lo `test -f 'others.c' || echo '$(srcdir)/'`others.c
835
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-others.Tpo $(DEPDIR)/libclamav_internal_utils_la-others.Plo
836
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='others.c' object='libclamav_internal_utils_la-others.lo' libtool=yes @AMDEPBACKSLASH@
833
+libclamav_internal_utils_la-others_common.lo: others_common.c
834
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-others_common.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-others_common.Tpo -c -o libclamav_internal_utils_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
835
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-others_common.Tpo $(DEPDIR)/libclamav_internal_utils_la-others_common.Plo
836
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='others_common.c' object='libclamav_internal_utils_la-others_common.lo' libtool=yes @AMDEPBACKSLASH@
837
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
838
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-others_common.lo `test -f 'others_common.c' || echo '$(srcdir)/'`others_common.c
839
+
840
+libclamav_internal_utils_la-strlcpy.lo: regex/strlcpy.c
841
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-strlcpy.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Tpo -c -o libclamav_internal_utils_la-strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
842
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Tpo $(DEPDIR)/libclamav_internal_utils_la-strlcpy.Plo
843
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/strlcpy.c' object='libclamav_internal_utils_la-strlcpy.lo' libtool=yes @AMDEPBACKSLASH@
844
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
845
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-strlcpy.lo `test -f 'regex/strlcpy.c' || echo '$(srcdir)/'`regex/strlcpy.c
846
+
847
+libclamav_internal_utils_la-regcomp.lo: regex/regcomp.c
848
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-regcomp.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-regcomp.Tpo -c -o libclamav_internal_utils_la-regcomp.lo `test -f 'regex/regcomp.c' || echo '$(srcdir)/'`regex/regcomp.c
849
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-regcomp.Tpo $(DEPDIR)/libclamav_internal_utils_la-regcomp.Plo
850
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regcomp.c' object='libclamav_internal_utils_la-regcomp.lo' libtool=yes @AMDEPBACKSLASH@
851
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
852
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-regcomp.lo `test -f 'regex/regcomp.c' || echo '$(srcdir)/'`regex/regcomp.c
853
+
854
+libclamav_internal_utils_la-regerror.lo: regex/regerror.c
855
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-regerror.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-regerror.Tpo -c -o libclamav_internal_utils_la-regerror.lo `test -f 'regex/regerror.c' || echo '$(srcdir)/'`regex/regerror.c
856
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-regerror.Tpo $(DEPDIR)/libclamav_internal_utils_la-regerror.Plo
857
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regerror.c' object='libclamav_internal_utils_la-regerror.lo' libtool=yes @AMDEPBACKSLASH@
858
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
859
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-regerror.lo `test -f 'regex/regerror.c' || echo '$(srcdir)/'`regex/regerror.c
860
+
861
+libclamav_internal_utils_la-regexec.lo: regex/regexec.c
862
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-regexec.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-regexec.Tpo -c -o libclamav_internal_utils_la-regexec.lo `test -f 'regex/regexec.c' || echo '$(srcdir)/'`regex/regexec.c
863
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-regexec.Tpo $(DEPDIR)/libclamav_internal_utils_la-regexec.Plo
864
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regexec.c' object='libclamav_internal_utils_la-regexec.lo' libtool=yes @AMDEPBACKSLASH@
865
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
866
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-regexec.lo `test -f 'regex/regexec.c' || echo '$(srcdir)/'`regex/regexec.c
867
+
868
+libclamav_internal_utils_la-regfree.lo: regex/regfree.c
869
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-regfree.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-regfree.Tpo -c -o libclamav_internal_utils_la-regfree.lo `test -f 'regex/regfree.c' || echo '$(srcdir)/'`regex/regfree.c
870
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-regfree.Tpo $(DEPDIR)/libclamav_internal_utils_la-regfree.Plo
871
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='regex/regfree.c' object='libclamav_internal_utils_la-regfree.lo' libtool=yes @AMDEPBACKSLASH@
837 872
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
838
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-others.lo `test -f 'others.c' || echo '$(srcdir)/'`others.c
873
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -c -o libclamav_internal_utils_la-regfree.lo `test -f 'regex/regfree.c' || echo '$(srcdir)/'`regex/regfree.c
839 874
 
840 875
 unrar15.lo: ../libclamunrar/unrar15.c
841 876
 @am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT unrar15.lo -MD -MP -MF $(DEPDIR)/unrar15.Tpo -c -o unrar15.lo `test -f '../libclamunrar/unrar15.c' || echo '$(srcdir)/'`../libclamunrar/unrar15.c
... ...
@@ -60,13 +60,7 @@
60 60
 
61 61
 #ifdef CL_THREAD_SAFE
62 62
 #  include <pthread.h>
63
-#ifndef CLI_MEMFUNSONLY
64 63
 static pthread_mutex_t cli_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER;
65
-#endif
66
-
67
-# ifndef HAVE_CTIME_R
68
-static pthread_mutex_t cli_ctime_mutex = PTHREAD_MUTEX_INITIALIZER;
69
-# endif
70 64
 
71 65
 #endif
72 66
 
... ...
@@ -92,40 +86,8 @@ static pthread_mutex_t cli_ctime_mutex = PTHREAD_MUTEX_INITIALIZER;
92 92
 #define       P_tmpdir        "C:\\WINDOWS\\TEMP"
93 93
 #endif
94 94
 
95
-uint8_t cli_debug_flag = 0;
96
-
97
-#ifndef CLI_MEMFUNSONLY
98 95
 static unsigned char name_salt[16] = { 16, 38, 97, 12, 8, 4, 72, 196, 217, 144, 33, 124, 18, 11, 17, 253 };
99
-#endif
100
-
101
-#define MSGCODE(x)					    \
102
-	va_list args;					    \
103
-	int len = sizeof(x) - 1;			    \
104
-	char buff[BUFSIZ];				    \
105
-    strncpy(buff, x, len);				    \
106
-    buff[BUFSIZ-1]='\0';				    \
107
-    va_start(args, str);				    \
108
-    vsnprintf(buff + len, sizeof(buff) - len, str, args);   \
109
-    buff[sizeof(buff) - 1] = '\0';			    \
110
-    fputs(buff, stderr);				    \
111
-    va_end(args)
112
-
113
-void cli_warnmsg(const char *str, ...)
114
-{
115
-    MSGCODE("LibClamAV Warning: ");
116
-}
117
-
118
-void cli_errmsg(const char *str, ...)
119
-{
120
-    MSGCODE("LibClamAV Error: ");
121
-}
122
-
123
-void cli_dbgmsg_internal(const char *str, ...)
124
-{
125
-    MSGCODE("LibClamAV debug: ");
126
-}
127 96
 
128
-#ifndef CLI_MEMFUNSONLY
129 97
 int (*cli_unrar_open)(int fd, const char *dirname, unrar_state_t *state);
130 98
 int (*cli_unrar_extract_next_prepare)(unrar_state_t *state, const char *dirname);
131 99
 int (*cli_unrar_extract_next)(unrar_state_t *state, const char *dirname);
... ...
@@ -553,120 +515,7 @@ static char *cli_md5buff(const unsigned char *buffer, unsigned int len, unsigned
553 553
 
554 554
     return md5str;
555 555
 }
556
-#endif
557
-
558
-void *cli_malloc(size_t size)
559
-{
560
-	void *alloc;
561
-
562
-
563
-    if(!size || size > CLI_MAX_ALLOCATION) {
564
-	cli_errmsg("cli_malloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
565
-	return NULL;
566
-    }
567
-
568
-#if defined(_MSC_VER) && defined(_DEBUG)
569
-    alloc = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__);
570
-#else
571
-    alloc = malloc(size);
572
-#endif
573
-
574
-    if(!alloc) {
575
-	cli_errmsg("cli_malloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) size);
576
-	perror("malloc_problem");
577
-	return NULL;
578
-    } else return alloc;
579
-}
580
-
581
-void *cli_calloc(size_t nmemb, size_t size)
582
-{
583
-	void *alloc;
584
-
585
-
586
-    if(!size || size > CLI_MAX_ALLOCATION) {
587
-	cli_errmsg("cli_calloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
588
-	return NULL;
589
-    }
590
-
591
-#if defined(_MSC_VER) && defined(_DEBUG)
592
-    alloc = _calloc_dbg(nmemb, size, _NORMAL_BLOCK, __FILE__, __LINE__);
593
-#else
594
-    alloc = calloc(nmemb, size);
595
-#endif
596
-
597
-    if(!alloc) {
598
-	cli_errmsg("cli_calloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) (nmemb * size));
599
-	perror("calloc_problem");
600
-	return NULL;
601
-    } else return alloc;
602
-}
603
-
604
-void *cli_realloc(void *ptr, size_t size)
605
-{
606
-	void *alloc;
607
-
608
-
609
-    if(!size || size > CLI_MAX_ALLOCATION) {
610
-	cli_errmsg("cli_realloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
611
-	return NULL;
612
-    }
613 556
 
614
-    alloc = realloc(ptr, size);
615
-
616
-    if(!alloc) {
617
-	cli_errmsg("cli_realloc(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size);
618
-	perror("realloc_problem");
619
-	return NULL;
620
-    } else return alloc;
621
-}
622
-
623
-void *cli_realloc2(void *ptr, size_t size)
624
-{
625
-	void *alloc;
626
-
627
-
628
-    if(!size || size > CLI_MAX_ALLOCATION) {
629
-	cli_errmsg("cli_realloc2(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
630
-	return NULL;
631
-    }
632
-
633
-    alloc = realloc(ptr, size);
634
-
635
-    if(!alloc) {
636
-	cli_errmsg("cli_realloc2(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size);
637
-	perror("realloc_problem");
638
-	if(ptr)
639
-	    free(ptr);
640
-	return NULL;
641
-    } else return alloc;
642
-}
643
-
644
-char *cli_strdup(const char *s)
645
-{
646
-        char *alloc;
647
-
648
-
649
-    if(s == NULL) {
650
-        cli_errmsg("cli_strdup(): s == NULL. Please report to http://bugs.clamav.net\n");
651
-        return NULL;
652
-    }
653
-
654
-#if defined(_MSC_VER) && defined(_DEBUG)
655
-    alloc = _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__);
656
-#else
657
-    alloc = strdup(s);
658
-#endif
659
-
660
-    if(!alloc) {
661
-        cli_errmsg("cli_strdup(): Can't allocate memory (%u bytes).\n", (unsigned int) strlen(s));
662
-        perror("strdup_problem");
663
-        return NULL;
664
-    }
665
-
666
-    return alloc;
667
-}
668
-
669
-#ifndef CLI_MEMFUNSONLY
670 557
 unsigned int cli_rndnum(unsigned int max)
671 558
 {
672 559
     if(name_salt[0] == 16) { /* minimizes re-seeding after the first call to cli_gentemp() */
... ...
@@ -753,7 +602,6 @@ int cli_gentempfd(const char *dir, char **name, int *fd)
753 753
 
754 754
     return CL_SUCCESS;
755 755
 }
756
-#endif
757 756
 
758 757
 /* Function: unlink
759 758
         unlink() with error checking
... ...
@@ -1107,64 +955,3 @@ int cli_bitset_test(bitset_t *bs, unsigned long bit_offset)
1107 1107
 	return (bs->bitset[char_offset] & ((unsigned char)1 << bit_offset));
1108 1108
 }
1109 1109
 
1110
-/* returns converted timestamp, in case of error the returned string contains at least one character */
1111
-const char* cli_ctime(const time_t *timep, char *buf, const size_t bufsize)
1112
-{
1113
-	const char *ret;
1114
-	if(bufsize < 26) {
1115
-		/* standard says we must have at least 26 bytes buffer */
1116
-		cli_warnmsg("buffer too small for ctime\n");
1117
-		return " ";
1118
-	}
1119
-	if((uint32_t)(*timep) > 0x7fffffff) {
1120
-		/* some systems can consider these timestamps invalid */
1121
-		strncpy(buf, "invalid timestamp", bufsize-1);
1122
-		buf[bufsize-1] = '\0';
1123
-		return buf;
1124
-	}
1125
-
1126
-#ifdef HAVE_CTIME_R	
1127
-# ifdef HAVE_CTIME_R_2
1128
-	ret = ctime_r(timep, buf);
1129
-# else
1130
-	ret = ctime_r(timep, buf, bufsize);
1131
-# endif
1132
-#else /* no ctime_r */
1133
-
1134
-# ifdef CL_THREAD_SAFE
1135
-	pthread_mutex_lock(&cli_ctime_mutex);
1136
-# endif
1137
-	ret = ctime(timep);
1138
-	if(ret) {
1139
-		strncpy(buf, ret, bufsize-1);
1140
-		buf[bufsize-1] = '\0';
1141
-		ret = buf;
1142
-	}
1143
-# ifdef CL_THREAD_SAFE
1144
-	pthread_mutex_unlock(&cli_ctime_mutex);
1145
-# endif
1146
-#endif
1147
-	/* common */
1148
-	if(!ret) {
1149
-		buf[0] = ' ';
1150
-		buf[1] = '\0';
1151
-		return buf;
1152
-	}
1153
-	return ret;
1154
-}
1155
-
1156
-#ifndef CLI_MEMFUNSONLY
1157
-int cli_matchregex(const char *str, const char *regex)
1158
-{
1159
-	regex_t reg;
1160
-	int match;
1161
-
1162
-    if(cli_regcomp(&reg, regex, REG_EXTENDED | REG_NOSUB) == 0) {
1163
-	match = (cli_regexec(&reg, str, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
1164
-	cli_regfree(&reg);
1165
-	return match;
1166
-    }
1167
-
1168
-    return 0;
1169
-}
1170
-#endif
1171 1110
new file mode 100644
... ...
@@ -0,0 +1,275 @@
0
+/*
1
+ *  Copyright (C) 2007-2008 Sourcefire, Inc.
2
+ *
3
+ *  Authors: Tomasz Kojm, Trog
4
+ *
5
+ *  This program is free software; you can redistribute it and/or modify
6
+ *  it under the terms of the GNU General Public License version 2 as
7
+ *  published by the Free Software Foundation.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
+ *  MA 02110-1301, USA.
18
+ *
19
+ */
20
+
21
+#if HAVE_CONFIG_H
22
+#include "clamav-config.h"
23
+#endif
24
+
25
+#include <stdio.h>
26
+#include <stdarg.h>
27
+#include <string.h>
28
+#include <stdlib.h>
29
+#include <ctype.h>
30
+#ifdef	HAVE_UNISTD_H
31
+#include <unistd.h>
32
+#endif
33
+#include <sys/types.h>
34
+#include <sys/stat.h>
35
+#ifndef	C_WINDOWS
36
+#include <sys/wait.h>
37
+#include <sys/time.h>
38
+#include <dirent.h>
39
+#endif
40
+#include <time.h>
41
+#include <fcntl.h>
42
+#ifndef	C_WINDOWS
43
+#include <pwd.h>
44
+#endif
45
+#include <errno.h>
46
+#include "target.h"
47
+#ifndef	C_WINDOWS
48
+#include <sys/time.h>
49
+#endif
50
+#ifdef	HAVE_SYS_PARAM_H
51
+#include <sys/param.h>
52
+#endif
53
+#ifdef	HAVE_MALLOC_H
54
+#include <malloc.h>
55
+#endif
56
+#if	defined(_MSC_VER) && defined(_DEBUG)
57
+#include <crtdbg.h>
58
+#endif
59
+
60
+#include "clamav.h"
61
+#include "others.h"
62
+#include "md5.h"
63
+#include "cltypes.h"
64
+#include "regex/regex.h"
65
+#include "ltdl.h"
66
+#include "matcher-ac.h"
67
+
68
+#ifdef CL_THREAD_SAFE
69
+#  include <pthread.h>
70
+
71
+# ifndef HAVE_CTIME_R
72
+static pthread_mutex_t cli_ctime_mutex = PTHREAD_MUTEX_INITIALIZER;
73
+# endif
74
+
75
+#endif
76
+uint8_t cli_debug_flag = 0;
77
+
78
+#define MSGCODE(x)					    \
79
+	va_list args;					    \
80
+	int len = sizeof(x) - 1;			    \
81
+	char buff[BUFSIZ];				    \
82
+    strncpy(buff, x, len);				    \
83
+    buff[BUFSIZ-1]='\0';				    \
84
+    va_start(args, str);				    \
85
+    vsnprintf(buff + len, sizeof(buff) - len, str, args);   \
86
+    buff[sizeof(buff) - 1] = '\0';			    \
87
+    fputs(buff, stderr);				    \
88
+    va_end(args)
89
+
90
+void cli_warnmsg(const char *str, ...)
91
+{
92
+    MSGCODE("LibClamAV Warning: ");
93
+}
94
+
95
+void cli_errmsg(const char *str, ...)
96
+{
97
+    MSGCODE("LibClamAV Error: ");
98
+}
99
+
100
+void cli_dbgmsg_internal(const char *str, ...)
101
+{
102
+    MSGCODE("LibClamAV debug: ");
103
+}
104
+
105
+int cli_matchregex(const char *str, const char *regex)
106
+{
107
+	regex_t reg;
108
+	int match;
109
+
110
+    if(cli_regcomp(&reg, regex, REG_EXTENDED | REG_NOSUB) == 0) {
111
+	match = (cli_regexec(&reg, str, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
112
+	cli_regfree(&reg);
113
+	return match;
114
+    }
115
+
116
+    return 0;
117
+}
118
+void *cli_malloc(size_t size)
119
+{
120
+	void *alloc;
121
+
122
+
123
+    if(!size || size > CLI_MAX_ALLOCATION) {
124
+	cli_errmsg("cli_malloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
125
+	return NULL;
126
+    }
127
+
128
+#if defined(_MSC_VER) && defined(_DEBUG)
129
+    alloc = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__);
130
+#else
131
+    alloc = malloc(size);
132
+#endif
133
+
134
+    if(!alloc) {
135
+	cli_errmsg("cli_malloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) size);
136
+	perror("malloc_problem");
137
+	return NULL;
138
+    } else return alloc;
139
+}
140
+
141
+void *cli_calloc(size_t nmemb, size_t size)
142
+{
143
+	void *alloc;
144
+
145
+
146
+    if(!size || size > CLI_MAX_ALLOCATION) {
147
+	cli_errmsg("cli_calloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
148
+	return NULL;
149
+    }
150
+
151
+#if defined(_MSC_VER) && defined(_DEBUG)
152
+    alloc = _calloc_dbg(nmemb, size, _NORMAL_BLOCK, __FILE__, __LINE__);
153
+#else
154
+    alloc = calloc(nmemb, size);
155
+#endif
156
+
157
+    if(!alloc) {
158
+	cli_errmsg("cli_calloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) (nmemb * size));
159
+	perror("calloc_problem");
160
+	return NULL;
161
+    } else return alloc;
162
+}
163
+
164
+void *cli_realloc(void *ptr, size_t size)
165
+{
166
+	void *alloc;
167
+
168
+
169
+    if(!size || size > CLI_MAX_ALLOCATION) {
170
+	cli_errmsg("cli_realloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
171
+	return NULL;
172
+    }
173
+
174
+    alloc = realloc(ptr, size);
175
+
176
+    if(!alloc) {
177
+	cli_errmsg("cli_realloc(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size);
178
+	perror("realloc_problem");
179
+	return NULL;
180
+    } else return alloc;
181
+}
182
+
183
+void *cli_realloc2(void *ptr, size_t size)
184
+{
185
+	void *alloc;
186
+
187
+
188
+    if(!size || size > CLI_MAX_ALLOCATION) {
189
+	cli_errmsg("cli_realloc2(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size);
190
+	return NULL;
191
+    }
192
+
193
+    alloc = realloc(ptr, size);
194
+
195
+    if(!alloc) {
196
+	cli_errmsg("cli_realloc2(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size);
197
+	perror("realloc_problem");
198
+	if(ptr)
199
+	    free(ptr);
200
+	return NULL;
201
+    } else return alloc;
202
+}
203
+
204
+char *cli_strdup(const char *s)
205
+{
206
+        char *alloc;
207
+
208
+
209
+    if(s == NULL) {
210
+        cli_errmsg("cli_strdup(): s == NULL. Please report to http://bugs.clamav.net\n");
211
+        return NULL;
212
+    }
213
+
214
+#if defined(_MSC_VER) && defined(_DEBUG)
215
+    alloc = _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__);
216
+#else
217
+    alloc = strdup(s);
218
+#endif
219
+
220
+    if(!alloc) {
221
+        cli_errmsg("cli_strdup(): Can't allocate memory (%u bytes).\n", (unsigned int) strlen(s));
222
+        perror("strdup_problem");
223
+        return NULL;
224
+    }
225
+
226
+    return alloc;
227
+}
228
+
229
+/* returns converted timestamp, in case of error the returned string contains at least one character */
230
+const char* cli_ctime(const time_t *timep, char *buf, const size_t bufsize)
231
+{
232
+	const char *ret;
233
+	if(bufsize < 26) {
234
+		/* standard says we must have at least 26 bytes buffer */
235
+		cli_warnmsg("buffer too small for ctime\n");
236
+		return " ";
237
+	}
238
+	if((uint32_t)(*timep) > 0x7fffffff) {
239
+		/* some systems can consider these timestamps invalid */
240
+		strncpy(buf, "invalid timestamp", bufsize-1);
241
+		buf[bufsize-1] = '\0';
242
+		return buf;
243
+	}
244
+
245
+#ifdef HAVE_CTIME_R	
246
+# ifdef HAVE_CTIME_R_2
247
+	ret = ctime_r(timep, buf);
248
+# else
249
+	ret = ctime_r(timep, buf, bufsize);
250
+# endif
251
+#else /* no ctime_r */
252
+
253
+# ifdef CL_THREAD_SAFE
254
+	pthread_mutex_lock(&cli_ctime_mutex);
255
+# endif
256
+	ret = ctime(timep);
257
+	if(ret) {
258
+		strncpy(buf, ret, bufsize-1);
259
+		buf[bufsize-1] = '\0';
260
+		ret = buf;
261
+	}
262
+# ifdef CL_THREAD_SAFE
263
+	pthread_mutex_unlock(&cli_ctime_mutex);
264
+# endif
265
+#endif
266
+	/* common */
267
+	if(!ret) {
268
+		buf[0] = ' ';
269
+		buf[1] = '\0';
270
+		return buf;
271
+	}
272
+	return ret;
273
+}
274
+