PP1=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","r"); if (PP1) { while (fgets(str,255,PP1)!=0) { if (strstr(str,"IPADDR=")>0) (str.endsWith(".250")) priznak2 = 1; if (strstr(str,"IPADDR=")>0) (str.endsWith(".251")) priznak2 = 2; if (strstr(str,"IPADDR=")>0) (str.endsWith(".252")) priznak2 = 3; if (strstr(str,"IPADDR=")>0) (str.endsWith(".253")) priznak2 = 4; } fclose(PP1); }if (priznak2 == 1) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.1\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } } else if (priznak2 == 2) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.2\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }else if(priznak2 == 3) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.3\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }else if(priznak2 == 4) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.4\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }
char *str; str=new char[255]; FILE * PP1;int priznak2=0;PP1=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","r"); if (PP1) { while (fgets(str,255,PP1)!=0) { if (strstr(str,"IPADDR=")>0) (str.endsWith(".250")) priznak2 = 1; if (strstr(str,"IPADDR=")>0) (str.endsWith(".251")) priznak2 = 2; if (strstr(str,"IPADDR=")>0) (str.endsWith(".252")) priznak2 = 3; if (strstr(str,"IPADDR=")>0) (str.endsWith(".253")) priznak2 = 4; } fclose(PP1); }if (priznak2 == 1) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.1\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } } else if (priznak2 == 2) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.2\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }else if(priznak2 == 3) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.3\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }else if(priznak2 == 4) { PP2=fopen("/etc/sysconfig/network-scripts/./ifcfg-eth0","w"); if (PP2) { fputs("DEVICE=eth0\n",PP2); fputs("IPADDR=1.1.1.4\n",PP2); fputs("NETMASK=255.255.255.0\n",PP2); fputs("ONBOOT=yes\n",PP2); fclose(PP2); } }