+ if (ustcomm_connect_app(pid, &app_fd)) {
+ ERR("could not connect to PID %u", (unsigned int) pid);
+ return -1;
+ }
+
+ req_header.command = LIST_TRACE_EVENTS;
+ req_header.size = 0;
+
+ result = ustcomm_send(app_fd, &req_header, NULL);
+ if (result != 1) {
+ ERR("error while requesting trace_event list");
+ return -1;
+ }
+
+ result = ustcomm_recv_alloc(app_fd, &res_header, &big_str);
+ if (result != 1) {
+ ERR("error while receiving markers list");
+ return -1;
+ }
+
+ close(app_fd);
+
+ tmp_tes = (struct trace_event_status *)
+ zmalloc(sizeof(struct trace_event_status) *
+ (ustcmd_count_nl(big_str) + 1));
+ if (tmp_tes == NULL) {
+ ERR("Failed to allocate TES array");
+ return -1;
+ }
+
+ /* Parse received reply string (format: "[name]"): */
+ while (big_str[i] != '\0') {
+ sscanf(big_str + i, "trace_event: %a[^\n]",
+ &tmp_tes[tes_ind].name);
+ while (big_str[i] != '\n') {
+ ++i; /* Go to next '\n' */
+ }
+ ++i; /* Skip current pointed '\n' */
+ ++tes_ind;
+ }
+ tmp_tes[tes_ind].name = NULL;
+
+ *tes = tmp_tes;
+
+ free(big_str);
+ return 0;
+}
+
+/**
+ * Set socket path
+ *
+ * @param sock_path Socket path
+ * @param pid Traced process ID
+ * @return 0 if successful, or error
+ */
+int ustcmd_set_sock_path(const char *sock_path, pid_t pid)