www.pudn.com > openwebspiderv0.1a.zip > hstlist.h



/* OpenWebSpider
 * 
 *     Coded by Shen139
 *     shen139 [at] eviltime (dot) com
 * 
 * 
 * This file is part of OpenWebSpider 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 *
 */
 
 /* (damn) */

#ifndef __HSTLIST
#define __HSTLIST

#include 
#include  
#include  
#include "options.h"
#include "list.h"

NODE* cur;
NODE* first;

NODE* lstInit(struct sHost host)
{
NODE* first=malloc(sizeof(NODE));
struct sHost* Host = malloc(sizeof(struct sHost));

	first->field = (void*)Host;
	memcpy(Host ,&host,sizeof(struct sHost));
	first->next = NULL;

return first;
}

int lstAddHost(NODE* first,struct sHost host)
{
NODE* nHost = malloc(sizeof(NODE));
struct sHost* Host = malloc(sizeof(struct sHost));

	cur = lstGetLastNode(first,NULL);

	cur->next = nHost;
	nHost->field = (void*)Host;
	memcpy(Host ,&host,sizeof(struct sHost));
	
	nHost->next = NULL;

return 1;
}

NODE* lstGetNodeByHost(NODE* first, struct sHost host)
{
	cur = first;

	while(cur != NULL)
	{
		if(strncmp(((struct sHost*)cur->field)->Host,host.Host ,strlen(host.Host))==0
		&& strncmp(((struct sHost*)cur->field)->Page,host.Page ,strlen(host.Page))==0)
			return cur;

		cur=cur->next;
	}

	return NULL;
}

NODE* lstGetFirstFreeNode(NODE* first)
{
	cur = first;

	while(cur != NULL)
	{
		if(((struct sHost*)cur->field)->viewed == 0)
			return cur;
		cur=cur->next;
	}

return NULL;
}

#endif


/*EOF*/