void doinit() { /* initializes variables */ inputnumbers2(&spp, &nonodes2, 1); getoptions(); if ( !usertree ) nonodes2--; alloctree(&curtree.nodep, nonodes2); allocd(nonodes2, curtree.nodep); allocw(nonodes2, curtree.nodep); if (!usertree) { alloctree(&bestree.nodep, nonodes2); allocd(nonodes2, bestree.nodep); allocw(nonodes2, bestree.nodep); alloctree(&priortree.nodep, nonodes2); allocd(nonodes2, priortree.nodep); allocw(nonodes2, priortree.nodep); if (njumble > 1) { alloctree(&bestree2.nodep, nonodes2); allocd(nonodes2, bestree2.nodep); allocw(nonodes2, bestree2.nodep); } } allocrest(); } /* doinit */
void doinit() { /* initializes variables */ inputnumbers2(&spp, &nonodes2, 1); if (inputnumbers2error) return; nonodes2--; alloctree(&curtree.nodep, nonodes2); allocd(nonodes2, curtree.nodep); allocw(nonodes2, curtree.nodep); alloctree(&bestree.nodep, nonodes2); allocd(nonodes2, bestree.nodep); allocw(nonodes2, bestree.nodep); alloctree(&priortree.nodep, nonodes2); allocd(nonodes2, priortree.nodep); allocw(nonodes2, priortree.nodep); if (njumble > 1) { alloctree(&bestree2.nodep, nonodes2); allocd(nonodes2, bestree2.nodep); allocw(nonodes2, bestree2.nodep); } allocrest(); } /* doinit */
void threadmain(int argc, char* argv[]) { char* mnt; char* srv; int mflag; Biobuf* b; char* user; srv = nil; mnt = nil; mflag = MREPL|MCREATE; ARGBEGIN{ case 'a': mflag = MAFTER|MCREATE; break; case 'b': mflag = MBEFORE|MCREATE; break; case 'c': mflag = MREPL|MCREATE; break; case 's': srv = EARGF(usage()); break; case 'm': mnt = EARGF(usage()); break; case 'D': debug = 1; chatty9p++; break; default: usage(); }ARGEND; if(argc != 1) usage(); tfname = argv[0]; ttfname = smprint("%s.new", tfname); b = Bopen(tfname, OREAD); if(b == nil) sysfatal("%s: %r", tfname); trie = rdtrie(b); Bterm(b); if(trie == nil) sysfatal("%s: %r", tfname); if(srv == nil && mnt == nil){ mnt = "/mnt/tags"; srv = srvname(tfname); } if(!chatty9p) rfork(RFNOTEG); sfs.tree = alloctree(nil, nil, DMDIR|0777, nil); user = getuser(); ctlf = createfile(sfs.tree->root, "ctl", user, 0666, nil); threadpostmountsrv(&sfs, srv, mnt, mflag); threadexits(nil); }
void doinit() { /* initializes variables */ inputnumbersfreq(phylofreq, &spp, &loci, &nonodes2, 2); if (printdata) fprintf(outfile, "\n%4ld Populations, %4ld Loci\n", spp, loci); alloctree(&curtree.nodep, nonodes2); if (!usertree) { alloctree(&bestree.nodep, nonodes2); alloctree(&priortree.nodep, nonodes2); if (njumble > 1) { alloctree(&bestree2.nodep, nonodes2); } } allocrest(); } /* doinit */
void doinit(void) { /* initializes variables */ inputnumbersstate(phylostates[0], &spp, &chars, &nonodes, 1); words = chars / bits + 1; // if (printdata) // fprintf(outfile, "%2ld species, %3ld characters\n\n", spp, chars); alloctree(&treenode); setuptree(treenode); allocrest(); } /* doinit */
void doinit() { /* initializes variables */ node *p; inputnumbers2(&spp, &nonodes2, 2); nonodes2 += (njoin ? 0 : 1); getoptions(); alloctree(&curtree.nodep, nonodes2+1); p = curtree.nodep[nonodes2]->next->next; curtree.nodep[nonodes2]->next = curtree.nodep[nonodes2]; free(p); allocrest(); } /* doinit */
void mountcons(void) { fschan = chancreate(sizeof(Fsevent), 0); writechan = chancreate(sizeof(void*), 0); fs.tree = alloctree("win", "win", DMDIR|0555, nil); devcons = createfile(fs.tree->root, "cons", "win", 0666, nil); if(devcons == nil) sysfatal("creating /dev/cons: %r"); devnew = createfile(fs.tree->root, "wnew", "win", 0666, nil); if(devnew == nil) sysfatal("creating /dev/wnew: %r"); threadpostmountsrv(&fs, nil, "/dev", MBEFORE); }
void threadmain(int argc, char **argv) { Dev *yd; char *devdir = nil; Ep *ep; int csps[] = {YurexCSP, 0}; int i; if(finddevs(matchdevcsp, csps, &devdir, 1) < 1){ fprint(2, "No yurex device\n"); threadexitsall("yurex not found"); } yd = opendev(devdir); if(yd == nil) sysfatal("opendev: %r"); if(configdev(yd)<0) sysfatal("configdev: %r"); for(i = 0; i < nelem(yd->usb->ep); i++){ if((ep = yd->usb->ep[i]) == nil) break; if(ep->type == Eintr && ep->dir == Ein) if(ep->iface->csp == YurexCSP){ yc.ep = openep(yd, ep->id); if(yc.ep == nil) sysfatal("YUREX: %s: openep %d: %r\n", yd->dir, ep->id); if(opendevdata(yc.ep, OREAD) < 0){ fprint(2, "YUERX: %s: opendevdata: %r\n", yc.ep->dir); closedev(yc.ep); yc.ep = nil; break; } fs.tree = alloctree(nil, nil, DMDIR|0777, destroyfile); createfile(fs.tree->root, "bbu", nil, 0444, nil); createfile(fs.tree->root, "mbbups", nil, 0444, nil); threadpostmountsrv(&fs, "yurex", nil, MREPL|MCREATE); proccreate(yurexwork, nil, Stack); } } threadexits(nil); }
void main(int argc, char **argv) { char *addr = nil; char *srvname = nil; char *mtpt = nil; Qid q; fs.tree = alloctree(nil, nil, DMDIR|0777, fsdestroyfile); q = fs.tree->root->qid; ARGBEGIN{ case 'D': chatty9p++; break; case 'a': addr = EARGF(usage()); break; case 's': srvname = EARGF(usage()); break; case 'm': mtpt = EARGF(usage()); break; default: usage(); }ARGEND; if(argc) usage(); if(chatty9p) fprint(2, "ramsrv.nopipe %d srvname %s mtpt %s\n", fs.nopipe, srvname, mtpt); if(addr == nil && srvname == nil && mtpt == nil) sysfatal("must specify -a, -s, or -m option"); if(addr) listensrv(&fs, addr); if(srvname || mtpt) postmountsrv(&fs, srvname, mtpt, MREPL|MCREATE); exits(0); }
void main(int argc, char **argv) { char *mtpt; Ofile *f; Odir d; mtpt = "/mnt/doc"; ARGBEGIN{ case 'm': mtpt = ARGF(); break; default: goto Usage; }ARGEND if(argc != 1) { Usage: fprint(2, "usage: olefs file\n"); exits("usage"); } f = oleopen(argv[0]); if(f == nil) { print("error opening %s: %r\n", argv[0]); exits("open"); } // dumpdir(f, 0); if(oreaddir(f, 0, &d) != 1) { fprint(2, "oreaddir error: %r\n"); exits("oreaddir"); } olesrv.tree = alloctree(nil, nil, DMDIR|0777, nil); filldir(olesrv.tree->root, f, d.dir, 0); postmountsrv(&olesrv, nil, mtpt, MREPL); exits(0); }
void doinput() { /* reads the input data */ inputnumbers(&spp, &chars, &nonodes, 1); words = chars / bits + 1; printf("%2ld species, %3ld characters\n", spp, chars); printf("\nReading input file ...\n\n"); getoptions(); if (weights) openfile(&weightfile,WEIGHTFILE,"weights file","r",progname,weightfilename); if(ancvar) openfile(&ancfile,ANCFILE,"ancestors file", "r",progname,ancfilename); if(factors) openfile(&factfile,FACTFILE,"factors file", "r",progname,factfilename); alloctree(&treenode); setuptree(treenode); allocrest(); inputoptions(); inputdata(treenode, dollo, false, stdout); } /* doinput */
void globrearrange() { /* does global rearrangements */ tree globtree; tree oldtree; int i,j,k,num_sibs,num_sibs2; node *where,*sib_ptr,*sib_ptr2; double oldbestyet = curtree.likelihood; int success = false; alloctree(&globtree.nodep,nonodes2); alloctree(&oldtree.nodep,nonodes2); setuptree(&globtree,nonodes2); setuptree(&oldtree,nonodes2); allocview(&oldtree, nonodes2, totalleles); allocview(&globtree, nonodes2, totalleles); copy_(&curtree,&globtree); copy_(&curtree,&oldtree); for ( i = spp ; i < nonodes2 ; i++ ) { num_sibs = count_sibs(curtree.nodep[i]); sib_ptr = curtree.nodep[i]; if ( (i - spp) % (( nonodes2 / 72 ) + 1 ) == 0 ) putchar('.'); fflush(stdout); for ( j = 0 ; j <= num_sibs ; j++ ) { re_move(&sib_ptr,&where); copy_(&curtree,&priortree); if (where->tip) { copy_(&oldtree,&curtree); copy_(&oldtree,&bestree); sib_ptr = sib_ptr->next; continue; } else num_sibs2 = count_sibs(where); sib_ptr2 = where; for ( k = 0 ; k < num_sibs2 ; k++ ) { addwhere = NULL; addtraverse(sib_ptr,sib_ptr2->back,true); if ( addwhere && where != addwhere && where->back != addwhere && bestree.likelihood > globtree.likelihood) { copy_(&bestree,&globtree); success = true; } sib_ptr2 = sib_ptr2->next; } copy_(&oldtree,&curtree); copy_(&oldtree,&bestree); sib_ptr = sib_ptr->next; } } copy_(&globtree,&curtree); copy_(&globtree,&bestree); if (success && globtree.likelihood > oldbestyet) { succeeded = true; } else { succeeded = false; } freeview(&oldtree, nonodes2); freeview(&globtree, nonodes2); freetree(&globtree.nodep,nonodes2); freetree(&oldtree.nodep,nonodes2); }
void main(int argc, char **argv) { Biobuf *b; Data *d; File *fdir, *f; Proc *p, *plist; Tree *tree; char *mtpt, buf[32]; int i, mflag; mtpt = "/proc"; mflag = MBEFORE; ARGBEGIN{ case 'D': chatty9p++; break; case 'd': debug = 1; break; case 'a': mflag = MAFTER; break; case 'm': mtpt = ARGF(); break; default: usage(); }ARGEND if(argc != 1) usage(); b = Bopen(argv[0], OREAD); if(b == nil) { fprint(2, "cannot open \"%s\": %r\n", argv[0]); exits("Bopen"); } if((plist = readsnap(b)) == nil) { fprint(2, "readsnap fails\n"); exits("readsnap"); } tree = alloctree(nil, nil, DMDIR|0555, nil); fs.tree = tree; for(p=plist; p; p=p->link) { print("process %ld %.*s\n", p->pid, 28, p->d[Pstatus] ? p->d[Pstatus]->data : ""); snprint(buf, sizeof buf, "%ld", p->pid); fdir = ecreatefile(tree->root, buf, nil, DMDIR|0555, nil); ecreatefile(fdir, "ctl", nil, 0777, nil); if(p->text) ecreatefile(fdir, "text", nil, 0777, PDProc(p)); ecreatefile(fdir, "mem", nil, 0666, PDProc(p)); for(i=0; i<Npfile; i++) { if((d = p->d[i])) { f = ecreatefile(fdir, pfile[i], nil, 0666, PDData(d)); f->Dir.length = d->len; } } } postmountsrv(&fs, nil, mtpt, mflag); exits(0); }
void main(int argc, char *argv[]) { char buf[32]; Dev *d, *ed; Ep *e; int i; ARGBEGIN { case 'D': chatty9p++; break; case 'd': usbdebug++; break; } ARGEND; if(argc == 0) usage(); if((d = getdev(*argv)) == nil) sysfatal("getdev: %r"); audiodev = d; /* parse descriptors, mark valid altc */ for(i = 0; i < nelem(d->usb->ddesc); i++) parsedescr(d->usb->ddesc[i]); for(i = 0; i < nelem(d->usb->ep); i++){ e = d->usb->ep[i]; if(e != nil && e->type == Eiso && e->iface != nil && e->iface->csp == CSP(Claudio, 2, 0)){ switch(e->dir){ case Ein: if(audioepin != nil) continue; audioepin = e; break; case Eout: if(audioepout != nil) continue; audioepout = e; break; case Eboth: if(audioepin != nil && audioepout != nil) continue; if(audioepin == nil) audioepin = e; if(audioepout == nil) audioepout = e; break; } if((ed = setupep(audiodev, e, audiofreq)) == nil){ fprint(2, "setupep: %r\n"); if(e == audioepin) audioepin = nil; if(e == audioepout) audioepout = nil; continue; } closedev(ed); } } if(audioepout == nil) sysfatal("no endpoints found"); fs.tree = alloctree(user, "usb", DMDIR|0555, nil); createfile(fs.tree->root, "volume", user, 0666, nil); snprint(buf, sizeof buf, "%d.audio", audiodev->id); postsharesrv(&fs, nil, "usb", buf); exits(0); }