[gmime] Make the function for unfolding a header (RFC 5322, sect. 2.2.3) publicly available. (#37)
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Make the function for unfolding a header (RFC 5322, sect. 2.2.3) publicly available. (#37)
- Date: Sun, 3 Dec 2017 21:37:44 +0000 (UTC)
commit c09bd4a4b25b5f1df06da55c628f63c85aaf7d6f
Author: albrechtd <albrecht dress arcor de>
Date: Fri Dec 1 03:39:15 2017 +0100
Make the function for unfolding a header (RFC 5322, sect. 2.2.3) publicly available. (#37)
gmime/gmime-header.c | 33 +--------------------------------
gmime/gmime-utils.c | 39 +++++++++++++++++++++++++++++++++++++++
gmime/gmime-utils.h | 1 +
3 files changed, 41 insertions(+), 32 deletions(-)
---
diff --git a/gmime/gmime-header.c b/gmime/gmime-header.c
index fff886a..bf0c368 100644
--- a/gmime/gmime-header.c
+++ b/gmime/gmime-header.c
@@ -214,37 +214,6 @@ g_mime_header_get_name (GMimeHeader *header)
}
-static char *
-unfold (const char *value)
-{
- register const char *inptr = value;
- const char *start, *inend;
- char *str, *outptr;
-
- while (is_lwsp (*inptr))
- inptr++;
-
- inend = start = inptr;
- while (*inptr) {
- if (!is_lwsp (*inptr++))
- inend = inptr;
- }
-
- outptr = str = g_malloc ((size_t) (inend - start) + 1);
- inptr = start;
-
- while (inptr < inend) {
- if (*inptr != '\r' && *inptr != '\n')
- *outptr++ = *inptr;
- inptr++;
- }
-
- *outptr = '\0';
-
- return str;
-}
-
-
/**
* g_mime_header_get_value:
* @header: a #GMimeHeader
@@ -261,7 +230,7 @@ g_mime_header_get_value (GMimeHeader *header)
g_return_val_if_fail (GMIME_IS_HEADER (header), NULL);
if (!header->value && header->raw_value) {
- buf = unfold (header->raw_value);
+ buf = g_mime_utils_header_value_unfold (header->raw_value);
header->value = g_mime_utils_header_decode_text (header->options, buf);
g_free (buf);
}
diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index 77f018b..0849cea 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -2754,3 +2754,42 @@ g_mime_utils_header_printf (GMimeParserOptions *options, GMimeFormatOptions *for
return ret;
}
+
+
+/**
+ * g_mime_utils_header_value_unfold:
+ * @value: raw header value
+ *
+ * Unfolds a raw header value according to the rules in rfc822.
+ *
+ * Returns: an allocated string containing the unfolded header value.
+ **/
+char *
+g_mime_utils_header_value_unfold (const char *value)
+{
+ register const char *inptr = value;
+ const char *start, *inend;
+ char *str, *outptr;
+
+ while (is_lwsp (*inptr))
+ inptr++;
+
+ inend = start = inptr;
+ while (*inptr) {
+ if (!is_lwsp (*inptr++))
+ inend = inptr;
+ }
+
+ outptr = str = g_malloc ((size_t) (inend - start) + 1);
+ inptr = start;
+
+ while (inptr < inend) {
+ if (*inptr != '\r' && *inptr != '\n')
+ *outptr++ = *inptr;
+ inptr++;
+ }
+
+ *outptr = '\0';
+
+ return str;
+}
diff --git a/gmime/gmime-utils.h b/gmime/gmime-utils.h
index c2517af..95204e6 100644
--- a/gmime/gmime-utils.h
+++ b/gmime/gmime-utils.h
@@ -42,6 +42,7 @@ char *g_mime_utils_decode_message_id (const char *message_id);
char *g_mime_utils_structured_header_fold (GMimeParserOptions *options, GMimeFormatOptions *format, const
char *header);
char *g_mime_utils_unstructured_header_fold (GMimeParserOptions *options, GMimeFormatOptions *format, const
char *header);
char *g_mime_utils_header_printf (GMimeParserOptions *options, GMimeFormatOptions *format, const char
*text, ...) G_GNUC_PRINTF (3, 4);
+char *g_mime_utils_header_value_unfold (const char *value);
char *g_mime_utils_quote_string (const char *str);
void g_mime_utils_unquote_string (char *str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]