2 * Citadel protocol main dispatcher
4 * Copyright (c) 1987-2017 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <libcitadel.h>
18 #include "../../citserver.h"
19 #include "../../ctdl_module.h"
20 #include "../../config.h"
22 * This loop recognizes all server commands.
24 void do_command_loop(void) {
25 struct CitContext *CCC = CC;
29 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
30 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
31 syslog(LOG_INFO, "Citadel client disconnected: ending session.");
32 CCC->kill_me = KILLME_CLIENT_DISCONNECTED;
36 /* Log the server command, but don't show passwords... */
37 if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) {
38 syslog(LOG_DEBUG, "[%s(%ld)] %s",
39 CCC->curr_user, CCC->user.usernum, cmdbuf
43 syslog(LOG_DEBUG, "[%s(%ld)] <password command hidden from log>",
44 CCC->curr_user, CCC->user.usernum
51 * Let other clients see the last command we executed, and
52 * update the idle time, but not NOOP, QNOP, PEXP, GEXP, RWHO, or TIME.
54 if ( (strncasecmp(cmdbuf, "NOOP", 4))
55 && (strncasecmp(cmdbuf, "QNOP", 4))
56 && (strncasecmp(cmdbuf, "PEXP", 4))
57 && (strncasecmp(cmdbuf, "GEXP", 4))
58 && (strncasecmp(cmdbuf, "RWHO", 4))
59 && (strncasecmp(cmdbuf, "TIME", 4)) ) {
60 strcpy(CCC->lastcmdname, " ");
61 safestrncpy(CCC->lastcmdname, cmdbuf, sizeof(CCC->lastcmdname));
65 if ((strncasecmp(cmdbuf, "ENT0", 4))
66 && (strncasecmp(cmdbuf, "MESG", 4))
67 && (strncasecmp(cmdbuf, "MSGS", 4)))
69 CCC->cs_flags &= ~CS_POSTING;
72 if (!DLoader_Exec_Cmd(cmdbuf)) {
73 cprintf("%d Unrecognized or unsupported command.\n", ERROR + CMD_NOT_SUPPORTED);
78 /* Run any after-each-command routines registered by modules */
79 PerformSessionHooks(EVT_CMD);