/* * reads in data from all relevant files * returns a pointer to an event object */ Event* read_data() { char* filename; Event* event; Vector* nodes; Vector* tracks; Vector* courses; Vector* entrants; filename = get_filename("Please enter name file: "); event = read_event(filename); filename = get_filename("Please enter nodes file: "); nodes = read_nodes(filename); filename = get_filename("Please enter tracks file: "); tracks = read_tracks(filename, nodes); filename = get_filename("Please enter courses file: "); courses = read_courses(filename, nodes, tracks); filename = get_filename("Please enter entrants file: "); entrants = read_entrants(filename, courses); event->nodes = nodes; event->entrants = entrants; return event; }
teledisk_prop_t * teledisk_open(const char *filename) { int ret; FILE *f; teledisk_prop_t *prop; f = fopen(filename, "rb"); if (f == NULL) return NULL; prop = malloc(sizeof(teledisk_prop_t)); if (prop == NULL) return NULL; prop->f = f; prop->heads = 0; prop->cylinders = 0; prop->sector_size = 0; prop->sectors_total = 0; prop->comment = NULL; prop->comment_date = NULL; if (!read_header(prop)) { free(prop); return NULL; } prop->filename = strdup(filename); while (242) { ret = read_tracks(prop); if (ret > 0) break; if (ret < 0) { teledisk_close(prop); return NULL; } } return prop; }
/** * @brief This function prompts the user with a question asking for the path to * a file containing data on tracks. The file should have data about paths * between nodes and the maximum time a entrant should use between the nodes. * * @param node_list A pointer to a NODE_LIST, it should be populated. The nodes * are needed to ensure that the tracks does not contain none existing nodes. * * @return This function returns a pointer to a TRACK_LIST if successful. If the * function fails NULL is returned. */ TRACK_LIST *get_tracks(NODE_LIST *node_list) { char response[255]; do { TRACK_LIST *temp = NULL; printf("Please enter a path to a file containing track data:\n>>> "); scanf(" %[^\t\n]", response); temp = read_tracks(response, node_list); if (temp != NULL) { printf("[i] %d tracks loaded from '%s'.\n\n", temp->size, response); return temp; } } while (1); }
void SvgGraph::read_settings(ifstream& setting_file) { strip_utf8header(setting_file); string temp_line; string head; string value; //background_color=color //background_radius=int std::getline(setting_file, temp_line); head = temp_line.substr(0, temp_line.find("=")); if (head.compare("background_color") != 0) { std::cout << "unexpected string " << head << " while waiting for color" << std::endl; exit(1); } background_color = color(temp_line.substr(temp_line.find("=") + 1)); std::getline(setting_file, temp_line); head = temp_line.substr(0, temp_line.find("=")); if (head.compare("background_radius") != 0) { std::cout << "unexpected string " << head << " while waiting for radius" << std::endl; exit(1); } background_radius = stoi(temp_line.substr(temp_line.find("=") + 1)); while (std::getline(setting_file, temp_line)) { //setting_file >> temp_line; std::cout<<temp_line<<std::endl; //Name(string) "file="filepath(string) auto delimiter = temp_line.find(" "); if (delimiter == temp_line.npos) { std::cout << "can't find blanksbace in " << temp_line << std::endl; exit(1); } string head = temp_line.substr(0, delimiter); delimiter = temp_line.find("=", delimiter); if (delimiter == temp_line.npos) { std::cout << "can't find = in " << temp_line << std::endl; exit(1); } string file_path = temp_line.substr(delimiter + 1); if (head_set.find(head) == head_set.end()) { std::cout << "unknownd head " << head << std::endl; exit(1); } if (head.compare("circle") == 0) { read_circles(file_path); } if (head.compare("band") == 0) { read_bands(file_path); } if (head.compare("tick_onband") == 0) { read_tick_onbands(file_path); } if (head.compare("fill_onband") == 0) { read_fill_onbands(file_path); } if (head.compare("label_onband") == 0) { read_label_onbands(file_path); } if (head.compare("linechart_onband") == 0) { read_linechart_onbands(file_path); } if (head.compare("heatmap_onband") == 0) { read_heatmap_onbands(file_path); } if (head.compare("histogram_onband") == 0) { read_histogram_onbands(file_path); } if (head.compare("link") == 0) { read_links(file_path); } if (head.compare("track") == 0) { read_tracks(file_path); } } }