- clamscan.patch: The changes here are about adding support for Win32-style paths. When a Win32 path (eg C:\foo\bar) is detected, it is canonicalized to POSIX style (eg /dev/fs/C/foo/bar). This allows Windows programs that do not understand the POSIX environment to pass paths to clamscan and clamdscan.
diff -ru clamav-0.88.2/clamscan/options.c clamav-0.88.2-interix/clamscan/options.c --- clamav-0.88.2/clamscan/options.c Thu Jun 23 16:03:09 2005 +++ clamav-0.88.2-interix/clamscan/options.c Tue May 16 15:42:58 2006 @@ -36,6 +36,18 @@ #include "memory.h" #include "output.h" +#ifdef __INTERIX +# include <errno.h> +# include <interix/interix.h> +# include <limits.h> +# ifndef TRUE +# define TRUE 1 +# endif +# ifndef FALSE +# define FALSE 0 +# endif +#endif + extern int clamscan(struct optstruct *opt); static char *clamdscan_long[] = { "help", "version", "verbose", "quiet", @@ -49,6 +61,12 @@ int main(int argc, char **argv) { + #ifdef __INTERIX + /* Need these to handle win32-style paths passed to the Interix subsystem on NT 5.x+*/ + int iswinpath = FALSE; + char c; + char *file, *srch; + #endif int ret, opt_index, i, len; struct optstruct *opt; @@ -155,24 +173,48 @@ } } - if (optind < argc) { - + if (optind < argc) + { len=0; - /* count length of non-option arguments */ - - for(i=optind; i<argc; i++) - len+=strlen(argv[i]); + /* count length of non-option arguments */ - len=len+argc-optind-1; /* add spaces between arguments */ - opt->filename=(char*)mcalloc(len + 256, sizeof(char)); - - for(i=optind; i<argc; i++) { - strncat(opt->filename, argv[i], strlen(argv[i])); - if(i != argc-1) - strncat(opt->filename, "\t", 1); - } + for(i=optind; i<argc; i++) + { + #ifdef __INTERIX + /* This block is to handle convertint win32-style paths to POSIX paths + on the Interix subsystem on NT 5.x+. */ + file = srch = argv[i]; + while( (c = *srch++) != '\0' ) + { + if( c == '\\' || c == ':' ) + { + iswinpath = TRUE; + break; + } + } + if( iswinpath ) + { + char buff[PATH_MAX]; + if ( winpath2unix( file, 0, buff, sizeof(buff) ) != 0 ) + { + mprintf( "ERROR: Unable to convert Windows path \"%s\" to POSIX.\n", file ); + return errno; + } + argv[i] = &buff; + } + #endif + len+=strlen(argv[i]); + } + len=len+argc-optind-1; /* add spaces between arguments */ + opt->filename=(char*)mcalloc(len + 256, sizeof(char)); + for(i=optind; i<argc; i++) + { + strncat(opt->filename, argv[i], strlen(argv[i])); + if(i != argc-1) + strncat(opt->filename, "\t", 1); + } } ret = clamscan(opt); Brian A. Reiter WolfeReiter, LLC : Thoughtful Computing [http://www.thoughtfulcomputing.com]
_______________________________________________ http://lurker.clamav.net/list/clamav-devel.html