}
}
- /* On some systems, Aides can gain access to mailboxes as well */
- if ( (config.c_aide_mailboxes)
- && (userbuf->axlevel >= 6)
+ /* Aides can gain access to mailboxes as well, but they don't show
+ * by default.
+ */
+ if ( (userbuf->axlevel >= 6)
&& (roombuf->QRflags & QR_MAILBOX) ) {
retval = retval | UA_GOTOALLOWED;
}
struct floor *cgetfloor(int floor_num) {
static int initialized = 0;
int i;
+ int fetch_new = 0;
+ struct floor *fl = NULL;
+ begin_critical_section(S_FLOORCACHE);
if (initialized == 0) {
for (i=0; i<MAXFLOORS; ++i) {
floorcache[floor_num] = NULL;
}
initialized = 1;
}
-
if (floorcache[floor_num] == NULL) {
- floorcache[floor_num] = mallok(sizeof(struct floor));
- getfloor(floorcache[floor_num], floor_num);
+ fetch_new = 1;
+ }
+ end_critical_section(S_FLOORCACHE);
+
+ if (fetch_new) {
+ lprintf(CTDL_DEBUG, "fetch_new is active ... going to disk\n");
+ fl = malloc(sizeof(struct floor));
+ getfloor(fl, floor_num);
+ begin_critical_section(S_FLOORCACHE);
+ if (floorcache[floor_num] != NULL) {
+ free(floorcache[floor_num]);
+ }
+ floorcache[floor_num] = fl;
+ end_critical_section(S_FLOORCACHE);
}
return(floorcache[floor_num]);
*/
void putfloor(struct floor *flbuf, int floor_num)
{
- cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
- flbuf, sizeof(struct floor));
-
/* If we've cached this, clear it out, 'cuz it's WRONG now! */
+ begin_critical_section(S_FLOORCACHE);
if (floorcache[floor_num] != NULL) {
- phree(floorcache[floor_num]);
- floorcache[floor_num] = NULL;
+ free(floorcache[floor_num]);
+ floorcache[floor_num] = malloc(sizeof(struct floor));
+ memcpy(floorcache[floor_num], flbuf, sizeof(struct floor));
}
+ end_critical_section(S_FLOORCACHE);
+
+ cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
+ flbuf, sizeof(struct floor));
}
get_mm();
cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
if (cdbfr != NULL) {
- msglist = mallok(cdbfr->len);
+ msglist = malloc(cdbfr->len);
memcpy(msglist, cdbfr->ptr, cdbfr->len);
num_msgs = cdbfr->len / sizeof(long);
cdb_free(cdbfr);
}
}
- if (msglist != NULL) phree(msglist);
+ if (msglist != NULL) free(msglist);
if (CC->room.QRflags & QR_MAILBOX)
rmailflag = 1;
if (retmsgs != NULL) *retmsgs = total_messages;
if (retnew != NULL) *retnew = new_messages;
- lprintf(9, "<%s> %d new of %d total messages\n",
+ lprintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
CC->room.QRname,
new_messages, total_messages
);
((ra & UA_KNOWN) == 0) &&
(CC->user.axlevel < 6)
) {
- lprintf(9, "Failed to acquire private room\n");
+ lprintf(CTDL_DEBUG, "Failed to acquire private room\n");
} else {
memcpy(&CC->room, &QRscratch,
sizeof(struct ctdlroom));
long owner = 0L;
char actual_old_name[SIZ];
- lprintf(9, "CtdlRenameRoom(%s, %s, %d)\n",
+ lprintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
old_name, new_name, new_floor);
if (new_floor >= 0) {
lgetfloor(&flbuf, old_floor);
--flbuf.f_ref_count;
lputfloor(&flbuf, old_floor);
- lprintf(9, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
+ lprintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
lgetfloor(&flbuf, new_floor);
++flbuf.f_ref_count;
lputfloor(&flbuf, new_floor);
- lprintf(9, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
+ lprintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
}
/* ...and everybody say "YATTA!" */
struct floor flbuf;
char filename[100];
- lprintf(9, "Deleting room <%s>\n", qrbuf->QRname);
+ lprintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
/* Delete the info file */
assoc_file_name(filename, sizeof filename, qrbuf, "info");
struct floor flbuf;
struct visit vbuf;
- lprintf(9, "create_room(%s)\n", new_room_name);
+ lprintf(CTDL_DEBUG, "create_room(%s)\n", new_room_name);
if (getroom(&qrbuf, new_room_name) == 0) {
- lprintf(9, "%s already exists.\n", new_room_name);
+ lprintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
return (0); /* already exists */
}
if (num_parms(args) >= 5) {
fl = cgetfloor(extract_int(args, 4));
- if ((fl->f_flags & F_INUSE) == 0) {
+ if (fl == NULL) {
+ cprintf("%d Invalid floor number.\n",
+ ERROR + INVALID_FLOOR_OPERATION);
+ return;
+ }
+ else if ((fl->f_flags & F_INUSE) == 0) {
cprintf("%d Invalid floor number.\n",
ERROR + INVALID_FLOOR_OPERATION);
return;
}
if (new_room_type == 5) {
- if ((config.c_aide_mailboxes == 0)
- || (CC->user.axlevel < 6)) {
+ if (CC->user.axlevel < 6) {
cprintf("%d Higher access required\n",
ERROR + HIGHER_ACCESS_REQUIRED);
return;
return;
}
assoc_file_name(infofilename, sizeof infofilename, &CC->room, "info");
- lprintf(9, "opening\n");
+ lprintf(CTDL_DEBUG, "opening\n");
fp = fopen(infofilename, "w");
- lprintf(9, "checking\n");
+ lprintf(CTDL_DEBUG, "checking\n");
if (fp == NULL) {
cprintf("%d Cannot open %s: %s\n",
ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
return;
}
cprintf("%d Send info...\n", SEND_LISTING);
+ flush_output();
do {
client_gets(buf);