summaryrefslogtreecommitdiffstats
path: root/maildir/maildirkwtest.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /maildir/maildirkwtest.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-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 'maildir/maildirkwtest.c')
-rw-r--r--maildir/maildirkwtest.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/maildir/maildirkwtest.c b/maildir/maildirkwtest.c
new file mode 100644
index 0000000..2b56f90
--- /dev/null
+++ b/maildir/maildirkwtest.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 "maildir/maildirkeywords.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;
+}