about summary refs log tree commit diff
path: root/src/base
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-12-08 00:26:55 +0100
committeroy <Tom_Adams@web.de>2010-12-08 00:26:55 +0100
commit9ef5e64916deb3faae1fdee2f1be6f4b7f33f1f8 (patch)
treeade10fd0bf8da17383249eac6d8c04a54003c935 /src/base
parent7c26dcbadd710e2aa0b8a010ecb2c03b7be56caa (diff)
downloadzcatch-9ef5e64916deb3faae1fdee2f1be6f4b7f33f1f8.tar.gz
zcatch-9ef5e64916deb3faae1fdee2f1be6f4b7f33f1f8.zip
added function to add a time stamp string
Diffstat (limited to 'src/base')
-rw-r--r--src/base/system.c11
-rw-r--r--src/base/system.h13
2 files changed, 24 insertions, 0 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 5799d972..bf0c6aa9 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -1280,6 +1280,17 @@ void str_hex(char *dst, int dst_size, const void *data, int data_size)
 	}
 }
 
+void str_timestamp(char *buffer, int buffer_size)
+{
+	time_t time_data;
+	struct tm *time_info;
+	
+	time(&time_data);
+	time_info = localtime(&time_data);
+	strftime(buffer, buffer_size, "%Y-%m-%d_%H-%M-%S", time_info);
+	buffer[buffer_size-1] = 0;	/* assure null termination */
+}
+
 int mem_comp(const void *a, const void *b, int size)
 {
 	return memcmp(a,b,size);
diff --git a/src/base/system.h b/src/base/system.h
index 39e7c994..2aca4de1 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -914,6 +914,19 @@ const char *str_find(const char *haystack, const char *needle);
 */
 void str_hex(char *dst, int dst_size, const void *data, int data_size);
 
+/*
+	Function: str_timestamp
+		Copies a time stamp in the format year-month-day_hour-minute-second to the string.
+
+	Parameters:
+		buffer - Pointer to a buffer that shall receive the time stamp string.
+		buffer_size - Size of the buffer.
+
+	Remarks:
+		- Guarantees that buffer string will contain zero-termination.
+*/
+void str_timestamp(char *buffer, int buffer_size);
+
 /* Group: Filesystem */
 
 /*