#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
+#include <sys/time.h>
#if HAVE_MMAP
# include <sys/mman.h>
#endif
return ret;
}
+
+/**
+ * virTimestamp:
+ *
+ * Return an allocated string containing the current date and time,
+ * followed by ": ". Return NULL on allocation failure.
+ */
+char *
+virTimestamp(void)
+{
+ struct timeval cur_time;
+ struct tm time_info;
+ char timestr[100];
+ char *timestamp;
+
+ gettimeofday(&cur_time, NULL);
+ localtime_r(&cur_time.tv_sec, &time_info);
+
+ strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", &time_info);
+
+ if (virAsprintf(×tamp, "%s.%03d: ",
+ timestr, (int) cur_time.tv_usec / 1000) < 0) {
+ return NULL;
+ }
+
+ return timestamp;
+}
char* virFilePid(const char *dir,
const char *name);
+
int virFileWritePidPath(const char *path,
pid_t pid) ATTRIBUTE_RETURN_CHECK;
int virFileWritePid(const char *dir,
# define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
+char *virTimestamp(void);
+
#endif /* __VIR_UTIL_H__ */