时间: 2021-07-31 作者:daque
记委派户记载剧本//以次是mas_res步调#include "t99_type.h"#include #include #include #include #include #include #include #include "parse.h"#include "parse.cpp"#include "mas_cvo.cpp"void write_log_entry( char[], char[] );void cgi_var_output();char* getenv_n( char [] );void gif_output( char [] );int main(){char *query_str = getenv("query_string");parse list( query_str == 0 ? (char*)"file=mas&page=test&" : query_str );if ( list.get_item( "file" ) != null ){write_log_entry( list.get_item_n( "file", 1, true ),list.get_item_n( "page" ) );}if ( list.get_item( "img" ) != null ){gif_output( list.get_item_n("img", 1, true) );} else {html("content-type: text/html"); html("");cgi_var_output(); // debug option}return 0;} void write_log_entry( char file[], char page[] ){//cout << "file = [" << file << "] page = [" << page << "]" << "\n";//cout.flush();ofstream inf( file, ios::app );//inf.open( file, ios::out );if ( !inf.fail() ){time_t t;time( &t);char *str = ctime( &t ); str[24] = '\0';inf << setiosflags( ios::left );inf << setw(24) << str << " " <<setw(10) << (page!=null? page : (char*)"unknown" ) << " " <<setw(18) << getenv_n("remote_addr") << " " <<setw(20) << getenv_n("remote_host") << "\n";// setw(20) << getenv_n("remote_user") << "\n";}}void gif_output( char gif[] ){char square [] = {'g', 'i', 'f', '8', '9', 'a', 0002, 0000, 0002, 0000, 0263, 0000, 0000, 0000, 0000, 0000,0277, 0000, 0000, 0000, 0277, 0000, 0277, 0277,0000, 0000, 0000, 0277, 0277, 0000, 0277, 0000,0277, 0277, 0300, 0300, 0300, 0200, 0200, 0200,0377, 0000, 0000, 0000, 0377, 0000, 0377, 0377,0000, 0000, 0000, 0377, 0377, 0000, 0377, 0000,0377, 0377, 0377, 0377, 0377, 0054, 0000, 0000,0000, 0000, 0002, 0000, 0002, 0000, 0100, 0004,0003, 0020, 0200, 0010, 0000, 0073 };html("content-type: image/gif"); html("");if ( gif[0] != '\0' ) // 输入gif文献{ifstream in( gif );if ( !in.fail() ) { char c;in.read( &c, 1 );while ( !in.eof() ){cout.write( &c, 1 );in.read( &c, 1 );}return; // 中断}}cout.write( square, (int) sizeof( square ) );} 固然,网页的欣赏器必需是扶助欣赏图片以及承载图片的。几个不许承载图片的来由是: 欣赏器不扶助图片欣赏; 用户仍旧废除对欣赏图片的选项,由于要加块贯穿搜集效劳器的速率; 效劳器件接受到归来图片的乞求。