diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-02-27 03:56:58 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-02-27 03:56:58 +0800 |
commit | a596227e1c1b3225751a276e9efab60e9eea4110 (patch) | |
tree | ca810c809d303abf0c4d94d37b888b51124a07a3 /camel/camel-mime-utils.c | |
parent | 43f2a52819c061bd0df80388d3877df508590485 (diff) | |
download | gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.gz gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.tar.zst gsoc2013-evolution-a596227e1c1b3225751a276e9efab60e9eea4110.zip |
Made thread-safe and moved to above the test code.
2001-02-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-utils.c: Made thread-safe and moved to above the test
code.
* camel-mime-message.c (camel_mime_message_init): Set the
message_id to NULL.
(camel_mime_message_finalize): Free the message_id.
(camel_mime_message_set_message_id): New function to set the
Message-Id.
(camel_mime_message_get_message_id): New function to get the
Message-Id.
(process_header): Decode the message-id.
svn path=/trunk/; revision=8393
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r-- | camel/camel-mime-utils.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 448c3dc077..10d2c99001 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -27,11 +27,16 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> /* for MAXHOSTNAMELEN */ #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 1024 +#endif + #include <unicode.h> #include <iconv.h> @@ -46,6 +51,10 @@ #include "camel-mime-utils.h" #include "camel-charset-map.h" +#ifdef ENABLE_THREADS +#include <pthread.h> +#endif + #ifndef CLEAN_DATE #include "broken-date-parser.h" #endif @@ -2895,6 +2904,35 @@ header_raw_clear(struct _header_raw **list) *list = NULL; } +char * +header_msgid_generate (void) +{ + char host[MAXHOSTNAMELEN], domain[MAXHOSTNAMELEN]; +#ifdef ENABLE_THREADS + static pthread_mutex_t count_lock = PTHREAD_MUTEX_INITIALIZER; +#define COUNT_LOCK() pthread_mutex_lock (&count_lock) +#define COUNT_UNLOCK() pthread_mutex_unlock (&count_lock) +#else +#define COUNT_LOCK() +#define COUNT_UNLOCK() +#endif /* ENABLE_THREADS */ + static gint count = 0; + gint hrv, drv; + char *ret; + + hrv = gethostname (host, sizeof (host)); + drv = getdomainname (domain, sizeof (domain)); + + COUNT_LOCK (); + ret = g_strdup_printf ("%d.%d.%d.camel@%s.%s", (gint) time (NULL), getpid (), count++, + (hrv == 0 && host && *host) ? host : "unknown.host", + (drv && domain && *domain) ? domain : "unknown.domain"); + COUNT_UNLOCK (); + + return ret; +} + + static struct { char *name; char *pattern; @@ -3335,18 +3373,3 @@ void run_test(void) } #endif /* BUILD_TABLE */ - -char * -header_msgid_generate (void) -{ - gchar host [256], domain [768]; - static gint count = 0; - gint hrv, drv; - - hrv = gethostname (host, sizeof (host)); - drv = getdomainname (domain, sizeof (domain)); - - return g_strdup_printf ("%d.%d.%d.camel@%s.%s", (gint) time (NULL), getpid (), count++, - (hrv == 0 && host && *host) ? host : "unknown.host", - (drv && domain && *domain) ? domain : "unknown.domain"); -} |