summaryrefslogtreecommitdiff
path: root/message.h
blob: 5977be68e7ddfb97f16bb403c84d465fbd613deb (plain)
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
56
57
58
59
60
61
62
63
64
/**
 * \file message.h
 * Simple message handling.
 * 
 * \author José Fonseca
 */

#ifndef _MESSAGE_H
#define _MESSAGE_H


#include <libesmtp.h>

#include "list.h"


/**
 * Item of the recipient list.
 */
typedef struct {
	struct list_head list;
	char *address;
} recipient_t;

/**
 * A message.
 */
typedef struct {
	char *reverse_path;	/**< reverse path for the mail envelope */
	struct list_head remote_recipients;	/**< remote recipients */
	struct list_head local_recipients;	/**< local recipients */

	enum notify_flags notify;	/**< libESMTP notificiation flags */
    
	/** \name buffering */
	/*@{*/
	char *buffer;
	size_t buffer_size;
	size_t buffer_start, buffer_stop;
	int buffer_r;		/**< whether the last character was a '\r' */
	/*@}*/
	
	FILE *fp;		/**< message file pointer */
} message_t;

/** Create a new message. */
message_t *message_new(void);

/** Free the resources associated with a message. */
void message_free(message_t *m);

int message_set_reverse_path(message_t *message, const char *address);

int message_add_recipient(message_t *message, const char *address);

int message_parse_headers(message_t *message);

size_t message_read(message_t *message, char *ptr, size_t size);

void message_rewind(message_t *message);

int message_eof(message_t *message);

#endif