summaryrefslogtreecommitdiffstats
path: root/imap/capability.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 /imap/capability.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 'imap/capability.c')
-rw-r--r--imap/capability.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/imap/capability.c b/imap/capability.c
new file mode 100644
index 0000000..25e77a2
--- /dev/null
+++ b/imap/capability.c
@@ -0,0 +1,137 @@
+/*
+** Copyright 1998 - 2008 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>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include "imapwrite.h"
+
+
+static int capa_keywords=0;
+
+extern const char *externalauth();
+
+void initcapability()
+{
+ const char *p=getenv("IMAP_KEYWORDS");
+
+ if (p) capa_keywords=atoi(p);
+}
+
+int have_starttls()
+{
+const char *p;
+
+ if ((p=getenv("IMAP_STARTTLS")) == 0) return (0);
+ if (*p != 'y' && *p != 'Y') return (0);
+
+ p=getenv("COURIERTLS");
+ if (!p || !*p) return (0);
+ if (access(p, X_OK)) return (0);
+ return (1);
+}
+
+
+int tlsrequired()
+{
+const char *p=getenv("IMAP_TLS_REQUIRED");
+
+ if (p && atoi(p)) return (1);
+ return (0);
+}
+
+int keywords()
+{
+ return capa_keywords != 0;
+}
+
+int fastkeywords()
+{
+ return capa_keywords == 1;
+}
+
+int magictrash()
+{
+ const char *p;
+
+ p=getenv("IMAP_MOVE_EXPUNGE_TO_TRASH");
+
+ if (p && atoi(p))
+ return 1;
+ return 0;
+}
+
+const char *imap_externalauth()
+{
+ const char *p;
+
+ if ((p=getenv("IMAP_TLS")) && atoi(p))
+ return externalauth();
+
+ return NULL;
+}
+
+
+void imapcapability()
+{
+ const char *p;
+
+ if ((p=getenv("IMAP_TLS")) && atoi(p) &&
+ (p=getenv("IMAP_CAPABILITY_TLS")) && *p)
+ writes(p);
+ else if ((p=getenv("IMAP_CAPABILITY")) != 0 && *p)
+ writes(p);
+ else
+ writes("IMAP4rev1");
+
+#if SMAP
+ p=getenv("SMAP_CAPABILITY");
+
+ if (p && *p)
+ {
+ writes(" ");
+ writes(p);
+
+ if (keywords())
+ writes(" KEYWORDS");
+ }
+#endif
+
+ if ((p=getenv("IMAP_ACL")) && atoi(p))
+ writes(" ACL ACL2=UNION");
+
+ if (getenv("IMAP_ID_FIELDS"))
+ writes(" ID");
+
+ if (have_starttls())
+ {
+ writes(" STARTTLS");
+ if (tlsrequired())
+ writes(" LOGINDISABLED");
+ }
+ else
+ {
+ if (imap_externalauth())
+ writes(" AUTH=EXTERNAL");
+ }
+
+
+ p=getenv("OUTBOX");
+
+ if (p && *p)
+ {
+ writes(" XCOURIEROUTBOX=INBOX");
+ writes(p);
+ }
+
+ if (magictrash())
+ writes(" XMAGICTRASH");
+}