summaryrefslogtreecommitdiffstats
path: root/sqwebmail/filter.h
blob: 547e07f34251d202be63dca04fd7413cdd0897c4 (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
65
66
67
/*
*/
#ifndef	filter_h
#define	filter_h

/*
** Copyright 1998 - 2011 Double Precision, Inc.  See COPYING for
** distribution information.
*/


/*
	The filter set of function is used to format message text for
	display. The message text gets converted from unicode to the
	display character set, and excessively long lines get truncated to
	some reasonable value.

	Special characters: <, >, &, and " get replaced by their HTML
	entities.


	filter(ptr, cnt) - repeated calls to this function are used to
	supply text being filtered.

	filter_end() - is called when the end of the text being filtered
	is reached.

*/

#if	HAVE_CONFIG_H
#undef	PACKAGE
#undef	VERSION
#include	"config.h"
#endif

#if	HAVE_UNISTD_H
#include	<unistd.h>
#endif

#include	<stdlib.h>

#include	<courier-unicode.h>

struct filter_info {
	unicode_convert_handle_t handle;

	int conversion_error;

	char32_t prevchar;

	size_t u_w;

	void (*handler_func)(const char *, size_t, void *);
	void *func_arg;

	size_t linesize;
};

void	filter_start(struct filter_info *, const char *,
		     void (*)(const char *, size_t, void *), void *);
void	filter(struct filter_info *,
	       const char32_t *, size_t);
void	filter_passthru(struct filter_info *info,
			const char32_t *ptr, size_t cnt);
void	filter_end(struct filter_info *info);

#endif