/* $Id$ */
+#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
+#endif
#include <time.h>
#include <limits.h>
+#include <errno.h>
#include "citadel.h"
#include "server.h"
#include "database.h"
return(retval);
}
+/*
+ * Self-checking stuff for a room record read into memory
+ */
+void room_sanity_check(struct quickroom *qrbuf) {
+ /* Mailbox rooms are always on the lowest floor */
+ if (qrbuf->QRflags & QR_MAILBOX) {
+ qrbuf->QRfloor = 0;
+ }
+
+ /* Listing order of 0 is illegal except for base rooms */
+ if (qrbuf->QRorder == 0)
+ if (!is_noneditable(qrbuf))
+ qrbuf->QRorder = 64;
+ }
+
+
/*
* getroom() - retrieve room data from disk
*/
sizeof(struct quickroom) : cdbqr->len) );
cdb_free(cdbqr);
- /* Mailbox rooms are always on the lowest floor */
- if (qrbuf->QRflags & QR_MAILBOX) {
- qrbuf->QRfloor = 0;
- }
+ room_sanity_check(qrbuf);
return(0);
}
( (cdbqr->len > sizeof(struct quickroom)) ?
sizeof(struct quickroom) : cdbqr->len) );
cdb_free(cdbqr);
+ room_sanity_check(&qrbuf);
if (qrbuf.QRflags & QR_INUSE) (*CallBack)(&qrbuf);
}
}
msglist, num_msgs * sizeof(long));
/* And finally, free up the memory we used. */
- free(msglist);
+ phree(msglist);
return(highest_msg);
}
}
/* ...and now the other parameters */
- cprintf("|%u|%d\n",
- qrbuf->QRflags,qrbuf->QRfloor);
+ cprintf("|%u|%d|%d\n",
+ qrbuf->QRflags,
+ (int)qrbuf->QRfloor,
+ (int)qrbuf->QRorder);
}
strcpy(CC->quickroom.QRname, where);
getroom(&CC->quickroom, where);
+
lgetuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
- vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
- vbuf.v_flags = vbuf.v_flags | V_ACCESS;
+ /* Know the room ... but not if it's the page log room */
+ if (strcasecmp(where, config.c_logpages)) {
+ vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
+ vbuf.v_flags = vbuf.v_flags | V_ACCESS;
+ }
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp,CC->curr_user);
}
getroom(&CC->quickroom, CC->quickroom.QRname);
- cprintf("%d%c%s|%s|%s|%d|%d\n",
+ cprintf("%d%c%s|%s|%s|%d|%d|%d\n",
OK,check_express(),
CC->quickroom.QRname,
((CC->quickroom.QRflags & QR_PASSWORDED) ? CC->quickroom.QRpasswd : ""),
((CC->quickroom.QRflags & QR_DIRECTORY) ? CC->quickroom.QRdirname : ""),
CC->quickroom.QRflags,
- (int)CC->quickroom.QRfloor);
+ (int)CC->quickroom.QRfloor,
+ (int)CC->quickroom.QRorder);
}
struct floor flbuf;
char old_name[ROOMNAMELEN];
int old_floor;
+ int new_order = 0;
if (!(CC->logged_in)) {
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
}
}
+ if (num_parms(args)>=7) {
+ new_order = extract_int(args, 6);
+ if (new_order < 1) new_order = 1;
+ if (new_order > 127) new_order = 127;
+ }
+
lgetroom(&CC->quickroom, CC->quickroom.QRname);
strcpy(old_name, CC->quickroom.QRname);
extract(buf,args,0); buf[ROOMNAMELEN]=0;
extract(buf,args,2); buf[15]=0;
strncpy(CC->quickroom.QRdirname,buf,19);
CC->quickroom.QRflags = ( extract_int(args,3) | QR_INUSE);
+ if (num_parms(args)>=7)
+ CC->quickroom.QRorder = (char)new_order;
/* Clean up a client boo-boo: if the client set the room to
* guess-name or passworded, ensure that the private flag is
return;
}
- if (CC->usersupp.axlevel<3) {
+ if (CC->usersupp.axlevel < config.c_createax) {
cprintf("%d You need higher access to create rooms.\n",
ERROR+HIGHER_ACCESS_REQUIRED);
return;