diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 | 
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 | 
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /rfc2045/testrfc3676parser.c | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'rfc2045/testrfc3676parser.c')
| -rw-r--r-- | rfc2045/testrfc3676parser.c | 70 | 
1 files changed, 70 insertions, 0 deletions
| diff --git a/rfc2045/testrfc3676parser.c b/rfc2045/testrfc3676parser.c new file mode 100644 index 0000000..1a8c268 --- /dev/null +++ b/rfc2045/testrfc3676parser.c @@ -0,0 +1,70 @@ +/* +** Copyright 2011 Double Precision, Inc. +** See COPYING for distribution information. +*/ + +#include	"rfc3676parser.h" + +#include	<stdlib.h> +#include	<stdio.h> + + +static int line_begin(size_t quote_level, void *arg) +{ +	printf("[%d: ", (int)quote_level); +	return 0; +} + +static int line_contents(const unicode_char *txt, +			 size_t txt_size, +			 void *arg) +{ +	while (txt_size--) +		putchar(*txt++); +	return 0; +} + +static int line_flowed_notify(void *arg) +{ +	printf("..."); +	return 0; +} + +static int line_end(void *arg) +{ +	printf("]\n"); +	return 0; +} + +int main(int argc, char **argv) +{ +	struct rfc3676_parser_info info; +	int n=0; +	char buf[BUFSIZ]; +	rfc3676_parser_t parser; + +	if (argc > 1) +		n=atoi(argv[1]); + +	memset(&info, 0, sizeof(info)); + +	info.charset="utf-8"; + +	info.isflowed=n != 0; +	info.isdelsp= n == 2; + +	info.line_begin=line_begin; +	info.line_contents=line_contents; +	info.line_flowed_notify=line_flowed_notify; +	info.line_end=line_end; + +	if ((parser=rfc3676parser_init(&info)) != NULL) +	{ +		while (fgets(buf, sizeof(buf), stdin)) +			rfc3676parser(parser, buf, strlen(buf)); +		rfc3676parser_deinit(parser, NULL); +		printf("\n"); +	} + +	return (0); +} | 
