📄 rules.c
字号:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include "rules.h"char filter_app[1024] ;FILE* fp = NULL; //a pointer stick to ./rules/rulechar msg[1000] = {0}; //save the rules from ./rules/ruleint check_rules_from_file(char * rule_file){ return 1 ;//check rules}int read_rules_from_file(){
fp = fopen("./rules/rule", "r+");
if(fp == NULL){
perror("fopen return error\n");
exit(1);
} while(fgets(msg, sizeof(msg), fp)){
if(msg[0] == '#' || msg[0] == '\n')
continue;
if(strlen(msg) <1)
continue;
if(msg[strlen(msg)-1] == '\n'){
msg[strlen(msg)-1] = '\0';
}
if(msg[strlen(msg)-2] == '\r'){
msg[strlen(msg)-1] = '\0';
} } return 1 ;//read rules from file}/* int init_filter_app() { filter_app[1024]="" ; }*/int set_filter_app(){ strncpy(filter_app,msg,strlen(msg)) ; //just for test //printf("\n\n%s\n\n",filter_app) ; return (filter_app == NULL)? 0:1;}int read_statment_from_rules(void){ //strncpy(filter_app,"++++++++++++++++++++++++",sizeof("++++++++++++++++++++++++")) ; return (filter_app == NULL)? 0:1;//compile rules}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -