예제 #1
0
파일: HTNews.c 프로젝트: ChatanW/WebDaM
PRIVATE HTStream * HTNewsStatus_new (HTRequest * request, news_info * news,
				     HTHost * host)
{
    HTStream *me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTNewsStatus_new");
    me->isa = &HTNewsStatusClass;
    me->request = request;
    me->news = news;
    me->EOLstate = EOL_BEGIN;
    me->host = host;
    return me;
}
예제 #2
0
PUBLIC HTBTree * HTBTree_new (HTComparer * comp)
    /*********************************************************
    ** This function returns an HTBTree with memory allocated 
    ** for it when given a mean to compare things
    */
{
    HTBTree * tree;
    if ((tree = (HTBTree  *) HT_CALLOC(1, sizeof(HTBTree))) == NULL)
        HT_OUTOFMEM("HTBTree_new");
    tree->compare = comp;
    tree->top = NULL;
    return tree;
}
예제 #3
0
파일: HTTee.c 프로젝트: ChatanW/WebDaM
/*	Tee Stream creation
**	-------------------
**	You can create a T stream using this method. Each stream returns a
**	return value and in order to resolve conflicts in the return code
**	you can specify a resolver callback function. Each time any of the 
**	data methods are called the resolver function is then called with
**	the return codes from the two streams. The return code of the T stream
**	itself will be the result of the resolver function. If you pass NULL
**	as the resolver routine then a default resolver is used.
*/
PUBLIC HTStream * HTTee(HTStream * s1, HTStream * s2, HTComparer * resolver)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(*me))) == NULL)
        HT_OUTOFMEM("HTTee");
    me->isa = &HTTeeClass;
    me->s1 = s1 ? s1 : HTBlackHole();
    me->s2 = s2 ? s2 : HTBlackHole();
    me->resolver = resolver ? resolver : default_resolver;
    HTTRACE(STREAM_TRACE, "Tee......... Created stream %p with resolver %p\n" _ 
		me _ me->resolver);
    return me;
}
예제 #4
0
파일: HTChannl.c 프로젝트: boatgm/urchin
/*
**	A channel is uniquely identified by a socket.
**	Note that we don't create the input and output stream - they are
**	created later.
**
**	We only keep a hash on sockfd's as we don't have to look for channels
**	for ANSI file descriptors.
*/
PUBLIC HTChannel * HTChannel_new (SOCKET sockfd, FILE * fp, BOOL active)
{
    HTList * list = NULL;
    HTChannel * ch = NULL;
    int hash = sockfd < 0 ? 0 : HASH(sockfd);
    HTTRACE(PROT_TRACE, "Channel..... Hash value is %d\n" _ hash);
    if (!channels) {
        if (!(channels = (HTList **) HT_CALLOC(HT_M_HASH_SIZE,sizeof(HTList*))))
            HT_OUTOFMEM("HTChannel_new");
    }
    if (!channels[hash]) channels[hash] = HTList_new();
    list = channels[hash];
    if ((ch = (HTChannel *) HT_CALLOC(1, sizeof(HTChannel))) == NULL)
        HT_OUTOFMEM("HTChannel_new");
    ch->sockfd = sockfd;
    ch->fp = fp;
    ch->active = active;
    ch->semaphore = 1;
    ch->channelIStream.isa = &ChannelIStreamIsa;
    ch->channelOStream.isa = &ChannelOStreamIsa;
    ch->channelIStream.channel = ch;
    ch->channelOStream.channel = ch;
    HTList_addObject(list, (void *) ch);

#ifdef HT_MUX
    /*
    **  Create a MUX channel and do a connect on this channel with a
    **  new session.
    */
    {
        HTProtocol * protocol = HTNet_protocol(net);
        HTMuxChannel * muxch = HTMuxChannel_new(me);
        net->session = HTMuxSession_connect(muxch, net, HTProtocol_id(protocol));
    }
#endif /* HT_MUX */

    HTTRACE(PROT_TRACE, "Channel..... Added %p to list %p\n" _ ch _ list);
    return ch;
}
예제 #5
0
/*	
**	Set up the list of suffix bindings. Done by HTLibInit
*/
PUBLIC BOOL HTBind_init (void)
{
    if (!HTBindings) {
	if (!(HTBindings = (HTList **) HT_CALLOC(HT_L_HASH_SIZE, sizeof(HTList *))))
	    HT_OUTOFMEM("HTBind_init");
    }
    StrAllocCopy(HTDelimiters, DEFAULT_SUFFIXES);
    no_suffix.type = WWW_UNKNOWN;
    no_suffix.encoding = WWW_CODING_BINARY;
    unknown_suffix.type = WWW_UNKNOWN;
    unknown_suffix.encoding = WWW_CODING_BINARY;
    return YES;
}
예제 #6
0
/*
**	A AA element is a particular AA procotol associated with a
**	particular point in the URL tree. The scheme is the name of the
**	AA protocol known to be able to handle this context. This protocol
**	must have been registered as a AA module.
*/
PRIVATE HTAAElement * HTAA_newElement (const char * scheme, void * context)
{
    if (scheme) {
	HTAAElement * me;
	if ((me = (HTAAElement *) HT_CALLOC(1, sizeof(HTAAElement))) == NULL)
	    HT_OUTOFMEM("HTAAElement_new");
	StrAllocCopy(me->scheme, scheme);
	me->context = context;
	HTTRACE(AUTH_TRACE, "Auth Engine. Created element %p\n" _ me);
	return me;
    }
    return NULL;
}
예제 #7
0
파일: HTTPServ.c 프로젝트: Rjoydip/libwww
PRIVATE HTStream * HTTPReceive_new (HTRequest * request, https_info * http)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTTPReceive_new");
    me->isa = &HTTPReceiveClass;
    me->request = request;
    me->http = http;
    me->state = EOL_BEGIN;
    me->buffer = HTChunk_new(128);		 /* Sufficiant for most URLs */
    HTTRACE(STREAM_TRACE, "HTTP Request Stream %p created\n" _ me);
    return me;
}
예제 #8
0
파일: HTTPServ.c 프로젝트: Rjoydip/libwww
PRIVATE HTStream * HTTPReply_new (HTRequest * request, https_info * http,
                                  HTStream * target)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTTPReply_new");
    me->isa = &HTTPReplyClass;
    me->request = request;
    me->http = http;
    me->target = target;
    HTTRACE(STREAM_TRACE, "HTTP Reply.. Stream %p created\n" _ me);
    return me;
}
예제 #9
0
/*	Create new or find old child anchor
**	-----------------------------------
**
**	Me one is for a new anchor being edited into an existing
**	document. The parent anchor must already exist. All
**	children without tags (no NAME attribut) points to the same NULL
**	child.
**	Children are now hashed for performance reasons. Thanks to
**	Michael Farrar
*/
PUBLIC HTChildAnchor * HTAnchor_findChild (HTParentAnchor *	parent,
					   const char *		tag)
{
    HTChildAnchor * child = NULL;
    HTList * kids = NULL;
    if (!parent) {
	HTTRACE(ANCH_TRACE, "Child Anchor Bad argument\n");
	return NULL;
    }

    /* Find a hash for this tag (if any) */
    {
	int hash = 0;
	/*
	** If tag is empty then use hash value 0
	*/
	if (tag) {
	    const char * ptr = tag;
	    for(; *ptr; ptr++)
		hash = (int) ((hash*3 + (*(unsigned char*)ptr)) % CHILD_HASH_SIZE);
	}
	if (!parent->children) {
	    if (!(parent->children = (HTList **)	
		  HT_CALLOC(CHILD_HASH_SIZE, sizeof(HTList *))))
		HT_OUTOFMEM("HTAnchor_findChild");
	}
	if (!parent->children[hash]) parent->children[hash] = HTList_new();
	kids = parent->children[hash];
    }

    /* First search list of children to see if tag is already there */
    if (tag && *tag) {
	HTList * cur = kids;
	while ((child = (HTChildAnchor *) HTList_nextObject(cur))) {
	    if (child->tag && !strcmp(child->tag, tag)) {
		HTTRACE(ANCH_TRACE, "Child Anchor %p of parent %p with name `%s' already exists.\n" _ 
			    (void *) child _ (void *) parent _ tag);
		return child;
	    }
	}
    }

    /* If not found then create a new child anchor */
    child = HTChildAnchor_new();
    HTList_addObject(kids, (void *) child);
    child->parent = parent;
    if (tag) StrAllocCopy(child->tag, tag);
    HTTRACE(ANCH_TRACE, "Child Anchor New Anchor %p named `%s' is child of %p\n" _ 
		(void *) child _ tag ? tag : (const char *) "" _ (void *)parent);
    return child;
}
예제 #10
0
/*	HTAlertCall_add
**	---------------
**	Register a call back function that is to be called when generating
**	messages, dialog, prompts, progress reports etc.
**
**	The opcode signifies which call back function to call depending of the 
**	type of the message. Opcode can be one of the enumerations defined
**	by HTAlertOpcode.
*/
PUBLIC BOOL HTAlertCall_add (HTList * list, HTAlertCallback * cbf,
			     HTAlertOpcode opcode)
{
    HTTRACE(CORE_TRACE, "Alert Call.. Add Alert Handler %p\n" _ (void *) cbf);
    if (list && cbf) {
	HTAlert *me;
	if ((me = (HTAlert  *) HT_CALLOC(1, sizeof(HTAlert))) == NULL)
	    HT_OUTOFMEM("HTAlertCall_add");
	me->cbf = cbf;
	me->opcode = opcode;
	return HTList_addObject(list, (void *) me);
    }
    return NO;
}
예제 #11
0
PUBLIC HTStream* HTPlainPresent (HTRequest *	request,
				 void *		param,
				 HTFormat	input_format,
				 HTFormat	output_format,
				 HTStream *	output_stream)
{
    HTStream * me;
    if ((me = (HTStream *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTPlain_new");
    me->isa = &HTPlain;       
    me->text = HTextImp_new(request, HTRequest_anchor(request), output_stream);
    HTextImp_build(me->text, HTEXT_BEGIN);
    return me;
}
예제 #12
0
PUBLIC BOOL HTMuxProtocol_add (HTMuxChannel * muxch,
			       HTProtocolId pid, const char * protocol)
{
    if (muxch && protocol) {	
	HTMuxProtocol * ms;
	if ((ms = (HTMuxProtocol *) HT_CALLOC(1, sizeof(HTMuxProtocol))) == NULL)
	    HT_OUTOFMEM("HTMuxProtocol_new");
	ms->name = HTAtom_caseFor(protocol);
	ms->pid = pid;
	if (!muxch->protocols) muxch->protocols = HTList_new();
	return HTList_addObject(muxch->protocols, ms);
    }
    return NO;
}
예제 #13
0
PUBLIC HTStream* HTXParse (HTRequest *	request,
			     void *		param,
			     HTFormat		input_format,
			     HTFormat		output_format,
			     HTStream *		output_stream)
{
    HTStream* me;
  
#ifdef HTDEBUG
    if (STREAM_TRACE) {
	HTTRACE(STREAM_TRACE, "HTXConvert..");
	if (input_format && input_format->name)
            HTTRACE(STREAM_TRACE, ".. input format is %s" _ input_format->name);
	if (output_format && output_format->name)
            HTTRACE(STREAM_TRACE, ".. output format is %s" _ output_format->name);
	HTTRACE(STREAM_TRACE, "\n");
    }
#endif /* HTDEBUG */

    if ((me = (HTStream *) HT_CALLOC(1, sizeof(*me))) == NULL)
        HT_OUTOFMEM("HTXConvert");
    me->isa = &HTXParseClass;

    if ((me->eps = (HTXParseStruct  *) HT_CALLOC(1, sizeof(HTXParseStruct))) == NULL)
        HT_OUTOFMEM("HTXConvert");

    if (input_format)
        me->eps->content_type = input_format->name;
    me->eps->call_client = HTCallClient;
    if ((me->eps->buffer = (char  *) HT_CALLOC(INPUT_BUFFER_SIZE,1)) == NULL)
        HT_OUTOFMEM("HTXParse");
    me->eps->used = 0;
    me->eps->finished = NO;
    me->eps->length = INPUT_BUFFER_SIZE;
    me->eps->request = request;
    return me;
}
예제 #14
0
파일: HTUser.c 프로젝트: ChatanW/WebDaM
/*
**	Create a new host profile object and initialize it with what we can
**	find on this host.
*/
PUBLIC HTUserProfile * HTUserProfile_new (const char * name, void * context)
{
    HTUserProfile * me = NULL;
    if (name) {
	if ((me = (HTUserProfile *) HT_CALLOC(1, sizeof(HTUserProfile)))==NULL)
	    HT_OUTOFMEM("HTUserProfile_new");

	HTTRACE(CORE_TRACE, "User Profile Adding `%s\'\n" _ name);
	StrAllocCopy(me->user, name);

	/* Set the context */
	me->context = context;
    }
    return me;
}
예제 #15
0
/*
**	Do not use "new" by itself outside this module. In order to enforce
**	consistency, we insist that you furnish more information about the
**	anchor you are creating : use newWithParent or newWithAddress.
*/
PRIVATE HTParentAnchor * HTParentAnchor_new (void)
{
    HTParentAnchor *newAnchor;
    if ((newAnchor = (HTParentAnchor *) HT_CALLOC(1, sizeof (HTParentAnchor))) == NULL)
	HT_OUTOFMEM("HTParentAnchor_new");
    newAnchor->parent = newAnchor;
    newAnchor->content_type = WWW_UNKNOWN;
    newAnchor->mainLink.method = METHOD_INVALID;
    newAnchor->content_length = -1;			 /* howcome 6 dec 95 */
    newAnchor->date = (time_t) -1;
    newAnchor->expires = (time_t) -1;
    newAnchor->last_modified = (time_t) -1;
    newAnchor->age = (time_t) -1;
    return newAnchor;
}
예제 #16
0
PUBLIC HTStream * HTFWriter_new (HTRequest * request, FILE * fp,
				 BOOL leave_open)
{
    HTStream * me = NULL;
    if (!fp) {
	HTTRACE(STREAM_TRACE, "FileWriter.. Bad file descriptor\n");
	return HTErrorStream();
    }
    if ((me = (HTStream *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTFWriter_new");
    me->isa = &HTFWriter;       
    me->fp = fp;
    me->leave_open = leave_open;
    return me;
}
예제 #17
0
PUBLIC BOOL HTAssocList_addObject (HTAssocList * list,
				   const char * name, const char * value)
{
    if (list && name) {
	HTAssoc * assoc;
	if ((assoc = (HTAssoc *) HT_CALLOC(1, sizeof(HTAssoc))) == NULL)
	    HT_OUTOFMEM("HTAssoc_add");
	StrAllocCopy(assoc->name, name);
	if (value) StrAllocCopy(assoc->value, value);
	return HTList_addObject(list, (void *) assoc);
    } else {
	HTTRACE(UTIL_TRACE, "HTAssoc_add: ERROR: assoc list NULL!!\n");
    }
    return NO;
}
예제 #18
0
PUBLIC HTList * HTList_addList (HTList * me, void * newObject)
{
    if (me) {
	HTList *newNode;
	if ((newNode = (HTList  *) HT_CALLOC(1, sizeof(HTList))) == NULL)
	    HT_OUTOFMEM("HTList_addObject");
	newNode->object = newObject;
	newNode->next = me->next;
	me->next = newNode;
	return newNode;
    } else {
	HTTRACE(CORE_TRACE, "HTList...... Can not add object %p to nonexisting List\n" _ newObject);
    }
    return (HTList *) NULL;
}
예제 #19
0
PUBLIC HTStream * HTBuffer_new (HTStream *	target,
				HTRequest *	request,
				int		max_size)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTBufferStream");
    me->isa = &HTBufferClass;
    me->target = target;
    me->request = request;
    me->max_size = (max_size > 0) ? max_size : HT_MAX_SIZE;
    me->mode = HT_BM_PLAIN;
    HTTRACE(STREAM_TRACE, "Buffer...... Created with size %d\n" _ me->max_size);
    return me;
}
예제 #20
0
PUBLIC HTOutputStream * HTWriter_new (HTHost * host, HTChannel * ch,
                                      void * param, int mode)
{
    if (host && ch) {
        HTOutputStream * me = HTChannel_output(ch);
        if (!me) {
            if ((me=(HTOutputStream *) HT_CALLOC(1, sizeof(HTOutputStream)))==NULL)
                HT_OUTOFMEM("HTWriter_new");
            me->isa = &HTWriter;
            me->ch = ch;
            me->host = host;
        }
        return me;
    }
    return NULL;
}
예제 #21
0
PRIVATE void append_buf (HTStream * me)
{
    HTBufItem * b;
    if ((b = (HTBufItem  *) HT_CALLOC(1, sizeof(HTBufItem))) == NULL)
        HT_OUTOFMEM("append_buf");
    b->len = me->tmp_ind;
    b->buf = me->tmp_buf;
    me->tmp_ind = 0;
    me->tmp_max = 0;
    me->tmp_buf = 0;
    if (me->tail)
	me->tail->next = b;
    else
	me->head = b;
    me->tail = b;
}
예제 #22
0
PUBLIC void HTCharset_add (HTList *		list,
			   const char *		charset,
			   double		quality)
{
    HTAcceptNode * node;
    if (!list || !charset || !*charset)  {
	HTTRACE(CORE_TRACE, "Charset..... Bad argument\n");
	return;
    }
    if ((node = (HTAcceptNode *) HT_CALLOC(1, sizeof(HTAcceptNode))) == NULL)
        HT_OUTOFMEM("HTAcceptCharsetuage");

    HTList_addObject(list, (void*)node);
    node->atom = HTAtom_for(charset);
    node->quality = quality;
}
예제 #23
0
PRIVATE regex_t * get_regex_t (const char * regex_str, int cflags)
{
    regex_t * regex = NULL;
    if (regex_str && *regex_str) {
	int status;
	if ((regex = (regex_t *) HT_CALLOC(1, sizeof(regex_t))) == NULL)
	    HT_OUTOFMEM("get_regex_t");
	if ((status = regcomp(regex, regex_str, cflags))) {
	    char * err_msg = get_regex_error(status, regex);
	    HTTRACE(PROT_TRACE, "HTProxy..... Regular expression error: %s\n" _ err_msg);
	    HT_FREE(err_msg);
	    HT_FREE(regex);
	}
    }
    return regex;
}
예제 #24
0
PUBLIC void HTLanguage_add (HTList *		list,
			    const char *	lang,
			    double		quality)
{
    HTAcceptNode * node;
    if (!list || !lang || !*lang)  {
	HTTRACE(CORE_TRACE, "Languages... Bad argument\n");
	return;
    }
    if ((node = (HTAcceptNode *) HT_CALLOC(1, sizeof(HTAcceptNode))) == NULL)
        HT_OUTOFMEM("HTAcceptLanguage");

    HTList_addObject(list, (void*)node);
    node->atom = HTAtom_for(lang);
    node->quality = quality;
}
예제 #25
0
파일: HTLine.c 프로젝트: svagionitis/libwww
/*	Create a Command Line Object
**	----------------------------
*/
PRIVATE ComLine * ComLine_new (void)
{
    ComLine * me;
    if ((me = (ComLine *) HT_CALLOC(1, sizeof(ComLine))) == NULL)
	HT_OUTOFMEM("ComLine_new");
    me->timer = DEFAULT_TIMEOUT*MILLIES;
    me->cwd = HTGetCurrentDirectoryURL();
    me->output = OUTPUT;

    /* Bind the ConLine object together with the Request Object */
    me->request = HTRequest_new();
    HTRequest_setOutputFormat(me->request, DEFAULT_FORMAT);
    HTRequest_setContext (me->request, me);

    return me;
}
예제 #26
0
/*		Converter from WAIS Source to whatever
**		--------------------------------------
*/
PUBLIC HTStream* HTWSRCConvert (HTRequest *	request,
				void *		param,
				HTFormat	input_format,
				HTFormat	output_format,
				HTStream *	output_stream)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1, sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTWSRCConvert");
    me->isa = &WSRCParserClass;
    me->target = HTMLGenerator(request, param, input_format, output_format,
			       output_stream);
    me->request = request;
    me->state = beginning;

    return me;
}
예제 #27
0
/*	Append a character
**	------------------
*/
PUBLIC void HTChunk_putc (HTChunk * ch, char c)
{
    if (ch) {	
	if (!ch->data || ch->size >= ch->allocated-1) { /* [SIC] bobr */
	    if (ch->data) {
		if ((ch->data = (char  *) HT_REALLOC(ch->data,ch->allocated+ch->growby)) == NULL)
		    HT_OUTOFMEM("HTChunk_putc");
		memset((void *) (ch->data + ch->allocated), '\0', ch->growby);
	    } else {
		if ((ch->data = (char  *) HT_CALLOC(1, ch->allocated+ch->growby)) == NULL)
		    HT_OUTOFMEM("HTChunk_putc");
	    }
	    ch->allocated += ch->growby;
	}
	*(ch->data+ch->size++) = c;
    }
}
예제 #28
0
PUBLIC HTEvent * HTEvent_new (HTEventCallback * cbf, void * context,
			      HTPriority priority, int millis)
{
    if (cbf) {
	HTEvent * me;
	if ((me = (HTEvent *) HT_CALLOC(1, sizeof(HTEvent))) == NULL)
	    HT_OUTOFMEM("HTEvent_new");
	me->cbf = cbf;
	me->param = context;
	me->priority = priority;
	me->millis = millis;
	HTTRACE(CORE_TRACE, "Event....... Created event %p with context %p, priority %d, and timeout %d\n" _ 
		    me _ context _ priority _ millis);
	return me;
    }
    return NULL;
}
예제 #29
0
PUBLIC HTStream * HTGuess_new (HTRequest *	request,
			       void *		param,
			       HTFormat		input_format,
			       HTFormat		output_format,
			       HTStream *	output_stream)
{
    HTStream * me;
    if ((me = (HTStream  *) HT_CALLOC(1,sizeof(HTStream))) == NULL)
        HT_OUTOFMEM("HTGuess_new");
    me->isa = &HTGuessClass;
    me->request = request;
    me->response = HTRequest_response(request);
    me->output_format = output_format;
    me->output_stream = output_stream;
    me->write_ptr = me->buffer;
    return me;
}
예제 #30
0
HText * HText_new2 (HTRequest * request, HTParentAnchor * anchor,
		    HTStream * stream)
{
    HText * me;
    Robot * mr = (Robot *) HTRequest_context(request);
    if ((me = (HText *) HT_CALLOC(1, sizeof(HText))) == NULL)
        HT_OUTOFMEM("HText_new2");

    /* Bind the HText object together with the Request Object */
    me->request = request;
    me->first_anchor = me->last_anchor = 0;
    me->anchors = 0;

    /* Add this HText object to our list */
    mr->htext = me;
    return me;
}