(mh_create_message_id): New function.
Showing
2 changed files
with
30 additions
and
0 deletions
... | @@ -303,6 +303,7 @@ int mh_disposition __P((const char *filename)); | ... | @@ -303,6 +303,7 @@ int mh_disposition __P((const char *filename)); |
303 | int mh_usedraft __P((const char *filename)); | 303 | int mh_usedraft __P((const char *filename)); |
304 | int mh_file_copy __P((const char *from, const char *to)); | 304 | int mh_file_copy __P((const char *from, const char *to)); |
305 | char *mh_draft_name __P((void)); | 305 | char *mh_draft_name __P((void)); |
306 | char *mh_create_message_id __P((int)); | ||
306 | int mh_whom __P((char *filename, int check)); | 307 | int mh_whom __P((char *filename, int check)); |
307 | 308 | ||
308 | void mh_annotate __P((message_t msg, char *field, char *text, int date)); | 309 | 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)); | ... | @@ -326,3 +327,4 @@ int mhdraft_stream_create __P((stream_t *stream, stream_t src, int flags)); |
326 | void mh_comp_draft __P((char *formfile, char *defformfile, char *draftfile)); | 327 | void mh_comp_draft __P((char *formfile, char *defformfile, char *draftfile)); |
327 | int check_draft_disposition __P((struct mh_whatnow_env *wh, int use_draft)); | 328 | int check_draft_disposition __P((struct mh_whatnow_env *wh, int use_draft)); |
328 | 329 | ||
330 | ... | ... |
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | #include <pwd.h> | 21 | #include <pwd.h> |
22 | #include <sys/types.h> | 22 | #include <sys/types.h> |
23 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
24 | #include <sys/time.h> | ||
24 | #include <stdarg.h> | 25 | #include <stdarg.h> |
25 | #include <unistd.h> | 26 | #include <unistd.h> |
26 | #include <errno.h> | 27 | #include <errno.h> |
... | @@ -733,3 +734,30 @@ mh_draft_name () | ... | @@ -733,3 +734,30 @@ mh_draft_name () |
733 | return mh_expand_name (draftfolder, "draft", 0); | 734 | return mh_expand_name (draftfolder, "draft", 0); |
734 | } | 735 | } |
735 | 736 | ||
737 | char * | ||
738 | mh_create_message_id (int m) | ||
739 | { | ||
740 | char date[4+2+2+2+2+2+1]; | ||
741 | time_t t = time (NULL); | ||
742 | struct tm *tm = localtime (&t); | ||
743 | char *host; | ||
744 | char *p; | ||
745 | |||
746 | strftime (date, sizeof date, "%Y%m%d%H%M%S", tm); | ||
747 | mu_get_host_name (&host); | ||
748 | |||
749 | if (m) | ||
750 | { | ||
751 | struct timeval tv; | ||
752 | gettimeofday (&tv, NULL); | ||
753 | asprintf (&p, "<%s.%lu.%lu@%s>", | ||
754 | date, | ||
755 | (unsigned long) tv.tv_usec, | ||
756 | (unsigned long) getpid (), | ||
757 | host); | ||
758 | } | ||
759 | else | ||
760 | asprintf (&p, "<%s.%lu@%s>", date, (unsigned long) getpid (), host); | ||
761 | free (host); | ||
762 | return p; | ||
763 | } | ... | ... |
-
Please register or sign in to post a comment