Commit 8fe94a41 8fe94a41e02078c7a7973189934b810f8a4dbacd by Sergey Poznyakoff

(mu_rfc2822_msg_id): New function

1 parent 1e32b2a3
...@@ -114,6 +114,7 @@ extern int mu_unroll_symlink (char *out, size_t outsz, const char *in); ...@@ -114,6 +114,7 @@ extern int mu_unroll_symlink (char *out, size_t outsz, const char *in);
114 114
115 extern char * mu_expand_path_pattern (const char *pattern, const char *username); 115 extern char * mu_expand_path_pattern (const char *pattern, const char *username);
116 116
117 extern int mu_rfc2822_msg_id (int subpart, char **pstr);
117 extern int mu_rfc2822_references (mu_message_t msg, char **pstr); 118 extern int mu_rfc2822_references (mu_message_t msg, char **pstr);
118 extern int mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr); 119 extern int mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr);
119 120
......
...@@ -1023,6 +1023,35 @@ mu_rfc2822_references (mu_message_t msg, char **pstr) ...@@ -1023,6 +1023,35 @@ mu_rfc2822_references (mu_message_t msg, char **pstr)
1023 return MU_ERR_FAILURE; 1023 return MU_ERR_FAILURE;
1024 } 1024 }
1025 1025
1026 int
1027 mu_rfc2822_msg_id (int subpart, char **pval)
1028 {
1029 char date[4+2+2+2+2+2+1];
1030 time_t t = time (NULL);
1031 struct tm *tm = localtime (&t);
1032 char *host;
1033 char *p;
1034
1035 mu_strftime (date, sizeof date, "%Y%m%d%H%M%S", tm);
1036 mu_get_host_name (&host);
1037
1038 if (subpart)
1039 {
1040 struct timeval tv;
1041 gettimeofday (&tv, NULL);
1042 asprintf (&p, "<%s.%lu.%d@%s>",
1043 date,
1044 (unsigned long) getpid (),
1045 subpart,
1046 host);
1047 }
1048 else
1049 asprintf (&p, "<%s.%lu@%s>", date, (unsigned long) getpid (), host);
1050 free (host);
1051 *pval = p;
1052 return 0;
1053 }
1054
1026 #define DATEBUFSIZE 128 1055 #define DATEBUFSIZE 128
1027 #define COMMENT "Your message of " 1056 #define COMMENT "Your message of "
1028 1057
......