s.c
来自「一个免费的SMART CARD OS系统。」· C语言 代码 · 共 71 行
C
71 行
/* ============================================================================ Simu test ========================================================================= *//* */#include "platform.h"#include "socket.h"#include "exp_simumsg.h"short gPort = 2000;jbyte ats[] = { 0x3b, 0x00, 0x90, 0x00 };jbyte card_response[] = { 0x90, 0x00 };void error( char * msg ){ printf( "error : %s\n", msg ); exit(-1);}int main(int argc, char ** argv){ SOCKET s; SIMUMSG msg; SIMUMSG* msgR; if (argc > 1 && atoi( argv[1] ) ) { gPort = atoi( argv[1] ); } printf("simu on port %d\n", gPort); if (init_socket() != JY_OK) error("can not init socket"); if (accept_socket(gPort,&s) != JY_OK) exit(-1); if (receive_simumsg(s,&msgR) != JY_OK) exit(-1); printf("receive k=%d p=%d\n",msgR->kindof,msgR->param); free_simumsg(msgR); printf("Send ATS\n"); msg.kindof = SIMUMSG_TCL_BLOCK; msg.param = sizeof(ats); msg.pdata = ats; if (send_simumsg(s,&msg) != JY_OK) error("can not send msg"); if (receive_simumsg(s,&msgR) != JY_OK) error("can not receive msg"); printf("receive k=%d param=0x%.2X (%d)\n",msgR->kindof,msgR->param,msgR->param); free_simumsg(msgR); printf("Send answer \n"); msg.kindof = SIMUMSG_TCL_BLOCK; msg.param = sizeof(card_response); msg.pdata = card_response; if (send_simumsg(s,&msg) != JY_OK) error("can not send msg"); if (receive_simumsg(s,&msgR) != JY_OK) error("can not receive msg"); printf("receive k=%d param=0x%.2X (%d)\n",msgR->kindof,msgR->param,msgR->param); free_simumsg(msgR); printf("\npress a key to stop this marvelous server ..."); getchar(); if (close_socket(s) != JY_OK) error("can not close socket"); if (done_socket() != JY_OK) error("can not finish socket"); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?