亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? webserve.c

?? 嵌入式TCPIP協(xié)議棧的源代碼!
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
        ok = 0;
    else if (conn == TCP_OPEN)
    {
        adp->in = 0;
    }
    else if (conn == TCP_DATA)
    {
        if ((len = buff_chrlen(&ts->rxb, '\n'))!=0) /* Got request? */
        {
            len = mini(len+1, HTTP_MAXLEN);         /* Truncate length */
            buff_out(&ts->rxb, (BYTE *)httpreq, (WORD)len);
            httpreq[len] = 0;
            if (webdebug)                           /* Display if debugging */
                printf("%s", httpreq);
            s = strtok(httpreq, " ");               /* Chop into tokens */
            if (!strcmp(s, "GET"))                  /* 1st token is 'GET'? */
            {
                name = strtok(0, " ?\r\n");         /* 2nd token is filename */
                http_get(ts, name);                 /* Process filename */
            }
        }
    }
    http_data(ts);
    return(ok);
}

/* Process the filepath from an HTTP 'get' method */
void http_get(TSOCK *ts, char *fname)
{
    APPDATA *adp;
    char *s=0;

    adp = (APPDATA *)ts->app;
    strcpy(filepath, filedir);          /* Add on base directory */
    if (*fname)                         /* Copy filename without leading '/' */
        strcat(filepath, fname+1);      
    strlwr(filepath);                   /* Force to lower-case */
    if (strlen(fname) <= 1)
    {                                   /* If name is only a '/'.. */
        if (webdebug)                   /* Display if debugging */
            printf("Sending directory\n", filepath);
        strcpy(filepath, filedir);
        strcat(filepath, "*.*");        /* ..display directory */
#if HTML_DIR == 3
        dir_head(&ts->txb, filedir);    /* Send out directory */
        adp->count = 1;
#elif HTML_DIR > 0
        dir_head(&ts->txb, filedir);    /* Send out directory */
        if ((s = find_first(filepath)) != 0) do {
            dir_entry(&ts->txb, s);
        } while ((s = find_next()) != 0);
        dir_tail(&ts->txb);
        close_tcp(ts);
#else
        buff_instr(&ts->txb, HTTP_OK HTTP_TXT HTTP_BLANK);
        buff_instr(&ts->txb, "Directory\r\n");
        if ((s = find_first(filepath)) != 0) do {
            buff_instr(&ts->txb, s);    /* One file per line */
            buff_instr(&ts->txb, "\r\n");
        } while ((s = find_next()) != 0);
        close_tcp(ts);
#endif
    }                                   /* If file not found.. */
    else if ((adp->in = fopen(filepath, "rb")) == 0)
    {                                   /* ..send message */
        if (webdebug)                   /* Display if debugging */
            printf("File '%s' not found\n", filepath);
        buff_instr(&ts->txb, HTTP_NOFILE HTTP_TXT HTTP_BLANK);
        buff_inprintf(&ts->txb, "Webserve v%s\r\n", VERSION);
        buff_inprintf(&ts->txb, "Can't find '%s'\r\n", filepath);
        close_tcp(ts);
    }
    else                                /* File found OK */
    {
#if HTTP_HEAD == 0
                                                    /* No HTTP header or.. */
#elif HTTP_HEAD == 1                                /* Simple OK header or.. */
        buff_instr(&ts->txb, HTTP_OK HTTP_BLANK);
#else                                               /* Content-type header */
        buff_instr(&ts->txb, HTTP_OK);
        s = strstr(filepath, ".htm") ? HTTP_HTM :
            strstr(filepath, ".txt") ? HTTP_TXT :
            strstr(filepath, ".gif") ? HTTP_GIF :
            strstr(filepath, ".xbm") ? HTTP_XBM : "";
        buff_instr(&ts->txb, s);
        buff_instr(&ts->txb, HTTP_BLANK);
#endif
        if (webdebug)                   /* Display if debugging */
            printf("File '%s' %s", filepath, *s ? s : "\n");
    }
}

/* If there is space in the transmit buffer, send HTTP data */
void http_data(TSOCK *ts)
{
    APPDATA *adp;
    int count=0, ok, len;
    char *s;

    adp = (APPDATA *)ts->app;
    if (adp->count)                     /* If sending a directory.. */
    {                                   /* Skip filenames already sent */
        ok = (s = find_first(filepath)) != 0;
        while (ok && ++count<adp->count)
            ok = (s = find_next()) != 0;
        while (ok && dir_entry(&ts->txb, s))
        {                               /* Send as many entries as will fit */
            adp->count++;
            ok = (s = find_next()) != 0;
        }
        if (!ok && dir_tail(&ts->txb))  /* If no more entries.. */
        {
            adp->count = 0;             /* ..start closing connection */
            close_tcp(ts);
        }
    }                                   /* If sending a file.. */
    if (adp->in && (len = buff_freelen(&ts->txb)) > 0)
    {                                   /* ..put out as much as possible */
        if ((len = buff_infile(&ts->txb, adp->in, (WORD)len)) == 0)
        {                               /* If end of file, close it.. */
            fclose(adp->in);
            adp->in = 0;
            close_tcp(ts);              /* ..and start closing connection */
        }
    }
}

/* Write out head of HTML file dir, given filepath. Return 0 if error */
int dir_head(CBUFF *bp, char *path)
{
#if HTML_DIR > 1
    return(buff_instr(bp, HTTP_OK HTTP_HTM HTTP_BLANK) &&
           buff_instr(bp, "<html><head><title>Directory</title></head>\r\n") &&
           buff_inprintf(bp, "<body><h2>Directory of %s</h2>\r\n", path) &&
           buff_instr(bp, "<table><th>File</th><th>Size</th>\r\n"));
#else
    return(buff_instr(bp, HTTP_OK HTTP_HTM HTTP_BLANK) &&
           buff_instr(bp, "<html><head><title>Directory</title></head>\r\n") &&
           buff_inprintf(bp, "<body><h2>Directory of %s</h2>\r\n", path));
#endif
}

/* Write out HTML file dir entry, given name. Return 0 if buffer full */
int dir_entry(CBUFF *bp, char *name)
{
#if HTML_DIR > 1
    return(buff_inprintf(bp, "<tr><td><a href='%s'>%s</a></td>", name, name) &&
           buff_inprintf(bp, "<td>%lu</td></tr>\r\n", find_filesize()));
#else
    return(buff_inprintf(bp, "<a href='%s'>%s</a><br>\r\n", name, name));
#endif
}

/* Write out tail of HTML file dir. Return length, 0 if error */
int dir_tail(CBUFF *bp)
{
#if HTML_DIR > 1
    return(buff_instr(bp, "</table></body></html>\r\n"));
#else
    return(buff_instr(bp, "</body></html>\r\n"));
#endif
}

/* Check for incoming packets, send response if required */
void do_receive(GENFRAME *gfp)
{
    NODE node;
    ARPKT *arp;
    IPKT *ip;
    ICMPKT *icmp;
    int rxlen, txlen, len;

    if ((rxlen=get_frame(gfp)) > 0)                 /* Any incoming frames? */
    {
        ip = getframe_datap(gfp);
        if (is_arp(gfp, rxlen))
        {                                           /* ARP response? */
            arp = getframe_datap(gfp);
            if (arp->op==ARPREQ && arp->dip==locnode.ip)
            {                                       /* ARP request? */
                node.ip = arp->sip;                 /* Make ARP response */
                memcpy(node.mac, arp->smac, MACLEN);
                txlen = make_arp(gfp, &locnode, &node, ARPRESP);
                put_frame(gfp, txlen);              /* Send packet */
            }
            if (arp->op==ARPRESP && arp->dip==locnode.ip)
            {                                       /* ARP response? */
                arp_receive(tsocks, NSOCKS, gfp);
            }
        }
        else if ((rxlen=is_ip(gfp, rxlen))!=0 &&    /* IP datagram? */
                 ip->i.dip==locnode.ip || ip->i.dip==BCASTIP)
        {
            getip_srce(gfp, &node);
            if ((len=is_icmp(ip, rxlen))!=0)        /* ICMP? */
            {
                icmp = (ICMPKT *)ip;
                if (icmp->c.type==ICREQ)            /* Echo request? */
                {
                    len = (WORD)maxi(len, 0);       /* Make response */
                    txlen = make_icmp(gfp, &locnode, &node, ICREP,
                                      icmp->c.code, (WORD)len);
                    put_frame(gfp, txlen);          /* Send packet */
                }
            }
            else if ((len=is_tcp(ip, rxlen))!=0)    /* TCP? */
            {
                tcp_receive(tsocks, NSOCKS, gfp, len);
            }
        }
    }
}

/* Poll the network interface to keep it alive */
void do_poll(GENFRAME *gfp)
{
    tcp_poll(tsocks, NSOCKS, gfp);
    poll_net(gfp->g.dtype);
}

/* Version of printf() to write a string into a circular buffer.
** Return string length, or zero if insufficient room in buffer */
int buff_inprintf(CBUFF *bp, char *str, ...)
{
    char temps[200];
    int len;

    va_list argptr;
    va_start(argptr, str);
    len = vsprintf(temps, str, argptr);
    va_end(argptr);
    if (len<=0 || len>buff_freelen(bp))
        len = 0;
    else
        buff_in(bp, (BYTE *)temps, (WORD)len);
    return(len);
}

/* Display usage help */
void disp_usage(void)
{
    printf("Usage:    WEBSERVE [ options ] [ directory ]\n");
    printf("          If no directory specified, default is '%s'\n", FILEDIR);
    printf("Options:  -c name   Config filename (default %s)\n", CFGFILE);
    printf("          -s        State display\n");
    printf("          -t        TCP segment display\n");
    printf("          -v        Verbose packet display\n");
    printf("          -w        Web (HTTP) diagnostics\n");
    printf("          -x        Hex packet display\n");
    printf("Example:  WEBSERVE c:\\mydocs\n");
}

/* Ctrl-break handler: set flag and return */
void break_handler(int sig)
{
    breakflag = sig;
}

/* EOF */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产99久久久久久免费看农村| 亚洲地区一二三色| 欧美精品一级二级| 国产成人av福利| 亚洲图片欧美色图| 国产精品视频一二三| 日韩午夜激情免费电影| 91老师国产黑色丝袜在线| 国内精品嫩模私拍在线| 婷婷久久综合九色综合伊人色| 国产精品久久久久婷婷| 亚洲精品在线网站| 欧美一区二区三区视频免费播放| 91美女精品福利| 成人午夜激情影院| 国产美女精品一区二区三区| 日韩国产欧美三级| 亚洲国产一区视频| 亚洲男同性恋视频| 亚洲欧美自拍偷拍| 国产女人18毛片水真多成人如厕 | 欧美日韩在线亚洲一区蜜芽| 国产精品一区二区三区99| 久久国产精品99久久久久久老狼| 视频一区中文字幕国产| 亚洲网友自拍偷拍| 亚洲国产精品久久一线不卡| 亚洲欧美日韩中文字幕一区二区三区 | 黄色小说综合网站| 日韩av成人高清| 日韩av电影一区| 蜜桃视频一区二区| 免费在线观看成人| 九九精品视频在线看| 日本不卡在线视频| 麻豆免费精品视频| 久久成人免费日本黄色| 久久国产精品99精品国产| 九一久久久久久| 紧缚捆绑精品一区二区| 激情六月婷婷久久| 国产毛片精品国产一区二区三区| 国产综合色在线| 懂色av中文一区二区三区| 国产盗摄女厕一区二区三区| 国产一区二区按摩在线观看| 国产乱淫av一区二区三区 | 欧美日韩美少妇| 欧美肥胖老妇做爰| 欧美一卡2卡3卡4卡| 精品久久久三级丝袜| 久久精品一区二区| 国产精品嫩草99a| 亚洲欧美日韩一区二区| 亚洲一卡二卡三卡四卡| 日韩精品免费专区| 国模冰冰炮一区二区| 成人午夜伦理影院| 欧美做爰猛烈大尺度电影无法无天| 在线观看亚洲精品视频| 欧美一区二区私人影院日本| 精品国产成人系列| 亚洲少妇中出一区| 天天色天天操综合| 国产福利一区二区三区视频| 成人精品国产一区二区4080| 91国产精品成人| 日韩一级片网址| 国产精品你懂的在线欣赏| 亚洲成人福利片| 国产激情一区二区三区四区| 色婷婷香蕉在线一区二区| 欧美一区二区日韩一区二区| 国产三级一区二区三区| 夜夜爽夜夜爽精品视频| 久久国产成人午夜av影院| 99综合影院在线| 91精品国产综合久久精品| 国产欧美一区二区精品仙草咪 | 国产乱理伦片在线观看夜一区| 91网页版在线| 欧美不卡一区二区三区四区| 1024成人网| 美女网站视频久久| 色综合视频一区二区三区高清| 日韩一区二区三区高清免费看看| 国产精品视频免费| 日本网站在线观看一区二区三区| 高清不卡一区二区| 777色狠狠一区二区三区| 国产精品国产三级国产aⅴ原创| 天堂在线一区二区| 97久久人人超碰| 精品三级av在线| 亚洲综合丝袜美腿| 成人手机在线视频| 日韩欧美区一区二| 亚洲国产日韩a在线播放性色| 国产成人午夜电影网| 7878成人国产在线观看| 亚洲人一二三区| 国产sm精品调教视频网站| 欧美精品日日鲁夜夜添| 亚洲欧美乱综合| 国产成人亚洲精品青草天美| 日韩欧美国产精品| 天堂影院一区二区| 在线观看视频欧美| 成人免费在线播放视频| 狠狠色伊人亚洲综合成人| 欧美高清激情brazzers| 一区二区国产视频| av高清久久久| 国产精品天干天干在线综合| 国内精品国产三级国产a久久| 538prom精品视频线放| 亚洲综合另类小说| 91蜜桃免费观看视频| 国产精品二三区| k8久久久一区二区三区| 欧美激情中文字幕| 国产精品996| 久久久99精品免费观看不卡| 精品写真视频在线观看 | 亚洲欧美日韩一区二区 | 欧美日韩一区视频| 亚洲中国最大av网站| 色婷婷国产精品久久包臀| 亚洲三级免费电影| 色域天天综合网| 亚洲精品视频一区| 色妞www精品视频| 亚洲一二三区不卡| 欧美日韩性生活| 奇米影视一区二区三区小说| 欧美一区二区三区爱爱| 伦理电影国产精品| 欧美精品一区在线观看| 国产精品996| ●精品国产综合乱码久久久久| 成人激情综合网站| 日韩一区在线看| 欧美视频你懂的| 日韩av二区在线播放| 日韩一级片网站| 国产精品羞羞答答xxdd| 亚洲欧美中日韩| 欧美午夜影院一区| 日本91福利区| 久久久久97国产精华液好用吗| 国产精品综合av一区二区国产馆| 中文一区二区在线观看 | 26uuu另类欧美亚洲曰本| 国产毛片精品一区| 自拍偷拍欧美精品| 欧美午夜精品久久久久久孕妇| 偷拍亚洲欧洲综合| 日韩欧美国产午夜精品| 成人一区在线观看| 一片黄亚洲嫩模| 欧美一区二区福利在线| 国产美女在线精品| 一区二区三区免费网站| 欧美一区二区三区视频在线 | 久久久综合视频| 99在线精品观看| 天天影视网天天综合色在线播放| 欧美一二三区精品| 成人午夜激情片| 午夜精品福利视频网站| 久久久综合视频| 欧美午夜精品电影| 国产精品一品二品| 夜夜嗨av一区二区三区| 欧美成人官网二区| 91福利区一区二区三区| 精品中文字幕一区二区| 亚洲乱码国产乱码精品精的特点| 91麻豆精品国产91久久久更新时间| 国产传媒日韩欧美成人| 亚洲成人午夜电影| 欧美激情一区三区| 51久久夜色精品国产麻豆| 不卡电影免费在线播放一区| 视频一区二区不卡| 1区2区3区国产精品| 日韩欧美国产电影| 欧美在线免费观看视频| 成人深夜在线观看| 毛片av一区二区三区| 亚洲一区二区三区四区中文字幕| 久久人人超碰精品| 欧美日韩激情一区二区| av午夜一区麻豆| 国产毛片精品国产一区二区三区| 午夜精品久久久久久久久| 国产精品福利影院| 久久久久久亚洲综合| 在线播放91灌醉迷j高跟美女 | 亚洲成人免费观看|