#include "citadel_dirs.h"
#include "threads.h"
+#include "ctdl_module.h"
+
struct floor *floorcache[MAXFLOORS];
/*
/* for internal programs, always do everything */
if (((CC->internal_pgm)) && (roombuf->QRflags & QR_INUSE)) {
- retval = (UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED);
+ retval = (UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED);
vbuf.v_view = 0;
goto SKIP_EVERYTHING;
}
if ( (userbuf->axlevel >= 6)
|| (userbuf->usernum == roombuf->QRroomaide)
) {
- retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED;
+ retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED | UA_POSTALLOWED;
}
NEWMSG: /* By the way, we also check for the presence of new messages */
+/*
+ * Message pointer compare function for sort_msglist()
+ */
+int sort_msglist_cmp(const void *m1, const void *m2) {
+ if ((*(const long *)m1) > (*(const long *)m2)) return(1);
+ if ((*(const long *)m1) < (*(const long *)m2)) return(-1);
+ return(0);
+}
+
/*
* sort message pointers
*/
int sort_msglist(long listptrs[], int oldcount)
{
- int a, b;
- long hold1, hold2;
int numitems;
numitems = oldcount;
- if (numitems < 2)
+ if (numitems < 2) {
return (oldcount);
+ }
/* do the sort */
- for (a = numitems - 2; a >= 0; --a) {
- for (b = 0; b <= a; ++b) {
- if (listptrs[b] > (listptrs[b + 1])) {
- hold1 = listptrs[b];
- hold2 = listptrs[b + 1];
- listptrs[b] = hold2;
- listptrs[b + 1] = hold1;
- }
- }
- }
+ qsort(listptrs, numitems, sizeof(long), sort_msglist_cmp);
/* and yank any nulls */
while ((numitems > 0) && (listptrs[0] == 0L)) {
if (retmsgs != NULL) *retmsgs = total_messages;
if (retnew != NULL) *retnew = new_messages;
- lprintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
+ CtdlLogPrintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
CC->room.QRname,
new_messages, total_messages
);
else if (!strcasecmp(towhere, "_TRASH_")) {
safestrncpy(towhere, USERTRASHROOM, maxlen);
}
+ else if (!strcasecmp(towhere, "_DRAFTS_")) {
+ safestrncpy(towhere, USERDRAFTROOM, maxlen);
+ }
else if (!strcasecmp(towhere, "_BITBUCKET_")) {
safestrncpy(towhere, config.c_twitroom, maxlen);
}
((ra & UA_KNOWN) == 0) &&
(CC->user.axlevel < 6)
) {
- lprintf(CTDL_DEBUG, "Failed to acquire private room\n");
+ CtdlLogPrintf(CTDL_DEBUG, "Failed to acquire private room\n");
} else {
memcpy(&CC->room, &QRscratch,
sizeof(struct ctdlroom));
}
-void cmd_whok(void)
+void cmd_whok(char *cmdbuf)
{
struct ctdluser temp;
struct cdbdata *cdbus;
/*
* RDIR command for room directory
*/
-void cmd_rdir(void)
+void cmd_rdir(char *cmdbuf)
{
char buf[256];
char comment[256];
stat(buf, &statbuf); /* stat the file */
if (!(statbuf.st_mode & S_IFREG))
{
- snprintf(buf2, sizeof buf2, "Command RDIR found something that is not a useable file. It should be cleaned up.\n RDIR found this non regular file:\n%s\n", buf);
- aide_message(buf2, "RDIR found bad 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
+ );
+ aide_message(buf2, "Unusable data found in room directory");
continue; /* not a useable file type so don't show it */
}
safestrncpy(comment, "", sizeof comment);
/*
* get room parameters (aide or room aide command)
*/
-void cmd_getr(void)
+void cmd_getr(char *cmdbuf)
{
if (CtdlAccessCheck(ac_room_aide)) return;
long owner = 0L;
char actual_old_name[ROOMNAMELEN];
- lprintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
+ CtdlLogPrintf(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(CTDL_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
+ CtdlLogPrintf(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(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
+ CtdlLogPrintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
}
/* ...and everybody say "YATTA!" */
/*
* get the name of the room aide for this room
*/
-void cmd_geta(void)
+void cmd_geta(char *cmdbuf)
{
struct ctdluser usbuf;
/*
* retrieve info file for this room
*/
-void cmd_rinf(void)
+void cmd_rinf(char *gargs)
{
char filename[128];
char buf[SIZ];
char old_name[ROOMNAMELEN];
static int seq = 0;
- lprintf(CTDL_NOTICE, "Scheduling room <%s> for deletion\n",
+ CtdlLogPrintf(CTDL_NOTICE, "Scheduling room <%s> for deletion\n",
qrbuf->QRname);
safestrncpy(old_name, qrbuf->QRname, sizeof old_name);
char filename[100];
/* TODO: filename magic? does this realy work? */
- lprintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
+ CtdlLogPrintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
/* Delete the info file */
assoc_file_name(filename, sizeof filename, qrbuf, ctdl_info_dir);
struct floor flbuf;
struct visit vbuf;
- lprintf(CTDL_DEBUG, "create_room(name=%s, type=%d, view=%d)\n",
+ CtdlLogPrintf(CTDL_DEBUG, "create_room(name=%s, type=%d, view=%d)\n",
new_room_name, new_room_type, new_room_view);
if (getroom(&qrbuf, new_room_name) == 0) {
- lprintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
+ CtdlLogPrintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
return(0);
}
return;
}
assoc_file_name(infofilename, sizeof infofilename, &CC->room, ctdl_info_dir);
- lprintf(CTDL_DEBUG, "opening\n");
+ CtdlLogPrintf(CTDL_DEBUG, "opening\n");
fp = fopen(infofilename, "w");
- lprintf(CTDL_DEBUG, "checking\n");
+ CtdlLogPrintf(CTDL_DEBUG, "checking\n");
if (fp == NULL) {
cprintf("%d Cannot open %s: %s\n",
ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
/*
* cmd_lflr() - List all known floors
*/
-void cmd_lflr(void)
+void cmd_lflr(char *gargs)
{
int a;
struct floor flbuf;
cprintf("%d Ok\n", CIT_OK);
}
+
+
+/*****************************************************************************/
+/* MODULE INITIALIZATION STUFF */
+/*****************************************************************************/
+
+CTDL_MODULE_INIT(room_ops)
+{
+ CtdlRegisterProtoHook(cmd_lrms, "LRMS", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lkra, "LKRA", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lkrn, "LKRN", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lkro, "LKRO", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lzrm, "LZRM", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lprm, "LPRM", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_goto, "GOTO", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_whok, "WHOK", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_rdir, "RDIR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_getr, "GETR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_setr, "SETR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_geta, "GETA", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_seta, "SETA", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_rinf, "RINF", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_kill, "KILL", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_cre8, "CRE8", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_einf, "EINF", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_lflr, "LFLR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_cflr, "CFLR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_kflr, "KFLR", "Autoconverted. TODO: document me.");
+ CtdlRegisterProtoHook(cmd_eflr, "EFLR", "Autoconverted. TODO: document me.");
+ /* return our Subversion id for the Log */
+ return "$Id$";
+}