Пример #1
0
/*
**	When deleting a channel we first look at if there are no more requests
**	using the channel (the semaphore is <= 0). Then, if the socket supports
**	persistent connections then we register the channel in the Host cache
**	and wait until the other end closes it or we get a time out on our side
*/
PUBLIC BOOL HTChannel_delete (HTChannel * channel, int status)
{
    if (channel) {
        HTTRACE(PROT_TRACE, "Channel..... Delete %p with semaphore %d, status %d\n" _
                channel _ channel->semaphore _ status);
        /*
        **  We call the free methods on both the input stream and the output
        **  stream so that we can free up the stream pipes. However, note that
        **  this doesn't mean that we close the input stream and output stream
        **  them selves - only the generic streams
        */
        HTChannel_deleteInput(channel, status);
        HTChannel_deleteOutput(channel, status);

        /*
        **  Check whether this channel is used by other objects or we can
        **  delete it and free memory.
        */
        if (channel->semaphore <= 0 && channels && (
                    channel->sockfd != INVSOC || channel->fp != NULL)) {
            int hash = HASH(channel->sockfd);
            HTList * list = channels[hash];
            if (list) {
                HTList_removeObject(list, (void *) channel);
                free_channel(channel);
                return YES;
            }
        } else
            HTChannel_downSemaphore(channel);
    }
    return NO;
}
Пример #2
0
PRIVATE BOOL delete_object (HTList * list, HTdns * me)
{
    HTTRACE(PROT_TRACE, "DNS Delete.. object %p from list %p\n" _ me _ list);
    HTList_removeObject(list, (void *) me);
    free_object(me);
    return YES;
}
Пример #3
0
/*
** Remove a conversion routine from the presentation list.
** The conversion routine must match up with the given args.
*/
PUBLIC void HTRemoveConversion ARGS3(
	WWW_CONST char *, representation_in,
	WWW_CONST char *, representation_out,
	HTConverter*,	converter
){
int numberOfPresentations; 
HTPresentation * pres;
HTAtom *rep_in, *rep_out;
int x;


    numberOfPresentations = HTList_count(HTPresentations);

    rep_in = HTAtom_for(representation_in);
    rep_out = HTAtom_for(representation_out);

    for (x = 0; x < numberOfPresentations; x++) {
        pres = HTList_objectAt(HTPresentations, x);
	if (pres) {
		if ((!strcmp(pres->rep->name,rep_in->name)) &&
		    (!strcmp(pres->rep_out->name,rep_out->name)) &&
		    (pres->converter == converter)) {
			HTList_removeObject(HTPresentations,pres);
			}
		}
	
	}
}
Пример #4
0
/*
**  Removes link information from one anchor to another.
**  Returns YES if OK, else NO
*/
PUBLIC BOOL HTLink_remove (HTAnchor * source, HTAnchor * destination)
{
    if (!source || !destination) return NO;
    HTTRACE(ANCH_TRACE, "Link delete. from anchor %p to anchor %p\n" _
            (void *) source _ (void *) destination);

    /* Remove if dest is the main link */
    if (source->mainLink.dest == destination) {
        source->mainLink.dest = NULL;
        source->mainLink.type = NULL;
        source->mainLink.method = METHOD_INVALID;
        source->mainLink.result = HT_LINK_INVALID;
        return YES;
    }

    /* Remove link information for other links */
    if (source->links) {
        HTList *cur = source->links;
        HTLink *pres;
        while ((pres = (HTLink *) HTList_nextObject(cur))) {
            if (pres->dest == destination) {
                HTList_removeObject(source->links, pres);
                HT_FREE(pres);
                return YES;
            }
        }
    }
    return NO;
}
Пример #5
0
PUBLIC BOOL HTHashtable_walk (HTHashtable *me,
			      int (*walkFunc)(HTHashtable *,char *, void *))
{
    if(me) {
	int i, j;
	for(i = 0; i< me->size; i++) {
	    HTList *l = (HTList *)me->table[i];
	    if(l) {
		HTList *cur = l;
		keynode *kn, *nextkn;
		for(kn = (keynode *)HTList_nextObject(cur); kn; kn = nextkn) {
		    j = walkFunc(me, kn->key, kn->object);
		    if(j == 0)
			return YES;
		    nextkn = (keynode *)HTList_nextObject(cur);
		    if (j < 0) {
			HTList_removeObject(l, kn);
			me->count--;
		    }
		}
	    }
	}
	return YES;
    }
    return NO;
}
Пример #6
0
PUBLIC BOOL HTStyleSheet_deleteStyle (HTStyleSheet * me, HTStyle * style)
{
    if (me && style) {
	HTList_removeObject(me->styles, style);
	HTStyle_delete(style);
	return YES;
    }
    return NO;
}
Пример #7
0
/*
**	Existing entries are replaced with new ones
*/
PRIVATE BOOL add_object (HTList * list, const char * access, const char * url,
			 BOOL regex, int regex_flags)
{
    HTProxy *me;
    if (!list || !access || !url || !*url)
	return NO;
    if ((me = (HTProxy *) HT_CALLOC(1, sizeof(HTProxy))) == NULL)
	HT_OUTOFMEM("add_object");
    StrAllocCopy(me->access, access);		     	    /* Access method */

#ifdef HT_POSIX_REGEX
    /* 
    **  If we support regular expressions then compile one up for
    **  this regular expression. Otherwise use is as a normal
    **  access scheme.
    */
    if (regex) {
	me->regex = get_regex_t(access,
				regex_flags < 0 ?
				W3C_DEFAULT_REGEX_FLAGS : regex_flags);
    } else
#endif
    {
	char *ptr = me->access;
	while ((*ptr = TOLOWER(*ptr))) ptr++;
    }

    me->url = HTParse(url, "", PARSE_ACCESS+PARSE_HOST+PARSE_PUNCTUATION);
    if (*(me->url+strlen(me->url)-1) != '/')
	StrAllocCat(me->url, "/");
    me->url = HTSimplify(&me->url);

    /* See if we already have this one */
    {
	HTList *cur = list;
	HTProxy *pres;
	while ((pres = (HTProxy *) HTList_nextObject(cur)) != NULL) {
	    if (!strcmp(pres->access, me->access))
		break;				       /* We already have it */
	}
	if (pres) {
	    HTTRACE(PROT_TRACE, "HTProxy..... replacing for `%s\' access %s\n" _ 
			me->url _ me->access);
	    HT_FREE(pres->access);
	    HT_FREE(pres->url);
#ifdef HT_POSIX_REGEX
	    if (pres->regex) regfree(pres->regex);
#endif
	    HTList_removeObject(list, (void *) pres);
	    HT_FREE(pres);
	}
	HTTRACE(PROT_TRACE, "HTProxy..... adding for `%s\' access %s\n" _ 
		    me->url _ me->access);
	HTList_addObject(list, (void *) me);
    }
    return YES;
}
Пример #8
0
/*		Put a presentation near start of list
**		-------------------------------------
**
**	Look up a presentation (exact match only) and, if found, reorder
**	it to the start of the HTPresentations list. - kw
*/
PUBLIC void HTReorderPresentation ARGS2(
	HTFormat,		rep_in,
	HTFormat,		rep_out)
{
    HTPresentation *match;
    if ((match = HTFindPresentation(rep_in, rep_out, NULL))) {
	HTList_removeObject(HTPresentations, match);
	HTList_addObject(HTPresentations, match);
    }
}
Пример #9
0
PUBLIC BOOL HTAA_deleteModule (const char * scheme)
{
    if (scheme) {
	HTAAModule * pres = find_module(scheme);
	if (pres) {
	    HTList_removeObject(HTSchemes, pres);
	    HTTRACE(AUTH_TRACE, "Auth Engine. deleted %p\n" _ pres);
	    delete_module(pres);
	    return YES;
	}
    }
    return NO;
}
Пример #10
0
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);
    }
  }
}
Пример #11
0
PUBLIC BOOL HTMuxChannel_delete (HTMuxChannel * me)
{
    if (me) {
	HTList * list = NULL;
	HTTRACE(MUX_TRACE, "Mux Channel. Deleting %p\n" _ me);
	if (muxchs && (list = muxchs[me->hash])) {
	    HTList_removeObject(list, (void *) me);
	    channel_delete(me);
	    return YES;
	}
    }
    return NO;
}
Пример #12
0
PUBLIC BOOL HTMuxProtocol_delete (HTMuxChannel * muxch, HTProtocolId pid)
{
    if (muxch && muxch->protocols) {
	HTList * cur = muxch->protocols;
	HTMuxProtocol * pres;
	while ((pres = (HTMuxProtocol *) HTList_nextObject(cur))) {
	    if (pres->pid == pid) {
		HTList_removeObject(muxch->protocols, pres);
		HT_FREE(pres);
		return YES;
	    }
	}
    }
    return NO;
}
Пример #13
0
/*
**	Deletes a Transport module
*/
PUBLIC BOOL HTTransport_delete (const char * name)
{
    if (transports) {
	HTList *cur = transports;
	HTTransport *pres;
	while ((pres = (HTTransport *) HTList_nextObject(cur))) {
	    if (!strcmp(pres->name, name)) {
		BOOL status = HTList_removeObject(transports, (void *) pres);
		HT_FREE(pres->name);
		HT_FREE(pres);
		return status;
	    }
	}
    }
    return NO;
}
Пример #14
0
PRIVATE BOOL HTCookieHolder_delete (HTCookieHolder * me)
{
    if (me) {
        if (me->cookies) {
            HTList * cookies = me->cookies;
            HTCookie * cookie;
            while ((cookie = (HTCookie *) HTList_nextObject(cookies)))
                HTCookie_delete(cookie);
            HTList_delete(me->cookies);
        }
        HTList_removeObject(cookie_holder, me);
        HT_FREE(me);
        return YES;
    }
    return NO;
}
Пример #15
0
/*	HTAlertCall_delete
**	------------------
**	Unregister a call back function from a list
*/
PUBLIC BOOL HTAlertCall_delete (HTList * list, HTAlertCallback *cbf)
{
    HTTRACE(CORE_TRACE, "Alert Call..  Delete Alert Handler %p\n" _ (void *) cbf);
    if (list && cbf) {
	HTList *cur = list;
	HTAlert *pres;
	while ((pres = (HTAlert *) HTList_nextObject(cur))) {
	    if (pres->cbf == cbf) {
		HTList_removeObject(list, (void *) pres);
		HT_FREE(pres);
		return YES;
	    }
	}
    }
    return NO;
}
Пример #16
0
/*	HTAlertCall_deleteOpcode
**	------------------------
**	Unregister all handlers registered for a given opcode.
*/
PUBLIC BOOL HTAlertCall_deleteOpcode (HTList * list, HTAlertOpcode opcode)
{
    HTTRACE(CORE_TRACE, "Alert Call.. Delete all handlers with opcode %d\n" _ opcode);
    if (list) {
	HTList * cur = list;
	HTAlert * pres;
	while ((pres = (HTAlert *) HTList_nextObject(cur))) {
	    if (pres->opcode == opcode) {
		HTList_removeObject(list, (void *) pres);
		HT_FREE(pres);
		cur = list;
	    }
	}
	return YES;
    }
    return NO;
}
Пример #17
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;
    }
}
Пример #18
0
/*
**	Deletes a Protocol module as an active access method
*/
PUBLIC BOOL HTProtocol_delete (const char * name)
{
    if (protocols) {
	HTList *cur = protocols;
	HTProtocol *pres;
	while ((pres = (HTProtocol *) HTList_nextObject(cur))) {
	    if (!strcmp(pres->name, name)) {
		BOOL status = HTList_removeObject(protocols, (void *) pres);
		HT_FREE(pres->name);
		HT_FREE(pres->transport);
		HT_FREE(pres);
		return status;
	    }
	}
    }
    return NO;
}
Пример #19
0
/*
**  Searches the whole list and removes all elements with this name
*/
PUBLIC BOOL HTAssocList_removeObject (HTAssocList * list, const char * name)
{
    BOOL found = NO;
    if (list && name) {
	HTAssocList * cur = list;
	HTAssoc * assoc;
	int len = strlen(name);
	while ((assoc = (HTAssoc *) HTList_nextObject(cur))) {
	    if (!strncasecomp(assoc->name, name, len)) {
		HTList_removeObject(list, assoc);
		HT_FREE(assoc);
		found = YES;
		cur = list;
	    }
	}
    }
    return found;
}
Пример #20
0
/*
** Destroy HTSSL object if no references to it remain in application
*/
PUBLIC void HTSSL_free (HTSSL * htssl)
{
    (htssl->ref_count)--;
    HTTRACE(PROT_TRACE, "HTSSL Free.. ref_count = %d\n" _ htssl->ref_count);

    if (htssl->ref_count == 0) {
        HTTRACE(PROT_TRACE, "HTSSL.Free.. FINAL RELEASE\n");

        if (htssl->ssl) {
            SSL_free(htssl->ssl);
            htssl->ssl = NULL;
        }
       
        HTList_removeObject(ssl_list, htssl);          

        /* releases itself */
        HT_FREE(htssl);
    }
}
Пример #21
0
PUBLIC BOOL HTHashtable_removeObject (HTHashtable *me, const char *key)
{
    if(me) {
	int size = me->size;
	int i = hash_number(key,size);
	HTList *l = (HTList *)me->table[i];
	if(l) {
	    HTList *cur = l;
	    keynode *kn;
	    while ((kn = (keynode *) HTList_nextObject(cur))) {
		if(!strcmp(key,kn->key)) {
		    HTList_removeObject(l,kn);
		    me->count--;
		    return YES;
		}
	    }
	}
    }
    return NO;
}
Пример #22
0
PUBLIC BOOL HTChannel_setSocket (HTChannel * channel, SOCKET sockfd)
{
    if (channel) {

        /*
        ** As we use the socket number as the hash entry then we have to
        ** update the hash table as well.
        */
        int old_hash = HASH(channel->sockfd);
        int new_hash = sockfd < 0 ? 0 : HASH(sockfd);
        HTList * list = channels[old_hash];
        if (list) HTList_removeObject(list, channel);
        if (!channels[new_hash]) channels[new_hash] = HTList_new();
        list = channels[new_hash];
        HTList_addObject(list, channel);

        channel->sockfd = sockfd;
        return YES;
    }
    return NO;
}
Пример #23
0
/*
 * Utility for listing shortcuts, making any repeated
 * shortcut the most current in the list. - FM
 */
void LYAddJumpShortcut(HTList *historyp, char *shortcut)
{
    char *tmp = NULL;
    char *old;
    HTList *cur = historyp;

    if (!historyp || isEmpty(shortcut))
	return;

    StrAllocCopy(tmp, shortcut);

    while (NULL != (old = (char *) HTList_nextObject(cur))) {
	if (!strcmp(old, tmp)) {
	    HTList_removeObject(historyp, old);
	    FREE(old);
	    break;
	}
    }
    HTList_addObject(historyp, tmp);

    return;
}
Пример #24
0
PUBLIC BOOL HTAnchor_deleteEncoding (HTParentAnchor * me, HTEncoding encoding)
{
    return (me && me->content_encoding && encoding) ?
	HTList_removeObject(me->content_encoding, encoding) : NO;
}
Пример #25
0
PUBLIC BOOL HTAnchor_deleteVariant (HTParentAnchor * me,
				    HTParentAnchor * variant)
{
    return (me && variant) ? HTList_removeObject(me->variants, variant) : NO;
}
Пример #26
0
/*	HTMemoryCall_delete
**	-------------------
**	Unregister a call back function from a list
*/
PUBLIC BOOL HTMemoryCall_delete (HTMemoryCallback * cbf)
{
    HTTRACE(MEM_TRACE, "Mem Delete.. Callback %p\n" _ (void *) cbf);
    return (HTMemCall && cbf) ? HTList_removeObject(HTMemCall,(void*)cbf) : NO;
}