コード例 #1
0
ファイル: 02-rbtree.c プロジェクト: nrdvana/userp
bool dump_node(TAP_state_t *state, userp_ident_t *root, int lev) {
	if (!root) return false;
	userp_ident_t *next= userp_ident_by_name_right(root);
	if (next) dump_node(state, next, lev+1);
	TAP_NOTE("%*s(%c) %s", lev*4, "", root->name_tree_node.color? 'R':'B', root->name);
	next= userp_ident_by_name_left(root);
	if (next) dump_node(state, next, lev+1);
	return true;
}
コード例 #2
0
ファイル: test_parser.c プロジェクト: atupal/klcommon
void dump_node( struct xmlNode *node )
{
	if( node == 0 )
	{
		return;
	}
	printf( "Node:%s Attr:", node->name );
	dump_attr( node->attr_list );
	putc( '\n', stdout );
	dump_node( node->children );
	dump_node( node->sibling );
}
コード例 #3
0
ファイル: test_parser.c プロジェクト: atupal/klcommon
int main( int argc, char **argv )
{
	FILE *fp = 0;
	if( argc < 2 )
	{
		fprintf( stderr, "Usage : %s filename.\n", argv[0] );
		exit( -1 );
	}
	fp = fopen( argv[1], "r" );
	if( fp == 0 )
	{
		fprintf( stderr, "Unable to open %s.\n", argv[1] );
		exit( -1 );
	}

	{
		struct xmlDocument *doc = xmldoc_new( fp );
		xml_seterrorfn( error_log );
		xml_parse( doc );
		dump_node( doc->root );
		xmldoc_free( doc );
	}
	fclose( fp );

	return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 void dump_node(Node *n, bool same_line, int padding, MappedSubstring orig) {
     int delta = 0;
     if (!same_line) {
         for (int i = 0; i < padding; ++i) {
             std::cout << " ";
         }
     }
     if (!orig.empty()) {
         auto s = haystack.find(orig.ref_str);
         for (int i = orig.l; i <= orig.r && i <= s->second.length(); ++i) {
             std::cout << s->second[i];
         }
         std::cout << "-";
         delta = orig.r - orig.l + 2;
         if (orig.r == std::numeric_limits<int>::max()) {
             delta = s->second.length() - orig.l + 2;
         }
     }
     same_line = true;
     for (auto t_it : n->g) {
         dump_node(t_it.second.tgt, same_line, padding + delta, t_it.second.sub);
         same_line = false;
     }
     if (same_line) {
         std::cout << "##" << std::endl;
     }
 }
コード例 #5
0
ファイル: debug.c プロジェクト: k0kubun/clannad
void
dump_vector(int indent, Vector *vec)
{
  for (int i = 0; i < vec->length; i++) {
    dump_node(indent, (Node *)vector_get(vec, i));
  }
}
コード例 #6
0
ファイル: c-gimplify.c プロジェクト: sequoiar/moxiedev
void
c_genericize (tree fndecl)
{
  FILE *dump_orig;
  int local_dump_flags;
  struct cgraph_node *cgn;

  /* Dump the C-specific tree IR.  */
  dump_orig = dump_begin (TDI_original, &local_dump_flags);
  if (dump_orig)
    {
      fprintf (dump_orig, "\n;; Function %s",
	       lang_hooks.decl_printable_name (fndecl, 2));
      fprintf (dump_orig, " (%s)\n",
	       (!DECL_ASSEMBLER_NAME_SET_P (fndecl) ? "null"
		: IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))));
      fprintf (dump_orig, ";; enabled by -%s\n", dump_flag_name (TDI_original));
      fprintf (dump_orig, "\n");

      if (local_dump_flags & TDF_RAW)
	dump_node (DECL_SAVED_TREE (fndecl),
		   TDF_SLIM | local_dump_flags, dump_orig);
      else
	print_c_tree (dump_orig, DECL_SAVED_TREE (fndecl));
      fprintf (dump_orig, "\n");

      dump_end (TDI_original, dump_orig);
    }

  /* Dump all nested functions now.  */
  cgn = cgraph_node (fndecl);
  for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
    c_genericize (cgn->decl);
}
コード例 #7
0
ファイル: dump.c プロジェクト: mommel/alien-svn
static svn_error_t *
open_file(const char *path,
          void *parent_baton,
          svn_revnum_t ancestor_revision,
          apr_pool_t *pool,
          void **file_baton)
{
  struct dir_baton *pb = parent_baton;
  struct edit_baton *eb = pb->edit_baton;
  const char *cmp_path = NULL;
  svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;

  /* If the parent directory has explicit comparison path and rev,
     record the same for this one. */
  if (ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev))
    {
      cmp_path = svn_relpath_join(pb->cmp_path,
                                  svn_relpath_basename(path, pool), pool);
      cmp_rev = pb->cmp_rev;
    }

  SVN_ERR(dump_node(eb, path,
                    svn_node_file, svn_node_action_change,
                    FALSE, cmp_path, cmp_rev, pool));

  *file_baton = NULL;  /* muhahahaha again */
  return SVN_NO_ERROR;
}
コード例 #8
0
ファイル: dump.c プロジェクト: mommel/alien-svn
static svn_error_t *
close_directory(void *dir_baton,
                apr_pool_t *pool)
{
  struct dir_baton *db = dir_baton;
  struct edit_baton *eb = db->edit_baton;
  apr_hash_index_t *hi;
  apr_pool_t *subpool = svn_pool_create(pool);

  for (hi = apr_hash_first(pool, db->deleted_entries);
       hi;
       hi = apr_hash_next(hi))
    {
      const void *key;
      const char *path;
      apr_hash_this(hi, &key, NULL, NULL);
      path = key;

      svn_pool_clear(subpool);

      /* By sending 'svn_node_unknown', the Node-kind: header simply won't
         be written out.  No big deal at all, really.  The loader
         shouldn't care.  */
      SVN_ERR(dump_node(eb, path,
                        svn_node_unknown, svn_node_action_delete,
                        FALSE, NULL, SVN_INVALID_REVNUM, subpool));
    }

  svn_pool_destroy(subpool);
  return SVN_NO_ERROR;
}
コード例 #9
0
ファイル: dump.c プロジェクト: mommel/alien-svn
static svn_error_t *
add_file(const char *path,
         void *parent_baton,
         const char *copyfrom_path,
         svn_revnum_t copyfrom_rev,
         apr_pool_t *pool,
         void **file_baton)
{
  struct dir_baton *pb = parent_baton;
  struct edit_baton *eb = pb->edit_baton;
  void *val;
  svn_boolean_t is_copy = FALSE;

  /* This might be a replacement -- is the path already deleted? */
  val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);

  /* Detect add-with-history. */
  is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);

  /* Dump the node. */
  SVN_ERR(dump_node(eb, path,
                    svn_node_file,
                    val ? svn_node_action_replace : svn_node_action_add,
                    is_copy,
                    is_copy ? copyfrom_path : NULL,
                    is_copy ? copyfrom_rev : SVN_INVALID_REVNUM,
                    pool));

  if (val)
    /* delete the path, it's now been dumped. */
    apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING, NULL);

  *file_baton = NULL;  /* muhahahaha */
  return SVN_NO_ERROR;
}
コード例 #10
0
ファイル: node.c プロジェクト: Qingtao-Cao/quiz
void dump_node(const node_t *node, const char *path)
{
	node_t *child;
	char *path_new;
	int i;

	assert (node && path);	/* path could point to an empty string but never NULL */

	if (!(path_new = (char *)malloc(strlen(path) + 2))) {
		return;
	}

	sprintf(path_new, "%s%c", path, node->c);

	if (node->cnt) {
		printf("%s : %d\n", path_new, node->cnt);
	}

	for (i = 0; i < AVAILABLE_CHARS; i++) {
		if (!(child = node->children[i])) {
			continue;
		}

		dump_node(child, path_new);
	}

	free(path_new);
}
コード例 #11
0
ファイル: util.c プロジェクト: Fresne/i3-1
char *store_restart_layout(void) {
    setlocale(LC_NUMERIC, "C");
    yajl_gen gen = yajl_gen_alloc(NULL);

    dump_node(gen, croot, true);

    setlocale(LC_NUMERIC, "");

    const unsigned char *payload;
    size_t length;
    y(get_buf, &payload, &length);

    /* create a temporary file if one hasn't been specified, or just
     * resolve the tildes in the specified path */
    char *filename;
    if (config.restart_state_path == NULL) {
        filename = get_process_filename("restart-state");
        if (!filename)
            return NULL;
    } else {
        filename = resolve_tilde(config.restart_state_path);
    }

    int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
    if (fd == -1) {
        perror("open()");
        free(filename);
        return NULL;
    }

    size_t written = 0;
    while (written < length) {
        int n = write(fd, payload + written, length - written);
        /* TODO: correct error-handling */
        if (n == -1) {
            perror("write()");
            free(filename);
            close(fd);
            return NULL;
        }
        if (n == 0) {
            DLOG("write == 0?\n");
            free(filename);
            close(fd);
            return NULL;
        }
        written += n;
        DLOG("written: %zd of %zd\n", written, length);
    }
    close(fd);

    if (length > 0) {
        DLOG("layout: %.*s\n", (int)length, payload);
    }

    y(free);

    return filename;
}
コード例 #12
0
ファイル: red-black-tree.c プロジェクト: tanakamura/anytrace
static void
dump_node(struct npr_rbtree_node *n, int depth)
{
    if (n) {
        dump_node(n->left, depth+1);
        for (int di=0; di<depth; di++) {
            printf("    ");
        }
        if (n->color == BLACK) {
            printf("{B, %d,%d}\n", (int)n->key, (int)n->v);
        } else {
            printf("{R, %d,%d}\n", (int)n->key, (int)n->v);
        }

        dump_node(n->right, depth+1);
    }
}
コード例 #13
0
ファイル: trie.c プロジェクト: jeffli999/bitband
void dump_trie(Trie *v, int detail)
{
	int		i;

	dump_node(v, detail);
	for (i = 0; i < v->nchildren; i++)
		dump_trie(&v->children[i], detail);
}
コード例 #14
0
ファイル: trie.c プロジェクト: jeffli999/bitband
void dump_path(Trie *v, int detail)
{
	int		depth = v->depth, i;
	Trie 	*path[MAX_DEPTH];

	while (v != NULL) {
		path[v->depth] = v;
		v = v->parent;
	}

	for (i = 0; i < depth; i++) {
		if (path[i]->nrules <= 16)
			dump_node(path[i], detail);
		else
			dump_node(path[i], 0);
	}
}
コード例 #15
0
ファイル: printing.c プロジェクト: fwum/fwum
/*
Print the created AST to stdout, mostly for debugging purposes
*/
void dump(file_contents contents) {
    {
        linked_iter iterator = ll_iter_head(contents.imports);
        while(ll_iter_has_next(&iterator)) {
            import_declaration *import = ll_iter_next(&iterator);
            printf("IMPORT: %s\n", evaluate(import->name));
        }
    }
    {
        linked_iter iterator = ll_iter_head(contents.enums);
        while(ll_iter_has_next(&iterator)) {
            enum_declaration *dec = ll_iter_next(&iterator);
            printf("ENUM: %s\n", evaluate(dec->name));
            linked_iter items = ll_iter_head(dec->options);
            while(ll_iter_has_next(&items)) {
                statement *option = ll_iter_next(&items);
                printf("\tOPTION: %s\n", evaluate(option->data));
            }
        }
    }
	{
		linked_iter iterator = ll_iter_head(contents.structs);
		while(ll_iter_has_next(&iterator)) {
            struct_declaration *current = ll_iter_next(&iterator);
			printf("STRUCT: %s\n", evaluate(current->name));
            linked_iter iterator = ll_iter_head(current->members);
			while(ll_iter_has_next(&iterator)) {
                struct_member *member = ll_iter_next(&iterator);
				printf("\tMEMBER: NAME: %s | TYPE: %s\n", evaluate(member->name), evaluate(member->type));
			}
		}
	}
	{
        linked_iter iterator = ll_iter_head(contents.functions);
        while(ll_iter_has_next(&iterator)) {
            func_declaration *current = ll_iter_next(&iterator);
			printf("FUNC: %s | TYPE : %s\n", evaluate(current->name), evaluate(current->type));
            printf("\tPARAMETERS:\n");
			dump_node(current->parameters, 2);
            printf("\tBODY:\n");
			dump_node(current->root->children, 2);
		}
	}

}
コード例 #16
0
ファイル: dump.c プロジェクト: ahaym/trumpify
static int dump_node(pNode node)
{
  switch(node->type) {
  case literal: printf("\"%s\"", node->data); break;
  case symbol: 
    printf("{%s", node->data); 
    if(node->params) { printf("("); dump_atoms(node->params); printf(")"); };
    printf("}"); 
    break;
  case mapping: dump_node(node->params); printf(" > %s", node->data); break;
  case deref: printf("DEREF("); dump_node(node->params); printf(")"); break;
  case var_conddef: printf("%s << ", node->data); dump_node(node->params); 
      break;
  case var_def: printf("%s = ", node->data); dump_node(node->params); break;
  case code: printf("code:"); dump_code(node->data); break;
    break;
  };
};
コード例 #17
0
ファイル: astree.cpp プロジェクト: Nicojaw/104a-A4
void yyprint (FILE* outfile, unsigned short toknum,
              astree* yyvaluep) {
   if (is_defined_token (toknum)) {
      dump_node (outfile, yyvaluep);
   }else {
      fprintf (outfile, "%s(%d)\n",
               get_yytname (toknum), toknum);
   }
   fflush (NULL);
}
コード例 #18
0
ファイル: astree.c プロジェクト: mtnash/oc
void yyprint (FILE *outfile, unsigned short toknum, astree yyvaluep) {
   fprintf (outfile, "%d=%s)\n%*s(",
             toknum, get_yytname (toknum), 9, "");
   if (is_astree (yyvaluep)) {
      dump_node (outfile, yyvaluep, 3);
   }else{
      fprintf (outfile, "yyvaluep = %p", (void*) yyvaluep);
   }
   fflush (NULL);
}
コード例 #19
0
ファイル: astree.cpp プロジェクト: Nicojaw/104a-A4
static void dump_astree_rec (FILE* outfile, astree* root,
                             int depth) {
   if (root == NULL) return;
   dump_node (outfile, root);
   fprintf (outfile, "\n");
   for (size_t child = 0; child < root->children.size();
        ++child) {
      dump_astree_rec (outfile, root->children[child],
                       depth + 1);
   }
}
コード例 #20
0
ファイル: astree.c プロジェクト: mtnash/oc
static void dump_astree_rec (FILE *outfile, astree root, int depth) {
   astree child = NULL;
   if (root == NULL) return;
   assert (is_astree (root));
   //fprintf (outfile, "%*s%s ", depth * 3, "", root->lexinfo);
   dump_node (outfile, root, depth);
   fprintf (outfile, "\n");
   for (child = root->first; child != NULL; child = child->next) {
      dump_astree_rec (outfile, child, depth + 1);
   }
}
コード例 #21
0
static void dump_branch (
	tree_s		*tree,
	branch_s	*branch,
	unint		depth)
{
	key_s	*k;
	unint	i;

	if (!branch) return;

	dprintk("%sbranch: num keys = %d\n",
		indent(depth), branch->br_num);
	dprintk("%sfirst %llx\n", indent(depth), branch->br_first);
	dump_node(tree, branch->br_first, depth+1);
	for (k = branch->br_key, i = 0; i < branch->br_num; k++, i++) {
		dprintk("%s%4lu. %16llx: %llx\n",
			indent(depth),
			i, k->k_key, k->k_block);
		dump_node(tree, k->k_block, depth+1);
	}
}
コード例 #22
0
ファイル: mtree.c プロジェクト: taysom/tau
void dump_branch (
    tree_s		*tree,
    branch_s	*branch,
    unint		depth)
{
    key_s	*k;
    unint	i;

    if (!branch) return;

    printf("%sbranch: num keys = %d\n",
           indent(depth), branch->br_num);
    printf("%sfirst %p\n", indent(depth), branch->br_first);
    dump_node(tree, branch->br_first, depth+1);
    for (k = branch->br_key, i = 0; i < branch->br_num; k++, i++) {
        printf("%s%4lu. %8x: %p\n",
               indent(depth),
               i, k->k_key, k->k_node);
        dump_node(tree, k->k_node, depth+1);
    }
}
コード例 #23
0
ファイル: test-uglib.c プロジェクト: erdincay/uget2
void  test_node (void)
{
	UgNode*	root;
	UgNode*	node1;
	UgNode*	node2;
	UgNode*	node3;
	UgNode*	node4;

	puts ("\n--- test_node:");
	root = ug_node_new ();
	node1 = ug_node_new ();
	node1->data = (void*)(uintptr_t) 1;
	node2 = ug_node_new ();
	node2->data = (void*)(uintptr_t) 2;
	node3 = ug_node_new ();
	node3->data = (void*)(uintptr_t) 3;
	node4 = ug_node_new ();
	node4->data = (void*)(uintptr_t) 4;

	ug_node_append (root, node3);
	printf ("ug_node_append (3)\n");
	ug_node_prepend (root, node1);
	printf ("ug_node_prepend (1)\n");
	ug_node_insert (root, node3, node2);
	printf ("ug_node_insert (2) before 3\n");
	ug_node_append (root, node4);
	printf ("ug_node_append (4)\n");
	printf ("root.n_children : %d\n", root->n_children);
	dump_node (root);

	ug_node_unlink (node2);
	dump_node (node2);

	ug_node_free (root);
	ug_node_free (node1);
	ug_node_free (node2);
	ug_node_free (node3);
	ug_node_free (node4);
}
コード例 #24
0
ファイル: b2r2_debug.c プロジェクト: 791254467/u8500_kernel
static ssize_t last_job_read(struct file *filp, char __user *buf,
		size_t bytes, loff_t *off)
{
	struct b2r2_control *cont = filp->f_dentry->d_inode->i_private;
	struct b2r2_node *node = cont->last_job;
	int node_count = 0;
	int i;

	size_t size;
	size_t count;
	loff_t offs = *off;

	for (; node != NULL; node = node->next)
		node_count++;

	size = node_count * DUMPED_NODE_SIZE;

	if (node_count != cont->prev_node_count) {
		kfree(cont->last_job_chars);

		cont->last_job_chars = kzalloc(size, GFP_KERNEL);
		if (!cont->last_job_chars)
			return 0;
		cont->prev_node_count = node_count;
	}

	mutex_lock(&cont->last_job_lock);
	node = cont->last_job;
	for (i = 0; i < node_count; i++) {
		BUG_ON(node == NULL);
		dump_node(cont->last_job_chars +
			i * DUMPED_NODE_SIZE/sizeof(char),
			node);
		node = node->next;
	}
	mutex_unlock(&cont->last_job_lock);

	if (offs > size)
		return 0;

	if (offs + bytes > size)
		count = size - offs;
	else
		count = bytes;

	if (copy_to_user(buf, cont->last_job_chars + offs, count))
		return -EFAULT;

	*off = offs + count;
	return count;
}
コード例 #25
0
ファイル: dfont.c プロジェクト: 676381026/ejoy2d
void 
dfont_dump(struct dfont * df) {
	printf("version = %d\n",df->version);
	printf("By version : ");
	struct hash_rect *hr;
	int version = -1;
	list_for_each_entry(hr, struct hash_rect, &df->time, time) {
		if (hr->version != version) {
			version = hr->version;
			printf("\nversion %d : ", version);
		}
		dump_node(hr);
	}
	printf("\n");
	printf("By line : \n");
	int i;
	for (i=0;i<df->max_line;i++) {
		struct font_line *line = &df->line[i];
		printf("line (y=%d h=%d space=%d) :",line->start_line, line->height,line->space);
		list_for_each_entry(hr, struct hash_rect, &line->head, next_char) {
			printf("%d(%d-%d) ",hr->c,hr->rect.x,hr->rect.x+hr->rect.w-1);
		}
		printf("\n");
	}
	printf("By hash : \n");
	for (i=0;i<HASH_SIZE;i++) {
		struct hash_rect *hr = df->hash[i];
		if (hr) {
			printf("%d : ",i);
			while (hr) {
				dump_node(hr);
				hr = hr->next_hash;
			}

			printf("\n");
		}
	}
}
コード例 #26
0
ファイル: printing.c プロジェクト: fwum/fwum
/*
Print an AST node to stdout (recursive)
*/
void dump_node(linked_list *list, int indentation) {
    linked_iter iterator = ll_iter_head(list);
    while(ll_iter_has_next(&iterator)) {
        for(int i = 0; i < indentation; i++) {
    		printf("\t");
        }
        statement *state = ll_iter_next(&iterator);
        printf("%s", statement_to_string(state->type));
    	printf(": %s\n", evaluate(state->data));
    	if(state->children != NULL) {
    		dump_node(state->children, indentation + 1);
        }
    }
}
コード例 #27
0
ファイル: astar.c プロジェクト: Elzair/nazghul
static struct astar_node *astar_path_reverse(struct astar_node *node)
{
	struct astar_node *ret;

	dump_node(node);

	/* simple case of only one node in the path */
	if (!node->next)
		return node;

	node->len = 0;
	ret = astar_path_reverse_aux(node->next, node);
	node->next = 0;

	return ret;
}
コード例 #28
0
ファイル: yadb_data.c プロジェクト: blabos/Random-Head
void dump_db(yadb_t* db) {
	printf("File: '%s'\n", db->filename);
	printf("Head: %10p\n", db->head);
	printf("Tail: %10p\n", db->tail);
	printf("Size: %10d\n", db->size);
	
	node_t* it = _db_begin(db);
	
	if (it) {
		printf("Data: \n\n");
	}
	
	for (it = _db_begin(db); it != _db_end(db); it = it->next) {
		dump_node(it);
	}
}
コード例 #29
0
ファイル: astar.c プロジェクト: Elzair/nazghul
static struct astar_node *astar_path_reverse_aux(struct astar_node *node, struct astar_node *prev)
{
	struct astar_node *ret;

	dump_node(node);

	node->len = prev->len + 1;
	assert(node->len < 1000);	/* debug */
	if (node->next)
		ret = astar_path_reverse_aux(node->next, node);
	else
		ret = node;
	node->next = prev;

	return ret;
}
コード例 #30
0
ファイル: repository.c プロジェクト: 0-T-0/ps4-linux
static int delete_node(u64 n1, u64 n2, u64 n3, u64 n4)
{
	int result;

	dump_node(0, n1, n2, n3, n4, 0, 0);

	result = lv1_delete_repository_node(n1, n2, n3, n4);

	if (result) {
		pr_devel("%s:%d: lv1_delete_repository_node failed: %s\n",
			__func__, __LINE__, ps3_result(result));
		return -ENOENT;
	}

	return 0;
}