Esempio n. 1
0
/*	Link me Anchor to another given one
**	-------------------------------------
*/
PUBLIC BOOL HTLink_add (HTAnchor *	source,
                        HTAnchor * 	destination,
                        HTLinkType	type,
                        HTMethod	method)
{
    if (source && destination) {
        HTTRACE(ANCH_TRACE, "Link create. from anchor %p to %p with type %s, method %s\n" _
                (void *) source _ (void *) destination _
                type ? HTAtom_name(type) : "NONE" _
                method != METHOD_INVALID ? HTMethod_name(method) : "NONE");
        if (!source->mainLink.dest) {
            source->mainLink.dest = destination;
            source->mainLink.type = type;
            source->mainLink.method = method;
        } else {
            HTLink * newLink = HTLink_new();
            newLink->dest = destination;
            newLink->type = type;
            newLink->method = method;
            if (!source->links) source->links = HTList_new();
            HTList_addObject (source->links, newLink);
        }
        if (!destination->parent->sources)
            destination->parent->sources = HTList_new();
        HTList_addObject (destination->parent->sources, source);
        return YES;
    } else
        HTTRACE(ANCH_TRACE, "Link........ Bad argument\n");
    return NO;
}
Esempio n. 2
0
PUBLIC BOOL HTAnchor_setMainLink  (HTAnchor * me, HTLink * movingLink)
{
    if (!(me && me->links && movingLink &&
	  HTList_removeObject(me->links, movingLink)))
	return NO;
    else {
	/* First push current main link onto top of links list */
	HTLink * newLink = HTLink_new();
	memcpy ((void *) newLink, & me->mainLink, sizeof (HTLink));
	HTList_addObject (me->links, newLink);

	/* Now make movingLink the new main link, and delete it */
	memcpy ((void *) &me->mainLink, movingLink, sizeof (HTLink));
	HTLink_delete(movingLink);
	return YES;
    }
}