queue.h

来自「基于UNIX的中间件编程,只能运行于UNIX操作系统」· C头文件 代码 · 共 101 行

H
101
字号
/******************************************************	queue.h:The header file for the queue source file****				zhoushijie****					2000/3******************************************************/#include "include.h"/*--------------------------------------------------------------------- define the max transaction the dead message queue can contains---------------------------------------------------------------------*/#define RECORD  3/*---------------------------------------------------------------------  define the max lengthof the  message ---------------------------------------------------------------------*/#define MAXLEN  512/*-----------------------------------------------		队列数据结构-----------------------------------------------*/#define IP_ALEN				4typedef  char	IPaddr[IP_ALEN+1]; typedef struct  {	char packettype[3];	char sn[11];	char requesttype[3];	char oprcode[7];	IPaddr source;	IPaddr destination;	char message[MAXLEN+1]; }MESSAGESTRUCTURE;/*---------------------------------------------define the request message queue structure---------------------------------------------*/typedef struct{	MESSAGESTRUCTURE MessageQueue;	int flag;	}MESSAGEQUEUE;/*----------------------------------------------------define the queue data structure----------------------------------------------------*/typedef int MAXQUEUE;typedef int QUEUECOUNT;typedef  MESSAGEQUEUE QueueEntry;typedef struct QueueNode{	QueueEntry entry;	struct QueueNode *next;}QueueNode;typedef struct Queue{	QUEUECOUNT count;	QueueNode *front;	QueueNode *rear;}Queue;/*--------------------------------------------------declare the functions--------------------------------------------------*/void CreateQueue(Queue *q);void AppendNode(QueueNode *x,Queue *q);int QueueSize(Queue *q);int QueueFull(Queue *q,MAXQUEUE max);void ServeNode(QueueNode **p,Queue *q);int QueueEmpty(Queue *q);void ClearQueue(Queue *q);void DestroyQueue(Queue *q);void QueueFront(QueueEntry *x,Queue  *q);void QueueFrontNode(QueueNode *p,Queue *q);void TraverseQueue(Queue *q,int (Visit(QueueEntry x)));int  DeleteQueueNode(QueueNode *node,Queue *q,QueueNode **ReturnNode);QueueNode *MakeQueueNode(QueueEntry x);int AllocateNode(Queue *Source,Queue *Destination,MESSAGESTRUCTURE m_struct);void SetNodeEntryContent(QueueNode *node,MESSAGESTRUCTURE message);Queue *CopyQueue(Queue *destination,Queue *source);int  Error(char *message);void Warning(char *message);

⌨️ 快捷键说明

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