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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? httpd.c

?? 嵌入式操作系統ECOS的網絡開發包
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* =================================================================
 *
 *      httpd.c
 *
 *      A simple embedded HTTP server
 *
 * ================================================================= 
 * ####ECOSGPLCOPYRIGHTBEGIN####
 * -------------------------------------------
 * This file is part of eCos, the Embedded Configurable Operating
 * System.
 * Copyright (C) 2002 Nick Garnett.
 * 
 * eCos is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 or (at your option)
 * any later version.
 * 
 * eCos is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with eCos; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 * 
 * As a special exception, if other files instantiate templates or
 * use macros or inline functions from this file, or you compile this
 * file and link it with other works to produce a work based on this
 * file, this file does not by itself cause the resulting work to be
 * covered by the GNU General Public License. However the source code
 * for this file must still be made available in accordance with
 * section (3) of the GNU General Public License.
 * 
 * This exception does not invalidate any other reasons why a work
 * based on this file might be covered by the GNU General Public
 * License.
 *
 * -------------------------------------------
 * ####ECOSGPLCOPYRIGHTEND####
 * =================================================================
 * #####DESCRIPTIONBEGIN####
 * 
 *  Author(s):    nickg@calivar.com
 *  Contributors: nickg@calivar.com
 *  Date:         2002-10-14
 *  Purpose:      
 *  Description:  
 *               
 * ####DESCRIPTIONEND####
 * 
 * =================================================================
 */

#include <pkgconf/system.h>
#include <pkgconf/isoinfra.h>
#include <pkgconf/httpd.h>

#include <cyg/infra/cyg_trac.h>        /* tracing macros */
#include <cyg/infra/cyg_ass.h>         /* assertion macros */

#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

#include <network.h>
#include <arpa/inet.h>

#include <cyg/httpd/httpd.h>

/* ================================================================= */

#if 0
#define HTTPD_DIAG diag_printf
#else
#define HTTPD_DIAG(...)
#endif

/* ================================================================= */
/* Server socket address and file descriptor.
 */

static struct sockaddr_in server_address;

static int server_socket = -1;

/* ================================================================= */
/* Thread stacks, etc.
 */

static cyg_uint8 httpd_stacks[CYGNUM_HTTPD_THREAD_COUNT]
                             [CYGNUM_HAL_STACK_SIZE_MINIMUM+
                              CYGNUM_HTTPD_SERVER_BUFFER_SIZE+
                              CYGNUM_HTTPD_THREAD_STACK_SIZE];

static cyg_handle_t httpd_thread[CYGNUM_HTTPD_THREAD_COUNT];

static cyg_thread httpd_thread_object[CYGNUM_HTTPD_THREAD_COUNT];

/* ================================================================= */
/* Filename lookup table
 */

CYG_HAL_TABLE_BEGIN( cyg_httpd_table, httpd_table );
CYG_HAL_TABLE_END( cyg_httpd_table_end, httpd_table );

__externC cyg_httpd_table_entry cyg_httpd_table[];
__externC cyg_httpd_table_entry cyg_httpd_table_end[];

/* ================================================================= */
/* Page not found message
 */

static char cyg_httpd_not_found[] =
"<head><title>Page Not found</title></head>\n"
"<body><h2>The requested URL was not found on this server.</h2></body>\n";

/* ================================================================= */
/* Simple pattern matcher for filenames
 *
 * This performs a simple pattern match between the given name and the
 * pattern. At present the only matching supported is either exact, or
 * if the pattern ends in * then that matches all remaining
 * characters. At some point we might want to implement a more
 * complete regular expression parser here.
 */

static cyg_bool match( char *name, char *pattern )
{
    while( *name != 0 && *pattern != 0 && *name == *pattern )
        name++, pattern++;

    if( *name == 0 && *pattern == 0 )
        return true;

    if( *pattern == '*' )
        return true;

    return false;
}

/* ================================================================= */
/* Main HTTP server
 *
 * This just loops, collects client connections, reads the HTTP
 * header, look it up in the table and calls the handler.
 */

static void cyg_httpd_server( cyg_addrword_t arg )
{
    do
    {
        int err;
        int client_socket;
        struct sockaddr_in client_address;
        int calen;
        int nlc = 0;
        char request[CYGNUM_HTTPD_SERVER_BUFFER_SIZE];
        FILE *client;
        cyg_httpd_table_entry *entry = cyg_httpd_table;
        char *filename;
        char *formdata = NULL;
        char *p;
        cyg_bool success = false;

        /* Wait for a connection.
         */
        client_socket = accept( server_socket, (struct sockaddr *)&client_address, &calen );
        
        HTTPD_DIAG("Connection from %08x[%d]\n",client_address.sin_addr.s_addr,
                   client_address.sin_port);

        /* Convert the file descriptor to a C library FILE object so
         * we can use fprintf() and friends on it.
         */
        client = fdopen( client_socket, "r+");

        /* We are really only interested in the first line.
         */
        fgets( request, sizeof(request), client );

        HTTPD_DIAG("Request >%s<\n", request );
        
        /* Absorb the rest of the header. We nibble it away a
         * character at a time like this to avoid having to define
         * another buffer to read lines into. If we ever need to take
         * more interest in the header fields, we will need to be a
         * lot more sophisticated than this.
         */
        do{
            int c = getc( client );
            HTTPD_DIAG("%c",c);
            if( c == '\n' )
                nlc++;
            else if( c != '\r' )
                nlc = 0;
        } while(nlc < 2);

        /* Extract the filename and any form data being returned.
         * We know that the "GET " request takes 4 bytes.
         * TODO: handle POST type requests as well as GET's.
         */

        filename = p = request+4;

        /* Now scan the filename until we hit a space or a '?'. If we
         * end on a '?' then the rest is a form request. Put NULs at
         * the end of each string.
         */
        while( *p != ' ' && *p != '?' )
            p++;
        if( *p == '?' )
            formdata = p+1;
        *p = 0;

        if( formdata != NULL )
        {
            while( *p != ' ' )
                p++;
            *p = 0;
        }

        HTTPD_DIAG("Request filename >%s< formdata >%s<\n",filename,formdata?formdata:"-NULL-");

        HTTPD_DIAG("table: %08x...%08x\n",cyg_httpd_table, cyg_httpd_table_end);

        /* Now scan the table for a matching entry. If we find one
         * call the handler routine. If that returns true then we
         * terminate the scan, otherwise we keep looking.
         */
        while( entry != cyg_httpd_table_end )
        {
            HTTPD_DIAG("try %08x: %s\n", entry, entry->pattern);
            
            if( match( filename, entry->pattern ) )
            {
                if( (success = entry->handler( client, filename, formdata, entry->arg )) )
                    break;
            }

            entry++;
        }

        /* If we failed to find a match in the table, send a "not
         * found" response.
         * TODO: add an optional fallback to go look for files in
         * some filesystem, somewhere.
         */
        if( !success )
            cyg_httpd_send_html( client, NULL, NULL, cyg_httpd_not_found );

        /* All done, close the connection
         */
        err = fclose( client );
        CYG_ASSERT( err == 0, "fclose() returned error");        
        
    } while(1);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费大片在线观看| 91丨九色porny丨蝌蚪| 福利电影一区二区三区| 欧美日韩精品一区二区| 亚洲国产精品成人综合 | 国产·精品毛片| 欧美精品在线观看一区二区| 国产精品情趣视频| 美国一区二区三区在线播放| 色www精品视频在线观看| 国产精品嫩草99a| 韩国一区二区三区| 在线播放视频一区| 亚洲国产日韩精品| 在线观看国产一区二区| 国产精品网友自拍| 丁香啪啪综合成人亚洲小说 | 国产精品538一区二区在线| 欧美日韩久久久久久| 亚洲精品免费一二三区| 成人午夜在线免费| 国产精品天天看| 成人中文字幕电影| 久久久影视传媒| 国产剧情一区二区三区| 日韩欧美一区二区三区在线| 日本美女一区二区三区| 7777精品久久久大香线蕉| 午夜久久久久久久久| 欧美在线一区二区| 天天综合色天天综合色h| 欧美午夜宅男影院| 亚洲综合在线视频| 欧美日韩一区二区三区视频| 亚洲一区二区美女| 欧美女孩性生活视频| 视频在线在亚洲| 91精品国产乱码| 久久疯狂做爰流白浆xx| 欧美精品一区二区久久久| 国产精品夜夜爽| 欧美激情中文不卡| 99久久婷婷国产综合精品电影| 一色桃子久久精品亚洲| 99国内精品久久| 亚洲一区二区精品视频| 制服丝袜成人动漫| 国产在线精品免费| 国产精品不卡在线| 日本久久一区二区三区| 偷拍与自拍一区| 精品国产一区二区三区久久影院| 国产乱子轮精品视频| 亚洲欧洲一区二区在线播放| 欧美性猛交xxxx乱大交退制版| 婷婷开心久久网| 2020国产精品| 在线观看91视频| 蜜桃免费网站一区二区三区| 国产欧美日韩综合| 欧美日韩国产一二三| 国产麻豆91精品| 一区二区三区在线影院| 欧美草草影院在线视频| 成人av网址在线| 丝袜亚洲精品中文字幕一区| 久久一留热品黄| 欧美在线免费视屏| 国产伦精品一区二区三区在线观看 | 日韩美女久久久| 欧美一区二区成人| 本田岬高潮一区二区三区| 天堂va蜜桃一区二区三区| 欧美国产精品一区二区三区| 8v天堂国产在线一区二区| 高清shemale亚洲人妖| 亚洲在线视频一区| 国产精品久久久久久亚洲伦| 91精品国产综合久久蜜臀| www.性欧美| 韩国av一区二区三区在线观看| 亚洲女爱视频在线| 国产欧美一区二区精品久导航 | 久久精品72免费观看| 综合欧美一区二区三区| 精品国产123| 欧美日韩中文字幕一区| 99精品久久免费看蜜臀剧情介绍| 老司机一区二区| 亚洲国产精品一区二区久久| 国产精品国产a| 久久久不卡网国产精品一区| 欧美一区二区观看视频| 欧美私人免费视频| 91成人免费在线视频| 成人国产精品免费网站| 国产在线不卡视频| 蜜桃av一区二区在线观看| 日本午夜一区二区| 亚洲成人综合视频| 亚洲一区二区三区四区的| 亚洲三级在线播放| 亚洲免费看黄网站| 亚洲天堂久久久久久久| 在线成人av影院| 精品理论电影在线| 欧美系列一区二区| 在线视频亚洲一区| 一本久久a久久精品亚洲| 成人免费视频免费观看| 成人免费高清视频在线观看| 国产成人鲁色资源国产91色综| 精品一区二区免费| 紧缚奴在线一区二区三区| 狂野欧美性猛交blacked| 捆绑调教美女网站视频一区| 老司机午夜精品| 国产一区二区看久久| 国产成人免费在线视频| 丰满少妇久久久久久久| 国产99久久久国产精品潘金网站| 国产精品99久久久久久似苏梦涵| 国产精品一区二区三区网站| 国产激情视频一区二区在线观看 | 亚洲一区二区三区国产| 亚洲1区2区3区4区| 看片的网站亚洲| 久久亚洲私人国产精品va媚药| 欧美日产在线观看| 日韩亚洲欧美在线| 欧美mv日韩mv| 国产精品久久久久久亚洲伦| 亚洲另类中文字| 五月综合激情婷婷六月色窝| 久久av中文字幕片| 成人午夜在线播放| 91精品办公室少妇高潮对白| 欧美日韩国产综合视频在线观看| 日韩欧美国产高清| 中文字幕精品三区| 亚洲与欧洲av电影| 精品一区免费av| 成人av网站免费观看| 欧美日韩国产在线播放网站| www亚洲一区| 亚洲激情在线激情| 麻豆久久一区二区| a在线欧美一区| 欧美日韩不卡视频| 国产精品日韩精品欧美在线| 性久久久久久久| 国产精品一区二区三区四区| 欧美亚洲国产一区在线观看网站| 亚洲综合另类小说| 日本一区二区高清| 亚洲v日本v欧美v久久精品| 日本三级韩国三级欧美三级| 国产v日产∨综合v精品视频| 欧美色综合网站| 欧美国产一区在线| 五月激情综合婷婷| 91在线视频18| 久久综合999| 午夜精品成人在线| 99精品偷自拍| 久久精品夜色噜噜亚洲a∨| 亚洲国产视频直播| av一二三不卡影片| 久久久精品tv| 免费在线成人网| 日本丶国产丶欧美色综合| 精品国产乱码久久久久久浪潮| 亚洲精品免费电影| 国产91精品欧美| 久久久综合九色合综国产精品| 亚洲电影一区二区| 96av麻豆蜜桃一区二区| 国产亚洲精品bt天堂精选| 午夜激情综合网| 日本高清无吗v一区| 欧美国产成人在线| 亚洲女厕所小便bbb| 国产精品污www在线观看| 亚洲国产成人va在线观看天堂| 国产剧情一区二区三区| 69av一区二区三区| 亚洲人午夜精品天堂一二香蕉| 九一九一国产精品| 欧美巨大另类极品videosbest | 99热精品国产| 国产精品久久久久一区二区三区共 | 蜜桃一区二区三区四区| 欧美蜜桃一区二区三区| 亚洲精品一二三| 99视频一区二区| 亚洲视频精选在线| 91欧美一区二区| 亚洲视频在线观看三级| 91在线播放网址| 亚洲一级二级三级|