From 35a328e687d7cd9372fe446a5eccc5483119f4c9 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 16 Nov 2017 01:34:42 +0000 Subject: [PATCH] rename date functions --- copy.c | 2 +- from.c | 10 +++---- handler.c | 2 +- imap/message.c | 4 +-- mbox.c | 4 +-- mutt/date.c | 70 ++++++++++++++++++++++----------------------- mutt/date.h | 18 ++++++------ ncrypt/gnupgparse.c | 2 +- parse.c | 8 +++--- pattern.c | 8 +++--- sendlib.c | 6 ++-- 11 files changed, 67 insertions(+), 67 deletions(-) diff --git a/copy.c b/copy.c index fb422e28766..9f6d06b52a9 100644 --- a/copy.c +++ b/copy.c @@ -570,7 +570,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Header *hdr, int flags, LOFF_T new_length = body->length; char date[SHORT_STRING]; - mutt_make_date(date, sizeof(date)); + mutt_date_make_date(date, sizeof(date)); int dlen = mutt_strlen(date); if (dlen == 0) return -1; diff --git a/from.c b/from.c index 492c54c8beb..d92cb62c91c 100644 --- a/from.c +++ b/from.c @@ -52,7 +52,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) mutt_debug(3, "\nis_from(): parsing: %s\n", s); - if (!is_day_name(s)) + if (!mutt_date_is_day_name(s)) { const char *p = NULL; size_t len; @@ -102,7 +102,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) if (!*s) return 0; - if (!is_day_name(s)) + if (!mutt_date_is_day_name(s)) { mutt_debug(1, "is_from(): expected weekday, got: %s\n", s); return 0; @@ -117,7 +117,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) * this could happen when receiving mail from a local user whose login name * is the same as a three-letter abbreviation of the day of the week. */ - if (is_day_name(s)) + if (mutt_date_is_day_name(s)) { s = next_word(s); if (!*s) @@ -125,7 +125,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) } /* now we should be on the month. */ - tm.tm_mon = mutt_check_month(s); + tm.tm_mon = mutt_date_check_month(s); if (tm.tm_mon < 0) return 0; @@ -191,6 +191,6 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) tm.tm_isdst = -1; if (tp) - *tp = mutt_mktime(&tm, 0); + *tp = mutt_date_make_time(&tm, 0); return 1; } diff --git a/handler.c b/handler.c index fefc5619a25..3de4f14ae7e 100644 --- a/handler.c +++ b/handler.c @@ -1506,7 +1506,7 @@ static int external_body_handler(struct Body *b, struct State *s) expiration = mutt_get_parameter("expiration", b->parameter); if (expiration) - expire = mutt_parse_date(expiration, NULL); + expire = mutt_date_parse_date(expiration, NULL); else expire = -1; diff --git a/imap/message.c b/imap/message.c index b52320f7f06..ed98e6fe2b6 100644 --- a/imap/message.c +++ b/imap/message.c @@ -349,7 +349,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) return -1; s++; /* skip past the trailing " */ *ptmp = '\0'; - h->received = imap_parse_date(tmp); + h->received = mutt_date_parse_imap(tmp); } else if (mutt_strncasecmp("RFC822.SIZE", s, 11) == 0) { @@ -1294,7 +1294,7 @@ int imap_append_message(struct Context *ctx, struct Message *msg) MUTT_PROGRESS_SIZE, NetInc, len); imap_munge_mbox_name(idata, mbox, sizeof(mbox), mailbox); - imap_make_date(internaldate, sizeof(internaldate), msg->received); + mutt_date_make_imap(internaldate, sizeof(internaldate), msg->received); imap_flags[0] = imap_flags[1] = 0; if (msg->flags.read) diff --git a/mbox.c b/mbox.c index 8cd6702abbd..7f128ed30e6 100644 --- a/mbox.c +++ b/mbox.c @@ -170,7 +170,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) } } else - hdr->received = t - mutt_local_tz(t); + hdr->received = t - mutt_date_local_tz(t); hdr->env = mutt_read_rfc822_header(ctx->fp, hdr, 0, 0); @@ -313,7 +313,7 @@ static int mbox_parse_mailbox(struct Context *ctx) mx_alloc_memory(ctx); curhdr = ctx->hdrs[ctx->msgcount] = mutt_new_header(); - curhdr->received = t - mutt_local_tz(t); + curhdr->received = t - mutt_date_local_tz(t); curhdr->offset = loc; curhdr->index = ctx->msgcount; diff --git a/mutt/date.c b/mutt/date.c index ab534bae8f7..665dc7bf8ef 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -31,17 +31,17 @@ * | #TimeZones | Lookup table of Time Zones * | #Weekdays | Day of the week (abbreviated) * - * | Function | Description - * | :-------------------- | :-------------------------------------------------- - * | imap_make_date() | Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz - * | imap_parse_date() | Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz - * | is_day_name() | Is the string a valid day name - * | mutt_check_month() | Is the string a valid month name - * | mutt_local_tz() | Calculate the local timezone in seconds east of UTC - * | mutt_make_date() | Write a date in RFC822 format to a buffer - * | mutt_mktime() | Convert `struct tm` to `time_t` - * | mutt_normalize_time() | Fix the contents of a struct tm - * | mutt_parse_date() | Parse a date string in RFC822 format + * | Function | Description + * | :------------------------- | :-------------------------------------------------- + * | mutt_date_check_month() | Is the string a valid month name + * | mutt_date_is_day_name() | Is the string a valid day name + * | mutt_date_local_tz() | Calculate the local timezone in seconds east of UTC + * | mutt_date_make_date() | Write a date in RFC822 format to a buffer + * | mutt_date_make_imap() | Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz + * | mutt_date_make_time() | Convert `struct tm` to `time_t` + * | mutt_date_normalize_time() | Fix the contents of a struct tm + * | mutt_date_parse_date() | Parse a date string in RFC822 format + * | mutt_date_parse_imap() | Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz */ #include "config.h" @@ -211,14 +211,14 @@ static const char *uncomment_timezone(char *buf, size_t buflen, const char *tz) } /** - * mutt_local_tz - Calculate the local timezone in seconds east of UTC + * mutt_date_local_tz - Calculate the local timezone in seconds east of UTC * @param t Time to examine * @retval num Seconds east of UTC * * Returns the local timezone in seconds east of UTC for the time t, * or for the current time if t is zero. */ -time_t mutt_local_tz(time_t t) +time_t mutt_date_local_tz(time_t t) { /* Check we haven't overflowed the time (on 32-bit arches) */ if ((t == TIME_T_MAX) || (t == TIME_T_MIN)) @@ -237,7 +237,7 @@ time_t mutt_local_tz(time_t t) } /** - * mutt_mktime - Convert `struct tm` to `time_t` + * mutt_date_make_time - Convert `struct tm` to `time_t` * @param t Time to convert * @param local Should the local timezone be considered * @retval num Time in Unix format @@ -245,7 +245,7 @@ time_t mutt_local_tz(time_t t) * Convert a struct tm to time_t, but don't take the local timezone into * account unless ``local'' is nonzero */ -time_t mutt_mktime(struct tm *t, int local) +time_t mutt_date_make_time(struct tm *t, int local) { time_t g; @@ -301,7 +301,7 @@ time_t mutt_mktime(struct tm *t, int local) } /** - * mutt_normalize_time - Fix the contents of a struct tm + * mutt_date_normalize_time - Fix the contents of a struct tm * @param tm Time to correct * * If values have been added/subtracted from a struct tm, it can lead to @@ -309,7 +309,7 @@ time_t mutt_mktime(struct tm *t, int local) * * This function will correct any over/under-flow. */ -void mutt_normalize_time(struct tm *tm) +void mutt_date_normalize_time(struct tm *tm) { static const char DaysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, @@ -382,16 +382,16 @@ void mutt_normalize_time(struct tm *tm) } /** - * mutt_make_date - Write a date in RFC822 format to a buffer + * mutt_date_make_date - Write a date in RFC822 format to a buffer * @param buf Buffer for result * @param buflen Length of buffer * @retval ptr Buffer containing result */ -char *mutt_make_date(char *buf, size_t buflen) +char *mutt_date_make_date(char *buf, size_t buflen) { time_t t = time(NULL); struct tm *l = localtime(&t); - time_t tz = mutt_local_tz(t); + time_t tz = mutt_date_local_tz(t); tz /= 60; @@ -402,7 +402,7 @@ char *mutt_make_date(char *buf, size_t buflen) } /** - * mutt_check_month - Is the string a valid month name + * mutt_date_check_month - Is the string a valid month name * @param s String to check * @retval num Index into Months array (0-based) * @retval -1 Error @@ -410,7 +410,7 @@ char *mutt_make_date(char *buf, size_t buflen) * @note Only the first three characters are checked * @note The comparison is case insensitive */ -int mutt_check_month(const char *s) +int mutt_date_check_month(const char *s) { for (int i = 0; i < 12; i++) if (mutt_strncasecmp(s, Months[i], 3) == 0) @@ -420,14 +420,14 @@ int mutt_check_month(const char *s) } /** - * is_day_name - Is the string a valid day name + * mutt_date_is_day_name - Is the string a valid day name * @param s String to check * @retval boolean * * @note Only the first three characters are checked * @note The comparison is case insensitive */ -bool is_day_name(const char *s) +bool mutt_date_is_day_name(const char *s) { if ((strlen(s) < 3) || !*(s + 3) || !ISSPACE(*(s + 3))) return false; @@ -440,7 +440,7 @@ bool is_day_name(const char *s) } /** - * mutt_parse_date - Parse a date string in RFC822 format + * mutt_date_parse_date - Parse a date string in RFC822 format * @param[in] s String to parse * @param[out] tz_out Pointer to timezone (optional) * @retval num Unix time in seconds @@ -450,7 +450,7 @@ bool is_day_name(const char *s) * * The 'timezone' field is optional; it defaults to +0000 if missing. */ -time_t mutt_parse_date(const char *s, struct Tz *tz_out) +time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) { int count = 0; char *t = NULL; @@ -492,7 +492,7 @@ time_t mutt_parse_date(const char *s, struct Tz *tz_out) break; case 1: /* month of the year */ - i = mutt_check_month(t); + i = mutt_date_check_month(t); if ((i < 0) || (i > 11)) return -1; tm.tm_mon = i; @@ -595,7 +595,7 @@ time_t mutt_parse_date(const char *s, struct Tz *tz_out) tz_out->zoccident = zoccident; } - time_t time = mutt_mktime(&tm, 0); + time_t time = mutt_date_make_time(&tm, 0); /* Check we haven't overflowed the time (on 32-bit arches) */ if ((time != TIME_T_MAX) && (time != TIME_T_MIN)) time += tz_offset; @@ -604,7 +604,7 @@ time_t mutt_parse_date(const char *s, struct Tz *tz_out) } /** - * imap_make_date - Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz + * mutt_date_make_imap - Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz * @param buf Buffer to store the results * @param buflen Length of buffer * @param timestamp Time to format @@ -612,10 +612,10 @@ time_t mutt_parse_date(const char *s, struct Tz *tz_out) * * Caller should provide a buffer of at least 27 bytes. */ -int imap_make_date(char *buf, size_t buflen, time_t timestamp) +int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp) { struct tm *tm = localtime(×tamp); - time_t tz = mutt_local_tz(timestamp); + time_t tz = mutt_date_local_tz(timestamp); tz /= 60; @@ -625,12 +625,12 @@ int imap_make_date(char *buf, size_t buflen, time_t timestamp) } /** - * imap_parse_date - Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz + * mutt_date_parse_imap - Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz * @param s Date in string form * @retval 0 Error * @retval time_t Unix time */ -time_t imap_parse_date(char *s) +time_t mutt_date_parse_imap(char *s) { struct tm t; time_t tz; @@ -640,7 +640,7 @@ time_t imap_parse_date(char *s) if (*s != '-') return 0; s++; - t.tm_mon = mutt_check_month(s); + t.tm_mon = mutt_date_check_month(s); s += 3; if (*s != '-') return 0; @@ -674,5 +674,5 @@ time_t imap_parse_date(char *s) if (s[0] == '+') tz = -tz; - return (mutt_mktime(&t, 0) + tz); + return (mutt_date_make_time(&t, 0) + tz); } diff --git a/mutt/date.h b/mutt/date.h index 64cd1162236..de8f7118911 100644 --- a/mutt/date.h +++ b/mutt/date.h @@ -41,14 +41,14 @@ extern const char *const Weekdays[]; extern const char *const Months[]; extern const struct Tz TimeZones[]; -int imap_make_date(char *buf, size_t buflen, time_t timestamp); -time_t imap_parse_date(char *s); -bool is_day_name(const char *s); -int mutt_check_month(const char *s); -time_t mutt_local_tz(time_t t); -char *mutt_make_date(char *buf, size_t buflen); -time_t mutt_mktime(struct tm *t, int local); -void mutt_normalize_time(struct tm *tm); -time_t mutt_parse_date(const char *s, struct Tz *tz_out); +int mutt_date_check_month(const char *s); +bool mutt_date_is_day_name(const char *s); +time_t mutt_date_local_tz(time_t t); +char *mutt_date_make_date(char *buf, size_t buflen); +int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp); +time_t mutt_date_make_time(struct tm *t, int local); +void mutt_date_normalize_time(struct tm *tm); +time_t mutt_date_parse_date(const char *s, struct Tz *tz_out); +time_t mutt_date_parse_imap(char *s); #endif /* _MUTT_DATE_H */ diff --git a/ncrypt/gnupgparse.c b/ncrypt/gnupgparse.c index 93f49ce41fb..3a286b31f42 100644 --- a/ncrypt/gnupgparse.c +++ b/ncrypt/gnupgparse.c @@ -278,7 +278,7 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe p = tstr + 8; goto bail; } - tmp.gen_time = mutt_mktime(&time, 0); + tmp.gen_time = mutt_date_make_time(&time, 0); break; } case 7: /* valid for n days */ diff --git a/parse.c b/parse.c index 3cc119c2e69..cc8bdcea420 100644 --- a/parse.c +++ b/parse.c @@ -840,7 +840,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, if (hdr) { struct Tz tz; - hdr->date_sent = mutt_parse_date(p, &tz); + hdr->date_sent = mutt_date_parse_date(p, &tz); if (hdr->date_sent > 0) { hdr->zhours = tz.zhours; @@ -854,7 +854,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, case 'e': if ((mutt_strcasecmp("xpires", line + 1) == 0) && hdr && - mutt_parse_date(p, NULL) < time(NULL)) + mutt_date_parse_date(p, NULL) < time(NULL)) hdr->expired = true; break; @@ -1003,7 +1003,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, char *d = strrchr(p, ';'); if (d) - hdr->received = mutt_parse_date(d + 1, NULL); + hdr->received = mutt_date_parse_date(d + 1, NULL); } } break; @@ -1190,7 +1190,7 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, { /* MH sometimes has the From_ line in the middle of the header! */ if (hdr && !hdr->received) - hdr->received = t - mutt_local_tz(t); + hdr->received = t - mutt_date_local_tz(t); continue; } diff --git a/pattern.c b/pattern.c index 0815f6cccb9..ba8d86ac336 100644 --- a/pattern.c +++ b/pattern.c @@ -160,7 +160,7 @@ static const char *get_offset(struct tm *tm, const char *s, int sign) default: return s; } - mutt_normalize_time(tm); + mutt_date_normalize_time(tm); return (ps + 1); } @@ -429,7 +429,7 @@ static bool eat_date(struct Pattern *pat, struct Buffer *s, struct Buffer *err) memset(&max, 0, sizeof(max)); /* Arbitrary year in the future. Don't set this too high - or mutt_mktime() returns something larger than will + or mutt_date_make_time() returns something larger than will fit in a time_t on some systems */ max.tm_year = 130; max.tm_mon = 11; @@ -530,8 +530,8 @@ static bool eat_date(struct Pattern *pat, struct Buffer *s, struct Buffer *err) /* Since we allow two dates to be specified we'll have to adjust that. */ adjust_date_range(&min, &max); - pat->min = mutt_mktime(&min, 1); - pat->max = mutt_mktime(&max, 1); + pat->min = mutt_date_make_time(&min, 1); + pat->max = mutt_date_make_time(&max, 1); FREE(&buffer.data); diff --git a/sendlib.c b/sendlib.c index c8acf3fbf31..564a929f0cb 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2020,7 +2020,7 @@ int mutt_write_rfc822_header(FILE *fp, struct Envelope *env, bool has_agent = false; /* user defined user-agent header field exists */ if (mode == 0 && !privacy) - fputs(mutt_make_date(buffer, sizeof(buffer)), fp); + fputs(mutt_date_make_date(buffer, sizeof(buffer)), fp); /* OPT_USE_FROM is not consulted here so that we can still write a From: * field if the user sets it with the `my_hdr' command @@ -2738,7 +2738,7 @@ static int bounce_message(FILE *fp, struct Header *h, struct Address *to, fseeko(fp, h->offset, SEEK_SET); fprintf(f, "Resent-From: %s", resent_from); - fprintf(f, "\nResent-%s", mutt_make_date(date, sizeof(date))); + fprintf(f, "\nResent-%s", mutt_date_make_date(date, sizeof(date))); msgid_str = gen_msgid(); fprintf(f, "Resent-Message-ID: %s\n", msgid_str); fputs("Resent-To: ", f); @@ -3004,7 +3004,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, /* mutt_write_rfc822_header() only writes out a Date: header with * mode == 0, i.e. _not_ postponement; so write out one ourself */ if (post) - fprintf(msg->fp, "%s", mutt_make_date(buf, sizeof(buf))); + fprintf(msg->fp, "%s", mutt_date_make_date(buf, sizeof(buf))); /* (postponement) if the mail is to be signed or encrypted, save this info */ if ((WithCrypto & APPLICATION_PGP) && post && (hdr->security & APPLICATION_PGP))