Grammar change in the license declaration.
[citadel.git] / webcit-ng / server / admin_functions.c
index 2c2d85f1f205181f38655620adf4d15481f25dbd..62843f26e6933fb30aef2bc9fbcb5866e478c9f7 100644 (file)
@@ -1,9 +1,9 @@
 // Admin functions
 //
-// Copyright (c) 1996-2022 by the citadel.org team
+// Copyright (c) 1996-2023 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// disclosure is subject to the GNU General Public License v3.
 
 #include "webcit.h"
 
@@ -84,6 +84,21 @@ void whoami(struct http_transaction *h, struct ctdlsession *c) {
 }
 
 
+// /ctdl/a/biff returns the number of new messages that have arrived in the inbox
+// since the beginning of the session or since the last call to biff
+void biff(struct http_transaction *h, struct ctdlsession *c) {
+       char biffbuff[1024];
+
+       ctdl_printf(c, "BIFF");                         // send the command
+       ctdl_readline(c, biffbuff, sizeof(biffbuff));   // read the result
+       h->response_code = 200;
+       h->response_string = strdup("OK");
+       add_response_header(h, strdup("Content-type"), strdup("text/plain"));
+       h->response_body = strdup(&biffbuff[4]);
+       h->response_body_length = strlen(h->response_body);
+}
+
+
 // Dispatcher for paths starting with /ctdl/a/
 void ctdl_a(struct http_transaction *h, struct ctdlsession *c) {
        if (!strcasecmp(h->url, "/ctdl/a/login")) {     // log in
@@ -101,5 +116,10 @@ void ctdl_a(struct http_transaction *h, struct ctdlsession *c) {
                return;
        }
 
+       if (!strcasecmp(h->url, "/ctdl/a/biff")) {      // check for new messages in the inbox
+               biff(h, c);
+               return;
+       }
+
        do_404(h);                                      // unknown
 }