From 300ad90afa3c9142ebfe3bcc344432ee760bd3c9 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Tue, 8 Dec 2015 17:31:12 +0900 Subject: [PATCH] apply coding rule Signed-off-by: Ji-hoon Jung Change-Id: Ia240e077268d9d1ce92befe7eb2a58a7e238df2f --- test/smartcard_unit_test.c | 391 +++++++++++++++---------------------- 1 file changed, 153 insertions(+), 238 deletions(-) diff --git a/test/smartcard_unit_test.c b/test/smartcard_unit_test.c index 1e18840..5bce7f7 100644 --- a/test/smartcard_unit_test.c +++ b/test/smartcard_unit_test.c @@ -19,57 +19,52 @@ typedef struct { tc_table_t tc_table[] = { /* manage api*/ - {"smartcard_initialize" ,1}, //OK - {"smartcard_deinitialize" ,2}, //OK + {"smartcard_initialize", 1}, + {"smartcard_deinitialize", 2}, /* service api */ - {"smartcard_get_readers" ,3},//OK - {"smartcard_get_version" ,4},//OK + {"smartcard_get_readers", 3}, + {"smartcard_get_version", 4}, /* reader api */ - {"smartcard_reader_get_name" ,5},//OK - {"smartcard_reader_is_secure_element_present" ,6},//OK - {"smartcard_reader_open_session" ,7},//OK - {"smartcard_reader_close_sessions" ,8},//OK + {"smartcard_reader_get_name", 5}, + {"smartcard_reader_is_secure_element_present", 6}, + {"smartcard_reader_open_session", 7}, + {"smartcard_reader_close_sessions", 8}, /* session api */ - {"smartcard_session_get_reader", 9},//OK - {"smartcard_session_get_atr", 10},//OK - {"smartcard_session_close", 11},//OK - {"smartcard_session_is_closed", 12},//OK - {"smartcard_session_close_channels", 13},//OK - {"smartcard_session_open_basic_channel", 14}, //good - {"smartcard_session_open_logical_channel", 15}, //good + {"smartcard_session_get_reader", 9}, + {"smartcard_session_get_atr", 10}, + {"smartcard_session_close", 11}, + {"smartcard_session_is_closed", 12}, + {"smartcard_session_close_channels", 13}, + {"smartcard_session_open_basic_channel", 14}, + {"smartcard_session_open_logical_channel", 15}, /* channel api */ - {"smartcard_channel_close", 16}, //good - {"smartcard_channel_is_basic_channel", 17}, //good - {"smartcard_channel_is_closed", 18}, // good - {"smartcard_channel_get_select_response", 19}, //good - {"smartcard_channel_get_session", 20}, //good - {"smartcard_channel_transmit", 21}, //good - {"smartcard_channel_transmit_get_response", 22}, //good - {"smartcard_channel_select_next", 23}, //not good - - /* -----------*/ - {"Finish" , 0x00ff}, - {NULL , 0x0000}, + {"smartcard_channel_close", 16}, + {"smartcard_channel_is_basic_channel", 17}, + {"smartcard_channel_is_closed", 18}, + {"smartcard_channel_get_select_response", 19}, + {"smartcard_channel_get_session", 20}, + {"smartcard_channel_transmit", 21}, + {"smartcard_channel_transmit_get_response", 22}, + {"smartcard_channel_select_next", 23}, + + /* -----------*/ + {"Finish" , 0x00ff}, + {NULL , 0x0000}, }; void tc_usage_print(void) { int i = 0; - while (tc_table[i].tc_name) - { + while (tc_table[i].tc_name) { if (tc_table[i].tc_code != 0x00ff) - { TC_PRT("Key %d : usage %s", tc_table[i].tc_code, tc_table[i].tc_name); - } else - { - TC_PRT("Key %d : usage %s\n\n", 0x00ff, tc_table[i].tc_name); - } + TC_PRT("Key %d : usage %s\n\n", 0x00ff, tc_table[i].tc_name); i++; } @@ -85,81 +80,74 @@ int test_input_callback(void *data) TC_PRT("Finished"); g_main_loop_quit(main_loop); break; - case 1: //smartcard_initialize + case 1: { int ret; ret = smartcard_initialize(); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard initialize success"); else TC_PRT("smartcard initialize failed"); } break; - case 2: //smartcard_deinitialize + case 2: { int ret; ret = smartcard_deinitialize(); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard deinitialize success"); else TC_PRT("smartcard deinitialize failed"); } break; - case 3: //smartcard_get_readers + case 3: { int pLength; int *phReaders = NULL; ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_get_readers is success"); TC_PRT("reader handle : %d", phReaders[0]); TC_PRT("readers length : %d", pLength); - } - else - { + } else { TC_PRT("smartcard_get_readers is failed : %d", ret); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 5: //smartcard_reader_get_name + case 5: { int pLength; int *phReaders = NULL; ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { char * pReader = NULL; ret = smartcard_reader_get_name(phReaders[0], &pReader); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_reader_get_name success"); TC_PRT("reader name : %s", pReader); - } - else - { + } else { TC_PRT("smartcard_reader_get_name failed : %d", ret); } - if(pReader != NULL) + if (pReader != NULL) free(pReader); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 6: //smartcard_reader_is_secure_element_present + case 6: { int pLength; int *phReaders = NULL; @@ -167,25 +155,21 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_is_secure_element_present(phReaders[0], &is_present); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_reader_is_secure_element_present is success"); TC_PRT("reader secure element present : %d", is_present); - } - else - { + } else { TC_PRT("smartcard_reader_is_secure_element_present is failed : %d", ret); } } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 7: //smartcard_reader_open_session + case 7: { int pLength; int *phReaders = NULL; @@ -193,28 +177,24 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_reader_open_session is success"); TC_PRT("session : %d", (int)session); - } - else - { + } else { TC_PRT("smartcard_reader_open_session is failed : %d", ret); } ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 8: //smartcard_reader_close_sessions + case 8: { int pLength; int *phReaders = NULL; @@ -222,35 +202,27 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_reader_close_sessions(phReaders[0]); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_reader_close_sessions success"); - } else - { TC_PRT("smartcard_reader_close_sessions failed : %d", ret); - } - } - else - { + } else { TC_PRT("open session failed : %d", ret); } ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 9: //smartcard_session_get_reader + case 9: { int pLength; int *phReaders = NULL; @@ -260,36 +232,31 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_get_reader(session, &reader); ret = smartcard_reader_get_name(reader, &pReader); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_session_get_reader success"); TC_PRT("reader name : %s", pReader); - } - else - { + } else { TC_PRT("smartcard_session_get_reader failed"); } - if(pReader != NULL) + if (pReader != NULL) free(pReader); } ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 10: //smartcard_session_get_atr + case 10: { int i = 0; int pLength; @@ -298,27 +265,22 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { pLength = 0; unsigned char * pAtr = NULL; ret = smartcard_session_get_atr(session, &pAtr, &pLength); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_serssion_get_atr success : %d", pLength); g_print("response is "); - for(i = 0; i < pLength; i++) + for (i = 0; i < pLength; i++) g_print("%x ", (int)pAtr[i]); g_print("\n"); - } - else - { + } else { TC_PRT("smartcard_serssion_get_atr is failed"); } } @@ -326,11 +288,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 11: //smartcard_session_close + case 11: { int pLength; int *phReaders = NULL; @@ -338,25 +300,23 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_close(session); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_session_close is success"); else TC_PRT("smartcard_session_close is failed"); } } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 12: //smartcard_session_is_closed + case 12: { int pLength; int *phReaders = NULL; @@ -365,26 +325,24 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_close(session); ret = smartcard_session_is_closed(session, &is_closed); - if(ret == SMARTCARD_ERROR_NONE && is_closed == true) + if (ret == SMARTCARD_ERROR_NONE && is_closed == true) TC_PRT("smartcard_session_is_closed is success"); else TC_PRT("smartcard_session_is_closed is failed"); } } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 13: //smartcard_session_close_channels + case 13: { int pLength; int *phReaders = NULL; @@ -392,14 +350,12 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_close_channels(session); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_session_close_channels is success"); else TC_PRT("smartcard_session_close_channels is failed"); @@ -408,11 +364,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 14: //smartcard_session_open_basic_channel + case 14: { int pLength; int *phReaders = NULL; @@ -422,14 +378,12 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_open_basic_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_session_open_basic_channel is success : %d", (int)channel); else TC_PRT("smartcard_session_open_basic_channel is failed"); @@ -438,11 +392,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 15: //smartcard_session_open_logical_channel + case 15: { int pLength; int *phReaders = NULL; @@ -452,14 +406,12 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_open_logical_channel(session, aid, 12, 0x04, &channel); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_session_open_basic_channel is success : %d", (int)channel); else TC_PRT("smartcard_session_open_basic_channel is failed : %d", ret); @@ -468,11 +420,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 16: //smartcard_channel_close + case 16: { int pLength; int *phReaders = NULL; @@ -482,18 +434,15 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_close(channel); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_channel_close is success"); else TC_PRT("smartcard_channel_close is failed : %d", ret); @@ -503,11 +452,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 17: //smartcard_channel_is_basic_channel + case 17: { int pLength; int *phReaders = NULL; @@ -517,19 +466,16 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { bool is_basic = true; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_is_basic_channel(channel, &is_basic); - if(ret == SMARTCARD_ERROR_NONE && is_basic == false) + if (ret == SMARTCARD_ERROR_NONE && is_basic == false) TC_PRT("smartcard_channel_is_basic_channel is success"); else TC_PRT("smartcard_channel_is_basic_channel is failed"); @@ -539,11 +485,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 18: //smartcard_channel_is_closed + case 18: { int pLength; int *phReaders = NULL; @@ -553,20 +499,17 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { bool is_close = false; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_close(channel); ret = smartcard_channel_is_closed(channel, &is_close); - if(ret == SMARTCARD_ERROR_NONE && is_close == true) + if (ret == SMARTCARD_ERROR_NONE && is_close == true) TC_PRT("smartcard_channel_is_closed is success"); else TC_PRT("smartcard_channel_is_closed is failed"); @@ -576,11 +519,11 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 19: //smartcard_channel_get_select_response + case 19: { int pLength = 5; int *phReaders = NULL; @@ -590,44 +533,38 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { int i; unsigned char * pSelectResponse; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_get_select_response(channel, &pSelectResponse, &pLength); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_channel_get_select_response is success"); - for(i = 0; i < pLength; i++) + for (i = 0; i < pLength; i++) g_print("%x ", (int)pSelectResponse[i]); - } - else - { + } else { TC_PRT("smartcard_channel_get_select_response is failed"); } } - if(pSelectResponse != NULL) + if (pSelectResponse != NULL) free(pSelectResponse); } ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; - case 20: // smartcard_channel_get_session + case 20: { int pLength; int *phReaders = NULL; @@ -637,20 +574,17 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { int session_handle; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_get_session(channel, &session_handle); - if(ret == SMARTCARD_ERROR_NONE) + if (ret == SMARTCARD_ERROR_NONE) TC_PRT("smartcard_channel_get_session is success: %d", session_handle); else TC_PRT("smartcard_channel_get_session is failed"); @@ -660,7 +594,7 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; @@ -678,28 +612,22 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_channel_transmit is success"); g_print("response is "); - for(i = 0; i < resp_len; i++) + for (i = 0; i < resp_len; i++) g_print("%x ", (int)response[i]); g_print("\n"); - } - else - { + } else { TC_PRT("smartcard_channel_transmit is failed"); } } @@ -708,7 +636,7 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; @@ -725,32 +653,26 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { int i; unsigned char * ptransmitResponse; ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len); ret = smartcard_channel_transmit_retrieve_response(channel, &ptransmitResponse, &pLength); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { TC_PRT("smartcard_channel_transmit_get_response is success"); g_print("response is "); - for(i = 0; i < pLength; i++) + for (i = 0; i < pLength; i++) g_print("%x ", (int)ptransmitResponse[i]); g_print("\n"); - } - else - { + } else { TC_PRT("smartcard_channel_transmit_get_response is failed"); } } @@ -759,7 +681,7 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; @@ -773,18 +695,15 @@ int test_input_callback(void *data) ret = smartcard_get_readers(&phReaders, &pLength); - if(ret == SMARTCARD_ERROR_NONE && pLength != 0) - { + if (ret == SMARTCARD_ERROR_NONE && pLength != 0) { ret = smartcard_reader_open_session(phReaders[0], &session); - if(ret == SMARTCARD_ERROR_NONE && session != 0) - { + if (ret == SMARTCARD_ERROR_NONE && session != 0) { ret = smartcard_session_open_logical_channel(session, aid, 12, 0x00, &channel); - if(ret == SMARTCARD_ERROR_NONE) - { + if (ret == SMARTCARD_ERROR_NONE) { bool is_next = true; ret = smartcard_channel_select_next(channel, &is_next); - if(ret == SMARTCARD_ERROR_NONE && is_next == false) + if (ret == SMARTCARD_ERROR_NONE && is_next == false) TC_PRT("smartcard_channel_select_next is success"); else TC_PRT("smartcard_channel_select_next is failed"); @@ -793,7 +712,7 @@ int test_input_callback(void *data) ret = smartcard_session_close(session); } - if(phReaders != NULL) + if (phReaders != NULL) free(phReaders); } break; @@ -801,12 +720,12 @@ int test_input_callback(void *data) break; } - return 0; + return 0; } static gboolean key_event_cb(GIOChannel *chan, - GIOCondition cond, - gpointer data) + GIOCondition cond, + gpointer data) { char buf[BUFFER_LEN] = { 0 }; @@ -832,10 +751,6 @@ int main(int argc, char ** argv) { GIOChannel *key_io; -//#if !GLIB_CHECK_VERSION(2,35,0) -// g_type_init(); -//#endif - key_io = g_io_channel_unix_new(fileno(stdin)); g_io_channel_set_encoding(key_io, NULL, NULL); -- 2.34.1