From: Kim Gunsoo Date: Thu, 28 May 2015 13:03:12 +0000 (+0900) Subject: Add new command "capability" to get the platform capability information. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a06f145a727c81554d9da54e06e14d875623980;p=sdk%2Ftools%2Fsdb.git Add new command "capability" to get the platform capability information. Change-Id: Id351161877ba1598625c8e996fbf47260a5306cd Signed-off-by: Kim Gunsoo --- diff --git a/src/command_function.c b/src/command_function.c index 46486cc..d3b8d34 100644 --- a/src/command_function.c +++ b/src/command_function.c @@ -704,6 +704,30 @@ int uninstall(int argc, char **argv) { return 0; } +#define CAPBUF_SIZE 4096 +int get_capability(int argc, char ** argv) { + char full_cmd[16] = {0,}; + char cap_buffer[CAPBUF_SIZE] = {0,}; + uint16_t len = 0; + + snprintf(full_cmd, sizeof(full_cmd), "capability:"); + D(COMMANDLINE_MSG_FULL_CMD, argv[0], full_cmd); + int fd = sdb_connect(full_cmd); + + if(fd >= 0) { + readx(fd, &len, sizeof(uint16_t)); + if (len > CAPBUF_SIZE-1) { + len = CAPBUF_SIZE-1; + } + readx(fd, cap_buffer, len); + + fprintf(stdout, "%s\n", cap_buffer); + sdb_close(fd); + return 0; + } + return 1; +} + // Get the package temporary path. Returns minus if exception happens. static int get_pkg_tmp_dir(char* pkg_tmp_dir){ diff --git a/src/command_function.h b/src/command_function.h index fc49f9e..19ddf69 100644 --- a/src/command_function.h +++ b/src/command_function.h @@ -59,5 +59,6 @@ int install(int argc, char **argv); int uninstall(int argc, char **argv); int forkserver(int argc, char** argv); int shell(int argc, char ** argv); +int get_capability(int argc, char ** argv); #endif /* COMMAND_FUNCTION_H_ */ diff --git a/src/commandline.c b/src/commandline.c index 3b7c92d..3fe1885 100755 --- a/src/commandline.c +++ b/src/commandline.c @@ -612,6 +612,11 @@ static void create_cmd_list(LIST_NODE** cmd_list) { create_command(&da_cmd , COMMANDLINE_DA_NAME, NULL, 0, EMPTY_STRING, da, COMMANDLINE_DA_MAX_ARG, COMMANDLINE_DA_MIN_ARG); prepend(cmd_list, da_cmd ); + + COMMAND* capability_cmd = NULL; + create_command(&capability_cmd, COMMANDLINE_CAPABILITY_NAME, NULL, + 0, EMPTY_STRING, get_capability, COMMANDLINE_CAPABILITY_MAX_ARG, COMMANDLINE_CAPABILITY_MIN_ARG); + prepend(cmd_list, capability_cmd); } int process_cmdline(int argc, char** argv) { diff --git a/src/sdb_constants.c b/src/sdb_constants.c index 7e23d38..510428c 100644 --- a/src/sdb_constants.c +++ b/src/sdb_constants.c @@ -269,6 +269,10 @@ const int COMMANDLINE_FORKSERVER_MAX_ARG = 1; const int COMMANDLINE_FORKSERVER_MIN_ARG = 1; + const char* COMMANDLINE_CAPABILITY_NAME = "capability"; + const int COMMANDLINE_CAPABILITY_MAX_ARG = 0; + const int COMMANDLINE_CAPABILITY_MIN_ARG = 0; + const char* COMMANDLINE_SERIAL_SHORT_OPT = "s"; const char* COMMANDLINE_SERIAL_LONG_OPT = "serial"; const char* COMMANDLINE_SERIAL_DESC[] = { diff --git a/src/sdb_constants.h b/src/sdb_constants.h index 8ef1be8..3d8ea04 100644 --- a/src/sdb_constants.h +++ b/src/sdb_constants.h @@ -223,6 +223,11 @@ typedef enum host_type HOST_TYPE; extern const int COMMANDLINE_FORKSERVER_MAX_ARG; extern const int COMMANDLINE_FORKSERVER_MIN_ARG; + extern const char* COMMANDLINE_CAPABILITY_NAME; + extern const int COMMANDLINE_CAPABILITY_MAX_ARG; + extern const int COMMANDLINE_CAPABILITY_MIN_ARG; + + extern const char* COMMANDLINE_SERIAL_SHORT_OPT; extern const char* COMMANDLINE_SERIAL_LONG_OPT; extern const char* COMMANDLINE_SERIAL_DESC[];