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

📄 dvistuff.c

📁 harvest是一个下载html网页得机器人
💻 C
📖 第 1 页 / 共 3 页
字号:
    while ((opcode = (int) get1()) != EOP) {        if (opcode > POST_POST)            errorexit(illop);        else            switch (opcode) {                case SET1     :                case PUT1     :                case RIGHT1   :                case W1       :                case X1       :                case DOWN1    :                case Y1       :                case Z1       : /* assume FNT change can also be skipped */                case FNT1     : mseek(DVIfile, 1L, relative); break;                case SET2     :                case PUT2     :                case RIGHT2   :                case W2       :                case X2       :                case DOWN2    :                case Y2       :                case Z2       :                case FNT2     : mseek(DVIfile, 2L, relative); break;                case SET3     :                case PUT3     :                case RIGHT3   :                case W3       :                case X3       :                case DOWN3    :                case Y3       :                case Z3       :                case FNT3     : mseek(DVIfile, 3L, relative); break;                case SET4     :                case PUT4     :                case RIGHT4   :                case W4       :                case X4       :                case DOWN4    :                case Y4       :                case Z4       :                case FNT4     : mseek(DVIfile, 4L, relative); break;                case SET_RULE :                case PUT_RULE : mseek(DVIfile, 8L, relative); break;                case BOP      : errorexit(bdbop); break;                case XXX1     : mseek(DVIfile, get1(), relative); break;                case XXX2     : mseek(DVIfile, get2(), relative); break;                case XXX3     : mseek(DVIfile, get3(), relative); break;                case XXX4     : mseek(DVIfile, get4(), relative); break;                case FNT_DEF1 :                case FNT_DEF2 :                case FNT_DEF3 :                case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1); break;                case PRE      : errorexit(bdpre); break;                case POST     : errorexit(bdpst); break;                case POST_POST: errorexit(bdpp); break;        }    }    return;} /* skippage *//* * PRINTPAGE -- 'end of page', writes lines of page to output file */void printpage(void){    register int  i, j;    register char ch;    if (sptr != 0)        fprintf(stderr, "dvi2tty: warning - stack not empty at eop.\n");    for (currentline = firstline; currentline != nil;          currentline = currentline->next) {        if (currentline != firstline) {            foo = ((currentline->vv - currentline->prev->vv)/lineheight)-1;            foo &= 3;            /* linespacings not too large */            for (i = 1; i <= (int) foo; i++)                putc('\n', output);        }        if (currentline->charactercount >= leftmargin) {            foo = ttywidth - 2;            for (i = firstcolumn, j = 1; i <= currentline->charactercount;                   i++, j++) {                ch = currentline->text[i - leftmargin];                if (ch >= SPACE || allchar)                    putc(ch, output);                if ((j > (int) foo) && (currentline->charactercount > i+1)) {                        fprintf(output, "*\n");         /* if line to large */                        fprintf(output, " *");          /* mark output      */                        j = 2;                }            }        }        putc('\n', output);    }    currentline = firstline;    while (currentline->next != nil) {        currentline = currentline->next;        free(currentline->prev);    }    free(currentline);              /* free last line */    currentline = nil;    return;} /* printpage *//* * INLIST -- return true if pagenr is in the list of pages to be printed. */bool inlist(long pagenr){    while ((currentpage->pag < 0) && (currentpage->pag != pagenr) &&           !currentpage->all && (currentpage->nxt != nil))        currentpage = currentpage->nxt;    if ((currentpage->all && (pagenr < currentpage->pag)) ||         (currentpage->pag == pagenr))            return TRUE;    else if (pagenr > 0) {        while ((currentpage->pag < pagenr) && (currentpage->nxt != nil))            currentpage = currentpage->nxt;        if (currentpage->pag == pagenr)            return TRUE;    }    return FALSE;} /* inlist *//* * RULE -- Output a rule (vertical or horizontal). *         Increment h if moving is true. */void rule(bool moving, long rulewt, long ruleht){    register char ch;               /* character to set rule with            */    register long saveh, savev;                              /* rule   --   starts up the recursive routine */    if (!moving)        saveh = h;    if ((ruleht <= 0) || (rulewt <= 0))        h += rulewt;    else {        savev = v;        if ((ruleht / rulewt) > 0)         /* value < 1 truncates to 0 */            ch = '|';        else if (ruleht > (lineheight / 2))            ch = '=';        else            ch = '_';        ruleaux(rulewt, ruleht, ch);        v = savev;    }    if (!moving)        h = saveh;    return;} /* rule *//* * RULEAUX -- do the actual outtput for the rule recursively. */void ruleaux(long rulewt, long ruleht, char ch){    register long wt, lmh, rmh;    wt = rulewt;    lmh = h;                        /* save left margin                      */    if (h < 0) {                    /* let rules that start at negative h    */        wt -= h;                    /* start at coordinate 0, but let it     */        h = 0;                      /*   have the right length               */    }    while (wt > 0) {                /* output the part of the rule that      */        rmh = h;                    /*   goes on this line                   */        outchar(ch);        wt -= (h-rmh);              /* decrease the width left on line       */    }    ruleht -= lineheight;      /* decrease the height                   */    if (ruleht > lineheight) { /* still more vertical?                  */        rmh = h;                    /* save current h (right margin)         */        h = lmh;                    /* restore left margin                   */        v -= (lineheight + lineheight / 10);        ruleaux(rulewt, ruleht, ch);        h = rmh;                    /* restore right margin                  */    }    return;} /* ruleaux *//* * HORIZONTALMOVE -- Move the h pointer by amount. */long horizontalmove(long amount){#if defined(MSDOS) || defined(THINK_C)    if (labs(amount) > charwidth / 4L) {    /* } to make vi happy */#else    if (abs(amount) > charwidth / 4L) {#endif        foo = 3*charwidth / 4;        if (amount > 0)            amount = ((amount+foo) / charwidth) * charwidth;        else#if defined(VMS)            amount = (ROUND( (float) (amount-foo) / charwidth) + 1)* charwidth;#else            amount = ((amount-foo) / charwidth) * charwidth;#endif        h += amount;        return amount;    }    else        return 0;}   /* horizontalmove *//* * SKIPNOPS -- Return first non NOP opcode. */int skipnops(void){    register int opcode;    while ((opcode = (int) num(1)) == NOP);    return opcode;} /* skipnops *//* * GETLINE -- Returns an initialized line-object */linetype *getline(void){    register int  i;    register linetype *temp;    if ((temp = (linetype *) malloc(sizeof(linetype))) == NULL)        errorexit(lnerq);    temp->charactercount = leftmargin - 1;    temp->prev = nil;    temp->next = nil;    for (i = 0; i < LINELEN; i++)        temp->text[i] = ' ';    temp->text[i] = '\0';    return temp;} /* getline *//* * FINDLINE -- Find best fit line were text should go *             and generate new line if needed. */linetype *findline(void){    register linetype *temp;    register long topd, botd;    if (v <= firstline->vv) {                      /* above first line */        if (firstline->vv - v > lineheight) {            temp = getline();            temp->next = firstline;            firstline->prev = temp;            temp->vv = v;            firstline = temp;        }        return firstline;    }    if (v >= lastline->vv) {                       /* below last line */        if (v - lastline->vv > lineheight) {            temp = getline();            temp->prev = lastline;            lastline->next = temp;            temp->vv = v;            lastline = temp;        }        return lastline;    }    temp = lastline;                               /* in between two lines */    while ((temp->vv > v) && (temp != firstline))        temp = temp->prev;    /* temp->vv < v < temp->next->vv --- temp is above, temp->next is below */    topd = v - temp->vv;    botd = temp->next->vv - v;    if ((topd < lineheight) || (botd < lineheight)) {        if (topd < botd)                           /* take best fit */            return temp;        else            return temp->next;    }    /* no line fits suitable, generate a new one */    currentline = getline();    currentline->next = temp->next;    currentline->prev = temp;    temp->next->prev = currentline;    temp->next = currentline;    currentline->vv = v;    return currentline;} /* findline *//* * NUM -- */unsigned long num(int size){    register int i;    register unsigned long x = 0;    for (i = size; i > 0; i--)        x = (x << 8) + (unsigned) getc(DVIfile);    return x;} /* num *//* * SNUM -- */long snum(int size){    register int i;    register long x;    x = getc(DVIfile);    if (x & 0x80)        x -= 0x100;    for (i = size - 1; i > 0; i--)        x = (x << 8) + (unsigned) getc(DVIfile);    return x;} /* snum *//* * DOCHAR -- Process a character opcode. */void dochar(char ch){    if (japan && jfontnum)        jischar((long) ch);    else if (symbolfont == TRUE)        symchar(ch);    else        normchar(ch);    return;} /* dochar *//* * SYMCHAR -- Process a character opcode for a symbol font. */void symchar(char ch){    switch (ch) {       /* can do a lot more on MSDOS machines ... */       case   0: ch = '-'; break;       case   1: ch = '.'; break;       case   2: ch = 'x'; break;       case   3: ch = '*'; break;       case  13: ch = 'O'; break;       case  14: ch = 'O'; break;       case  15: ch = 'o'; break;       case  24: ch = '~'; break;       case  32: ch = japan ? '<' : 32; break; /* really only for japan? */       case  33: ch = japan ? '>' : 33; break; /* really only for japan? */       case 102: ch = '{'; break;       case 103: ch = '}'; break;       case 104: ch = '<'; break;       case 105: ch = '>'; break;       case 106: ch = '|'; break;       case 110: ch = '\\'; break;    }    outchar(ch);    return;} /* symchar *//* * NORMCHAR -- Process a character opcode for a normal font. */void normchar(char ch){    switch (ch) {        case 11  :  if (ttfont)                        ch = '^';                   /* up symbol       */                    else if (!allchar) {                        outchar('f'); ch = 'f';     /* ligature        */                    }                    break;        case 12  :  if (ttfont)                        ch = 'v';                   /* low symbol       */                    else if (!allchar) {                        outchar('f'); ch = 'i';     /* ligature        */                    }                    break;        case 13  :  if (ttfont)                        ch = '`';                    else if (!allchar) {                        outchar('f'); ch = 'l';     /* ligature        */                    }                    break;        case 14  :  if (ttfont)                        ch = 'i';                   /* spanish !        */                    else if (!allchar) {                        outchar('f'); outchar('f');                                  ch = 'i';         /* ligature        */                    }                    break;        case 15  :  if (ttfont)                        ch = '.';                   /* spanish ?        */                    else if (!allchar) {                        outchar('f'); outchar('f');                                  ch = 'l';         /* ligature        */                    }                    break;        case 16  :  if (!allchar) ch = 'i'; break;        case 17  :  if (!allchar) ch = 'j'; break;        case 25  :  if (!allchar) {                        outchar('s');                        ch = 's';                    }                    break;  /* German double s */        case 26  :  if (!allchar) {                        outchar('a');                        ch = 'e';                    }                    break;  /* Dane/Norw ae    */        case 27  :  if (!allchar) {                        outchar('o');                        ch = 'e';                    }                    break;  /* Dane/Norw oe    */        case 28  :  if (!allchar) {                        if (scascii)                            ch = '|';                   /* Dane/Norw /o    */                        else                            ch = 'o';                    }                    break;        case 29  :  if (!allchar) {                        outchar('A');                        ch = 'E';                    }                    break;  /* Dane/Norw AE    */

⌨️ 快捷键说明

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