win32: add clamscan

0.96
aCaB 16 years ago
parent 5ff0fe419a
commit ad0afaf185
  1. 4
      ChangeLog
  2. 9
      win32/ClamAV.sln
  3. 239
      win32/clamscan.vcproj
  4. 3
      win32/compat/dirent.h
  5. 153
      win32/compat/libgen.c
  6. 31
      win32/compat/libgen.h
  7. 38
      win32/libclamav.def
  8. 14
      win32/libclamav.vcproj
  9. 6
      win32/platform.h

@ -1,3 +1,7 @@
Tue Oct 13 20:13:53 CEST 2009 (acab)
------------------------------------
* win32: clamscan builds (and will scan soon...)
Tue Oct 13 00:54:05 CEST 2009 (acab)
------------------------------------
* win32/compat: add POSIX compatible snprintf

@ -3,6 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libclamav", "libclamav.vcproj", "{3AD5B16C-340A-40AC-96AD-6017B941A316}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clamscan", "clamscan.vcproj", "{F79E7CA7-E49D-479E-8D68-0EA9CB585575}"
ProjectSection(ProjectDependencies) = postProject
{3AD5B16C-340A-40AC-96AD-6017B941A316} = {3AD5B16C-340A-40AC-96AD-6017B941A316}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -13,6 +18,10 @@ Global
{3AD5B16C-340A-40AC-96AD-6017B941A316}.Debug|Win32.Build.0 = Debug|Win32
{3AD5B16C-340A-40AC-96AD-6017B941A316}.Release|Win32.ActiveCfg = Release|Win32
{3AD5B16C-340A-40AC-96AD-6017B941A316}.Release|Win32.Build.0 = Release|Win32
{F79E7CA7-E49D-479E-8D68-0EA9CB585575}.Debug|Win32.ActiveCfg = Debug|Win32
{F79E7CA7-E49D-479E-8D68-0EA9CB585575}.Debug|Win32.Build.0 = Debug|Win32
{F79E7CA7-E49D-479E-8D68-0EA9CB585575}.Release|Win32.ActiveCfg = Release|Win32
{F79E7CA7-E49D-479E-8D68-0EA9CB585575}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,239 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="clamscan"
ProjectGUID="{F79E7CA7-E49D-479E-8D68-0EA9CB585575}"
RootNamespace="clamscan"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="1"
DisableSpecificWarnings="4996;4244;4018;4090;4333;4101;4146"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="1"
DisableSpecificWarnings="4996;4244;4018;4090;4333;4101;4146"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\clamscan\clamscan.c"
>
</File>
<File
RelativePath="..\clamscan\manager.c"
>
</File>
<File
RelativePath="..\clamscan\others.c"
>
</File>
<Filter
Name="shared"
>
<File
RelativePath="..\shared\actions.c"
>
</File>
<File
RelativePath="..\shared\getopt.c"
>
</File>
<File
RelativePath="..\shared\misc.c"
>
</File>
<File
RelativePath="..\shared\optparser.c"
>
</File>
<File
RelativePath="..\shared\output.c"
>
</File>
</Filter>
<Filter
Name="compat"
>
<File
RelativePath=".\compat\libgen.c"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -55,4 +55,5 @@ DIR *opendir(const char *name);
struct dirent *readdir(DIR *dirp);
void rewinddir(DIR *dirp);
int closedir(DIR *dirp);
#endif
#endif /* __DIRENT_H */

@ -0,0 +1,153 @@
/*
* Copyright (C) 2009 Sourcefire, Inc.
*
* Authors: aCaB <acab@clamav.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include <string.h>
#include "libgen.h"
/*
Note: an exact implementation of is not really possible, but this is good enough for us
*path* *dirname* *basename*
"C:" "C:" ""
"C:\" "C:" ""
"C:\\" "C:" ""
"C:file" "C:file" ""
"C:file\" "C:file" ""
"C:\file" "C:" "file"
"C:\file\" "C:" "file"
"C:\path\file" "C:\path" "file"
"C:\path\file\" "C:\path" "file"
"\\net" "\\net" ""
"\\net\" "\\net" ""
"\\net\share" "\\net" "share"
"\\net\share\" "\\net" "share"
"\\net\share\file" "\\net\share" "file"
"\\net\share\file\" "\\net\share" "file"
"\\net\share\path\file" "\\net\share\path" "file"
"\\net\share\path\file\" "\\net\share\path" "file"
"\\?\C:" "\\?\C:" ""
"\\?\C:\" "\\?\C:" ""
"\\?\C:\\" "\\?\C:" ""
"\\?\C:\file" "\\?\C:" "file"
"\\?\C:\file\" "\\?\C:" "file"
"\\?\C:\path\file" "\\?\C:\path" "file"
"\\?\C:\path\file\" "\\?\C:\path" "file"
"\" "" ""
"\\" "" ""
"\file" "" "file"
"\file\" "" "file"
"\path\file" "\path" "file"
"\path\file\" "\path" "file"
"." "." ""
".\" "." ""
".." ".." ""
"..\" ".." ""
"file" "." "file"
"file\" "." "file"
"path\file" "path" "file"
"path\file\" "path" "file"
"\\.\PhysicalDrive0" "\\.\PhysicalDrive0" ""
"\\.\PhysicalDrive0\other" "\\.\PhysicalDrive0" "other"
"" "." ""
NULL "." ""
Hopefully I didn't miss anything...
*/
static void splitpath(char *path, char **dir, char **base) {
char *startpath, *endpath;
int len;
if(!path || !(len = strlen(path))) {
*dir = ".";
*base = "";
return;
}
endpath = &path[len-1];
while(endpath >= path && *endpath == '\\') {
*endpath = '\0';
endpath--;
}
if(endpath < path) {
*dir = "";
*base = "";
return;
}
len = endpath-path + 1;
if(len > 2 && path[0] == '\\' && path[1] == '\\') {
if(len > 4 && (path[2] == '.' || path[2] == '?') && path[3] == '\\')
startpath = strchr(path + 4, '\\');
else
startpath = strchr(path + 2, '\\');
if(!startpath) {
*dir = path;
*base = "";
return;
}
startpath ++;
} else startpath = path;
endpath = strrchr(startpath, '\\');
if(!endpath) {
if(startpath == path) {
if(!strcmp(path, ".") || !strcmp(path, "..") || (len >= 2 && ((*path >= 'a' && *path <= 'z') || (*path >= 'A' && *path <= 'Z')) && path[1] == ':')) {
*dir = path;
*base = "";
return;
}
*dir = ".";
*base = path;
return;
}
*base = startpath;
endpath = startpath - 1;
startpath = path;
} else {
*base = endpath + 1;
}
*dir = path;
while(endpath >= startpath && *endpath == '\\') {
*endpath = '\0';
endpath--;
}
}
char *dirname(char *path) {
char *dir, *base;
splitpath(path, &dir, &base);
return dir;
}
char *basename(char *path) {
char *dir, *base;
splitpath(path, &dir, &base);
return base;
}

@ -0,0 +1,31 @@
/*
* Copyright (C) 2009 Sourcefire, Inc.
*
* Authors: aCaB <acab@clamav.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef __LIBGEN_H
#define __LIBGEN_H
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
char *dirname(char *path);
char *basename(char *path);
#endif /* __LIBGEN_H */

@ -0,0 +1,38 @@
LIBRARY libclamav
; cl_stuff - should be exported as is
EXPORTS cl_debug
EXPORTS cl_load
EXPORTS cl_engine_compile
EXPORTS cl_engine_set_num
EXPORTS cl_engine_set_str
EXPORTS cl_engine_free
EXPORTS cl_engine_new
EXPORTS cl_strerror
EXPORTS cl_init
EXPORTS cl_retdbdir
EXPORTS cl_scandesc
EXPORTS cl_scanfile
EXPORTS cl_cvdfree
EXPORTS cl_cvdhead
; cli_stuff - should be mangled or exported by ordinal only
EXPORTS cli_gentemp
EXPORTS cli_gettmpdir
EXPORTS cli_regcomp
EXPORTS cli_regexec
EXPORTS cli_regfree
EXPORTS cli_ctime
; shared stuff - to be either double compiled into the tools or treated like cli_xxx
EXPORTS gettimeofday
EXPORTS opendir
EXPORTS readdir
EXPORTS closedir
EXPORTS snprintf
; winsock - bridging for now
EXPORTS htonl
EXPORTS htons
EXPORTS send
EXPORTS select
EXPORTS gethostbyname

@ -19,7 +19,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="build\$(ProjectName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\compat&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -66,6 +66,7 @@
AdditionalDependencies="ws2_32.lib"
LinkIncremental="2"
IgnoreAllDefaultLibraries="false"
ModuleDefinitionFile="$(SolutionDir)libclamav.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
@ -95,7 +96,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="build\$(ProjectName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
@ -119,7 +120,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\compat&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)compat&quot;;&quot;$(SolutionDir)3rdparty\zlib&quot;;&quot;$(SolutionDir)3rdparty\pthreads&quot;;&quot;$(SolutionDir)3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@ -144,6 +145,7 @@
AdditionalDependencies="ws2_32.lib"
LinkIncremental="1"
IgnoreAllDefaultLibraries="false"
ModuleDefinitionFile="$(SolutionDir)libclamav.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@ -793,6 +795,10 @@
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\libclamav.def"
>
</File>
</Filter>
</Files>
<Globals>

@ -8,14 +8,20 @@
#include <io.h>
#include <direct.h>
#include "gettimeofday.h"
#include "snprintf.h"
typedef int ssize_t;
typedef unsigned short mode_t;
#define strcasecmp lstrcmpi
#define strncasecmp strnicmp
#define mkdir(path, mode) mkdir(path)
#define lstat stat
/* FIXME: need to wrap all win32 and winsock functions and map
(WSA)GetLastError to errno */
#define EWOULDBLOCK 31337
#define PATH_MAX 32767
#define S_IRUSR S_IREAD

Loading…
Cancel
Save