void printnode(int i, struct segtabnode *n)
{
    if (!n)
        return;
    printnode(i + 1, n->left);
    printf("%*s%d %d %ld\n", i, "", n->localseg, n->destseg, n->offset);
    printnode(i + 1, n->right);
}
void mostrar(NO *x, int b, FILE *da1) {

    if (x == NULL)
    {
        printnode(-1, b, da1);
        return;
    }
    mostrar(x->direita, b+1, da1);
    printnode(x->matricula, b, da1);
    mostrar(x->esquerda, b+1, da1);
}
示例#3
0
void dictionary::printall(FILE * fp)
    {
    for(tchildrencount i = 0;i < NODES.ntoplevel;++i)
        {
        printnode(0,i,fp);
        }
    }
示例#4
0
void dictionary::printnode(size_t indent, tindex pos, FILE * fp)
    {
    tchildren n = NODES.numberOfChildren[pos];
    tchildrencount i;
    for(size_t j = indent;j;--j)
        fputc(' ',fp);
    fprintf(fp,"%s",NODES.strings[pos]);
    if(NODES.pos[pos] < 0)
        {
        fprintf(fp,"\n");
        for(i = 0;i < n;++i)
            {
            printnode(indent + 2,i - NODES.pos[pos],fp);
            }
        }
    else
        {
        fprintf(fp,"(");
        for(i = 0;i < n;++i)
            {
            printlex(NODES.pos[pos] + i,fp);
            if(i < NODES.numberOfChildren[pos] - 1)
                fprintf(fp,",");
            }
        fprintf(fp,")\n");
        }
    }
示例#5
0
/*
 *	Read a directory
 */
int
dread(Fid *fidp, int cnt)
{
	uchar *q, *eq, *oq;
	int n, skip;
	Node *np;

	if(debugfd >= 0)
		fprint(debugfd, "dread %d\n", cnt);

	np = fidp->node;
	oq = q = rbuf+IOHDRSZ;
	eq = q+cnt;
	if(fidp->dirindex >= np->count)
		return 0;

	skip = fidp->dirindex;
	for(np = np->children; skip > 0 && np; np = np->sibs)
		skip--;
	if(np == 0)
		return 0;

	for(; q < eq && np; np = np->sibs){
		if(debugfd >= 0)
			printnode(np);
		if((n=convD2M(&np->d, q, eq-q)) <= BIT16SZ)
			break;
		q += n;
		fidp->dirindex++;
	}
	return q - oq;
}
示例#6
0
文件: hash.c 项目: ashikawa/scripts
void printnode( struct nlist *np )
{
	if(np != NULL){
		printf("%s:%s,", np->name, np->defn);
		printnode(np->next);
	}
}
示例#7
0
文件: doc.c 项目: echoline/echsml
void printnode(Node *n) {
	int i;
	if (n->single) {
		printf("<%s", n->name);
		for (i = 0; n->attribs[i]; i++) {
			printf(" %s=%s", n->attribs[i]->name, n->attribs[i]->value);
		}
		if (n->single == 1)
			printf("/");
		printf(">");
		return;
	}
	printf("<%s", n->name);
	for (i = 0; n->attribs[i]; i++) {
		printf(" %s=%s", n->attribs[i]->name, n->attribs[i]->value);
	}
	printf(">");
	for (i = 0; n->children[i]; i++) {
		if (n->children[i]->type == NODE)
			printnode(n->children[i]->u.n);
		else if (n->children[i]->type == CSTR)
			printf("%s", n->children[i]->u.c);
		else
			exit(-1);
	}
	printf("</%s>", n->name);
}
示例#8
0
文件: deftab.c 项目: momo9/kr-code
void printtab(void) {
  int i;
  for (i = 0; i < HASHSIZE; ++i) {
    printf("%d:\n", i);
    printnode(tab[i]);
  }
}
示例#9
0
文件: list.c 项目: aaiijmrtt/JUCSE
void printlist(list *oldlist) {
    node *newnode=oldlist->head;
    while(newnode) {
        printnode(newnode);
        newnode=newnode->next;
    }
    printf("\n");
}
示例#10
0
文件: htops.c 项目: shivin9/dsa
void printHT(Hash_item ht, int htsize)
{
    int i = 0, j;
    while(i < htsize) {
        Hash_id hi = ht.HT_id[i];
        for(j = 0; j < 10; j++)
            printnode(hi[j]);
    }
}
示例#11
0
void printlist(varnode *head)
{
   while (head)
   {
      printf("%s : ", head->varname);
      printnode(head->head);
      puts("");
      head = head->next;
   }
}
示例#12
0
文件: doc.c 项目: echoline/echsml
void printdoc(Doc *doc) {
	int j;
	if (!doc)
		return;

	for (j = 0; doc->roots[j]; j++) {
		printnode(doc->roots[j]);
	}
	printf("\n");
}
示例#13
0
/* each node and calling 'printnode' to print each node found */ 
void printlist( struct node *ptr, char *suppType ) 
{ 
  while( ptr != NULL )  /* continue whilst there are nodes left */ 
    {
      if(strcmp(suppType, ptr->suppType ) == 0)
  { 
    printnode( ptr ); /* print out the current node */ 
  }
      ptr = ptr->next;  /* goto the next node in the list */ 
    } 
} 
示例#14
0
文件: debug.c 项目: PoCTo/yamsh
void printtree(Tree* T, FILE* f){
    
    if (T==NULL){ return; }
    printnode(T,f);
    if ((T->left)!=NULL)
        fprintf(f,"node%p -> node%p;\n",T,(T->left));
    if ((T->right)!=NULL)
        fprintf(f,"node%p -> node%p;\n",T,(T->right));
    printtree(T->left,f);
    printtree(T->right,f);
    //fclose(f);
}
示例#15
0
文件: hash.c 项目: ashikawa/scripts
void printhash()
{
	int i;
	for( i = 0; i < HASHSIZE; i++ ){
		
		if( hashtab[i] != NULL ){
			printf("%d\t", i);
			printnode(hashtab[i]);
			printf("\n");
		}
	}
}
示例#16
0
int main(void) {

	int val, len, pos;
	printf("How Many elements you want in your Linked list? \n");
	scanf(" %d", &len);

	//Make randomisation independent of fixed system seed
	srand(time(NULL));
	for(int i=1; i<=len; i++) {
		val = rand() % 10;
		insertnode(val, i);
		printf("your list is : ");
		printnode();
	}

	puts("Enter Your Desired Position to delete");
	scanf(" %d", &pos);
	deletenode(pos);
	printf("\nyour list is  now : ");
	printnode();

	return 0;
}
示例#17
0
void printnode(fnode_t *node)
{
    int i = 0; 
    
    kprintf("\n%s\t%p", node->f_name, &node);

    for (i = 2; i < node->end; ++i) {
        if (node->f_child[i]->f_type == FILE) {
            kprintf("\nfile %s \t %p \t %p", node->f_child[i]->f_name, node->f_child[i]->start, node->f_child[i]->end);
        } else { 
            printnode(node->f_child[i]); 
        }
    }
}
示例#18
0
int main(void) {

	int len, val;

	puts("How much Big You want your Linked List ?");
	scanf(" %d", &len);

	puts("Enter Your Elements :");
	for(int i=1; i<=len; i++) {
		scanf(" %d", &val);
		insertnode(val, i);
		printnode();
	}
	return 0;
}
示例#19
0
/*     For testing(?) - prints out tree     */
void printnode(struct treenode *node_p,int flag,FILE *fp){
  int n;

  n=flag;
  while(n<DOODAH && CHILD(node)!=NULL){
    fprintf(fp,"# %s\tConnected to %15s by Length %e\n",node_p->name
                ,CHILD(node)->name,CHILD(length));

/*  When calling parent from child - be careful of
 * infinite recursion!
 *  The first branch always the parent, except for
 * the tree root, in which case, the first branch
 * is also a child.*/ 
    printnode(CHILD(node),1,fp);
    n++;
  }
}
示例#20
0
文件: deftab.c 项目: momo9/kr-code
// print the hash table, for test
static void printnode(DefNode *pdn) {
  if (pdn) {
    printf("def: %s; val: %s\n", pdn->def, pdn->val);
    printnode(pdn->next);
  }
}
示例#21
0
文件: pwd.c 项目: mannias/SO
int pwd_main(int argc, char **argv) {
	printnode(currentdir);
	printk("\n");
	return 0;
}
示例#22
0
int
main (int argc, char *argv[])
{
    FILE *infile;
    char filename[PATH_MAX], *listname, *newline, *rc;
    int argn, opt, use_file, use_pipe, verbose;

    /* parse options */

    listname = "";
    verbose = 0;
    use_file = 0;
    use_pipe = 0;
    while ((opt = getopt (argc, argv, "f:hpqv")) != OPTEND)
        switch (opt)
        {
        case 'f':
            use_file = 1;
            listname = optarg;
            break;
        case 'h':
            help (stdout);
            return (0);
        case 'p':
            use_pipe = 1;
            break;
        case 'q':
            verbose = -1;
            break;
        case 'v':
            verbose = 1;
            break;
        case '?':
            help (stderr);
            return (1);
        }

    /* finalize options */

    if ((optind == argc) && (use_file == 0) && (use_pipe == 0))
    {
        help (stdout);
        return (0);
    }
    if (verbose == 0)
    {
        if (((argc - optind) != 1) || use_file || use_pipe)
            verbose = 1;
        else
            verbose = -1;
    }

    /* process files in listed in file specified by -f option */

    if (use_file)
    {
        infile = fopen (listname, "r");
        if (infile == NULL)
            fprintf (stderr, "filenode error: can't open %s!\n", listname);
        else
        {
            while (!feof (infile))
            {
                rc = fgets (filename, PATH_MAX - 1, infile);
                if (rc != NULL)
                {
                    newline = strchr (filename, '\n');
                    if (newline != NULL)
                        *newline = '\0';
                    if (strlen (filename) != 0)
                        printnode (filename, verbose);
                }
            }
            (void) fclose (infile);
        }
    }

    /* process files listed on stdin (i.e., the -p option) */

    if (use_pipe)
        while (!feof (stdin))
        {
            rc = fgets (filename, PATH_MAX - 1, stdin);
            if (rc != NULL)
            {
                newline = strchr (filename, '\n');
                if (newline != NULL)
                    *newline = '\0';
                if (strlen (filename) != 0)
                    printnode (filename, verbose);
            }
        }

    /* process files given in the argument list */

    for (argn = optind; argn < argc; argn++)
        printnode (argv[argn], verbose);

    /* indicate successful finish */

    return (0);
}
示例#23
0
/* If the hash is present nothing happens.
   Otherwise a new node is created for the hash picking one from the begin of the chain.
   Used nodes are moved to the end of the chain */
static inline void cacheset_add(struct cache_set *cs, unsigned char *md5, size_t size, uint32_t reclevel) {
    struct node *newnode;
    int64_t hash[2];

    memcpy(hash, md5, 16);
    if(splay(hash, size, cs)) {
	if(cs->root->minrec > reclevel)
	    cs->root->minrec = reclevel;
	return; /* Already there */
    }

    ptree("1:\n");
    if(printtree(cs, cs->root, 0)) {
	cli_errmsg("cacheset_add: inconsistent tree before choosing newnode, good luck\n");
	return;
    }

    newnode = cs->first;
    while(newnode) {
        if(!newnode->right && !newnode->left)
            break;
        if(newnode->next) {
            if(newnode == newnode->next) {
                cli_errmsg("cacheset_add: cache chain in a bad state\n");
                return;
            }
            newnode = newnode->next;
        }
        else {
	    cli_warnmsg("cacheset_add: end of chain reached\n");
	    return;
        }
    }
    if(!newnode) {
	cli_errmsg("cacheset_add: tree has got no end nodes\n");
	return;
    }
    if(newnode->up) {
    	if(newnode->up->left == newnode)
    	    newnode->up->left = NULL;
    	else
    	    newnode->up->right = NULL;
    }
    if(newnode->prev)
    	newnode->prev->next = newnode->next;
    if(newnode->next)
    	newnode->next->prev = newnode->prev;
    if(cs->first == newnode)
    	cs->first = newnode->next;

    newnode->prev = cs->last;
    newnode->next = NULL;
    cs->last->next = newnode;
    cs->last = newnode;

    ptree("2:\n");
    if(printtree(cs, cs->root, 0)) {
	cli_errmsg("cacheset_add: inconsistent tree before adding newnode, good luck\n");
	return;
    }

    if(!cs->root) {
	newnode->left = NULL;
	newnode->right = NULL;
    } else {
	if(cmp(hash, size, cs->root->digest, cs->root->size) < 0) {
	    newnode->left = cs->root->left;
	    newnode->right = cs->root;
	    cs->root->left = NULL;
	} else {
	    newnode->right = cs->root->right;
	    newnode->left = cs->root;
	    cs->root->right = NULL;
	}
	if(newnode->left) newnode->left->up = newnode;
	if(newnode->right) newnode->right->up = newnode;
    }
    newnode->digest[0] = hash[0];
    newnode->digest[1] = hash[1];
    newnode->up = NULL;
    newnode->size = size;
    newnode->minrec = reclevel;
    cs->root = newnode;

    ptree("3: %lld\n", hash[1]);
    if(printtree(cs, cs->root, 0)) {
	cli_errmsg("cacheset_add: inconsistent tree after adding newnode, good luck\n");
	return;
    }
    printnode("newnode", cs, newnode);
}
示例#24
0
void printtable()
{
    printnode(0, root);
}
示例#25
0
/* If the hash is not present nothing happens other than splaying the tree.
   Otherwise the identified node is removed from the tree and then placed back at 
   the front of the chain. */
static inline void cacheset_remove(struct cache_set *cs, unsigned char *md5, size_t size) {
    struct node *targetnode;
    struct node *reattachnode;
    int64_t hash[2];

    memcpy(hash, md5, 16);
    if(splay(hash, size, cs) != 1) {
	cli_dbgmsg("cacheset_remove: node not found in tree\n");
	return; /* No op */
    }

    ptree("cacheset_remove: node found and splayed to root\n");
    targetnode = cs->root;
    printnode("targetnode", cs, targetnode);

    /* First fix the tree */
    if(targetnode->left == NULL) {
        /* At left edge so prune */
        cs->root = targetnode->right;
        if(cs->root)
            cs->root->up = NULL;
    }
    else {
        /* new root will come from leftside tree */
        cs->root = targetnode->left;
        cs->root->up = NULL;
        /* splay tree, expecting not found, bringing rightmost member to root */
        splay(hash, size, cs);

        if (targetnode->right) {
            /* reattach right tree to clean right-side attach point */
            reattachnode = cs->root;
            while (reattachnode->right) 
                reattachnode = reattachnode->right; /* shouldn't happen, but safer in case of dupe */
            reattachnode->right = targetnode->right;
            targetnode->right->up = reattachnode;
        }
    }
    targetnode->size = (size_t)0;
    targetnode->digest[0] = 0;
    targetnode->digest[1] = 0;
    targetnode->up = NULL;
    targetnode->left = NULL;
    targetnode->right = NULL;

    /* Tree is fixed, so now fix chain around targetnode */
    if(targetnode->prev) 
        targetnode->prev->next = targetnode->next;
    if(targetnode->next) 
        targetnode->next->prev = targetnode->prev;
    if(cs->last == targetnode)
        cs->last = targetnode->prev;

    /* Put targetnode at front of chain, if not there already */
    if(cs->first != targetnode) {
        targetnode->next = cs->first;
        if(cs->first)
            cs->first->prev = targetnode;
        cs->first = targetnode;
    }
    targetnode->prev = NULL;

    printnode("root", cs, cs->root);
    printnode("first", cs, cs->first);
    printnode("last", cs, cs->last);

    printchain("remove (after)", cs);
}