From: sajal.j Date: Tue, 28 Jun 2016 11:44:58 +0000 (+0530) Subject: Deleted shell_tc X-Git-Tag: accepted/tizen/mobile/20160629.021725^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbea825a399d372b5a4d2fff9d13027145b6eef6;p=platform%2Fcore%2Faccount%2Ffido-client.git Deleted shell_tc Signed-off-by: sajal.j Change-Id: Ife6e4f7a0df45efea0da3e51900ef5e860e01f54 --- diff --git a/test/shell_tc/CMakeLists.txt b/test/shell_tc/CMakeLists.txt deleted file mode 100644 index 0609e1b..0000000 --- a/test/shell_tc/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -SET(FIDO_SHELL_TC fido-shell-tc) - -INCLUDE(FindPkgConfig) -pkg_check_modules(FIDO_SHELL_TC_PKGS REQUIRED - dlog - glib-2.0 - gio-unix-2.0 - capi-base-common -) - -FOREACH(flag ${FIDO_SHELL_TC_PKGS_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test/shell_tc) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common) - - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror -Wno-unused-result") -SET(CMAKE_LDFLAGS "-Wl,-zdefs") - -SET(FIDO_SHELL_TC_SRCS - fido_shell_tc_util.c - fido_shell_tc.c -) - -ADD_EXECUTABLE(${FIDO_SHELL_TC} ${FIDO_SHELL_TC_SRCS}) - -TARGET_LINK_LIBRARIES(${FIDO_SHELL_TC} ${FIDO_SHELL_TC_LDFLAGS}) -TARGET_LINK_LIBRARIES(${FIDO_SHELL_TC} fido-client) - -INSTALL(TARGETS ${FIDO_SHELL_TC} DESTINATION /opt/usr/devel/fido/tc) diff --git a/test/shell_tc/fido_shell_tc.c b/test/shell_tc/fido_shell_tc.c deleted file mode 100644 index 0dac8c1..0000000 --- a/test/shell_tc/fido_shell_tc.c +++ /dev/null @@ -1,421 +0,0 @@ - -#include "fido_shell_tc_util.h" -#include "fido.h" - -#include -#include -#include - -static char *json_reg = "[ { \"header\": { \"upv\": { \"major\": 1, \"minor\": 0 },\"op\":\"Reg\", \"serverData\": \"nwV8EPqS5raZdAgH3GD9Z-ytCA9MkiiWaCsr1GHHNJ2yUh3HaV1HHxd4Z67FefJOD5sQYZvipfg5BavhdWPMecD2SH39aJixoXN9ZaNwRlcftJe9WbtPNDC9q5V9WX7Z5jCwkAwehcI\" }, \"challenge\": \"9pIcUwwrY5eD9o3OwfhkeHLnoIl0vaeJUbxSHMe_XgE\", \"username\":\"ryan\", \"policy\": { \"accepted\": [ [ { \"aaid\": [ \"0001#8001\" ] } ], [ { \"aaid\": [ \"DDDD#F001\" ] } ] ] } } ]"; -static char *json_auth = "[ { \"header\": { \"upv\": { \"major\": 1, \"minor\": 0 }, \"op\": \"Auth\", \"serverData\": \"emKubKMS8RxYOth7J8enT_x7dQWBaO1CiC0fGmSEhX56kq2RYo1LRpwvfHlzYRI3p9Ay-l4zJcV3lX6rQ0CYNWi5nNDabClFm3k0pPj0kX5V-db9ejN_05y2J6wqztSD\" }, \"challenge\": \"1AM2yZY4-9SG4Ns7-hMdB8IV_FTDKFFiUqNJNVbsVoo\", \"transaction\": [ { \"contentType\": \"text/plain\", \"content\": \"VHJhbnNhY3Rpb24gQ29udGVudCBmb3IgVGVzdC4\", \"tcDisplayPNGCharacteristics\": [ { \"width\": 320, \"height\": 240, \"bitDepth\": 16, \"colorType\": 2, \"compression\": 0, \"filter\": 0, \"interlace\": 0 } ] } ], \"policy\": { \"accepted\": [ [ { \"aaid\": [ \"0001#8001\" ] } ], [ { \"aaid\": [ \"DDDD#F001\" ] } ] ] } } ]"; -static char *json_dereg = "[ { \"header\": { \"upv\": { \"major\": \"1\", \"minor\": \"0\" }, \"op\": \"Dereg\" }, \"authenticators\": [ { \"aaid\": \"0001#8001\", \"keyID\": \"uWrbo_8JI1HmPESrNAStTVV8ZbBrzLsf_kZu1QKX2YY\" } ] } ]"; - -void get_user_choice(void); - -static char * -__get_error_code(fido_error_e error_code) -{ - - char *error_str = calloc(1, 128); - - if (error_code == FIDO_ERROR_NONE) - strcpy(error_str, "SUCCESS"); - else if (error_code == FIDO_ERROR_OUT_OF_MEMORY) - strcpy(error_str, "FIDO_ERROR_OUT_OF_MEMORY"); - else if (error_code == FIDO_ERROR_INVALID_PARAMETER) - strcpy(error_str, "FIDO_ERROR_INVALID_PARAMETER"); - else if (error_code == FIDO_ERROR_NO_DATA) - strcpy(error_str, "FIDO_ERROR_NO_DATA"); - else if (error_code == FIDO_ERROR_PERMISSION_DENIED) - strcpy(error_str, "FIDO_ERROR_PERMISSION_DENIED"); - else if (error_code == FIDO_ERROR_NOT_SUPPORTED) - strcpy(error_str, "FIDO_ERROR_NOT_SUPPORTED"); - else if (error_code == FIDO_ERROR_USER_ACTION_IN_PROGRESS) - strcpy(error_str, "FIDO_ERROR_USER_ACTION_IN_PROGRESS"); - else if (error_code == FIDO_ERROR_USER_CANCELLED) - strcpy(error_str, "FIDO_ERROR_USER_CANCELLED"); - else if (error_code == FIDO_ERROR_UNSUPPORTED_VERSION) - strcpy(error_str, "FIDO_ERROR_UNSUPPORTED_VERSION"); - else if (error_code == FIDO_ERROR_NO_SUITABLE_AUTHENTICATOR) - strcpy(error_str, "FIDO_ERROR_NO_SUITABLE_AUTHENTICATOR"); - else if (error_code == FIDO_ERROR_PROTOCOL_ERROR) - strcpy(error_str, "FIDO_ERROR_PROTOCOL_ERROR"); - else if (error_code == FIDO_ERROR_UNTRUSTED_FACET_ID) - strcpy(error_str, "FIDO_ERROR_UNTRUSTED_FACET_ID"); - else - strcpy(error_str, "FIDO_ERROR_UNKNOWN"); - return error_str; -} - -static void -__show_error(int tizen_error_code) -{ - char *error_string = __get_error_code(tizen_error_code); - printf("%s\n", error_string); - fflush(stdout); - free(error_string); -} - -static void -__process_cb(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) -{ - if (tizen_error_code == 0 && uaf_response != NULL) { - - const int max_str_len = strlen(uaf_response) + 500; - char *display_str = calloc(1, max_str_len); - - snprintf(display_str, max_str_len - 1, "UAF Response =%s", uaf_response); - - printf("%s\n", uaf_response); - free(display_str); - } else { - __show_error(tizen_error_code); - } - get_user_choice(); -} - -#define STRING_SIZE_1024 1024 -#define STRING_SIZE_5000 5000 - -void fido_attestation_type_cb_list(fido_auth_attestation_type_e att_type, void *user_data) -{ - char *str = (char *) user_data; - - char tmp[STRING_SIZE_1024] = {0,}; - if (att_type != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Attestation Type = [%d]", att_type); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } -} - -static char * -__get_authinfo_string(const fido_authenticator_h auth) -{ - char str[STRING_SIZE_5000] = {0,}; - str[0] = '\0'; - strcpy(str, "DISCOVER RESPONSE"); - char tmp[STRING_SIZE_1024] = {0,}; - - char *title = NULL; - fido_authenticator_get_title(auth, &title); - if (title) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Title = [%s]", title); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(title); - - char *aaid = NULL; - fido_authenticator_get_aaid(auth, &aaid); - if (aaid) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | AAID = [%s]", aaid); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(aaid); - - char *description = NULL; - fido_authenticator_get_description(auth, &description); - if (description) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Description = [%s]", description); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(description); - - char *scheme = NULL; - fido_authenticator_get_assertion_scheme(auth, &scheme); - if (scheme) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Scheme = [%s]", scheme); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(scheme); - - fido_authenticator_foreach_attestation_type(auth, fido_attestation_type_cb_list, str); - - fido_auth_algo_e get_algo = -1; - fido_authenticator_get_algorithm(auth, &get_algo); - if (get_algo != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Algo = [%d]", get_algo); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - fido_auth_user_verify_type_e user_ver = -1; - fido_authenticator_get_verification_method(auth, &user_ver); - if (user_ver != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Verification = [%d]", user_ver); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - fido_auth_key_protection_type_e key_protection = -1; - fido_authenticator_get_key_protection_method(auth, &key_protection); - if (key_protection != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Key Protection = [%d]", key_protection); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - fido_auth_matcher_protection_type_e matcher_protection = -1; - fido_authenticator_get_matcher_protection_method(auth, &matcher_protection); - if (matcher_protection != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Matcher Protection = [%d]", matcher_protection); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - fido_auth_attachment_hint_e attachment_hint = -1; - fido_authenticator_get_attachment_hint(auth, &attachment_hint); - if (attachment_hint != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Attachment Hint = [%d]", attachment_hint); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - fido_auth_tc_display_type_e tc_discplay = -1; - fido_authenticator_get_tc_discplay(auth, &tc_discplay); - if (tc_discplay != -1) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Tc Display = [%d]", tc_discplay); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - - char *tc_display_type = NULL; - fido_authenticator_get_tc_display_type(auth, &tc_display_type); - if (tc_display_type) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Tc Display Type = [%s]", tc_display_type); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(tc_display_type); - - char *icon = NULL; - fido_authenticator_get_icon(auth, &icon); - if (icon) { - snprintf(tmp, STRING_SIZE_1024 - 1, " | Icon = [%s]", icon); - strncat(str, tmp, STRING_SIZE_1024 - 1); - } - free(icon); - - return strdup(str); -} - -static void -auth_list_cb(const fido_authenticator_h auth, void *user_data) -{ - char *auth_info_str = __get_authinfo_string(auth); - if (auth_info_str != NULL) - printf("%s", auth_info_str); - -} - -void -find_auth(void) -{ - int ret = fido_foreach_authenticator(auth_list_cb, NULL); - - if (ret != FIDO_ERROR_NONE) - __show_error(ret); - - get_user_choice(); -} - -void -check_supported(void) -{ - bool is_supported = false; - int ret = fido_uaf_is_supported(json_reg, &is_supported); - - if (ret != FIDO_ERROR_NONE) { - char *error_string = __get_error_code(ret); - - printf("Check policy resonse: %s\n", error_string); - fflush(stdout); - free(error_string); - } else { - if (is_supported == true) { - printf("Check policy resonse: TRUE\n"); - fflush(stdout); - } else { - printf("Check policy resonse: FALSE\n"); - fflush(stdout); - } - } - get_user_choice(); -} - -void -registration(void) -{ - int ret = fido_uaf_get_response_message(json_reg, NULL, __process_cb, NULL); - if (ret != FIDO_ERROR_NONE) { - __show_error(ret); - get_user_choice(); - } -} - -static void -_process_cb(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) -{ - if (tizen_error_code == 0 && uaf_response != NULL) { - fflush(stdout); - printf("UAF Response =%s\n", uaf_response); - fflush(stdout); - } else { - __show_error(tizen_error_code); - } - get_user_choice(); -} - -void -authentication(void) -{ - if (json_auth != NULL) { - int ret = fido_uaf_get_response_message(json_auth, NULL, _process_cb, NULL); - - if (ret != FIDO_ERROR_NONE) { - __show_error(ret); - get_user_choice(); - } - } -} - -static void -_process_dereg_cb(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) -{ - char *str = __get_error_code(tizen_error_code); - printf("%s\n", str); - fflush(stdout); - free(str); - get_user_choice(); -} - -void -dereg(void) -{ - if (json_reg != NULL) { - int ret = fido_uaf_get_response_message(json_dereg, NULL, _process_dereg_cb, NULL); - - if (ret != FIDO_ERROR_NONE) { - __show_error(ret); - get_user_choice(); - } - } -} - -static void -_process_cb_for_notify_pos(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) -{ - if (tizen_error_code == 0) { - - int ret = fido_uaf_set_server_result(FIDO_SERVER_STATUS_CODE_OK, uaf_response); - - char *str = __get_error_code(ret); - printf("%s\n", str); - fflush(stdout); - free(str); - } else { - __show_error(tizen_error_code); - } - get_user_choice(); -} - -void -set_result_success(void) -{ - if (json_reg != NULL) { - int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_pos, NULL); - - if (ret != FIDO_ERROR_NONE) { - __show_error(ret); - get_user_choice(); - } - } -} - -static void -_process_cb_for_notify_neg(fido_error_e tizen_error_code, const char *uaf_response, void *user_data) -{ - if (tizen_error_code == 0) { - - int ret = fido_uaf_set_server_result(0, uaf_response); - if (ret == FIDO_ERROR_NONE) { - printf("SUCCESS\n"); - } else { - char *str = __get_error_code(ret); - printf("Error Code = %s\n", str); - free(str); - } - fflush(stdout); - } else { - __show_error(tizen_error_code); - } - get_user_choice(); -} - -void -set_result_failure(void) -{ - if (json_reg != NULL) { - int ret = fido_uaf_get_response_message(json_reg, NULL, _process_cb_for_notify_neg, NULL); - - if (ret != FIDO_ERROR_NONE) { - __show_error(ret); - get_user_choice(); - } - } -} - -void -get_user_choice(void) -{ - int sel_opt = 0; - const int options[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; - const char *names[8] = { "Find Authenticator", - "Check UAF Message Supported", - "Registration", - "Authentication", - "De-Registration", - "Set Server Result with Success", - "Set Server Result with Failure", - "Exit"}; - - sel_opt = show_menu("Select action:", options, names, 8); - switch (sel_opt) { - case 1: - find_auth(); - break; - - case 2: - check_supported(); - break; - - case 3: - registration(); - break; - - case 4: - authentication(); - break; - - case 5: - dereg(); - break; - - case 6: - set_result_success(); - break; - - case 7: - set_result_failure(); - break; - - default: - exit(1); - } -} - -int -main(void) -{ - GMainLoop *mainloop = NULL; - - mainloop = g_main_loop_new(NULL, FALSE); - - get_user_choice(); - - g_main_loop_run(mainloop); - - return 0; -} diff --git a/test/shell_tc/fido_shell_tc_util.c b/test/shell_tc/fido_shell_tc_util.c deleted file mode 100644 index 0f092b1..0000000 --- a/test/shell_tc/fido_shell_tc_util.c +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "fido_shell_tc_util.h" -#include "fido.h" - -#include -#include -#include - -void -print_fail_result( - const char *action_name, - int action_return_value) -{ - printf(TEXT_RED - "Error with code %i was occurred during action '%s'" - TEXT_RESET "\n", - action_return_value, - action_name); -} - -void -print_done_result(const char *action_name) -{ - printf(TEXT_YELLOW - "Action '%s' was finished" - TEXT_RESET "\n", - action_name); -} - -void -print_success_result(const char *action_name) -{ - printf(TEXT_GREEN - "Action '%s' was finished successfully" - TEXT_RESET - "\n", action_name); -} - -void -print_action_result( - const char *action_name, - int action_return_value, - notification_type_e notification_type_e) -{ - switch (notification_type_e) { - case FAIL_OR_SUCCESSS: - if (FIDO_ERROR_NONE != action_return_value) - print_fail_result(action_name, action_return_value); - else - print_success_result(action_name); - - break; - case FAIL_OR_DONE: - if (FIDO_ERROR_NONE != action_return_value) - print_fail_result(action_name, action_return_value); - else - print_done_result(action_name); - - break; - default: - print_done_result(action_name); - } -} - -int -input_string(const char *prompt, size_t max_len, char **string) -{ - printf("\n"); - printf("%s ", prompt); - - if (scanf("\n") != 0) - return -1; - - char buffer[max_len]; - int last_char = 0; - buffer[last_char] = '\0'; - buffer[sizeof(buffer) - 1] = ~'\0'; - if (NULL == fgets(buffer, sizeof(buffer), stdin)) - return -1; - - size_t real_string_len = strlen(buffer); - buffer[real_string_len - 1] = '\0'; - *string = (char*)malloc(real_string_len * sizeof(char)); - if (*string == NULL) - return -1; - - strncpy(*string, buffer, real_string_len); - - return strlen(*string); -} - -int -input_size(const char *prompt, size_t max_size, size_t *size) -{ - printf("\n"); - printf("%s ", prompt); - - if (scanf("%20zu", size) == 0) { - if (scanf("%*[^\n]%*c") != 0) { - printf("ERROR: Reading the input line error.\n"); - return -1; - } - printf("ERROR: Incorrect input.\n"); - return -1; - } - scanf("%*[^\n]%*c"); - - return (*size > max_size ? -1 : 0); -} - -int -input_int(const char *prompt, int min_value, int max_value, int *value) -{ - printf("\n"); - printf("%s ", prompt); - - if (scanf("%20i", value) == 0) { - if (scanf("%*[^\n]%*c") != 0) { - printf("ERROR: Reading the input line error.\n"); - return -1; - } - printf("ERROR: Incorrect input.\n"); - return -1; - } - scanf("%*[^\n]%*c"); - - return (*value < min_value || *value > max_value ? -1 : 0); -} - -int -input_double( - const char *prompt, - double min_value, - double max_value, - double *value) -{ - printf("\n"); - printf("%s ", prompt); - - if (scanf("%20lf", value) == 0) { - if (scanf("%*[^\n]%*c") != 0) { - printf("ERROR: Reading the input line error.\n"); - return -1; - } - printf("ERROR: Incorrect input.\n"); - return -1; - } - scanf("%*[^\n]%*c"); - - return (*value < min_value || *value > max_value ? -1 : 0); -} - -bool -show_confirm_dialog(const char *title) -{ - const int options[2] = {1, 2}; - const char *names[2] = { "No", "Yes" }; - - bool answer = false; - - int sel = -1; - while (sel == -1) { - sel = show_menu(title, options, names, 2); - switch (sel) { - case 1: - answer = false; - break; - case 2: - answer = true; - break; - default: - sel = -1; - printf("ERROR: Incorrect input.\n"); - continue; - } - } - - return answer; -} - -int -show_menu( - const char *title, - const int *options, - const char **names, - int number_of_option) -{ - if (NULL == title || NULL == options || NULL == names || 0 >= number_of_option) - return -1; - - int number_size = 1; - - int tn_counter = number_of_option; - while (tn_counter /= 10) - ++number_size; - - int max_len = strlen(title) - number_size - 2; - - int i = 0; - for (i = 0; i < number_of_option; ++i) { - const int temp_len = strlen(names[i]); - if (max_len < temp_len) - max_len = temp_len; - } - - const int full_size = number_size + 2 + max_len; - - printf("\n**"); - for (i = 0; i < full_size; ++i) - printf("*"); - printf("**\n"); - - printf("* %-*s *\n", full_size, title); - - printf("*-"); - for (i = 0; i < full_size; ++i) - printf("-"); - printf("-*\n"); - - for (i = 0; i < number_of_option; ++i) - printf("* %0*i. %-*s *\n", number_size, options[i], max_len, names[i]); - - printf("**"); - for (i = 0; i < full_size; ++i) - printf("*"); - printf("**\n\n"); - - int selection = 0; - printf("Your choice: "); - if (scanf("%25i", &selection) == 0) { - if (scanf("%*[^\n]%*c") != 0) - printf("ERROR: Reading the input line error.\n"); - - printf("ERROR: Incorrect input.\n"); - return -1; - } - scanf("%*[^\n]%*c"); - - return selection; -} - diff --git a/test/shell_tc/fido_shell_tc_util.h b/test/shell_tc/fido_shell_tc_util.h deleted file mode 100644 index e306b6f..0000000 --- a/test/shell_tc/fido_shell_tc_util.h +++ /dev/null @@ -1,175 +0,0 @@ - -#ifndef __FIDO_SHELL_TC_UTIL_H_ -#define __FIDO_SHELL_TC_UTIL_H_ - -#include -#include -#include - -#define TEXT_RED "\x1b[31m" -#define TEXT_GREEN "\x1b[32m" -#define TEXT_YELLOW "\x1b[33m" -#define TEXT_BLUE "\x1b[34m" -#define TEXT_MAGENTA "\x1b[35m" -#define TEXT_CYAN "\x1b[36m" -#define TEXT_RESET "\x1b[0m" - -#ifdef ROOTSTRAP_OUT - -#define LOGD(...) \ -do { \ - printf("<%s:%d>", __FUNCTION__, __LINE__); \ - printf(TEXT_CYAN); \ - printf(__VA_ARGS__); \ - printf(TEXT_RESET "\n"); \ -} while (0) - -#define LOGI(...) \ -do { \ - printf("<%s:%d>", __FUNCTION__, __LINE__); \ - printf(TEXT_GREEN); \ - printf(__VA_ARGS__); \ - printf(TEXT_RESET "\n"); \ -} while (0) - -#define LOGW(...) \ -do { \ - printf("<%s:%d>", __FUNCTION__, __LINE__); \ - printf(TEXT_YELLOW); \ - printf(__VA_ARGS__); \ - printf(TEXT_RESET "\n"); \ -} while (0) - -#define LOGE(...) \ -do { \ - printf("<%s:%d>", __FUNCTION__, __LINE__); \ - printf(TEXT_RED); \ - printf(__VA_ARGS__); \ - printf(TEXT_RESET "\n"); \ -} while (0) - -#endif - - -typedef enum { - FAIL_OR_SUCCESSS, - FAIL_OR_DONE -} notification_type_e; - -/** - * @brief Prints success result of action. - * - * @since_tizen 3.0 - * @param [in] action_name Name of action which result will be printed - * @param [in] action_return_value Return value of action - */ -void print_fail_result( - const char *action_name, - int action_return_value); - -/** - * @brief Prints success result of action. - * - * @since_tizen 3.0 - * @param [in] action_name Name of action which result will be printed - */ -void print_done_result(const char *action_name); - -/** - * @brief Prints success result of action. - * - * @since_tizen 3.0 - * @param [in] action_name Name of action which result will be printed - */ -void print_success_result(const char *action_name); - -/** - * @brief Prints action result. - * - * @since_tizen 3.0 - * @param [in] action_name Name of action which result will be printed - * @param [in] action_return_value Return value of action - * @param [in] notification_type_e Type of notification - */ -void print_action_result( - const char *action_name, - int action_return_value, - notification_type_e notification_type_e); - -/** - * @brief Gets srting from console. - * - * @since_tizen 3.0 - * @param [in] prompt The prompt before getting string value - * @param [in] max_len Maximum length of the string which will be got - * @param [out] string Output string which was got from console - * @return Length of the output string on success, otherwise a negative error value - */ -int input_string(const char *prompt, size_t max_len, char **string); - -/** - * @brief Gets unsigned integer from console. - * - * @since_tizen 3.0 - * @param [in] prompt The prompt before getting unsigned integer value - * @param [in] max_size The thresold for maximum possible value - * @param [out] size The output unsigned integer which was got from console - * @return @c 0 on success, otherwise a negative error value - */ -int input_size(const char *prompt, size_t max_size, size_t *size); - -/** - * @brief Gets integer from console. - * - * @since_tizen 3.0 - * @param [in] prompt The prompt before getting integer value - * @param [in] min_value The thresold for minimum possible value - * @param [in] max_value The thresold for maximum possible value - * @param [out] value The output integer which was got from console - * @return @c 0 on success, otherwise a negative error value - */ -int input_int(const char *prompt, int min_value, int max_value, int *value); - -/** - * @brief Gets double from console. - * - * @since_tizen 3.0 - * @param [in] prompt The prompt before getting double value - * @param [in] min_value The thresold for minimum possible value - * @param [in] max_value The thresold for maximum possible value - * @param [out] value The output double which was got from console - * @return @c 0 on success, otherwise a negative error value - */ -int input_double(const char *prompt, double min_value, double max_value, double *value); - -/** - * @brief Shows confirm dialog in console and gets answer (Yes/No). - * - * @since_tizen 3.0 - * @param [in] title The title for confirm dialog which will be printed - * before input of the answer - * @return false if answer is "No" and true if answer is "Yes" - */ -bool show_confirm_dialog(const char *title); - -/** - * @brief Shows menu in console and allows to get item from the array of options. - * - * @since_tizen 3.0 - * @param [in] title The title for show menu which will be printed - * before options - * @param [in] options The array with integer numbers of options - * which will be shown - * @param [in] names The array with names of options which will - * be shown - * @param [in] number_of_option The number of options which will be shown - * @return The selected item positive number from options array on success, - * otherwise a negative error value - */ -int show_menu( - const char *title, - const int *options, - const char **names, - int number_of_option); - -#endif /* __FIDO_SHELL_TC_UTIL_H_ */