// IMAP server for the Citadel system
//
-// Copyright (C) 2000-2022 by Art Cancro and others.
-// This code is released under the terms of the GNU General Public License.
+// Copyright (c) 1987-2022 by the citadel.org team
//
-// WARNING: the IMAP protocol is badly designed. No implementation of it
-// is perfect. Indeed, with so much gratuitous complexity, *all* IMAP
-// implementations have bugs.
-//
-// This program is open source software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// This program is open source software. Use, duplication, or disclosure
+// is subject to the terms of the GNU General Public License, version 3.
#include "../../sysdep.h"
#include <stdlib.h>
#include "../../ctdl_module.h"
HashList *ImapCmds = NULL;
-void registerImapCMD(const char *First, long FLen,
- const char *Second, long SLen,
- imap_handler H,
- int Flags)
-{
+void registerImapCMD(const char *First, long FLen, const char *Second, long SLen, imap_handler H, int Flags) {
imap_handler_hook *h;
h = (imap_handler_hook*) malloc(sizeof(imap_handler_hook));
}
-const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params)
-{
+const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params) {
struct CitContext *CCC = CC;
void *v;
citimap *Imap = CCCIMAP;
StrBufUpCase(Imap->Reply);
syslog(LOG_DEBUG, "---- Looking up [%s] -----", ChrPtr(Imap->Reply));
- if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
- {
+ if (GetHash(ImapCmds, SKEY(Imap->Reply), &v)) {
syslog(LOG_DEBUG, "Found.");
FlushStrBuf(Imap->Reply);
return (imap_handler_hook *) v;
}
- if (num_parms == 1)
- {
+ if (num_parms == 1) {
syslog(LOG_DEBUG, "NOT Found.");
FlushStrBuf(Imap->Reply);
return NULL;
syslog(LOG_DEBUG, "---- Looking up [%s] -----", ChrPtr(Imap->Reply));
StrBufAppendBufPlain(Imap->Reply, CKEY(Params[2]), 0);
StrBufUpCase(Imap->Reply);
- if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
- {
+ if (GetHash(ImapCmds, SKEY(Imap->Reply), &v)) {
syslog(LOG_DEBUG, "Found.");
FlushStrBuf(Imap->Reply);
return (imap_handler_hook *) v;
return NULL;
}
+
/* imap_rename() uses this struct containing list of rooms to rename */
struct irl {
struct irl *next;
int irl_newfloor;
};
+
/* Data which is passed between imap_rename() and imap_rename_backend() */
typedef struct __irlparms {
const char *oldname;
const char *newname;
long newnamelen;
struct irl **irl;
-}irlparms;
+} irlparms;
/*
* If there is a message ID map in memory, free it
*/
-void imap_free_msgids(void)
-{
+void imap_free_msgids(void) {
citimap *Imap = IMAP;
if (Imap->msgids != NULL) {
free(Imap->msgids);
}
-
/*
* Back end for imap_load_msgids()
*
}
-
/*
* Set up a message ID map for the current room (folder)
*/
num_msgs = cdbfr->len / sizeof(long);
cdbfr->len = 0;
cdb_free(cdbfr);
- } else {
+ }
+ else {
num_msgs = 0;
}
/*
- * Does the actual work of the CAPABILITY command (because we need to
- * output this stuff in other places as well)
+ * Does the actual work of the CAPABILITY command (because we need to output this stuff in other places as well)
*/
void imap_output_capability_string(void) {
IAPuts("CAPABILITY IMAP4REV1 NAMESPACE ID AUTH=PLAIN AUTH=LOGIN UIDPLUS");
IAPrintf("] Hello, %s\r\n", CC->user.fullname);
return;
}
- else
- {
+ else {
IReplyPrintf("NO AUTHENTICATE %s failed", Params[3].Key);
return;
}
*/
IAPuts("* FLAGS (\\Deleted \\Seen \\Answered)\r\n");
IAPuts("* OK [PERMANENTFLAGS (\\Deleted \\Seen \\Answered)] permanent flags\r\n");
-
- IReplyPrintf("OK [%s] %s completed",
- (Imap->readonly ? "READ-ONLY" : "READ-WRITE"), Params[1].Key
- );
+ IReplyPrintf("OK [%s] %s completed", (Imap->readonly ? "READ-ONLY" : "READ-WRITE"), Params[1].Key);
}
/* Then try a mailbox name match */
if (c != 0) {
- CtdlMailboxName(augmented_roomname, sizeof augmented_roomname,
- &CC->user, roomname);
+ CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, roomname);
c = CtdlGetRoom(&QRscratch, augmented_roomname);
if (c == 0)
safestrncpy(roomname, augmented_roomname, sizeof(roomname));
if (!ok) {
strcpy(returned_roomname, "");
return (2);
- } else {
+ }
+ else {
safestrncpy(returned_roomname, QRscratch.QRname, ROOMNAMELEN);
return (0);
}
*/
if (CtdlForgetThisRoom() == 0) {
IReply("OK UNSUBSCRIBE completed");
- } else {
+ }
+ else {
IReply("NO You may not unsubscribe from this folder.");
}
if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->room)) {
CtdlScheduleRoomForDeletion(&CC->room);
IReply("OK DELETE completed");
- } else {
+ }
+ else {
IReply("NO Can't delete this folder.");
}
/* ... and now rename them. */
while (irl != NULL) {
- r = CtdlRenameRoom(irl->irl_oldroom,
- irl->irl_newroom,
- irl->irl_newfloor);
+ r = CtdlRenameRoom(irl->irl_oldroom, irl->irl_newroom, irl->irl_newfloor);
if (r != crr_ok) {
/* FIXME handle error returns better */
syslog(LOG_ERR, "CtdlRenameRoom() error %d", r);
else if (Imap->authstate == imap_as_expecting_plainauth) {
syslog(LOG_INFO, "<plain_auth>");
}
- else if ((Imap->authstate == imap_as_expecting_multilineusername) ||
- cbmstrcasestr(ChrPtr(Imap->Cmd.CmdBuf), " LOGIN ")) {
+ else if ((Imap->authstate == imap_as_expecting_multilineusername) || cbmstrcasestr(ChrPtr(Imap->Cmd.CmdBuf), " LOGIN ")) {
syslog(LOG_INFO, "LOGIN...");
}
else {