int write_cfg_for_rec(struct opt_s *opt, char *filename) { int err; config_t cfg; config_init(&cfg); stub_rec_cfg(config_root_setting(&cfg), opt); err = write_cfg(&cfg, filename); config_destroy(&cfg); return err; }
static int update_cfg(void) { if(write_cfg(CFGFILE, &cfg) == -1) { return -1; } if(dpid == -1) { if((dpid = get_daemon_pid()) == -1) { return -1; } } if(kill(dpid, SIGHUP) == -1 && errno != EPERM) { dpid = -1; /* invalidate pid, will be searched again next time */ return -1; } return 0; }
void Ut::read_write() { qDebug() << "begin read_write"; QFile inp(filename); if (!inp.open(QFile::ReadOnly)) { qDebug() << "ERROR1"; return; } QTextStream text1(&inp); QString filename2 = filename.left(filename.size() - 6) + "ut.txt"; qDebug() << filename << "-->" << filename2; QFile out(filename2); if (!out.open(QFile::WriteOnly)) { qDebug() << "ERROR2"; return; } QTextStream text2(&out); while (!text1.atEnd()) { QString line(text1.readLine()); if (line.mid(42,1) != " ") text2 << line << endl; else if (ui.JD2UT->isChecked()) text2 << convJD(line) << endl; else text2 << conv(line) << endl; } inp.close(); out.close(); ui.convert->setText("DONE!"); ui.convert->setDisabled(true); write_cfg(); qDebug() << "end read_write"; }