Commit 12754c27 12754c2721a007a20394a3166eb9d8e76d73a829 by Sergey Poznyakoff

(mh_create_message_id): New function.

1 parent efc4fcd5
......@@ -303,6 +303,7 @@ int mh_disposition __P((const char *filename));
int mh_usedraft __P((const char *filename));
int mh_file_copy __P((const char *from, const char *to));
char *mh_draft_name __P((void));
char *mh_create_message_id __P((int));
int mh_whom __P((char *filename, int check));
void mh_annotate __P((message_t msg, char *field, char *text, int date));
......@@ -326,3 +327,4 @@ int mhdraft_stream_create __P((stream_t *stream, stream_t src, int flags));
void mh_comp_draft __P((char *formfile, char *defformfile, char *draftfile));
int check_draft_disposition __P((struct mh_whatnow_env *wh, int use_draft));
......
......@@ -21,6 +21,7 @@
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
......@@ -733,3 +734,30 @@ mh_draft_name ()
return mh_expand_name (draftfolder, "draft", 0);
}
char *
mh_create_message_id (int m)
{
char date[4+2+2+2+2+2+1];
time_t t = time (NULL);
struct tm *tm = localtime (&t);
char *host;
char *p;
strftime (date, sizeof date, "%Y%m%d%H%M%S", tm);
mu_get_host_name (&host);
if (m)
{
struct timeval tv;
gettimeofday (&tv, NULL);
asprintf (&p, "<%s.%lu.%lu@%s>",
date,
(unsigned long) tv.tv_usec,
(unsigned long) getpid (),
host);
}
else
asprintf (&p, "<%s.%lu@%s>", date, (unsigned long) getpid (), host);
free (host);
return p;
}
......