diff options
-rw-r--r-- | pttbbs/common/sys/time.c | 14 | ||||
-rw-r--r-- | pttbbs/common/sys/vbuf.c | 7 | ||||
-rw-r--r-- | pttbbs/include/cmsys.h | 3 |
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 *); |