chunk.c

来自「www工具包」· C语言 代码 · 共 57 行

C
57
字号
#include "WWWLib.h"#include "WWWHTTP.h"#include "WWWInit.h"PRIVATE int tracer (const char * fmt, va_list pArgs){    return (vfprintf(stderr, fmt, pArgs));}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 */    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", "");    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 = HTChunk_toCString(chunk);	    printf("%s", string ? string : "no text");	    HT_FREE(string);	}    } else {	printf("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 + =
减小字号Ctrl + -
显示快捷键?