Returns error code when it fails to get the value of tzplatform envrionment variable. 34/73934/3 accepted/tizen/common/20160610.183510 accepted/tizen/ivi/20160613.022107 accepted/tizen/mobile/20160613.022130 accepted/tizen/tv/20160613.022036 accepted/tizen/wearable/20160613.022053 submit/tizen/20160610.110149
authorshingil.kang <shingil.kang@samsung.com>
Fri, 10 Jun 2016 05:58:36 +0000 (14:58 +0900)
committershingil.kang <shingil.kang@samsung.com>
Fri, 10 Jun 2016 09:50:31 +0000 (18:50 +0900)
- 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 <shingil.kang@samsung.com>
src/services.c

index 94558c64ee27430120a248b66eaa6e04ab3a5364..a1c00086a9d02c544c9784c0dcc40633078f33f2 100644 (file)
@@ -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);
 }