#include "citadel.h"
#include "citadel_dirs.h"
-/*
- * Generate an associated file name for a room
- */
+// Generate an associated file name for a room
size_t assoc_file_name(char *buf, size_t n, struct ctdlroom *qrbuf, const char *prefix) {
return snprintf(buf, n, "%s%ld", prefix, qrbuf->QRnumber);
}
}
rv = chmod(which, ACCESS);
if (rv == -1) {
- syslog(LOG_ERR,
- "failed to set permissions for directory %s: %s",
- which,
- strerror(errno));
+ syslog(LOG_ERR, "failed to set permissions for directory %s: %s", which, strerror(errno));
return rv;
}
rv = chown(which, UID, GID);
if (rv == -1) {
- syslog(LOG_ERR,
- "failed to set owner for directory %s: %s",
- which,
- strerror(errno));
+ syslog(LOG_ERR, "failed to set owner for directory %s: %s", which, strerror(errno));
return rv;
}
return rv;
// listener on a unix domain socket and transmits the message. Really though,
// if your MTA supports LMTP then you definitely should be using that instead.
//
-// Copyright (c) 1987-2021 by the citadel.org team
+// Copyright (c) 1987-2022 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.
}
-/*
- * input binary data from socket
- */
-void serv_read(char *buf, int bytes)
-{
+// input binary data from socket
+void serv_read(char *buf, int bytes) {
int len, rlen;
len = 0;
}
-/*
- * send binary to server
- */
-void serv_write(char *buf, int nbytes)
-{
+// send binary to server
+void serv_write(char *buf, int nbytes) {
int bytes_written = 0;
int retval;
while (bytes_written < nbytes) {
}
-
-/*
- * input string from socket - implemented in terms of serv_read()
- */
-void serv_gets(char *buf)
-{
+// input string from socket - implemented in terms of serv_read()
+void serv_gets(char *buf) {
int i;
- /* Read one character at a time.
- */
+ // Read one character at a time.
for (i = 0;; i++) {
serv_read(&buf[i], 1);
if (buf[i] == '\n' || i == (SIZ-1))
break;
}
- /* If we got a long line, discard characters until the newline.
- */
+ // If we got a long line, discard characters until the newline.
if (i == (SIZ-1))
while (buf[i] != '\n')
serv_read(&buf[i], 1);
- /* Strip all trailing nonprintables (crlf)
- */
+ // Strip all trailing nonprintables (crlf)
buf[i] = 0;
strip_trailing_nonprint(buf);
if (debug) fprintf(stderr, "> %s\n", buf);
}
-/*
- * send line to server - implemented in terms of serv_write()
- */
-void serv_puts(char *buf)
-{
+// send line to server - implemented in terms of serv_write()
+void serv_puts(char *buf) {
if (debug) fprintf(stderr, "< %s\n", buf);
serv_write(buf, strlen(buf));
serv_write("\n", 1);
}
-
void cleanup(int exitcode) {
char buf[1024];
}
-
int main(int argc, char **argv) {
char buf[1024];
char fromline[1024];
cleanup(0);
}
- /* We won't actually reach this statement but the compiler will
- * display a spurious warning about an invalid return type if
- * we don't return an int.
- */
+ // We won't actually reach this statement but the compiler will
+ // display a spurious warning about an invalid return type if
+ // we don't return an int.
return(0);
}
int openid_level_supported = 0;
-/*
- * Various things that need to be initialized at startup
- */
-void master_startup(void)
-{
+// Various things that need to be initialized at startup
+void master_startup(void) {
struct timeval tv;
unsigned int seed;
FILE *urandom;
syslog(LOG_INFO, "Opening databases");
open_databases();
- /* Load site-specific configuration */
+ // Load site-specific configuration
syslog(LOG_INFO, "Initializing configuration system");
initialize_config_system();
validate_config();
ForEachUser(reindex_user_928, NULL);
}
- /* Check floor reference counts */
+ // Check floor reference counts
check_ref_counts();
syslog(LOG_INFO, "Creating base rooms (if necessary)");
CtdlCreateRoom(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
CtdlCreateRoom(CtdlGetConfigStr("c_twitroom"), 0, "", 0, 1, 0, VIEW_BBS);
- /* The "Local System Configuration" room doesn't need to be visible */
+ // The "Local System Configuration" room doesn't need to be visible
if (CtdlGetRoomLock(&qrbuf, SYSCONFIGROOM) == 0) {
qrbuf.QRflags2 |= QR2_SYSTEM;
CtdlPutRoomLock(&qrbuf);
}
- /* Aide needs to be public postable, else we're not RFC conformant. */
+ // Aide needs to be public postable, else we're not RFC conformant.
if (CtdlGetRoomLock(&qrbuf, AIDEROOM) == 0) {
qrbuf.QRflags2 |= QR2_SMTP_PUBLIC;
CtdlPutRoomLock(&qrbuf);
syslog(LOG_ERR, "citserver: failed to read random seed: %m");
}
fclose(urandom);
- } else {
+ }
+ else {
gettimeofday(&tv, NULL);
seed = tv.tv_usec;
}
}
-/*
- * Cleanup routine to be called when the server is shutting down. Returns the needed exit code.
- */
-int master_cleanup(int exitcode)
-{
+// Cleanup routine to be called when the server is shutting down. Returns the needed exit code.
+int master_cleanup(int exitcode) {
static int already_cleaning_up = 0;
if (already_cleaning_up) {
}
already_cleaning_up = 1;
- /* Do system-dependent stuff */
+ // Do system-dependent stuff
sysdep_master_cleanup();
- /* Close the configuration system */
+ // Close the configuration system
shutdown_config_system();
- /* Close databases */
+ // Close databases
syslog(LOG_INFO, "citserver: closing databases");
close_databases();
- /* If the operator requested a halt but not an exit, halt here. */
+ // If the operator requested a halt but not an exit, halt here.
if (shutdown_and_halt) {
syslog(LOG_ERR, "citserver: Halting server without exiting.");
fflush(stdout);
}
}
- /* Now go away. */
+ // Now go away.
syslog(LOG_ERR, "citserver: Exiting with status %d", exitcode);
fflush(stdout);
fflush(stderr);
if (restart_server != 0) {
exitcode = 1;
- } else if ((running_as_daemon != 0) && ((exitcode == 0))) {
+ }
+ else if ((running_as_daemon != 0) && ((exitcode == 0))) {
exitcode = CTDLEXIT_SHUTDOWN;
}
return (exitcode);
}
-/*
- * returns an asterisk if there are any instant messages waiting,
- * space otherwise.
- */
-char CtdlCheckExpress(void)
-{
+// returns an asterisk if there are any instant messages waiting, space otherwise.
+char CtdlCheckExpress(void) {
if (CC->FirstExpressMessage == NULL) {
return (' ');
- } else {
+ }
+ else {
return ('*');
}
}
-void citproto_begin_session()
-{
+void citproto_begin_session() {
if (CC->nologin == 1) {
cprintf("%d Too many users are already online (maximum is %d)\n",
ERROR + MAX_SESSIONS_EXCEEDED, CtdlGetConfigInt("c_maxsessions")
- );
+ );
CC->kill_me = KILLME_MAX_SESSIONS_EXCEEDED;
- } else {
+ }
+ else {
cprintf("%d %s Citadel server ready.\n", CIT_OK, CtdlGetConfigStr("c_fqdn"));
CC->can_receive_im = 1;
}
}
-void citproto_begin_admin_session()
-{
+void citproto_begin_admin_session() {
CC->internal_pgm = 1;
cprintf("%d %s Citadel server ADMIN CONNECTION ready.\n", CIT_OK, CtdlGetConfigStr("c_fqdn"));
}
-/*
- * This loop performs all asynchronous functions.
- */
-void do_async_loop(void)
-{
+// This loop performs all asynchronous functions.
+void do_async_loop(void) {
PerformSessionHooks(EVT_ASYNC);
}
#include "ctdl_module.h"
#include "clientsocket.h"
-int sock_connect(char *host, char *service)
-{
+int sock_connect(char *host, char *service) {
struct in6_addr serveraddr;
struct addrinfo hints;
struct addrinfo *res = NULL;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- /*
- * Handle numeric IPv4 and IPv6 addresses
- */
+ // Handle numeric IPv4 and IPv6 addresses
rc = inet_pton(AF_INET, host, &serveraddr);
- if (rc == 1) { /* dotted quad */
+ if (rc == 1) { // dotted quad
hints.ai_family = AF_INET;
hints.ai_flags |= AI_NUMERICHOST;
- } else {
+ }
+ else {
rc = inet_pton(AF_INET6, host, &serveraddr);
- if (rc == 1) { /* IPv6 address */
+ if (rc == 1) { // IPv6 address
hints.ai_family = AF_INET6;
hints.ai_flags |= AI_NUMERICHOST;
}
}
- /* Begin the connection process */
-
+ // Begin the connection process
rc = getaddrinfo(host, service, &hints, &res);
if (rc != 0) {
syslog(LOG_ERR, "%s: %s", host, gai_strerror(rc));
return(-1);
}
- /*
- * Try all available addresses until we connect to one or until we run out.
- */
+ // Try all available addresses until we connect to one or until we run out.
for (ai = res; ai != NULL; ai = ai->ai_next) {
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) {
}
-
-/*
- * Read data from the client socket.
- *
- * sock socket fd to read from
- * buf buffer to read into
- * bytes number of bytes to read
- * timeout Number of seconds to wait before timing out
- *
- * Possible return values:
- * 1 Requested number of bytes has been read.
- * 0 Request timed out.
- * -1 Connection is broken, or other error.
- */
-int socket_read_blob(int *Socket, StrBuf *Target, int bytes, int timeout)
-{
+// Read data from the client socket.
+//
+// sock socket fd to read from
+// buf buffer to read into
+// bytes number of bytes to read
+// timeout Number of seconds to wait before timing out
+//
+// Possible return values:
+// 1 Requested number of bytes has been read.
+// 0 Request timed out.
+// -1 Connection is broken, or other error.
+int socket_read_blob(int *Socket, StrBuf *Target, int bytes, int timeout) {
const char *Error;
int retval = 0;
}
-int CtdlSockGetLine(int *sock, StrBuf *Target, int nSec)
-{
- CitContext *CCC = MyContext();
+int CtdlSockGetLine(int *sock, StrBuf *Target, int nSec) {
const char *Error;
int rc;
FlushStrBuf(Target);
rc = StrBufTCP_read_buffered_line_fast(Target,
- CCC->SBuf.Buf,
- &CCC->SBuf.ReadWritePointer,
+ CC->SBuf.Buf,
+ &CC->SBuf.ReadWritePointer,
sock, nSec, 1, &Error);
if ((rc < 0) && (Error != NULL)) {
syslog(LOG_ERR, "clientsocket: CtdlSockGetLine() failed: %s", Error);
}
-/*
- * client_getln() ... Get a LF-terminated line of text from the client.
- */
-int sock_getln(int *sock, char *buf, int bufsize)
-{
+// client_getln() ... Get a LF-terminated line of text from the client.
+int sock_getln(int *sock, char *buf, int bufsize) {
int i, retval;
- CitContext *CCC = MyContext();
const char *pCh;
- FlushStrBuf(CCC->sMigrateBuf);
- retval = CtdlSockGetLine(sock, CCC->sMigrateBuf, 5);
+ FlushStrBuf(CC->sMigrateBuf);
+ retval = CtdlSockGetLine(sock, CC->sMigrateBuf, 5);
- i = StrLength(CCC->sMigrateBuf);
- pCh = ChrPtr(CCC->sMigrateBuf);
+ i = StrLength(CC->sMigrateBuf);
+ pCh = ChrPtr(CC->sMigrateBuf);
memcpy(buf, pCh, i + 1);
- FlushStrBuf(CCC->sMigrateBuf);
+ FlushStrBuf(CC->sMigrateBuf);
if (retval < 0) {
safestrncpy(&buf[i], "000", bufsize - i);
i += 3;
}
-/*
- * sock_write() - send binary to server.
- * Returns the number of bytes written, or -1 for error.
- */
-int sock_write(int *sock, const char *buf, int nbytes)
-{ return sock_write_timeout(sock, buf, nbytes, 50); }
-int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout)
-{
+// sock_write() - send binary to server.
+// Returns the number of bytes written, or -1 for error.
+int sock_write(int *sock, const char *buf, int nbytes) {
+ return sock_write_timeout(sock, buf, nbytes, 50);
+}
+
+
+int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout) {
int nSuccessLess = 0;
int bytes_written = 0;
int retval;
fdflags = fcntl(*sock, F_GETFL);
IsNonBlock = (fdflags & O_NONBLOCK) == O_NONBLOCK;
- while ((nSuccessLess < timeout) &&
- (*sock != -1) &&
- (bytes_written < nbytes))
- {
- if (IsNonBlock){
+ while ((nSuccessLess < timeout) && (*sock != -1) && (bytes_written < nbytes)) {
+ if (IsNonBlock) {
tv.tv_sec = selectresolution;
tv.tv_usec = 0;
}
-/*
- * client_getln() ... Get a LF-terminated line of text from the client.
- */
-int sock_getln_err(int *sock, char *buf, int bufsize, int *rc, int nSec)
-{
+// client_getln() ... Get a LF-terminated line of text from the client.
+int sock_getln_err(int *sock, char *buf, int bufsize, int *rc, int nSec) {
int i, retval;
- CitContext *CCC = MyContext();
const char *pCh;
- FlushStrBuf(CCC->sMigrateBuf);
- *rc = retval = CtdlSockGetLine(sock, CCC->sMigrateBuf, nSec);
+ FlushStrBuf(CC->sMigrateBuf);
+ *rc = retval = CtdlSockGetLine(sock, CC->sMigrateBuf, nSec);
- i = StrLength(CCC->sMigrateBuf);
- pCh = ChrPtr(CCC->sMigrateBuf);
+ i = StrLength(CC->sMigrateBuf);
+ pCh = ChrPtr(CC->sMigrateBuf);
memcpy(buf, pCh, i + 1);
- FlushStrBuf(CCC->sMigrateBuf);
+ FlushStrBuf(CC->sMigrateBuf);
if (retval < 0) {
safestrncpy(&buf[i], "000", bufsize - i);
i += 3;
}
-/*
- * Multiline version of sock_gets() ... this is a convenience function for
- * client side protocol implementations. It only returns the first line of
- * a multiline response, discarding the rest.
- */
-int ml_sock_gets(int *sock, char *buf, int nSec)
-{
+// Multiline version of sock_gets() ... this is a convenience function for
+// client side protocol implementations. It only returns the first line of
+// a multiline response, discarding the rest.
+int ml_sock_gets(int *sock, char *buf, int nSec) {
int rc = 0;
char bigbuf[1024];
int g;
}
-/*
- * sock_puts() - send line to server - implemented in terms of serv_write()
- * Returns the number of bytes written, or -1 for error.
- */
-int sock_puts(int *sock, char *buf)
-{
+// sock_puts() - send line to server - implemented in terms of serv_write()
+// Returns the number of bytes written, or -1 for error.
+int sock_puts(int *sock, char *buf) {
int i, j;
i = sock_write(sock, buf, strlen(buf));
HashList *ctdlconfig = NULL; // new configuration
-void config_warn_if_port_unset(char *key, int default_port)
-{
+void config_warn_if_port_unset(char *key, int default_port) {
int p = CtdlGetConfigInt(key);
if ((p < -1) || (p == 0) || (p > UINT16_MAX))
{
}
-void config_warn_if_empty(char *key)
-{
- if (IsEmptyStr(CtdlGetConfigStr(key)))
- {
+void config_warn_if_empty(char *key) {
+ if (IsEmptyStr(CtdlGetConfigStr(key))) {
syslog(LOG_ERR, "config: setting %s is empty, but must not - check your config!", key);
}
}
* Migrate a supplied legacy configuration to the new in-db format.
* No individual site should ever have to do this more than once.
*/
-void migrate_legacy_config(struct legacy_config *lconfig)
-{
+void migrate_legacy_config(struct legacy_config *lconfig) {
CtdlSetConfigStr( "c_nodename" , lconfig->c_nodename );
CtdlSetConfigStr( "c_fqdn" , lconfig->c_fqdn );
CtdlSetConfigStr( "c_humannode" , lconfig->c_humannode );
* Called when Citadel server is shutting down.
* Clears out the config hash table.
*/
-void shutdown_config_system(void)
-{
+void shutdown_config_system(void) {
DeleteHash(&ctdlconfig);
}
/*
* Set a system config value. Simple key/value here.
*/
-void CtdlSetConfigStr(char *key, char *value)
-{
+void CtdlSetConfigStr(char *key, char *value) {
int key_len = strlen(key);
int value_len = strlen(value);
/*
* Set a numeric system config value (long integer)
*/
-void CtdlSetConfigLong(char *key, long value)
-{
+void CtdlSetConfigLong(char *key, long value) {
char longstr[256];
sprintf(longstr, "%ld", value);
CtdlSetConfigStr(key, longstr);
/*
* Set a numeric system config value (integer)
*/
-void CtdlSetConfigInt(char *key, int value)
-{
+void CtdlSetConfigInt(char *key, int value) {
char intstr[256];
sprintf(intstr, "%d", value);
CtdlSetConfigStr(key, intstr);
/*
* Delete a system config value.
*/
-void CtdlDelConfig(char *key)
-{
+void CtdlDelConfig(char *key) {
int key_len = strlen(key);
if (IsEmptyStr(key)) return;
/*
* Fetch a system config value. Caller does *not* own the returned value and may not alter it.
*/
-char *CtdlGetConfigStr(char *key)
-{
+char *CtdlGetConfigStr(char *key) {
char *value = NULL;
struct cdbdata *cdb;
int key_len = strlen(key);
/*
* Fetch a system config value - integer
*/
-int CtdlGetConfigInt(char *key)
-{
+int CtdlGetConfigInt(char *key) {
char *s = CtdlGetConfigStr(key);
if (s) return atoi(s);
return 0;
/* Try to go single user */
-int CtdlTrySingleUser(void)
-{
+int CtdlTrySingleUser(void) {
int can_do = 0;
begin_critical_section(S_SINGLE_USER);
}
-void CtdlEndSingleUser(void)
-{
+void CtdlEndSingleUser(void) {
begin_critical_section(S_SINGLE_USER);
want_single_user = 0;
end_critical_section(S_SINGLE_USER);
}
-int CtdlWantSingleUser(void)
-{
+int CtdlWantSingleUser(void) {
return want_single_user;
}
-int CtdlIsSingleUser(void)
-{
- if (want_single_user)
- {
+int CtdlIsSingleUser(void) {
+ if (want_single_user) {
/* check for only one context here */
if (num_sessions == 1)
return 1;
* User CAN terminate any other session that has them logged in.
* Aide CAN terminate any session except the current one.
*/
-int CtdlTerminateOtherSession (int session_num)
-{
- struct CitContext *CCC = CC;
+int CtdlTerminateOtherSession (int session_num) {
int ret = 0;
CitContext *ccptr;
int aide;
- if (session_num == CCC->cs_pid) return TERM_NOTALLOWED;
+ if (session_num == CC->cs_pid) return TERM_NOTALLOWED;
- aide = ( (CCC->user.axlevel >= AxAideU) || (CCC->internal_pgm) ) ;
+ aide = ( (CC->user.axlevel >= AxAideU) || (CC->internal_pgm) ) ;
syslog(LOG_DEBUG, "context: locating session to kill");
begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
if (session_num == ccptr->cs_pid) {
ret |= TERM_FOUND;
- if ((ccptr->user.usernum == CCC->user.usernum) || aide) {
+ if ((ccptr->user.usernum == CC->user.usernum) || aide) {
ret |= TERM_ALLOWED;
}
break;
if (((ret & TERM_FOUND) != 0) && ((ret & TERM_ALLOWED) != 0))
{
- if (ccptr->user.usernum == CCC->user.usernum)
+ if (ccptr->user.usernum == CC->user.usernum)
ccptr->kill_me = KILLME_ADMIN_TERMINATE;
else
ccptr->kill_me = KILLME_IDLE;
}
-
/*
* Check to see if the user who we just sent mail to is logged in. If yes,
* bump the 'new mail' counter for their session. That enables them to
* receive a new mail notification without having to hit the database.
*/
-void BumpNewMailCounter(long which_user)
-{
+void BumpNewMailCounter(long which_user) {
CtdlBumpNewMailCounter(which_user);
}
-void CtdlBumpNewMailCounter(long which_user)
-{
+
+void CtdlBumpNewMailCounter(long which_user) {
CitContext *ptr;
begin_critical_section(S_SESSION_TABLE);
* The user may not have been logged in when this function was called BUT
* because of threading the user might be logged in before you test the result.
*/
-int CtdlIsUserLoggedIn (char *user_name)
-{
+int CtdlIsUserLoggedIn(char *user_name) {
CitContext *cptr;
int ret = 0;
}
-
/*
* Check to see if a user is currently logged in.
* Basically same as CtdlIsUserLoggedIn() but uses the user number instead.
* The user may not have been logged in when this function was called BUT
* because of threading the user might be logged in before you test the result.
*/
-int CtdlIsUserLoggedInByNum (long usernum)
-{
+int CtdlIsUserLoggedInByNum (long usernum) {
CitContext *cptr;
int ret = 0;
}
-
/*
* Return a pointer to the CitContext structure bound to the thread which
* called this function. If there's no such binding (for example, if it's
}
-
-
/*
* Terminate idle sessions. This function pounds through the session table
* comparing the current time to each session's time-of-last-command. If an
* idle session is found it is terminated, then the search restarts at the
* beginning because the pointer to our place in the list becomes invalid.
*/
-void terminate_idle_sessions(void)
-{
+void terminate_idle_sessions(void) {
CitContext *ccptr;
time_t now;
int killed = 0;
/*
* During shutdown, close the sockets of any sessions still connected.
*/
-void terminate_all_sessions(void)
-{
+void terminate_all_sessions(void) {
CitContext *ccptr;
int killed = 0;
}
-
/*
* Terminate a session.
*/
-void RemoveContext (CitContext *con)
-{
+void RemoveContext (CitContext *con) {
const char *c;
if (con == NULL) {
syslog(LOG_ERR, "context: RemoveContext() called with NULL, this should not happen");
* If the client is still connected, blow 'em away.
* if the socket is 0 or -1, its already gone or was never there.
*/
- if (con->client_socket > 0)
- {
+ if (con->client_socket > 0) {
syslog(LOG_INFO, "context: closing socket %d", con->client_socket);
close(con->client_socket);
}
}
-
/*
* Initialize a new context and place it in the list. The session number
* used to be the PID (which is why it's called cs_pid), but that was when we
* This allows worker threads to perform "for each context" operations without
* having to lock and traverse the live list.
*/
-CitContext *CtdlGetContextArray(int *count)
-{
+CitContext *CtdlGetContextArray(int *count) {
int nContexts, i;
CitContext *nptr, *cptr;
}
-
/*
* Back-end function for starting a session
*/
-void begin_session(CitContext *con)
-{
+void begin_session(CitContext *con) {
/*
* Initialize some variables specific to our context.
*/
* This function fills in a context and its user field correctly
* Then creates/loads that user
*/
-void CtdlFillSystemContext(CitContext *context, char *name)
-{
+void CtdlFillSystemContext(CitContext *context, char *name) {
char sysname[SIZ];
long len;
internal_create_user(sysname, &(context->user), -1) ;
/* Check to see if the system user needs upgrading */
- if (context->user.usernum == 0)
- { /* old system user with number 0, upgrade it */
+ if (context->user.usernum == 0) { /* old system user with number 0, upgrade it */
context->user.usernum = get_new_user_number();
syslog(LOG_INFO, "context: upgrading system user \"%s\" from user number 0 to user number %ld", context->user.fullname, context->user.usernum);
/* add user to the database */
/*
* Cleanup any contexts that are left lying around
*/
-void context_cleanup(void)
-{
+void context_cleanup(void) {
CitContext *ptr = NULL;
CitContext *rem = NULL;
}
-
/*
* Purge all sessions which have the 'kill_me' flag set.
* This function has code to prevent it from running more than once every
}
-
-
-
/*
* masterCC is the context we use when not attached to a session. This
* function initializes it.
}
-
-
-
/*
* Set the "async waiting" flag for a session, if applicable
*/
-void set_async_waiting(struct CitContext *ccptr)
-{
+void set_async_waiting(struct CitContext *ccptr) {
syslog(LOG_DEBUG, "context: setting async_waiting flag for session %d", ccptr->cs_pid);
if (ccptr->is_async) {
ccptr->async_waiting++;
+++ /dev/null
-#!/bin/bash
-
-BASE_SITE=http://www.citadel.org
-
-
-
-#retrieves an index document from the citadel.org website, and filters it
-# 1: URL
-# 2: outfile where to put the filtered content at
-GetIndex()
-{
- cd /tmp/; wget -q "${BASE_SITE}/${1}"
- cat "/tmp/${1}" | \
- grep /doku.php/ | \
- grep -v "do=" | \
- sed -e "s;.*href=\";;" \
- -e "s;\" .*;;" \
- -e "s;doku.php/;doku.php?id=;"| \
- grep "^/doku" > \
- "/tmp/$2"
-}
-
-rm -f /tmp/mainindex /tmp/doku.php*
-GetIndex "doku.php?id=faq:start" mainindex
-
-for i in `cat /tmp/mainindex`; do
- TMPNAME=`echo $i|sed "s;.*=;;"`
- echo $i $TMPNAME
- mkdir /tmp/$TMPNAME
- GetIndex "$i" "$TMPNAME/$TMPNAME"
- for j in `cat /tmp/$TMPNAME/$TMPNAME`; do
- echo "-----------$j----------------"
- cd /tmp/$TMPNAME/;
- DOCUMENT_NAME=`echo $j|sed -e "s;/doku.php?id=.*:;;"`
- PLAIN_NAME=`grep "$DOCUMENT_NAME" /tmp/doku*$TMPNAME |head -n1 |sed -e "s;','/doku.*;;" -e "s;.*';;"`
-
- echo "********** retrieving $DOCUMENT_NAME ************"
- wget -q "${BASE_SITE}/${j}&do=export_xhtmlbody"
- mv "/tmp/$TMPNAME/${j}&do=export_xhtmlbody" /tmp/$TMPNAME/$DOCUMENT_NAME
-
- echo "<li><a href=\"#$DOCUMENT_NAME\">$PLAIN_NAME</a></li>" >>collect_index
- echo "<a name=\"$DOCUMENT_NAME\"></a>" >>collect_bodies
- cat $DOCUMENT_NAME>>collect_bodies
- done
- (
- echo "<html><head>$TMPNAME</head><body><ul>"
- cat "/tmp/$TMPNAME/collect_index"
- echo "<hr></ul>"
- cat "/tmp/$TMPNAME/collect_bodies"
- echo "</body></html>"
- ) >/tmp/`echo $TMPNAME|sed "s;:;_;g"`.html
-done
\ No newline at end of file
-/*
- * Index messages by EUID per room.
- *
- * Copyright (c) 1987-2020 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// Index messages by EUID per room.
+//
+// Copyright (c) 1987-2022 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
#include "sysdep.h"
#include <stdio.h>
#include "citserver.h"
#include "room_ops.h"
-/*
- * The structure of an euidindex record *key* is:
- *
- * |----room_number----|----------EUID-------------|
- * (sizeof long) (actual length of euid)
- *
- *
- * The structure of an euidindex record *value* is:
- *
- * |-----msg_number----|----room_number----|----------EUID-------------|
- * (sizeof long) (sizeof long) (actual length of euid)
- *
- */
-
-/*
- * Return nonzero if the supplied room is one which should have
- * an EUID index.
- */
+// The structure of an euidindex record *key* is:
+//
+// |----room_number----|----------EUID-------------|
+// (sizeof long) (actual length of euid)
+//
+//
+// The structure of an euidindex record *value* is:
+//
+// |-----msg_number----|----room_number----|----------EUID-------------|
+// (sizeof long) (sizeof long) (actual length of euid)
+
+// Return nonzero if the supplied room is one which should have
+// an EUID index.
int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) {
switch(qrbuf->QRdefaultview) {
}
-/*
- * Locate a message in a given room with a given euid, and return
- * its message number.
- */
+// Locate a message in a given room with a given euid, and return
+// its message number.
long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf) {
return CtdlLocateMessageByEuid (euid, qrbuf);
}
msgnum = (-1L);
}
else {
- /* The first (sizeof long) of the record is what we're
- * looking for. Throw away the rest.
- */
+ // The first (sizeof long) of the record is what we're looking for. Throw away the rest.
memcpy(&msgnum, cdb_euid->ptr, sizeof(long));
cdb_free(cdb_euid);
}
}
-/*
- * Store the euid index for a message, which has presumably just been
- * stored in this room by the caller.
- */
+// Store the euid index for a message, which has presumably just been
+// stored in this room by the caller.
void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
char *key;
int key_len;
}
-/*
- * Called by rebuild_euid_index_for_room() to index one message.
- */
+// Called by rebuild_euid_index_for_room() to index one message.
void rebuild_euid_index_for_msg(long msgnum, void *userdata) {
struct CtdlMessage *msg = NULL;
struct RoomProcList *ptr;
struct ctdlroom qr;
- /* Lazy programming here. Call this function as a CtdlForEachRoom backend
- * in order to queue up the room names, or call it with a null room
- * to make it do the processing.
- */
+ // Lazy programming here. Call this function as a CtdlForEachRoom backend
+ // in order to queue up the room names, or call it with a null room
+ // to make it do the processing.
if (qrbuf != NULL) {
ptr = (struct RoomProcList *)
malloc(sizeof (struct RoomProcList));
}
-/*
- * Globally rebuild the EUID indices in every room.
- */
+// Globally rebuild the EUID indices in every room.
void rebuild_euid_index(void) {
- cdb_trunc(CDB_EUIDINDEX); /* delete the old indices */
- CtdlForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate rm names */
- rebuild_euid_index_for_room(NULL, NULL); /* and index them */
+ cdb_trunc(CDB_EUIDINDEX); // delete the old indices
+ CtdlForEachRoom(rebuild_euid_index_for_room, NULL); // enumerate room names
+ rebuild_euid_index_for_room(NULL, NULL); // and index them
}
-/*
- * Server command to fetch a message number given an euid.
- */
+// Server command to fetch a message number given an euid.
void cmd_euid(char *cmdbuf) {
char euid[256];
long msgnum;
-/*
- * This module handles loading, saving, and parsing of room network configurations.
- *
- * Copyright (c) 2000-2021 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+// This module handles loading, saving, and parsing of room network configurations.
+//
+// Copyright (c) 2000-2021 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
#include "sysdep.h"
#include <stdio.h>
#include "config.h"
-/*
- * Create a config key for a room's netconfig entry
- */
+// Create a config key for a room's netconfig entry
void netcfg_keyname(char *keybuf, long roomnum) {
if (!keybuf) return;
sprintf(keybuf, "c_netconfig_%010ld", roomnum);
}
-/*
- * Given a room number and a textual netconfig, convert to base64 and write to the configdb
- */
+// Given a room number and a textual netconfig, convert to base64 and write to the configdb
void SaveRoomNetConfigFile(long roomnum, const char *raw_netconfig) {
char keyname[25];
char *enc;
}
-/*
- * Given a room number, attempt to load the netconfig configdb entry for that room.
- * If it returns NULL, there is no netconfig.
- * Otherwise the caller owns the returned memory and is responsible for freeing it.
- */
+// Given a room number, attempt to load the netconfig configdb entry for that room.
+// If it returns NULL, there is no netconfig.
+// Otherwise the caller owns the returned memory and is responsible for freeing it.
char *LoadRoomNetConfigFile(long roomnum) {
char keyname[25];
char *encoded_netconfig = NULL;
}
-/*-----------------------------------------------------------------------------*
- * Per room network configs : exchange with client *
- *-----------------------------------------------------------------------------*/
-
+//-----------------------------------------------------------------------------
+// Per room network configs : exchange with client
+//-----------------------------------------------------------------------------
void cmd_gnet(char *argbuf) {
if ( (CC->room.QRflags & QR_MAILBOX) && (CC->user.usernum == atol(CC->room.QRname)) ) {
- /* users can edit the netconfigs for their own mailbox rooms */
+ // users can edit the netconfigs for their own mailbox rooms
}
else if (CtdlAccessCheck(ac_room_aide)) return;
}
-/*
- * Convert any legacy configuration files in the "netconfigs" directory
- */
-void convert_legacy_netcfg_files(void)
-{
+// Convert any legacy configuration files in the "netconfigs" directory
+void convert_legacy_netcfg_files(void) {
DIR *dh = NULL;
struct dirent *dit = NULL;
char filename[PATH_MAX];