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(long *m1, long *m2) {
+ if (*m1 > *m2) return(1);
+ if (*m1 < *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
);
((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));
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!" */
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));