unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 01fe9e35f979851c1184124a9fee248e42181e5b 1324 bytes (raw)
name: util/gmime-extra.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
#include "gmime-extra.h"

GMimeStream *
g_mime_stream_stdout_new()
{
    GMimeStream *stream_stdout = NULL;
    GMimeStream *stream_buffered = NULL;

    stream_stdout = g_mime_stream_pipe_new (STDOUT_FILENO);
    if (!stream_stdout)
	return NULL;

    g_mime_stream_pipe_set_owner (GMIME_STREAM_PIPE (stream_stdout), FALSE);

    stream_buffered = g_mime_stream_buffer_new (stream_stdout, GMIME_STREAM_BUFFER_BLOCK_WRITE);

    g_object_unref (stream_stdout);

    return stream_buffered;
}

/**
 * copy a glib string into a talloc context, and free it.
 */
static char*
g_string_talloc_strdup (void *ctx, char *g_string)
{
    char *new_str = talloc_strdup (ctx, g_string);
    g_free (g_string);
    return new_str;
}

#if (GMIME_MAJOR_VERSION < 3)

char *
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
{
    char *date = g_mime_message_get_date_as_string (message);
    return g_string_talloc_strdup (ctx, date);
}

#else /* GMime >= 3.0 */

char *
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
{
    GDateTime* parsed_date = g_mime_message_get_date (message);
    if (parsed_date) {
	char *date = g_mime_utils_header_format_date (parsed_date);
	return g_string_talloc_strdup (ctx, date);
    } else {
	return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
    }
}
#endif

debug log:

solving 01fe9e35 ...
found 01fe9e35 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).