Changeset 1042
- Timestamp:
- 01/03/10 11:30:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/oscam-config.c
r1036 r1042 829 829 // } 830 830 // } 831 } 832 833 int write_config() 834 { 835 //int i; 836 FILE *f; 837 //char *dot = ""; //flag for comma 838 char tmpfile[256]; 839 char destfile[256]; 840 char bakfile[256]; 841 842 snprintf(destfile, 255,"%s%s", cs_confdir, cs_conf); 843 snprintf(tmpfile, 255, "%s%s.tmp", cs_confdir, cs_conf); 844 snprintf(bakfile, 255,"%s%s.bak", cs_confdir, cs_conf); 845 846 if (!(f=fopen(tmpfile, "w"))){ 847 cs_log("Cannot open file \"%s\" (errno=%d)", tmpfile, errno); 848 return(1); 849 } 850 fprintf(f,"#oscam.config generated automatically\n\n"); 851 852 /*global settings*/ 853 fprintf(f,"[global]\n"); 854 fprintf(f,"serverip = %s\n", inet_ntoa(*(struct in_addr *)&cfg->srvip)); 855 fprintf(f,"logfile = %s\n", logfile); 856 fprintf(f,"pidfile = %s\n", cfg->pidfile); 857 fprintf(f,"usrfile = %s\n", cfg->usrfile); 858 fprintf(f,"cwlogdir = %s\n", cfg->cwlogdir); 859 fprintf(f,"clienttimeout = %ld\n", cfg->ctimeout); 860 fprintf(f,"fallbacktimeout = %ld\n", cfg->ftimeout); 861 fprintf(f,"clientmaxidle = %d\n", cfg->cmaxidle); 862 fprintf(f,"cachedelay = %ld\n", cfg->delay); 863 fprintf(f,"bindwait = %d\n", cfg->bindwait); 864 fprintf(f,"netprio = %ld\n", cfg->netprio); 865 fprintf(f,"resolvedelay = %d\n", cfg->resolvedelay); 866 fprintf(f,"sleep = %d\n", cfg->tosleep); 867 fprintf(f,"unlockparental = %d\n", cfg->ulparent); 868 fprintf(f,"nice = %d\n", cfg->nice); 869 fprintf(f,"serialreadertimeout = %d\n", cfg->srtimeout); 870 fprintf(f,"maxlogsize = %d\n", cfg->max_log_size); 871 fprintf(f,"showecmdw = %d\n", cfg->show_ecm_dw); 872 fprintf(f,"waitforcards = %d\n", cfg->waitforcards); 873 fprintf(f,"preferlocalcards = %d\n", cfg->preferlocalcards); 874 fprintf(f,"\n"); 875 876 /*monitor settings*/ 877 fprintf(f,"[monitor]\n"); 878 //todo 879 880 881 882 fclose(f); 883 884 if(file_exists(bakfile)){ 885 if(remove(destfile) < 0) { 886 cs_log("Error removing original conf file %s (errno=%d). Will maintain original one!", destfile, errno); 887 if(remove(tmpfile) < 0) cs_log("Error removing temp conf file %s (errno=%d).!", tmpfile, errno); 888 return(1); 889 } 890 } else { 891 if(rename(destfile, bakfile) < 0){ 892 cs_log("Error renaming original conf file %s to %s (errno=%d). Will maintain original one!", destfile, bakfile, errno); 893 if(remove(tmpfile) < 0) cs_log("Error removing temp conf file %s (errno=%d).!", tmpfile, errno); 894 return(1); 895 } 896 } 897 if(rename(tmpfile, destfile) < 0){ 898 cs_log("Error renaming new conf file %s to %s (errno=%d). The config will be missing upon next startup as this is non-recoverable!", tmpfile, destfile, errno); 899 return(1); 900 } 901 return(0); 831 902 } 832 903
Note:
See TracChangeset
for help on using the changeset viewer.