⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chunk.c

📁 www工具包. 这是W3C官方支持的www支撑库. 其中提供通用目的的客户端的WebAPI: complete HTTP/1.1 (with caching, pipelining, PUT, POS
💻 C
字号:
#include "WWWLib.h"#include "WWWHTTP.h"#include "WWWInit.h"PRIVATE int printer (const char * fmt, va_list pArgs){    return (vfprintf(stdout, fmt, pArgs));}PRIVATE int tracer (const char * fmt, va_list pArgs){    return (vfprintf(stderr, fmt, pArgs));}PRIVATE int terminate_handler (HTRequest * request, HTResponse * response,			       void * param, int status) {    /* Check for status */    HTPrint("Load resulted in status %d\n", status);		/* we're not handling other requests */	HTEventList_stopLoop (); 	/* stop here */    return HT_ERROR;}int main (int argc, char ** argv){    HTRequest * request = HTRequest_new();    HTChunk * chunk = NULL;    char * url = argc==2 ? argv[1] : NULL;    /* Initialize libwww core */    HTProfile_newPreemptiveClient("TestApp", "1.0");    /* Gotta set up our own traces */    HTPrint_setCallback(printer);    HTTrace_setCallback(tracer);    /* Turn on TRACE so we can see what is going on */#if 0    HTSetTraceMessageMask("sop");#endif    /* We want raw output including headers */    HTRequest_setOutputFormat(request, WWW_RAW);    /* Close connection immediately */    HTRequest_addConnection(request, "close", "");    /* Add our own filter to handle termination */    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);    if (url) {	char * cwd = HTGetCurrentDirectoryURL();	char * absolute_url = HTParse(url, cwd, PARSE_ALL);	chunk = HTLoadToChunk(absolute_url, request);	HT_FREE(absolute_url);	HT_FREE(cwd);	/* If chunk != NULL then we have the data */	if (chunk) {	    char * string;	    /* Go into the event loop... */	    HTEventList_loop(request);	    /* print the chunk result */	    string = HTChunk_toCString(chunk);	    HTPrint("%s", string ? string : "no text");	    HT_FREE(string);	}    } else {	HTPrint("Type the URL you want to accces on the command line\n");    }	    /* Clean up the request */    HTRequest_delete(request);    /* Terminate the Library */    HTProfile_delete();    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -