lymap.c
来自「基于rtos开发的浏览器!」· C语言 代码 · 共 591 行 · 第 1/2 页
C
591 行
*/PUBLIC BOOL LYHaveImageMap ARGS1( char *, address){ LYImageMap *Map; HTList *cur = LynxMaps; if (!(cur && address && *address != '\0')) return FALSE; while (NULL != (Map = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(Map->address, address)) { return TRUE; } } return FALSE;}/* * Fills in a DocAddress structure for getting the HTParentAnchor of * the underlying resource. ALso returns a pointer to that anchor in * *punderlying if we are dealing with POST data. - kw * * address is the address of the underlying resource, i.e. the one * containing the MAP element, the MAP's name appended as * fragment is ignored. * anAnchor is the LYNXIMGMAP: anchor; if it is associated with POST * data, we want the specific list, otherwise the global list. */PRIVATE void fill_DocAddress ARGS4( DocAddress *, wwwdoc, char *, address, HTParentAnchor *, anAnchor, HTParentAnchor **, punderlying){ HTParentAnchor * underlying; if (anAnchor && anAnchor->post_data) { wwwdoc->address = address; wwwdoc->post_data = anAnchor->post_data; wwwdoc->post_content_type = anAnchor->post_content_type; wwwdoc->bookmark = NULL; wwwdoc->isHEAD = FALSE; wwwdoc->safe = FALSE; underlying = HTAnchor_parent(HTAnchor_findAddress(wwwdoc)); if (underlying->safe) wwwdoc->safe = TRUE; if (punderlying) *punderlying = underlying; } else { wwwdoc->address = address; wwwdoc->post_data = NULL; wwwdoc->post_content_type = NULL; wwwdoc->bookmark = NULL; wwwdoc->isHEAD = FALSE; wwwdoc->safe = FALSE; if (punderlying) *punderlying = NULL; }}/* * Get the appropriate list for creating a LYNXIMGMAP: pseudo- * document: either the global list (LynxMaps), or the specific * list if a List Page for a POST response is requested. Also * fill in the DocAddress structure etc. by calling fill_DocAddress(). * * address is the address of the underlying resource, i.e. the one * containing the MAP element, the MAP's name appended as * fragment is ignored. * anchor is the LYNXIMGMAP: anchor for which LYLoadIMGmap() is * requested; if it is associated with POST data, we want the * specific list for this combination of address+post_data. * * if DONT_TRACK_INTERNAL_LINKS is defined, the Anchor passed to * LYLoadIMGmap() will never have post_data, so that the global list * will be used. - kw */PRIVATE HTList * get_the_list ARGS4( DocAddress *, wwwdoc, char *, address, HTParentAnchor *, anchor, HTParentAnchor **, punderlying){ if (anchor && anchor->post_data) { fill_DocAddress(wwwdoc, address, anchor, punderlying); if (punderlying && *punderlying) return (*punderlying)->imaps; return anchor->imaps; } else { fill_DocAddress(wwwdoc, address, NULL, punderlying); return LynxMaps; }}/* LYLoadIMGmap - F.Macrides (macrides@sci.wfeb.edu)** ------------** Create a text/html stream with a list of links** for HyperText References in AREAs of a MAP.*/PRIVATE int LYLoadIMGmap ARGS4 ( CONST char *, arg, HTParentAnchor *, anAnchor, HTFormat, format_out, HTStream*, sink){ HTFormat format_in = WWW_HTML; HTStream *target = NULL; char buf[1024]; LYMapElement *new = NULL; LYImageMap *theMap = NULL; char *MapTitle = NULL; char *MapAddress = NULL; HTList *theList; HTList *cur = NULL; char *address = NULL; char *cp = NULL; DocAddress WWWDoc; HTParentAnchor * underlying; BOOL old_cache_setting = LYforce_no_cache; BOOL old_reloading = reloading; HTFormat old_format_out = HTOutputFormat; if (!strncasecomp(arg, "LYNXIMGMAP:", 11)) { address = (char * )(arg + 11); } if (!(address && strchr(address, ':'))) { HTAlert(MISDIRECTED_MAP_REQUEST); return(HT_NOT_LOADED); } theList = get_the_list(&WWWDoc, address, anAnchor, &underlying); if (WWWDoc.safe) anAnchor->safe = TRUE; if (!theList) { if (anAnchor->post_data && !WWWDoc.safe && ((underlying && underlying->document && !LYforce_no_cache) || HTConfirm(#if __STDC__ "LYNXIMGMAP: "#endif CONFIRM_POST_RESUBMISSION) != TRUE)) { HTAlert("Image map from POST response not available!"); return(HT_NOT_LOADED); } LYforce_no_cache = TRUE; reloading = TRUE; HTOutputFormat = WWW_PRESENT; LYMapsOnly = TRUE; if (!HTLoadAbsolute(&WWWDoc)) { LYforce_no_cache = old_cache_setting; reloading = old_reloading; HTOutputFormat = old_format_out; LYMapsOnly = FALSE; HTAlert(MAP_NOT_ACCESSIBLE); return(HT_NOT_LOADED); } LYforce_no_cache = old_cache_setting; reloading = old_reloading; HTOutputFormat = old_format_out; LYMapsOnly = FALSE; theList = get_the_list(&WWWDoc, address, anAnchor, &underlying); } if (!theList) { HTAlert(MAPS_NOT_AVAILABLE); return(HT_NOT_LOADED); } cur = theList; while (NULL != (theMap = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(theMap->address, address)) { break; } } if (!(theMap && theMap->elements)) { if (anAnchor->post_data && !WWWDoc.safe && ((underlying && underlying->document && !LYforce_no_cache) || HTConfirm(#if __STDC__ "LYNXIMGMAP: "#endif CONFIRM_POST_RESUBMISSION) != TRUE)) { HTAlert("Image map from POST response not available!"); return(HT_NOT_LOADED); } LYforce_no_cache = TRUE; reloading = TRUE; HTOutputFormat = WWW_PRESENT; LYMapsOnly = TRUE; if (!HTLoadAbsolute(&WWWDoc)) { LYforce_no_cache = old_cache_setting; reloading = old_reloading; HTOutputFormat = old_format_out; LYMapsOnly = FALSE; HTAlert(MAP_NOT_ACCESSIBLE); return(HT_NOT_LOADED); } LYforce_no_cache = old_cache_setting; reloading = old_reloading; HTOutputFormat = old_format_out; LYMapsOnly = FALSE; cur = get_the_list(&WWWDoc, address, anAnchor, &underlying); while (NULL != (theMap = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(theMap->address, address)) { break; } } if (!(theMap && theMap->elements)) { HTAlert(MAP_NOT_AVAILABLE); return(HT_NOT_LOADED); } }#ifdef DONT_TRACK_INTERNAL_LINKS anAnchor->no_cache = TRUE;#endif target = HTStreamStack(format_in, format_out, sink, anAnchor); if (!target || target == NULL) { sprintf(buf, CANNOT_CONVERT_I_TO_O, HTAtom_name(format_in), HTAtom_name(format_out)); HTAlert(buf); return(HT_NOT_LOADED); } if (theMap->title && *theMap->title) { StrAllocCopy(MapTitle, theMap->title); } else if (anAnchor->title && *anAnchor->title) { StrAllocCopy(MapTitle, anAnchor->title); } else if (LYRequestTitle && *LYRequestTitle && strcasecomp(LYRequestTitle, "[USEMAP]")) { StrAllocCopy(MapTitle, LYRequestTitle); } else if ((cp=strrchr(address, '#')) != NULL) { StrAllocCopy(MapTitle, (cp+1)); } if (!(MapTitle && *MapTitle)) { StrAllocCopy(MapTitle, "[USEMAP]"); } else { LYEntify(&MapTitle, TRUE); } sprintf(buf,"<head>\n<title>%s</title>\n</head>\n<body>\n", MapTitle); (*target->isa->put_block)(target, buf, strlen(buf)); sprintf(buf,"<h1><em>%s</em></h1>\n", MapTitle); (*target->isa->put_block)(target, buf, strlen(buf)); StrAllocCopy(MapAddress, address); LYEntify(&MapAddress, FALSE); sprintf(buf,"<h2><em>MAP:</em> %s</h2>\n", MapAddress); (*target->isa->put_block)(target, buf, strlen(buf)); sprintf(buf, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); (*target->isa->put_block)(target, buf, strlen(buf)); cur = theMap->elements; while (NULL != (new=(LYMapElement *)HTList_nextObject(cur))) { StrAllocCopy(MapAddress, new->address); LYEntify(&MapAddress, FALSE); (*target->isa->put_block)(target, "<li><a href=\"", 13); (*target->isa->put_block)(target, MapAddress, strlen(MapAddress));#ifndef DONT_TRACK_INTERNAL_LINKS if (new->intern_flag) (*target->isa->put_block)(target, "\" TYPE=\"internal link\"\n>",24); else#endif (*target->isa->put_block)(target, "\"\n>", 3); StrAllocCopy(MapTitle, new->title); LYEntify(&MapTitle, TRUE); (*target->isa->put_block)(target, MapTitle, strlen(MapTitle)); (*target->isa->put_block)(target, "</a>\n", 5); } sprintf(buf,"</%s>\n</body>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? "ol" : "ul")); (*target->isa->put_block)(target, buf, strlen(buf)); (*target->isa->_free)(target); FREE(MapAddress); FREE(MapTitle); return(HT_LOADED);}#ifdef GLOBALDEF_IS_MACRO#define _LYIMGMAP_C_GLOBALDEF_1_INIT { "LYNXIMGMAP", LYLoadIMGmap, 0}GLOBALDEF (HTProtocol,LYLynxIMGmap,_LYIMGMAP_C_GLOBALDEF_1_INIT);#elseGLOBALDEF PUBLIC HTProtocol LYLynxIMGmap = {"LYNXIMGMAP", LYLoadIMGmap, 0};#endif /* GLOBALDEF_IS_MACRO */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?