diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2003-03-18 23:15:54 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2003-03-18 23:15:54 +0000 |
commit | 12754c2721a007a20394a3166eb9d8e76d73a829 (patch) | |
tree | c766c60a6b2464f3bfd8a71a11db8f023b5a073b | |
parent | efc4fcd5d14ff42b4159cbd80d60ba7eea7df772 (diff) | |
download | mailutils-12754c2721a007a20394a3166eb9d8e76d73a829.tar.gz mailutils-12754c2721a007a20394a3166eb9d8e76d73a829.tar.bz2 |
(mh_create_message_id): New function.
-rw-r--r-- | mh/mh.h | 2 | ||||
-rw-r--r-- | mh/mh_init.c | 28 |
2 files changed, 30 insertions, 0 deletions
@@ -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; +} |