int postURL_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { if (argc == 3) { char *url = argv[1]; char *dest = argv[2]; if (url && dest) { HTParentAnchor *source = (HTParentAnchor *) HTAnchor_findAddress(url); HTRequest *req = HTRequest_new(); HTChunk *chunk = HTChunk_new(0x2000); HTStream *stream = HTStreamToChunk(req, &chunk, 0); BOOL work; HTRequest_setOutputFormat(req, DEFAULT_FORMAT); HTRequest_setOutputStream(req, stream); HTRequest_setPreemptive(req, YES); work = HTPostAbsolute (source, dest, req); Tcl_AppendResult(interp, work ? "YES" : "NO", HTChunkData(chunk), NULL); HT_FREE(url); HTRequest_kill(req); HTAnchor_delete(source); HT_FREE(stream); HTChunkFree(chunk); return TCL_OK; } Tcl_AppendResult(interp, bad_vars, NULL); return TCL_ERROR; } else { Tcl_AppendResult(interp, err_string, argv[0], " url destination", NULL); return TCL_ERROR; } }
PRIVATE void delete_links (HTAnchor * me) { if (! me) return; /* Recursively try to delete target anchors */ if (me->mainLink.dest) { HTParentAnchor *parent = me->mainLink.dest->parent; HTList_removeObject (parent->sources, me); if (! parent->document) /* Test here to avoid calling overhead */ HTAnchor_delete (parent); } if (me->links) { /* Extra destinations */ HTLink *target; while ((target = (HTLink *) HTList_removeLastObject (me->links))) { HTParentAnchor *parent = target->dest->parent; HTList_removeObject (parent->sources, me); if (! parent->document) /* Test here to avoid calling overhead */ HTAnchor_delete (parent); } } }
/* * Recursively try to delete destination anchor of this child. * In any event, this will tell destination anchor that we * no longer consider it a destination. */ PRIVATE void deleteLinks ARGS1( HTChildAnchor *, me) { /* * Unregister me with our destination anchor's parent. */ if (me->dest) { HTParentAnchor0 *parent = me->dest->parent; /* * Start. Set the dest pointer to zero. */ me->dest = NULL; /* * Remove me from the parent's sources so that the * parent knows one less anchor is its dest. */ if ((me->parent != parent) && !HTList_isEmpty(&parent->sources)) { /* * Really should only need to deregister once. */ HTList_unlinkObject(&parent->sources, (void *)me); } /* * Recursive call. * Test here to avoid calling overhead. * Don't delete if document is loaded or being loaded. */ if ((me->parent != parent) && !parent->underway && (!parent->info || !parent->info->document)) { HTAnchor_delete(parent); } /* * At this point, we haven't a destination. Set it to be * so. * Leave the HTAtom pointed to by type up to other code to * handle (reusable, near static). */ me->type = NULL; } }