优化读取配置文件正确性!

This commit is contained in:
aixiao 2023-02-28 11:04:47 +08:00
parent 17f06235df
commit bc6e6b253c
2 changed files with 18 additions and 17 deletions

33
conf.c
View File

@ -207,8 +207,6 @@ static void parse_global_module(char *content, conf * conf)
conf->CLAMAV_ARG_LEN = val_begin_len;
if (copy_new_mem(val_begin, val_begin_len, &conf->CLAMAV_ARG) != 0)
return;
} else {
conf->CLAMAV_ARG_LEN = 0;
}
// 磁盘使用率
@ -322,16 +320,16 @@ void free_conf(conf * conf)
void ptintf_conf(conf * conf)
{
if (conf->DAEMON)
printf("%s\n", conf->DAEMON);
printf("%d\n", conf->TIME);
printf("%d\n", conf->REFUSE_NUMBER);
printf("%d\n", conf->IS_MAIL);
printf("%d\n", conf->IS_DING_WEBHOOK);
printf("DAEMON %s\n", conf->DAEMON);
printf("TIME %d\n", conf->TIME);
printf("REFUSE_NUMBER %d\n", conf->REFUSE_NUMBER);
printf("IS_MAIL %d\n", conf->IS_MAIL);
printf("IS_DING_WEBHOOK %d\n", conf->IS_DING_WEBHOOK);
if (conf->PHONE)
printf("%s\n", conf->PHONE);
printf("PHONE %s\n", conf->PHONE);
if (conf->DING_WEBHOOK)
printf("%s\n", conf->DING_WEBHOOK);
printf("%d\n", conf->IS_QQMAIL);
printf("DING_WEBHOOK %s\n", conf->DING_WEBHOOK);
printf("IS_QQMAIL %d\n", conf->IS_QQMAIL);
/*
if (conf->SEND_QQ)
printf("%s\n", conf->SEND_QQ);
@ -339,17 +337,20 @@ void ptintf_conf(conf * conf)
printf("%s\n", conf->QQMAIL_KEY);
*/
if (conf->RECV_MAIL)
printf("%s\n", conf->RECV_MAIL);
printf("RECV_MAIL %s\n", conf->RECV_MAIL);
if (conf->PUBLIC_IP)
printf("%s\n", conf->PUBLIC_IP);
printf("PUBLIC_IP %s\n", conf->PUBLIC_IP);
printf("%d\n", conf->IPV4_RESTRICTION);
printf("IPV4_RESTRICTION %d\n", conf->IPV4_RESTRICTION);
if (conf->IPV4_WHITE_LIST)
printf("%s\n", conf->IPV4_WHITE_LIST);
printf("IPV4_WHITE_LIST %s\n", conf->IPV4_WHITE_LIST);
printf("%d\n", conf->REGION);
printf("REGION %d\n", conf->REGION);
if (conf->REGION_LIST)
printf("%s\n", conf->REGION_LIST);
printf("REGION_LIST %s\n", conf->REGION_LIST);
if (conf->CLAMAV_ARG)
printf("CLAMAV_ARG %s %d\n", conf->CLAMAV_ARG, conf->CLAMAV_ARG_LEN);
}
void split_string(char string[], char delims[], char (*whitelist_ip)[WHITELIST_IP_NUM])

View File

@ -957,7 +957,7 @@ int main(int argc, char *argv[], char **env)
read_conf(path, conf);
//ptintf_conf(conf);
if (0 == conf->CLAMAV_ARG_LEN)
if (0 >= conf->CLAMAV_ARG_LEN)
{
printf("\033[31mError reading configuration file, please check the configuration file!\033[0m\n");