int isclean(char *file) { if (isregular(file) == 0) /* prove this first !!! */ return 0; if (isinfected(file) == 1) return 0; if (iself(file) == 0) return 0; return 1; }
int scan_dir (char *directory, char *logfile, int flag) { FILE *fd; char *fileapath; struct dirent **filelist; struct stat buf; int count = 0,i = 0; char *detectstring = "VLP"; fd = fopen(logfile, "w+"); /* return egal */ if ((fileapath = (char*) (malloc (1000))) == NULL) perror (""), exit (1); if ((i = scandir (directory, &filelist, 0, 0)) == -1) // dir. scannen perror (""), exit (2); for (count = 2; count < i; count++) { /* alle gefundenen Dateien,ausser "." , ".." */ if ((fileapath = strcpy (fileapath, directory)) == NULL) // Pfad perror (""), exit (3); fileapath = strcat (fileapath, "/"); /* Trenner */ if ((fileapath = strcat (fileapath, filelist[count]->d_name)) == NULL) // + Datei perror (""), exit (4); stat (fileapath, &buf); if ((buf.st_mode & S_IFDIR) == S_IFDIR) /* falls Unterverzeichniss */ scan_dir (fileapath, logfile, flag); /* rekursiv weiter */ else { /* sonst scannen */ printf("\r "); printf(" \r"); printf("Datei <%s> ist ", fileapath); if (isinfected (fileapath)) { if (fd != NULL) fprintf(fd, "Datei <%s> ist infiziert.", fileapath); printf ("infiziert"); if (flag) { disinfect(fileapath); printf(" ... I disinfect ..."); if (fd != NULL) fprintf(fd, " ... I disinfect ..."); } if (fd != NULL) fprintf(fd, "\n"); } else printf("sauber"); fflush(stdout); } /* else */ } /* for */ return count; }