summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mh/mh.h2
-rw-r--r--mh/mh_init.c28
2 files changed, 30 insertions, 0 deletions
diff --git a/mh/mh.h b/mh/mh.h
index dfcb9c7b8..6fcffd689 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -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));
+
diff --git a/mh/mh_init.c b/mh/mh_init.c
index a07a28c2c..711575072 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -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;
+}

Return to:

Send suggestions and report system problems to the System administrator.