From b41aa04a613aab95aa822238ed9671063f72a7b8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 30 Jan 2024 10:26:53 -0500 Subject: [PATCH] CtdlCheckExpress() now accepts a session context. This is an experiment in reducing the use of the "CC" macro that appears everywhere in the server. Willi used to do a lot of "struct CitContext *CCC = CC" but that still called the macro once per function call and it added complexity to the code. This method is the right way, actually passing the session context up the stack like we do in WebCit-NG. --- citadel/server/citserver.c | 6 +++--- citadel/server/citserver.h | 4 ++-- citadel/server/modules/ctdlproto/serv_rooms.c | 4 ++-- citadel/server/modules/ctdlproto/serv_session.c | 4 ++-- citadel/server/modules/roomchat/serv_roomchat.c | 4 ++-- citadel/server/modules/rwho/serv_rwho.c | 6 +++--- citadel/server/room_ops.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/citadel/server/citserver.c b/citadel/server/citserver.c index 183fe3c17..da0865899 100644 --- a/citadel/server/citserver.c +++ b/citadel/server/citserver.c @@ -1,6 +1,6 @@ // Main source module for the Citadel server // -// Copyright (c) 1987-2023 by the citadel.org team +// Copyright (c) 1987-2024 by the citadel.org team // // This program is open source software. Use, duplication, or disclosure // is subject to the terms of the GNU General Public License, version 3. @@ -166,8 +166,8 @@ void master_cleanup(int exitcode) { // returns an asterisk if there are any instant messages waiting, space otherwise. -char CtdlCheckExpress(void) { - if (CC->FirstExpressMessage == NULL) { +char CtdlCheckExpress(struct CitContext *con) { + if (con->FirstExpressMessage == NULL) { return (' '); } else { diff --git a/citadel/server/citserver.h b/citadel/server/citserver.h index 9eaaa16af..be4f3b75c 100644 --- a/citadel/server/citserver.h +++ b/citadel/server/citserver.h @@ -1,4 +1,4 @@ -// Copyright (c) 1987-2023 by the citadel.org team +// Copyright (c) 1987-2024 by the citadel.org team // // This program is open source software. Use, duplication, or disclosure // is subject to the terms of the GNU General Public License, version 3. @@ -35,7 +35,7 @@ void begin_session(struct CitContext *con); void citproto_begin_session(void); void citproto_begin_admin_session(void); void help_subst (char *strbuf, char *source, char *dest); -char CtdlCheckExpress(void); +char CtdlCheckExpress(struct CitContext *con); int CheckIfAlreadySeen(StrBuf *guid); void ctdl_lockfile(int); diff --git a/citadel/server/modules/ctdlproto/serv_rooms.c b/citadel/server/modules/ctdlproto/serv_rooms.c index a6bd3036b..4da11284b 100644 --- a/citadel/server/modules/ctdlproto/serv_rooms.c +++ b/citadel/server/modules/ctdlproto/serv_rooms.c @@ -1,6 +1,6 @@ // Server functions which perform operations on room objects. // -// Copyright (c) 1987-2022 by the citadel.org team +// Copyright (c) 1987-2024 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, version 3. @@ -434,7 +434,7 @@ void cmd_getr(char *cmdbuf) { CtdlGetRoom(&CC->room, CC->room.QRname); cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n", CIT_OK, - CtdlCheckExpress(), + CtdlCheckExpress(CC), ((CC->room.QRflags & QR_MAILBOX) ? &CC->room.QRname[11] : CC->room.QRname), ((CC->room.QRflags & QR_PASSWORDED) ? CC->room.QRpasswd : ""), ((CC->room.QRflags & QR_DIRECTORY) ? CC->room.QRdirname : ""), diff --git a/citadel/server/modules/ctdlproto/serv_session.c b/citadel/server/modules/ctdlproto/serv_session.c index 79ed2d042..301213af6 100644 --- a/citadel/server/modules/ctdlproto/serv_session.c +++ b/citadel/server/modules/ctdlproto/serv_session.c @@ -1,6 +1,6 @@ // Server functions which perform operations on user objects. // -// Copyright (c) 1987-2023 by the citadel.org team +// Copyright (c) 1987-2024 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, version 3. @@ -13,7 +13,7 @@ void cmd_noop(char *argbuf) { - cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() ); + cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress(CC) ); } diff --git a/citadel/server/modules/roomchat/serv_roomchat.c b/citadel/server/modules/roomchat/serv_roomchat.c index 91e21fca1..842862c81 100644 --- a/citadel/server/modules/roomchat/serv_roomchat.c +++ b/citadel/server/modules/roomchat/serv_roomchat.c @@ -1,7 +1,7 @@ /* * This module handles instant messaging between users. * - * Copyright (c) 2012-2022 by the citadel.org team + * Copyright (c) 2012-2024 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 version 3. @@ -185,7 +185,7 @@ void roomchat_rwho(char *argbuf) { return; } - cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() ); + cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress(CC) ); nptr = CtdlGetContextArray(&nContexts) ; // grab a copy of the wholist if (nptr) { diff --git a/citadel/server/modules/rwho/serv_rwho.c b/citadel/server/modules/rwho/serv_rwho.c index 64a0e42fe..96e25e787 100644 --- a/citadel/server/modules/rwho/serv_rwho.c +++ b/citadel/server/modules/rwho/serv_rwho.c @@ -1,7 +1,7 @@ // This module implements server commands related to the display and // manipulation of the "Who's online" list. // -// Copyright (c) 1987-2022 by the citadel.org team +// Copyright (c) 1987-2024 by the citadel.org team // // This program is open source software. Use, duplication, or disclosure // is subject to the terms of the GNU General Public License, version 3. @@ -73,13 +73,13 @@ void cmd_rwho(char *argbuf) { nptr = CtdlGetContextArray(&nContexts) ; if (!nptr) { // Couldn't malloc so we have to bail but stick to the protocol - cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() ); + cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress(CC) ); cprintf("000\n"); return; } aide = ( (CC->user.axlevel >= AxAideU) || (CC->internal_pgm) ) ; - cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() ); + cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress(CC) ); for (i=0; i