⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wps_queue.c

📁 WiFi Protected Setup (WPS) 又叫Simple config。 是无线局域网领域推出的新协议
💻 C
字号:
/*
 *  WPS_QUEUE.C : WPS Common Used Queue Module
 * 
 *  ver        date            author         comment
 *  0.0.1      08/02/26        Gao Hua        First
 */
 
#include "wps_types.h"
#include "wps_queue.h"


/* Initialize a wps_queue node ------------------------------------------------- */
void wps_init_que(wps_queue *item, void *body)
{
	item->q_forw = NULL;
	item->q_back = NULL;
	item->q_body = body;
}

/* Insert a item to a wps_queue ------------------------------------------------ */
/*
root	:Pointer to Root pointer
point	:Insert point (item will be link after it)
item	:Item to insert
*/
void wps_insert_que(wps_queue **root, wps_queue *point, wps_queue *item)
{
	if (*root == NULL) {
		item->q_back = NULL;
		item->q_forw = NULL;
		*root =item;
	}
	else {
		if (point == NULL) {
			item->q_back = NULL;
			item->q_forw = *root;
			(*root)->q_back = item;
			*root = item;
		}
		else {
			/* Link forword wps_queue */
			item->q_forw = point->q_forw;
			if (point->q_forw != NULL) point->q_forw->q_back = item;

			/* Link back wps_queue */
			point->q_forw = item;
			item->q_back = point;
		}
	}

	return;
}

/* Append a item to a wps_queue ------------------------------------------------ */
/*
root	:Pointer to Root pointer
item	:Item to append
*/
void wps_append_que(wps_queue **root, wps_queue *item)
{
	wps_queue	*point;

	item->q_forw = NULL;

	if (*root == NULL) {
		item->q_back = NULL;
		*root =item;
	}
	else {
		point = *root;

		while (point->q_forw != NULL) point = point->q_forw;

		/* Link back wps_queue */
		point->q_forw = item;
		item->q_back = point;
	}

	return;
}

/* Delete a item from a wps_queue ---------------------------------------------- */
/*
root	:Pointer to Root pointer
item	:Item to delete
*/
void wps_remove_que(wps_queue **root, wps_queue *item)
{
	/* Delete forword link */
	if (item->q_forw != NULL) item->q_forw->q_back = item->q_back;

	/* Delete back link */
	if (item->q_back == NULL) {
		/*
		 * 1999.07.03
		 * Ensure that the node is really the first node of the link.
		 */
		if (*root == item) *root = item->q_forw;
	}
	else
		item->q_back->q_forw = item->q_forw;

	item->q_back = NULL;
	item->q_forw = NULL;

	return;
}

/* Count number of node in a wps_queue ----------------------------------------- */
int wps_count_que(wps_queue *qp)
{
	int	i = 0;

	while (qp != NULL) {
		qp = qp->q_forw;
		i++;
	}

	return (i);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -