update
This commit is contained in:
@@ -7,7 +7,10 @@ int setting_virus_ctrl_virus_found_action = 0;
|
||||
char*setting_server_server_url = new char[300];
|
||||
char exluded_folders[100][300];
|
||||
int excluded_folders_size = 0;
|
||||
char included_folders[100][300];
|
||||
int included_folders_size = 0;
|
||||
bool setting_rtp_folder_scan_status = 1; //0=off, 1=on
|
||||
void load_included_folders();
|
||||
void load_excluded_folders();
|
||||
int load_settings() {
|
||||
FILE* fp;
|
||||
@@ -58,6 +61,7 @@ int load_settings() {
|
||||
delete[] settings_cmd;
|
||||
delete[] settings_arg;
|
||||
}
|
||||
load_included_folders();
|
||||
load_excluded_folders();
|
||||
return 0;
|
||||
}
|
||||
@@ -82,6 +86,47 @@ int get_setting(const char* setting_name,char*out) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void load_included_folders() {
|
||||
FILE* fp;
|
||||
if (fopen_s(&fp, INCLUDED_FOLDERS, "r") != 0) {
|
||||
log(LOGLEVEL::ERR, "[load_included_files()]: Could not open included folders file. ", INCLUDED_FOLDERS);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
char* path = new char[300];
|
||||
while (!feof(fp)) {
|
||||
//get the path of an excluded folder
|
||||
path[0] = '\0';
|
||||
//the path is encapsulated with "
|
||||
int cnt = 0;
|
||||
int chr = 0;
|
||||
chr = fgetc(fp);
|
||||
if (chr == '\"') {
|
||||
chr = 0;
|
||||
while (cnt < 295 && chr != '\"') {
|
||||
chr = fgetc(fp); //get a char
|
||||
if (chr != '\"')
|
||||
path[cnt] = chr;
|
||||
path[cnt + 1] = '\0';
|
||||
cnt++;
|
||||
}
|
||||
//now add the path to the array
|
||||
if (included_folders_size < 95) {
|
||||
strcpy_s(included_folders[included_folders_size], 295, path);
|
||||
included_folders_size++;
|
||||
}
|
||||
else {
|
||||
log(LOGLEVEL::ERR, "[load_included_files()]: included folders array is full. Cannot add more folders.");
|
||||
}
|
||||
}
|
||||
//else { we dont need to error out here. it is normal that it givs errors at the last lien of the file. but nothing bad happens, so errors arent needed
|
||||
// log(LOGLEVEL::ERR, "[load_excluded_folders()]: Error while processing excluded folders database. Expected \" but got ", chr);
|
||||
//}
|
||||
}
|
||||
fclose(fp);
|
||||
delete[] path;
|
||||
}
|
||||
}
|
||||
void load_excluded_folders() {
|
||||
FILE* fp;
|
||||
if (fopen_s(&fp, EXCLUDED_FOLDERS, "r") != 0) {
|
||||
@@ -121,17 +166,25 @@ void load_excluded_folders() {
|
||||
}
|
||||
fclose(fp);
|
||||
delete[] path;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool is_folder_excluded(const char*path) {
|
||||
for (int i = 0; i < excluded_folders_size; i++) {
|
||||
if (strstr(path,exluded_folders[i]) != 0 and strcmp(exluded_folders[i],"")!=0 and strcmp(exluded_folders[i], " ") != 0 ) {
|
||||
bool is_folder_included(const char*path) {
|
||||
for (int i = 0; i < included_folders_size; i++) {
|
||||
if (strstr(path,included_folders[i]) != 0 and strcmp(included_folders[i],"")!=0 and strcmp(included_folders[i], " ") != 0 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void print_exclusions() {
|
||||
bool is_folder_excluded(const char* path) {
|
||||
for (int i = 0; i < excluded_folders_size; i++) {
|
||||
if (strstr(path, exluded_folders[i]) != 0 and strcmp(exluded_folders[i], "") != 0 and strcmp(exluded_folders[i], " ") != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void print_inclusuions() {
|
||||
for (int i = 0; i < excluded_folders_size; i++) {
|
||||
log(LOGLEVEL::INFO, "[print_exclusions()]: Excluded folder: ", exluded_folders[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user