util: Add nullvec2str 83/189983/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 3 Oct 2018 09:15:31 +0000 (11:15 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 3 Oct 2018 09:15:31 +0000 (11:15 +0200)
This function will be used to convert char *arr[] arrays
(like argv[] and envp[]) arrays to simple strings.

Change-Id: I352f2cc35ee5f06f6a9e6bc81b45702ea11f711d

src/shared/util.c
src/shared/util.h

index 2a76866..b47fd02 100644 (file)
@@ -800,6 +800,18 @@ char* get_exe_path(pid_t pid)
 
        return result;
 }
+
+char *nullvec2str(char *const vec[])
+{
+       char command[PATH_MAX] = {0, };
+
+       for (char *const *p = vec; *p; ++p) {
+               strncat(command, *p, sizeof(command)-1);
+               strncat(command, " ", sizeof(command)-1);
+       }
+       command[sizeof(command)-1] = 0;
+       return strdup(command);
+}
 /**
  * @}
  */
index 73078e6..c4aa1a6 100644 (file)
@@ -60,6 +60,8 @@ int find_crash_tid(int pid);
 char* get_exe_path(pid_t pid);
 
 char* get_cmd_line(pid_t pid);
+
+char *nullvec2str(char *const vec[]);
 /**
  * @}
  */