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 /imap/kwtest.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 'imap/kwtest.c')
| -rw-r--r-- | imap/kwtest.c | 97 | 
1 files changed, 97 insertions, 0 deletions
| diff --git a/imap/kwtest.c b/imap/kwtest.c new file mode 100644 index 0000000..3813cad --- /dev/null +++ b/imap/kwtest.c @@ -0,0 +1,97 @@ +/* +** Copyright 2003 Double Precision, Inc. +** See COPYING for distribution information. +*/ + +#if	HAVE_CONFIG_H +#include	"config.h" +#endif +#include	<stdio.h> +#include	<stdlib.h> +#include	<string.h> +#include	<errno.h> +#if	HAVE_UNISTD_H +#include	<unistd.h> +#endif +#include	"keywords.h" + +static struct libmail_kwHashtable h; + +int smapflag=0; + +static int count_flags(struct libmail_keywordEntry *dummy1, void *dummy) +{ +	++*(size_t *)dummy; + +	return 0; +} + +static struct libmail_kwMessage *msgs[3]; +static const char * const flags[]={"apple", "banana", "pear", "grape"}; + + +static int dump() +{ +	size_t cnt=0; + +	if (libmail_kwEnumerate(&h, &count_flags, &cnt)) +		return -1; + +	printf("%d flags\n", (int)cnt); + +	for (cnt=0; cnt<sizeof(msgs)/sizeof(msgs[0]); cnt++) +	{ +		struct libmail_kwMessageEntry *e; + +		printf("%d:", (int)cnt); + +		for (e=msgs[cnt]->firstEntry; e; e=e->next) +			printf(" %s", keywordName(e->libmail_keywordEntryPtr)); +		printf("\n"); +	} +	return 0; + +} + +int main() +{ +	size_t i; + +	libmail_kwhInit(&h); + +	for (i=0; i<sizeof(msgs)/sizeof(msgs[0]); i++) +	{ +		if ((msgs[i]=libmail_kwmCreate()) == NULL) +		{ +			perror("malloc"); +			exit(1); +		} + +		msgs[i]->u.userNum=i; +	} + +	if (libmail_kwmSetName(&h, msgs[0], flags[0]) >= 0 && +	    libmail_kwmSetName(&h, msgs[1], flags[1]) >= 0 && +	    libmail_kwmSetName(&h, msgs[2], flags[2]) >= 0 && +	    libmail_kwmSetName(&h, msgs[0], flags[0]) >= 0 && +	    libmail_kwmSetName(&h, msgs[0], flags[1]) >= 0 && +	    libmail_kwmSetName(&h, msgs[1], flags[2]) >= 0 && +	    libmail_kwmSetName(&h, msgs[2], flags[3]) >= 0) +	{ + +		if (dump() == 0) +		{ +			libmail_kwmClearName(msgs[2], flags[3]); +			libmail_kwmClearName(msgs[2], flags[3]); +			libmail_kwmClearName(msgs[0], flags[1]); + +			if (dump() == 0) +				exit(0); +		} + +	} + +	perror("ERROR"); +	exit(1); +	return 0; +} | 
