📄 htanchor.c
字号:
if (!HTList_isEmpty(parent->sources)) { /* * Really should only need to deregister once. */ HTList_removeObject(parent->sources, (void *)me); } /* * Test here to avoid calling overhead. * If the parent has no loaded document, then we should * tell it to attempt to delete itself. * Don't do this jazz if the anchor passed in is the same * as the anchor to delete. * Also, don't do this if the destination parent is our * parent. */ if (!parent->document && parent != (HTParentAnchor *)me && me->parent != parent) { HTAnchor_delete(parent); } /* * At this point, we haven't a mainLink. Set it to be * so. * Leave the HTAtom pointed to by type up to other code to * handle (reusable, near static). */ me->mainLink.type = NULL; } /* * Check for extra destinations in our links list. */ if (!HTList_isEmpty(me->links)) { HTLink *target; HTParentAnchor *parent; /* * Take out our extra non mainLinks one by one, calling * their parents to know that they are no longer * the destination of me's anchor. */ while ((target = (HTLink *)HTList_removeLastObject(me->links)) != 0) { parent = target->dest->parent; if (!HTList_isEmpty(parent->sources)) { /* * Only need to tell destination parent * anchor once. */ HTList_removeObject(parent->sources, (void *)me); } /* * Avoid calling overhead. * If the parent hasn't a loaded document, then * we will attempt to have the parent * delete itself. * Don't call twice if this is the same anchor * that we are trying to delete. * Also, don't do this if we are trying to delete * our parent. */ if (!parent->document && (HTParentAnchor *)me != parent && me->parent != parent) { HTAnchor_delete(parent); } /* * The link structure has to be deleted, too! * That was missing, but this code probably never * got exercised by Lynx. - KW */ FREE(target); } /* * At this point, me no longer has any destination in * the links list. Get rid of it. */ if (me->links) { HTList_delete(me->links); me->links = NULL; } } /* * Catch in case links list exists but nothing in it. */ if (me->links) { HTList_delete(me->links); me->links = NULL; }}#ifdef SOURCE_CACHEPUBLIC void HTAnchor_clearSourceCache ARGS1( HTParentAnchor *, me){ /* * Clean up the source cache, if any. */ if (me->source_cache_file) { CTRACE((tfp, "SourceCache: Removing file %s\n", me->source_cache_file)); LYRemoveTemp(me->source_cache_file); FREE(me->source_cache_file); } if (me->source_cache_chunk) { CTRACE((tfp, "SourceCache: Removing memory chunk %p\n", (void *)me->source_cache_chunk)); HTChunkFree(me->source_cache_chunk); me->source_cache_chunk = NULL; }}#endif /* SOURCE_CACHE */PUBLIC BOOL HTAnchor_delete ARGS1( HTParentAnchor *, me){ /* * Memory leaks fixed. * 05-27-94 Lynx 2-3-1 Garrett Arch Blythe */ HTList *cur; HTChildAnchor *child; /* * Do nothing if nothing to do. */ if (!me) { return(NO); } /* * Don't delete if document is loaded or being loaded. */ if (me->document || me->underway) { return(NO); } /* * Mark ourselves busy, so that recursive calls of this function * on this HTParentAnchor will not free it from under our feet. - kw */ me->underway = TRUE; /* * Recursively try to delete destination anchors of this parent. * In any event, this will tell all destination anchors that we * no longer consider them a destination. */ deleteLinks((HTAnchor *)me); /* * There are still incoming links to this one (we are the * destination of another anchor). * Don't actually delete this anchor, but children are OK to * delete their links. */ if (!HTList_isEmpty(me->sources)) { /* * Delete all outgoing links from children, do not * delete the children, though. */ if (!HTList_isEmpty(me->children)) { cur = me->children; while ((child = (HTChildAnchor *)HTList_nextObject(cur)) != 0) { if (child != NULL) { deleteLinks((HTAnchor *)child); } } } me->underway = FALSE; /* * Can't delete parent, still have sources. */ return(NO); } /* * No more incoming links : kill everything * First, recursively delete children and their links. */ if (!HTList_isEmpty(me->children)) { while ((child = (HTChildAnchor *)HTList_removeLastObject( me->children)) != 0) { if (child) { deleteLinks((HTAnchor *)child); if (child->tag) { FREE(child->tag); } FREE(child); } } } me->underway = FALSE; /* * Delete our empty list of children. */ if (me->children) { HTList_delete(me->children); me->children = NULL; } /* * Delete our empty list of sources. */ if (me->sources) { HTList_delete(me->sources); me->sources = NULL; } /* * Delete the methods list. */ if (me->methods) { /* * Leave what the methods point to up in memory for * other code (near static stuff). */ HTList_delete(me->methods); me->methods = NULL; } /* * Free up all allocated members. */ FREE(me->charset); FREE(me->isIndexAction); FREE(me->isIndexPrompt); FREE(me->title); FREE(me->physical); FREE(me->post_data); FREE(me->post_content_type); FREE(me->bookmark); FREE(me->owner); FREE(me->RevTitle); FREE(me->citehost);#ifdef SOURCE_CACHE HTAnchor_clearSourceCache(me);#endif if (me->FileCache) { FILE *fd; if ((fd = fopen(me->FileCache, "r")) != NULL) { fclose(fd); remove(me->FileCache); } FREE(me->FileCache); } FREE(me->SugFname); FREE(me->cache_control); FREE(me->content_type); FREE(me->content_language); FREE(me->content_encoding); FREE(me->content_base); FREE(me->content_disposition); FREE(me->content_location); FREE(me->content_md5); FREE(me->message_id); FREE(me->subject); FREE(me->date); FREE(me->expires); FREE(me->last_modified); FREE(me->ETag); FREE(me->server);#ifdef USE_COLOR_STYLE FREE(me->style);#endif /* * Remove ourselves from the hash table's list. */ if (adult_table) { unsigned short usi_hash = (unsigned short) HASH_FUNCTION(me->address); if (adult_table[usi_hash]) { HTList_removeObject(adult_table[usi_hash], (void *)me); } } /* * Original code wanted a way to clean out the HTFormat if no * longer needed (ref count?). I'll leave it alone since * those HTAtom objects are a little harder to know where * they are being referenced all at one time. (near static) */ /* * Free the address. */ FREE(me->address); FREE (me->UCStages); ImageMapList_free(me->imaps); /* * Finally, kill the parent anchor passed in. */ FREE(me); return(YES);}/* Move an anchor to the head of the list of its siblings** ------------------------------------------------------**** This is to ensure that an anchor which might have already existed** is put in the correct order as we load the document.*/PUBLIC void HTAnchor_makeLastChild ARGS1( HTChildAnchor *, me){ if (me->parent != (HTParentAnchor *)me) { /* Make sure it's a child */ HTList * siblings = me->parent->children; HTList_removeObject (siblings, me); HTList_addObject (siblings, me); }}/* Data access functions** ---------------------*/PUBLIC HTParentAnchor * HTAnchor_parent ARGS1( HTAnchor *, me){ return( me ? me->parent : NULL);}PUBLIC void HTAnchor_setDocument ARGS2( HTParentAnchor *, me, HyperDoc *, doc){ if (me) me->document = doc;}PUBLIC HyperDoc * HTAnchor_document ARGS1( HTParentAnchor *, me){ return( me ? me->document : NULL);}PUBLIC char * HTAnchor_address ARGS1( HTAnchor *, me){ char *addr = NULL; if (me) { if (((HTParentAnchor *)me == me->parent) || !((HTChildAnchor *)me)->tag) { /* it's an adult or no tag */ StrAllocCopy(addr, me->parent->address); } else { /* it's a named child */ HTSprintf0(&addr, "%s#%s", me->parent->address, ((HTChildAnchor *)me)->tag); } } return(addr);}PUBLIC void HTAnchor_setFormat ARGS2( HTParentAnchor *, me, HTFormat, form){ if (me) me->format = form;}PUBLIC HTFormat HTAnchor_format ARGS1( HTParentAnchor *, me){ return( me ? me->format : NULL);}PUBLIC void HTAnchor_setIndex ARGS2( HTParentAnchor *, me, char *, address){ if (me) { me->isIndex = YES; StrAllocCopy(me->isIndexAction, address); }}PUBLIC void HTAnchor_setPrompt ARGS2( HTParentAnchor *, me, char *, prompt){ if (me) { StrAllocCopy(me->isIndexPrompt, prompt); }}PUBLIC BOOL HTAnchor_isIndex ARGS1( HTParentAnchor *, me){ return( me ? me->isIndex : NO);}/* Whether Anchor has been designated as an ISMAP link** (normally by presence of an ISMAP attribute on A or IMG) - KW*/PUBLIC BOOL HTAnchor_isISMAPScript ARGS1( HTAnchor *, me){ return( me ? me->parent->isISMAPScript : NO);}PUBLIC BOOL HTAnchor_hasChildren ARGS1( HTParentAnchor *, me){ return (BOOL) ( me ? ! HTList_isEmpty(me->children) : NO);}#if defined(USE_COLOR_STYLE)/* Style handling.*/PUBLIC CONST char * HTAnchor_style ARGS1( HTParentAnchor *, me){ return( me ? me->style : NULL);}PUBLIC void HTAnchor_setStyle ARGS2( HTParentAnchor *, me, CONST char *, style){ if (me) { StrAllocCopy(me->style, style); }}#endif/* Title handling.*/PUBLIC CONST char * HTAnchor_title ARGS1( HTParentAnchor *, me){ return( me ? me->title : NULL);}PUBLIC void HTAnchor_setTitle ARGS2( HTParentAnchor *, me, CONST char *, title){ int i; if (me) { if (title) { StrAllocCopy(me->title, title); for (i = 0; me->title[i]; i++) { if (UCH(me->title[i]) == 1 || UCH(me->title[i]) == 2) { me->title[i] = ' '; } } } else { CTRACE((tfp,"HTAnchor_setTitle: New title is NULL! ")); if (me->title) { CTRACE((tfp,"Old title was \"%s\".\n", me->title)); FREE(me->title); } else { CTRACE((tfp,"Old title was NULL.\n")); } } }}PUBLIC void HTAnchor_appendTitle ARGS2( HTParentAnchor *, me, CONST char *, title){ int i; if (me) { StrAllocCat(me->title, title); for (i = 0; me->title[i]; i++) { if (UCH(me->title[i]) == 1 || UCH(me->title[i]) == 2) { me->title[i] = ' '; } } }}/* Bookmark handling.*/PUBLIC CONST char * HTAnchor_bookmark ARGS1( HTParentAnchor *, me){ return( me ? me->bookmark : NULL);}PUBLIC void HTAnchor_setBookmark ARGS2( HTParentAnchor *, me, CONST char *, bookmark){ if (me) StrAllocCopy(me->bookmark, bookmark);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -