PRIVATE Robot * Robot_new (void) { Robot * me; if ((me = (Robot *) HT_CALLOC(1, sizeof(Robot))) == NULL || (me->tv = (struct timeval*) HT_CALLOC(1, sizeof(struct timeval))) == NULL) HT_OUTOFMEM("Robot_new"); me->htext = 0; me->tv->tv_sec = DEFAULT_TIMEOUT; me->cwd = HTGetCurrentDirectoryURL(); me->output = OUTPUT; me->urilist = HTList_new(); me->count = 0; /* We keep an extra timeout request object for the timeout_handler */ me->timeout = HTRequest_new(); /* Bind the Robot object together with the Request Object */ me->request = HTRequest_new(); HTRequest_setContext (me->request, me); HTRequest_setPreemptive(me->request, YES); /* Make a new profile */ HTProfile_newPreemptiveRobot ("w3clibtcl", "1.0"); return me; }
CWinComDoc::CWinComDoc() { CWinComApp * pApp = (CWinComApp *) AfxGetApp(); ASSERT(pApp != NULL); m_cwd = HTGetCurrentDirectoryURL(); m_detectVersionConflict = pApp->GetIniDetectVersionConflict(); m_showServerStatus = pApp->GetIniShowServerStatus(); }
int main (int argc, char ** argv) { char * uri = NULL; char * cwd = HTGetCurrentDirectoryURL(); /* Create a new premptive client */ HTProfile_newHTMLNoCacheClient ("ParseRDF", "1.0"); /* Need our own trace and print functions */ HTPrint_setCallback(printer); HTTrace_setCallback(tracer); /* Set trace messages */ #if 0 HTSetTraceMessageMask("sopx"); #endif /* Add our own termination filter */ HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST); /* Setup a timeout on the request for 15 secs */ HTHost_setEventTimeout(15000); /* Handle command line args */ if (argc >= 2) uri = HTParse(argv[1], cwd, PARSE_ALL); HT_FREE(cwd); /* Set up our RDF To Triple conveter stream */ HTFormat_addConversion("text/rdf", "*/*", HTRDFParser_new, 1.0, 0.0, 0.0); /* Set our new RDF parser instance callback */ HTRDF_registerNewParserCallback (new_parser_handler, NULL); if (uri) { HTRequest * request = HTRequest_new(); HTAnchor * anchor = HTAnchor_findAddress(uri); BOOL status = NO; /* Start the GET request */ status = HTLoadAnchor(anchor, request); /* Go into the event loop... */ if (status == YES) HTEventList_loop(request); } else { HTPrint("Type the URI to parse\n"); HTPrint("\t%s <uri>\n", argv[0]); HTPrint("For example:\n"); HTPrint("\t%s http://www.yoursite.com/your.rdf\n", argv[0]); } return 0; }
/* BINDINGS BETWEEN ICONS AND MEDIA TYPES ** -------------------------------------- ** Not done automaticly - may be done by application! ** For directory listings etc. you can bind a set of icons to a set of ** media types and special icons for directories and other objects that ** do not have a media type. */ PUBLIC void HTIconInit (const char * url_prefix) { const char * prefix = url_prefix ? url_prefix : ICON_LOCATION; HTIcon_deleteAll(); /* Start fresh */ HTIcon_addBlank("blank.xbm", prefix, NULL); HTIcon_addDir("directory.xbm", prefix, "DIR"); HTIcon_addParent("back.xbm", prefix, "UP"); HTIcon_addUnknown("unknown.xbm", prefix, NULL); HTIcon_add("unknown.xbm", prefix, NULL, "*/*"); HTIcon_add("binary.xbm", prefix, "BIN", "binary"); HTIcon_add("unknown.xbm", prefix, NULL, "www/unknown"); HTIcon_add("text.xbm", prefix, "TXT", "text/*"); HTIcon_add("image.xbm", prefix, "IMG", "image/*"); HTIcon_add("movie.xbm", prefix, "MOV", "video/*"); HTIcon_add("sound.xbm", prefix, "AU", "audio/*"); HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-tar"); HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-gtar"); HTIcon_add("compressed.xbm",prefix, "CMP", "x-compress"); HTIcon_add("compressed.xbm",prefix, "GZP", "x-gzip"); HTIcon_add("index.xbm", prefix, "IDX", "application/x-gopher-index"); HTIcon_add("index2.xbm", prefix, "CSO", "application/x-gopher-cso"); HTIcon_add("telnet.xbm", prefix, "TEL", "application/x-gopher-telnet"); HTIcon_add("unknown.xbm", prefix, "DUP", "application/x-gopher-duplicate"); HTIcon_add("unknown.xbm", prefix, "TN", "application/x-gopher-tn3270"); /* Add global mapping to where to find the internal icons */ { char * curdir = HTGetCurrentDirectoryURL(); char * virtual = HTParse(ICON_LOCATION, curdir, PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION); char * physical = NULL; StrAllocCat(virtual, "*"); { char * str = NULL; if ((str = (char *) HT_MALLOC(strlen(W3C_ICONS) + 4)) == NULL) HT_OUTOFMEM("HTIconInit"); strcpy(str, W3C_ICONS); if (*(str + strlen(str) - 1) != '/') strcat(str, "/"); strcat(str, "*"); physical = HTParse(str, curdir, PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION); HT_FREE(str); } HTRule_addGlobal(HT_Pass, virtual, physical); HT_FREE(virtual); HT_FREE(physical); HT_FREE(curdir); } }
/* Create a Command Line Object ** ---------------------------- */ PRIVATE ComLine * ComLine_new (void) { ComLine * me; if ((me = (ComLine *) HT_CALLOC(1, sizeof(ComLine))) == NULL) HT_OUTOFMEM("ComLine_new"); me->timer = DEFAULT_TIMEOUT*MILLIES; me->cwd = HTGetCurrentDirectoryURL(); me->output = OUTPUT; /* Bind the ConLine object together with the Request Object */ me->request = HTRequest_new(); HTRequest_setOutputFormat(me->request, DEFAULT_FORMAT); HTRequest_setContext (me->request, me); return me; }
int main (int argc, char ** argv) { HTRequest * request = NULL; HTAnchor * src = NULL; HTAnchor * dst = NULL; char * src_str = NULL; char * dst_str = NULL; BOOL status = NO; /* Create a new premptive client */ HTProfile_newNoCacheClient("libwww-PUT", "1.0"); /* Need our own trace and print functions */ HTPrint_setCallback(printer); HTTrace_setCallback(tracer); /* And the traces... */ #if 0 HTSetTraceMessageMask("sop"); #endif /* Add our own filter to update the history list */ HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST); /* Handle command line args */ if (argc >= 3) { src_str = argv[1]; dst_str = argv[2]; } else { HTPrint("Type the URI of the source and the URI of the destination.\n"); HTPrint("\t%s <src> <dst>\n", argv[0]); HTPrint("For example, %s http://www.w3.org http://myserver/destination.html\n", argv[0]); return -1; } if (src_str && *src_str && dst_str && *dst_str) { /* Make source relative to where we are */ char * cwd = HTGetCurrentDirectoryURL(); char * full_src_str = HTParse(src_str, cwd, PARSE_ALL); HTPrint("Saving %s to %s\n", full_src_str, dst_str); /* Create a request */ request = HTRequest_new(); /* Get an anchor object for the src and dest URIs */ src = HTAnchor_findAddress(full_src_str); dst = HTAnchor_findAddress(dst_str); /* PUT the source to the dest */ status = HTPutDocumentAnchor(HTAnchor_parent(src), dst, request); /* We don't need these anymore */ HT_FREE(cwd); HT_FREE(full_src_str); /* Go into the event loop... */ if (status == YES) HTEventList_loop(request); } return 0; }
int main (int argc, char ** argv) { HTRequest * request = NULL; HTParentAnchor * src = NULL; HTAnchor * dst = NULL; char * dst_str = NULL; char * data = NULL; BOOL status = NO; /* Create a new premptive client */ HTProfile_newNoCacheClient("libwww-POST", "1.0"); /* Need our own trace and print functions */ HTPrint_setCallback(printer); HTTrace_setCallback(tracer); /* Add our own filter to update the history list */ HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST); /* Handle command line args */ if (argc >= 3) { dst_str = argv[1]; data = argv[2]; } else { HTPrint("Type the URI of the destination you want to POST to and the contents that you want to post.\n"); HTPrint("\t%s <destination> <data>\n", argv[0]); HTPrint("For example, %s http://myserver/destination.html \"This is some testdata\"\n", argv[0]); return -1; } if (data && *data && dst_str && *dst_str) { /* Make source relative to where we are */ char * cwd = HTGetCurrentDirectoryURL(); HTPrint("Posting to %s\n", dst_str); /* Create a request */ request = HTRequest_new(); /* Get an anchor object for the destination URI */ dst = HTAnchor_findAddress(dst_str); /* ** Dream up a source anchor (an editor can for example use this). ** After creation we associate the data that we want to post and ** set some metadata about what the data is. More formats can be found ** ../src/HTFormat.html */ src = HTTmpAnchor(NULL); HTAnchor_setDocument(src, data); HTAnchor_setFormat(src, WWW_PLAINTEXT); /* ** If not posting to an HTTP/1.1 server then content length MUST be ** there. If HTTP/1.1 then it doesn't matter as we just use chunked ** encoding under the covers */ HTAnchor_setLength(src, strlen(data)); /* POST the source to the dest */ status = HTPostAnchor(src, dst, request); /* We don't need these anymore */ HT_FREE(cwd); /* Go into the event loop... */ if (status == YES) HTEventList_loop(request); } return 0; }