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

📄 new_repos.c

📁 sco unix下c语言开发工具库
💻 C
字号:
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include "all.h"
#include "macro_def.h"
#include "new_monitor.h"

extern	int	tomon;

/***************************************************************
功能:
写监控信息
ENTRY:
	long	type	信息类型:交易或其它
	char	*buf	数据缓存
	int	len	长度
RETURN:
	0:函数执行结束或监控暂停都返回0
	-1:交易监控消息队列不存在或向交易监控消息队列发送消息失败
****************************************************************/
int new_repos(type, buf, len)
long	type;
char	*buf;
int	len;
{
	int  	mqid,i;
	MONITOR_MSG msnd;
	PUBLIC	*pub;
	T_msgtrans tran;

	if (getmon() == -1)
		return(-1);

	if (!monitor_ok()) {
		errcall(DEBUG, "monitor 未激活状态或共享内存异常.");
	}

	msnd.wtype = type;
	memset ( msnd.buff, '\0', sizeof(msnd.buff) );

	if ( type == MSG_TRANS ) {
		pub = (PUBLIC *) buf;
		tran.tran_type = pub->Tran_type;
		tran.old_tran_type = pub->Void_tran_type;
		tran.oldold_tran_type = pub->Void_old_tran_type;
		strcpy ( tran.msgid, pub->Msg_id);
		strcpy ( tran.merchant_id, pub->Merchant_id);
		strcpy ( tran.terminal_id, pub->Terminal_id);
		if ( tran.tran_type == NET_LOGIN || 
		     tran.tran_type == NET_CHGKEY ||
		     tran.tran_type == NET_LOGOUT ) {
			strcpy( tran.acq_bankid, pub->Snd_bank_id);
			strcpy( tran.acq_hostid, pub->Snd_host_id);
#ifdef DEBUG1
errcall(ERROR, "rcv%s,snd%s,acq%s,iss%s,resp%s", pub->Rcv_bank_id, pub->Snd_bank_id, pub->Acq_bank_id, pub->Iss_bank_id, pub->Resp_bank_id);
#endif
		} else {
			strcpy ( tran.acq_bankid, pub->Acq_bank_id);
			strcpy ( tran.acq_hostid, pub->Acq_host_id);
		}
		tran.saf_flag = pub->Saf_flag;
		strcpy ( tran.mcc, pub->Mcc);
		strcpy ( tran.mode, pub->Input_mode);
		strcpy ( tran.card_no, pub->Card_no);
		strcpy ( tran.expire, pub->Exp_date);
		strcpy ( tran.amount, pub->Tran_amount);
		strcpy ( tran.authno, pub->Auth_no);
		strcpy ( tran.ret_code, pub->Resp_code);
#ifdef zgx010616_modi
		strcpy ( tran.ret_bankid, pub->Resp_bank_id);
		strcpy ( tran.ret_hostid, pub->Resp_host_id);
#else
		if ( tran.tran_type == NET_LOGIN || 
		     tran.tran_type == NET_CHGKEY ||
		     tran.tran_type == NET_LOGOUT ) {
			strcpy( tran.ret_bankid, pub->Rcv_bank_id);
			strcpy( tran.ret_hostid, pub->Rcv_host_id);
		} else {
			strcpy ( tran.ret_bankid, pub->Resp_bank_id);
			if (!strcmp(pub->Resp_host_id, ""))
				strcpy(tran.ret_hostid, "00");
			else
			strcpy ( tran.ret_hostid, pub->Resp_host_id);
		}
#endif
		
		memcpy ( msnd.buff, &tran, sizeof(msnd.buff));
	} else
		memcpy ( msnd.buff, buf, sizeof(msnd.buff));
	

	i = msgsnd(tomon, &msnd, sizeof(msnd.buff), IPC_NOWAIT);
	if (i == -1) {
		errcall(ERROR, "msgsnd monitor err![%d:%d]", tomon, errno);
		return(-1);
	}

	return(0);
}

⌨️ 快捷键说明

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