-/*
- * Server functions which perform operations on room objects.
- *
- * 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.
- */
+// Server functions which perform operations on room objects.
+//
+// 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.
-/*
- * Back-back-end for all room listing commands
- */
-void list_roomname(struct ctdlroom *qrbuf, int ra, int current_view, int default_view)
-{
+// Back-back-end for all room listing commands
+void list_roomname(struct ctdlroom *qrbuf, int ra, int current_view, int default_view) {
if ( (qrbuf->QRflags & QR_MAILBOX)
&& (atol(qrbuf->QRname) == CC->user.usernum) ) {
safestrncpy(truncated_roomname, qrbuf->QRname, sizeof truncated_roomname);
safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
cprintf("%s", truncated_roomname);
}
if ( (qrbuf->QRflags & QR_MAILBOX)
&& (atol(qrbuf->QRname) == CC->user.usernum) ) {
safestrncpy(truncated_roomname, qrbuf->QRname, sizeof truncated_roomname);
safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
cprintf("%s", truncated_roomname);
}
-/*
- * cmd_lrms() - List all accessible rooms, known or forgotten
- */
-void cmd_lrms_backend(struct ctdlroom *qrbuf, void *data)
-{
+// cmd_lrms() - List all accessible rooms, known or forgotten
+void cmd_lrms_backend(struct ctdlroom *qrbuf, void *data) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
}
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
}
int FloorBeingSearched = (-1);
if (!IsEmptyStr(argbuf))
FloorBeingSearched = extract_int(argbuf, 0);
int FloorBeingSearched = (-1);
if (!IsEmptyStr(argbuf))
FloorBeingSearched = extract_int(argbuf, 0);
-
-/*
- * cmd_lkra() - List all known rooms
- */
-void cmd_lkra_backend(struct ctdlroom *qrbuf, void *data)
-{
+// cmd_lkra() - List all known rooms
+void cmd_lkra_backend(struct ctdlroom *qrbuf, void *data) {
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
- if ((( ra & (UA_KNOWN)))
- && ((qrbuf->QRfloor == (FloorBeingSearched))
- || ((FloorBeingSearched) < 0)))
+ if ((( ra & (UA_KNOWN))) && ((qrbuf->QRfloor == (FloorBeingSearched)) || ((FloorBeingSearched) < 0))) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
- if ( ((qrbuf->QRflags & QR_PRIVATE) == 0)
- && ((qrbuf->QRflags & QR_MAILBOX) == 0)
- && ((qrbuf->QRfloor == (FloorBeingSearched))
- || ((FloorBeingSearched) < 0)))
+ if (((qrbuf->QRflags & QR_PRIVATE) == 0) && ((qrbuf->QRflags & QR_MAILBOX) == 0) && ((qrbuf->QRfloor == (FloorBeingSearched)) || ((FloorBeingSearched) < 0))) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
-
-/*
- * cmd_lkrn() - List all known rooms with new messages
- */
-void cmd_lkrn_backend(struct ctdlroom *qrbuf, void *data)
-{
+// cmd_lkrn() - List all known rooms with new messages
+void cmd_lkrn_backend(struct ctdlroom *qrbuf, void *data) {
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
- if ((ra & UA_KNOWN)
- && (ra & UA_HASNEWMSGS)
- && ((qrbuf->QRfloor == (FloorBeingSearched))
- || ((FloorBeingSearched) < 0)))
+ if ((ra & UA_KNOWN) && (ra & UA_HASNEWMSGS) && ((qrbuf->QRfloor == (FloorBeingSearched)) || ((FloorBeingSearched) < 0))) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
-
-/*
- * cmd_lkro() - List all known rooms
- */
-void cmd_lkro_backend(struct ctdlroom *qrbuf, void *data)
-{
+// cmd_lkro() - List all known rooms
+void cmd_lkro_backend(struct ctdlroom *qrbuf, void *data) {
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
- if ((ra & UA_KNOWN)
- && ((ra & UA_HASNEWMSGS) == 0)
- && ((qrbuf->QRfloor == (FloorBeingSearched))
- || ((FloorBeingSearched) < 0)))
+ if ((ra & UA_KNOWN) && ((ra & UA_HASNEWMSGS) == 0) && ((qrbuf->QRfloor == (FloorBeingSearched)) || ((FloorBeingSearched) < 0))) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
-
-/*
- * cmd_lzrm() - List all forgotten rooms
- */
-void cmd_lzrm_backend(struct ctdlroom *qrbuf, void *data)
-{
+// cmd_lzrm() - List all forgotten rooms
+void cmd_lzrm_backend(struct ctdlroom *qrbuf, void *data) {
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
FloorBeingSearched = *(int *)data;
CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
- if ((ra & UA_GOTOALLOWED)
- && (ra & UA_ZAPPED)
- && ((qrbuf->QRfloor == (FloorBeingSearched))
- || ((FloorBeingSearched) < 0)))
+ if ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED) && ((qrbuf->QRfloor == (FloorBeingSearched)) || ((FloorBeingSearched) < 0))) {
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
int FloorBeingSearched = (-1);
if (!IsEmptyStr(argbuf))
FloorBeingSearched = extract_int(argbuf, 0);
int FloorBeingSearched = (-1);
if (!IsEmptyStr(argbuf))
FloorBeingSearched = extract_int(argbuf, 0);
- CtdlMailboxName(augmented_roomname, sizeof augmented_roomname,
- &CCC->user, towhere);
+ CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CCC->user, towhere);
- memcpy(&CCC->room, &QRscratch,
- sizeof(struct ctdlroom));
+ memcpy(&CCC->room, &QRscratch, sizeof(struct ctdlroom));
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
}
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
}
CtdlRoomAccess(&QRscratch, &CCC->user, &ra, NULL);
CtdlRoomAccess(&QRscratch, &CCC->user, &ra, NULL);
- memcpy(&CCC->room, &QRscratch,
- sizeof(struct ctdlroom));
+ memcpy(&CCC->room, &QRscratch, sizeof(struct ctdlroom));
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
- } else if ((QRscratch.QRflags & QR_PASSWORDED) &&
- ((ra & UA_KNOWN) == 0) &&
- (strcasecmp(QRscratch.QRpasswd, password)) &&
- (CCC->user.axlevel < AxAideU)
- ) {
- cprintf("%d wrong or missing passwd\n",
- ERROR + PASSWORD_REQUIRED);
+ }
+ else if ((QRscratch.QRflags & QR_PASSWORDED) &&
+ ((ra & UA_KNOWN) == 0) &&
+ (strcasecmp(QRscratch.QRpasswd, password)) &&
+ (CCC->user.axlevel < AxAideU)
+ ) {
+ cprintf("%d wrong or missing passwd\n", ERROR + PASSWORD_REQUIRED);
((QRscratch.QRflags & QR_PASSWORDED) == 0) &&
((QRscratch.QRflags & QR_GUESSNAME) == 0) &&
((ra & UA_KNOWN) == 0) &&
(CCC->user.axlevel < AxAideU)
) {
syslog(LOG_DEBUG, "rooms: failed to acquire private room");
((QRscratch.QRflags & QR_PASSWORDED) == 0) &&
((QRscratch.QRflags & QR_GUESSNAME) == 0) &&
((ra & UA_KNOWN) == 0) &&
(CCC->user.axlevel < AxAideU)
) {
syslog(LOG_DEBUG, "rooms: failed to acquire private room");
- } else {
- memcpy(&CCC->room, &QRscratch,
- sizeof(struct ctdlroom));
+ }
+ else {
+ memcpy(&CCC->room, &QRscratch, sizeof(struct ctdlroom));
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
}
CtdlUserGoto(NULL, 1, transiently, NULL, NULL, NULL, NULL);
return;
}
snprintf(buf, sizeof buf, "%s/%s/filedir", ctdl_file_dir, CC->room.QRdirname);
fd = fopen(buf, "r");
snprintf(buf, sizeof buf, "%s/%s/filedir", ctdl_file_dir, CC->room.QRdirname);
fd = fopen(buf, "r");
- while ((filedir_entry = readdir(filedir)))
- {
- if (strcasecmp(filedir_entry->d_name, "filedir") && filedir_entry->d_name[0] != '.')
- {
+ }
+ while ((filedir_entry = readdir(filedir))) {
+ if (strcasecmp(filedir_entry->d_name, "filedir") && filedir_entry->d_name[0] != '.') {
#endif
snprintf(buf, sizeof buf, "%s/%s/%s", ctdl_file_dir, CC->room.QRdirname, filedir_entry->d_name);
stat(buf, &statbuf); /* stat the file */
#endif
snprintf(buf, sizeof buf, "%s/%s/%s", ctdl_file_dir, CC->room.QRdirname, filedir_entry->d_name);
stat(buf, &statbuf); /* stat the file */
snprintf(buf2, sizeof buf2,
"\"%s\" appears in the file directory for room \"%s\" but is not a regular file. Directories, named pipes, sockets, etc. are not usable in Citadel room directories.\n",
buf, CC->room.QRname
snprintf(buf2, sizeof buf2,
"\"%s\" appears in the file directory for room \"%s\" but is not a regular file. Directories, named pipes, sockets, etc. are not usable in Citadel room directories.\n",
buf, CC->room.QRname
safestrncpy(comment, "", sizeof comment);
fseek(fd, 0L, 0); /* rewind descriptions file */
/* Get the description from the descriptions file */
safestrncpy(comment, "", sizeof comment);
fseek(fd, 0L, 0); /* rewind descriptions file */
/* Get the description from the descriptions file */
buf[strlen(buf) - 1] = 0;
if ((!strncasecmp(buf, filedir_entry->d_name, d_namelen)) && (buf[d_namelen] == ' '))
safestrncpy(comment, &buf[d_namelen + 1], sizeof comment);
}
len = extract_token (mimebuf, comment, 0,' ', 64);
buf[strlen(buf) - 1] = 0;
if ((!strncasecmp(buf, filedir_entry->d_name, d_namelen)) && (buf[d_namelen] == ' '))
safestrncpy(comment, &buf[d_namelen + 1], sizeof comment);
}
len = extract_token (mimebuf, comment, 0,' ', 64);
if (CtdlAccessCheck(ac_room_aide)) return;
CtdlGetRoom(&CC->room, CC->room.QRname);
cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n",
CIT_OK,
CtdlCheckExpress(),
if (CtdlAccessCheck(ac_room_aide)) return;
CtdlGetRoom(&CC->room, CC->room.QRname);
cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n",
CIT_OK,
CtdlCheckExpress(),
-
- ((CC->room.QRflags & QR_MAILBOX) ?
- &CC->room.QRname[11] : CC->room.QRname),
-
- ((CC->room.QRflags & QR_PASSWORDED) ?
- CC->room.QRpasswd : ""),
-
- ((CC->room.QRflags & QR_DIRECTORY) ?
- CC->room.QRdirname : ""),
-
+ ((CC->room.QRflags & QR_MAILBOX) ? &CC->room.QRname[11] : CC->room.QRname),
+ ((CC->room.QRflags & QR_PASSWORDED) ? CC->room.QRpasswd : ""),
+ ((CC->room.QRflags & QR_DIRECTORY) ? CC->room.QRdirname : ""),
if (num_parms(args) >= 6) {
new_floor = extract_int(args, 5);
if (num_parms(args) >= 6) {
new_floor = extract_int(args, 5);
*/
if (CC->room.QRflags & QR_MAILBOX) {
sprintf(new_name, "%010ld.", atol(CC->room.QRname) );
*/
if (CC->room.QRflags & QR_MAILBOX) {
sprintf(new_name, "%010ld.", atol(CC->room.QRname) );
safestrncpy(new_name, "", sizeof new_name);
}
extract_token(&new_name[strlen(new_name)], args, 0, '|', (sizeof new_name - strlen(new_name)));
safestrncpy(new_name, "", sizeof new_name);
}
extract_token(&new_name[strlen(new_name)], args, 0, '|', (sizeof new_name - strlen(new_name)));
if (r == crr_room_not_found) {
cprintf("%d Internal error - room not found?\n", ERROR + INTERNAL_ERROR);
if (r == crr_room_not_found) {
cprintf("%d Internal error - room not found?\n", ERROR + INTERNAL_ERROR);
cprintf("%d '%s' already exists.\n",
ERROR + ALREADY_EXISTS, new_name);
cprintf("%d '%s' already exists.\n",
ERROR + ALREADY_EXISTS, new_name);
cprintf("%d Target floor does not exist.\n",
ERROR + INVALID_FLOOR_OPERATION);
cprintf("%d Target floor does not exist.\n",
ERROR + INVALID_FLOOR_OPERATION);
cprintf("%d You do not have permission to edit '%s'\n",
ERROR + HIGHER_ACCESS_REQUIRED,
CC->room.QRname);
cprintf("%d You do not have permission to edit '%s'\n",
ERROR + HIGHER_ACCESS_REQUIRED,
CC->room.QRname);
cprintf("%d Error: CtdlRenameRoom() returned %d\n",
ERROR + INTERNAL_ERROR, r);
}
cprintf("%d Error: CtdlRenameRoom() returned %d\n",
ERROR + INTERNAL_ERROR, r);
}
CC->room.QRflags &= ~(QR_PRIVATE & QR_PASSWORDED &
QR_GUESSNAME & QR_PREFONLY & QR_MAILBOX);
CC->room.QRflags |= QR_PERMANENT;
CC->room.QRflags &= ~(QR_PRIVATE & QR_PASSWORDED &
QR_GUESSNAME & QR_PREFONLY & QR_MAILBOX);
CC->room.QRflags |= QR_PERMANENT;
/* March order (doesn't apply to AIDEROOM) */
if (num_parms(args) >= 7)
CC->room.QRorder = (char) new_order;
/* Room password */
extract_token(buf, args, 1, '|', sizeof buf);
buf[10] = 0;
/* March order (doesn't apply to AIDEROOM) */
if (num_parms(args) >= 7)
CC->room.QRorder = (char) new_order;
/* Room password */
extract_token(buf, args, 1, '|', sizeof buf);
buf[10] = 0;
- safestrncpy(CC->room.QRpasswd, buf,
- sizeof CC->room.QRpasswd);
+ safestrncpy(CC->room.QRpasswd, buf, sizeof CC->room.QRpasswd);
- snprintf(buf, sizeof buf,"%s/%s",
- ctdl_file_dir,
- CC->room.QRdirname);
+ snprintf(buf, sizeof buf,"%s/%s", ctdl_file_dir, CC->room.QRdirname);
mkdir(buf, 0755);
}
snprintf(buf, sizeof buf, "The room \"%s\" has been edited by %s.\n",
mkdir(buf, 0755);
}
snprintf(buf, sizeof buf, "The room \"%s\" has been edited by %s.\n",
struct ctdluser usbuf;
if (CtdlAccessCheck(ac_logged_in)) return;
if (CtdlGetUserByNumber(&usbuf, CC->room.QRroomaide) == 0) {
cprintf("%d %s\n", CIT_OK, usbuf.fullname);
struct ctdluser usbuf;
if (CtdlAccessCheck(ac_logged_in)) return;
if (CtdlGetUserByNumber(&usbuf, CC->room.QRroomaide) == 0) {
cprintf("%d %s\n", CIT_OK, usbuf.fullname);
- /*
- * We have to post the change notice _after_ writing changes to
- * the room table, otherwise it would deadlock!
- */
+ // We have to post the change notice _after_ writing changes to
+ // the room table, otherwise it would deadlock!
if (post_notice == 1) {
if (!IsEmptyStr(usbuf.fullname))
snprintf(buf, sizeof buf,
if (post_notice == 1) {
if (!IsEmptyStr(usbuf.fullname))
snprintf(buf, sizeof buf,
-/*
- * Retrieve info file for this room (this ought to be upgraded to handle non-plain-text)
- */
-void cmd_rinf(char *argbuf)
-{
+
+// Retrieve info file for this room (this ought to be upgraded to handle non-plain-text)
+void cmd_rinf(char *argbuf) {
struct CtdlMessage *msg = CtdlFetchMessage(CC->room.msgnum_info, 1);
if (msg != NULL) {
cprintf("%d Info:\n", LISTING_FOLLOWS);
struct CtdlMessage *msg = CtdlFetchMessage(CC->room.msgnum_info, 1);
if (msg != NULL) {
cprintf("%d Info:\n", LISTING_FOLLOWS);
);
CtdlAideMessage(msg, "Room Purger Message");
cprintf("%d '%s' deleted.\n", CIT_OK, deleted_room_name);
);
CtdlAideMessage(msg, "Room Purger Message");
cprintf("%d '%s' deleted.\n", CIT_OK, deleted_room_name);
-/*
- * Upload the room banner text for this room.
- * This should be amended to handle content types other than plain text.
- */
-void cmd_einf(char *ok)
-{ /* enter info file for current room */
+// Upload the room banner text for this room.
+// This should be amended to handle content types other than plain text.
+void cmd_einf(char *ok) { /* enter info file for current room */
- cprintf("%d Floor %d not in use.\n",
- ERROR + INVALID_FLOOR_OPERATION, floor_to_delete);
+ cprintf("%d Floor %d not in use.\n", ERROR + INVALID_FLOOR_OPERATION, floor_to_delete);
lgetfloor(&flbuf, floor_num);
if ((flbuf.f_flags & F_INUSE) == 0) {
lputfloor(&flbuf, floor_num);
lgetfloor(&flbuf, floor_num);
if ((flbuf.f_flags & F_INUSE) == 0) {
lputfloor(&flbuf, floor_num);
- cprintf("%d Floor %d is not in use.\n",
- ERROR + INVALID_FLOOR_OPERATION, floor_num);
+ cprintf("%d Floor %d is not in use.\n", ERROR + INVALID_FLOOR_OPERATION, floor_num);
extract_token(flbuf.f_name, argbuf, 1, '|', sizeof flbuf.f_name);
extract_token(flbuf.f_name, argbuf, 1, '|', sizeof flbuf.f_name);
lputfloor(&flbuf, floor_num);
cprintf("%d Ok\n", CIT_OK);
}
lputfloor(&flbuf, floor_num);
cprintf("%d Ok\n", CIT_OK);
}
-
-/*
- * cmd_stat() - return the modification time of the current room (maybe other things in the future)
- */
-void cmd_stat(char *gargs)
-{
+// cmd_stat() - return the modification time of the current room (maybe other things in the future)
+void cmd_stat(char *gargs) {
if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
CtdlGetRoom(&CC->room, CC->room.QRname);
cprintf("%d %s|%ld|\n", CIT_OK, CC->room.QRname, CC->room.QRmtime);
}
if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
CtdlGetRoom(&CC->room, CC->room.QRname);
cprintf("%d %s|%ld|\n", CIT_OK, CC->room.QRname, CC->room.QRmtime);
}
/*****************************************************************************/
/* MODULE INITIALIZATION STUFF */
/*****************************************************************************/
/*****************************************************************************/
/* MODULE INITIALIZATION STUFF */
/*****************************************************************************/