int main() { GREG g; yyinit(&g); while (yyparse(&g)); yydeinit(&g); return 0; }
int main() { GREG g; yyinit(&g); printf(yyparse(&g) ? "success\n" : "failure\n"); yydeinit(&g); return 0; }
int main(void) { GC_INIT(); GREG g; int jval, jval2; char c; sym_tab_init(); ast_init(); type_init(); scope_init(); rel_assign_init(); jit_t * jit = llvm_init(); yyinit(&g); printf("Welcome to Cesium v 0.2\n"); printf("To exit press CTRL-D\n\n"); printf("> "); while (1) { if (!(jval = setjmp(exc))) { if (!yyparse(&g)) { printf("Error parsing\n"); abort(); } else if (root != NULL) { rel_stack_init(); rel_assign_mark(); scope_mark(); annotate_ast(root); if (TRACE) ast_print(root, 0); unify(rel_stack, rel_assign); if (TRACE) print_assigns(rel_assign); exec_root(jit, root); if (root->tag != AST_FNDEC) rel_assign_rewind(); } } else if (jval == 1) root = NULL; else if (jval == 2) break; printf("\n> "); } yydeinit(&g); llvm_cleanup(jit); return 0; }
char * revarpa(char str[]) { if (yyinit(str) < 0) return(NOSTR); if (name()) return(NOSTR); if (strcmp(str, netbuf) == 0) return(str); return(savestr(netbuf)); }
void token_init(void) { static bool fTokenInit = false; yyinit(); if ( fTokenInit) { token_clear(); } else { fTokenInit = true; if (max_multi_token_len == 0) max_multi_token_len = (max_token_len+1) * multi_token_count + MAX_PREFIX_LEN; yylval_text_size = max_multi_token_len + MSG_COUNT_PADDING; yylval_text = (byte *) malloc( yylval_text_size+D ); yylval.leng = 0; yylval.u.text = yylval_text; /* First IP Address in Received: statement */ msg_addr = word_new( NULL, max_token_len ); /* Message ID */ msg_id = word_new( NULL, max_token_len * 3 ); /* Message's first queue ID */ queue_id = word_new( NULL, max_token_len ); ipsave = word_new( NULL, max_token_len ); /* word_new() used to avoid compiler complaints */ w_to = word_news("to:"); /* To: */ w_from = word_news("from:"); /* From: */ w_rtrn = word_news("rtrn:"); /* Return-Path: */ w_subj = word_news("subj:"); /* Subject: */ w_recv = word_news("rcvd:"); /* Received: */ w_head = word_news("head:"); /* Header: */ w_mime = word_news("mime:"); /* Mime: */ w_ip = word_news("ip:"); /* ip: */ w_url = word_news("url:"); /* url: */ nonblank_line = word_news(NONBLANK); /* do multi-word token initializations */ init_token_array(); } return; }
/* * send the damn thing */ char * data(String *from, Biobuf *b) { char *buf, *cp; int i, n, nbytes, bufsize, eof, r; String *fromline; char errmsg[Errlen]; char id[40]; /* * input the header. */ buf = malloc(1); if(buf == 0){ s_append(s_restart(reply), "out of memory"); return Retry; } n = 0; eof = 0; for(;;){ cp = Brdline(b, '\n'); if(cp == nil){ eof = 1; break; } nbytes = Blinelen(b); buf = realloc(buf, n+nbytes+1); if(buf == 0){ s_append(s_restart(reply), "out of memory"); return Retry; } strncpy(buf+n, cp, nbytes); n += nbytes; if(nbytes == 1) /* end of header */ break; } buf[n] = 0; bufsize = n; /* * parse the header, turn all addresses into @ format */ yyinit(buf, n); yyparse(); /* * print message observing '.' escapes and using \r\n for \n */ alarm(20*alarmscale); if(!filter){ dBprint("DATA\r\n"); switch(getreply()){ case 3: break; case 5: free(buf); return Giveup; default: free(buf); return Retry; } } /* * send header. add a message-id, a sender, and a date if there * isn't one */ nbytes = 0; fromline = convertheader(from); uneaten = buf; srand(truerand()); if(messageid == 0){ for(i=0; i<16; i++){ r = rand()&0xFF; id[2*i] = hex[r&0xF]; id[2*i+1] = hex[(r>>4)&0xF]; } id[2*i] = '\0'; nbytes += Bprint(&bout, "Message-ID: <%s@%s>\r\n", id, hostdomain); if(debug) Bprint(&berr, "Message-ID: <%s@%s>\r\n", id, hostdomain); } if(originator==0){ nbytes += Bprint(&bout, "From: %s\r\n", s_to_c(fromline)); if(debug) Bprint(&berr, "From: %s\r\n", s_to_c(fromline)); } s_free(fromline); if(destination == 0 && toline) if(*s_to_c(toline) == '@'){ /* route addr */ nbytes += Bprint(&bout, "To: <%s>\r\n", s_to_c(toline)); if(debug) Bprint(&berr, "To: <%s>\r\n", s_to_c(toline)); } else { nbytes += Bprint(&bout, "To: %s\r\n", s_to_c(toline)); if(debug) Bprint(&berr, "To: %s\r\n", s_to_c(toline)); } if(date==0 && udate) nbytes += printdate(udate); if (usys) uneaten = usys->end + 1; nbytes += printheader(); if (*uneaten != '\n') putcrnl("\n", 1); /* * send body */ putcrnl(uneaten, buf+n - uneaten); nbytes += buf+n - uneaten; if(eof == 0){ for(;;){ n = Bread(b, buf, bufsize); if(n < 0){ rerrstr(errmsg, sizeof(errmsg)); s_append(s_restart(reply), errmsg); free(buf); return Retry; } if(n == 0) break; alarm(10*alarmscale); putcrnl(buf, n); nbytes += n; } } free(buf); if(!filter){ if(last != '\n') dBprint("\r\n.\r\n"); else dBprint(".\r\n"); alarm(10*alarmscale); switch(getreply()){ case 2: break; case 5: return Giveup; default: return Retry; } syslog(0, "smtp", "%s sent %d bytes to %s", s_to_c(from), nbytes, s_to_c(toline));/**/ } return 0; }
/* * Pop the topmost PCB from the PCB stack and destroy any data structures that * are associated with it. If 'err' is non-zero, destroy any intermediate * state that is left behind as part of a compilation that has failed. */ void dt_pcb_pop(dtrace_hdl_t *dtp, int err) { dt_pcb_t *pcb = yypcb; uint_t i; assert(pcb != NULL); assert(pcb == dtp->dt_pcb); while (pcb->pcb_dstack.ds_next != NULL) (void) dt_scope_pop(); dt_scope_destroy(&pcb->pcb_dstack); dt_irlist_destroy(&pcb->pcb_ir); dt_node_link_free(&pcb->pcb_list); dt_node_link_free(&pcb->pcb_hold); if (err != 0) { dt_xlator_t *dxp, *nxp; dt_provider_t *pvp, *nvp; if (pcb->pcb_prog != NULL) dt_program_destroy(dtp, pcb->pcb_prog); if (pcb->pcb_stmt != NULL) dtrace_stmt_destroy(dtp, pcb->pcb_stmt); if (pcb->pcb_ecbdesc != NULL) dt_ecbdesc_release(dtp, pcb->pcb_ecbdesc); for (dxp = dt_list_next(&dtp->dt_xlators); dxp; dxp = nxp) { nxp = dt_list_next(dxp); if (dxp->dx_gen == dtp->dt_gen) dt_xlator_destroy(dtp, dxp); } for (pvp = dt_list_next(&dtp->dt_provlist); pvp; pvp = nvp) { nvp = dt_list_next(pvp); if (pvp->pv_gen == dtp->dt_gen) dt_provider_destroy(dtp, pvp); } (void) dt_idhash_iter(dtp->dt_aggs, dt_pcb_pop_ident, dtp); dt_idhash_update(dtp->dt_aggs); (void) dt_idhash_iter(dtp->dt_globals, dt_pcb_pop_ident, dtp); dt_idhash_update(dtp->dt_globals); (void) dt_idhash_iter(dtp->dt_tls, dt_pcb_pop_ident, dtp); dt_idhash_update(dtp->dt_tls); (void) ctf_discard(dtp->dt_cdefs->dm_ctfp); (void) ctf_discard(dtp->dt_ddefs->dm_ctfp); } if (pcb->pcb_pragmas != NULL) dt_idhash_destroy(pcb->pcb_pragmas); if (pcb->pcb_locals != NULL) dt_idhash_destroy(pcb->pcb_locals); if (pcb->pcb_idents != NULL) dt_idhash_destroy(pcb->pcb_idents); if (pcb->pcb_inttab != NULL) dt_inttab_destroy(pcb->pcb_inttab); if (pcb->pcb_strtab != NULL) dt_strtab_destroy(pcb->pcb_strtab); if (pcb->pcb_regs != NULL) dt_regset_destroy(pcb->pcb_regs); for (i = 0; i < pcb->pcb_asxreflen; i++) dt_free(dtp, pcb->pcb_asxrefs[i]); dt_free(dtp, pcb->pcb_asxrefs); dt_difo_free(dtp, pcb->pcb_difo); free(pcb->pcb_filetag); free(pcb->pcb_sflagv); dtp->dt_pcb = pcb->pcb_prev; bzero(pcb, sizeof (dt_pcb_t)); yyinit(dtp->dt_pcb); }
/* * pipe message to mailer with the following transformations: * - change \r\n into \n. * - add sender's domain to any addrs with no domain * - add a From: if none of From:, Sender:, or Replyto: exists * - add a Received: line */ int pipemsg(int *byteswritten) { int n, nbytes, sawdot, status, nonhdr, bpr; char *cp; Field *f; Link *l; Node *p; String *hdr, *line; pipesig(&status); /* set status to 1 on write to closed pipe */ sawdot = 0; status = 0; /* * add a 'From ' line as envelope */ nbytes = 0; nbytes += Bprint(pp->std[0]->fp, "From %s %s remote from \n", s_to_c(senders.first->p), thedate()); /* * add our own Received: stamp */ nbytes += Bprint(pp->std[0]->fp, "Received: from %s ", him); if(nci->rsys) nbytes += Bprint(pp->std[0]->fp, "([%s]) ", nci->rsys); nbytes += Bprint(pp->std[0]->fp, "by %s; %s\n", me, thedate()); /* * read first 16k obeying '.' escape. we're assuming * the header will all be there. */ line = s_new(); hdr = s_new(); while(sawdot == 0 && s_len(hdr) < 16*1024){ n = getcrnl(s_reset(line), &bin); /* eof or error ends the message */ if(n <= 0) break; /* a line with only a '.' ends the message */ cp = s_to_c(line); if(n == 2 && *cp == '.' && *(cp+1) == '\n'){ sawdot = 1; break; } s_append(hdr, *cp == '.' ? cp+1 : cp); } /* * parse header */ yyinit(s_to_c(hdr), s_len(hdr)); yyparse(); /* * Look for masquerades. Let Sender: trump From: to allow mailing list * forwarded messages. */ if(fflag) nbytes += forgedheaderwarnings(); /* * add an orginator and/or destination if either is missing */ if(originator == 0){ if(senders.last == nil || senders.last->p == nil) nbytes += Bprint(pp->std[0]->fp, "From: /dev/null@%s\n", him); else nbytes += Bprint(pp->std[0]->fp, "From: %s\n", s_to_c(senders.last->p)); } if(destination == 0){ nbytes += Bprint(pp->std[0]->fp, "To: "); for(l = rcvers.first; l; l = l->next){ if(l != rcvers.first) nbytes += Bprint(pp->std[0]->fp, ", "); nbytes += Bprint(pp->std[0]->fp, "%s", s_to_c(l->p)); } nbytes += Bprint(pp->std[0]->fp, "\n"); } /* * add sender's domain to any domainless addresses * (to avoid forging local addresses) */ cp = s_to_c(hdr); for(f = firstfield; cp != nil && f; f = f->next){ for(p = f->node; cp != 0 && p; p = p->next) { bpr = 0; cp = bprintnode(pp->std[0]->fp, p, &bpr); nbytes += bpr; } if(status == 0 && Bprint(pp->std[0]->fp, "\n") < 0){ piperror = "write error"; status = 1; } nbytes++; /* for newline */ } if(cp == nil){ piperror = "sender domain"; status = 1; } /* write anything we read following the header */ nonhdr = s_to_c(hdr) + s_len(hdr) - cp; if(status == 0 && Bwrite(pp->std[0]->fp, cp, nonhdr) < 0){ piperror = "write error 2"; status = 1; } nbytes += nonhdr; s_free(hdr); /* * pass rest of message to mailer. take care of '.' * escapes. */ while(sawdot == 0){ n = getcrnl(s_reset(line), &bin); /* eof or error ends the message */ if(n <= 0) break; /* a line with only a '.' ends the message */ cp = s_to_c(line); if(n == 2 && *cp == '.' && *(cp+1) == '\n'){ sawdot = 1; break; } if(cp[0] == '.'){ cp++; n--; } nbytes += n; if(status == 0 && Bwrite(pp->std[0]->fp, cp, n) < 0){ piperror = "write error 3"; status = 1; } } s_free(line); if(sawdot == 0){ /* message did not terminate normally */ snprint(pipbuf, sizeof pipbuf, "network eof: %r"); piperror = pipbuf; if (pp->pid > 0) { syskillpg(pp->pid); /* none can't syskillpg, so try a variant */ sleep(500); syskill(pp->pid); } status = 1; } if(status == 0 && Bflush(pp->std[0]->fp) < 0){ piperror = "write error 4"; status = 1; } if (debug) { stamp(); fprint(2, "at end of message; %s .\n", (sawdot? "saw": "didn't see")); } stream_free(pp->std[0]); pp->std[0] = 0; *byteswritten = nbytes; pipesigoff(); if(status && !piperror) piperror = "write on closed pipe"; return status; }
void main(int argc, char **argv) { String *msg; String *firstline; char *listname, *alfile; Waitmsg *w; int fd; char *replytoname = nil; ARGBEGIN{ case 'r': replytoname = ARGF(); break; }ARGEND; rfork(RFENVG|RFREND); if(argc < 2) usage(); alfile = argv[0]; listname = argv[1]; if(replytoname == nil) replytoname = listname; readaddrs(alfile); if(Binit(&in, 0, OREAD) < 0) sysfatal("opening input: %r"); msg = s_new(); firstline = s_new(); /* discard the 'From ' line */ if(s_read_line(&in, firstline) == nil) sysfatal("reading input: %r"); /* read up to the first 128k of the message. more is ridiculous. Not if word documents are distributed. Upped it to 2MB (pb) */ if(s_read(&in, msg, 2*1024*1024) <= 0) sysfatal("reading input: %r"); /* parse the header */ yyinit(s_to_c(msg), s_len(msg)); yyparse(); /* get the sender */ getaddrs(); if(from == nil) from = sender; if(from == nil) sysfatal("message must contain From: or Sender:"); if(strcmp(listname, s_to_c(from)) == 0) sysfatal("can't remail messages from myself"); addaddr(s_to_c(from)); /* start the mailer up and return a pipe to it */ fd = startmailer(listname); /* send message adding our own reply-to and precedence */ printmsg(fd, msg, replytoname, listname); close(fd); /* wait for mailer to end */ while(w = wait()){ if(w->msg != nil && w->msg[0]) sysfatal("%s", w->msg); free(w); } /* if the mailbox exists, cat the mail to the end of it */ appendtoarchive(listname, firstline, msg); exits(0); }
int main(int argc, char **argv){ int i; char *p; GC_INIT(); ::cgc1::cgc_root_t hash_bucket_root(hash_buckets); hash_buckets=reinterpret_cast<node*>(::cgc1::cgc_malloc(sizeof(node)*7313)); progname = BaseName(argv[0]); yyinit(); for (p=argv[0]; *p; p++) if (*p=='/') progname = p+1; for (i=1; i<argc; i++) { if (EQUAL == strcmp(argv[i],"--help")) { usage(); exit(0); } if (EQUAL == strcmp(argv[i],"-dep")) { stop_after_dep = TRUE; continue; } if (EQUAL == strcmp(argv[i],"-cxx")) { do_cxx = TRUE; continue; } if (EQUAL == strcmp(argv[i],"-noline")) { noline = TRUE; continue; } if (EQUAL == strcmp(argv[i],"-pthreadlocal")) { pthreadThreadLocal=TRUE; compilerThreadLocal=FALSE; continue; } if (EQUAL == strcmp(argv[i],"-typecodes")) { printtypecodes(); return 0; } if (EQUAL == strcmp(argv[i],"-noarraychks")) { arraychks = FALSE; continue; } if (EQUAL == strcmp(argv[i],"-nocasechks")) { casechks = FALSE; continue; } if (EQUAL == strcmp(argv[i],"-nomacros")) { nomacros = TRUE; continue; } if (EQUAL == strcmp(argv[i],"-O")) { arraychks = FALSE; casechks = FALSE; continue; } if (EQUAL == strcmp(argv[i],"-tabwidth")) { i++; if (i < argc) tabwidth = atoi(argv[i]); continue; } if (EQUAL == strcmp(argv[i],"-yydebug")) { yydebug = 1; continue; } if (EQUAL == strcmp(argv[i],"-debug")) { debug = TRUE; continue; } if (EQUAL == strcmp(argv[i],"-v")) { puts(Version); puts(Copyright); continue; } if ('-' == argv[i][0] && 'I' == argv[i][1]) { if (argv[i][2] == 0) { error("-I option: missing directory"); usage(); exit(1); } char buf[256]; strcpy(buf,sigpath); strcat(buf,":"); strcat(buf,argv[i]+2); sigpath = strperm(buf); continue; } if ('-' == argv[i][0]) { error("unrecognized option %s\n",argv[i]); usage(); exit(1); } if ( EQUAL == strcmp(".d",tail(argv[i])) || EQUAL == strcmp(".dd",tail(argv[i])) ) { node f; do_this_cxx = do_cxx || EQUAL == strcmp(".dd",tail(argv[i])); global_scope = new(struct SCOPE); readsetup(global_scope); targetname = newsuffixbase(argv[i],""); f = readfile(argv[i]); if (debug) { char *n = newsuffixbase(argv[i],".out"); if (NULL == freopen(n,"w", stdout)) { fatal("can't open file %s",n); } put("After parsing:\n"); pp(f); fflush(stdout); } outfilename = newsuffixbase(argv[i], do_this_cxx ? "-tmp.cc" : "-tmp.c"); { char *n = newsuffixbase(argv[i],".dep.tmp"); dependfile = fopen(n,"w"); if (dependfile == NULL) fatal("can't open file %s",n); } f = chkprogram(f); if (debug) { char *n = newsuffixbase(argv[i],".log"); if (NULL == freopen(n,"w", stdout)) { fatal("can't open file %s",n); } pprintl(f); } { node t = global_scope->signature; char *n = newsuffixbase(argv[i],".sig.tmp"); if (NULL == freopen(n,"w", stdout)) { fatal("can't open file %s",n); } printf("-- generated by %s\n\n",progname); while (t != NULL) { dprint(CAR(t)); put(";\n"); t = CDR(t); } } if (stop_after_dep) quit(); checkfordeferredsymbols(); if (debug) { char *n = newsuffixbase(argv[i],".sym"); if (NULL == freopen(n,"w", stdout)) { fatal("can't open file %s",n); } printsymboltable(); printtypelist(); printstringlist(); } if (n_errors > 0) { quit(); } if (TRUE) { char *n = newsuffixbase(argv[i],"-exports.h.tmp"); if (NULL == freopen(n,"w", stdout)) { fatal("can't open file %s",n); } printf("#ifndef %s_included\n",targetname); printf("#define %s_included\n",targetname); declarationsstrings = reverse(declarationsstrings); while (declarationsstrings) { node s = unpos(car(declarationsstrings)); assert(isstrconst(s)); put_unescape(s->body.string_const.characters); put("\n"); declarationsstrings = cdr(declarationsstrings); } put(declarations_header); /* printtypecodes(); */ cprinttypes(); put(declarations_trailer); put("#endif\n"); } if (TRUE) { if (NULL == freopen(outfilename,"w", stdout)) { fatal("can't open file %s",outfilename); } printf("#include \"%s\"\n",newsuffixbase(argv[i],"-exports.h")); put(code_header); headerstrings = reverse(headerstrings); while (headerstrings) { locn(car(headerstrings)); printpos(); node s = unpos(car(headerstrings)); assert(isstrconst(s)); put_unescape(s->body.string_const.characters); put("\n"); locn(NULL); headerstrings = cdr(headerstrings); } cprintsemi(f); } } else { fprintf(stderr,"unknown file type %s\n",argv[i]); usage(); exit(1); } } quit(); return 0; }
/* fix 822 addresses */ static void rfc822cruft(message *mp) { Field *f; Node *p; String *body, *s; char *cp; /* * parse headers in in-core part */ yyinit(s_to_c(mp->body), s_len(mp->body)); mp->rfc822headers = 0; yyparse(); mp->rfc822headers = 1; mp->received = received; /* * remove equivalent systems in all addresses */ body = s_new(); cp = s_to_c(mp->body); for(f = firstfield; f; f = f->next){ if(f->node->c == MIMEVERSION) mp->havemime = 1; if(f->node->c == FROM) mp->havefrom = getaddr(f->node); if(f->node->c == SENDER) mp->havesender = getaddr(f->node); if(f->node->c == REPLY_TO) mp->havereplyto = getaddr(f->node); if(f->node->c == TO) mp->haveto = 1; if(f->node->c == DATE) mp->havedate = 1; if(f->node->c == SUBJECT) mp->havesubject = getstring(f->node); if(f->node->c == PRECEDENCE && f->node->next && f->node->next->next){ s = f->node->next->next->s; if(s && (strcmp(s_to_c(s), "bulk") == 0 || strcmp(s_to_c(s), "Bulk") == 0)) mp->bulk = 1; } for(p = f->node; p; p = p->next){ if(p->s){ if(p->addr){ cp = skipequiv(s_to_c(p->s)); s_append(body, cp); } else s_append(body, s_to_c(p->s)); }else{ s_putc(body, p->c); s_terminate(body); } if(p->white) s_append(body, s_to_c(p->white)); cp = p->end+1; } s_append(body, "\n"); } if(*s_to_c(body) == 0){ s_free(body); return; } if(*cp != '\n') s_append(body, "\n"); s_memappend(body, cp, s_len(mp->body) - (cp - s_to_c(mp->body))); s_terminate(body); firstfield = 0; mp->size += s_len(body) - s_len(mp->body); s_free(mp->body); mp->body = body; }
void main(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) sysfatal("opening %s: %r", buf); } else { if(root == nil) root = ðer; fd = open(file, OREAD); if(fd < 0) sysfatal("opening %s: %r", file); } filter = compile(filter); if(tiflag){ /* read a trace file */ for(;;){ n = read(fd, pkt, 10); if(n != 10) break; pkttime = NetL(pkt+2); pkttime = (pkttime<<32) | NetL(pkt+6); if(starttime == 0LL) starttime = pkttime; n = NetS(pkt); if(readn(fd, pkt, n) != n) break; if(filterpkt(filter, pkt, pkt+n, root, 1)) if(toflag) tracepkt(pkt, n); else printpkt(buf, e, pkt, pkt+n); } } else { /* read a real time stream */ starttime = nsec(); for(;;){ n = root->framer(fd, pkt, Pktlen); if(n <= 0) break; pkttime = nsec(); if(filterpkt(filter, pkt, pkt+n, root, 1)) if(toflag) tracepkt(pkt, n); else printpkt(buf, e, pkt, pkt+n); } } }