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

📄 msgmng.h

📁 在SCO UNIX制定界面程序 可根据文件配制菜单,而不必修改源程序,非常方便
💻 H
字号:
#ifndef _MSGMNG_H_
#define _MSGMNG_H_

#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <signal.h>
#include <setjmp.h>

typedef unsigned char	uchar;

/*
#define MAX_MNGQ_NUM		32
#define MAX_MSGLOG_NUM		8096
#define MAX_MSGRLOG_NUM		1024
#define PUBLIC_MSGDATA_SIZE	256*1024
#define MSG_WAIT_LOG_SIZE	1024
*/

#define PRIVATE_MSGLOG_NUM	128
#define PRIVATE_MSGDATA_SIZE	16*1024

#define MSG_QUEUE_SRC		0
#define MSG_W_LOG_SRC		1
#define MSG_LOG_SRC		2
#define MSG_R_LOG_SRC		3
#define MSG_DATA_SRC		4
#define MSG_WAIT_MSGLOG_FREE	5
#define MSG_WAIT_MSGDATA_FREE	6
#define SPEC_SEM_NUM		7


#define MSGMNG_INTERNAL		30

#define PERMS			0666

/* Only for 32bits Platform */

#define V_PTR(p) 	(void *)((unsigned long )p-(unsigned long )_msg_mng)
#define R_PTR(p) 	(void *)((unsigned long )p+(unsigned long )_msg_mng)

struct MSG_LOG {
		void *next;

		long 	mtype;
		time_t 	snd_tm;
		uchar	sig_flag;
		
		int  size;
		void *data;
};

struct MSG_R_LOG {
		void *next;

		long 	mtype;
		pid_t 	pid;
};

struct MSG_W_LOG {
		void 	*next;
		
		long 	mtype;
		pid_t	pid;
		uchar 	sig_flag;
};

struct MSG_QUEUE_LOG {
	int 			flag;
	key_t			msg_key;
	int 			max_delay_time;
	
	void			*msg_r_log;
	void			*msg_log_first;
	void			*msg_log_last;
	void			*msg_log_pri;
	void			*msg_w_log_first;
	void			*msg_w_log_last;
	struct MSG_LOG		priv_msg_log_spool[PRIVATE_MSGLOG_NUM];
	char			priv_data_spool[PRIVATE_MSGDATA_SIZE];
};

struct MSG_INFO {
	int	MAX_MNGQ_NUM;
	int	MAX_MSGLOG_NUM;
	int	MAX_MSGRLOG_NUM;
	int	MSG_WAIT_LOG_SIZE;
	int	PUBLIC_MSGDATA_SIZE;
};

struct MSG_MNG {
	struct MSG_INFO		msg_info;
	void			*msg_queue_log;

	struct MSG_LOG 		*msg_log_spool;
	void			*msg_log_free;

	struct MSG_R_LOG	*msg_r_log_spool;
	void			*msg_r_log_free;

	struct MSG_W_LOG	*msg_w_log_spool;
	void			*msg_w_log_free;

	char			*msg_data_spool;
	
	uchar 			wait_msg_log_free;
	uchar			wait_msg_data_free;
};

struct msg_stru {
		long mtype;
		char *data;
};

extern struct MSG_LOG *get_msg_log_free ();
extern int put_msg_log_free (struct MSG_LOG *msg_log);

extern struct MSG_R_LOG *get_msg_r_log_free ();
extern int put_msg_r_log_free (struct MSG_R_LOG *msg_w_log);

extern struct MSG_W_LOG *get_msg_w_log_free ();
extern int put_msg_w_log_free (struct MSG_W_LOG *msg_w_log);

extern void *Malloc ( int msgid , int size );
extern void Free ( void *p );

extern int MAX_MNGQ_NUM;
extern int MAX_MSGLOG_NUM;
extern int MAX_MSGRLOG_NUM;
extern int MSG_WAIT_LOG_SIZE;
extern int PUBLIC_MSGDATA_SIZE;

#endif //#ifndef MSGMNG_H_

⌨️ 快捷键说明

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