Пример #1
0
static void
print_body (GMimeMessage *msg)
{
	GMimeObject		*body;
	GMimeDataWrapper	*wrapper;
	GMimeStream		*stream;

	body = g_mime_message_get_body (msg);

	if (GMIME_IS_MULTIPART(body))
		body = g_mime_multipart_get_part (GMIME_MULTIPART(body), 0);

	if (!GMIME_IS_PART(body))
		return;

	wrapper = g_mime_part_get_content_object (GMIME_PART(body));
	if (!GMIME_IS_DATA_WRAPPER(wrapper))
		return;

	stream = g_mime_data_wrapper_get_stream (wrapper);
	if (!GMIME_IS_STREAM(stream))
		return;

	do {
		char	buf[512];
		ssize_t	len;

		len = g_mime_stream_read (stream, buf, sizeof(buf));
		if (len == -1)
			break;

		if (write (fileno(stdout), buf, len) == -1)
			break;

		if (len < (int)sizeof(buf))
			break;

	} while (1);
}
Пример #2
0
void GetMessageBody(GMimeMessage* pMessage)
{
    GMimeObject *ps =g_mime_message_get_body(pMessage);
    printf("\n\n\nbody:%s\n",  g_mime_object_to_string(ps));
}