static int conf_add_connection(const char *rel, const char *full) { char buf[PATH_MAX]; Connection *c; c = connections + nconnections; connection_init(c); c->name = xstrdup(rel); make_path(buf, full, "command"); c->command = read_data_string(buf); if(!c->command) { parse_error(buf,"cannot read command data",xsyserr()); return -1; } make_path(buf, full, "update"); if(read_data_list(buf, conf_add_update, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read update data",xsyserr()); return -1; } conf_add_update(c, "image"); conf_add_update(c, "beep"); } make_path(buf, full, "reset"); if(read_data_list(buf, conf_add_reset, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read reset data",xsyserr()); return -1; } conf_add_reset(c, "image-reset"); } make_path(buf, full, "folders"); if(read_data_list(buf, conf_add_folder, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read folder data",xsyserr()); return -1; } conf_add_folder(c, "INBOX"); } make_path(buf, full, "secret"); if(!dir_is_protected(buf)) { parse_error(buf,"\"secret\" directory has loose permissions",0); return -1; } nconnections++; return 0; }
void read_input() { char data_list_path[1024]; FILE *input_file=open_file("input","r"); read_formatted_from_file_expecting(data_list_path,input_file,"%s","data_list_file"); read_formatted_from_file_expecting(corr_name,input_file,"%s","corr_name"); read_formatted_from_file_expecting((char*)(&tmin),input_file,"%d","tmin"); read_formatted_from_file_expecting((char*)(&tmax),input_file,"%d","tmax"); read_data_list(data_list_path); fclose(input_file); }