static int read_conf_init_info(char * file_path, myStruct *attr)
{
int value = 0;
char buf[256] = {0};
char *buf_ptr = NULL;
char *value_ptr = NULL;
char *cur_ptr = NULL;
FILE *fp = NULL;
if(file_path == NULL){
printf( "conf file path is null!\n");
return ERR;
}
if(!(fp = fopen(file_path,"rb"))){
printf( "open %s is NULL!\n",file_path);
return ERR;
}
memset(attr,0,sizeof(myStruct ));
while(!feof(fp) && (buf_ptr = fgets(buf,256,fp))!= NULL){
if((strncmp(buf,"\n",2) == 0) || (strncmp(buf,"#",1) == 0)){
continue;
}else{
cur_ptr = strtok_r(buf,"=",&buf_ptr);
value_ptr = strtok_r(NULL,"=",&buf_ptr);
value = atoi(value_ptr);
printf( "value = %d\n",value);
if(strncmp(buf,"A_num ",5) == 0){
attr->A_num = value;
printf( "A_num = %d\n",attr->A_num);
}
if(strncmp(buf,"B_num",5) == 0){
attr->B_num = value;
printf( "max_num = %d\n",attr->B_num);
}
//other conf item
}
}
fclose(fp);
return OK;
}