citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

serv_ctdlproto.c
Go to the documentation of this file.
1/*
2 * Citadel protocol main dispatcher
3 *
4 * Copyright (c) 1987-2017 by the citadel.org team
5 *
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.
8 *
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.
13 */
14
15#include <stdio.h>
16#include <libcitadel.h>
17
18#include "citserver.h"
19#include "ctdl_module.h"
20#include "config.h"
21/*
22 * This loop recognizes all server commands.
23 */
24void do_command_loop(void) {
25 struct CitContext *CCC = CC;
26 char cmdbuf[SIZ];
27
28 time(&CCC->lastcmd);
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.");
33 return;
34 }
35
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
40 );
41 }
42 else {
43 syslog(LOG_DEBUG, "[%s(%ld)] <password command hidden from log>",
44 CCC->curr_user, CCC->user.usernum
45 );
46 }
47
49
50 /*
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.
53 */
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));
62 time(&CCC->lastidle);
63 }
64
65 if ((strncasecmp(cmdbuf, "ENT0", 4))
66 && (strncasecmp(cmdbuf, "MESG", 4))
67 && (strncasecmp(cmdbuf, "MSGS", 4)))
68 {
69 CCC->cs_flags &= ~CS_POSTING;
70 }
71
72 if (!DLoader_Exec_Cmd(cmdbuf)) {
73 cprintf("%d Unrecognized or unsupported command.\n", ERROR + CMD_NOT_SUPPORTED);
74 }
75
77
78 /* Run any after-each-command routines registered by modules */
80}
81
#define CC
Definition: context.h:140
#define CMD_NOT_SUPPORTED
Definition: ipcdef.h:18
#define ERROR
Definition: ipcdef.h:9
void do_command_loop(void)
void PerformSessionHooks(int EventType)
int DLoader_Exec_Cmd(char *cmdbuf)
#define EVT_CMD
Definition: server.h:219
@ KILLME_CLIENT_DISCONNECTED
Definition: server.h:90
char lastcmdname[5]
Definition: context.h:76
struct ctdluser user
Definition: context.h:109
time_t lastidle
Definition: context.h:48
unsigned cs_flags
Definition: context.h:77
char curr_user[64]
Definition: context.h:69
int kill_me
Definition: context.h:50
time_t lastcmd
Definition: context.h:47
long usernum
Definition: citadel.h:87
#define SIZ
Definition: sysconfig.h:33
void cprintf(const char *format,...)
Definition: sysdep.c:381
int client_getln(char *buf, int bufsize)
Definition: sysdep.c:548
void buffer_output(void)
Definition: sysdep.c:267
void unbuffer_output(void)
Definition: sysdep.c:276