2 * Server functions which perform operations on room objects.
4 * Copyright (c) 1987-2012 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.
22 #include <dirent.h> /* for cmd_rdir to read contents of the directory */
24 #if TIME_WITH_SYS_TIME
25 # include <sys/time.h>
29 # include <sys/time.h>
38 #include <libcitadel.h>
43 #include "sysdep_decls.h"
46 #include "citserver.h"
48 #include "citadel_dirs.h"
51 #include "ctdl_module.h"
54 struct floor *floorcache[MAXFLOORS];
57 * Determine whether the currently logged in session has permission to read
58 * messages in the current room.
60 int CtdlDoIHavePermissionToReadMessagesInThisRoom(void) {
61 if ( (!(CC->logged_in))
62 && (!(CC->internal_pgm))
63 && (!config.c_guest_logins)
65 return(om_not_logged_in);
71 * Check to see whether we have permission to post a message in the current
72 * room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
73 * returns 0 on success.
75 int CtdlDoIHavePermissionToPostInThisRoom(
78 const char* RemoteIdentifier,
84 if (!(CC->logged_in) &&
85 (PostPublic == POST_LOGGED_IN)) {
86 snprintf(errmsgbuf, n, "Not logged in.");
87 return (ERROR + NOT_LOGGED_IN);
89 else if (PostPublic == CHECK_EXISTANCE) {
90 return (0); // We're Evaling whether a recipient exists
92 else if (!(CC->logged_in)) {
94 if ((CC->room.QRflags & QR_READONLY)) {
95 snprintf(errmsgbuf, n, "Not logged in.");
96 return (ERROR + NOT_LOGGED_IN);
98 if (CC->room.QRflags2 & QR2_MODERATED) {
99 snprintf(errmsgbuf, n, "Not logged in Moderation feature not yet implemented!");
100 return (ERROR + NOT_LOGGED_IN);
102 if ((PostPublic!=POST_LMTP) &&(CC->room.QRflags2 & QR2_SMTP_PUBLIC) == 0) {
104 return CtdlNetconfigCheckRoomaccess(errmsgbuf, n, RemoteIdentifier);
110 if ((CC->user.axlevel < AxProbU)
111 && ((CC->room.QRflags & QR_MAILBOX) == 0)) {
112 snprintf(errmsgbuf, n, "Need to be validated to enter (except in %s> to sysop)", MAILROOM);
113 return (ERROR + HIGHER_ACCESS_REQUIRED);
116 CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL);
118 if (ra & UA_POSTALLOWED) {
119 strcpy(errmsgbuf, "OK to post or reply here");
123 if ( (ra & UA_REPLYALLOWED) && (is_reply) ) {
125 * To be thorough, we ought to check to see if the message they are
126 * replying to is actually a valid one in this room, but unless this
127 * actually becomes a problem we'll go with high performance instead.
129 strcpy(errmsgbuf, "OK to reply here");
133 if ( (ra & UA_REPLYALLOWED) && (!is_reply) ) {
134 /* Clarify what happened with a better error message */
135 snprintf(errmsgbuf, n, "You may only reply to existing messages here.");
136 return (ERROR + HIGHER_ACCESS_REQUIRED);
139 snprintf(errmsgbuf, n, "Higher access is required to post in this room.");
140 return (ERROR + HIGHER_ACCESS_REQUIRED);
145 * Check whether the current user has permission to delete messages from
146 * the current room (returns 1 for yes, 0 for no)
148 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void) {
150 CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL);
151 if (ra & UA_DELETEALLOWED) return(1);
156 * Retrieve access control information for any user/room pair
158 void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
159 int *result, int *view)
166 if (userbuf == &CC->user) {
170 if ((is_me) && (config.c_guest_logins) && (!CC->logged_in)) {
174 /* for internal programs, always do everything */
175 if (((CC->internal_pgm)) && (roombuf->QRflags & QR_INUSE)) {
176 retval = (UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED);
178 goto SKIP_EVERYTHING;
181 /* If guest mode is enabled, always grant access to the Lobby */
182 if ((is_guest) && (!strcasecmp(roombuf->QRname, BASEROOM))) {
183 retval = (UA_KNOWN | UA_GOTOALLOWED);
185 goto SKIP_EVERYTHING;
188 /* Locate any applicable user/room relationships */
190 memset(&vbuf, 0, sizeof vbuf);
193 CtdlGetRelationship(&vbuf, userbuf, roombuf);
196 /* Force the properties of the Aide room */
197 if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
198 if (userbuf->axlevel >= AxAideU) {
199 retval = UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED;
206 /* If this is a public room, it's accessible... */
207 if ( ((roombuf->QRflags & QR_PRIVATE) == 0)
208 && ((roombuf->QRflags & QR_MAILBOX) == 0)
210 retval = retval | UA_KNOWN | UA_GOTOALLOWED;
213 /* If this is a preferred users only room, check access level */
214 if (roombuf->QRflags & QR_PREFONLY) {
215 if (userbuf->axlevel < AxPrefU) {
216 retval = retval & ~UA_KNOWN & ~UA_GOTOALLOWED;
220 /* For private rooms, check the generation number matchups */
221 if ( (roombuf->QRflags & QR_PRIVATE)
222 && ((roombuf->QRflags & QR_MAILBOX) == 0)
225 /* An explicit match means the user belongs in this room */
226 if (vbuf.v_flags & V_ACCESS) {
227 retval = retval | UA_KNOWN | UA_GOTOALLOWED;
229 /* Otherwise, check if this is a guess-name or passworded
230 * room. If it is, a goto may at least be attempted
232 else if ( (roombuf->QRflags & QR_PRIVATE)
233 || (roombuf->QRflags & QR_PASSWORDED)
235 retval = retval & ~UA_KNOWN;
236 retval = retval | UA_GOTOALLOWED;
240 /* For mailbox rooms, also check the namespace */
241 /* Also, mailbox owners can delete their messages */
242 if ( (roombuf->QRflags & QR_MAILBOX) && (atol(roombuf->QRname) != 0)) {
243 if (userbuf->usernum == atol(roombuf->QRname)) {
244 retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED;
246 /* An explicit match means the user belongs in this room */
247 if (vbuf.v_flags & V_ACCESS) {
248 retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED;
252 /* For non-mailbox rooms... */
255 /* User is allowed to post in the room unless:
256 * - User is not validated
257 * - User has no net privileges and it is a shared network room
258 * - It is a read-only room
259 * - It is a blog room (in which case we only allow replies to existing messages)
261 int post_allowed = 1;
262 int reply_allowed = 1;
263 if (userbuf->axlevel < AxProbU) {
267 if ((userbuf->axlevel < AxNetU) && (roombuf->QRflags & QR_NETWORK)) {
271 if (roombuf->QRflags & QR_READONLY) {
275 if (roombuf->QRdefaultview == VIEW_BLOG) {
279 retval = retval | UA_POSTALLOWED | UA_REPLYALLOWED;
282 retval = retval | UA_REPLYALLOWED;
285 /* If "collaborative deletion" is active for this room, any user who can post
286 * is also allowed to delete
288 if (roombuf->QRflags2 & QR2_COLLABDEL) {
289 if (retval & UA_POSTALLOWED) {
290 retval = retval | UA_DELETEALLOWED;
296 /* Check to see if the user has forgotten this room */
297 if (vbuf.v_flags & V_FORGET) {
298 retval = retval & ~UA_KNOWN;
299 if ( ( ((roombuf->QRflags & QR_PRIVATE) == 0)
300 && ((roombuf->QRflags & QR_MAILBOX) == 0)
301 ) || ( (roombuf->QRflags & QR_MAILBOX)
302 && (atol(roombuf->QRname) == CC->user.usernum))
304 retval = retval | UA_ZAPPED;
308 /* If user is explicitly locked out of this room, deny everything */
309 if (vbuf.v_flags & V_LOCKOUT) {
310 retval = retval & ~UA_KNOWN & ~UA_GOTOALLOWED & ~UA_POSTALLOWED & ~UA_REPLYALLOWED;
313 /* Aides get access to all private rooms */
314 if ( (userbuf->axlevel >= AxAideU)
315 && ((roombuf->QRflags & QR_MAILBOX) == 0)
317 if (vbuf.v_flags & V_FORGET) {
318 retval = retval | UA_GOTOALLOWED | UA_POSTALLOWED | UA_REPLYALLOWED;
321 retval = retval | UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_REPLYALLOWED;
325 /* Aides can gain access to mailboxes as well, but they don't show
328 if ( (userbuf->axlevel >= AxAideU)
329 && (roombuf->QRflags & QR_MAILBOX)
331 retval = retval | UA_GOTOALLOWED | UA_POSTALLOWED | UA_REPLYALLOWED;
334 /* Aides and Room Aides have admin privileges */
335 if ( (userbuf->axlevel >= AxAideU)
336 || (userbuf->usernum == roombuf->QRroomaide)
338 retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED | UA_POSTALLOWED | UA_REPLYALLOWED;
341 NEWMSG: /* By the way, we also check for the presence of new messages */
342 if (is_msg_in_sequence_set(vbuf.v_seen, roombuf->QRhighest) == 0) {
343 retval = retval | UA_HASNEWMSGS;
346 /* System rooms never show up in the list. */
347 if (roombuf->QRflags2 & QR2_SYSTEM) {
348 retval = retval & ~UA_KNOWN;
352 /* Now give the caller the information it wants. */
353 if (result != NULL) *result = retval;
354 if (view != NULL) *view = vbuf.v_view;
359 * Self-checking stuff for a room record read into memory
361 void room_sanity_check(struct ctdlroom *qrbuf)
363 /* Mailbox rooms are always on the lowest floor */
364 if (qrbuf->QRflags & QR_MAILBOX) {
367 /* Listing order of 0 is illegal except for base rooms */
368 if (qrbuf->QRorder == 0)
369 if (!(qrbuf->QRflags & QR_MAILBOX) &&
370 strncasecmp(qrbuf->QRname, config.c_baseroom, ROOMNAMELEN)
372 strncasecmp(qrbuf->QRname, config.c_aideroom, ROOMNAMELEN))
378 * CtdlGetRoom() - retrieve room data from disk
380 int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name)
382 struct cdbdata *cdbqr;
383 char lowercase_name[ROOMNAMELEN];
384 char personal_lowercase_name[ROOMNAMELEN];
388 dptr = lowercase_name;
390 eptr = (dptr + (sizeof lowercase_name - 1));
391 while (!IsEmptyStr(sptr) && (dptr < eptr)){
392 *dptr = tolower(*sptr);
397 memset(qrbuf, 0, sizeof(struct ctdlroom));
399 /* First, try the public namespace */
400 cdbqr = cdb_fetch(CDB_ROOMS,
401 lowercase_name, strlen(lowercase_name));
403 /* If that didn't work, try the user's personal namespace */
405 snprintf(personal_lowercase_name,
406 sizeof personal_lowercase_name, "%010ld.%s",
407 CC->user.usernum, lowercase_name);
408 cdbqr = cdb_fetch(CDB_ROOMS,
409 personal_lowercase_name,
410 strlen(personal_lowercase_name));
413 memcpy(qrbuf, cdbqr->ptr,
414 ((cdbqr->len > sizeof(struct ctdlroom)) ?
415 sizeof(struct ctdlroom) : cdbqr->len));
418 room_sanity_check(qrbuf);
427 * CtdlGetRoomLock() - same as getroom() but locks the record (if supported)
429 int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name)
432 retval = CtdlGetRoom(qrbuf, room_name);
433 if (retval == 0) begin_critical_section(S_ROOMS);
439 * b_putroom() - back end to putroom() and b_deleteroom()
440 * (if the supplied buffer is NULL, delete the room record)
442 void b_putroom(struct ctdlroom *qrbuf, char *room_name)
444 char lowercase_name[ROOMNAMELEN];
449 bptr = lowercase_name;
450 while (!IsEmptyStr(aptr))
452 *bptr = tolower(*aptr);
458 len = bptr - lowercase_name;
460 cdb_delete(CDB_ROOMS, lowercase_name, len);
462 time(&qrbuf->QRmtime);
463 cdb_store(CDB_ROOMS, lowercase_name, len, qrbuf, sizeof(struct ctdlroom));
469 * CtdlPutRoom() - store room data to disk
471 void CtdlPutRoom(struct ctdlroom *qrbuf) {
472 b_putroom(qrbuf, qrbuf->QRname);
477 * b_deleteroom() - delete a room record from disk
479 void b_deleteroom(char *room_name) {
480 b_putroom(NULL, room_name);
485 * CtdlPutRoomLock() - same as CtdlPutRoom() but unlocks the record (if supported)
487 void CtdlPutRoomLock(struct ctdlroom *qrbuf)
491 end_critical_section(S_ROOMS);
497 * CtdlGetFloorByName() - retrieve the number of the named floor
498 * return < 0 if not found else return floor number
500 int CtdlGetFloorByName(const char *floor_name)
503 struct floor *flbuf = NULL;
505 for (a = 0; a < MAXFLOORS; ++a) {
506 flbuf = CtdlGetCachedFloor(a);
508 /* check to see if it already exists */
509 if ((!strcasecmp(flbuf->f_name, floor_name))
510 && (flbuf->f_flags & F_INUSE)) {
519 * CtdlGetFloorByNameLock() - retrieve floor number for given floor and lock the floor list.
521 int CtdlGetFloorByNameLock(const char *floor_name)
523 begin_critical_section(S_FLOORTAB);
524 return CtdlGetFloorByName(floor_name);
530 * CtdlGetAvailableFloor() - Return number of first unused floor
531 * return < 0 if none available
533 int CtdlGetAvailableFloor(void)
536 struct floor *flbuf = NULL;
538 for (a = 0; a < MAXFLOORS; a++) {
539 flbuf = CtdlGetCachedFloor(a);
541 /* check to see if it already exists */
542 if ((flbuf->f_flags & F_INUSE) == 0) {
551 * CtdlGetFloor() - retrieve floor data from disk
553 void CtdlGetFloor(struct floor *flbuf, int floor_num)
555 struct cdbdata *cdbfl;
557 memset(flbuf, 0, sizeof(struct floor));
558 cdbfl = cdb_fetch(CDB_FLOORTAB, &floor_num, sizeof(int));
560 memcpy(flbuf, cdbfl->ptr,
561 ((cdbfl->len > sizeof(struct floor)) ?
562 sizeof(struct floor) : cdbfl->len));
565 if (floor_num == 0) {
566 safestrncpy(flbuf->f_name, "Main Floor",
567 sizeof flbuf->f_name);
568 flbuf->f_flags = F_INUSE;
569 flbuf->f_ref_count = 3;
577 * lgetfloor() - same as CtdlGetFloor() but locks the record (if supported)
579 void lgetfloor(struct floor *flbuf, int floor_num)
582 begin_critical_section(S_FLOORTAB);
583 CtdlGetFloor(flbuf, floor_num);
588 * CtdlGetCachedFloor() - Get floor record from *cache* (loads from disk if needed)
590 * This is strictly a performance hack.
592 struct floor *CtdlGetCachedFloor(int floor_num) {
593 static int initialized = 0;
596 struct floor *fl = NULL;
598 begin_critical_section(S_FLOORCACHE);
599 if (initialized == 0) {
600 for (i=0; i<MAXFLOORS; ++i) {
601 floorcache[floor_num] = NULL;
605 if (floorcache[floor_num] == NULL) {
608 end_critical_section(S_FLOORCACHE);
611 fl = malloc(sizeof(struct floor));
612 CtdlGetFloor(fl, floor_num);
613 begin_critical_section(S_FLOORCACHE);
614 if (floorcache[floor_num] != NULL) {
615 free(floorcache[floor_num]);
617 floorcache[floor_num] = fl;
618 end_critical_section(S_FLOORCACHE);
621 return(floorcache[floor_num]);
626 * CtdlPutFloor() - store floor data on disk
628 void CtdlPutFloor(struct floor *flbuf, int floor_num)
630 /* If we've cached this, clear it out, 'cuz it's WRONG now! */
631 begin_critical_section(S_FLOORCACHE);
632 if (floorcache[floor_num] != NULL) {
633 free(floorcache[floor_num]);
634 floorcache[floor_num] = malloc(sizeof(struct floor));
635 memcpy(floorcache[floor_num], flbuf, sizeof(struct floor));
637 end_critical_section(S_FLOORCACHE);
639 cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
640 flbuf, sizeof(struct floor));
645 * CtdlPutFloorLock() - same as CtdlPutFloor() but unlocks the record (if supported)
647 void CtdlPutFloorLock(struct floor *flbuf, int floor_num)
650 CtdlPutFloor(flbuf, floor_num);
651 end_critical_section(S_FLOORTAB);
657 * lputfloor() - same as CtdlPutFloor() but unlocks the record (if supported)
659 void lputfloor(struct floor *flbuf, int floor_num)
661 CtdlPutFloorLock(flbuf, floor_num);
666 * Traverse the room file...
668 void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data)
670 struct ctdlroom qrbuf;
671 struct cdbdata *cdbqr;
673 cdb_rewind(CDB_ROOMS);
675 while (cdbqr = cdb_next_item(CDB_ROOMS), cdbqr != NULL) {
676 memset(&qrbuf, 0, sizeof(struct ctdlroom));
677 memcpy(&qrbuf, cdbqr->ptr,
678 ((cdbqr->len > sizeof(struct ctdlroom)) ?
679 sizeof(struct ctdlroom) : cdbqr->len)
682 room_sanity_check(&qrbuf);
683 if (qrbuf.QRflags & QR_INUSE) {
690 * Traverse the room file...
692 void CtdlForEachNetCfgRoom(ForEachRoomNetCfgCallBack CB,
696 struct ctdlroom qrbuf;
697 struct cdbdata *cdbqr;
699 cdb_rewind(CDB_ROOMS);
701 while (cdbqr = cdb_next_item(CDB_ROOMS), cdbqr != NULL) {
702 memset(&qrbuf, 0, sizeof(struct ctdlroom));
703 memcpy(&qrbuf, cdbqr->ptr,
704 ((cdbqr->len > sizeof(struct ctdlroom)) ?
705 sizeof(struct ctdlroom) : cdbqr->len)
708 room_sanity_check(&qrbuf);
709 if (qrbuf.QRflags & QR_INUSE)
711 OneRoomNetCfg* RNCfg;
712 RNCfg = CtdlGetNetCfgForRoom(qrbuf.QRnumber);
713 if ((RNCfg != NULL) &&
714 ((filter == maxRoomNetCfg) ||
715 (RNCfg->NetConfigs[filter] != NULL)))
717 CB(&qrbuf, in_data, RNCfg);
725 * delete_msglist() - delete room message pointers
727 void delete_msglist(struct ctdlroom *whichroom)
729 struct cdbdata *cdbml;
731 /* Make sure the msglist we're deleting actually exists, otherwise
732 * libdb will complain when we try to delete an invalid record
734 cdbml = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
738 /* Go ahead and delete it */
739 cdb_delete(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
745 * Message pointer compare function for sort_msglist()
747 int sort_msglist_cmp(const void *m1, const void *m2) {
748 if ((*(const long *)m1) > (*(const long *)m2)) return(1);
749 if ((*(const long *)m1) < (*(const long *)m2)) return(-1);
755 * sort message pointers
756 * (returns new msg count)
758 int sort_msglist(long listptrs[], int oldcount)
769 qsort(listptrs, numitems, sizeof(long), sort_msglist_cmp);
771 /* and yank any nulls */
772 while ((i < numitems) && (listptrs[i] == 0L)) i++;
776 memmove(&listptrs[0], &listptrs[i], (sizeof(long) * (numitems - i)));
785 * Determine whether a given room is non-editable.
787 int CtdlIsNonEditable(struct ctdlroom *qrbuf)
790 /* Mail> rooms are non-editable */
791 if ( (qrbuf->QRflags & QR_MAILBOX)
792 && (!strcasecmp(&qrbuf->QRname[11], MAILROOM)) )
795 /* Everything else is editable */
801 * Back-back-end for all room listing commands
803 void list_roomname(struct ctdlroom *qrbuf, int ra, int current_view, int default_view)
805 char truncated_roomname[ROOMNAMELEN];
807 /* For my own mailbox rooms, chop off the owner prefix */
808 if ( (qrbuf->QRflags & QR_MAILBOX)
809 && (atol(qrbuf->QRname) == CC->user.usernum) ) {
810 safestrncpy(truncated_roomname, qrbuf->QRname, sizeof truncated_roomname);
811 safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
812 cprintf("%s", truncated_roomname);
814 /* For all other rooms, just display the name in its entirety */
816 cprintf("%s", qrbuf->QRname);
819 /* ...and now the other parameters */
820 cprintf("|%u|%d|%d|%d|%d|%d|%d|%ld|\n",
822 (int) qrbuf->QRfloor,
823 (int) qrbuf->QRorder,
824 (int) qrbuf->QRflags2,
834 * cmd_lrms() - List all accessible rooms, known or forgotten
836 void cmd_lrms_backend(struct ctdlroom *qrbuf, void *data)
838 int FloorBeingSearched = (-1);
842 FloorBeingSearched = *(int *)data;
843 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
845 if ((( ra & (UA_KNOWN | UA_ZAPPED)))
846 && ((qrbuf->QRfloor == (FloorBeingSearched))
847 || ((FloorBeingSearched) < 0)))
848 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
851 void cmd_lrms(char *argbuf)
853 int FloorBeingSearched = (-1);
854 if (!IsEmptyStr(argbuf))
855 FloorBeingSearched = extract_int(argbuf, 0);
857 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
859 CtdlGetUser(&CC->user, CC->curr_user);
860 cprintf("%d Accessible rooms:\n", LISTING_FOLLOWS);
862 CtdlForEachRoom(cmd_lrms_backend, &FloorBeingSearched);
869 * cmd_lkra() - List all known rooms
871 void cmd_lkra_backend(struct ctdlroom *qrbuf, void *data)
873 int FloorBeingSearched = (-1);
877 FloorBeingSearched = *(int *)data;
878 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
880 if ((( ra & (UA_KNOWN)))
881 && ((qrbuf->QRfloor == (FloorBeingSearched))
882 || ((FloorBeingSearched) < 0)))
883 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
886 void cmd_lkra(char *argbuf)
888 int FloorBeingSearched = (-1);
889 if (!IsEmptyStr(argbuf))
890 FloorBeingSearched = extract_int(argbuf, 0);
892 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
894 CtdlGetUser(&CC->user, CC->curr_user);
895 cprintf("%d Known rooms:\n", LISTING_FOLLOWS);
897 CtdlForEachRoom(cmd_lkra_backend, &FloorBeingSearched);
903 void cmd_lprm_backend(struct ctdlroom *qrbuf, void *data)
905 int FloorBeingSearched = (-1);
909 FloorBeingSearched = *(int *)data;
910 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
912 if ( ((qrbuf->QRflags & QR_PRIVATE) == 0)
913 && ((qrbuf->QRflags & QR_MAILBOX) == 0)
914 && ((qrbuf->QRfloor == (FloorBeingSearched))
915 || ((FloorBeingSearched) < 0)))
916 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
919 void cmd_lprm(char *argbuf)
921 int FloorBeingSearched = (-1);
922 if (!IsEmptyStr(argbuf))
923 FloorBeingSearched = extract_int(argbuf, 0);
925 cprintf("%d Public rooms:\n", LISTING_FOLLOWS);
927 CtdlForEachRoom(cmd_lprm_backend, &FloorBeingSearched);
934 * cmd_lkrn() - List all known rooms with new messages
936 void cmd_lkrn_backend(struct ctdlroom *qrbuf, void *data)
938 int FloorBeingSearched = (-1);
942 FloorBeingSearched = *(int *)data;
943 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
946 && (ra & UA_HASNEWMSGS)
947 && ((qrbuf->QRfloor == (FloorBeingSearched))
948 || ((FloorBeingSearched) < 0)))
949 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
952 void cmd_lkrn(char *argbuf)
954 int FloorBeingSearched = (-1);
955 if (!IsEmptyStr(argbuf))
956 FloorBeingSearched = extract_int(argbuf, 0);
958 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
960 CtdlGetUser(&CC->user, CC->curr_user);
961 cprintf("%d Rooms w/ new msgs:\n", LISTING_FOLLOWS);
963 CtdlForEachRoom(cmd_lkrn_backend, &FloorBeingSearched);
970 * cmd_lkro() - List all known rooms
972 void cmd_lkro_backend(struct ctdlroom *qrbuf, void *data)
974 int FloorBeingSearched = (-1);
978 FloorBeingSearched = *(int *)data;
979 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
982 && ((ra & UA_HASNEWMSGS) == 0)
983 && ((qrbuf->QRfloor == (FloorBeingSearched))
984 || ((FloorBeingSearched) < 0)))
985 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
988 void cmd_lkro(char *argbuf)
990 int FloorBeingSearched = (-1);
991 if (!IsEmptyStr(argbuf))
992 FloorBeingSearched = extract_int(argbuf, 0);
994 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
996 CtdlGetUser(&CC->user, CC->curr_user);
997 cprintf("%d Rooms w/o new msgs:\n", LISTING_FOLLOWS);
999 CtdlForEachRoom(cmd_lkro_backend, &FloorBeingSearched);
1006 * cmd_lzrm() - List all forgotten rooms
1008 void cmd_lzrm_backend(struct ctdlroom *qrbuf, void *data)
1010 int FloorBeingSearched = (-1);
1014 FloorBeingSearched = *(int *)data;
1015 CtdlRoomAccess(qrbuf, &CC->user, &ra, &view);
1017 if ((ra & UA_GOTOALLOWED)
1019 && ((qrbuf->QRfloor == (FloorBeingSearched))
1020 || ((FloorBeingSearched) < 0)))
1021 list_roomname(qrbuf, ra, view, qrbuf->QRdefaultview);
1024 void cmd_lzrm(char *argbuf)
1026 int FloorBeingSearched = (-1);
1027 if (!IsEmptyStr(argbuf))
1028 FloorBeingSearched = extract_int(argbuf, 0);
1030 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
1032 CtdlGetUser(&CC->user, CC->curr_user);
1033 cprintf("%d Zapped rooms:\n", LISTING_FOLLOWS);
1035 CtdlForEachRoom(cmd_lzrm_backend, &FloorBeingSearched);
1041 * Make the specified room the current room for this session. No validation
1042 * or access control is done here -- the caller should make sure that the
1043 * specified room exists and is ok to access.
1045 void CtdlUserGoto(char *where, int display_result, int transiently,
1046 int *retmsgs, int *retnew)
1048 struct CitContext *CCC = CC;
1050 int new_messages = 0;
1051 int old_messages = 0;
1052 int total_messages = 0;
1056 int newmailcount = 0;
1058 char truncated_roomname[ROOMNAMELEN];
1059 struct cdbdata *cdbfr;
1060 long *msglist = NULL;
1062 unsigned int original_v_flags;
1065 char setstr[128], lostr[64], histr[64];
1069 /* If the supplied room name is NULL, the caller wants us to know that
1070 * it has already copied the room record into CC->room, so
1071 * we can skip the extra database fetch.
1073 if (where != NULL) {
1074 safestrncpy(CCC->room.QRname, where, sizeof CCC->room.QRname);
1075 CtdlGetRoom(&CCC->room, where);
1078 /* Take care of all the formalities. */
1080 begin_critical_section(S_USERS);
1081 CtdlGetRelationship(&vbuf, &CCC->user, &CCC->room);
1082 original_v_flags = vbuf.v_flags;
1084 /* Know the room ... but not if it's the page log room, or if the
1085 * caller specified that we're only entering this room transiently.
1087 if ((strcasecmp(CCC->room.QRname, config.c_logpages))
1088 && (transiently == 0) ) {
1089 vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
1090 vbuf.v_flags = vbuf.v_flags | V_ACCESS;
1093 /* Only rewrite the database record if we changed something */
1094 if (vbuf.v_flags != original_v_flags) {
1095 CtdlSetRelationship(&vbuf, &CCC->user, &CCC->room);
1097 end_critical_section(S_USERS);
1099 /* Check for new mail */
1100 newmailcount = NewMailCount();
1102 /* set info to 1 if the user needs to read the room's info file */
1103 if (CCC->room.QRinfo > vbuf.v_lastseen) {
1107 cdbfr = cdb_fetch(CDB_MSGLISTS, &CCC->room.QRnumber, sizeof(long));
1108 if (cdbfr != NULL) {
1109 msglist = (long *) cdbfr->ptr;
1110 cdbfr->ptr = NULL; /* CtdlUserGoto() now owns this memory */
1111 num_msgs = cdbfr->len / sizeof(long);
1116 for (a=0; a<num_msgs; ++a) {
1117 if (msglist[a] > 0L) ++total_messages;
1120 num_sets = num_tokens(vbuf.v_seen, ',');
1121 for (s=0; s<num_sets; ++s) {
1122 extract_token(setstr, vbuf.v_seen, s, ',', sizeof setstr);
1124 extract_token(lostr, setstr, 0, ':', sizeof lostr);
1125 if (num_tokens(setstr, ':') >= 2) {
1126 extract_token(histr, setstr, 1, ':', sizeof histr);
1127 if (!strcmp(histr, "*")) {
1128 snprintf(histr, sizeof histr, "%ld", LONG_MAX);
1132 strcpy(histr, lostr);
1137 for (a=0; a<num_msgs; ++a) if (msglist[a] > 0L) {
1138 if ((msglist[a] >= lo) && (msglist[a] <= hi)) {
1144 new_messages = total_messages - old_messages;
1146 if (msglist != NULL) free(msglist);
1148 if (CCC->room.QRflags & QR_MAILBOX)
1153 if ((CCC->room.QRroomaide == CCC->user.usernum)
1154 || (CCC->user.axlevel >= AxAideU))
1159 safestrncpy(truncated_roomname, CCC->room.QRname, sizeof truncated_roomname);
1160 if ( (CCC->room.QRflags & QR_MAILBOX)
1161 && (atol(CCC->room.QRname) == CCC->user.usernum) ) {
1162 safestrncpy(truncated_roomname, &truncated_roomname[11], sizeof truncated_roomname);
1165 if (!strcasecmp(truncated_roomname, USERTRASHROOM)) {
1169 if (retmsgs != NULL) *retmsgs = total_messages;
1170 if (retnew != NULL) *retnew = new_messages;
1171 MSG_syslog(LOG_INFO, "<%s> %d new of %d total messages\n",
1173 new_messages, total_messages
1176 CCC->curr_view = (int)vbuf.v_view;
1178 if (display_result) {
1179 cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|%d|%d|%ld|\n",
1180 CIT_OK, CtdlCheckExpress(),
1183 (int)total_messages,
1185 (int)CCC->room.QRflags,
1186 (long)CCC->room.QRhighest,
1187 (long)vbuf.v_lastseen,
1191 (int)CCC->room.QRfloor,
1193 (int)CCC->room.QRdefaultview,
1195 (int)CCC->room.QRflags2,
1196 (long)CCC->room.QRmtime
1203 * Handle some of the macro named rooms
1205 void convert_room_name_macros(char *towhere, size_t maxlen) {
1206 if (!strcasecmp(towhere, "_BASEROOM_")) {
1207 safestrncpy(towhere, config.c_baseroom, maxlen);
1209 else if (!strcasecmp(towhere, "_MAIL_")) {
1210 safestrncpy(towhere, MAILROOM, maxlen);
1212 else if (!strcasecmp(towhere, "_TRASH_")) {
1213 safestrncpy(towhere, USERTRASHROOM, maxlen);
1215 else if (!strcasecmp(towhere, "_DRAFTS_")) {
1216 safestrncpy(towhere, USERDRAFTROOM, maxlen);
1218 else if (!strcasecmp(towhere, "_BITBUCKET_")) {
1219 safestrncpy(towhere, config.c_twitroom, maxlen);
1221 else if (!strcasecmp(towhere, "_CALENDAR_")) {
1222 safestrncpy(towhere, USERCALENDARROOM, maxlen);
1224 else if (!strcasecmp(towhere, "_TASKS_")) {
1225 safestrncpy(towhere, USERTASKSROOM, maxlen);
1227 else if (!strcasecmp(towhere, "_CONTACTS_")) {
1228 safestrncpy(towhere, USERCONTACTSROOM, maxlen);
1230 else if (!strcasecmp(towhere, "_NOTES_")) {
1231 safestrncpy(towhere, USERNOTESROOM, maxlen);
1237 * cmd_goto() - goto a new room
1239 void cmd_goto(char *gargs)
1241 struct ctdlroom QRscratch;
1245 char augmented_roomname[ROOMNAMELEN];
1246 char towhere[ROOMNAMELEN];
1248 int transiently = 0;
1250 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
1252 extract_token(towhere, gargs, 0, '|', sizeof towhere);
1253 extract_token(password, gargs, 1, '|', sizeof password);
1254 transiently = extract_int(gargs, 2);
1256 CtdlGetUser(&CC->user, CC->curr_user);
1259 * Handle some of the macro named rooms
1261 convert_room_name_macros(towhere, sizeof towhere);
1263 /* First try a regular match */
1264 c = CtdlGetRoom(&QRscratch, towhere);
1266 /* Then try a mailbox name match */
1268 CtdlMailboxName(augmented_roomname, sizeof augmented_roomname,
1269 &CC->user, towhere);
1270 c = CtdlGetRoom(&QRscratch, augmented_roomname);
1272 safestrncpy(towhere, augmented_roomname, sizeof towhere);
1275 /* And if the room was found... */
1278 /* Let internal programs go directly to any room. */
1279 if (CC->internal_pgm) {
1280 memcpy(&CC->room, &QRscratch,
1281 sizeof(struct ctdlroom));
1282 CtdlUserGoto(NULL, 1, transiently, NULL, NULL);
1286 /* See if there is an existing user/room relationship */
1287 CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL);
1289 /* normal clients have to pass through security */
1290 if (ra & UA_GOTOALLOWED) {
1295 if ((QRscratch.QRflags & QR_MAILBOX) &&
1296 ((ra & UA_GOTOALLOWED))) {
1297 memcpy(&CC->room, &QRscratch,
1298 sizeof(struct ctdlroom));
1299 CtdlUserGoto(NULL, 1, transiently, NULL, NULL);
1301 } else if ((QRscratch.QRflags & QR_PASSWORDED) &&
1302 ((ra & UA_KNOWN) == 0) &&
1303 (strcasecmp(QRscratch.QRpasswd, password)) &&
1304 (CC->user.axlevel < AxAideU)
1306 cprintf("%d wrong or missing passwd\n",
1307 ERROR + PASSWORD_REQUIRED);
1309 } else if ((QRscratch.QRflags & QR_PRIVATE) &&
1310 ((QRscratch.QRflags & QR_PASSWORDED) == 0) &&
1311 ((QRscratch.QRflags & QR_GUESSNAME) == 0) &&
1312 ((ra & UA_KNOWN) == 0) &&
1313 (CC->user.axlevel < AxAideU)
1315 syslog(LOG_DEBUG, "Failed to acquire private room\n");
1317 memcpy(&CC->room, &QRscratch,
1318 sizeof(struct ctdlroom));
1319 CtdlUserGoto(NULL, 1, transiently, NULL, NULL);
1325 cprintf("%d room '%s' not found\n", ERROR + ROOM_NOT_FOUND, towhere);
1329 void cmd_whok(char *cmdbuf)
1331 struct ctdluser temp;
1332 struct cdbdata *cdbus;
1335 cprintf("%d Who knows room:\n", LISTING_FOLLOWS);
1336 cdb_rewind(CDB_USERS);
1337 while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
1338 memset(&temp, 0, sizeof temp);
1339 memcpy(&temp, cdbus->ptr, sizeof temp);
1342 CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
1343 if ((!IsEmptyStr(temp.fullname)) &&
1344 (CC->room.QRflags & QR_INUSE) &&
1347 cprintf("%s\n", temp.fullname);
1354 * RDIR command for room directory
1356 void cmd_rdir(char *cmdbuf)
1361 struct stat statbuf;
1362 DIR *filedir = NULL;
1363 struct dirent *filedir_entry;
1369 if (CtdlAccessCheck(ac_logged_in)) return;
1371 CtdlGetRoom(&CC->room, CC->room.QRname);
1372 CtdlGetUser(&CC->user, CC->curr_user);
1374 if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
1375 cprintf("%d not here.\n", ERROR + NOT_HERE);
1378 if (((CC->room.QRflags & QR_VISDIR) == 0)
1379 && (CC->user.axlevel < AxAideU)
1380 && (CC->user.usernum != CC->room.QRroomaide)) {
1381 cprintf("%d not here.\n", ERROR + HIGHER_ACCESS_REQUIRED);
1385 snprintf(buf, sizeof buf, "%s/%s", ctdl_file_dir, CC->room.QRdirname);
1386 filedir = opendir (buf);
1388 if (filedir == NULL) {
1389 cprintf("%d not here.\n", ERROR + HIGHER_ACCESS_REQUIRED);
1392 cprintf("%d %s|%s/%s\n", LISTING_FOLLOWS, config.c_fqdn, ctdl_file_dir, CC->room.QRdirname);
1394 snprintf(buf, sizeof buf, "%s/%s/filedir", ctdl_file_dir, CC->room.QRdirname);
1395 fd = fopen(buf, "r");
1397 fd = fopen("/dev/null", "r");
1398 while ((filedir_entry = readdir(filedir)))
1400 if (strcasecmp(filedir_entry->d_name, "filedir") && filedir_entry->d_name[0] != '.')
1402 #ifdef _DIRENT_HAVE_D_NAMELEN
1403 d_namelen = filedir_entry->d_namelen;
1405 d_namelen = strlen(filedir_entry->d_name);
1407 snprintf(buf, sizeof buf, "%s/%s/%s", ctdl_file_dir, CC->room.QRdirname, filedir_entry->d_name);
1408 stat(buf, &statbuf); /* stat the file */
1409 if (!(statbuf.st_mode & S_IFREG))
1411 snprintf(buf2, sizeof buf2,
1412 "\"%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",
1413 buf, CC->room.QRname
1415 CtdlAideMessage(buf2, "Unusable data found in room directory");
1416 continue; /* not a useable file type so don't show it */
1418 safestrncpy(comment, "", sizeof comment);
1419 fseek(fd, 0L, 0); /* rewind descriptions file */
1420 /* Get the description from the descriptions file */
1421 while ((fgets(buf, sizeof buf, fd) != NULL) && (IsEmptyStr(comment)))
1423 buf[strlen(buf) - 1] = 0;
1424 if ((!strncasecmp(buf, filedir_entry->d_name, d_namelen)) && (buf[d_namelen] == ' '))
1425 safestrncpy(comment, &buf[d_namelen + 1], sizeof comment);
1427 len = extract_token (mimebuf, comment, 0,' ', 64);
1428 if ((len <0) || strchr(mimebuf, '/') == NULL)
1430 snprintf (mimebuf, 64, "application/octetstream");
1433 cprintf("%s|%ld|%s|%s\n",
1434 filedir_entry->d_name,
1435 (long)statbuf.st_size,
1447 * get room parameters (admin or room admin command)
1449 void cmd_getr(char *cmdbuf)
1451 if (CtdlAccessCheck(ac_room_aide)) return;
1453 CtdlGetRoom(&CC->room, CC->room.QRname);
1454 cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n",
1458 ((CC->room.QRflags & QR_MAILBOX) ?
1459 &CC->room.QRname[11] : CC->room.QRname),
1461 ((CC->room.QRflags & QR_PASSWORDED) ?
1462 CC->room.QRpasswd : ""),
1464 ((CC->room.QRflags & QR_DIRECTORY) ?
1465 CC->room.QRdirname : ""),
1468 (int) CC->room.QRfloor,
1469 (int) CC->room.QRorder,
1471 CC->room.QRdefaultview,
1478 * Back end function to rename a room.
1479 * You can also specify which floor to move the room to, or specify -1 to
1480 * keep the room on the same floor it was on.
1482 * If you are renaming a mailbox room, you must supply the namespace prefix
1483 * in *at least* the old name!
1485 int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
1487 struct ctdlroom qrbuf;
1488 struct ctdlroom qrtmp;
1493 char actual_old_name[ROOMNAMELEN];
1495 syslog(LOG_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
1496 old_name, new_name, new_floor);
1498 if (new_floor >= 0) {
1499 fl = CtdlGetCachedFloor(new_floor);
1500 if ((fl->f_flags & F_INUSE) == 0) {
1501 return(crr_invalid_floor);
1505 begin_critical_section(S_ROOMS);
1507 if ( (CtdlGetRoom(&qrtmp, new_name) == 0)
1508 && (strcasecmp(new_name, old_name)) ) {
1509 ret = crr_already_exists;
1512 else if (CtdlGetRoom(&qrbuf, old_name) != 0) {
1513 ret = crr_room_not_found;
1516 else if ( (CC->user.axlevel < AxAideU) && (!CC->internal_pgm)
1517 && (CC->user.usernum != qrbuf.QRroomaide)
1518 && ( (((qrbuf.QRflags & QR_MAILBOX) == 0) || (atol(qrbuf.QRname) != CC->user.usernum))) ) {
1519 ret = crr_access_denied;
1522 else if (CtdlIsNonEditable(&qrbuf)) {
1523 ret = crr_noneditable;
1528 safestrncpy(actual_old_name, qrbuf.QRname, sizeof actual_old_name);
1529 if (qrbuf.QRflags & QR_MAILBOX) {
1530 owner = atol(qrbuf.QRname);
1532 if ( (owner > 0L) && (atol(new_name) == 0L) ) {
1533 snprintf(qrbuf.QRname, sizeof(qrbuf.QRname),
1534 "%010ld.%s", owner, new_name);
1537 safestrncpy(qrbuf.QRname, new_name,
1538 sizeof(qrbuf.QRname));
1541 /* Reject change of floor for baseroom/aideroom */
1542 if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN) ||
1543 !strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
1547 /* Take care of floor stuff */
1548 old_floor = qrbuf.QRfloor;
1549 if (new_floor < 0) {
1550 new_floor = old_floor;
1552 qrbuf.QRfloor = new_floor;
1553 CtdlPutRoom(&qrbuf);
1555 begin_critical_section(S_CONFIG);
1557 /* If baseroom/aideroom name changes, update config */
1558 if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN)) {
1559 safestrncpy(config.c_baseroom, new_name, ROOMNAMELEN);
1562 if (!strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
1563 safestrncpy(config.c_aideroom, new_name, ROOMNAMELEN);
1567 end_critical_section(S_CONFIG);
1569 /* If the room name changed, then there are now two room
1570 * records, so we have to delete the old one.
1572 if (strcasecmp(new_name, old_name)) {
1573 b_deleteroom(actual_old_name);
1579 end_critical_section(S_ROOMS);
1581 /* Adjust the floor reference counts if necessary */
1582 if (new_floor != old_floor) {
1583 lgetfloor(&flbuf, old_floor);
1584 --flbuf.f_ref_count;
1585 lputfloor(&flbuf, old_floor);
1586 syslog(LOG_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
1587 lgetfloor(&flbuf, new_floor);
1588 ++flbuf.f_ref_count;
1589 lputfloor(&flbuf, new_floor);
1590 syslog(LOG_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
1593 /* ...and everybody say "YATTA!" */
1599 * set room parameters (admin or room admin command)
1601 void cmd_setr(char *args)
1607 char new_name[ROOMNAMELEN];
1609 if (CtdlAccessCheck(ac_logged_in)) return;
1611 if (num_parms(args) >= 6) {
1612 new_floor = extract_int(args, 5);
1614 new_floor = (-1); /* don't change the floor */
1617 /* When is a new name more than just a new name? When the old name
1618 * has a namespace prefix.
1620 if (CC->room.QRflags & QR_MAILBOX) {
1621 sprintf(new_name, "%010ld.", atol(CC->room.QRname) );
1623 safestrncpy(new_name, "", sizeof new_name);
1625 extract_token(&new_name[strlen(new_name)], args, 0, '|', (sizeof new_name - strlen(new_name)));
1627 r = CtdlRenameRoom(CC->room.QRname, new_name, new_floor);
1629 if (r == crr_room_not_found) {
1630 cprintf("%d Internal error - room not found?\n", ERROR + INTERNAL_ERROR);
1631 } else if (r == crr_already_exists) {
1632 cprintf("%d '%s' already exists.\n",
1633 ERROR + ALREADY_EXISTS, new_name);
1634 } else if (r == crr_noneditable) {
1635 cprintf("%d Cannot edit this room.\n", ERROR + NOT_HERE);
1636 } else if (r == crr_invalid_floor) {
1637 cprintf("%d Target floor does not exist.\n",
1638 ERROR + INVALID_FLOOR_OPERATION);
1639 } else if (r == crr_access_denied) {
1640 cprintf("%d You do not have permission to edit '%s'\n",
1641 ERROR + HIGHER_ACCESS_REQUIRED,
1643 } else if (r != crr_ok) {
1644 cprintf("%d Error: CtdlRenameRoom() returned %d\n",
1645 ERROR + INTERNAL_ERROR, r);
1652 CtdlGetRoom(&CC->room, new_name);
1654 /* Now we have to do a bunch of other stuff */
1656 if (num_parms(args) >= 7) {
1657 new_order = extract_int(args, 6);
1660 if (new_order > 127)
1664 CtdlGetRoomLock(&CC->room, CC->room.QRname);
1666 /* Directory room */
1667 extract_token(buf, args, 2, '|', sizeof buf);
1669 safestrncpy(CC->room.QRdirname, buf,
1670 sizeof CC->room.QRdirname);
1673 if (num_parms(args) >= 8) {
1674 CC->room.QRdefaultview = extract_int(args, 7);
1677 /* Second set of flags */
1678 if (num_parms(args) >= 9) {
1679 CC->room.QRflags2 = extract_int(args, 8);
1683 CC->room.QRflags = (extract_int(args, 3) | QR_INUSE);
1684 /* Clean up a client boo-boo: if the client set the room to
1685 * guess-name or passworded, ensure that the private flag is
1688 if ((CC->room.QRflags & QR_GUESSNAME)
1689 || (CC->room.QRflags & QR_PASSWORDED))
1690 CC->room.QRflags |= QR_PRIVATE;
1692 /* Some changes can't apply to BASEROOM */
1693 if (!strncasecmp(CC->room.QRname, config.c_baseroom,
1695 CC->room.QRorder = 0;
1696 CC->room.QRpasswd[0] = '\0';
1697 CC->room.QRflags &= ~(QR_PRIVATE & QR_PASSWORDED &
1698 QR_GUESSNAME & QR_PREFONLY & QR_MAILBOX);
1699 CC->room.QRflags |= QR_PERMANENT;
1701 /* March order (doesn't apply to AIDEROOM) */
1702 if (num_parms(args) >= 7)
1703 CC->room.QRorder = (char) new_order;
1705 extract_token(buf, args, 1, '|', sizeof buf);
1707 safestrncpy(CC->room.QRpasswd, buf,
1708 sizeof CC->room.QRpasswd);
1709 /* Kick everyone out if the client requested it
1710 * (by changing the room's generation number)
1712 if (extract_int(args, 4)) {
1713 time(&CC->room.QRgen);
1716 /* Some changes can't apply to AIDEROOM */
1717 if (!strncasecmp(CC->room.QRname, config.c_baseroom,
1719 CC->room.QRorder = 0;
1720 CC->room.QRflags &= ~QR_MAILBOX;
1721 CC->room.QRflags |= QR_PERMANENT;
1724 /* Write the room record back to disk */
1725 CtdlPutRoomLock(&CC->room);
1727 /* Create a room directory if necessary */
1728 if (CC->room.QRflags & QR_DIRECTORY) {
1729 snprintf(buf, sizeof buf,"%s/%s",
1731 CC->room.QRdirname);
1734 snprintf(buf, sizeof buf, "The room \"%s\" has been edited by %s.\n",
1736 (CC->logged_in ? CC->curr_user : "an administrator")
1738 CtdlAideMessage(buf, "Room modification Message");
1739 cprintf("%d Ok\n", CIT_OK);
1745 * get the name of the room admin for this room
1747 void cmd_geta(char *cmdbuf)
1749 struct ctdluser usbuf;
1751 if (CtdlAccessCheck(ac_logged_in)) return;
1753 if (CtdlGetUserByNumber(&usbuf, CC->room.QRroomaide) == 0) {
1754 cprintf("%d %s\n", CIT_OK, usbuf.fullname);
1756 cprintf("%d \n", CIT_OK);
1762 * set the room admin for this room
1764 void cmd_seta(char *new_ra)
1766 struct ctdluser usbuf;
1771 if (CtdlAccessCheck(ac_room_aide)) return;
1773 if (CtdlGetUser(&usbuf, new_ra) != 0) {
1776 newu = usbuf.usernum;
1779 CtdlGetRoomLock(&CC->room, CC->room.QRname);
1781 if (CC->room.QRroomaide != newu) {
1784 CC->room.QRroomaide = newu;
1785 CtdlPutRoomLock(&CC->room);
1788 * We have to post the change notice _after_ writing changes to
1789 * the room table, otherwise it would deadlock!
1791 if (post_notice == 1) {
1792 if (!IsEmptyStr(usbuf.fullname))
1793 snprintf(buf, sizeof buf,
1794 "%s is now the room admin for \"%s\".\n",
1795 usbuf.fullname, CC->room.QRname);
1797 snprintf(buf, sizeof buf,
1798 "There is now no room admin for \"%s\".\n",
1800 CtdlAideMessage(buf, "Admin Room Modification");
1802 cprintf("%d Ok\n", CIT_OK);
1806 * retrieve info file for this room
1808 void cmd_rinf(char *gargs)
1810 char filename[PATH_MAX];
1814 assoc_file_name(filename, sizeof filename, &CC->room, ctdl_info_dir);
1815 info_fp = fopen(filename, "r");
1817 if (info_fp == NULL) {
1818 cprintf("%d No info file.\n", ERROR + FILE_NOT_FOUND);
1821 cprintf("%d Info:\n", LISTING_FOLLOWS);
1822 while (fgets(buf, sizeof buf, info_fp) != NULL) {
1823 if (!IsEmptyStr(buf))
1824 buf[strlen(buf) - 1] = 0;
1825 cprintf("%s\n", buf);
1832 * Asynchronously schedule a room for deletion. The room will appear
1833 * deleted to the user(s), but it won't actually get purged from the
1834 * database until THE DREADED AUTO-PURGER makes its next run.
1836 void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf)
1838 char old_name[ROOMNAMELEN];
1841 syslog(LOG_NOTICE, "Scheduling room <%s> for deletion\n",
1844 safestrncpy(old_name, qrbuf->QRname, sizeof old_name);
1846 CtdlGetRoom(qrbuf, qrbuf->QRname);
1848 /* Turn the room into a private mailbox owned by a user who doesn't
1849 * exist. This will immediately make the room invisible to everyone,
1850 * and qualify the room for purging.
1852 snprintf(qrbuf->QRname, sizeof qrbuf->QRname, "9999999999.%08lx.%04d.%s",
1857 qrbuf->QRflags |= QR_MAILBOX;
1858 time(&qrbuf->QRgen); /* Use a timestamp as the new generation number */
1862 b_deleteroom(old_name);
1868 * Back end processing to delete a room and everything associated with it
1869 * (This one is synchronous and should only get called by THE DREADED
1870 * AUTO-PURGER in serv_expire.c. All user-facing code should call
1871 * the asynchronous schedule_room_for_deletion() instead.)
1873 void CtdlDeleteRoom(struct ctdlroom *qrbuf)
1877 /* TODO: filename magic? does this realy work? */
1879 syslog(LOG_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
1881 /* Delete the info file */
1882 assoc_file_name(filename, sizeof filename, qrbuf, ctdl_info_dir);
1885 /* Delete the image file */
1886 assoc_file_name(filename, sizeof filename, qrbuf, ctdl_image_dir);
1889 /* Delete the room's network config file */
1890 assoc_file_name(filename, sizeof filename, qrbuf, ctdl_netcfg_dir);
1893 /* Delete the messages in the room
1894 * (Careful: this opens an S_ROOMS critical section!)
1896 CtdlDeleteMessages(qrbuf->QRname, NULL, 0, "");
1898 /* Flag the room record as not in use */
1899 CtdlGetRoomLock(qrbuf, qrbuf->QRname);
1901 CtdlPutRoomLock(qrbuf);
1903 /* then decrement the reference count for the floor */
1904 lgetfloor(&flbuf, (int) (qrbuf->QRfloor));
1905 flbuf.f_ref_count = flbuf.f_ref_count - 1;
1906 lputfloor(&flbuf, (int) (qrbuf->QRfloor));
1908 /* Delete the room record from the database! */
1909 b_deleteroom(qrbuf->QRname);
1915 * Check access control for deleting a room
1917 int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr) {
1919 if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
1923 if (CtdlIsNonEditable(qr)) {
1928 * For mailboxes, check stuff
1930 if (qr->QRflags & QR_MAILBOX) {
1932 if (strlen(qr->QRname) < 12) return(0); /* bad name */
1934 if (atol(qr->QRname) != CC->user.usernum) {
1935 return(0); /* not my room */
1938 /* Can't delete your Mail> room */
1939 if (!strcasecmp(&qr->QRname[11], MAILROOM)) return(0);
1941 /* Otherwise it's ok */
1946 * For normal rooms, just check for admin or room admin status.
1948 return(is_room_aide());
1952 * admin command: kill the current room
1954 void cmd_kill(char *argbuf)
1956 char deleted_room_name[ROOMNAMELEN];
1960 kill_ok = extract_int(argbuf, 0);
1962 if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->room) == 0) {
1963 cprintf("%d Can't delete this room.\n", ERROR + NOT_HERE);
1967 if (CC->room.QRflags & QR_MAILBOX) {
1968 safestrncpy(deleted_room_name, &CC->room.QRname[11], sizeof deleted_room_name);
1971 safestrncpy(deleted_room_name, CC->room.QRname, sizeof deleted_room_name);
1974 /* Do the dirty work */
1975 CtdlScheduleRoomForDeletion(&CC->room);
1977 /* Return to the Lobby */
1978 CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
1980 /* tell the world what we did */
1981 snprintf(msg, sizeof msg, "The room \"%s\" has been deleted by %s.\n",
1983 (CC->logged_in ? CC->curr_user : "an administrator")
1985 CtdlAideMessage(msg, "Room Purger Message");
1986 cprintf("%d '%s' deleted.\n", CIT_OK, deleted_room_name);
1988 cprintf("%d ok to delete.\n", CIT_OK);
1994 * Internal code to create a new room (returns room flags)
1996 * Room types: 0=public, 1=hidden, 2=passworded, 3=invitation-only,
1997 * 4=mailbox, 5=mailbox, but caller supplies namespace
1999 unsigned CtdlCreateRoom(char *new_room_name,
2001 char *new_room_pass,
2008 struct ctdlroom qrbuf;
2012 syslog(LOG_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
2013 new_room_name, new_room_type, new_room_view);
2015 if (CtdlGetRoom(&qrbuf, new_room_name) == 0) {
2016 syslog(LOG_DEBUG, "%s already exists.\n", new_room_name);
2020 memset(&qrbuf, 0, sizeof(struct ctdlroom));
2021 safestrncpy(qrbuf.QRpasswd, new_room_pass, sizeof qrbuf.QRpasswd);
2022 qrbuf.QRflags = QR_INUSE;
2023 if (new_room_type > 0)
2024 qrbuf.QRflags = (qrbuf.QRflags | QR_PRIVATE);
2025 if (new_room_type == 1)
2026 qrbuf.QRflags = (qrbuf.QRflags | QR_GUESSNAME);
2027 if (new_room_type == 2)
2028 qrbuf.QRflags = (qrbuf.QRflags | QR_PASSWORDED);
2029 if ( (new_room_type == 4) || (new_room_type == 5) ) {
2030 qrbuf.QRflags = (qrbuf.QRflags | QR_MAILBOX);
2031 /* qrbuf.QRflags2 |= QR2_SUBJECTREQ; */
2034 /* If the user is requesting a personal room, set up the room
2035 * name accordingly (prepend the user number)
2037 if (new_room_type == 4) {
2038 CtdlMailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->user, new_room_name);
2041 safestrncpy(qrbuf.QRname, new_room_name, sizeof qrbuf.QRname);
2044 /* If the room is private, and the system administrator has elected
2045 * to automatically grant room admin privileges, do so now.
2047 if ((qrbuf.QRflags & QR_PRIVATE) && (CREATAIDE == 1)) {
2048 qrbuf.QRroomaide = CC->user.usernum;
2050 /* Blog owners automatically become room admins of their blogs.
2051 * (In the future we will offer a site-wide configuration setting to suppress this behavior.)
2053 else if (new_room_view == VIEW_BLOG) {
2054 qrbuf.QRroomaide = CC->user.usernum;
2056 /* Otherwise, set the room admin to undefined.
2059 qrbuf.QRroomaide = (-1L);
2063 * If the caller is only interested in testing whether this will work,
2064 * return now without creating the room.
2066 if (!really_create) return (qrbuf.QRflags);
2068 qrbuf.QRnumber = get_new_room_number();
2069 qrbuf.QRhighest = 0L; /* No messages in this room yet */
2070 time(&qrbuf.QRgen); /* Use a timestamp as the generation number */
2071 qrbuf.QRfloor = new_room_floor;
2072 qrbuf.QRdefaultview = new_room_view;
2074 /* save what we just did... */
2075 CtdlPutRoom(&qrbuf);
2077 /* bump the reference count on whatever floor the room is on */
2078 lgetfloor(&flbuf, (int) qrbuf.QRfloor);
2079 flbuf.f_ref_count = flbuf.f_ref_count + 1;
2080 lputfloor(&flbuf, (int) qrbuf.QRfloor);
2082 /* Grant the creator access to the room unless the avoid_access
2083 * parameter was specified.
2085 if ( (CC->logged_in) && (avoid_access == 0) ) {
2086 CtdlGetRelationship(&vbuf, &CC->user, &qrbuf);
2087 vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
2088 vbuf.v_flags = vbuf.v_flags | V_ACCESS;
2089 CtdlSetRelationship(&vbuf, &CC->user, &qrbuf);
2092 /* resume our happy day */
2093 return (qrbuf.QRflags);
2100 void cmd_cre8(char *args)
2103 char new_room_name[ROOMNAMELEN];
2105 char new_room_pass[32];
2108 char *notification_message = NULL;
2111 int avoid_access = 0;
2113 cre8_ok = extract_int(args, 0);
2114 extract_token(new_room_name, args, 1, '|', sizeof new_room_name);
2115 new_room_name[ROOMNAMELEN - 1] = 0;
2116 new_room_type = extract_int(args, 2);
2117 extract_token(new_room_pass, args, 3, '|', sizeof new_room_pass);
2118 avoid_access = extract_int(args, 5);
2119 new_room_view = extract_int(args, 6);
2120 new_room_pass[9] = 0;
2123 if ((IsEmptyStr(new_room_name)) && (cre8_ok == 1)) {
2124 cprintf("%d Invalid room name.\n", ERROR + ILLEGAL_VALUE);
2128 if (!strcasecmp(new_room_name, MAILROOM)) {
2129 cprintf("%d '%s' already exists.\n",
2130 ERROR + ALREADY_EXISTS, new_room_name);
2134 if (num_parms(args) >= 5) {
2135 fl = CtdlGetCachedFloor(extract_int(args, 4));
2137 cprintf("%d Invalid floor number.\n",
2138 ERROR + INVALID_FLOOR_OPERATION);
2141 else if ((fl->f_flags & F_INUSE) == 0) {
2142 cprintf("%d Invalid floor number.\n",
2143 ERROR + INVALID_FLOOR_OPERATION);
2146 new_room_floor = extract_int(args, 4);
2150 if (CtdlAccessCheck(ac_logged_in)) return;
2152 if (CC->user.axlevel < config.c_createax && !CC->internal_pgm) {
2153 cprintf("%d You need higher access to create rooms.\n",
2154 ERROR + HIGHER_ACCESS_REQUIRED);
2158 if ((IsEmptyStr(new_room_name)) && (cre8_ok == 0)) {
2159 cprintf("%d Ok to create rooms.\n", CIT_OK);
2163 if ((new_room_type < 0) || (new_room_type > 5)) {
2164 cprintf("%d Invalid room type.\n", ERROR + ILLEGAL_VALUE);
2168 if (new_room_type == 5) {
2169 if (CC->user.axlevel < AxAideU) {
2170 cprintf("%d Higher access required\n",
2171 ERROR + HIGHER_ACCESS_REQUIRED);
2176 /* Check to make sure the requested room name doesn't already exist */
2177 newflags = CtdlCreateRoom(new_room_name,
2178 new_room_type, new_room_pass, new_room_floor,
2179 0, avoid_access, new_room_view);
2180 if (newflags == 0) {
2181 cprintf("%d '%s' already exists.\n",
2182 ERROR + ALREADY_EXISTS, new_room_name);
2187 cprintf("%d OK to create '%s'\n", CIT_OK, new_room_name);
2191 /* If we reach this point, the room needs to be created. */
2193 newflags = CtdlCreateRoom(new_room_name,
2194 new_room_type, new_room_pass, new_room_floor, 1, 0,
2197 /* post a message in Aide> describing the new room */
2198 notification_message = malloc(1024);
2199 snprintf(notification_message, 1024,
2200 "A new room called \"%s\" has been created by %s%s%s%s%s%s\n",
2202 (CC->logged_in ? CC->curr_user : "an administrator"),
2203 ((newflags & QR_MAILBOX) ? " [personal]" : ""),
2204 ((newflags & QR_PRIVATE) ? " [private]" : ""),
2205 ((newflags & QR_GUESSNAME) ? " [hidden]" : ""),
2206 ((newflags & QR_PASSWORDED) ? " Password: " : ""),
2207 ((newflags & QR_PASSWORDED) ? new_room_pass : "")
2209 CtdlAideMessage(notification_message, "Room Creation Message");
2210 free(notification_message);
2212 cprintf("%d '%s' has been created.\n", CIT_OK, new_room_name);
2217 void cmd_einf(char *ok)
2218 { /* enter info file for current room */
2220 char infofilename[SIZ];
2225 if (CtdlAccessCheck(ac_room_aide)) return;
2227 if (atoi(ok) == 0) {
2228 cprintf("%d Ok.\n", CIT_OK);
2231 assoc_file_name(infofilename, sizeof infofilename, &CC->room, ctdl_info_dir);
2232 syslog(LOG_DEBUG, "opening\n");
2233 fp = fopen(infofilename, "w");
2234 syslog(LOG_DEBUG, "checking\n");
2236 cprintf("%d Cannot open %s: %s\n",
2237 ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
2240 cprintf("%d Send info...\n", SEND_LISTING);
2243 client_getln(buf, sizeof buf);
2244 if (strcmp(buf, "000"))
2245 fprintf(fp, "%s\n", buf);
2246 } while (strcmp(buf, "000"));
2249 /* now update the room index so people will see our new info */
2250 CtdlGetRoomLock(&CC->room, CC->room.QRname); /* lock so no one steps on us */
2251 CC->room.QRinfo = CC->room.QRhighest + 1L;
2252 CtdlPutRoomLock(&CC->room);
2257 * cmd_lflr() - List all known floors
2259 void cmd_lflr(char *gargs)
2264 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
2266 cprintf("%d Known floors:\n", LISTING_FOLLOWS);
2268 for (a = 0; a < MAXFLOORS; ++a) {
2269 CtdlGetFloor(&flbuf, a);
2270 if (flbuf.f_flags & F_INUSE) {
2271 cprintf("%d|%s|%d\n",
2283 * create a new floor
2285 void cmd_cflr(char *argbuf)
2287 char new_floor_name[256];
2290 int free_slot = (-1);
2293 extract_token(new_floor_name, argbuf, 0, '|', sizeof new_floor_name);
2294 cflr_ok = extract_int(argbuf, 1);
2296 if (CtdlAccessCheck(ac_aide)) return;
2298 if (IsEmptyStr(new_floor_name)) {
2299 cprintf("%d Blank floor name not allowed.\n",
2300 ERROR + ILLEGAL_VALUE);
2304 for (a = 0; a < MAXFLOORS; ++a) {
2305 CtdlGetFloor(&flbuf, a);
2307 /* note any free slots while we're scanning... */
2308 if (((flbuf.f_flags & F_INUSE) == 0)
2312 /* check to see if it already exists */
2313 if ((!strcasecmp(flbuf.f_name, new_floor_name))
2314 && (flbuf.f_flags & F_INUSE)) {
2315 cprintf("%d Floor '%s' already exists.\n",
2316 ERROR + ALREADY_EXISTS,
2322 if (free_slot < 0) {
2323 cprintf("%d There is no space available for a new floor.\n",
2324 ERROR + INVALID_FLOOR_OPERATION);
2328 cprintf("%d ok to create...\n", CIT_OK);
2331 lgetfloor(&flbuf, free_slot);
2332 flbuf.f_flags = F_INUSE;
2333 flbuf.f_ref_count = 0;
2334 safestrncpy(flbuf.f_name, new_floor_name, sizeof flbuf.f_name);
2335 lputfloor(&flbuf, free_slot);
2336 cprintf("%d %d\n", CIT_OK, free_slot);
2344 void cmd_kflr(char *argbuf)
2347 int floor_to_delete;
2351 floor_to_delete = extract_int(argbuf, 0);
2352 kflr_ok = extract_int(argbuf, 1);
2354 if (CtdlAccessCheck(ac_aide)) return;
2356 lgetfloor(&flbuf, floor_to_delete);
2359 if ((flbuf.f_flags & F_INUSE) == 0) {
2360 cprintf("%d Floor %d not in use.\n",
2361 ERROR + INVALID_FLOOR_OPERATION, floor_to_delete);
2364 if (flbuf.f_ref_count != 0) {
2365 cprintf("%d Cannot delete; floor contains %d rooms.\n",
2366 ERROR + INVALID_FLOOR_OPERATION,
2371 cprintf("%d Ok\n", CIT_OK);
2373 cprintf("%d Ok to delete...\n", CIT_OK);
2380 if ((delete_ok == 1) && (kflr_ok == 1))
2382 lputfloor(&flbuf, floor_to_delete);
2388 void cmd_eflr(char *argbuf)
2394 np = num_parms(argbuf);
2396 cprintf("%d Usage error.\n", ERROR + ILLEGAL_VALUE);
2400 if (CtdlAccessCheck(ac_aide)) return;
2402 floor_num = extract_int(argbuf, 0);
2403 lgetfloor(&flbuf, floor_num);
2404 if ((flbuf.f_flags & F_INUSE) == 0) {
2405 lputfloor(&flbuf, floor_num);
2406 cprintf("%d Floor %d is not in use.\n",
2407 ERROR + INVALID_FLOOR_OPERATION, floor_num);
2411 extract_token(flbuf.f_name, argbuf, 1, '|', sizeof flbuf.f_name);
2412 lputfloor(&flbuf, floor_num);
2414 cprintf("%d Ok\n", CIT_OK);
2420 * cmd_stat() - return the modification time of the current room (maybe other things in the future)
2422 void cmd_stat(char *gargs)
2424 if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
2425 CtdlGetRoom(&CC->room, CC->room.QRname);
2426 cprintf("%d %s|%ld|\n", CIT_OK, CC->room.QRname, CC->room.QRmtime);
2431 /*****************************************************************************/
2432 /* MODULE INITIALIZATION STUFF */
2433 /*****************************************************************************/
2435 CTDL_MODULE_INIT(room_ops)
2438 CtdlRegisterProtoHook(cmd_lrms, "LRMS", "List rooms");
2439 CtdlRegisterProtoHook(cmd_lkra, "LKRA", "List all known rooms");
2440 CtdlRegisterProtoHook(cmd_lkrn, "LKRN", "List known rooms with new messages");
2441 CtdlRegisterProtoHook(cmd_lkro, "LKRO", "List known rooms without new messages");
2442 CtdlRegisterProtoHook(cmd_lzrm, "LZRM", "List zapped rooms");
2443 CtdlRegisterProtoHook(cmd_lprm, "LPRM", "List public rooms");
2444 CtdlRegisterProtoHook(cmd_goto, "GOTO", "Goto a named room");
2445 CtdlRegisterProtoHook(cmd_stat, "STAT", "Get mtime of the current room");
2446 CtdlRegisterProtoHook(cmd_whok, "WHOK", "List users who know this room");
2447 CtdlRegisterProtoHook(cmd_rdir, "RDIR", "List files in room directory");
2448 CtdlRegisterProtoHook(cmd_getr, "GETR", "Get room parameters");
2449 CtdlRegisterProtoHook(cmd_setr, "SETR", "Set room parameters");
2450 CtdlRegisterProtoHook(cmd_geta, "GETA", "Get the room admin name");
2451 CtdlRegisterProtoHook(cmd_seta, "SETA", "Set the room admin for this room");
2452 CtdlRegisterProtoHook(cmd_rinf, "RINF", "Fetch room info file");
2453 CtdlRegisterProtoHook(cmd_kill, "KILL", "Kill (delete) the current room");
2454 CtdlRegisterProtoHook(cmd_cre8, "CRE8", "Create a new room");
2455 CtdlRegisterProtoHook(cmd_einf, "EINF", "Enter info file for the current room");
2456 CtdlRegisterProtoHook(cmd_lflr, "LFLR", "List all known floors");
2457 CtdlRegisterProtoHook(cmd_cflr, "CFLR", "Create a new floor");
2458 CtdlRegisterProtoHook(cmd_kflr, "KFLR", "Kill a floor");
2459 CtdlRegisterProtoHook(cmd_eflr, "EFLR", "Edit a floor");
2461 /* return our Subversion id for the Log */