From 2d8f3831e54a0586e5eeb2117c2ef7d14d2565bd Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Wed, 13 Sep 2017 11:02:29 +0900 Subject: [PATCH] fix coding rule error Change-Id: Id06eb0c9d5c49d6247d3ad22264e7a5e995cd6d6 --- include/appsvc.h | 22 ++--- test/appsvc_test.c | 285 ++++++++++++++++++++++++----------------------------- 2 files changed, 140 insertions(+), 167 deletions(-) diff --git a/include/appsvc.h b/include/appsvc.h index 737dfc5..4127603 100755 --- a/include/appsvc.h +++ b/include/appsvc.h @@ -146,7 +146,7 @@ typedef enum _appsvc_return_val { APPSVC_RET_EINVAL = -2, /**< Invalid argument */ APPSVC_RET_ERROR = -1, /**< General error */ APPSVC_RET_OK = 0 /**< General success */ -}appsvc_return_val; +} appsvc_return_val; /** @@ -156,14 +156,14 @@ typedef enum _appsvc_result_val { APPSVC_RES_CANCEL = -2, /**< Cancel by system */ APPSVC_RES_NOT_OK = -1, /**< Fail by user */ APPSVC_RES_OK = 0 /**< Success by user */ -}appsvc_result_val; +} appsvc_result_val; /** * @brief appsvc_res_fn is appsvc result function - * @param[out] b result bundle - * @param[out] request_code request code - * @param[out] result result value + * @param[out] b result bundle + * @param[out] request_code request code + * @param[out] result result value * @param[out] data user-supplied data */ typedef void (*appsvc_res_fn)(bundle *b, int request_code, appsvc_result_val result, void *data); @@ -529,9 +529,9 @@ int appsvc_usr_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, vo static int iter_fn(const char* appid, void *data) { printf("\t==========================\n"); - printf("\t appid: %s\n", appid); - printf("\t==========================\n"); - return 0; + printf("\t appid: %s\n", appid); + printf("\t==========================\n"); + return 0; } ... @@ -890,8 +890,8 @@ int appsvc_send_result(bundle *b, appsvc_result_val result); * * @param[in] op operation * @param[in] mime_type mime-type - * @param[in] scheme scheme of uri - * @param[in] defapp default application + * @param[in] scheme scheme of uri + * @param[in] defapp default application * * @retval APPSVC_RET_OK - success * @retval APPSVC_RET_ERROR - general error @@ -920,7 +920,7 @@ int appsvc_set_defapp(const char *op, const char *mime_type, const char *uri, * @par Description: * This API unset the default application(package name) associated with op, uri and mime-type. * - * @param[in] defapp default application + * @param[in] defapp default application * * @retval APPSVC_RET_OK - success * @retval APPSVC_RET_ERROR - general error diff --git a/test/appsvc_test.c b/test/appsvc_test.c index cb4a62f..293601d 100755 --- a/test/appsvc_test.c +++ b/test/appsvc_test.c @@ -28,21 +28,19 @@ #include "appsvc.h" - -static char** gargv; +static char **gargv; static int gargc; -static char* cmd; +static char *cmd; static int apn_pid; +typedef struct _test_func_t { + char *name; + int (*func) (); + char *desc; + char *usage; +} test_func_t; -typedef struct _test_func_t{ - char* name; - int(*func)(); - char* desc; - char* usage; -}test_func_t; - -void __set_bundle_from_args(bundle * kb) +void __set_bundle_from_args(bundle *kb) { int opt; char *op = NULL; @@ -50,69 +48,68 @@ void __set_bundle_from_args(bundle * kb) char *uri = NULL; char *package = NULL; char *category = NULL; - char* key = NULL; - char* val_array[128]; - - while( (opt = getopt(gargc,gargv,"d:o:m:u:p:c:")) != -1){ - switch(opt) { - case 'o': - if(optarg) - op = strdup(optarg); - break; - case 'm': - if(optarg) - mime = strdup(optarg); - break; - case 'u': - if(optarg) - uri = strdup(optarg); - break; - case 'p': - if(optarg) - package = strdup(optarg); - break; - case 'c': - if(optarg) - category = strdup(optarg); - break; - case 'd': - if(optarg){ - int i = 0; - key = strtok(optarg,","); - while(1) - { - val_array[i] = strtok(NULL,","); - if(val_array[i] == NULL) - break; - i++; - } - if(i==1) - appsvc_add_data(kb, key, val_array[0]); - else if(i>1) - appsvc_add_data_array(kb, key, (const char **)val_array, i); + char *key = NULL; + char *val_array[128]; + + while ((opt = getopt(gargc, gargv, "d:o:m:u:p:c:")) != -1) { + switch (opt) { + case 'o': + if (optarg) + op = strdup(optarg); + break; + case 'm': + if (optarg) + mime = strdup(optarg); + break; + case 'u': + if (optarg) + uri = strdup(optarg); + break; + case 'p': + if (optarg) + package = strdup(optarg); + break; + case 'c': + if (optarg) + category = strdup(optarg); + break; + case 'd': + if (optarg) { + int i = 0; + key = strtok(optarg, ","); + while (1) { + val_array[i] = strtok(NULL, ","); + if (val_array[i] == NULL) + break; + i++; } - break; + if (i == 1) + appsvc_add_data(kb, key, val_array[0]); + else if (i > 1) + appsvc_add_data_array(kb, key, (const char **)val_array, i); + } + break; } - } + } - if(op) { - appsvc_set_operation(kb,op); + if (op) { + appsvc_set_operation(kb, op); free(op); } - if(mime) { - appsvc_set_mime(kb,mime); + if (mime) { + appsvc_set_mime(kb, mime); free(mime); } - if(uri) { - appsvc_set_uri(kb,uri); + if (uri) { + appsvc_set_uri(kb, uri); free(uri); } - if(package) { - appsvc_set_appid(kb,package); + if (package) { + appsvc_set_appid(kb, package); free(package); } - if(category) { - appsvc_set_category(kb,category); + if (category) { + appsvc_set_category(kb, category); free(category); } } @@ -120,36 +117,32 @@ void __set_bundle_from_args(bundle * kb) int run_svc() { int ret; - bundle *kb=NULL; + bundle *kb = NULL; kb = bundle_create(); - if(kb == NULL) - { + if (kb == NULL) { printf("bundle creation fail\n"); return -1; } printf("[run_svc test]\n"); __set_bundle_from_args(kb); - - ret = appsvc_usr_run_service(kb,0,NULL, NULL, getuid()); - - if(ret >= 0){ + + ret = appsvc_usr_run_service(kb, 0, NULL, NULL, getuid()); + + if (ret >= 0) { printf("open service success\n"); - if(kb) - { - bundle_free(kb); - kb=NULL; + if (kb) { + bundle_free(kb); + kb = NULL; } return 0; - } - else{ + } else { printf("open service fail\n"); - if(kb) - { - bundle_free(kb); - kb=NULL; + if (kb) { + bundle_free(kb); + kb = NULL; } - return -1; + return -1; } } @@ -162,40 +155,33 @@ static void prt_recvd_bundle(const char *key, const int type, const bundle_keyva char *val; size_t size; int i; - - if(bundle_keyval_type_is_array((bundle_keyval_t *)kv) > 0) { - bundle_keyval_get_array_val((bundle_keyval_t *)kv, - (void ***)&array_val, (unsigned int *)&array_len, - &array_item_size); - - for (i=0;i 0) { + bundle_keyval_get_array_val((bundle_keyval_t *)kv, (void ***)&array_val, (unsigned int *)&array_len, &array_item_size); + + for (i = 0; i < array_len; i++) printf("recvd - key: %s[%d], value: %s\n", key, i, array_val[i]); - } - } else { bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&val, &size); - printf("recvd - key: %s, value: %s\n",key,val); - } + printf("recvd - key: %s, value: %s\n", key, val); + } } static void cb_func(bundle *kb, int request_code, appsvc_result_val result, void *data) { int num; num = (int)data; - - if(result == APPSVC_RES_CANCEL){ - printf("==== %d : canceled(preemptted) my request ===\n",num); - } - else{ - printf("==== %d : result packet === result %d\n",num, (int)result); + + if (result == APPSVC_RES_CANCEL) { + printf("==== %d : canceled(preemptted) my request ===\n", num); + } else { + printf("==== %d : result packet === result %d\n", num, (int)result); //bundle_iterate(kb, prt_recvd_bundle, NULL); bundle_foreach(kb, prt_recvd_bundle, NULL); - } - + } - if(strcmp(cmd,"run_svc_res")==0){ + if (strcmp(cmd, "run_svc_res") == 0) { printf("==== end of appsvc_run() ====\n"); ecore_main_loop_quit(); } @@ -203,67 +189,60 @@ static void cb_func(bundle *kb, int request_code, appsvc_result_val result, void int run_svc_res() { - static int num=0; + static int num = 0; int ret; - bundle *kb=NULL; + bundle *kb = NULL; kb = bundle_create(); - if(kb == NULL) - { + if (kb == NULL) { printf("bundle creation fail\n"); return -1; } - + printf("[run_svc_res test]\n"); - - __set_bundle_from_args(kb); - - ret = appsvc_usr_run_service(kb, 0, cb_func, (void*)num, getuid()); - - if(ret >= 0){ + + __set_bundle_from_args(kb); + + ret = appsvc_usr_run_service(kb, 0, cb_func, (void *)num, getuid()); + + if (ret >= 0) { printf("open service success\n"); - if(kb) - { - bundle_free(kb); - kb=NULL; + if (kb) { + bundle_free(kb); + kb = NULL; } return 0; - } - else{ + } else { printf("open service fail\n"); - if(kb) - { - bundle_free(kb); - kb=NULL; + if (kb) { + bundle_free(kb); + kb = NULL; } - return -1; + return -1; } } - static test_func_t test_func[] = { - {"run_svc", run_svc, "run_svc test", - "[usage] run_svc -o [-m ] [-u ] [-d \",\"]..."}, - {"run_svc_res", run_svc_res, "run_svc_res test", - "[usage] run_svc_res -o [-m ] [-u ] [-d \",\"]..."}, - + "[usage] run_svc -o [-m ] [-u ] [-d \",\"]..."}, + {"run_svc_res", run_svc_res, "run_svc_res test", + "[usage] run_svc_res -o [-m ] [-u ] [-d \",\"]..."}, + }; -int callfunc(char* testname) +int callfunc(char *testname) { test_func_t *tmp; int res; int i; - for(i=0; iname)==0){ + if (strcmp(testname, tmp->name) == 0) { res = tmp->func(); - if(strcmp(testname,"all")){ - if(res < 0) + if (strcmp(testname, "all")) { + if (res < 0) printf("... test failed\n"); else printf("... test successs ret = %d\n", res); @@ -273,30 +252,27 @@ int callfunc(char* testname) return 0; } - -void print_usage(char* progname) +void print_usage(char *progname) { test_func_t *tmp; int i; - - printf("[usage] %s ...\n",progname); + + printf("[usage] %s ...\n", progname); printf(" - available cmd list\n"); - for(i=0; iname, tmp->desc); - printf("\t\t%s\n",tmp->usage); + printf("\t%s : %s\n", tmp->name, tmp->desc); + printf("\t\t%s\n", tmp->usage); } } - static Eina_Bool run_func(void *data) { callfunc(cmd); - if(strcmp(cmd,"run_svc_res") == 0 ) + if (strcmp(cmd, "run_svc_res") == 0) return 0; else ecore_main_loop_quit(); @@ -304,31 +280,28 @@ static Eina_Bool run_func(void *data) return 0; } - -int main(int argc, char** argv) +int main(int argc, char **argv) { - if(argc < 3){ + if (argc < 3) { print_usage(argv[0]); exit(0); } - + ecore_init(); cmd = argv[1]; gargc = argc; gargv = argv; apn_pid = atoi(argv[2]); - - aul_launch_init(NULL,NULL); + + aul_launch_init(NULL, NULL); //aul_listen_app_dead_signal(dead_tracker,NULL); //aul_listen_app_dead_signal(NULL,NULL); ecore_idler_add(run_func, NULL); - + ecore_main_loop_begin(); - + return 0; } - - -- 2.7.4