From 73fced74247296ff98430199d7dec8cbba9182e8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 10 Aug 2023 05:46:49 -0900 Subject: [PATCH] imap_acl.c: update to C99 style comments --- citadel/server/modules/imap/imap_acl.c | 158 ++++++++----------------- 1 file changed, 52 insertions(+), 106 deletions(-) diff --git a/citadel/server/modules/imap/imap_acl.c b/citadel/server/modules/imap/imap_acl.c index bba4bd7a4..1cb6337f8 100644 --- a/citadel/server/modules/imap/imap_acl.c +++ b/citadel/server/modules/imap/imap_acl.c @@ -1,22 +1,9 @@ -/* - * Functions which implement RFC2086 (and maybe RFC4314) (IMAP ACL extension) - * - * Copyright (c) 2007-2017 by the citadel.org team - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +// Functions which implement RFC2086 (and maybe RFC4314) (IMAP ACL extension) +// +// Copyright (c) 2007-2023 by the citadel.org team +// +// This program is open source software. Use, duplication or disclosure +// are subject to the terms of the GNU General Public License, version 3. #include "../../sysdep.h" #include @@ -51,83 +38,69 @@ #include "../../ctdl_module.h" -/* - * Implements the SETACL command. - */ +// Implements the SETACL command. void imap_setacl(int num_parms, ConstStr *Params) { - IReply("BAD not yet implemented FIXME"); return; } -/* - * Implements the DELETEACL command. - */ +// Implements the DELETEACL command. void imap_deleteacl(int num_parms, ConstStr *Params) { - IReply("BAD not yet implemented FIXME"); return; } -/* - * Given the bits returned by CtdlRoomAccess(), populate a string buffer - * with IMAP ACL format flags. This code is common to GETACL and MYRIGHTS. - */ -void imap_acl_flags(StrBuf *rights, int ra) -{ +// Given the bits returned by CtdlRoomAccess(), populate a string buffer +// with IMAP ACL format flags. This code is common to GETACL and MYRIGHTS. +void imap_acl_flags(StrBuf *rights, int ra) { FlushStrBuf(rights); - /* l - lookup (mailbox is visible to LIST/LSUB commands) - * r - read (SELECT the mailbox, perform STATUS et al) - * s - keep seen/unseen information across sessions (STORE SEEN flag) - */ - if ( (ra & UA_KNOWN) /* known rooms */ - || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED)) /* zapped rooms */ + // l - lookup (mailbox is visible to LIST/LSUB commands) + // r - read (SELECT the mailbox, perform STATUS et al) + // s - keep seen/unseen information across sessions (STORE SEEN flag) + if ( (ra & UA_KNOWN) // known rooms + || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED)) // zapped rooms ) { StrBufAppendBufPlain(rights, HKEY("l"), 0); StrBufAppendBufPlain(rights, HKEY("r"), 0); StrBufAppendBufPlain(rights, HKEY("s"), 0); - /* Only output the remaining flags if the room is known */ + // Only output the remaining flags if the room is known - /* w - write (set or clear flags other than SEEN or DELETED, not supported in Citadel */ + // w - write (set or clear flags other than SEEN or DELETED, not supported in Citadel - /* i - insert (perform APPEND, COPY into mailbox) */ - /* p - post (send mail to submission address for mailbox - not enforced) */ - /* c - create (CREATE new sub-mailboxes) */ + // i - insert (perform APPEND, COPY into mailbox) + // p - post (send mail to submission address for mailbox - not enforced) + // c - create (CREATE new sub-mailboxes) if (ra & UA_POSTALLOWED) { StrBufAppendBufPlain(rights, HKEY("i"), 0); StrBufAppendBufPlain(rights, HKEY("p"), 0); StrBufAppendBufPlain(rights, HKEY("c"), 0); } - /* d - delete messages (STORE DELETED flag, perform EXPUNGE) */ + // d - delete messages (STORE DELETED flag, perform EXPUNGE) if (ra & UA_DELETEALLOWED) { StrBufAppendBufPlain(rights, HKEY("d"), 0); } - /* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) */ + // a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) if (ra & UA_ADMINALLOWED) { - /* - * This is the correct place to put the "a" flag. We are leaving - * it commented out for now, because it implies that we could - * perform any of SETACL/DELETEACL/GETACL/LISTRIGHTS. Since these - * commands are not yet implemented, omitting the flag should - * theoretically prevent compliant clients from attempting to - * perform them. - * - * StrBufAppendBufPlain(rights, HKEY("a"), 0); - */ + // This is the correct place to put the "a" flag. We are leaving + // it commented out for now, because it implies that we could + // perform any of SETACL/DELETEACL/GETACL/LISTRIGHTS. Since these + // commands are not yet implemented, omitting the flag should + // theoretically prevent compliant clients from attempting to + // perform them. + // + // StrBufAppendBufPlain(rights, HKEY("a"), 0); } } } -/* - * Implements the GETACL command. - */ +// Implements the GETACL command. void imap_getacl(int num_parms, ConstStr *Params) { char roomname[ROOMNAMELEN]; char savedroom[ROOMNAMELEN]; @@ -143,19 +116,15 @@ void imap_getacl(int num_parms, ConstStr *Params) { return; } - /* - * Search for the specified room or folder - */ + // Search for the specified room or folder ret = imap_grabroom(roomname, Params[2].Key, 1); if (ret != 0) { IReply("NO Invalid mailbox name or access denied"); return; } - /* - * CtdlUserGoto() formally takes us to the desired room. (If another - * folder is selected, save its name so we can return there!!!!!) - */ + // CtdlUserGoto() formally takes us to the desired room. (If another + // folder is selected, save its name so we can return there!!!!!) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } @@ -164,13 +133,10 @@ void imap_getacl(int num_parms, ConstStr *Params) { IAPuts("* ACL "); IPutCParamStr(2); - /* - * Traverse the userlist - */ + // Traverse the userlist rights = NewStrBuf(); cdb_rewind(CDB_USERS); - while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) - { + while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) { memset(&temp, 0, sizeof temp); memcpy(&temp, cdbus->ptr, sizeof temp); cdb_free(cdbus); @@ -189,10 +155,8 @@ void imap_getacl(int num_parms, ConstStr *Params) { FreeStrBuf(&rights); IAPuts("\r\n"); - /* - * If another folder is selected, go back to that room so we can resume - * our happy day without violent explosions. - */ + // If another folder is selected, go back to that room so we can resume + // our happy day without violent explosions. if (IMAP->selected) { CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } @@ -201,9 +165,7 @@ void imap_getacl(int num_parms, ConstStr *Params) { } -/* - * Implements the LISTRIGHTS command. - */ +// Implements the LISTRIGHTS command. void imap_listrights(int num_parms, ConstStr *Params) { char roomname[ROOMNAMELEN]; char savedroom[ROOMNAMELEN]; @@ -217,18 +179,14 @@ void imap_listrights(int num_parms, ConstStr *Params) { return; } - /* - * Search for the specified room/folder - */ + // Search for the specified room/folder ret = imap_grabroom(roomname, Params[2].Key, 1); if (ret != 0) { IReply("NO Invalid mailbox name or access denied"); return; } - /* - * Search for the specified user - */ + // Search for the specified user ret = (-1); valid = validate_recipients(Params[3].Key, NULL, 0); if (valid != NULL) { @@ -242,30 +200,24 @@ void imap_listrights(int num_parms, ConstStr *Params) { return; } - /* - * CtdlUserGoto() formally takes us to the desired room. (If another - * folder is selected, save its name so we can return there!!!!!) - */ + // CtdlUserGoto() formally takes us to the desired room. (If another + // folder is selected, save its name so we can return there!!!!!) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } CtdlUserGoto(roomname, 0, 0, &msgs, &new, NULL, NULL); - /* - * Now output the list of rights - */ + // Now output the list of rights IAPuts("* LISTRIGHTS "); IPutCParamStr(2); IAPuts(" "); IPutCParamStr(3); IAPuts(" "); - IPutStr(HKEY("")); /* FIXME ... do something here */ + IPutStr(HKEY("")); // FIXME ... do something here IAPuts("\r\n"); - /* - * If another folder is selected, go back to that room so we can resume - * our happy day without violent explosions. - */ + // If another folder is selected, go back to that room so we can resume + // our happy day without violent explosions. if (IMAP->selected) { CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } @@ -275,9 +227,7 @@ void imap_listrights(int num_parms, ConstStr *Params) { } -/* - * Implements the MYRIGHTS command. - */ +// Implements the MYRIGHTS command. void imap_myrights(int num_parms, ConstStr *Params) { char roomname[ROOMNAMELEN]; char savedroom[ROOMNAMELEN]; @@ -297,10 +247,8 @@ void imap_myrights(int num_parms, ConstStr *Params) { return; } - /* - * CtdlUserGoto() formally takes us to the desired room. (If another - * folder is selected, save its name so we can return there!!!!!) - */ + // CtdlUserGoto() formally takes us to the desired room. (If another + // folder is selected, save its name so we can return there!!!!!) if (IMAP->selected) { strcpy(savedroom, CC->room.QRname); } @@ -318,9 +266,7 @@ void imap_myrights(int num_parms, ConstStr *Params) { FreeStrBuf(&rights); - /* - * If a different folder was previously selected, return there now. - */ + // If a different folder was previously selected, return there now. if ( (IMAP->selected) && (strcasecmp(roomname, savedroom)) ) { CtdlUserGoto(savedroom, 0, 0, &msgs, &new, NULL, NULL); } -- 2.39.2