这篇教程C++ EARGF函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EARGF函数的典型用法代码示例。如果您正苦于以下问题:C++ EARGF函数的具体用法?C++ EARGF怎么用?C++ EARGF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EARGF函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainintmain(int argc, char *argv[]){ size_t jf[2] = { jfield, jfield, }; FILE *fp[2]; int ret = 0, n; char *fno; ARGBEGIN { case '1': jf[0] = estrtonum(EARGF(usage()), 1, MIN(LLONG_MAX, SIZE_MAX)); break; case '2': jf[1] = estrtonum(EARGF(usage()), 1, MIN(LLONG_MAX, SIZE_MAX)); break; case 'a': fno = EARGF(usage()); if (strcmp(fno, "1") == 0) unpairsa = 1; else if (strcmp(fno, "2") == 0) unpairsb = 1; else usage(); break; case 'e': replace = EARGF(usage()); break; case 'o': oflag = 1; initolist(&output); makeolist(&output, EARGF(usage())); break; case 't': sep = EARGF(usage()); break; case 'v': pairs = 0; fno = EARGF(usage()); if (strcmp(fno, "1") == 0) unpairsa = 1; else if (strcmp(fno, "2") == 0) unpairsb = 1; else usage(); break; default: usage(); } ARGEND; if (sep) seplen = unescape(sep); if (argc != 2) usage(); for (n = 0; n < 2; n++) { if (!strcmp(argv[n], "-")) { argv[n] = "<stdin>"; fp[n] = stdin; } else if (!(fp[n] = fopen(argv[n], "r"))) { eprintf("fopen %s:", argv[n]); } } jf[0]--; jf[1]--; join(fp[0], fp[1], jf[0], jf[1]); if (oflag) freespecs(&output); if (fshut(fp[0], argv[0]) | (fp[0] != fp[1] && fshut(fp[1], argv[1])) | fshut(stdout, "<stdout>")) ret = 2; return ret;}
开发者ID:rovaughn,项目名称:distro,代码行数:78,
示例2: mainINT main(UINT argc, PTCHAR argv[]) { CONST PTCHAR Banner = "/t/t /t/n" "/t/t ## ## ######## ## ## ######## /t/n" "/t/t ## ## ## ## ## ## ## /t/n" "/t/t ## ## ## ## ## ## ## /t/n" "/t/t ######### ###### ## ## ## ## /t/n" "/t/t ## ## ## ## ## ## ## /t/n" "/t/t ## ## ## ## ## ## ## /t/n" "/t/t ## ## ######## ### ######## /t/n" "/t/t /t/n" "/t/t HackSys Extreme Vulnerable Driver Exploits /t/n" "/t/t Ashfaq Ansari (@HackSysTeam) /t/n" "/t/t ashfaq[at]payatu[dot]com /t/n" "/t/t /t/n"; PTCHAR CommandToExecute = NULL; EXPLOIT_VULNERABILITY ExploitVulnerability; ClearScreen(); CenterConsoleScreen(); // Print the banner DEBUG_SUCCESS(Banner); if (argc < 3) { ShowUsage(argv[0]); } // Parse the command line arguments ARGBEGIN { case 'p': ExploitVulnerability.VulnerabilityType = PoolOverflow; break; case 'u': ExploitVulnerability.VulnerabilityType = UseAfterFree; break; case 't': ExploitVulnerability.VulnerabilityType = TypeConfusion; break; case 's': ExploitVulnerability.VulnerabilityType = StackOverflow; break; case 'i': ExploitVulnerability.VulnerabilityType = IntegerOverflow; break; case 'g': ExploitVulnerability.VulnerabilityType = StackOverflowGS; break; case 'a': ExploitVulnerability.VulnerabilityType = ArbitraryOverwrite; break; case 'h': ExploitVulnerability.VulnerabilityType = UninitializedHeapVariable; break; case 'v': ExploitVulnerability.VulnerabilityType = UninitializedStackVariable; break; case 'n': ExploitVulnerability.VulnerabilityType = NullPointerDereference; break; case 'c': ExploitVulnerability.Command = EARGF(ShowUsage(argv[0])); break; default: ShowUsage(argv[0]); } ARGEND; // Start the exploitation Exploit(&ExploitVulnerability); return EXIT_SUCCESS;}
开发者ID:NimdaKey,项目名称:HackSysExtremeVulnerableDriver,代码行数:73,
示例3: mainvoidmain(int argc, char *argv[]){ char *file; char *rcmd, *wcmd; int fd0, fd1, ifd0, ifd1, dupflag; rfork(RFNOTEG); dupflag = 0; rcmd = wcmd = nil; ARGBEGIN{ case 'd': dupflag = 1; break; case 'r': rcmd = EARGF(usage()); break; case 'w': wcmd = EARGF(usage()); break; default: usage(); }ARGEND if(argc!=1 || (rcmd==nil && wcmd==nil)) usage(); if(rcmd == nil) rcmd = "/bin/cat"; if(wcmd == nil) wcmd = "/bin/cat"; file = argv[0]; if(dupflag){ ifd0 = open(file, ORDWR); if(ifd0 < 0) sysfatal("open %s: %r", file); ifd1 = dup(ifd0, -1); }else{ ifd0 = open(file, OREAD); if(ifd0 < 0) sysfatal("open %s: %r", file); ifd1 = open(file, OWRITE); if(ifd1 < 0) sysfatal("open %s: %r", file); } if(bind("#|", TEMP, MREPL) < 0) sysfatal("bind pipe %s: %r", TEMP); if(bind(TEMP "/data", file, MREPL) < 0) sysfatal("bind %s %s: %r", TEMP "/data", file); fd0 = open(TEMP "/data1", OREAD); if(fd0 < 0) sysfatal("open %s: %r", TEMP "/data1"); connect(wcmd, fd0, ifd1); fd1 = open(TEMP "/data1", OWRITE); if(fd1 < 0) sysfatal("open %s: %r", TEMP "/data1"); connect(rcmd, ifd0, fd1); unmount(nil, TEMP); exits(nil);}
开发者ID:aahud,项目名称:harvey,代码行数:62,
示例4: mainvoidmain(int argc, char **argv){ char dat[MaxStr], buf[MaxStr], cmd[MaxStr], *p, *err; int ac, fd, ms, data; char *av[10]; quotefmtinstall(); origargs = procgetname(); /* see if we should use a larger message size */ fd = open("/dev/draw", OREAD); if(fd > 0){ ms = iounit(fd); if(msgsize < ms+IOHDRSZ) msgsize = ms+IOHDRSZ; close(fd); } user = getuser(); if(user == nil) fatal(1, "can't read user name"); ARGBEGIN{ case 'a': p = EARGF(usage()); if(setam(p) < 0) fatal(0, "unknown auth method %s", p); break; case 'e': ealgs = EARGF(usage()); if(*ealgs == 0 || strcmp(ealgs, "clear") == 0) ealgs = nil; break; case 'd': dbg++; break; case 'f': /* ignored but accepted for compatibility */ break; case 'R': /* From listen */ remoteside(); break; case 'h': system = EARGF(usage()); break; case 'c': cflag++; cmd[0] = '!'; cmd[1] = '/0'; while(p = ARGF()) { strcat(cmd, " "); strcat(cmd, p); } break; case 'k': keyspec = smprint("%s %s", keyspec, EARGF(usage())); break; case 'P': patternfile = EARGF(usage()); break; case 'u': user = EARGF(usage()); keyspec = smprint("%s user=%s", keyspec, user); break; default: usage(); }ARGEND; if(argc != 0) usage(); if(system == nil) { p = getenv("cpu"); if(p == 0) fatal(0, "set $cpu"); system = p; } if(err = rexcall(&data, system, srvname)) fatal(1, "%s: %s", err, system); procsetname("%s", origargs); /* Tell the remote side the command to execute and where our working directory is */ if(cflag) writestr(data, cmd, "command", 0); if(getwd(dat, sizeof(dat)) == 0) writestr(data, "NO", "dir", 0); else writestr(data, dat, "dir", 0); /* start up a process to pass along notes */ lclnoteproc(data); /* * Wait for the other end to execute and start our file service * of /mnt/term */ if(readstr(data, buf, sizeof(buf)) < 0) fatal(1, "waiting for FS: %r"); if(strncmp("FS", buf, 2) != 0) {//.........这里部分代码省略.........
开发者ID:99years,项目名称:plan9,代码行数:101,
示例5: mainvoidmain(int argc, char **argv){ char *f[10], *local, *name, *remote, *s, *t, verb; int fd, havedb, havelocal, i, k, n, nf, resolve1, skip; int checkedmatch1, checkedmatch2, checkedmatch3, checkedmatch4; ulong now; Biobuf bin; Dir dbd, ld, nd, rd; Avlwalk *w; Entry *e; membogus(argv); quotefmtinstall(); ARGBEGIN{ case 's': case 'c': i = ARGC(); addresolve(i, EARGF(usage())); break; case 'n': donothing = 1; verbose = 1; break; case 'S': safeinstall = 0; break; case 'T': timefile = EARGF(usage()); break; case 't': tempspool = 0; break; case 'u': douid = 1; break; case 'v': verbose++; break; default: usage(); }ARGEND if(argc < 3) usage(); if(timefile) readtimefile(); lroot = argv[1]; if(!isdir(lroot)) sysfatal("bad local root directory"); rroot = argv[2]; if(!isdir(rroot)) sysfatal("bad remote root directory"); match = argv+3; nmatch = argc-3; for(i=0; i<nmatch; i++) if(match[i][0] == '/') match[i]++; if((clientdb = opendb(argv[0])) == nil) sysfatal("opendb %q: %r", argv[2]); copyerr = opendb(nil); skip = 0; Binit(&bin, 0, OREAD); for(; s=Brdstr(&bin, '/n', 1); free(s)){ t = estrdup(s); nf = tokenize(s, f, nelem(f)); if(nf != 10 || strlen(f[2]) != 1){ skip = 1; fprint(2, "warning: skipping bad log entry <%s>/n", t); free(t); continue; } free(t); now = strtoul(f[0], 0, 0); n = atoi(f[1]); verb = f[2][0]; name = f[3]; if(now < maxnow || (now==maxnow && n <= maxn)) continue; local = mkname(localbuf, sizeof localbuf, lroot, name); if(strcmp(f[4], "-") == 0) f[4] = f[3]; remote = mkname(remotebuf, sizeof remotebuf, rroot, f[4]); rd.name = f[4]; rd.mode = strtoul(f[5], 0, 8); rd.uid = f[6]; rd.gid = f[7]; rd.mtime = strtoul(f[8], 0, 10); rd.length = strtoll(f[9], 0, 10); havedb = finddb(clientdb, name, &dbd)>=0; havelocal = localdirstat(local, &ld)>=0; resolve1 = resolve(name);//.........这里部分代码省略.........
开发者ID:npe9,项目名称:harvey,代码行数:101,
示例6: cpumainvoidcpumain(int argc, char **argv){ char dat[MaxStr], buf[MaxStr], cmd[MaxStr], *err, *secstoreserver, *p, *s; int fd, ms, data; /* see if we should use a larger message size */ fd = open("/dev/draw", OREAD); if(fd > 0){ ms = iounit(fd); if(msgsize < ms+IOHDRSZ) msgsize = ms+IOHDRSZ; close(fd); } user = getenv("USER"); if(user == nil) user = readcons("user", nil, 0); secstoreserver = nil; authserver = getenv("auth"); if(authserver == nil) authserver = "lookout.cs.bell-labs.com"; system = getenv("cpu"); if(system == nil) system = "anna.cs.bell-labs.com"; ARGBEGIN{ case 'o': authserver = "plan9.bell-labs.com"; system = "plan9.bell-labs.com"; break; case 'a': authserver = EARGF(usage()); break; case 'c': system = EARGF(usage()); break; case 'd': dbg++; break; case 'e': ealgs = EARGF(usage()); if(*ealgs == 0 || strcmp(ealgs, "clear") == 0) ealgs = nil; break; case 'C': cflag++; cmd[0] = '!'; cmd[1] = '/0'; while((p = ARGF()) != nil) { strcat(cmd, " "); strcat(cmd, p); } break; case 'k': keyspec = EARGF(usage()); break; case 'u': user = EARGF(usage()); break; case 's': secstoreserver = EARGF(usage()); break; default: usage(); }ARGEND; if(argc != 0) usage(); if(mountfactotum() < 0){ if(secstoreserver == nil) secstoreserver = authserver; if(havesecstore(secstoreserver, user)){ s = secstorefetch(secstoreserver, user, nil); if(s){ if(strlen(s) >= sizeof secstorebuf) sysfatal("secstore data too big"); strcpy(secstorebuf, s); } } } if((err = rexcall(&data, system, srvname))) fatal(1, "%s: %s", err, system); /* Tell the remote side the command to execute and where our working directory is */ if(cflag) writestr(data, cmd, "command", 0); if(getcwd(dat, sizeof(dat)) == 0) writestr(data, "NO", "dir", 0); else writestr(data, dat, "dir", 0); /* * Wait for the other end to execute and start our file service * of /mnt/term */ if(readstr(data, buf, sizeof(buf)) < 0) fatal(1, "waiting for FS: %r"); if(strncmp("FS", buf, 2) != 0) {//.........这里部分代码省略.........
开发者ID:0intro,项目名称:drawterm,代码行数:101,
示例7: threadmainvoidthreadmain(int argc, char **argv){ int fd, i, nd; char *err, *mnt, *srv; Dir *d; srv = "usb"; mnt = "/dev"; ARGBEGIN{ case 'D': usbfsdebug++; break; case 'd': usbdebug++; break; case 's': srv = EARGF(usage()); break; case 'i': pollms = atoi(EARGF(usage())); break; case 'm': mnt = EARGF(usage()); break; default: usage(); }ARGEND; if(access("/dev/usb", AEXIST) < 0 && bind("#u", "/dev", MBEFORE) < 0) sysfatal("#u: %r"); args(); fmtinstall('U', Ufmt); quotefmtinstall(); rfork(RFNOTEG); portc = chancreate(sizeof(char *), 0); if(portc == nil) sysfatal("chancreate"); proccreate(work, portc, Stack); if(argc == 0){ fd = open("/dev/usb", OREAD); if(fd < 0) sysfatal("/dev/usb: %r"); nd = dirreadall(fd, &d); close(fd); if(nd < 2) sysfatal("/dev/usb: no hubs"); for(i = 0; i < nd; i++) if(strcmp(d[i].name, "ctl") != 0) sendp(portc, smprint("/dev/usb/%s", d[i].name)); free(d); }else for(i = 0; i < argc; i++) sendp(portc, strdup(argv[i])); sendp(portc, nil); err = recvp(portc); chanfree(portc); usbfsexits(0); usbfsinit(srv, mnt, &usbdirfs, MAFTER); snprint(ctlfs.name, sizeof(ctlfs.name), "usbdctl"); usbfsadd(&ctlfs); threadexits(err);}
开发者ID:elbing,项目名称:harvey,代码行数:64,
示例8: threadmainvoidthreadmain(int argc, char *argv[]){ Column *c; char buf[256]; int i, ncol; rfork(RFENVG|RFNAMEG); ncol = 1; ARGBEGIN{ case 'c': ncol = atoi(EARGF(usage())); if(ncol <= 0) usage(); break; case 'm': webmountpt = EARGF(usage()); break; case 'p': procstderr++; break; case 't': charset = EARGF(usage()); break; default: usage(); break; }ARGEND snprint(buf, sizeof(buf), "%s/ctl", webmountpt); webctlfd = open(buf, ORDWR); if(webctlfd < 0) sysfatal("can't initialize webfs: %r"); snarffd = open("/dev/snarf", OREAD|OCEXEC); if(initdraw(derror, fontnames[0], "abaco") < 0) sysfatal("can't open display: %r"); memimageinit(); iconinit(); timerinit(); initfontpaths(); cexit = chancreate(sizeof(int), 0); crefresh = chancreate(sizeof(Page *), 0); if(cexit==nil || crefresh==nil) sysfatal("can't create initial channels: %r"); mousectl = initmouse(nil, screen); if(mousectl == nil) sysfatal("can't initialize mouse: %r"); mouse = mousectl; keyboardctl = initkeyboard(nil); if(keyboardctl == nil) sysfatal("can't initialize keyboard: %r"); mainpid = getpid(); plumbwebfd = plumbopen("web", OREAD|OCEXEC); if(plumbwebfd >= 0){ cplumb = chancreate(sizeof(Plumbmsg*), 0); proccreate(plumbproc, nil, STACK); } plumbsendfd = plumbopen("send", OWRITE|OCEXEC); rowinit(&row, screen->clipr); for(i=0; i<ncol; i++){ c = rowadd(&row, nil, -1); if(c==nil && i==0) error("initializing columns"); } c = row.col[row.ncol-1]; for(i=0; i<argc; i++) if(i/WPERCOL >= row.ncol) readpage(c, argv[i]); else readpage(row.col[i/WPERCOL], argv[i]); flushimage(display, 1); threadcreate(keyboardthread, nil, STACK); threadcreate(mousethread, nil, STACK); threadnotify(shutdown, 1); recvul(cexit); threadexitsall(nil);}
开发者ID:99years,项目名称:plan9,代码行数:84,
示例9: threadmainvoidthreadmain(int argc, char *argv[]){ int i, printstats; char *host; VacFile *f; fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); fmtinstall('t', mtimefmt); fmtinstall('M', dirmodefmt); host = nil; printstats = 0; ARGBEGIN{ case 'T': settimes = 1; break; case 'V': chattyventi = 1; break; case 'c': tostdout++; break; case 'd': diff++; break; case 'h': host = EARGF(usage()); break; case 's': printstats++; break; case 't': table++; break; case 'v': chatty++; break; default: usage(); }ARGEND if(argc < 1) usage(); if(tostdout && diff){ fprint(2, "cannot use -c with -d/n"); usage(); } conn = vtdial(host); if(conn == nil) sysfatal("could not connect to server: %r"); if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); fs = vacfsopen(conn, argv[0], VtOREAD, 128); if(fs == nil) sysfatal("vacfsopen: %r"); nwant = argc-1; want = argv+1; found = vtmallocz(nwant*sizeof found[0]); if((f = vacfsgetroot(fs)) == nil) sysfatal("vacfsgetroot: %r"); unvac(f, nil, nil); for(i=0; i<nwant; i++){ if(want[i] && !found[i]){ fprint(2, "warning: didn't find %s/n", want[i]); errors++; } } if(errors) threadexitsall("errors"); if(printstats) fprint(2, "%lld bytes read, %lld bytes skipped/n", stats.data, stats.skipdata); threadexitsall(0);}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:85,
示例10: mainvoidmain(int argc, char **argv){ char *netdir; char buf[1024]; netdir = nil; quotefmtinstall(); fmtinstall('I', eipfmt); starttime = time(0); ARGBEGIN{ case 'a': authenticate = 1; break; case 'c': tlscert = EARGF(usage()); break; case 'D': Dflag++; break; case 'd': debug++; break; case 'f': /* disallow relaying */ fflag = 1; break; case 'g': gflag = 1; break; case 'h': /* default domain name */ dom = EARGF(usage()); break; case 'k': /* prohibited ip address */ addbadguy(EARGF(usage())); break; case 'm': /* set mail command */ mailer = mailerpath(EARGF(usage())); break; case 'n': /* log peer ip address */ netdir = EARGF(usage()); break; case 'p': passwordinclear = 1; break; case 'r': rflag = 1; /* verify sender's domain */ break; case 's': /* save blocked messages */ sflag = 1; break; case 't': fprint(2, "%s: the -t option is no longer supported, see -c/n", argv0); tlscert = "/sys/lib/ssl/smtpd-cert.pem"; break; default: usage(); }ARGEND; nci = getnetconninfo(netdir, 0); if(nci == nil) sysfatal("can't get remote system's address: %r"); parseip(rsysip, nci->rsys); if(mailer == nil) mailer = mailerpath("send"); if(debug){ snprint(buf, sizeof buf, "%s/smtpdb/%ld", UPASLOG, time(0)); close(2); if (create(buf, OWRITE | OEXCL, 0662) >= 0) { seek(2, 0, 2); fprint(2, "%d smtpd %s/n", getpid(), thedate()); } else debug = 0; } getconf(); if (isbadguy()) exits("banned"); Binit(&bin, 0, OREAD); if (chdir(UPASLOG) < 0) syslog(0, "smtpd", "no %s: %r", UPASLOG); me = sysname_read(); if(dom == 0 || dom[0] == 0) dom = domainname_read(); if(dom == 0 || dom[0] == 0) dom = me; sayhi(); parseinit(); /* allow 45 minutes to parse the header */ atnotify(catchalarm, 1); alarm(45*60*1000); zzparse(); exits(0);}
开发者ID:CoryXie,项目名称:nix-os,代码行数:97,
示例11: threadmainvoidthreadmain(int argc, char *argv[]){ char *mtpt, *s; char *secstorepw; char err[ERRMAX]; Dir d; rfork(RFNOTEG); mtpt = "/mnt"; extrafactotumdir = 1; secstorepw = nil; quotefmtinstall(); fmtinstall('A', attrfmt); fmtinstall('H', encodefmt); fmtinstall('N', attrnamefmt); if(argc == 3 && strcmp(argv[1], "-g") == 0){ gflag(argv[2]); threadexitsall(nil); } ARGBEGIN{ default: usage(); case 'D': chatty9p++; break; case 'S': /* server: read nvram, no prompting for keys */ askforkeys = 0; trysecstore = 0; sflag = 1; break; case 'a': authaddr = EARGF(usage()); break; case 'd': debug = 1; doprivate = 0; break; case 'g': usage(); case 'k': /* reinitialize nvram */ kflag = 1; break; case 'm': mtpt = EARGF(usage()); break; case 'n': trysecstore = 0; break; case 'p': doprivate = 0; break; case 's': service = EARGF(usage()); break; case 'u': /* user: set hostowner */ uflag = 1; break; case 'x': extrafactotumdir = 0; break; }ARGEND if(argc != 0) usage(); if(doprivate) private(); initcap(); if(sflag){ s = getnvramkey(kflag ? NVwrite : NVwriteonerr, &secstorepw); if(s == nil) fprint(2, "factotum warning: cannot read nvram: %r/n"); else if(ctlwrite(s) < 0) fprint(2, "factotum warning: cannot add nvram key: %r/n"); if(secstorepw != nil) trysecstore = 1; if (s != nil) { memset(s, 0, strlen(s)); free(s); } } else if(uflag) promptforhostowner(); owner = getuser(); if(trysecstore && havesecstore()){ while(secstorefetch(secstorepw) < 0){ rerrstr(err, sizeof err); if(strcmp(err, "cancel") == 0) break; fprint(2, "secstorefetch: %r/n"); fprint(2, "Enter an empty password to quit./n"); free(secstorepw); secstorepw = nil; /* just try nvram pw once */ } }//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:nix-os,代码行数:101,
示例12: mainvoidmain(int argc, char **argv){ char *mntpt, *srvpost, srvfile[64]; int backwards = 0, fd, mntflags, oldserver; quotefmtinstall(); srvpost = nil; oldserver = 0; mntflags = MREPL; ARGBEGIN{ case 'A': doauth = 0; break; case 'a': mntflags = MAFTER; break; case 'b': mntflags = MBEFORE; break; case 'c': mntflags |= MCREATE; break; case 'C': mntflags |= MCACHE; break; case 'd': debug++; break; case 'f': /* ignored but allowed for compatibility */ break; case 'O': case 'o': oldserver = 1; break; case 'E': if ((encproto = lookup(EARGF(usage()), encprotos)) < 0) usage(); break; case 'e': ealgs = EARGF(usage()); if(*ealgs == 0 || strcmp(ealgs, "clear") == 0) ealgs = nil; break; case 'k': keyspec = EARGF(usage()); break; case 'p': filterp = aan; break; case 'n': anstring = EARGF(usage()); break; case 's': srvpost = EARGF(usage()); break; case 'B': backwards = 1; break; case 'z': skiptree = 1; break; default: usage(); }ARGEND; mntpt = 0; /* to shut up compiler */ if(backwards){ switch(argc) { default: mntpt = argv[0]; break; case 0: usage(); } } else { switch(argc) { case 2: mntpt = argv[1]; break; case 3: mntpt = argv[2]; break; default: usage(); } } if (encproto == Enctls) sysfatal("%s: tls has not yet been implemented", argv[0]); notify(catcher); alarm(60*1000); if (backwards) fd = passive(); else fd = connect(argv[0], argv[1], oldserver);//.........这里部分代码省略.........
开发者ID:grobe0ba,项目名称:plan9front,代码行数:101,
示例13: mainvoidmain(int argc, char **argv){ int fd, i, n; char buf[10485760]; ARGBEGIN{ case 'd': verbose = 1; break; case 's': replacesame = atoi(EARGF(usage())); break; case 'm': mindist = atoi(EARGF(usage())); break; case 'n': win = atoi(EARGF(usage())); minrun = win; break; default: usage(); }ARGEND switch(argc){ default: usage(); case 0: fd = 0; break; case 1: if((fd = open(argv[0], OREAD)) < 0) sysfatal("open %s: %r", argv[0]); break; } while((n = readn(fd, buf, sizeof buf)) > 0){ data = realloc(data, length+n); if(data == nil) sysfatal("realloc: %r"); memmove(data+length, buf, n); length += n; if(n < sizeof buf) break; } odat = malloc(length); if(odat == nil) sysfatal("malloc: %r"); Binit(&bout, 1, OWRITE); Bprint(&bout, "BLZ/n"); Bputint(&bout, length); outn = 1; for(i=0; i<win; i++) outn = (outn * 256) % Prime; if(verbose) fprint(2, "256^%d = %.6lux/n", win, outn); outn = Prime - outn; if(verbose) fprint(2, "outn = %.6lux/n", outn); compress(); Bwrite(&bout, odat, nodat); Bterm(&bout); fprint(2, "brk %p/n", sbrk(1)); fprint(2, "%d nodes used; %d of %d hash slots used/n", nalloc, nnew, nhash); exits(nil); }
开发者ID:aahud,项目名称:harvey,代码行数:69,
示例14: mainvoidmain(int argc, char **argv){ int fd, xsize, ysize; Memimage *im, *nim; ulong ochan, tchan; xsize = ysize = 0; ARGBEGIN{ case 'a': xsize = ysize = getsize(EARGF(usage())); break; case 'x': xsize = getsize(EARGF(usage())); break; case 'y': ysize = getsize(EARGF(usage())); break; default: usage(); }ARGEND fd = 0; if(*argv){ fd = open(*argv, OREAD); if(fd < 0) sysfatal("open: %r"); } memimageinit(); if((im = readmemimage(fd)) == nil) sysfatal("readmemimage: %r"); if(xsize & PERCENT) xsize = ((xsize & ~PERCENT) * Dx(im->r)) / 100; if(ysize & PERCENT) ysize = ((ysize & ~PERCENT) * Dy(im->r)) / 100; if(xsize || ysize){ if(ysize == 0) ysize = (xsize * Dy(im->r)) / Dx(im->r); if(xsize == 0) xsize = (ysize * Dx(im->r)) / Dy(im->r); ochan = im->chan; switch(ochan){ default: for(tchan = ochan; tchan; tchan >>= 8) if(TYPE(tchan) == CAlpha){ tchan = RGBA32; break; } if(tchan == 0) tchan = RGB24; break; case GREY8: case RGB24: case RGBA32: case ARGB32: case XRGB32: tchan = ochan; break; case GREY1: case GREY2: case GREY4: tchan = GREY8; break; } if(tchan != ochan){ if((nim = allocmemimage(im->r, tchan)) == nil) sysfatal("allocimage: %r"); memimagedraw(nim, nim->r, im, im->r.min, nil, ZP, S); freememimage(im); im = nim; } if((nim = allocmemimage( Rect(im->r.min.x, im->r.min.y, im->r.min.x+xsize, im->r.min.y+ysize), tchan)) == nil) sysfatal("allocmemimage: %r"); resample(nim, nim->r, im, im->r); freememimage(im); im = nim; if(tchan != ochan){ if((im = allocmemimage(nim->r, ochan)) == nil) sysfatal("allocimage: %r"); memimagedraw(im, im->r, nim, nim->r.min, nil, ZP, S); freememimage(nim); } } if(writememimage(1, im) < 0) sysfatal("writememimage: %r"); exits(0);}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:88,
示例15: threadmainvoidthreadmain(int argc, char *argv[]){ int n; uchar score[VtScoreSize]; uchar *buf; char *host, *type; vlong off; VtEntry e; VtRoot root; VtCache *c; VtConn *z; VtFile *f; quotefmtinstall(); fmtinstall('F', vtfcallfmt); fmtinstall('V', vtscorefmt); host = nil; ARGBEGIN{ case 'V': chattyventi++; break; case 'h': host = EARGF(usage()); break; case 'v': chatty++; break; default: usage(); break; }ARGEND if(argc != 1) usage(); type = nil; if(vtparsescore(argv[0], &type, score) < 0) sysfatal("could not parse score '%s': %r", argv[0]); if(type == nil || strcmp(type, "file") != 0) sysfatal("bad score - not file:..."); buf = vtmallocz(VtMaxLumpSize); z = vtdial(host); if(z == nil) sysfatal("could not connect to server: %r"); if(vtconnect(z) < 0) sysfatal("vtconnect: %r"); // root block ... n = vtread(z, score, VtRootType, buf, VtMaxLumpSize); if(n < 0) sysfatal("could not read root %V: %r", score); if(n != VtRootSize) sysfatal("root block %V is wrong size %d != %d", score, n, VtRootSize); if(vtrootunpack(&root, buf) < 0) sysfatal("unpacking root block %V: %r", score); if(strcmp(root.type, "file") != 0) sysfatal("bad root type %q (not 'file')", root.type); if(chatty) fprint(2, "%V: %q %q %V %d %V/n", score, root.name, root.type, root.score, root.blocksize, root.prev); // ... points at entry block n = vtread(z, root.score, VtDirType, buf, VtMaxLumpSize); if(n < 0) sysfatal("could not read entry %V: %r", root.score); if(n != VtEntrySize) sysfatal("dir block %V is wrong size %d != %d", root.score, n, VtEntrySize); if(vtentryunpack(&e, buf, 0) < 0) sysfatal("unpacking dir block %V: %r", root.score); if((e.type&VtTypeBaseMask) != VtDataType) sysfatal("not a single file"); // open and read file c = vtcachealloc(z, root.blocksize*32); if(c == nil) sysfatal("vtcachealloc: %r"); f = vtfileopenroot(c, &e); if(f == nil) sysfatal("vtfileopenroot: %r"); off = 0; vtfilelock(f, VtOREAD); while((n = vtfileread(f, buf, VtMaxLumpSize, off)) > 0){ write(1, buf, n); off += n; } threadexitsall(0);}
开发者ID:00001,项目名称:plan9port,代码行数:93,
示例16: xlsstatic intxls(int argc, char *argv[]) { MIXP_MESSAGE m; MIXP_STAT *stat; MIXP_CFID *fid; char *file, *buf; int lflag, dflag, count, nstat, mstat, i; lflag = dflag = 0; ARGBEGIN{ case 'l': lflag++; break; case 'd': dflag++; break; default: usage(); }ARGEND; file = EARGF(usage()); stat = mixp_stat(client, file); if(stat == NULL) fatal("cannot stat file '%s': %s/n", file, mixp_errbuf()); if(dflag || (stat->mode&P9_DMDIR) == 0) { print_stat(stat, lflag); mixp_stat_free(stat); return 0; } mixp_stat_free(stat); fid = mixp_open(client, file, P9_OREAD); if(fid == NULL) fatal("Can't open file '%s': %s/n", file, mixp_errbuf()); nstat = 0; mstat = 16; stat = malloc(sizeof(*stat) * mstat); buf = malloc(fid->iounit); while((count = mixp_read(fid, buf, fid->iounit)) > 0) { m = mixp_message(buf, count, MsgUnpack); while(m.pos < m.end) { if(nstat == mstat) { mstat <<= 1; stat = ixp_erealloc(stat, sizeof(*stat) * mstat); } mixp_pstat(&m, &stat[nstat++]); } } qsort(stat, nstat, sizeof(*stat), comp_stat); for(i = 0; i < nstat; i++) { print_stat(&stat[i], lflag); mixp_stat_free(&stat[i]); } free(stat); if(count == -1) fatal("cannot read directory '%s': %s/n", file, mixp_errbuf()); return 0;}
开发者ID:metux,项目名称:libmixp,代码行数:64,
示例17: mainvoidmain(int argc, char *argv[]){ int i, c; char *a; char name[LIBNAMELEN]; Binit(&bso, 1, OWRITE); cout = -1; listinit(); memset(debug, 0, sizeof(debug)); nerrors = 0; outfile = "8.out"; HEADTYPE = -1; INITTEXT = -1; INITTEXTP = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; ARGBEGIN { default: c = ARGC(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': /* output to (next arg) */ outfile = ARGF(); break; case 'E': a = ARGF(); if(a) INITENTRY = a; break; case 'H': a = ARGF(); if(a) HEADTYPE = atolwhex(a); break; case 'L': addlibpath(EARGF(usage())); break; case 'T': a = ARGF(); if(a) INITTEXT = atolwhex(a); break; case 'P': a = ARGF(); if(a) INITTEXTP = atolwhex(a); break; case 'D': a = ARGF(); if(a) INITDAT = atolwhex(a); break; case 'R': a = ARGF(); if(a) INITRND = atolwhex(a); break; case 'x': /* produce export table */ doexp = 1; if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])){ a = ARGF(); if(strcmp(a, "*") == 0) allexport = 1; else readundefs(a, SEXPORT); } break; case 'u': /* produce dynamically loadable module */ dlm = 1; debug['l']++; if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) readundefs(ARGF(), SIMPORT); break; } ARGEND USED(argc); if(*argv == 0) usage(); if(!debug['9'] && !debug['U'] && !debug['B']) debug[DEFAULT] = 1; a = getenv("ccroot"); if(a != nil && *a != '/0') { if(!fileexists(a)) { diag("nonexistent $ccroot: %s", a); errorexit(); } }else a = ""; snprint(name, sizeof(name), "%s/%s/lib", a, thestring); addlibpath(name); if(HEADTYPE == -1) { if(debug['U']) HEADTYPE = 1; if(debug['B']) HEADTYPE = 2; if(debug['9']) HEADTYPE = 2;//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:legacy,代码行数:101,
示例18: mainvoidmain(int argc, char **argv){ int srvfd, pipefd[2], stdio; Xfsub **xs; stdio = 0; ARGBEGIN { case '9': noplan9 = 1; break; case 'c': nclust = atoi(EARGF(usage())); if (nclust <= 0) sysfatal("nclust %d non-positive", nclust); break; case 'f': deffile = EARGF(usage()); break; case 'r': norock = 1; break; case 's': stdio = 1; break; case 'v': chatty = 1; break; case 'J': nojoliet = 1; break; default: usage(); } ARGEND switch(argc) { case 0: break; case 1: srvname = argv[0]; break; default: usage(); } iobuf_init(); for(xs=xsublist; *xs; xs++) (*(*xs)->reset)(); if(stdio) { pipefd[0] = 0; pipefd[1] = 1; } else { close(0); close(1); open("/dev/null", OREAD); open("/dev/null", OWRITE); if(pipe(pipefd) < 0) panic(1, "pipe"); sprint(srvfile, "/srv/%s", srvname); srvfd = create(srvfile, OWRITE|ORCLOSE, 0600); if(srvfd < 0) panic(1, srvfile); fprint(srvfd, "%d", pipefd[0]); close(pipefd[0]); fprint(2, "%s %d: serving %s/n", argv0, getpid(), srvfile); } srvfd = pipefd[1]; switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC)){ case -1: panic(1, "fork"); default: _exits(0); case 0: break; } io(srvfd); exits(0);}
开发者ID:99years,项目名称:plan9,代码行数:81,
示例19: mainvoidmain(int argc, char **argv){ uchar *pkt; char *buf, *file, *p, *e; int fd, cfd; int n; Binit(&out, 1, OWRITE); fmtinstall('E', eipfmt); fmtinstall('V', eipfmt); fmtinstall('I', eipfmt); fmtinstall('H', encodefmt); fmtinstall('F', fcallfmt); pkt = malloc(Pktlen+16); pkt += 16; buf = malloc(Blen); e = buf+Blen-1; pflag = 1; Nflag = 32; sflag = 0; mkprotograph(); ARGBEGIN{ default: usage(); case '?': printusage(); printhelp(ARGF()); exits(0); break; case 'M': p = EARGF(usage()); Mflag = atoi(p); break; case 'N': p = EARGF(usage()); Nflag = atoi(p); break; case 'f': p = EARGF(usage()); yyinit(p); yyparse(); break; case 's': sflag = 1; break; case 'h': p = EARGF(usage()); root = findproto(p); if(root == nil) sysfatal("unknown protocol: %s", p); break; case 'd': toflag = 1; break; case 'D': toflag = 1; pcap = 1; break; case 't': tiflag = 1; break; case 'C': Cflag = 1; break; case 'p': pflag = 0; break; }ARGEND; if(pcap) pcaphdr(); if(argc == 0){ file = "/net/ether0"; if(root != nil) root = ðer; } else file = argv[0]; if((!tiflag) && strstr(file, "ether")){ if(root == nil) root = ðer; snprint(buf, Blen, "%s!-1", file); fd = dial(buf, 0, 0, &cfd); if(fd < 0) sysfatal("dialing %s: %r", buf); if(pflag && fprint(cfd, prom, strlen(prom)) < 0) sysfatal("setting %s", prom); } else if((!tiflag) && strstr(file, "ipifc")){ if(root == nil) root = &ip; snprint(buf, Blen, "%s/snoop", file); fd = open(buf, OREAD); if(fd < 0)//.........这里部分代码省略.........
开发者ID:aahud,项目名称:harvey,代码行数:101,
示例20: mainvoidmain(int argc, char **argv){ int auth, x; char *mtpt, *service, *where, *user; Netbuf n; UserPasswd *up; mtpt = "/mnt/news"; service = nil; memset(&n, 0, sizeof n); user = nil; auth = 0; ARGBEGIN{ case 'D': chatty9p++; break; case 'N': netdebug = 1; break; case 'a': auth = 1; break; case 'u': user = EARGF(usage()); break; case 's': service = EARGF(usage()); break; case 'm': mtpt = EARGF(usage()); break; default: usage(); }ARGEND if(argc > 1) usage(); if(argc==0) where = "$nntp"; else where = argv[0]; now = time(0); net = &n; if(auth) { n.auth = 1; if(user) up = auth_getuserpasswd(auth_getkey, "proto=pass service=nntp server=%q user=%q", where, user); else up = auth_getuserpasswd(auth_getkey, "proto=pass service=nntp server=%q", where); if(up == nil) sysfatal("no password: %r"); n.user = up->user; n.pass = up->passwd; } n.addr = netmkaddr(where, "tcp", "nntp"); root = emalloc(sizeof *root); root->name = estrdup(""); root->parent = root; n.fd = -1; if(nntpconnect(&n) < 0) sysfatal("nntpconnect: %s", n.response); x=netdebug; netdebug=0; nntprefreshall(&n); netdebug=x;// dumpgroups(root, 0); postmountsrv(&nntpsrv, service, mtpt, MREPL); exits(nil);}
开发者ID:aahud,项目名称:harvey,代码行数:78,
示例21: mainvoidmain(int argc, char **argv){ int p[2], pid, i, j, n, off, npad, prefix; char **av, *q, *r, *tofree, *name; char nambuf[100]; Biobuf *bin, *bout; Type *t; Field *f; quotefmtinstall(); oargc = argc; oargv = argv; av = emalloc((30+argc)*sizeof av[0]); atexit(waitforgcc); n = 0; av[n++] = "gcc"; av[n++] = "-c"; av[n++] = "-fdollars-in-identifiers"; av[n++] = "-S"; // write assembly av[n++] = "-gstabs"; // include stabs info av[n++] = "-o-"; // to stdout av[n++] = "-xc"; // read C ARGBEGIN{ case 'g': lang = &go; pkg = EARGF(usage()); break; case 'c': av[0] = EARGF(usage()); break; case 'f': av[n++] = EARGF(usage()); break; default: usage(); }ARGEND if(argc == 0) av[n++] = "-"; else av[n++] = argv[0]; av[n] = nil; // Run gcc writing assembly and stabs debugging to p[1]. if(pipe(p) < 0) sysfatal("pipe: %r"); pid = fork(); if(pid < 0) sysfatal("fork: %r"); if(pid == 0) { close(p[0]); dup(p[1], 1); if(argc == 0) { exec(av[0], av); fprint(2, "exec gcc: %r/n"); exit(1); } // Some versions of gcc do not accept -S with multiple files. // Run gcc once for each file. close(0); open("/dev/null", OREAD); for(i=0; i<argc; i++) { pid = fork(); if(pid < 0) sysfatal("fork: %r"); if(pid == 0) { av[n-1] = argv[i]; exec(av[0], av); fprint(2, "exec gcc: %r/n"); exit(1); } waitpid(); } exit(0); } close(p[1]); // Read assembly, pulling out .stabs lines. bin = Bfdopen(p[0], OREAD); while((q = Brdstr(bin, '/n', 1)) != nil) { // .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0 tofree = q; while(*q == ' ' || *q == '/t') q++; if(strncmp(q, ".stabs", 6) != 0) goto Continue; q += 6; while(*q == ' ' || *q == '/t') q++; if(*q++ != '/"') { Bad: sysfatal("cannot parse .stabs line:/n%s", tofree); } r = strchr(q, '/"');//.........这里部分代码省略.........
开发者ID:8l,项目名称:go-learn,代码行数:101,
示例22: threadmainvoidthreadmain(int argc, char *argv[]){ int vers; ArenaPart *ap; Part *part; Arena *arena; u64int addr, limit, asize, apsize; char *file, *name, aname[ANameSize]; int i, n, blocksize, tabsize, zero; ventifmtinstall(); statsinit(); blocksize = 8 * 1024; asize = 512 * 1024 *1024; tabsize = 512 * 1024; /* BUG: should be determine from number of arenas */ zero = -1; vers = ArenaVersion5; ARGBEGIN{ case 'D': settrace(EARGF(usage())); break; case 'a': asize = unittoull(EARGF(usage())); if(asize == TWID64) usage(); break; case 'b': blocksize = unittoull(EARGF(usage())); if(blocksize == ~0) usage(); if(blocksize > MaxDiskBlock) { fprint(2, "block size too large, max %d/n", MaxDiskBlock); threadexitsall("usage"); } break; case '4': vers = ArenaVersion4; break; case 'Z': zero = 0; break; default: usage(); break; } ARGEND if(zero == -1) { if(vers == ArenaVersion4) zero = 1; else zero = 0; } if(argc != 2) usage(); name = argv[0]; file = argv[1]; if(nameok(name) < 0) sysfatal("illegal name template %s", name); part = initpart(file, ORDWR|ODIRECT); if(part == nil) sysfatal("can't open partition %s: %r", file); if(zero) zeropart(part, blocksize); maxblocksize = blocksize; initdcache(20*blocksize); ap = newarenapart(part, blocksize, tabsize); if(ap == nil) sysfatal("can't initialize arena: %r"); apsize = ap->size - ap->arenabase; n = apsize / asize; if(apsize - (n * asize) >= MinArenaSize) n++; fprint(2, "fmtarenas %s: %,d arenas, %,lld bytes storage, %,d bytes for index map/n", file, n, apsize, ap->tabsize); ap->narenas = n; ap->map = MKNZ(AMap, n); ap->arenas = MKNZ(Arena*, n); addr = ap->arenabase; for(i = 0; i < n; i++) { limit = addr + asize; if(limit >= ap->size || ap->size - limit < MinArenaSize) { limit = ap->size; if(limit - addr < MinArenaSize) sysfatal("bad arena set math: runt arena at %lld,%lld %lld", addr, limit, ap->size); } snprint(aname, ANameSize, "%s%d", name, i);//.........这里部分代码省略.........
开发者ID:aberg001,项目名称:plan9,代码行数:101,
示例23: mainvoidmain(int argc, char **argv){ int fix; ulong block, newnull, cblock; vlong maxsize; uvlong length, clength; char buf[256], *dumpname, *proto, *s, *src, *status; Cdimg *cd; Cdinfo info; XDir dir; Direc *iconform, idumproot, iroot, *jconform, jdumproot, jroot, *r; Dump *dump; fix = 0; status = nil; memset(&info, 0, sizeof info); proto = "/sys/lib/sysconfig/proto/allproto"; src = "./"; info.volumename = atom("9CD"); info.volumeset = atom("9VolumeSet"); info.publisher = atom("9Publisher"); info.preparer = atom("dump9660"); info.application = atom("dump9660"); info.flags = CDdump; maxsize = 0; mk9660 = 0; fmtinstall('H', encodefmt); ARGBEGIN{ case 'D': chatty++; break; case 'M': mk9660 = 1; argv0 = "disk/mk9660"; info.flags &= ~CDdump; break; case '9': info.flags |= CDplan9; break; case ':': docolon = 1; break; case 'a': doabort = 1; break; case 'B': info.flags |= CDbootnoemu; /* fall through */ case 'b': if(!mk9660) usage(); info.flags |= CDbootable; info.bootimage = EARGF(usage()); break; case 'c': info.flags |= CDconform; break; case 'f': fix = 1; break; case 'j': info.flags |= CDjoliet; break; case 'n': now = atoi(EARGF(usage())); break; case 'm': maxsize = strtoull(EARGF(usage()), 0, 0); break; case 'o': dataoffset = atoll(EARGF(usage())); blocksize = atoi(EARGF(usage())); if(blocksize%Blocksize) sysfatal("bad block size %d -- must be multiple of 2048", blocksize); blocksize /= Blocksize; break; case 'p': proto = EARGF(usage()); break; case 'r': info.flags |= CDrockridge; break; case 's': src = EARGF(usage()); break; case 'v': info.volumename = atom(EARGF(usage())); break; case 'x': info.flags |= CDpbs; info.loader = EARGF(usage()); break; default: usage(); }ARGEND if(info.flags & CDpbs && !(info.flags & CDbootnoemu))//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:plan9-gpl,代码行数:101,
示例24: threadmainvoidthreadmain(int argc, char **argv){ char *devdir; int i; long value[8], volume[8]; Audiocontrol *c; char *p; extern int attachok; Ep *ep; int csps[] = { Audiocsp, 0}; devdir = nil; volume[0] = Undef; for(i = 0; i<8; i++) value[i] = 0; fmtinstall('A', Aconv); fmtinstall('U', Ufmt); quotefmtinstall(); ARGBEGIN{ case 'N': p = EARGF(usage()); /* ignore dev nb */ break; case 'd': usbdebug++; verbose++; break; case 'm': mntpt = EARGF(usage()); break; case 'p': attachok++; break; case 's': srvpost = EARGF(usage()); break; case 'v': volume[0] = strtol(EARGF(usage()), &p, 0); for(i = 1; i < 8; i++) volume[i] = volume[0]; break; case 'V': verbose++; break; default: usage(); }ARGEND switch(argc){ case 0: break; case 1: devdir = argv[0]; break; default: usage(); } if(devdir == nil) if(finddevs(matchdevcsp, csps, &devdir, 1) < 1){ fprint(2, "No usb audio/n"); threadexitsall("usbaudio not found"); } ad = opendev(devdir); if(ad == nil) sysfatal("opendev: %r"); if(configdev(ad) < 0) sysfatal("configdev: %r"); for(i = 0; i < nelem(ad->usb->ddesc); i++) if(ad->usb->ddesc[i] != nil) switch(ad->usb->ddesc[i]->data.bDescriptorType){ case AUDIO_INTERFACE: audio_interface(ad, ad->usb->ddesc[i]); break; case AUDIO_ENDPOINT: audio_endpoint(ad, ad->usb->ddesc[i]); break; } controlchan = chancreate(sizeof(char*), 8); for(i = 0; i < nelem(ad->usb->ep); i++) if((ep = ad->usb->ep[i]) != nil){ if(ep->iface->csp == CSP(Claudio, 2, 0) && ep->dir == Eout) endpt[0] = ep->id; if(ep->iface->csp == CSP(Claudio, 2, 0) && ep->dir == Ein) endpt[1] = ep->id; if(buttonendpt<0 && Class(ep->iface->csp) == Clhid) buttonendpt = ep->id; } if(endpt[0] != -1){ if(verbose) fprint(2, "usb/audio: playback on ep %d/n", endpt[0]); interface[0] = ad->usb->ep[endpt[0]]->iface->id; } if(endpt[1] != -1){ if(verbose) fprint(2, "usb/audio: record on ep %d/n", endpt[0]); interface[1] = ad->usb->ep[endpt[1]]->iface->id; }//.........这里部分代码省略.........
开发者ID:CoryXie,项目名称:nix-os,代码行数:101,
示例25: optparsevoidoptparse(Server *s, char **argv){ int64 ms; char *arg, c, *tmp;# define EARGF(x) (*arg ? (tmp=arg,arg="",tmp) : *argv ? *argv++ : (x)) while ((arg = *argv++) && *arg++ == '-' && *arg) { while ((c = *arg++)) { switch (c) { case 'p': s->port = EARGF(flagusage("-p")); warn_systemd_ignored_option("-p", s->port); break; case 'l': s->addr = EARGF(flagusage("-l")); warn_systemd_ignored_option("-l", s->addr); break; case 'L': s->path = EARGF(flagusage("-L")); warn_systemd_ignored_option("-L", s->path); if (strlen(s->path) > 100) { warnx("local socket path is longer than 100 bytes"); exit(1); } break; case 'z': job_data_size_limit = parse_size_t(EARGF(flagusage("-z"))); break; case 's': s->wal.filesize = parse_size_t(EARGF(flagusage("-s"))); break; case 'c': s->wal.nocomp = 0; break; case 'n': s->wal.nocomp = 1; break; case 'f': ms = (int64)parse_size_t(EARGF(flagusage("-f"))); s->wal.syncrate = ms * 1000000; s->wal.wantsync = 1; break; case 'F': s->wal.wantsync = 0; break; case 'u': s->user = EARGF(flagusage("-u")); break; case 'b': s->wal.dir = EARGF(flagusage("-b")); s->wal.use = 1; break; case 'h': usage(0); case 'v': printf("beanstalkd %s/n", version); exit(0); case 'V': verbose++; break; default: warnx("unknown flag: %s", arg-2); usage(5); } } } if (arg) { warnx("unknown argument: %s", arg-1); usage(5); }}
开发者ID:m1ksoftware,项目名称:beanstalkd,代码行数:72,
示例26: mainvoidmain(int argc, char *argv[]){ int c, i; char *p; Binit(&bso, 1, OWRITE); cout = -1; listinit(); nerrors = 0; outfile = "5.out"; HEADTYPE = -1; INITTEXT = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; p = getenv("GOARM"); if(p != nil && strcmp(p, "5") == 0) debug['F'] = 1; ARGBEGIN { default: c = ARGC(); if(c == 'l') usage(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': outfile = EARGF(usage()); break; case 'E': INITENTRY = EARGF(usage()); break; case 'I': interpreter = EARGF(usage()); break; case 'L': Lflag(EARGF(usage())); break; case 'T': INITTEXT = atolwhex(EARGF(usage())); break; case 'D': INITDAT = atolwhex(EARGF(usage())); break; case 'R': INITRND = atolwhex(EARGF(usage())); break; case 'r': rpath = EARGF(usage()); break; case 'H': HEADTYPE = headtype(EARGF(usage())); /* do something about setting INITTEXT */ break; case 'V': print("%cl version %s/n", thechar, getgoversion()); errorexit(); } ARGEND USED(argc); if(argc != 1) usage(); libinit(); if(!debug['9'] && !debug['U'] && !debug['B']) debug[DEFAULT] = 1; if(HEADTYPE == -1) { if(debug['U']) HEADTYPE = Hnoheader; if(debug['B']) HEADTYPE = Hrisc; if(debug['9']) HEADTYPE = Hplan9x32; HEADTYPE = Hlinux; } switch(HEADTYPE) { default: diag("unknown -H option"); errorexit(); case Hnoheader: /* no header */ HEADR = 0L; if(INITTEXT == -1) INITTEXT = 0; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) INITRND = 4; break; case Hrisc: /* aif for risc os */ HEADR = 128L; if(INITTEXT == -1) INITTEXT = 0x10005000 + HEADR; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1)//.........这里部分代码省略.........
开发者ID:machinaut,项目名称:go,代码行数:101,
示例27: threadmainvoidthreadmain(int argc, char *argv[]){ char *defsrv, *srvname; int p[2], fd; int stdio; char *host = nil; long ncache; stdio = 0; ncache = 256; fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); defmnt = nil; defsrv = nil; ARGBEGIN{ case 'd': fmtinstall('F', fcallfmt); dflag = 1; break; case 'c': ncache = atoi(EARGF(usage())); break; case 'i': defmnt = nil; stdio = 1; mfd[0] = 0; mfd[1] = 1; break; case 'h': host = EARGF(usage()); break; case 'S': defsrv = EARGF(usage()); break; case 's': defsrv = "vacfs"; break; case 'm': defmnt = EARGF(usage()); break; case 'p': noperm = 1; break; case 'V': chattyventi = 1; break; default: usage(); }ARGEND if(argc != 1) usage(); if(defsrv == nil && defmnt == nil && !stdio) defmnt = "/n/vac"; if(stdio && defmnt) sysfatal("cannot use -m with -i"); initfcalls(); notify(notifyf); user = getuser(); conn = vtdial(host); if(conn == nil) sysfatal("could not connect to server: %r"); if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); fs = vacfsopen(conn, argv[0], VtOREAD, ncache); if(fs == nil) sysfatal("vacfsopen: %r"); if(!stdio){ if(pipe(p) < 0) sysfatal("pipe failed: %r"); mfd[0] = p[0]; mfd[1] = p[0]; srvfd = p[1]; if(defsrv){ srvname = smprint("/srv/%s", defsrv); fd = create(srvname, OWRITE|ORCLOSE, 0666); if(fd < 0) sysfatal("create %s: %r", srvname); if(fprint(fd, "%d", srvfd) < 0) sysfatal("write %s: %r", srvname); free(srvname); } } procrfork(srv, 0, Stacksize, RFFDG|RFNAMEG|RFNOTEG); if(!stdio){ close(p[0]); if(defmnt){ if(mount(srvfd, -1, defmnt, MREPL|MCREATE, "") < 0)//.........这里部分代码省略.........
开发者ID:npe9,项目名称:harvey,代码行数:101,
示例28: mainvoidmain(int argc, char *argv[]){ int c; char *a; char name[LIBNAMELEN]; Binit(&bso, 1, OWRITE); cout = -1; listinit(); outfile = 0; nerrors = 0; curtext = P; HEADTYPE = -1; INITTEXT = -1; INITTEXTP = -1; INITDAT = -1; INITRND = -1; INITENTRY = 0; ARGBEGIN { default: c = ARGC(); if(c >= 0 && c < sizeof(debug)) debug[c]++; break; case 'o': outfile = ARGF(); break; case 'E': a = ARGF(); if(a) INITENTRY = a; break; case 'L': addlibpath(EARGF(usage())); break; case 'T': a = ARGF(); if(a) INITTEXT = atolwhex(a); break; case 'P': a = ARGF(); if(a) INITTEXTP = atolwhex(a); break; case 'D': a = ARGF(); if(a) INITDAT = atolwhex(a); break; case 'R': a = ARGF(); if(a) INITRND = atolwhex(a); break; case 'H': a = ARGF(); if(a) HEADTYPE = atolwhex(a); break; case 'x': /* produce export table */ doexp = 1; if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) readundefs(ARGF(), SEXPORT); break; case 'u': /* produce dynamically loadable module */ dlm = 1; if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) readundefs(ARGF(), SIMPORT); break; } ARGEND USED(argc); if(*argv == 0) usage(); if(!debug['9'] && !debug['U'] && !debug['B']) debug[DEFAULT] = 1; a = getenv("ccroot"); if(a != nil && *a != '/0') { if(!fileexists(a)) { diag("nonexistent $ccroot: %s", a); errorexit(); } }else a = ""; snprint(name, sizeof(name), "%s/%s/lib", a, thestring); addlibpath(name); r0iszero = debug['0'] == 0; if(HEADTYPE == -1) { if(debug['U']) HEADTYPE = 0; if(debug['B']) HEADTYPE = 1; if(debug['9']) HEADTYPE = 2; } switch(HEADTYPE) { default: diag("unknown -H option");//.........这里部分代码省略.........
开发者ID:lufia,项目名称:plan9-contrib,代码行数:101,
示例29: ethermainintethermain(Dev *dev, int argc, char **argv){ int epin, epout, i, devid; Ether *e; uint8_t ea[Eaddrlen]; devid = dev->id; memset(ea, 0, Eaddrlen); ARGBEGIN{ case 'a': if(parseaddr(ea, EARGF(usage())) < 0) return usage(); break; case 'd': if(etherdebug == 0) fprint(2, "ether debug on/n"); etherdebug++; break; case 'N': devid = atoi(EARGF(usage())); break; default: return usage(); }ARGEND if(argc != 0) { return usage(); } e = dev->aux = emallocz(sizeof(Ether), 1); e->dev = dev; dev->free = etherdevfree; memmove(e->addr, ea, Eaddrlen); e->Etherops.name = "cdc"; for(i = 0; i < nelem(ethers); i++) if(ethers[i](e) == 0) break; if(i == nelem(ethers)) return -1; if(e->Etherops.init == nil) e->Etherops.init = etherinit; if(e->Etherops.init(e, &epin, &epout) < 0) return -1; if(e->Etherops.bwrite == nil) e->Etherops.bwrite = etherbwrite; if(e->Etherops.bread == nil) e->Etherops.bread = etherbread; if(e->Etherops.bufsize == 0) e->Etherops.bufsize = Maxpkt; if(openeps(e, epin, epout) < 0) return -1; if(kernelproxy(e) == 0) return 0; e->fs = etherfs; snprint(e->fs.name, sizeof(e->fs.name), "etherU%d", devid); e->fs.dev = dev; e->fs.aux = e; e->bc = chancreate(sizeof(Buf*), Nbufs); e->rc = chancreate(sizeof(Buf*), Nconns/2); e->wc = chancreate(sizeof(Buf*), Nconns*2); incref(&e->dev->Ref); proccreate(etherwriteproc, e, 16*1024); incref(&e->dev->Ref); proccreate(etherreadproc, e, 16*1024); deprint(2, "%s: dev ref %ld/n", argv0, dev->Ref.ref); incref(&e->dev->Ref); usbfsadd(&e->fs); return 0;}
开发者ID:keedon,项目名称:harvey,代码行数:70,
示例30: mainintmain(int argc, char *argv[]){ DIR *dp; struct dirent *entry; pid_t pid; struct procstat ps; char cmdline[BUFSIZ], *cmd, *cmdbase = NULL, *p, *arg = NULL; int i, found = 0; int sflag = 0, oflag = 0; struct pidentry *pe; ARGBEGIN { case 's': sflag = 1; break; case 'o': oflag = 1; arg = EARGF(usage()); break; default: usage(); } ARGEND; if (!argc) return 1; SLIST_INIT(&omitpid_head); for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) { pe = emalloc(sizeof(*pe)); if (strcmp(p, "%PPID") == 0) pe->pid = getppid(); else pe->pid = estrtol(p, 10); SLIST_INSERT_HEAD(&omitpid_head, pe, entry); } if (!(dp = opendir("/proc"))) eprintf("opendir /proc:"); while ((entry = readdir(dp))) { if (!pidfile(entry->d_name)) continue; pid = estrtol(entry->d_name, 10); if (oflag) { SLIST_FOREACH(pe, &omitpid_head, entry) if (pe->pid == pid) break; if (pe) continue; } if (parsestat(pid, &ps) < 0) continue; if (parsecmdline(ps.pid, cmdline, sizeof(cmdline)) < 0) { cmd = ps.comm; cmdbase = cmd; } else { if ((p = strchr(cmdline, ' '))) *p = '/0'; cmd = cmdline; cmdbase = basename(cmdline); } /* Workaround for login shells */ if (cmd[0] == '-') cmd++; for (i = 0; i < argc; i++) { if (strcmp(cmd, argv[i]) == 0 || strcmp(cmdbase, argv[i]) == 0) { putword(entry->d_name); found++; if (sflag) goto out; } } }out: if (found) putchar('/n'); closedir(dp); return 0;}
开发者ID:michaelforney,项目名称:ubase,代码行数:86,
注:本文中的EARGF函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EASValsSetColor函数代码示例 C++ EAMP_PRINTK函数代码示例 |