#include "policy.h"
#include "control.h"
#include "euidindex.h"
+#include "context.h"
#include "svn_revision.h"
#ifndef HAVE_SNPRINTF
#include "ctdl_module.h"
-struct CitContext *ContextList = NULL;
-struct CitContext* next_session = NULL;
char *unique_session_numbers;
int ScheduledShutdown = 0;
time_t server_startup_time;
check_ref_counts();
CtdlLogPrintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
- create_room(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
- create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
- create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
- create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
+ CtdlCreateRoom(config.c_baseroom, 0, "", 0, 1, 0, VIEW_BBS);
+ CtdlCreateRoom(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
+ CtdlCreateRoom(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
+ CtdlCreateRoom(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
/* The "Local System Configuration" room doesn't need to be visible */
- if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
+ if (CtdlGetRoomLock(&qrbuf, SYSCONFIGROOM) == 0) {
qrbuf.QRflags2 |= QR2_SYSTEM;
- lputroom(&qrbuf);
+ CtdlPutRoomLock(&qrbuf);
}
/* Aide needs to be public postable, else we're not RFC conformant. */
- if (lgetroom(&qrbuf, AIDEROOM) == 0) {
+ if (CtdlGetRoomLock(&qrbuf, AIDEROOM) == 0) {
qrbuf.QRflags2 |= QR2_SMTP_PUBLIC;
- lputroom(&qrbuf);
+ CtdlPutRoomLock(&qrbuf);
}
CtdlLogPrintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
-/*
- * Terminate a session.
- */
-void RemoveContext (struct CitContext *con)
-{
- if (con==NULL) {
- CtdlLogPrintf(CTDL_ERR,
- "WARNING: RemoveContext() called with NULL!\n");
- return;
- }
- CtdlLogPrintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
-
- /* Run any cleanup routines registered by loadable modules.
- * Note: We have to "become_session()" because the cleanup functions
- * might make references to "CC" assuming it's the right one.
- */
- become_session(con);
- logout();
- PerformSessionHooks(EVT_STOP);
- become_session(NULL);
-
- CtdlLogPrintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
-
- /* If the client is still connected, blow 'em away. */
- CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
- close(con->client_socket);
-
- /* If using AUTHMODE_LDAP, free the DN */
- if (con->ldap_dn) {
- free(con->ldap_dn);
- con->ldap_dn = NULL;
- }
-
- CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
-}
-
-
-
-
-
/*
* cmd_info() - tell the client about this server
*/
* user also knows the rooms.
*/
void GenerateRoomDisplay(char *real_room,
- struct CitContext *viewed,
- struct CitContext *viewer) {
+ CitContext *viewed,
+ CitContext *viewer) {
int ra;
void cmd_term(char *cmdbuf)
{
int session_num;
- struct CitContext *ccptr;
+ CitContext *ccptr;
int found_it = 0;
int allowed = 0;
{
cprintf(Reply, CIT_OK + SERVER_SHUTTING_DOWN);
}
+ CC->kill_me = 1; /* Even the DOWN command has to follow correct proceedure when disconecting */
CtdlThreadStopAll();
}
* RFC 1725 et al specify a PID to be placed in front of the nonce.
* Quoth BTX: That would be stupid.
*/
-void generate_nonce(struct CitContext *con) {
+void generate_nonce(CitContext *con) {
struct timeval tv;
memset(con->cs_nonce, NONCE_SIZE, 0);
/*
* Back-end function for starting a session
*/
-void begin_session(struct CitContext *con)
+void begin_session(CitContext *con)
{
socklen_t len;
struct sockaddr_in sin;
{
/* as http://www.wsinnovations.com/softeng/articles/uds.html told us... */
struct ucred credentials;
- int ucred_length = sizeof(struct ucred);
+ socklen_t ucred_length = sizeof(struct ucred);
/*fill in the user data structure */
if(getsockopt(con->client_socket, SOL_SOCKET, SO_PEERCRED, &credentials, &ucred_length)) {
void cmd_lout(char *argbuf)
{
if (CC->logged_in)
- logout();
+ CtdlUserLogout();
cprintf("%d logged out.\n", CIT_OK);
}
CTDL_MODULE_INIT(citserver)
{
- CtdlRegisterProtoHook(cmd_noop, "NOOP", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_qnop, "QNOP", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_quit, "QUIT", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_lout, "LOUT", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_asyn, "ASYN", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_info, "INFO", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_mesg, "MESG", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_emsg, "EMSG", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_echo, "ECHO", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_more, "MORE", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_iden, "IDEN", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_ipgm, "IPGM", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_term, "TERM", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_down, "DOWN", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_halt, "HALT", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_scdn, "SCDN", "Autoconverted. TODO: document me.");
- CtdlRegisterProtoHook(cmd_time, "TIME", "Autoconverted. TODO: document me.");
+ if (!threading) {
+ CtdlRegisterProtoHook(cmd_noop, "NOOP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_qnop, "QNOP", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_quit, "QUIT", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lout, "LOUT", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_asyn, "ASYN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_info, "INFO", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_mesg, "MESG", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_emsg, "EMSG", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_echo, "ECHO", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_more, "MORE", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_iden, "IDEN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_ipgm, "IPGM", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_term, "TERM", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_down, "DOWN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_halt, "HALT", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_scdn, "SCDN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_time, "TIME", "Autoconverted. TODO: document me.");
+ }
/* return our Subversion id for the Log */
return "$Id$";
}