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

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

?? nedk_example_web_server.c

?? 很多儀器都輸出同步時鐘
?? C
?? 第 1 頁 / 共 2 頁
字號:
// file: nedk_web_server.c
//
// This is a very simple web server
// that can be modified to include
// several kinds of pages in a "wosfs"
// file directory. (File structure
// smashed into flash memory, immutable.)
//
// dvb@altera.com 2002
//
// ex:set tabstop=4:
//

#include "excalibur.h"
#include "plugs.h"
#include "wosfs.h"
#include "plugs_example_designs.h"


#define k_http_port 80
#define k_string_length 256

#define k_tcp_timeout 5000 // milliseconds

typedef struct
	{
	int tcp_plug_handle;
	int inquiry_number;
	int button_presses[4];

	long tcp_opened_time; // So we can time out the connection
	                      // in case of a dangled-open connect.
	} globals;

static globals g; // (starts life as zeroes of course)

// +---------------------------------
// | prototypes

static int r_handle_http_request(int plug_handle,unsigned char *message, int message_length);
static void r_get_cgi_param(char *url_and_args,char *parameter, char *value_out);
static void r_set_7_pattern(int control);
static void r_increment_button_counts(void);
static char *r_printable_string(char *s);
static int r_get_html_from_wosfs(char *url,char *html_out,int *html_length_out);
static int r_get_html_404(char *url,char *html_out);
static int r_substitute_string(char *fmt,char *s);
static int r_get_html_dynamically(char *url,char *url_and_args,char *html_out);

static int r_tcp_proc(int plug_handle,
		void *context,
		ns_plugs_packet *p,
		void *payload,
		int payload_length);

static int r_listen_proc(int plug_handle,
		void *context,
		host_32 remote_ip_address,
		host_16 remote_port);

static int r_start_listening(void);

// +---------------------------------
// | meat



int main(void)
	{
	int result;

	printf("[Xnedk_example_web_server] starting\n");

	// |
	// | Initialize the plugs library
	// |
	//
	result = nr_plugs_initialize
			(
			0, 0,
			__adapter__,
			__adapter_irq__,
			__adapter_struct_addr__
			);

	if(result)
		goto error_exit;

	// |
	// | Print the IP address we're using
	// |
		{
		ns_plugs_network_settings settings;

		result = nr_plugs_get_settings(0,&settings);

		printf("[nedk_example_web_server] IP address = ");
		nr_plugs_print_ip_address(settings.ip_address);
		printf("\n");
		}

	result = nr_plugs_create
			(
			&g.tcp_plug_handle, // | Plug to create
			ne_plugs_tcp,       // | Kind of plug (tcp connection)
			k_http_port,        // | Port to listen on
			r_tcp_proc,         // | To call with incoming data
			0,                  // | Context for plug callback
			0                   // | Flags for plug (none)
			);
	if(result)
		goto error_exit;

	// |
	// | Accept incoming connections
	// |

	result = r_start_listening();
	if(result)
		goto error_exit;
	
	// |
	// | Main loop: spin through here forever
	// | All this application does is serve
	// | web pages and blink the 7-segment
	// | display a little. If there were other tasks
	// | to do, like operating your factory
	// | equipment or something, you could
	// | have it running here in this main
	// | event loop (if timing weren't important),
	// | or as a timer task.
	// |

	while(1)
		{
		nr_plugs_idle();
		r_set_7_pattern(0);

		// |
		// | Check if tcp connection's been opened too long
		// |

		if( g.tcp_opened_time
				&& ((nr_timer_milliseconds() - g.tcp_opened_time) > k_tcp_timeout) )
			{
			char *s = "nedk_web_server: Connection timing out. Bye.\n";
			result = nr_plugs_send(g.tcp_plug_handle,s,strlen(s),0);
			result = r_start_listening();
			}
		}
	
	// |
	// | Only get here on an error condition...
	// |

error_exit:
	nr_plugs_print_error_message("[nedk_example_web_server]", result);
	return result;
	}

// +--------------------------------------
// | r_set_7_pattern
// |
// | Advance the little blinky-pattern that
// | moves around the 7-segment display
// |
// | Control Values
// |  0 advance tick
// |  1 all segments on
// |

#define k_7_time 80 // mSec between frames
static void r_set_7_pattern(int control)
	{
	long x;
	static long last_time = 0;
	static long current_step = 0;
	static long d_pattern[] =  // 8 steps in the pattern
		{
		0xffffffbf, 0xffffffdf, 0xffffffef, 0xfffffff7,  // outer edge
		0xfffff7ff, 0xfffffbff, 0xfffffdff, 0xffffbfff,
		};
	
	x = nr_timer_milliseconds();
	if(x - last_time > k_7_time)
		{
		// |
		// | Time enough to update the LED?
		// |

		last_time = x;

		current_step = (current_step + 1) & 7;
		}

	if(control == 1)
		x = 0;
	else
		x = d_pattern[current_step];

	na_seven_seg_pio->np_piodirection = 0xffff;
	na_seven_seg_pio->np_piodata = x;
	}


// +----------------------------------
// | r_start_listening
// |
// | This routine closes the current tcp
// | connection (if any) and starts listening
// | again.
// |

static int r_start_listening(void)
	{
	int result;

	printf("\nlistening on port %d at t = %8d\n",k_http_port,nr_timer_milliseconds() );

	result = nr_plugs_listen(g.tcp_plug_handle,r_listen_proc,0);
	g.tcp_opened_time = 0; // so it looks like we're "closed"

	return result;
	}


// +----------------------------------
// | r_listen_proc
// |
// | This is a plugs listener callback proc.
// | It gets called when a remote client
// | requests a connection. We always accept
// | the connection, but we do take the opportunity
// | to note the time of the connection. Then, in
// | the main loop, we see if the connection has
// | been left open too long, and maybe force it closed.

static int r_listen_proc(int plug_handle,
		void *context,
		host_32 remote_ip_address,
		host_16 remote_port)
	{

	g.tcp_opened_time = nr_timer_milliseconds();

	printf("[tcp_listen_proc] Accepted connection from ");
	nr_plugs_print_ip_address(nr_h2n32(remote_ip_address));
	printf(" port %d at t = %8d\n",remote_port,g.tcp_opened_time);

	return 0;
	}

// +----------------------------------
// | r_tcp_proc
// |
// | This is a plugs receive callback proc.
// | It gets called when a remote client connects
// | to our web server and sends a request. We
// | assume that the request arrives in a single
// | packet (or, at least, that the first line
// | of it, containing the URL, does).
// |
// | If the payload length is zero, this means
// | for a tcp_plug that the remote network device
// | has disconnected from us, and we listen for
// | the next connection.
// |


static int r_tcp_proc
		(
		int plug_handle,
		void *context,
		ns_plugs_packet *p,
		void *payload,
		int payload_length
		)
	{
	unsigned char *w;
	int i;
	int c;

	if(payload_length)
		{
		// |
		// | Incoming message, it must be a http request
		// | We let the http_server handle this request.
		// |
		
		r_handle_http_request(plug_handle,payload, payload_length);
		}
	else
		{
		// |
		// | Zero-length payload means "they disconnected",
		// | so, begin listening again on same port.
		// |

		r_start_listening();
		}

go_home:
	return 0;
	}

// +-------------------------------------------
// | r_handle_http_request(plug_handle, http_request, http_request_length)
// |
// | Actually, we just assume that the message
// | is, in fact, an HTTP request. An HTTP
// | request is of the form:
// |
// |    GET <url>[ <http-version>](CR)(LF)
// |
// | It may also continue with more information
// | on subsequent lines, each of the form:
// |
// |    <variable>: <value>
// |
// | And eventually ends with two CR-LF's.
// | But we ignore everything past the first
// | line here.
// |
// | To reply, we send a status line and 
// | a content-type, followed by to CRLF's and the HTML.
// |
// |    HTTP/1.1 200 OK
// |    Content-type: <content-type>
// |
// |    <HTML>
// |
// | The content type is either "text/html" or "image/gif".
// | We presume that if the content comes from WOSFS,
// | and the last letter of the filename is 'f', then it's
// | a GIF image.
// |

static int r_handle_http_request(int plug_handle,unsigned char *message, int message_length)
	{
	unsigned char *message_end;
	unsigned char *w;
	int i;
	int result = 0;
	char url_and_args[k_string_length];
	char url[k_string_length];
	int url_and_args_length;

	r_set_7_pattern(1); // | flash the 7-seg display

	++g.inquiry_number;

	message_end = message + message_length;
	w = message;

	// |
	// | Find the url_and_args portion of the packet, by looking for the
	// | first space (just after the word "GET").
	// |

	while(w < message_end && *w++ != ' ')
		;

	w = w + 1; // | omit the omnipresent leading slash
	url_and_args_length = 0;
	
	// |
	// | Copy the URL and any CGI arguments into url_and_args.
	// | look for the end of the URL and CGI parameters as a ' ' or crlf
	// |

	while(w < message_end && *w > ' ') // | break on blank or ctrl char
		url_and_args[url_and_args_length++] = *w++;

	url_and_args[url_and_args_length] = 0;  // | Terminate string

	// |
	// | Asking for the root of the server, "/", means
	// | they want "index.html".
	// |

	if(url_and_args_length == 0) // empty url?
		{
		strcpy(url_and_args,"index.html");
		url_and_args_length = strlen(url_and_args);
		}

	r_get_cgi_param(url_and_args,0,url); // null param = URL

printf("\n");
printf("[r_handle_http_request] url_and_args_length = %d\n", url_and_args_length);
printf("[r_handle_http_request] url_and_args = %s\n", url_and_args);
printf("[r_handle_http_request] url = \"%s\"\n",r_printable_string(url));

	// |
	// | We've extracted the url with arguments, and just the url
	// | by itself. We'll now look for a file, a dynamic page, or a 404 error.

		{
		char html_response[30000];
		int html_response_length = 0;
		char *http_result_code_and_message;
		char *http_content_type;
		int file_index;

		// |
		// | Default to 200 OK status, and check last char of URL for content type
		// |

		http_result_code_and_message = "200 OK";
		http_content_type = url[strlen(url) - 1] == 'f'
				? "image/gif" : "text/html";
		html_response[0] = 0;

		// |
		// | Try to get the file from wosfs
		// |

		result = r_get_html_from_wosfs(url,html_response,&html_response_length);

		// |
		// | If not wosfs, try dynamic
		// |

		if(result)
			result = r_get_html_dynamically(url,url_and_args,html_response);

		// |
		// | And if even that fails, call our
		// | error generation routine.
		// |
		
		if(result)
			{
			http_result_code_and_message = "404 File Not Found";
			http_content_type = "text/html";
			r_get_html_404(url,html_response);
			result = 0; // above routine not allowed to fail
			}


		// |
		// | If nobody filled out the html_response_length,
		// | get it as a string length.
		// |
		if(html_response_length == 0)
			html_response_length = strlen(html_response);

printf("[r_handle_http_request] sending %d bytes of html out.\n",html_response_length);
			

		// |
		// | Lastly, send the HTTP response.
		// | The plugs library will not automatically
		// | break up the packet into ethernet-legal
		// | chunks, so we do it here.
		// |

			{
			char http_intro[k_string_length];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产盗摄一区二区| 这里是久久伊人| 91久久精品一区二区三| 色视频欧美一区二区三区| 欧美一卡在线观看| 亚洲天堂a在线| 久久99久久久欧美国产| 99riav久久精品riav| 欧美一二三四区在线| 亚洲乱码国产乱码精品精98午夜| 日韩电影免费一区| 欧日韩精品视频| 国产女人18毛片水真多成人如厕 | 午夜视频在线观看一区二区三区 | 一区二区激情小说| 国产一区二区成人久久免费影院| 欧美亚洲另类激情小说| 国产精品天天看| 久久精品国产77777蜜臀| 欧美日韩在线一区二区| 中文字幕在线一区二区三区| 极品美女销魂一区二区三区免费| 欧美一级淫片007| 亚洲妇女屁股眼交7| 色88888久久久久久影院按摩| 久久蜜桃av一区精品变态类天堂| 蜜臀91精品一区二区三区| 欧美精品自拍偷拍动漫精品| 亚洲一区二区三区免费视频| 91色|porny| 亚洲视频精选在线| 北条麻妃国产九九精品视频| 久久久久久久综合色一本| 狠狠色丁香久久婷婷综| 91精品国产综合久久精品图片| 麻豆国产欧美日韩综合精品二区| 欧美在线视频全部完| 制服丝袜在线91| 精品蜜桃在线看| 天天做天天摸天天爽国产一区 | 亚洲电影一区二区三区| 国产成人三级在线观看| 欧美xxxx老人做受| 国产九色sp调教91| 久久久精品影视| 国产精品一色哟哟哟| 久久先锋影音av| 国产精品一区二区三区四区| 国产网站一区二区三区| 大胆欧美人体老妇| 亚洲丝袜制服诱惑| 欧美三级一区二区| 日本亚洲欧美天堂免费| 欧美成人bangbros| 成人美女在线观看| 亚洲日本va在线观看| 色哟哟在线观看一区二区三区| 亚洲综合区在线| 555夜色666亚洲国产免| 久久激情五月激情| 亚洲成a人在线观看| 884aa四虎影成人精品一区| 蜜桃精品视频在线| 2021久久国产精品不只是精品| 国产成人午夜视频| 亚洲免费观看高清完整版在线| 欧美亚洲高清一区二区三区不卡| 日韩电影在线一区| 国产日韩一级二级三级| www.日韩精品| 日本va欧美va精品发布| 久久精品视频在线免费观看| 色老汉av一区二区三区| 日韩成人dvd| 国产精品久久久久久亚洲伦| 欧美亚一区二区| 麻豆91在线看| 亚洲三级电影网站| 欧美一二三四在线| 色综合久久久久久久久| 免费成人av资源网| 国产日韩精品久久久| 欧美日韩在线直播| 成人av在线播放网址| 亚洲a一区二区| 国产精品视频一二三区| 欧美人与z0zoxxxx视频| 成人av免费网站| 久久国产精品色婷婷| 亚洲另类中文字| 国产欧美久久久精品影院| 欧美日韩精品欧美日韩精品一| 粉嫩嫩av羞羞动漫久久久| 天天色综合天天| 樱花影视一区二区| 国产女主播视频一区二区| 日韩一级大片在线| 欧美中文字幕一区| 91论坛在线播放| 国产成人鲁色资源国产91色综| 日日欢夜夜爽一区| 亚洲免费观看视频| 综合久久综合久久| 国产视频亚洲色图| 精品少妇一区二区三区在线播放| 欧美日韩视频一区二区| 色综合色综合色综合色综合色综合 | 亚洲成人动漫在线免费观看| 欧美国产欧美亚州国产日韩mv天天看完整| 91精品国产欧美一区二区成人| 欧美在线免费观看视频| 色网站国产精品| 91浏览器在线视频| 91麻豆精品一区二区三区| jlzzjlzz亚洲女人18| 成人黄色av网站在线| 成人黄色一级视频| 成人sese在线| www.亚洲色图.com| 91免费视频大全| 91免费观看在线| 色综合久久88色综合天天| 91麻豆精品视频| 欧美自拍偷拍一区| 欧美群妇大交群中文字幕| 欧美二区在线观看| 日韩三级免费观看| 精品对白一区国产伦| 久久亚洲综合av| 国产精品视频麻豆| 亚洲欧美综合色| 一区二区三区欧美久久| 五月开心婷婷久久| 久久精品国产亚洲5555| 国产乱码精品一区二区三区五月婷| 国产乱妇无码大片在线观看| 99久免费精品视频在线观看| 色香蕉久久蜜桃| 欧美一区日韩一区| 久久一日本道色综合| 最新成人av在线| 婷婷久久综合九色国产成人| 久久9热精品视频| av综合在线播放| 精品视频在线看| 精品精品国产高清a毛片牛牛 | 国模无码大尺度一区二区三区| 国产精品一线二线三线| 色综合久久久久久久久久久| 欧美一区国产二区| 中文字幕视频一区| 日日欢夜夜爽一区| 成人福利视频在线看| 在线播放日韩导航| 国产日产欧美一区| 亚洲国产精品一区二区www在线| 国产综合色精品一区二区三区| av福利精品导航| 日韩一区二区精品| 国产精品乱人伦中文| 天天综合色天天综合色h| 成人午夜av在线| 日韩一区二区三区精品视频| 中文字幕国产一区| 日韩av中文字幕一区二区三区| 国产成人aaaa| 欧美精品久久天天躁| 国产精品成人免费 | 一区二区三区鲁丝不卡| 国产麻豆一精品一av一免费| 精品视频一区三区九区| 中文成人av在线| 免费观看久久久4p| 欧美性一二三区| 国产精品久久久久aaaa樱花| 久久精品国产久精国产爱| 欧美在线视频不卡| √…a在线天堂一区| 国产资源在线一区| 91精品国产综合久久久久久| 一区二区三区在线观看国产| 成人综合婷婷国产精品久久 | 国产精品久久综合| 国内精品视频一区二区三区八戒| 欧美日本精品一区二区三区| 中文字幕一区二区三区蜜月| 韩国成人福利片在线播放| 制服丝袜一区二区三区| 亚洲chinese男男1069| 91福利国产精品| 亚洲丝袜美腿综合| 菠萝蜜视频在线观看一区| 久久精品欧美一区二区三区不卡| 日本vs亚洲vs韩国一区三区二区 | 久久婷婷综合激情| 日韩中文字幕区一区有砖一区 | 精品国产sm最大网站| 免费成人在线视频观看| 91精品婷婷国产综合久久性色| 亚洲国产aⅴ天堂久久|