dovecot-2.1: Use t_strflocaltime() where possible.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jan 10 22:57:16 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/d4c506d8f534
changeset: 13924:d4c506d8f534
user: Timo Sirainen <tss at iki.fi>
date: Tue Jan 10 22:57:09 2012 +0200
description:
Use t_strflocaltime() where possible.
diffstat:
src/doveadm/doveadm-util.c | 8 ++------
src/lib-storage/mail-storage.c | 11 ++++-------
src/lib-storage/mailbox-list.c | 12 ++++--------
src/lib/iostream-rawlog.c | 8 ++------
src/util/rawlog.c | 11 +++--------
5 files changed, 15 insertions(+), 35 deletions(-)
diffs (138 lines):
diff -r 22cfba724675 -r d4c506d8f534 src/doveadm/doveadm-util.c
--- a/src/doveadm/doveadm-util.c Tue Jan 10 22:51:52 2012 +0200
+++ b/src/doveadm/doveadm-util.c Tue Jan 10 22:57:09 2012 +0200
@@ -3,6 +3,7 @@
#include "lib.h"
#include "array.h"
#include "network.h"
+#include "time-util.h"
#include "master-service.h"
#include "module-dir.h"
#include "doveadm-settings.h"
@@ -76,12 +77,7 @@
const char *unixdate2str(time_t timestamp)
{
- static char buf[64];
- struct tm *tm;
-
- tm = localtime(×tamp);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
- return buf;
+ return t_strflocaltime("%Y-%m-%d %H:%M:%S", timestamp);
}
const char *doveadm_plugin_getenv(const char *name)
diff -r 22cfba724675 -r d4c506d8f534 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Tue Jan 10 22:51:52 2012 +0200
+++ b/src/lib-storage/mail-storage.c Tue Jan 10 22:57:09 2012 +0200
@@ -8,6 +8,7 @@
#include "istream.h"
#include "eacces-error.h"
#include "mkdir-parents.h"
+#include "time-util.h"
#include "var-expand.h"
#include "mail-index-private.h"
#include "mail-index-alloc-cache.h"
@@ -466,16 +467,12 @@
void mail_storage_set_internal_error(struct mail_storage *storage)
{
- struct tm *tm;
- char str[256];
+ const char *str;
- tm = localtime(&ioloop_time);
+ str = t_strflocaltime(MAIL_ERRSTR_CRITICAL_MSG_STAMP, ioloop_time);
i_free(storage->error_string);
- storage->error_string =
- strftime(str, sizeof(str),
- MAIL_ERRSTR_CRITICAL_MSG_STAMP, tm) > 0 ?
- i_strdup(str) : i_strdup(MAIL_ERRSTR_CRITICAL_MSG);
+ storage->error_string = i_strdup(str);
storage->error = MAIL_ERROR_TEMP;
}
diff -r 22cfba724675 -r d4c506d8f534 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c Tue Jan 10 22:51:52 2012 +0200
+++ b/src/lib-storage/mailbox-list.c Tue Jan 10 22:57:09 2012 +0200
@@ -8,6 +8,7 @@
#include "sha1.h"
#include "hash.h"
#include "home-expand.h"
+#include "time-util.h"
#include "unichar.h"
#include "settings-parser.h"
#include "imap-utf7.h"
@@ -1401,16 +1402,11 @@
void mailbox_list_set_internal_error(struct mailbox_list *list)
{
- struct tm *tm;
- char str[256];
+ const char *str;
- tm = localtime(&ioloop_time);
-
+ str = t_strflocaltime(MAIL_ERRSTR_CRITICAL_MSG_STAMP, ioloop_time);
i_free(list->error_string);
- list->error_string =
- strftime(str, sizeof(str),
- MAIL_ERRSTR_CRITICAL_MSG_STAMP, tm) > 0 ?
- i_strdup(str) : i_strdup(MAIL_ERRSTR_CRITICAL_MSG);
+ list->error_string = i_strdup(str);
list->error = MAIL_ERROR_TEMP;
}
diff -r 22cfba724675 -r d4c506d8f534 src/lib/iostream-rawlog.c
--- a/src/lib/iostream-rawlog.c Tue Jan 10 22:51:52 2012 +0200
+++ b/src/lib/iostream-rawlog.c Tue Jan 10 22:57:09 2012 +0200
@@ -77,16 +77,12 @@
struct ostream **output)
{
static unsigned int counter = 0;
- const char *in_path, *out_path;
+ const char *timestamp, *in_path, *out_path;
struct istream *old_input;
struct ostream *old_output;
- struct tm *tm;
- char timestamp[50];
int in_fd, out_fd;
- tm = localtime(&ioloop_time);
- if (strftime(timestamp, sizeof(timestamp), "%Y%m%d-%H%M%S", tm) <= 0)
- i_fatal("strftime() failed");
+ timestamp = t_strflocaltime("%Y%m%d-%H%M%S", ioloop_time);
counter++;
in_path = t_strdup_printf("%s/%s.%s.%u.in",
diff -r 22cfba724675 -r d4c506d8f534 src/util/rawlog.c
--- a/src/util/rawlog.c Tue Jan 10 22:51:52 2012 +0200
+++ b/src/util/rawlog.c Tue Jan 10 22:57:09 2012 +0200
@@ -11,6 +11,7 @@
#include "ostream.h"
#include "process-title.h"
#include "restrict-access.h"
+#include "time-util.h"
#include "master-service.h"
#include <stdlib.h>
@@ -226,15 +227,9 @@
static void proxy_open_logs(struct rawlog_proxy *proxy, const char *path)
{
- time_t now;
- struct tm *tm;
- const char *fname;
- char timestamp[50];
+ const char *fname, *timestamp;
- now = time(NULL);
- tm = localtime(&now);
- if (strftime(timestamp, sizeof(timestamp), "%Y%m%d-%H%M%S", tm) <= 0)
- i_fatal("strftime() failed");
+ timestamp = t_strflocaltime("%Y%m%d-%H%M%S", time(NULL));
if ((proxy->flags & RAWLOG_FLAG_LOG_INPUT) != 0) {
fname = t_strdup_printf("%s/%s-%s.in", path, timestamp,
More information about the dovecot-cvs
mailing list