]> granicus.if.org Git - neomutt/commitdiff
rename date functions
authorRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 01:34:42 +0000 (01:34 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 03:39:55 +0000 (03:39 +0000)
copy.c
from.c
handler.c
imap/message.c
mbox.c
mutt/date.c
mutt/date.h
ncrypt/gnupgparse.c
parse.c
pattern.c
sendlib.c

diff --git a/copy.c b/copy.c
index fb422e28766b1a1df8ee3ffa3727ee3c14d365af..9f6d06b52a945b60dd2a5c79bd0d75ab77315ed4 100644 (file)
--- 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 492c54c8bebf207b1799588e5cf28fa4c22a0005..d92cb62c91c79a77226740e64bf50587a7e9d8b7 100644 (file)
--- 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;
 }
index fefc5619a2504faff4850a89521bb9fc81cad821..3de4f14ae7ed65f0a15ea3701b29ae0743c666ed 100644 (file)
--- 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;
 
index b52320f7f0662b662514122cff9c5706e35b1faf..ed98e6fe2b6c00b45d606413a3ed7fddb6952867 100644 (file)
@@ -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 8cd6702abbdbf44a921e706429dc3ddeb6bef9bc..7f128ed30e6d83ba8f092e30a151edf65930c187 100644 (file)
--- 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;
 
index ab534bae8f7ba1530d6667e9cd7924e1d408782a..665dc7bf8ef9d601fe2978d4e8d7296e2a921fec 100644 (file)
  * | #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(&timestamp);
-  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);
 }
index 64cd1162236f82fac6bd8c5e86c9aad1c6a2b8a7..de8f7118911dc13f064482b4be74eab5cd989719 100644 (file)
@@ -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 */
index 93f49ce41fba55493977f81cade80eaae200b6e9..3a286b31f426d1fa8c45e116bf84f081762cd725 100644 (file)
@@ -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 3cc119c2e6981f80fdb3e5ddf3d97d66e390e4ae..cc8bdcea4201b03405bdef5194f53df6be1e0a0b 100644 (file)
--- 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;
       }
 
index 0815f6cccb9d8165004a71a08d375de678c2acc4..ba8d86ac3361880c8249ea10f9571032e591e7da 100644 (file)
--- 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);
 
index c8acf3fbf319306b112c3b378060ee721adf0b62..564a929f0cbeb760b2217fc724f4f541cf094acd 100644 (file)
--- 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))