Read macfilter file

This commit is contained in:
Lakindu Akash 2020-10-31 00:41:15 +05:30
parent 8b60cf5bda
commit 7b0e88eebb
No known key found for this signature in database
GPG Key ID: 87D9889F7A634A38
3 changed files with 32 additions and 0 deletions

View File

@ -57,6 +57,7 @@ char cmd_write_mac[BUFSIZE];
char h_running_info[BUFSIZE];
char interface_list[BUFSIZE];
char wifi_interface_list[BUFSIZE];
char accepted_macs[BUFSIZE];
const char* g_ssid=NULL;
const char* g_pass=NULL;
@ -164,6 +165,26 @@ void write_accepted_macs(char* filename, char* accepted_macs){
}
char * read_mac_filter_file(char * filename){
char ch;
FILE *fp;
fp = fopen(filename, "r"); // read mode
if (fp == NULL)
{
perror("Error while opening the file.\n");
return NULL;
}
while((ch = (char)fgetc(fp)) != EOF)
strcat(accepted_macs, &ch);
fclose(fp);
return accepted_macs;
}
//int write_config(char* file){
//
// config_t cfg;

View File

@ -57,4 +57,6 @@ char** get_wifi_interface_list(int *length);
void write_accepted_macs(char* filename, char* accepted_macs);
char * read_mac_filter_file(char * filename);
#endif //WIHOTSPOT_H_PROP_H

View File

@ -483,6 +483,15 @@ void init_ui_from_config(){
gtk_toggle_button_set_active((GtkToggleButton*) cb_novirt,TRUE);
}
if(strcmp(values->mac_filter,"1")==0){
gtk_toggle_button_set_active((GtkToggleButton*) cb_mac_filter,TRUE);
}
char *macs =read_mac_filter_file(values->accepted_mac_file);
if (macs!=NULL || strlen(macs)<1){
gtk_text_buffer_set_text(buffer_mac_filter,macs,strlen(macs));
}
}
}