www.pudn.com > openwebspiderv0.1a.zip > list.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 
 * 
 */

#ifndef __LIST
#define __LIST

typedef struct _NODE
{
	void* field;
	struct _NODE* next;
} NODE;

int lstFreeAll(NODE* first)
{
NODE* cur = first;
NODE* tmp;

	while(cur != NULL)
	{
		tmp=cur->next;
		free(cur->field);
		free(cur);
		cur=tmp;
	}

	first=NULL;

return 1;
}

NODE* lstGetNodeX(NODE* first, int x)
{
NODE* cur = first;

	while(cur != NULL && x>0)	//to correct in do while
	{
		x--;
		cur=cur->next;
	}

return (x==0) ? cur : NULL;
}

NODE* lstGetLastNode(NODE* first, int* NumOfNodes)
{
NODE* cur = first;

	if(NumOfNodes!=NULL)
		*NumOfNodes=0;

	while(cur->next != NULL)
	{
		if(NumOfNodes!=NULL)
			(*NumOfNodes)++;

		cur=cur->next;
	}

return cur;
}

#endif


/*EOF*/