static void node_dump(Lib3dsNode *node, int level) { Lib3dsNode *p; char l[128]; assert(node); memset(l, ' ', 2*level); l[2*level] = 0; if (node->type == LIB3DS_NODE_MESH_INSTANCE) { Lib3dsMeshInstanceNode *n = (Lib3dsMeshInstanceNode*)node; printf("%s%s [%s] (%s)\n", l, node->name, n->instance_name, node_names_table[node->type] ); } else { printf("%s%s (%s)\n", l, node->name, node_names_table[node->type] ); } for (p = node->childs; p != 0; p = p->next) { node_dump(p, level + 1); } }
STATIC void node_dump(Linear_s *t, Blknum_t blknum, int indent) { Buf_s *buf; Node_s *node; Blknum_t overflow; if (!blknum) return; buf = t_get(t, blknum); node = buf->d; Hrec_s rec; unint i; if (Dump_buf) { pr_buf(buf, indent); } pr_head(node, indent); for (i = 0; i < node->numrecs; i++) { rec = get_rec(node, i); pr_indent(indent); printf("%ld. ", i); rec_dump(rec); } overflow = node->overflow; buf_put(&buf); if (overflow) { node_dump(t, overflow, indent+1); } }
void symbol_dump(int indent, struct symbol *sym) { const char *ty; int i; for (i = 0; i < indent; i++) fprintf(stderr, "\t"); if (sym == NULL) { fprintf(stderr, "*NULLSYM*\n"); return; } switch (sym->type) { case SYM_TYPE_NODE: ty = "node"; break; default: ty = "?"; break; } fprintf(stderr, "%-30s %-10s", sym->token, ty); if (sym->type == SYM_TYPE_NODE) { node_dump(sym->dest); } else { fprintf(stderr, "\n"); } }
static gboolean node_dump_tvs(gpointer key, gpointer value, gpointer data) { gchar *msg_node; gchar *tmp; gchar **msg = (gchar **)data; const node_t *node = (const node_t *)value; msg_node = node_dump(node); tmp = *msg; *msg = g_strdup_printf("%snode %p:\n%s\n", tmp, node, msg_node); g_free(tmp); g_free(msg_node); return FALSE; }
/* Called for every event a node receives. Right now it's used to * set a message in the statusbar and launch the popup timeout */ static gint node_item_event (GnomeCanvasItem * item, GdkEvent * event, canvas_node_t * canvas_node) { gdouble item_x, item_y; const node_t *node = NULL; /* This is not used yet, but it will be. */ item_x = event->button.x; item_y = event->button.y; gnome_canvas_item_w2i (item->parent, &item_x, &item_y); switch (event->type) { case GDK_2BUTTON_PRESS: if (canvas_node) node = nodes_catalog_find(&canvas_node->canvas_node_id); if (node) { node_protocols_window_create( &canvas_node->canvas_node_id ); g_my_info ("Nodes: %d (shown %u)", nodes_catalog_size(), displayed_nodes); if (DEBUG_ENABLED) { gchar *msg = node_dump(node); g_my_debug("%s", msg); g_free(msg); } } break; default: break; } return FALSE; } /* node_item_event */
/// @brief dumps node contents, optionally recursively /// @param[in] node_addr block number of node /// @param[in] recurse enable depth-first recursion through branch nodes void node_dump(uint32_t node_addr, bool recurse) { node_ptr node = node_map(node_addr, false); warnx("%s: this 0x%" PRIx32 " parent 0x%" PRIx32 " prev 0x%" PRIx32 " next 0x%" PRIx32 " cnt %" PRIu16 " free %" PRIu32, __func__, node->hdr.this, node->hdr.parent, node->hdr.prev, node->hdr.next, node->hdr.cnt, node_free(node)); if (node->hdr.leaf) { node_dump_leaf(node); } else { node_dump_branch(node); if (recurse) { const node_ref *elem_end = node->b_elems + node->hdr.cnt; for (const node_ref *elem = node->b_elems; elem < elem_end; ++elem) { node_dump(elem->addr, true); } } } node_unmap(node); }
int main(int argc, char **argv) { FILE *file; Lib3dsFile *f = 0; Lib3dsIo io; int result; int i; parse_args(argc, argv); file = fopen(filename, "rb"); if (!file) { fprintf(stderr, "***ERROR***\nFile not found: %s\n", filename); exit(1); } f = lib3ds_file_new(); memset(&io, 0, sizeof(io)); io.self = file; io.seek_func = fileio_seek_func; io.tell_func = fileio_tell_func; io.read_func = fileio_read_func; io.write_func = fileio_write_func; io.log_func = fileio_log_func; result = lib3ds_file_read(f, &io); fclose(file); if (!result) { fprintf(stderr, "***ERROR***\nLoading file failed: %s\n", filename); exit(1); } if (flags & LIB3DSDUMP_MATERIALS) { printf("Dumping materials:\n"); for (i = 0; i < f->nmaterials; ++i) material_dump(f->materials[i]); printf("\n"); } if (flags & LIB3DSDUMP_TRIMESHES) { printf("Dumping meshes:\n"); for (i = 0; i < f->nmeshes; ++i) mesh_dump(f->meshes[i]); printf("\n"); } if (flags & LIB3DSDUMP_INSTANCES) { Lib3dsNode *p; printf("Dumping instances:\n"); for (p = f->nodes; p != 0; p = p->next) { dump_instances(p, ""); } printf("\n"); } if (flags & LIB3DSDUMP_CAMERAS) { printf("Dumping cameras:\n"); for (i = 0; i < f->ncameras; ++i) camera_dump(f->cameras[i]); printf("\n"); } if (flags & LIB3DSDUMP_LIGHTS) { printf("Dumping lights:\n"); for (i = 0; i < f->nlights; ++i) light_dump(f->lights[i]); printf("\n"); } if (flags & LIB3DSDUMP_NODES) { Lib3dsNode *p; printf("Dumping node hierarchy:\n"); for (p = f->nodes; p != 0; p = p->next) { node_dump(p, 1); } printf("\n"); } if (output) { if (!lib3ds_file_save(f, output)) { printf("***ERROR**** Writing %s\n", output); } } lib3ds_file_free(f); return 0; }
int main(){ FILE* base = NULL; node* tree = NULL; node* temp_nd = NULL; char answer[MAX_ELEM_SIZE] = ""; char question[MAX_ELEM_SIZE] = ""; tree = node_new(); base = fopen("out.txt", "r"); create_tree(base, tree, get_node); temp_nd = tree; printf("1"); while (strcmp(answer, "q\n")) { printf("2"); if ((strcmp(answer, "r\n") == 0)) { node_dump(tree, base); create_tree(base, tree, get_node); temp_nd = tree; } fflush(stdin); fputs(temp_nd -> data, stdout); fgets(answer,MAX_ELEM_SIZE ,stdin); printf("%s", answer); if (strcmp(answer, "y\n") == 0){ if (temp_nd -> left == NULL && temp_nd -> right == NULL){ printf("Я знал что угадаю.Введите q чтобы выйти. Введите r для рестарта.\n"); } else if (temp_nd -> left != NULL) { temp_nd = temp_nd -> left; } } if (strcmp(answer, "n\n") == 0){ if (temp_nd -> left == NULL && temp_nd -> right == NULL){ printf("Вы знаете другие операционные системы с таки ми свойствами? Введите ее название:\n"); fflush(stdin); fgets(answer, MAX_ELEM_SIZE, stdin); answer[strlen(answer) - 1] = '\0'; printf("Задайте вопрос определяющий вашу операционнуюю систему:\n"); fflush(stdin); fgets(question,MAX_ELEM_SIZE , stdin); question[strlen(question) - 1] = '\0'; create_new_branch(temp_nd, question, answer); printf("Ваш вариант добавлен в базу данных.Введите q чтобы выйти.Введите r для рестарта.\n"); } else if (temp_nd -> right != NULL){ temp_nd = temp_nd -> right; } } } fclose(base); base = fopen("out.txt", "w"); node_dump(tree, base); fclose(base); // node_dtor(tree); return 0; }
// visitor function for large inline bool visit(Zone *zone, Large *large) { // send single block information node_dump(large->address(), large->size(), large->layout(), large->refcount()); // always continue return true; }