From: ho.namkoong Date: Thu, 21 Nov 2013 09:21:02 +0000 (+0900) Subject: SDB: modify sdb uninstall X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F12700%2F1;p=sdk%2Ftools%2Fsdb.git SDB: modify sdb uninstall 1. describe about pkg_id in help page 2. refine uninstall error message Change-Id: I14f8d2ec7c42058f276163f0b72c2a5dcbd82ac2 Signed-off-by: ho.namkoong --- diff --git a/src/command_function.c b/src/command_function.c index b95a3d1..d588ecc 100644 --- a/src/command_function.c +++ b/src/command_function.c @@ -645,20 +645,40 @@ static int get_pkgtype_from_app_id(const char* app_id, void** extargv) { } char buf[100] = ""; - int rl_result = read_line(result, buf, 100); - if(rl_result < 0) { - D("Error to read buffer (fd=%d)\n", rl_result); - return rl_result; + int rl_result = read_lines(result, buf, 100); + if(rl_result <= 0) { + fprintf(stderr, "error: package '%s' does not exist\n", app_id); + return -1; + } + + if(rl_result > 1) { + fprintf(stderr, "error: '%s' is not unique package id\n", app_id); + return -1; } sdb_close(result); result = -1; + char* end_line = strchr(buf, '\n'); + + if(end_line != NULL) { + *end_line = '\0'; + } + if(strstr(buf, "[tpk]") != NULL) { result = 1; - } else if(strstr(buf, "[wgt]") != NULL) { + } + else if(strstr(buf, "[wgt]") != NULL) { result = 0; } + else { + if(strstr(buf, "error") != NULL) { + fprintf(stderr, "%s\n", buf); + } + else { + fprintf(stderr, "error: not supported package type '%s'\n", buf); + } + } return result; } diff --git a/src/file_sync_functions.c b/src/file_sync_functions.c index ad833b3..385af7a 100644 --- a/src/file_sync_functions.c +++ b/src/file_sync_functions.c @@ -92,7 +92,6 @@ int initialize_remote(char* path, void** extargv) { int fd = sdb_connect("sync:", extargv); if(fd < 0) { - fprintf(stderr,"cannot sync remote: %s\n", strerror(errno)); return -1; } diff --git a/src/sdb_constants.c b/src/sdb_constants.c index 0f88bd7..bc31029 100644 --- a/src/sdb_constants.c +++ b/src/sdb_constants.c @@ -220,10 +220,12 @@ const char* COMMANDLINE_UNINSTALL_NAME = "uninstall"; const char* COMMANDLINE_UNINSTALL_DESC[] = { - "uninstall an app from the device" + "uninstall an app from the device", + "the is an unique 10-digit unique identifier for the application. The following command shows an example:", + "Ex.) sdb uninstall ko983dw33q" }; const int COMMANDLINE_UNINSTALL_DESC_SIZE = GET_ARRAY_SIZE(COMMANDLINE_UNINSTALL_DESC, char*); - const char* COMMANDLINE_UNINSTALL_ARG_DESC = ""; + const char* COMMANDLINE_UNINSTALL_ARG_DESC = ""; const int COMMANDLINE_UNINSTALL_MAX_ARG = 1; const int COMMANDLINE_UNINSTALL_MIN_ARG = 1; diff --git a/src/strutils.c b/src/strutils.c index e7444b7..d3d5417 100755 --- a/src/strutils.c +++ b/src/strutils.c @@ -41,6 +41,23 @@ void free_strings(char **array, int n) } } +int read_lines(const int fd, char* ptr, unsigned int maxlen) +{ + int lines = 0; + while (1) { + int len = read_line(fd, ptr, maxlen); + if(len < 0) { + break; + } + ptr += len; + *ptr++ = '\n'; + len++; + maxlen -= len; + lines++; + } + return lines; +} + int read_line(const int fd, char* ptr, const unsigned int maxlen) { unsigned int n = 0; diff --git a/src/strutils.h b/src/strutils.h index d5bf30b..ef8cd3b 100644 --- a/src/strutils.h +++ b/src/strutils.h @@ -5,6 +5,7 @@ size_t tokenize(const char *str, const char *delim, char *tokens[], size_t max_tokens); void free_strings(char **array, int n); +int read_lines(const int fd, char* ptr, const unsigned int maxlen); int read_line(const int fd, char* ptr, const unsigned int maxlen); char *s_strncpy(char *dest, const char *source, size_t n); size_t s_strnlen(const char *s, size_t maxlen);