CtdlCheckExpress() now accepts a session context.
authorArt Cancro <ajc@citadel.org>
Tue, 30 Jan 2024 15:26:53 +0000 (10:26 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 30 Jan 2024 15:26:53 +0000 (10:26 -0500)
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
citadel/server/citserver.h
citadel/server/modules/ctdlproto/serv_rooms.c
citadel/server/modules/ctdlproto/serv_session.c
citadel/server/modules/roomchat/serv_roomchat.c
citadel/server/modules/rwho/serv_rwho.c
citadel/server/room_ops.c

index 183fe3c17714aec4677fd5c977d67c1c6cba26c4..da0865899516b30e7c93a4eb44d81d0493a07b3f 100644 (file)
@@ -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 {
index 9eaaa16af037d979e92b88e852293ef3a32fa5ff..be4f3b75c76a3d6f620d6710dc1aa7d58727f503 100644 (file)
@@ -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);
 
index a6bd3036ba0557e2d43603dcaf28dfab2209f74f..4da11284b92cc10bac1887dcb09bcfb2a6e7d081 100644 (file)
@@ -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 : ""),
index 79ed2d042739d0ff604ba52cf4deeb7b6f0d61a9..301213af6bba76a6c456a1cb3f5f09323382cb6b 100644 (file)
@@ -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) );
 }
 
 
index 91e21fca148e22ed5127f8a93325c3386db951c5..842862c8175e69e64dc5bfa3ac8a16ccc9a451a8 100644 (file)
@@ -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) {
index 64a0e42fe9668c816e7c9a9b16e343c446cb81d6..96e25e7877afd70cd2a1858730d2a7fec6ff2f55 100644 (file)
@@ -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<nContexts; i++)  {
                flags[0] = '\0';
index f9d82bf6ededaa56bce6f00945954f7102ee229e..d6288c9871b65db59537e0dd8c83493d40c00773 100644 (file)
@@ -756,7 +756,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently, int *retmsgs
 
        if (display_result) {
                cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|%d|%d|%ld|\n",
-                       CIT_OK, CtdlCheckExpress(),
+                       CIT_OK, CtdlCheckExpress(CC),
                        truncated_roomname,
                        (int)new_messages,
                        (int)total_messages,