return *reinterpret_cast<UserLog*>(handle);
}
+int audit_user_log_get_time(audit_user_log_h handle,
+ time_t *time, unsigned short *ms)
+{
+ RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(time, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(ms, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+
+ const auto &log = GetUserLog(handle).log;
+ *time = log.time.time;
+ *ms = log.time.millisec;
+
+ return AUDIT_TRAIL_ERROR_NONE;
+}
+
+int audit_user_log_get_pid(audit_user_log_h handle, pid_t *pid)
+{
+ RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(pid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+
+ const auto &log = GetUserLog(handle).log;
+ *pid = log.log.pid;
+
+ return AUDIT_TRAIL_ERROR_NONE;
+}
+
+int audit_user_log_get_type(audit_user_log_h handle, int *type)
+{
+ RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(type, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+
+ const auto &log = GetUserLog(handle).log;
+ *type = log.log.type;
+
+ return AUDIT_TRAIL_ERROR_NONE;
+}
+
+int audit_user_log_get_text(audit_user_log_h handle, const char **text)
+{
+ RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(text, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
+
+ const auto &log = GetUserLog(handle).log;
+ *text = ::strdup(log.log.text.c_str());
+
+ return AUDIT_TRAIL_ERROR_NONE;
+}
+
int audit_trail_foreach_user_log(audit_trail_h handle,
audit_user_log_cb callback, void *user_data)
{
*/
typedef void* audit_user_log_h;
+/**
+ * @brief Get the time of the user audit log
+ * @details This API can be used to get when the user audit log occured from * its handle
+ * @since_tizen 5.0
+ * @param[in] handle The user audit log handle
+ * @param[out] time The time as UNIX epoch timestamp
+ * @param[out] ms milliseconds of the time
+ * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
+ * @retval #AUDIT_TRAIL_ERROR_NONE Successful
+ * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
+ * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+AUDIT_TRAIL_API int audit_user_log_get_time(audit_user_log_h handle,
+ time_t *time, unsigned short *ms);
+
+/**
+ * @brief Get the ID of process who sent the user audit log
+ * @details This API can be used to get a process ID of the user audit log
+ * from its handle.
+ * @since_tizen 5.0
+ * @param[in] handle The user audit log handle
+ * @param[out] type The process ID
+ * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
+ * @retval #AUDIT_TRAIL_ERROR_NONE Successful
+ * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
+ * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+AUDIT_TRAIL_API int audit_user_log_get_pid(audit_user_log_h handle, pid_t *pid);
+
+/**
+ * @brief Get the type number of the user audit log
+ * @details This API can be used to get a type number of the user audit log
+ * from its handle.
+ * @since_tizen 5.0
+ * @param[in] handle The user audit log handle
+ * @param[out] type The number indicating a log type
+ * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
+ * @retval #AUDIT_TRAIL_ERROR_NONE Successful
+ * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
+ * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+AUDIT_TRAIL_API int audit_user_log_get_type(audit_user_log_h handle, int *type);
+
+/**
+ * @brief Get the user audit log as a text
+ * @details This API can be used to get a content of the user audit log
+ * from its handle. The text should be freed when it is no longer
+ * required.
+ * @since_tizen 5.0
+ * @param[in] handle The user audit log handle
+ * @param[out] text The text content of the log
+ * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
+ * @retval #AUDIT_TRAIL_ERROR_NONE Successful
+ * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
+ * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post text should be freed by free()
+ */
+AUDIT_TRAIL_API int audit_user_log_get_text(audit_user_log_h handle, const char **text);
+
/**
* @brief Called to get a audit logs from user processes as an array.
* This function is called with user audit log handles, which can
std::stringstream str;
str << "time={";
+ {
+ time_t time;
+ unsigned short millisec;
+ audit_user_log_get_time(log, &time, &millisec);
+ struct tm *local = localtime(&time);
+
+ str << local->tm_hour << ":" << local->tm_min << ":" << local->tm_sec
+ << "." << millisec;
+ }
str << "},log={";
+ {
+ const char *text;
+ pid_t pid;
+ int type;
+
+ audit_user_log_get_pid(log, &pid);
+ str << "pid=" << pid;
+ audit_user_log_get_type(log, &type);
+ str << ",type=" << type;
+
+ audit_user_log_get_text(log, &text);
+ str << ",text=" << text;
+ }
str << "}";
return str.str();