读写文件
FILE *fpin = NULL;
FILE *fpout = NULL;
char str1[512] = {0};
char str2[512] = {0};
system("iptables-save >/tmp/.currentipt");
fpin = fopen(IPTABLES_CURRENT_FILE,"r") ;
fpout = fopen(IPTABLES_MINIUPNPD_FILE,"w+");
if(fpin !=NULL && fpout !=NULL)
{
while(fgets(str1,512,fpin) != NULL)
{
if(strncmp(str1,"-A MINIUPNPD",strlen("-A MINIUPNPD")) == 0)
{
strcpy(str2,str1);
cprintf("[%s_%d]###str2:%s\n", __FUNCTION__, __LINE__,str2);
fprintf(fpout,"%s",str2);
}
else
continue;
}
fclose(fpin);
fclose(fpout);
}