Initialize the gmime for upstream
[platform/upstream/gmime.git] / gmime / gmime-utils.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*  GMime
3  *  Copyright (C) 2000-2012 Jeffrey Stedfast
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public License
7  *  as published by the Free Software Foundation; either version 2.1
8  *  of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
18  *  02110-1301, USA.
19  */
20
21
22 #ifndef __GMIME_UTILS_H__
23 #define __GMIME_UTILS_H__
24
25 #include <glib.h>
26 #include <time.h>
27 #include <stdarg.h>
28
29 #include <gmime/gmime-encodings.h>
30
31 G_BEGIN_DECLS
32
33 typedef struct _GMimeReferences GMimeReferences;
34
35 /**
36  * GMimeReferences:
37  * @next: Pointer to the next reference.
38  * @msgid: Reference message-id.
39  *
40  * A List of references, as per the References or In-Reply-To header
41  * fields.
42  **/
43 struct _GMimeReferences {
44         GMimeReferences *next;
45         char *msgid;
46 };
47
48
49 time_t g_mime_utils_header_decode_date (const char *str, int *tz_offset);
50 char  *g_mime_utils_header_format_date (time_t date, int tz_offset);
51
52 char *g_mime_utils_generate_message_id (const char *fqdn);
53
54 /* decode a message-id */
55 char *g_mime_utils_decode_message_id (const char *message_id);
56
57 /* decode a References or In-Reply-To header */
58 GMimeReferences *g_mime_references_decode (const char *text);
59 void g_mime_references_append (GMimeReferences **refs, const char *msgid);
60 void g_mime_references_clear (GMimeReferences **refs);
61 void g_mime_references_free (GMimeReferences *refs);
62 const GMimeReferences *g_mime_references_get_next (const GMimeReferences *ref);
63 const char *g_mime_references_get_message_id (const GMimeReferences *ref);
64
65 char  *g_mime_utils_structured_header_fold (const char *str);
66 char  *g_mime_utils_unstructured_header_fold (const char *str);
67 char  *g_mime_utils_header_fold (const char *str);
68 char  *g_mime_utils_header_printf (const char *format, ...);
69
70 char  *g_mime_utils_quote_string (const char *str);
71 void   g_mime_utils_unquote_string (char *str);
72
73 /* encoding decision making utilities ;-) */
74 gboolean g_mime_utils_text_is_8bit (const unsigned char *text, size_t len);
75 GMimeContentEncoding g_mime_utils_best_encoding (const unsigned char *text, size_t len);
76
77 /* utility function to convert text in an unknown 8bit/multibyte charset to UTF-8 */
78 char *g_mime_utils_decode_8bit (const char *text, size_t len);
79
80 /* utilities to (de/en)code headers */
81 char *g_mime_utils_header_decode_text (const char *text);
82 char *g_mime_utils_header_encode_text (const char *text);
83
84 char *g_mime_utils_header_decode_phrase (const char *phrase);
85 char *g_mime_utils_header_encode_phrase (const char *phrase);
86
87 G_END_DECLS
88
89 #endif /* __GMIME_UTILS_H__ */