Ejemplo n.º 1
0
PUBLIC void HTHashtable_print (HTHashtable *me)
{
    HTArray *keys = HTHashtable_keys(me);
    int i;
    HTPrint("Printing Hash Table of size %d\n", HTArray_size(keys));
    for(i = 0; i< HTArray_size(keys); i++) {
	HTPrint("Key %d %s\n",i,HTArray_data(keys)[i]);
    }
    for(i = 0; i< HTArray_size(keys); i++) {
	HT_FREE(HTArray_data(keys)[i]);
    }
    HTArray_delete(keys);
}
Ejemplo n.º 2
0
/* Added by MP. */
PRIVATE HTNewsNode* HTNewsDir_findNodeNamed (HTNewsDir* dir, char* name)
{
    int i;
    for (i = 0; i < HTArray_size(dir->array); i++)
    {
        HTNewsNode* node = (HTNewsNode*)(HTArray_data(dir->array)[i]);
        if (node->name && strcasecomp(node->name, name) == 0)
            return node;
    }
    return NULL;
}
Ejemplo n.º 3
0
/* Added by MP. */
PRIVATE void HTNewsDir_setRefInfo (HTNewsDir* dir)
{
    /* Array grows when fake elements are added.  */
    /* We don't want to set reference info for fake elements. */
    int size = HTArray_size(dir->array);
    int i;
    for (i = 0; i < size; i++)
        HTNewsNode_setRefInfo_pass1 (dir, (HTNewsNode*)(HTArray_data(dir->array)[i]));
    for (i = 0; i < size; i++)
        HTNewsNode_setRefInfo_pass2 (dir, (HTNewsNode*)(HTArray_data(dir->array)[i]));
    for (i = 0; i < size; i++)
        HTNewsNode_setRefInfo_pass3 (dir, (HTNewsNode*)(HTArray_data(dir->array)[i]));
}
Ejemplo n.º 4
0
/*	HTDir_free
**	----------
**    	If we are sorting then do the sorting and put out the list,
**	else just append the end of the list.
*/
PUBLIC BOOL HTDir_free (HTDir * dir)
{
    if (!dir) return NO;
    if (dir->key != HT_DK_NONE) {
	HTArray *array = dir->array;
	void **data = NULL;
	HTDirNode *node;
	HTDir_headLine(dir);	
	HTArray_sort(array, (dir->key==HT_DK_CINS ? DirCaseSort : DirSort));
	node = (HTDirNode *) HTArray_firstObject(array, data);
	while (node) {
	    HTDirNode_print(dir, node);
	    HTDirNode_free(node);
	    node = (HTDirNode *) HTArray_nextObject(array, data);
	}
	dir->size = HTArray_size(array);
    	HTArray_delete(array);	
    }

    /* Put out the end of the HTML stuff */
    {
	HTStructured *target = dir->target;
	END(HTML_PRE);
	START(HTML_HR);
	START(HTML_PRE);
	if (!dir->size)
	    PUTS("Empty directory");
	else if (dir->size == 1)
	    PUTS("1 File");
	else {
	    char buffer[20];
	    sprintf(buffer, "%u files", dir->size);
	    PUTS(buffer);
	}
	END(HTML_PRE);
	END(HTML_BODY);
	END(HTML_HTML);
	FREE_TARGET;
    }

    HT_FREE(dir->fnbuf);
    HT_FREE(dir->lnbuf);
    HT_FREE(dir->base);
    HT_FREE(dir);
    return YES;
}
Ejemplo n.º 5
0
/*
**	Runs through a sorted list of news groups and identifies the group
**	hierarchy. Template groups are added to the list, for example as
**	"alt.*"
*/
PRIVATE void HTNewsDir_setGroupInfo (HTNewsDir * dir)
{
    HTArray * array = dir->array;
    HTNewsNode * node;
    int cur_size = HTArray_size(array);
    int cnt;

    /*
    ** If we don't have a template to test against then create one
    ** A template can be something like "alt.*" for example
    */
    for (cnt=0; cnt<cur_size; cnt++) {
	node = (HTNewsNode *) HTArray_data(array)[cnt];

	/*
	** Make a template if we don't have any
	*/
	if (!dir->tmplate) make_template(dir, node);
    
	/*
	** Now, if we do have a template then test the node name against
	** it to see if we have this group already or it is a new group
	** at this level in the hierarchy
	*/
	if (dir->tmplate) {
	    if (HTStrCaseMatch(dir->tmplate, node->name) == NULL) {
		make_template(dir, node);
	    } else {
		HTNewsNode * tmp_node = dir->tmplate_node;
		
		/* Should we show this element in the list? */
		if (tmp_node->lastChild) {
		    tmp_node->lastChild->show = NO;
		    node->show = NO;
		}
	    }
	    HTNewsNode_linkRef(dir->tmplate_node, node);
	}
    }
}
Ejemplo n.º 6
0
/* Added by MP. */
PRIVATE HTNewsNode* HTNewsDir_findNodeWithSubject (HTNewsDir* dir, 
    char* subject, int which, HTNewsNode* avoidNode)
{
    int i;
    int whichDate = (which & FNWS_MIN ? -1 : (which & FNWS_MAX ? 1 : 0));
    HTNewsNode* foundNode = NULL;
    for (i = 0; i < HTArray_size(dir->array); i++)
    {
        HTNewsNode* node = (HTNewsNode*)(HTArray_data(dir->array)[i]);
        if (!(which & FNWS_ONLYFAKE && !node->fake) && 
            !(which & FNWS_NOTFAKE && node->fake) &&
            !(which & FNWS_NOTORPHAN && !node->fake && !node->refNames) &&
            node != avoidNode && node->subject && 
            strcasecomp(node->subject, subject) == 0)
        {
            if (which == FNWS_ANY)
                return node;
            else if (!foundNode || (node->date != 0 && 
                (node->date - foundNode->date) * (long)whichDate > 0))
                foundNode = node;
        }                  
    }
    return foundNode;
}