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

📄 dvi2tty.c

📁 harvest是一个下载html网页得机器人
💻 C
📖 第 1 页 / 共 3 页
字号:
#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)        pager = FALSE;#endif    }    else {        output = stdout;#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)        if (pager && isatty(fileno(output))) {   /* try to pipe to a pager   */            if ((output = popen(path, "w")) == NULL) /* get pipe to pager    */                errorexit(pipcr);                /* make output to output    */        }        else            pager = FALSE;#endif    }    dvimain();#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)    if (pager)        pclose(output);                     /* close pipe to pager            */#endif    return(0);} /* main *//* * GETARGS -- Process options from command line and from environment. */void getargs(){    char *str, *envp;    bool DVIfound;                      /* if a dvi filename found           */#if !defined(THINK_C)    if (Argc <= 1)        usage(ign);#endif    pageswitchon = FALSE;       /* show all pages                            */    sequenceon   = FALSE;       /* selected pages are TeX-numbered           */    outputtofile = FALSE;       /* write to stdout                           */#if defined(THINK_C)    inputfromfile = FALSE;      /* read from stdin                           */#endif#if !defined(MSDOS) && !defined(VMS) && !defined (THINK_C) && !defined(AMIGA)    pager        = WANTPAGER;   /* want paging, compile time option          */#endif    accent       = TRUE;        /* show all accent etc. as extra char        */    ttfont       = FALSE;	/* assume tt font (verbatim mode)            */    noffd        = FALSE;       /* print formfeed between pages              */    scascii      = DEFSCAND;    /* scandinavian, compile time option         */    ttywidth     = 80;          /* default terminal width                    */    espace       = 0;           /* to fake ttywith calcs                     */    DVIfound     = FALSE;    printfont    = FALSE;       /* do not print font switches                */    allchar      = FALSE;       /* do not put out all characters             */#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)    if ((path = getenv("PAGER")) == NULL)   /* find default pathname of page */            path = DEFPAGER;             /* program in case paging is wanted */#endif    /*     *     * With VAX-C under VMS getenv normally searches the environment array     * looking for the variables HOME, TERM, PATH, and USER.  In certain     * situations getenv attempts to first perform a logical name translation     * if none of the environment array strings are matched and then trying     * to translate a CLI symbol.  Unfortunately we need a CLI symbol defined     * as;     *     *     dvi2tty :== $path:dvi2tty.exe     *     * to invoke dvi2tty with command line arguments as it would be invoked     * under Unix.  So we use the logical DVI$DVI2TYY as the environment     * variable from which options may be set.     *     */    /*     * First process environment variable.     */#if defined(VMS)    if ((envp = getenv("DVI$DVI2TTY")) != NULL) {#else    if ((envp = getenv("DVI2TTY")) != NULL) { /* } keep vi happy */#endif        while (*envp == ' ')             envp++;        while (*envp) {                     /* environment var args          */            if (strchr(OPTSET, optch = *envp++) != NULL) {                /*                 * we always pass one option, and arrange for optarg ourselfes,                 * so setoption does not mesh up Argv                 */                if (strchr(OPTWARG, optch) != NULL) {                    while (*envp == ' ')                        envp++;                    if (*envp == '\0')                        usage(noarg);                    str = envp;             /* str points to optarg          */                    while ((*envp != ' ') && (*envp != '\0'))                        envp++;             /* set envp just after optarg    */                    if (*envp != '\0')                        *envp++ = '\0';     /* end optarg string             */                }                else                    str = "";                setoption(str);            }            else                usage(bdopt);            while (*envp == ' ')                 envp++;        }    }    /*     * Now process command line options.     */    while (--Argc > 0) {                    /* command line args             */        str = *++Argv;        if (*str != '-') {                  /* argument is not an option     */            if (DVIfound)                   /* only one dvi file allowed     */                usage(onef);            getfname(str);#if defined(THINK_C)            inputfromfile =#endif            DVIfound = TRUE;        }        else if (strchr(OPTSET, optch = *++str) != NULL) {            str++;                      /* point to rest of argument if any  */            if ((strchr(OPTWARG, optch) != NULL) && (*str == '\0')) {                if (--Argc <= 0)                    usage(noarg);                str = *++Argv;            }            setoption(str);        }        else            usage(bdopt);    }    if (!DVIfound)#if defined(THINK_C)                             /* Allow use of stdin for   */        if (isatty(fileno(stdin)))            usage(nored);                        /*   Mac, if redirected     */#else        usage(ign);#endif    return;} /* getargs *//* * SETOPTION -- Process an option. */void setoption(char *optarg){    int j = 0;    while (strchr(OPTSET, optch) != NULL) {        switch (optch) {	    case 'h' : usage(ign); break;#if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)	    case 'q' : pager = FALSE; break;	    case 'f' : pager = TRUE; break;            case 'F' : pager = TRUE;                       path = optarg;                       j = strlen(optarg);                       break;#endif            case 'J' : japan   = TRUE; break;            case 't' : ttfont  = TRUE; break;	    case 'l' : noffd   = TRUE; break;	    case 's' : scascii = TRUE; break;	    case 'u' : scascii = FALSE; break;	    case 'a' : accent  = FALSE; break;	    case 'c' : allchar = TRUE; break;            case 'P' : sequenceon = TRUE;     /* fall through */            case 'p' : if (pageswitchon)                           usage(onepp);                       getpages(j, optarg);                       break;            case 'w' : if (getinteger(&ttywidth, &j, optarg))                           usage(nan);                       if (optarg[j] != '\0')                           usage(gae);                       if ((ttywidth < 16) || (ttywidth > MAXTERMWIDTH))                           usage(wrnge);                       break;            case 'e' : if (getinteger(&espace, &j, optarg))                           usage(nan);                       if (optarg[j] != '\0')                           usage(gae);                       break;            case 'v' : if (getlong(&lineheight, &j, optarg))                           usage(nan);                       if (optarg[j] != '\0')                           usage(gae);                       /* lineheight *= 65536L; */                          /* want to specify in pt, but have no getfloat */                       break;            case 'o' : OUTfilename = optarg;		       outputtofile = TRUE;                       j = strlen(optarg);                       break;            case 'b' : printfont = TRUE;                       delim = optarg;                       if (!strlen(optarg))                           printfont = FALSE;                       break;            default  : usage(bdopt);        }        if ((optch = optarg[j++]) == '\0')            break;        if ( (optarg[j] == '\0') && (strchr(OPTWARG, optch) != NULL) ) {                if (--Argc <= 0)                    usage(noarg);                optarg = *++Argv;                j = 0;            }    }    return;} /* setoption *//* * GETPAGES -- Getr a list of pages to print. */void getpages(int j, char *str){    int i, c;    int num;    pageswitchon = TRUE;    firstpage = (printlisttype *) malloc(sizeof(printlisttype));    firstpage->all = FALSE;    firstpage->nxt = nil;    firstpage->pag = 0;    lastpage = firstpage;    currentpage = firstpage;    if (getinteger(&num, &j, str))        usage(nan);    plcnxt((int) num);    while (str[j]) {        c = str[j];        if (c == ',' || c == ':') {            j++;            if (getinteger(&num, &j, str))                usage(nan);        }        else            break;        if (c == ',')            plcnxt(num);        else {            if (currentpage->pag < 0) {                if (num > 0) {                    currentpage->all = TRUE;                    plcnxt(num);                }                else if (num < currentpage->pag)                    for (i = currentpage->pag - 1; i >= num; i--)                        plcnxt(i);                else                    usage(bdlst);            }            else {                if (num < currentpage->pag)                    usage(bdlst);                for (i = currentpage->pag + 1; i <= num; i++)                    plcnxt(i);            }        }    }    if ((str[j] != ' ') && (str[j] != '\0')) {        usage(gae);    }    currentpage = firstpage;    return;

⌨️ 快捷键说明

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