Here I have a patch for the clamav CVS that allows compiliation of libclamav and clamscan on DJGPP. Note that in addition to the patch, the ./configure script needs to also #define lstat stat and #define d_ino d_namlen for DJGPP.
diff -ur clamav-devel.orig/clamscan/treewalk.c clamav/clamscan/treewalk.c --- clamav-devel.orig/clamscan/treewalk.c 2005-08-03 07:31:22.000000000 +0000 +++ clamav/clamscan/treewalk.c 2005-08-31 12:27:34.000000000 +0000 @@ -106,7 +106,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode) && recursion) { + #else if(S_ISDIR(statbuf.st_mode) && (S_ISLNK(statbuf.st_mode) && recursion) { + #endif if(treewalk(fname, root, user, opt, limits, options, depth) == 1) scanret++; } else { @@ -161,7 +165,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) { + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { + #endif if(rmdir(fname) == -1) { /* can't be deleted */ if(errno == EACCES) { logg("^Can't remove some temporary directories due to access problem.\n"); @@ -263,7 +271,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) { + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { + #endif chmod(fname, 0700); fixperms(fname); } else if(S_ISREG(statbuf.st_mode)) @@ -311,7 +323,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) { + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { + #endif du(fname, n); } else { n->space += statbuf.st_size / 1024; diff -ur clamav-devel.orig/libclamav/mbox.c clamav/libclamav/mbox.c --- clamav-devel.orig/libclamav/mbox.c 2005-08-12 05:00:06.000000000 +0000 +++ clamav/libclamav/mbox.c 2005-08-31 12:35:04.000000000 +0000 @@ -116,6 +116,8 @@ */ #if C_SOLARIS && __GNUC__ #undef WITH_CURL +#elif defined(__DJGPP__) +#undef WITH_CURL #endif #ifdef WITH_CURL diff -ur clamav-devel.orig/libclamav/others.c clamav/libclamav/others.c --- clamav-devel.orig/libclamav/others.c 2005-08-03 07:31:22.000000000 +0000 +++ clamav/libclamav/others.c 2005-09-01 08:38:22.000000000 +0000 @@ -399,16 +399,30 @@ struct stat foo; if(!dir) { +#if defined(__DJGPP__) + if((mdir = getenv("TEMP")) == NULL) + if((mdir = getenv("TMP")) == NULL) + if((mdir = getenv("TMPDIR")) == NULL) +#ifdef P_tmpdir + mdir = P_tmpdir; +#else + mdir = "c:/tmp"; +#endif +#else if((mdir = getenv("TMPDIR")) == NULL) #ifdef P_tmpdir mdir = P_tmpdir; #else mdir = "/tmp"; #endif +#endif } else mdir = dir; - +#if defined(__DJGPP__) + name = (char *) cli_calloc(strlen(mdir) + 1 + 6 + 1 + 3, sizeof(char)); +#else name = (char *) cli_calloc(strlen(mdir) + 1 + 32 + 1 + 7, sizeof(char)); +#endif if(!name) { cli_dbgmsg("cli_gentempname('%s'): out of memory\n", mdir); return NULL; @@ -435,8 +449,15 @@ return NULL; } +#if defined(__DJGPP__) + sprintf(name, "%s/av", mdir); + strncat(name, tmp, 6); + strcat(name, "."); + strncat(name, tmp, 3); +#else sprintf(name, "%s/clamav-", mdir); strncat(name, tmp, 32); +#endif free(tmp); return(name); @@ -538,7 +559,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) { + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { + #endif if(rmdir(fname) == -1) { /* can't be deleted */ if(errno == EACCES) { cli_errmsg("Can't remove some temporary directories due to access problem.\n"); diff -ur clamav-devel.orig/libclamav/scanners.c clamav/libclamav/scanners.c --- clamav-devel.orig/libclamav/scanners.c 2005-08-29 08:02:38.000000000 +0000 +++ clamav/libclamav/scanners.c 2005-08-31 12:35:56.000000000 +0000 @@ -873,7 +873,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) { + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { + #endif if (cli_scandir(fname, virname, scanned, root, limits, options, arec, mrec) == CL_VIRUS) { free(fname); closedir(dd); @@ -1042,7 +1046,11 @@ /* stat the file */ if(lstat(fname, &statbuf) != -1) { + #if defined(__DJGPP__) + if(S_ISDIR(statbuf.st_mode)) + #else if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) + #endif if (cli_vba_scandir(fname, virname, scanned, root, limits, options, arec, mrec) == CL_VIRUS) { ret = CL_VIRUS; free(fname); diff -ur clamav-devel.orig/libclamav/unrar/unrar.c clamav/libclamav/unrar/unrar.c --- clamav-devel.orig/libclamav/unrar/unrar.c 2005-04-19 04:32:42.000000000 +0000 +++ clamav/libclamav/unrar/unrar.c 2005-08-31 12:36:20.000000000 +0000 @@ -39,7 +39,11 @@ #include "clamav.h" #include "others.h" +#if defined(__DJGPP__) +#define int64to32(x) ((unsigned int)(x)) +#else #define int64to32(x) ((uint)(x)) +#endif #ifdef RAR_HIGH_DEBUG #define rar_dbgmsg printf diff -ur clamav-devel.orig/libclamav/unrar/unrarvm.c clamav/libclamav/unrar/unrarvm.c --- clamav-devel.orig/libclamav/unrar/unrarvm.c 2005-04-19 04:32:42.000000000 +0000 +++ clamav/libclamav/unrar/unrarvm.c 2005-08-31 04:36:36.000000000 +0000 @@ -314,7 +314,11 @@ { int in_addr=bit_pos/8; int in_bit=bit_pos&7; - unsigned int bit_field=(uint)data[in_addr++]; + #if defined(__DJGPP__) + unsigned int bit_field=(unsigned int)data[in_addr++]; + #else + unsigned int bit_field=(uint)data[in_addr++]; + #endif bit_field|=(unsigned int)data[in_addr++] << 8; bit_field|=(unsigned int)data[in_addr++] << 16; bit_field|=(unsigned int)data[in_addr] << 24; Only in clamav: libclamav.pc diff -ur clamav-devel.orig/shared/output.c clamav/shared/output.c --- clamav-devel.orig/shared/output.c 2005-07-19 12:04:38.000000000 +0000 +++ clamav/shared/output.c 2005-09-01 09:45:52.000000000 +0000 @@ -35,12 +35,14 @@ #include <sys/stat.h> #include <errno.h> #include <sys/time.h> +#if !defined(__DJGPP__) #include <sys/socket.h> +#endif #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif -#if defined(USE_SYSLOG) && !defined(C_AIX) +#if defined(USE_SYSLOG) && !defined(C_AIX) && !defined(__DJGPP__) #include <syslog.h> #endif @@ -73,7 +75,7 @@ short int logg_verbose = 0, logg_lock = 0, logg_time = 0; int logg_size = 0; const char *logg_file = NULL; -#if defined(USE_SYSLOG) && !defined(C_AIX) +#if defined(USE_SYSLOG) && !defined(C_AIX) && !defined(__DJGPP__) short logg_syslog; #endif @@ -91,7 +93,9 @@ va_start(args, str); bytes = vsnprintf(buff, 512, str, args); va_end(args); +#if !defined(__DJGPP__) return send(desc, buff, bytes, 0); +#endif } void logg_close(void) { @@ -107,7 +111,7 @@ pthread_mutex_unlock(&logg_mutex); #endif -#if defined(USE_SYSLOG) && !defined(C_AIX) +#if defined(USE_SYSLOG) && !defined(C_AIX) && defined(__DJGPP__) if(logg_syslog) { closelog(); } @@ -200,7 +204,7 @@ } } -#if defined(USE_SYSLOG) && !defined(C_AIX) +#if defined(USE_SYSLOG) && !defined(C_AIX) && !defined(__DJGPP__) if(logg_syslog) { /* due to a problem with superfluous control characters (which @@ -312,7 +316,7 @@ int code; }; -#if defined(USE_SYSLOG) && !defined(C_AIX) +#if defined(USE_SYSLOG) && !defined(C_AIX) && !defined(__DJGPP__) static const struct facstruct facilitymap[] = { #ifdef LOG_AUTH { "LOG_AUTH", LOG_AUTH }, _______________________________________________ http://lurker.clamav.net/list/clamav-devel.html