?? pg_client.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 + -