static void print_and_process_tree(struct print_manager *pm, GNode * node) { //printf("Printing tree\n"); prong_assert(node != NULL); prong_assert(node->data != NULL); struct job_node_data *data = (struct job_node_data *) node->data; unsigned int num_results; const result_t *results = contract_completion_report_get_results(data->node_report, &num_results); prong_assert(num_results > 0); unsigned int num_ranges; block_range_t *ranges = result_get_block_ranges(results[0], &num_ranges); int is_valid = 1; if ((contract_get_absolute_offset(data->node_contract) != pm->current_offset) && (is_offset_within_ranges(pm->current_offset, ranges, num_ranges) != 1)) { is_valid = 0; } if (is_valid == 0) { printf("WARNING MCP passed me a node that is out of sequence!\n"); printf("Print manager has printed up to offset %lld, but the node passed has offset %lld\n", pm->current_offset * pm->block_size, contract_get_absolute_offset(data->node_contract) * pm->block_size); printf("I *should* assert and blow up, but it's commented out for now\n"); unsigned int num_results = 0; const result_t *results = contract_completion_report_get_results(data->node_report, &num_results); prong_assert(num_results > 0); printf("The data type of the node was %s\n", result_get_brief_data_description(results[0])); return; } prong_assert(is_valid != 0); pm->print_handler->print_node(pm->current_offset, pm->block_size, node); save_children(pm, node); //printf("Incremented current offset\n"); pm->current_offset++; }
static void save_window (GString *s, GdkWindow *window) { gint x, y; GdkColor *color; gdk_window_get_position (window, &x, &y); color = g_object_get_data (G_OBJECT (window), "color"); g_string_append_printf (s, "%d,%d %dx%d (%d,%d,%d) %d %d\n", x, y, gdk_window_get_width (window), gdk_window_get_height (window), color->red, color->green, color->blue, gdk_window_has_native (window), g_list_length (gdk_window_peek_children (window))); save_children (s, window); }
static void save_clicked (GtkWidget *button, gpointer data) { GString *s; GtkWidget *dialog; GFile *file; s = g_string_new (""); save_children (s, gtk_widget_get_window (darea)); dialog = gtk_file_chooser_dialog_new ("Filename for window data", NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)); g_file_replace_contents (file, s->str, s->len, NULL, FALSE, 0, NULL, NULL, NULL); g_object_unref (file); } gtk_widget_destroy (dialog); g_string_free (s, TRUE); }
void StepNode::save(FILE * file){ key.save(file); data.save(file); fprintf(file,"\n"); save_children(file); }
static int do_tree_check(struct print_manager *pm) { //printf("Checking abs_off tree\n"); pm->lookup_offset = pm->current_offset; g_tree_foreach(pm->abs_tree, (GTraverseFunc) abs_tree_check, pm); if (pm->destroy_array != NULL) { for (int i = 0; i < pm->destroy_array->len; i++) { long long off = g_array_index(pm->destroy_array, long long, i); GNode *node = (GNode *) g_tree_lookup(pm->abs_tree, &off); save_children(pm, node); g_tree_remove(pm->abs_tree, &off); } g_array_free(pm->destroy_array, TRUE); pm->destroy_array = NULL; } if (pm->print_array != NULL) { for (int i = 0; i < pm->print_array->len; i++) { long long off = g_array_index(pm->print_array, long long, i); GNode *node = (GNode *) g_tree_lookup(pm->abs_tree, &off); print_and_process_tree(pm, node); g_tree_remove(pm->abs_tree, &off); } g_array_free(pm->print_array, TRUE); pm->print_array = NULL; } //printf("Checking continuation tree\n"); g_tree_foreach(pm->continuation_tree, (GTraverseFunc) continuation_tree_check, pm); if (pm->destroy_array != NULL) { for (int i = 0; i < pm->destroy_array->len; i++) { block_range_t br = g_array_index(pm->destroy_array, block_range_t, i); gboolean ret = g_tree_remove(pm->continuation_tree, br); prong_assert(ret == TRUE); block_range_close(br); } g_array_free(pm->destroy_array, TRUE); pm->destroy_array = NULL; } if (pm->print_array != NULL) { for (int i = 0; i < pm->print_array->len; i++) { block_range_t br = g_array_index(pm->print_array, block_range_t, i); struct continuation_node *node = (struct continuation_node *) g_tree_lookup(pm->continuation_tree, br); prong_assert(node != NULL); if (node->is_constant == 1) { pm->print_handler->print_const_continuation((unsigned long long) pm->current_offset * pm->block_size, (unsigned long long) node->owner_offset * pm->block_size, node->path); //printf("%13lld %13lld Constant\n", pm->current_offset * pm->block_size, node->owner_offset * pm->block_size); } else { pm->print_handler->print_continuation((unsigned long long) pm->current_offset * pm->block_size, (unsigned long long) node->owner_offset * pm->block_size, node->brief_description); //printf("%13lld %13lld (Continuation of %s)\n", pm->current_offset * pm->block_size, node->owner_offset * pm->block_size, node->brief_description); } //printf("Incremented current offset\n"); pm->current_offset++; block_range_close(br); } g_array_free(pm->print_array, TRUE); pm->print_array = NULL; return 1; } return 0; }