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

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

?? nedk_example_web_server.c

?? 包括基于Cyclone1C20芯片NiosII軟件開發的各種模塊的測試例子
?? C
?? 第 1 頁 / 共 2 頁
字號:
			// |
			// | Send the HTTP stuff
			// |
			sprintf(http_intro,"HTTP/1.1 %s\r\nContent-type: %s\r\n\r\n",
					http_result_code_and_message,
					http_content_type
					);

			nr_plugs_send(plug_handle,http_intro,strlen(http_intro),0);
			}


			{
			int this_packet;
			int size_left = html_response_length;
			char *w = html_response;
			int mtu = 512;


			// |
			// | And send the HTML, broken up into MTU sized bits
			// |

			while(size_left)
				{
				this_packet = size_left;
				if(this_packet > mtu)
					this_packet = mtu;
				nr_plugs_send(plug_handle,w,this_packet,0);
				size_left -= this_packet;
				w += this_packet;
				}
			}

		// And close the connection by re-listening

		r_start_listening();
		}
	
	}



// +--------------------------------------------
// | r_get_html_from_wosfs(url,html_out,html_length_out)
// |
// | Look for a WOSFS file with a file name
// | matching the URL, and fill html_out with
// | its contents if found. If no such file
// | is found, return result -1.
// |
// | The length is also returned, since it
// | might be a gif image, and strlen will not
// | work on that.
// | 

static int r_get_html_from_wosfs(char *url,char *html_out,int *html_length_out)
	{
	ns_wosfs_directory_entry de;
	int result = 0;
	int file_index;

	file_index = nr_wosfs_get_directory_entry_by_name(url,&de);
	if(file_index >= 0)
		{
		// |
		// | Found a wosfs file with the same name
		// | as the url requested. Get the file contents.
		// | Also, add a null terminator, to make it
		// | a C string.
		// |

		nr_wosfs_read(file_index,0,de.file_length,html_out); // should check length...
		html_out[de.file_length] = 0; // c string terminator
		*html_length_out = de.file_length; // and return the length, too
		}
	else
		result = -1;

	return result;
	}


// +--------------------------------------------
// | r_get_html_404(url,html_out)
// |
// | Construct a 404 error message page.
// | 

static int r_get_html_404(char *url,char *html_out)
	{
	ns_wosfs_directory_entry de;
	int result = 0;
	int file_index;

printf("[r_get_html_404] Assembling 404 Error\n");

	file_index = nr_wosfs_get_directory_entry_by_name("404_page.html",&de);
	if(file_index >= 0)
		{
		nr_wosfs_read(file_index,0,de.file_length,html_out);
		html_out[de.file_length] = 0; // C string terminator

		// |
		// | r_substitute_string() searches for the first
		// | occurence of "%s" and replaces it with the string
		// | (in this case the URL, so the error page can say
		// | what the bad URL was)
		// |

		r_substitute_string(html_out,url);
		}
	else
		{
		// |
		// | This shouldnt happen, only if our wosfs
		// | is missing the file "404_page.html".
		// |
		strcpy(html_out,"<h1>404: File Not Found</h1>");
		}
	
	return result;
	}


// +-----------------------------------------------
// | r_get_html_dynamically(url,url_and_args,html_out)
// |
// | This routine generates any dynamic html for the web server
// | It first retrieves a wosfs file named "<url>.template", if
// | any, and then checks for several possible dynamically
// | generated pages. If it's not one of those, return an error.
// |

static int r_get_html_dynamically(char *url,char *url_and_args,char *html_out)
	{
	char template_file[k_string_length];
	ns_wosfs_directory_entry de;
	int result = 0;
	int file_index;

	strcpy(template_file,url);
	strcat(template_file,".template");

printf("[r_get_html_dynamically] looking for template %s\n",template_file);

	file_index = nr_wosfs_get_directory_entry_by_name(template_file,&de);
	if(file_index >= 0)
		{
		nr_wosfs_read(file_index,0,de.file_length,html_out); // should check length...
		html_out[de.file_length] = 0;
		}
	else
		html_out[0] = 0;

	if(!strcmp(url,"template_page.html"))
		{
		// |
		// | General Info page
		// | Fill in a couple of blanks
		// | with the number of web inquiries so far,
		// | and the number of milliseconds since starting
		// |

		char s[k_string_length];

		sprintf(s,"%4d",g.inquiry_number); // s must be more than 2 chars long!
		r_substitute_string(html_out,s);

		sprintf(s,"%4d",nr_timer_milliseconds()); // s must be more than 2 chars long!
		r_substitute_string(html_out,s);
		}
	else if(!strcmp(url,"dynamic_page.html"))
		{
		// |
		// | The memory dump page is generated entirely in this
		// | routine. No WOSFS file is used.
		// |
		char x[k_string_length];
		char *w;
		char c;
		int i;
		int j;
		int address;


		sprintf(html_out,"
<HTML>
<HEAD>
<TITLE>Nios</TITLE>
<BODY BGCOLOR=#FFFFFF>
<BLOCKQUOTE>
<H1><A HREF=index.html><IMG SRC=exc-nios.gif BORDER=0></A>Nios Memory Dump</H1>
<HR><BLOCKQUOTE><PRE>
");
		r_get_cgi_param(url_and_args,"address",x);
		w = x;

		address = 0;
		while((c = *w++) != 0)
			{
			if(c > '9')
				c += 9;
			address = (address << 4) + (c & 0x0f);
			}

		for(j = address; j < address + 1024; j += 32)
			{
			sprintf(html_out+strlen(html_out),"%08x: ",j);
			for(i = 0; i < 32; i++)
				sprintf(html_out+strlen(html_out),"%02x ",*(unsigned char *)(j + i));
			sprintf(html_out+strlen(html_out),"  :  ");
			for(i = 0; i < 32; i++)
				{
				c = *(unsigned char *)(j + i);
				if(c < 32 || c > 0x7e)
					c = '.';
				if(c == '<')
					sprintf(html_out+strlen(html_out),"&lt;");
				else
					sprintf(html_out+strlen(html_out),"%c",c);
				}
			sprintf(html_out+strlen(html_out),"\n");
			}
		sprintf(html_out+strlen(html_out),"
</PRE></BLOCKQUOTE>
<HR>
 <FORM ACTION=dynamic_page.html name=a_form>
 <INPUT TYPE=submit name=next value=\"Show Next 1024 bytes\">
 <INPUT TYPE=hidden name=address value=%08x>
 </FORM>
<HR>
 <FORM ACTION=dynamic_page.html name=b_form>
 Base Address: <INPUT TYPE=text name=address size=30>
 <INPUT TYPE=submit name=submit value=Show>
 </FORM>
<HR>

<A HREF=index.html>Home</A>
</BLOCKQUOTE>
</BODY>
</HTML>
",address+1024);
		}
	else 
		{
		// |
		// | Else, it's a dynamic url we dont know about. return error.
		// |

		result = -1;
		}
	return result;
	}




// +-------------------------------------
// | r_substitute_string(char *fmt,char *s)
// |
// | Scan fmt for the first occurence of
// | "%s", and replace it with string s.
// |
// | Very useful for implementing dynamic
// | pages where a few parts are written
// | in with values or something.
// |

static int r_substitute_string(char *fmt,char *s)
	{
	int result = 0;
	int i;
	int fmt_len;
	int s_len;

	fmt_len = strlen(fmt);
	s_len = strlen(s);
	for(i = 0; i < (fmt_len - 1); i++)
		{
		if(fmt[i] == '%' && fmt[i + 1] == 's')
			{
			// |
			// | found "%s", move stuff around a bit.
			// |

			bcopy(fmt + i,fmt + i + s_len - 2,fmt_len - i + 1); // -2 for %s itself
			bcopy(s,fmt + i,s_len);
			goto go_home;
			}
		}

	result = -1; // didnt find %s, so didnt do substitution

go_home:
	return result;
	}


// +------------------------------------------
// | Given a pointer to a char *, read a string until
// | either a null terminator or the until_character
// | is hit. Leave the char * pointing to this
// | last character.

static void r_read_string_until(char **wp,char *string_out,char until_character)
	{
	char *w = *wp;
	char c;

	while(1)
		{
		c = *w;

		if(c == 0 || c == until_character)
			goto go_home;

		if(c == '+')        // | http, + means blank
			c = ' ';
		else if(c == '%')   // | http, %AB is hex encoding
			{
			char a;

			w++;
			c = *w;
			if(!c)
				goto go_home;
			c -= '0';
			if(c > 9)
				c = (c & 15) + 9;

			a = *w;
			if(!a)
				goto go_home;
			a -= '0';
			if(a > 9)
				a = (a & 15) + 9;

			c += (a<<4);
			}

		*string_out++ = c;
		w++;
		}
go_home:
	*string_out = 0;
	*wp = w;
	}

// +---------------------------------------------------
// | Extract a single CGI parameter from the arguments
// |
// | URL and arguments are of the form
// |
// |    <url>?<param>=<val>+<param>=<val>...
// |
// | Example:  /controls/index.html?number=300&menu=fish
// |
// | This routine takes that URL and arguments string and
// | pulls out the named parameter into a string you
// | pass in. If you pass NULL for the parameter, it
// | extracts just the URL.
// | If the named parameter is not present, it returns
// | a zero-length string for the value_out.
// |

static void r_get_cgi_param(char *url_and_args,char *parameter, char *value_out)
	{
	char *w;
	char this_param[k_string_length];

	value_out[0] = 0; // assume empty string output

	// | First, advance past url, to the parameters

	w = url_and_args;

	// |
	// | Read the first thing, the URL
	// |

	r_read_string_until(&w,value_out,'?');
	
	// |
	// | parameter=NULL means we wanted the URL
	// | Which we have just found.
	// |

	if(parameter == 0)
		goto go_home;

	// |
	// | Read each param name & param value, and then see if it's
	// | the one we are looking for.
	// |

read_next_param_name:

	// |
	// | *w was left pointing at either 0 or the until_char of last segment
	// |

	value_out[0] = 0;
	if(*w++ == 0)
		goto go_home;

	value_out[0] = 0;

	r_read_string_until(&w,this_param,'=');

	if(*w++ == 0)
		goto go_home;

	r_read_string_until(&w,value_out,'&');

	if(nr_wosfs_string_match(this_param,parameter))
		return;
	
	// |
	// | if not, go up there & try again
	// |

	goto read_next_param_name;

go_home:
	return;
	}

// +-----------------------------------
// | r_printable_string
// |
// | return a char * to the string with
// | all unprintable characters replaced
// | with some oddball symbol. (Uses a
// | static string buffer, so only the
// | most recent result of this function
// | is available.)

static char *r_printable_string(char *s)
	{
	int c;
	static char printable_string[k_string_length];
	int i = 0;

	while((c = *s++) != 0 && i < (k_string_length - 1))
		{
		if(c < 0x20 || c > 0x7e)
			c = 21;
		printable_string[i++] = c;
		}
	printable_string[i] = 0;

	return printable_string;
	}




// end of file

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品成人a区在线观看| 国产日产欧美精品一区二区三区| 91啪亚洲精品| 欧美日韩亚洲丝袜制服| 欧美哺乳videos| 亚洲卡通动漫在线| 青青草一区二区三区| 国产激情一区二区三区四区| 91丝袜美腿高跟国产极品老师| 欧美色大人视频| **网站欧美大片在线观看| 亚洲一级二级在线| 99视频一区二区三区| 日韩欧美国产麻豆| 国产精品久久久久婷婷| 国内久久婷婷综合| 欧美日韩亚洲高清一区二区| 亚洲欧美在线视频观看| 精品一区二区三区不卡| 欧美网站一区二区| 亚洲欧美日韩电影| 国产自产视频一区二区三区| 精品污污网站免费看| 亚洲国产精品激情在线观看| 亚洲一区二区中文在线| 成人性生交大合| 欧美体内she精高潮| 欧美电影精品一区二区| 一区二区三区精品| 国产精品白丝av| 欧美日韩激情在线| 中文字幕亚洲成人| 亚洲福利视频导航| 91麻豆精品在线观看| 欧美激情一区二区在线| 免费久久99精品国产| 欧美三级韩国三级日本一级| 亚洲欧美日韩精品久久久久| av不卡免费电影| 国产精品全国免费观看高清 | www日韩大片| 亚洲日本一区二区| 成人亚洲一区二区一| 久久亚洲综合色| 免费观看久久久4p| 91精品一区二区三区在线观看| 亚洲精品日韩专区silk| eeuss鲁片一区二区三区| 欧美激情综合网| 丰满白嫩尤物一区二区| 久久欧美一区二区| 国产一区二区福利视频| 91蝌蚪porny九色| 欧美日韩高清影院| 日韩毛片在线免费观看| 日本91福利区| 日韩女优av电影在线观看| 裸体在线国模精品偷拍| 精品欧美久久久| 国产一区二区三区四区五区美女| 精品国产人成亚洲区| 国产精品99久久久久久似苏梦涵| 久久久99精品免费观看| 国产成人鲁色资源国产91色综| 国产欧美精品国产国产专区| 久久精品国产澳门| 国产亚洲综合性久久久影院| 成人黄色a**站在线观看| 久久精品在线免费观看| 国产.欧美.日韩| 亚洲日本va在线观看| 欧美性欧美巨大黑白大战| 日本中文字幕一区| 日韩三级av在线播放| 国产精品一区二区黑丝| 久久亚洲春色中文字幕久久久| 国产福利精品一区| 综合色天天鬼久久鬼色| 高清不卡一二三区| 亚洲欧美一区二区三区极速播放 | 国产成人亚洲综合a∨婷婷| 国产欧美日韩中文久久| 国内精品写真在线观看| 国产情人综合久久777777| 99精品1区2区| 美女一区二区视频| 国产精品另类一区| 欧美日本在线观看| 成人一级视频在线观看| 亚洲成年人影院| 国产精品久久久久久久久快鸭| 欧美日韩中文精品| 国产成人午夜精品5599| 亚洲bt欧美bt精品| 国产欧美日本一区视频| 欧美精品日韩一本| 国产成人一区二区精品非洲| 中文字幕中文字幕在线一区| 日本高清不卡在线观看| 国产成人午夜电影网| 午夜视频在线观看一区| 日本一区二区三区久久久久久久久不 | 91麻豆文化传媒在线观看| 久久精品国产一区二区三| 亚洲欧美日韩久久精品| 日韩一区二区三区在线视频| 91女厕偷拍女厕偷拍高清| 日韩电影在线看| 久久久久久久久久久99999| 欧美日本在线播放| 在线观看日韩国产| 99免费精品在线| 日本不卡一区二区三区| 一区二区三区毛片| 国产精品美女视频| 久久综合中文字幕| 91精品免费在线观看| 成人精品视频一区二区三区尤物| 日av在线不卡| 午夜精品久久久久久久久| 亚洲激情av在线| 亚洲欧洲制服丝袜| 中文字幕亚洲视频| 中文字幕在线一区| 26uuu国产一区二区三区| 日本韩国一区二区三区| 91麻豆自制传媒国产之光| 成人av网址在线观看| 成人看片黄a免费看在线| 国产a视频精品免费观看| 国产一区二区三区四区在线观看| 亚洲成av人片一区二区| 中文字幕成人网| 欧美综合一区二区| 在线看国产一区二区| 欧美午夜精品一区二区蜜桃 | 国产精品视频看| 精品国免费一区二区三区| 国产成人av一区二区| 亚洲va国产天堂va久久en| 日韩精品成人一区二区三区| 日韩黄色免费网站| 日韩成人一级片| 精品亚洲成a人在线观看| 韩国成人精品a∨在线观看| 国产美女娇喘av呻吟久久| 美女脱光内衣内裤视频久久影院| 亚洲国产精品久久人人爱| 亚洲激情中文1区| 五月天一区二区| 寂寞少妇一区二区三区| 国产精品18久久久久| 99久久精品国产网站| 色综合久久中文字幕| 欧美理论片在线| 久久久久久久免费视频了| 精品国内二区三区| 国产精品精品国产色婷婷| 日韩欧美一区二区久久婷婷| 欧美成人午夜电影| 成人免费在线视频观看| 午夜激情综合网| 日本va欧美va欧美va精品| 国产.欧美.日韩| 欧美色图一区二区三区| 日韩美女天天操| 国产精品成人免费精品自在线观看 | 免费在线欧美视频| 国产999精品久久| 91福利国产成人精品照片| 欧美精品第1页| 久久精品欧美一区二区三区不卡| 久久综合精品国产一区二区三区| 中文字幕一区二区三中文字幕| 日本一区二区动态图| 天堂资源在线中文精品| 成人精品鲁一区一区二区| 成人av在线看| 欧美亚洲自拍偷拍| 欧美一区二区在线不卡| 国产欧美一区二区三区在线老狼| 在线免费观看一区| 国产伦精品一区二区三区免费迷| 粉嫩13p一区二区三区| 日韩一区二区三区视频在线观看| 国产精品久久久久一区 | 91麻豆国产福利精品| 欧美一区二区三区在线观看| 中文字幕制服丝袜一区二区三区| 日韩高清不卡一区| 久久久久久久综合日本| 国产视频一区在线观看 | 99re这里都是精品| 欧美国产激情二区三区| 久久激五月天综合精品| 欧美日本精品一区二区三区| 最新热久久免费视频| 国产精品一区专区| 精品捆绑美女sm三区| 无码av免费一区二区三区试看 |