From: shingil.kang Date: Fri, 10 Jun 2016 05:58:36 +0000 (+0900) Subject: Returns error code when it fails to get the value of tzplatform envrionment variable. X-Git-Tag: submit/tizen/20160610.110149^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6f8c1ddc5d7d940e89f69860f3015304e60b769;p=sdk%2Ftarget%2Fsdbd.git Returns error code when it fails to get the value of tzplatform envrionment variable. - return 0 when succeeded - return 1 when error is occured while getting the value of tzplatform environment variable. - return 2 when tzplatform environment variable is not valid. Change-Id: Ie4530148c43d757f69a3e8457777cbf25cb4dc3d Signed-off-by: shingil.kang --- diff --git a/src/services.c b/src/services.c index 94558c6..a1c0008 100644 --- a/src/services.c +++ b/src/services.c @@ -219,6 +219,12 @@ void rootshell_service(int fd, void *cookie) sdb_close(fd); } +enum tzplatform_get_env_error_status { + NO_ERROR_TZPLATFORM_ENV = 0, + ERROR_TZPLATFORM_ENV_GENERAL = 1, + ERROR_TZPLATFORM_ENV_INVALID_VARIABLES = 2, +}; + void get_tzplatform_env(int fd, void *cookie) { char buf[PATH_MAX] = { 0, }; char *env_name = (char*) cookie; @@ -228,10 +234,16 @@ void get_tzplatform_env(int fd, void *cookie) { char *env_value = tzplatform_getenv(env_id); if (env_value) { D("environment value : %s\n", env_value); - snprintf(buf, sizeof(buf), env_value); - writex(fd, buf, strlen(buf)); + snprintf(buf, sizeof(buf), "%d%s", NO_ERROR_TZPLATFORM_ENV, env_value); + } else { + D("failed to get environment value using tzplatform_getenv"); + snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_GENERAL); } + } else { + D("environment name (%s) is invalid\n", env_name); + snprintf(buf, sizeof(buf), "%d", ERROR_TZPLATFORM_ENV_INVALID_VARIABLES); } + writex(fd, buf, strlen(buf)); free(env_name); sdb_close(fd); }