File: message.h

package info (click to toggle)
cronosii 0.2.2.23.1-3.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,416 kB
  • ctags: 2,009
  • sloc: ansic: 28,566; sh: 2,548; makefile: 565; sed: 93
file content (124 lines) | stat: -rw-r--r-- 3,283 bytes parent folder | download | duplicates (4)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*  Cronos II
 *  Copyright (C) 2000-2001 Pablo Fernndez Navarro
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/* This functions usually give at least two flags. Functions that the first two arguments are
 * Message *message and char *msg means that the first is a CronosMessage and if the calling
 * function doesn't uses Messages you should pass the message string in the second argument
 * and set message to NULL:
 * Using Message: message_function (message, NULL, ...)
 * Not using Message: message_function (NULL, message, ...)
 */
#ifndef MESSAGES_H
#define MESSAGES_H

#ifdef __cplusplus
extern "C" {
#endif

#include "mailbox.h"
#include <glib.h>

typedef struct {
  const char *pos;
  int len;

  char *part;

  char *type, *subtype, *id;
  char *parameter;
  char *disposition;
  char *encoding;
} MimeHash;

#define MIMEHASH(obj)	((MimeHash*) (obj))

typedef struct {
  char *mbox;	/* Freeable string */
  mid_t mid;
  char *message;/* Freeable string */
  char *header; /* Freeable string */
  char *body;	/* Non-freeable string (points to the (first \n\n)+2 of message */
  GList *mime;/* Mime Parts */
} Message;

#define MESSAGE(obj)		((Message*)obj)
#define c2_message_new(message)	{ \
  				  message = g_new0 (Message, 1); \
				  message->mbox = NULL; \
				  message->mid = -1; \
				  message->message = NULL; \
				  message->header = NULL; \
				  message->body = NULL; \
				  message->mime = NULL; \
				}
				

Message *
message_get_message					(const char *mbox, mid_t mid);

Message *
message_get_message_from_file				(const char *filename);

char *
message_get_message_header				(Message *message, const char *msg);

const char *
message_get_message_body				(Message *message, const char *msg);

char *
message_get_header_field				(Message *message, const char *header,
    							 const char *field);

Message *
message_copy						(const Message *message);

void
message_free						(Message *message);

GList *
message_mime_parse					(Message *message, const char *msg);

char *
message_mime_get_parameter_value			(const char *parameter, const char *field);

void
message_mime_parse_content_type				(const char *content_type, char **type,										char **subtype, char **parameter);

MimeHash *
message_mime_get_default_part				(const GList *list);

void
message_mime_get_part					(MimeHash *mime);

char *
encode_base64						(char *data, int *length);

char *
decode_base64						(char *data, int *length);

char *
decode_quoted_printable					(char *message, int *length);

int
message_messages_in_mailbox				(const char *mbox);

#ifdef __cplusplus
}
#endif

#endif