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);
extern char * mu_expand_path_pattern (const char *pattern, const char *username);
extern int mu_rfc2822_msg_id (int subpart, char **pstr);
extern int mu_rfc2822_references (mu_message_t msg, char **pstr);
extern int mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr);
......
......@@ -1023,6 +1023,35 @@ mu_rfc2822_references (mu_message_t msg, char **pstr)
return MU_ERR_FAILURE;
}
int
mu_rfc2822_msg_id (int subpart, char **pval)
{
char date[4+2+2+2+2+2+1];
time_t t = time (NULL);
struct tm *tm = localtime (&t);
char *host;
char *p;
mu_strftime (date, sizeof date, "%Y%m%d%H%M%S", tm);
mu_get_host_name (&host);
if (subpart)
{
struct timeval tv;
gettimeofday (&tv, NULL);
asprintf (&p, "<%s.%lu.%d@%s>",
date,
(unsigned long) getpid (),
subpart,
host);
}
else
asprintf (&p, "<%s.%lu@%s>", date, (unsigned long) getpid (), host);
free (host);
*pval = p;
return 0;
}
#define DATEBUFSIZE 128
#define COMMENT "Your message of "
......