summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-27 21:22:27 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-27 21:22:27 +0800
commit45ba3a7cba31c011227f613d9fb4768ca156a262 (patch)
tree2fb974379c53b2c11af7046b72d1e44b52444cd3
parent31fd72a8ad2846b605663fa49b1ac3f8503a8350 (diff)
downloadpttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar.gz
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar.bz2
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar.lz
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar.xz
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.tar.zst
pttbbs-45ba3a7cba31c011227f613d9fb4768ca156a262.zip
* add Cdate_mdHMS (we need seconds)
* use bzero instead of memset git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4999 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/common/sys/time.c14
-rw-r--r--pttbbs/common/sys/vbuf.c7
-rw-r--r--pttbbs/include/cmsys.h3
3 files changed, 20 insertions, 4 deletions
diff --git a/pttbbs/common/sys/time.c b/pttbbs/common/sys/time.c
index 6c022698..ec309283 100644
--- a/pttbbs/common/sys/time.c
+++ b/pttbbs/common/sys/time.c
@@ -107,6 +107,20 @@ Cdate_mdHM(const time4_t * clock)
return cdate_buffer;
}
+/**
+ * 13+1 bytes, "12/31 10:01:01\0"
+ */
+const char*
+Cdate_mdHMS(const time4_t * clock)
+{
+ time_t temp = (time_t)*clock;
+ struct tm mytm;
+
+ localtime_r(&temp, &mytm);
+ strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d %H:%M:%S", &mytm);
+ return cdate_buffer;
+}
+
#ifdef TIMET64
char *
ctime4(const time4_t *clock)
diff --git a/pttbbs/common/sys/vbuf.c b/pttbbs/common/sys/vbuf.c
index 4135af71..41f86e45 100644
--- a/pttbbs/common/sys/vbuf.c
+++ b/pttbbs/common/sys/vbuf.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <errno.h>
#include <assert.h>
@@ -81,7 +82,7 @@ VBUFPROTO void
vbuf_new(VBUF *v, size_t szbuf)
{
assert(szbuf > 1);
- memset(v, 0, sizeof(*v));
+ bzero(v, sizeof(*v)); // memset(v, 0, sizeof(*v));
v->buf = (char*)malloc(szbuf);
assert(v->buf);
v->buf_end = v->buf + szbuf;
@@ -93,7 +94,7 @@ VBUFPROTO void
vbuf_delete(VBUF *v)
{
free(v->buf);
- memset(v, 0, sizeof(*v));
+ bzero(v, sizeof(*v)); // memset(v, 0, sizeof(*v));
}
VBUFPROTO void
@@ -108,7 +109,7 @@ vbuf_attach(VBUF *v, char *buf, size_t szbuf)
VBUFPROTO void
vbuf_detach(VBUF *v)
{
- memset(v, 0, sizeof(VBUF));
+ bzero(v, sizeof(*v)); // memset(v, 0, sizeof(*v));
}
VBUFPROTO void
diff --git a/pttbbs/include/cmsys.h b/pttbbs/include/cmsys.h
index 02c2af48..3a8a9dd9 100644
--- a/pttbbs/include/cmsys.h
+++ b/pttbbs/include/cmsys.h
@@ -126,8 +126,9 @@ extern int getHoroscope(int m, int d);
extern const char* Cdate(const time4_t *clock);
extern const char* Cdatelite(const time4_t *clock);
extern const char* Cdatedate(const time4_t * clock);
-extern const char * Cdate_mdHM(const time4_t * clock);
extern const char * Cdate_md(const time4_t * clock);
+extern const char * Cdate_mdHM(const time4_t * clock);
+extern const char * Cdate_mdHMS(const time4_t * clock);
#ifdef TIMET64
struct tm* localtime4(const time4_t *);