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

📄 pg_client.cpp

📁 实现pg接口功能
💻 CPP
字号:
/**************************************************************** * PG接口主处理程序					 * Language:		C++					 * OS Platform:   	UNIX						 * Authors:						 * Date:						 * Copyight (C)  	 ****************************************************************/#include "pg_net.h"#include "pg_head.h"#ifdef HP_UX#define __cplusplus  199708L #endif#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/time.h>#include <string.h>#include <strings.h>#include <errno.h>#ifdef HP_UX#include <sys/pstat.h>#include <mntent.h>#endif#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <signal.h>#include <sys/ddi.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>#include <alloca.h>extern "C" md5_calc (unsigned char *, unsigned char *, unsigned int);CRw_net	Rw_net;int main(int argc,void ** argv){	int 		sockfd,i,len1;	struct sockaddr cliaddr;	socklen_t	clilen;	pid_t		pid;	PGAuthenReqDef	PGAuth_Req;	PGAuthenResDef	PGAuth_Res;		char	*pw,*buf,digest[48],pw1[50];	if ((sockfd = Rw_net.set_sockfd(18813,"10.25.79.97")) < 0)	{		printf("Cannot get sockfd!\n");		exit(0);	}		PGAuth_Req.msg_head.msg_type = AUTHEN_REQ_MSG;	PGAuth_Req.msg_head.msg_version = 1;	strcpy(PGAuth_Req.msg_head.transaction_id,"12345678");	strcpy(PGAuth_Req.timestamp,"22222222222");	strcpy(PGAuth_Req.account,(const char *)argv[1]);	/*pw = (char *)alloca(100);	buf = pw;	strcpy(buf,(const char *)argv[2]);	buf=buf+1;	strcpy(buf,"123456");	md5_calc((unsigned char *)digest,(unsigned char *)pw,(unsigned int)strlen(pw));*/	len1=strlen((const char *)argv[2]);	strcpy(pw1,(const char *)argv[2]);	strcpy(pw1+len1,"123456");	pw1[len1+6]='\0';	printf("pw1=%s结束\n",pw1);	md5_calc((unsigned char *)digest,(unsigned char *)pw1,(unsigned int)(len1+6));	printf("digest=(%s )strlen(digest)=%d结束\n",digest,strlen(digest));	for(i=0;i<strlen((const char *)digest);i++)	{		printf("%0x ",(unsigned char)digest[i]);	}	printf("\n");	//strcpy(PGAuth_Req.passwd,(const char *)digest);	strcpy(PGAuth_Req.passwd,(const char *)argv[2]);	strcpy(PGAuth_Req.account_type,(const char *)argv[3]);	if (Rw_net.write_all(sockfd,(void *)&PGAuth_Req,sizeof(PGAuth_Req)) != sizeof(PGAuth_Req))	{		printf("send PGAuth_Req failed!\n");		exit(0);	}		if (Rw_net.read_all(sockfd,(void *)&PGAuth_Res,sizeof(PGAuth_Res)) != sizeof(PGAuth_Res))	{		printf("recv PGAuth_Res failed!\n");		exit(0);	}	printf("result = %d\n",PGAuth_Res.result);	return 0;	}

⌨️ 快捷键说明

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