pass through the database.
* Repaired the "create floor" operation which was broken by the switch
to the new IPC libray
$Log$
+ Revision 605.33 2003/04/07 05:02:23 ajc
+ * Reworked all the "list rooms" operations so that they only require one
+ pass through the database.
+ * Repaired the "create floor" operation which was broken by the switch
+ to the new IPC libray
+
Revision 605.32 2003/04/02 13:33:28 ajc
* Fixed output of "-0500" vs. "+0500" type of timezone stamps in RFC822.
(I think they were reversed.)
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
unsigned int march_flags;
char march_floor;
char march_order;
+ unsigned int march_flags2;
+ int march_access;
};
#define NODENAME config.c_nodename
mptr->march_flags = (unsigned int) extract_int(aaa, 1);
mptr->march_floor = (char) extract_int(aaa, 2);
mptr->march_order = (char) extract_int(aaa, 3);
+ mptr->march_flags2 = (unsigned int) extract_int(aaa, 4);
+ mptr->march_access = (char) extract_int(aaa, 5);
if (march == NULL)
march = mptr;
else {
int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret)
{
register int ret;
- char *aaa;
+ char aaa[SIZ];
if (!cret) return -2;
if (!name) return -2;
- if (!*name) return -2;
-
- aaa = (char *)malloc(strlen(name) + 17);
- if (!aaa) return -1;
sprintf(aaa, "CFLR %s|%d", name, for_real);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
- free(aaa);
return ret;
}
/* KFLR */
int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret)
{
- char aaa[27];
+ char aaa[SIZ];
if (!cret) return -1;
if (floornum < 0) return -1;
int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret)
{
register int ret;
- char *aaa;
+ char aaa[SIZ];
if (!cret) return -2;
if (!floorname) return -2;
if (floornum < 0) return -2;
- aaa = (char *)malloc(strlen(floorname) + 17);
- if (!aaa) return -1;
-
sprintf(aaa, "EFLR %d|%s", floornum, floorname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
- free(aaa);
return ret;
}
US_NOPROMPT | US_DISAPPEAR | US_PAGINATOR | \
US_FLOORS | US_COLOR | US_PROMPTCTL )
+#define UA_KNOWN 2
+#define UA_GOTOALLOWED 4
+#define UA_HASNEWMSGS 8
+#define UA_ZAPPED 16
+
#ifdef __cplusplus
}
#endif
/*
* Back-back-end for all room listing commands
*/
-void list_roomname(struct quickroom *qrbuf)
+void list_roomname(struct quickroom *qrbuf, int ra)
{
char truncated_roomname[ROOMNAMELEN];
}
/* ...and now the other parameters */
- cprintf("|%u|%d|%d|%d\n",
+ cprintf("|%u|%d|%d|%d|%d|\n",
qrbuf->QRflags,
(int) qrbuf->QRfloor,
(int) qrbuf->QRorder,
- (int) qrbuf->QRflags2
+ (int) qrbuf->QRflags2,
+ ra
);
}
void cmd_lrms_backend(struct quickroom *qrbuf, void *data)
{
int FloorBeingSearched = (-1);
+ int ra;
+
FloorBeingSearched = *(int *)data;
+ ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
- if (((CtdlRoomAccess(qrbuf, &CC->usersupp)
- & (UA_KNOWN | UA_ZAPPED)))
+ if ((( ra & (UA_KNOWN | UA_ZAPPED)))
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lrms(char *argbuf)
void cmd_lkra_backend(struct quickroom *qrbuf, void *data)
{
int FloorBeingSearched = (-1);
+ int ra;
+
FloorBeingSearched = *(int *)data;
+ ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
- if (((CtdlRoomAccess(qrbuf, &CC->usersupp)
- & (UA_KNOWN)))
+ if ((( ra & (UA_KNOWN)))
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lkra(char *argbuf)
void cmd_lprm_backend(struct quickroom *qrbuf, void *data)
{
int FloorBeingSearched = (-1);
+ int ra;
+
FloorBeingSearched = *(int *)data;
+ ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
if ( ((qrbuf->QRflags & QR_PRIVATE) == 0)
&& ((qrbuf->QRflags & QR_MAILBOX) == 0)
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lprm(char *argbuf)
*/
void cmd_lkrn_backend(struct quickroom *qrbuf, void *data)
{
- int ra;
int FloorBeingSearched = (-1);
- FloorBeingSearched = *(int *)data;
+ int ra;
+ FloorBeingSearched = *(int *)data;
ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
+
if ((ra & UA_KNOWN)
&& (ra & UA_HASNEWMSGS)
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lkrn(char *argbuf)
*/
void cmd_lkro_backend(struct quickroom *qrbuf, void *data)
{
- int ra;
int FloorBeingSearched = (-1);
- FloorBeingSearched = *(int *)data;
+ int ra;
+ FloorBeingSearched = *(int *)data;
ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
+
if ((ra & UA_KNOWN)
&& ((ra & UA_HASNEWMSGS) == 0)
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lkro(char *argbuf)
*/
void cmd_lzrm_backend(struct quickroom *qrbuf, void *data)
{
- int ra;
int FloorBeingSearched = (-1);
- FloorBeingSearched = *(int *)data;
+ int ra;
+ FloorBeingSearched = *(int *)data;
ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
+
if ((ra & UA_GOTOALLOWED)
&& (ra & UA_ZAPPED)
&& ((qrbuf->QRfloor == (FloorBeingSearched))
|| ((FloorBeingSearched) < 0)))
- list_roomname(qrbuf);
+ list_roomname(qrbuf, ra);
}
void cmd_lzrm(char *argbuf)
void assoc_file_name(char *buf, size_t n,
struct quickroom *qrbuf, const char *prefix);
void delete_room(struct quickroom *qrbuf);
-void list_roomname(struct quickroom *qrbuf);
+void list_roomname(struct quickroom *qrbuf, int ra);
int is_noneditable(struct quickroom *qrbuf);
int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf);
int CtdlDoIHavePermissionToDeleteThisRoom(struct quickroom *qr);
/*
* Common code for all room listings
*/
-static void listrms(CtdlIPC *ipc, enum RoomList variety, int floor)
+static void listrms(struct march *listing, int new_only, int floor_only)
{
- char buf[SIZ];
- struct march *listing = NULL;
- struct march *tmp = NULL;
+ struct march *mptr;
struct roomlisting *rl = NULL;
struct roomlisting *rp;
struct roomlisting *rs;
- int r; /* IPC response code */
-
- /* Ask the server for a room list */
- r = CtdlIPCKnownRooms(ipc, variety, floor, &listing, buf);
- if (r / 100 != 1) {
- return;
- }
- while (listing) {
- rp = malloc(sizeof(struct roomlisting));
- strncpy(rp->rlname, listing->march_name, ROOMNAMELEN);
- rp->rlflags = listing->march_flags;
- rp->rlfloor = listing->march_floor;
- rp->rlorder = listing->march_order;
- rp->lnext = NULL;
- rp->rnext = NULL;
-
- tmp = listing->next;
- free(listing);
- listing = tmp;
-
- rs = rl;
- if (rl == NULL) {
- rl = rp;
- } else {
- while (rp != NULL) {
- if (rordercmp(rp, rs) < 0) {
- if (rs->lnext == NULL) {
- rs->lnext = rp;
- rp = NULL;
+ int list_it;
+
+ for (mptr = listing; mptr != NULL; mptr = mptr->next) {
+ list_it = 1;
+
+ if ( (new_only == LISTRMS_NEW_ONLY)
+ && ((mptr->march_access & UA_HASNEWMSGS) == 0))
+ list_it = 0;
+
+ if ( (new_only == LISTRMS_OLD_ONLY)
+ && ((mptr->march_access & UA_HASNEWMSGS) != 0))
+ list_it = 0;
+
+ if ( (floor_only >= 0)
+ && (mptr->march_floor != floor_only))
+ list_it = 0;
+
+ if (list_it) {
+ rp = malloc(sizeof(struct roomlisting));
+ strncpy(rp->rlname, mptr->march_name, ROOMNAMELEN);
+ rp->rlflags = mptr->march_flags;
+ rp->rlfloor = mptr->march_floor;
+ rp->rlorder = mptr->march_order;
+ rp->lnext = NULL;
+ rp->rnext = NULL;
+
+ rs = rl;
+ if (rl == NULL) {
+ rl = rp;
+ } else {
+ while (rp != NULL) {
+ if (rordercmp(rp, rs) < 0) {
+ if (rs->lnext == NULL) {
+ rs->lnext = rp;
+ rp = NULL;
+ } else {
+ rs = rs->lnext;
+ }
} else {
- rs = rs->lnext;
- }
- } else {
- if (rs->rnext == NULL) {
- rs->rnext = rp;
- rp = NULL;
- } else {
- rs = rs->rnext;
+ if (rs->rnext == NULL) {
+ rs->rnext = rp;
+ rp = NULL;
+ } else {
+ rs = rs->rnext;
+ }
}
}
}
void knrooms(CtdlIPC *ipc, int kn_floor_mode)
{
int a;
+ struct march *listing = NULL;
+ struct march *mptr;
+ int r; /* IPC response code */
+ char buf[SIZ];
+
+
+ /* Ask the server for a room list */
+ r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
+ if (r / 100 != 1) {
+ listing = NULL;
+ }
load_floorlist(ipc);
+
if (kn_floor_mode == 0) {
color(BRIGHT_CYAN);
pprintf("\n Rooms with unread messages:\n");
- listrms(ipc, SubscribedRoomsWithNewMessages, -1);
+ listrms(listing, LISTRMS_NEW_ONLY, -1);
color(BRIGHT_CYAN);
pprintf("\n\n No unseen messages in:\n");
- listrms(ipc, SubscribedRoomsWithNoNewMessages, -1);
+ listrms(listing, LISTRMS_OLD_ONLY, -1);
pprintf("\n");
}
color(BRIGHT_CYAN);
pprintf("\n Rooms with unread messages on %s:\n",
floorlist[(int) curr_floor]);
- listrms(ipc, SubscribedRoomsWithNewMessages, curr_floor);
+ listrms(listing, LISTRMS_NEW_ONLY, curr_floor);
color(BRIGHT_CYAN);
pprintf("\n\n Rooms with no new messages on %s:\n",
floorlist[(int) curr_floor]);
- listrms(ipc, SubscribedRoomsWithNoNewMessages, curr_floor);
+ listrms(listing, LISTRMS_OLD_ONLY, curr_floor);
color(BRIGHT_CYAN);
pprintf("\n\n Other floors:\n");
list_other_floors();
color(BRIGHT_CYAN);
pprintf("\n Rooms on %s:\n",
floorlist[a]);
- listrms(ipc, AllAccessibleRooms, a);
+ listrms(listing, LISTRMS_ALL, a);
pprintf("\n");
}
}
}
+ /* Free the room list */
+ while (listing) {
+ mptr = listing->next;
+ free(listing);
+ listing = mptr;
+ };
+
color(DIM_WHITE);
IFNEXPERT hit_any_key();
}
void listzrooms(CtdlIPC *ipc)
{ /* list public forgotten rooms */
+ struct march *listing = NULL;
+ struct march *mptr;
+ int r; /* IPC response code */
+ char buf[SIZ];
+
+
+ /* Ask the server for a room list */
+ r = CtdlIPCKnownRooms(ipc, UnsubscribedRooms, 1, &listing, buf);
+ if (r / 100 != 1) {
+ listing = NULL;
+ }
+
color(BRIGHT_CYAN);
pprintf("\n Forgotten public rooms:\n");
- listrms(ipc, UnsubscribedRooms, -1);
+ listrms(listing, LISTRMS_ALL, -1);
pprintf("\n");
+
+ /* Free the room list */
+ while (listing) {
+ mptr = listing->next;
+ free(listing);
+ listing = mptr;
+ };
+
color(DIM_WHITE);
IFNEXPERT hit_any_key();
}
load_floorlist(ipc);
r = CtdlIPCCreateFloor(ipc, 0, "", buf);
- if (r / 100 != 2) {
+ if ( (r / 100 != 2) && (r != ERROR + ILLEGAL_VALUE) ) {
scr_printf("%s\n", buf);
return;
}
};
+enum {
+ LISTRMS_NEW_ONLY,
+ LISTRMS_OLD_ONLY,
+ LISTRMS_ALL
+};
+
+
#define V_LOCKOUT 2 /* User is locked out of this room */
#define V_ACCESS 4 /* Access is granted to this room */
-#define UA_KNOWN 2
-#define UA_GOTOALLOWED 4
-#define UA_HASNEWMSGS 8
-#define UA_ZAPPED 16
-
/* Supplementary data for a message on disk
* (These are kept separately from the message itself because they are
The fourth field displayed on each line is a "room listing order." Unless
there is a compelling reason not to, clients should sort any received room
listings by this value.
-
-
-
+
+ The fifth field is a special bit bucket containing fields which pertain to
+room access controls:
+
+#define UA_KNOWN 2 /* Known room */
+#define UA_GOTOALLOWED 4 /* Access will be granted to this room
+ * if the user calls it up by name */
+#define UA_HASNEWMSGS 8 /* Unread messages exist in room */
+#define UA_ZAPPED 16 /* Zapped from known rooms list */
+
+
+
LKRO (List Known Rooms with Old [no new] messages)
This follows the same usage and format as LKRN.