static int processleafedge_shulen(bool firstsucc, unsigned long fatherdepth, GtBUinfo_shulen *father, unsigned long leafnumber, GtBUstate_shulen *state, GT_UNUSED GtError *err) { unsigned long gnum; #ifdef SHUDEBUG printf("processleafedge %lu firstsucc=%s, " " depth(father)=%lu, path=", leafnumber, firstsucc ? "true" : "false", fatherdepth); if (fatherdepth > 0) { gt_encseq_showatstartposwithdepth(stdout, state->encseq, GT_READMODE_FORWARD, leafnumber, fatherdepth); } printf("\n"); #endif if (state->file_to_genome_map != NULL) { gnum = state->file_to_genome_map[gt_encseq_filenum(state->encseq, leafnumber)]; } else { gnum = gt_encseq_filenum(state->encseq,leafnumber); } if (firstsucc) { gt_assert(father != NULL); if (father->gnumdist == NULL) { father->gnumdist = gt_malloc(sizeof (*father->gnumdist) * state->numofdbfiles); } resetgnumdist_shulen(father,state->numofdbfiles); #ifdef SHUDEBUG shownode(__LINE__,state,"father",father); #endif } else { #ifdef SHUDEBUG shownode(__LINE__,state,"father",father); #endif shu_compute_leaf_edge_contrib(state,father->gnumdist,gnum,fatherdepth); } father->gnumdist[gnum]++; #ifdef SHUDEBUG printf("gnumdist[id=%lu,filenum=%lu]=%lu\n",father->id,gnum, father->gnumdist[gnum]); state->lastleafnumber = leafnumber; #endif return 0; }
static void showsimplenoderelations(const Mergertrienode *node) { shownode(node); printf(".firstchild="); shownode(node->firstchild); printf("; "); shownode(node); printf(".rightsibling="); shownode(node->rightsibling); printf("\n"); }
int main() { struct btree_node *n, *bt = NULL; //btree_init(&bt); struct mydata foo = { 10, "hello" }; struct mydata bar = { 20, "world" }; printf("EMPTY TREE: %d\n", btree_empty(&bt)); btree_add(&bt, &foo, mycmp); btree_add(&bt, &bar, mycmp); printf("EMPTY TREE: %d\n", btree_empty(&bt)); printf("==== go search ====\n"); /* find existent data */ struct mydata *p = btree_get(bt, &bar, mycmp); shownode("result for 20: ", p); printf("==== go search ====\n"); /* find unexistent data */ struct mydata nop = { 15, NULL }; p = btree_get(bt, &nop, mycmp); shownode("result for 15: ", p); printf("==== go get hittest ====\n"); n = btree_hittest(bt, NULL); shownode("hitest is: ", p); printf("==== go remove 20 ====\n"); if (btree_del(bt, &bar, mycmp, NULL)) printf("node found and removed\n"); else printf("oops\n"); printf("==== go search ====\n"); /* find existent data */ p = btree_get(bt, &bar, mycmp); shownode("result for 20: ", p); printf("==== go search ====\n"); /* find existent data */ p = btree_get(bt, &foo, mycmp); shownode("result for 10: ", p); btree_cleartree(bt, NULL); return 0; }
static int mismatch(NODE *n1, NODE *n2, int differ, char const *path) { if (n2 == NULL) { shownode(n1, differ, path); return (1); } if (n1 == NULL) { printf("\t"); shownode(n2, differ, path); return (1); } if (!(differ & keys)) return(0); printf("\t\t"); shownode(n1, differ, path); printf("\t\t"); shownode(n2, differ, path); return (1); }
Bool TERMWINDOWMEMBER readnode(Bool Option) { label Buffer; #ifdef WINCIT Bool toreturn = ReadNodesCit(this, &node, CurrentUser->GetName(Buffer, sizeof(Buffer)), CONSOLE, Option); #else Bool toreturn = ReadNodesCit(&node, CurrentUser->GetName(Buffer, sizeof(Buffer)), CONSOLE, Option); #endif if (debug && toreturn) { doccr(); shownode(node, CONSOLE); doccr(); } return (toreturn); }
void shownode(int level, struct filenode *node, FILE *f) { struct filenode *p; fprintf(f, "%-4d %-20s [0x%-8x, 0x%-8x] %07o, sz %5u, at 0x%-6x", level, node->name, (int)node->ondev, (int)node->onino, node->modes, node->size, node->offset); if (node->orig_link) fprintf(f, " [link to 0x%-6x]", node->orig_link->offset); fprintf(f, "\n"); p = node->dirlist.head; while (p->next) { shownode(level+1, p, f); p = p->next; } }
int main(int argc, char *argv[]) { int c; char *dir = "."; char *outf = NULL; char *volname = NULL; int verbose = 0; char buf[256]; struct filenode *root; struct stat sb; int lastoff; int i; char *p; struct aligns *pa, *pa2; struct excludes *pe, *pe2; FILE *f; while((c = getopt(argc, argv, "V:vd:f:ha:A:x:")) != EOF) { switch(c) { case 'd': dir = optarg; break; case 'f': outf = optarg; break; case 'V': volname = optarg; break; case 'v': verbose = 1; break; case 'h': showhelp(argv[0]); exit(0); case 'a': align = strtoul(optarg, NULL, 0); if(align < 16 || (align & (align - 1))) { fprintf(stderr, "Align has to be at least 16 bytes and a power of two\n"); exit(1); } break; case 'A': i = strtoul(optarg, &p, 0); if(i < 16 || (i & (i - 1))) { fprintf(stderr, "Align has to be at least 16 bytes and a power of two\n"); exit(1); } if(*p != ',' || !p[1]) { fprintf(stderr, "-A takes N,PATTERN format of argument, where N is a number\n"); exit(1); } /* strlen(p+1) + 1 eq strlen(p) */ pa = (struct aligns *)malloc(sizeof(*pa) + strlen(p)); pa->align = i; pa->next = NULL; strcpy(pa->pattern, p + 1); if(!alignlist) alignlist = pa; else { for(pa2 = alignlist; pa2->next; pa2 = pa2->next) ; pa2->next = pa; } break; case 'x': pe = (struct excludes *)malloc(sizeof(*pe) + strlen(optarg) + 1); pe->next = NULL; strcpy(pe->pattern, optarg); if(!excludelist) excludelist = pe; else { for(pe2 = excludelist; pe2->next; pe2 = pe2->next) ; pe2->next = pe; } break; default: exit(1); } } if(!volname) { sprintf(buf, "rom %08lx", time(NULL)); volname = buf; } if(!outf) { fprintf(stderr, "%s: you must specify the destination file\n", argv[0]); fprintf(stderr, "Try `%s -h' for more information\n", argv[0]); exit(1); } if(strcmp(outf, "-") == 0) { f = fdopen(1, "wb"); } else f = fopen(outf, "wb"); if(!f) { perror(outf); exit(1); } realbase = strlen(dir); root = newnode(dir, volname, 0); root->parent = root; lastoff = processdir(1, dir, dir, &sb, root, root, spaceneeded(root)); if(lastoff < 0) { fprintf(stderr, "Error while processing directory.\n"); return 1; } if(verbose) shownode(0, root, stderr); if(dumpall(root, lastoff, f)) { fprintf(stderr, "Error while dumping!\n"); return 1; } return 0; }
static int processbranchingedge_shulen(bool firstsucc, unsigned long fatherdepth, GtBUinfo_shulen *father, GT_UNUSED unsigned long sondepth, GT_UNUSED unsigned long sonwidth, GtBUinfo_shulen *son, GtBUstate_shulen *state, GT_UNUSED GtError *err) { unsigned long idx; #ifdef SHUDEBUG printf("%s firstsucc=%s, depth(father)=%lu,path=",__func__, firstsucc ? "true" : "false",fatherdepth); if (fatherdepth > 0) { gt_encseq_showatstartposwithdepth(stdout, state->encseq, GT_READMODE_FORWARD, state->lastleafnumber, fatherdepth); } printf("\n"); #endif if (firstsucc) { gt_assert(father != NULL); if (father->gnumdist == NULL) { father->gnumdist = gt_malloc(sizeof (*father->gnumdist) * state->numofdbfiles); resetgnumdist_shulen(father,state->numofdbfiles); } #ifdef SHUDEBUG shownode(__LINE__,state,"father",father); #endif } else { #ifdef SHUDEBUG gt_assert(father != NULL); shownode(__LINE__,state,"father",father); gt_assert(son != NULL); shownode(__LINE__,state,"son",son); #endif cartproduct_shulen(state, fatherdepth, father->gnumdist, son->gnumdist); cartproduct_shulen(state, fatherdepth, son->gnumdist, father->gnumdist); } if (son != NULL) { for (idx = 0; idx < state->numofdbfiles; idx++) { father->gnumdist[idx] += son->gnumdist[idx]; son->gnumdist[idx] = 0; #ifdef SHUDEBUG printf("gnumdist[id=%lu,filenum=%lu]=%lu\n",father->id,idx, father->gnumdist[idx]); printf("gnumdist[id=%lu,filenum=%lu]=0\n",son->id,idx); #endif } } return 0; }