⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traceset.c

📁 harvest是一个下载html网页得机器人
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "sgmlincl.h"         /* #INCLUDE statements for SGML parser. */#ifdef TRACE#include "context.h"/* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ */#define STATUX tags[ts].status/* Trace variables.*/int  trace = 0;               /* Switch: 1=trace state transitions; 0=don't. */int atrace = 0;               /* Switch: 1=trace attribute activity; 0=don't. */int ctrace = 0;               /* Switch: 1=trace context checking; 0=don't. */int dtrace = 0;               /* Switch: 1=trace declaration parsing; 0=don't.*/int etrace = 0;               /* Switch: 1=trace entity activity; 0=don't.*/int gtrace = 0;               /* Switch: 1=trace group creations; 0=don't. */int itrace = 0;               /* Switch: 1=trace ID activity; 0=don't. */int mtrace = 0;               /* Switch: 1=trace MS activity; 0=don't. */int ntrace = 0;               /* Switch: 1=trace notation activity; 0=don't. */char emd[] = "EMD";           /* For "EMD" parameter type in dtrace calls. *//* Return a printable representation of c.*/staticchar *printable(c)int c;{     static char buf[5];     if (c >= 040 && c < 0177) {	  buf[0] = c;	  buf[1] = '\0';     }     else	  sprintf(buf, "\\%03o", (UNCH)c);     return buf;}staticVOID dotrace(s)char *s;{     trace = (s && strchr(s, 't') != 0);     atrace = (s && strchr(s, 'a') != 0);     ctrace = (s && strchr(s, 'c') != 0);     dtrace = (s && strchr(s, 'd') != 0);     etrace = (s && strchr(s, 'e') != 0);     gtrace = (s && strchr(s, 'g') != 0);     itrace = (s && strchr(s, 'i') != 0);     mtrace = (s && strchr(s, 'm') != 0);     ntrace = (s && strchr(s, 'n') != 0);}/* TRACESET: Set switches for tracing body of document.*/VOID traceset(){     dotrace(sw.trace);          if (trace||atrace||ctrace||dtrace||etrace||gtrace||itrace||mtrace||ntrace)          fprintf(stderr,"TRACESET: state=%d;att=%d;con=%d;dcl=%d;ent=%d;grp=%d;id=%d;ms=%d;dcn=%d.\n",		  trace, atrace, ctrace, dtrace, etrace, gtrace, itrace,		  mtrace, ntrace);}/* TRACEPRO: Set switches for tracing prolog. */VOID tracepro(){     dotrace(sw.ptrace);          if (trace||atrace||dtrace||etrace||gtrace||mtrace||ntrace)	  fprintf(stderr,		  "TRACEPRO: state=%d; att=%d; dcl=%d; ent=%d; grp=%d; ms=%d; dcn=%d.\n",		  trace, atrace, dtrace, etrace, gtrace, mtrace, ntrace);}/* TRACEPCB: Trace character just parsed and other pcb data. */VOID tracepcb(pcb)struct parse *pcb;{     fprintf(stderr, "%-8s %2u-%2u-%2u-%2u from %s [%3d] in %s, %lu:%d.\n",	     pcb->pname, pcb->state, pcb->input, pcb->action,	     pcb->newstate, printable(*FPOS), *FPOS, ENTITY+1, RCNT,	     RSCC+FPOS+1-FBUF);}/* TRACETKN: Trace character just read during token parse. */VOID tracetkn(scope, lextoke)int scope;UNCH lextoke[];               /* Lexical table for token and name parses. */{     fprintf(stderr, "TOKEN    %2d-%2d       from %s [%3d] in %s, %lu:%d.\n",	     scope, lextoke[*FPOS],	     printable(*FPOS), *FPOS, ENTITY+1, RCNT,	     RSCC+FPOS+1-FBUF);}/* TRACEGML: Trace state of main SGML driver routine. */VOID tracegml(scb, pss, conactsw, conact)struct restate *scb;int pss, conactsw, conact;{     fprintf(stderr,	     "SGML%02d   %2d-%2d-%2d-%2d in main driver; conactsw=%d; conact=%d.\n",	     pss, scb[pss].sstate, scb[pss].sinput, scb[pss].saction,	     scb[pss].snext, conactsw, conact);}/* TRACEVAL: Trace parse of an attribute value that is a token list. */VOID traceval(pcb, atype, aval, tokencnt)struct parse *pcb;UNS atype;                    /* Type of token list expected. */UNCH *aval;                   /* Value string to be parsed as token list. */int tokencnt;                 /* Number of tokens found in attribute value. */{     fprintf(stderr,	     "%-8s %2d-%2d-%2d-%2d at %p, atype=%02x, tokencnt=%d: ",	     pcb->pname, pcb->state, pcb->input, pcb->action,	     pcb->newstate, (UNIV)aval, atype, tokencnt);     fprintf(stderr, "%s\n", aval);}/* TRACESTK: Trace entry just placed on tag stack. */VOID tracestk(pts, ts2, etictr)struct tag *pts;              /* Stack entry for this tag. */int ts2;                      /* Stack depth. */int etictr;                   /* Number of "netok" tags on stack. */{     fprintf(stderr,	     "STACK    %s begun; stack depth %d; tflag=%02x; etictr=%d",	     pts->tetd->etdgi+1, ts2, pts->tflags, etictr);     fprintf(stderr, " srm=%s.\n",	     pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY");}/* TRACEDSK: Trace entry just removed from tag stack. */VOID tracedsk(pts, ptso, ts3, etictr)struct tag *pts;              /* Stack entry for new open tag. */struct tag *ptso;             /* Stack entry for tag just ended. */int ts3;                      /* Stack depth. */int etictr;                   /* Number of "netok" tags on stack. */{     fprintf(stderr,	     "DESTACK  %s ended; otflag=%02x; %s resumed; depth=%d; tflag=%02x; etictr=%d",	     ptso->tetd->etdgi+1, ptso->tflags,	     pts->tetd->etdgi+1, ts3, pts->tflags, etictr);     fprintf(stderr, " srm=%s.\n",	     pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY");}/* TRACECON: Trace interactions between content parse and stag/context   processing.   */VOID tracecon(etagimct, dostag, datarc, pcb, conrefsw, didreq)int etagimct;                 /* Implicitly ended elements left on stack. */int dostag;                   /* 1=retry newetd instead of parsing; 0=parse. */int datarc;                   /* Return code for data: DAF_ or REF_ or zero. */struct parse *pcb;            /* Parse control block for this parse. */int conrefsw;                 /* 1=content reference att specified; 0=no. */int didreq;                   /* 1=required implied empty tag processed; 0=no.*/{     fprintf(stderr,	     "CONTENT  etagimct=%d dostag=%d datarc=%d pname=%s action=%d \conrefsw=%d didreq=%d\n",	     etagimct, dostag, datarc, pcb->pname, pcb->action,	     conrefsw, didreq);}/* TRACESTG: Trace start-tag context validation input and results. */VOID tracestg(curetd, dataret, rc, nextetd, mexts)struct etd *curetd;           /* The etd for this tag. */int dataret;                  /* Data pending: DAF_ REF_ 0=not #PCDATA. */int rc;                       /* Return code from context or other test. */struct etd *nextetd;          /* The etd for a forced start-tag (if rc==2). */int mexts;                    /* >0=stack level of minus grp; -1=plus; 0=none.*/{     fprintf(stderr,	     "STARTTAG newetd=%p; dataret=%d; rc=%d; nextetd=%p; mexts=%d.\n",	     (UNIV)curetd, dataret, rc, (UNIV)nextetd, mexts);}/* TRACEETG: Trace end-tag matching test on stack. */VOID traceetg(pts, curetd, tsl, etagimct)struct tag *pts;              /* Stack entry for this tag. */struct etd *curetd;           /* The etd for this tag. */int tsl;                      /* Temporary stack level for looping. */int etagimct;                 /* Num of implicitly ended tags left on stack. */{     fprintf(stderr,	     "ENDTAG   tsl=%d; newetd=%p; stacketd=%p; tflags=%02x; etagimct=%d.\n",	     tsl, (UNIV)curetd, (UNIV)pts->tetd, pts->tflags, etagimct);}/* TRACEECB: Trace entity control block activity. */VOID traceecb(action, p)char *action;struct entity *p;{     static char estype1[] = " TMMMSEIXCNFPDLK";     static char estype2[] = "  DS            ";     if (!p)	  return;     fprintf(stderr,	     "%-8s (es=%d) type %c%c entity %s at %p containing ",	     action, es, estype1[p->estore], estype2[p->estore], p->ename+1,	     (UNIV)p);     if (p->estore==ESN && strcmp(action, "ENTDEF"))	  traceesn(p->etx.n);     else if (p->etx.x==0)	  fprintf(stderr, "[NOTHING]");     else	  fprintf(stderr, "%s",		  p->etx.c[0] ? (char *)p->etx.c : "[EMPTY]");     putc('\n', stderr);}/* TRACEDCN: Trace data content notation activity. */VOID tracedcn(p)struct dcncb *p;{     fprintf(stderr, 	    "DCN      dcn=%p; adl=%p; notation is %s\n",	     (UNIV)p, (UNIV)p->adl, p->ename+1);     if (p->adl)	  traceadl(p->adl);}/* TRACEESN: Print a data entity control block. */VOID traceesn(p)PNE p;{     fprintf(stderr, "ESN      Entity name is %s; entity type is %s.\n",            (NEENAME(p)!=0) ? ((char *)NEENAME(p))+1 : "[UNDEFINED]",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -