extern char temp[];
extern char tempdir[];
extern int editor_pid;
-extern char editor_path[];
extern int screenwidth;
extern int screenheight;
extern char fullname[];
/*
* 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();
}
int rbump = 0;
char raide[USERNAME_SIZE];
char buf[SIZ];
- struct quickroom *attr = NULL;
+ struct room *attr = NULL;
struct ExpirePolicy *eptr = NULL;
int r; /* IPC response code */
/*
- * un-goto the previous room
+ * un-goto the previous room, or a specified room
*/
+void dotungoto(CtdlIPC *ipc, char *towhere)
+ {
+ /* Find this 'towhere' room in the list ungoto from this room to
+ that at the messagepointer position in that room in our ungoto list.
+ I suppose I could be a real dick and just ungoto that many places
+ in our list. */
+ int found = -1;
+ int lp;
+ char buf[SIZ];
+ struct ctdlipcroom *rret = NULL; /* ignored */
+ int r;
+
+ if (uglistsize == 0)
+ {
+ scr_printf("No rooms to ungoto.\n");
+ return;
+ }
+ if (towhere == NULL)
+ {
+ scr_printf("Must specify a room to ungoto.\n");
+ return;
+ }
+ if (strlen(towhere) == 0)
+ {
+ scr_printf("Must specify a room to ungoto.\n");
+ return;
+ }
+ for (lp = uglistsize-1; lp >= 0; lp--)
+ {
+ if (strcasecmp(towhere, uglist[lp]) == 0)
+ {
+ found = lp;
+ break;
+ }
+ }
+ if (found == -1)
+ {
+ scr_printf("Room: %s not in ungoto list.\n", towhere);
+ return;
+ }
+
+ r = CtdlIPCGotoRoom(ipc, uglist[found], "", &rret, buf);
+ if (rret) free(rret); /* ignored */
+ if (r / 100 != 2) {
+ scr_printf("%s\n", buf);
+ return;
+ }
+ r = CtdlIPCSetLastRead(ipc, uglistlsn[found], buf);
+ if (r / 100 != 2) {
+ scr_printf("%s\n", buf);
+ }
+ safestrncpy(buf, uglist[found], sizeof(buf));
+ /* we queue ungoto information here, because we're not really
+ ungotoing, we're really going to a random spot in some arbitrary
+ room list. */
+ dotgoto(ipc, buf, 0, 0);
+ }
+
void ungoto(CtdlIPC *ipc)
{
char buf[SIZ];
char cmd[SIZ];
int b, cksum, editor_exit;
- if (strlen(editor_path) == 0) {
+ if (strlen(editor_paths[0]) == 0) {
scr_printf("Do you wish to re-enter %s? ", desc);
if (yesno() == 0)
return;
return;
}
- if (strlen(editor_path) > 0) {
+ if (strlen(editor_paths[0]) > 0) {
CtdlIPC_putline(ipc, read_cmd);
CtdlIPC_getline(ipc, cmd);
if (cmd[0] == '1') {
cksum = file_checksum(temp);
- if (strlen(editor_path) > 0) {
+ if (strlen(editor_paths[0]) > 0) {
char tmp[SIZ];
snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc);
editor_pid = fork();
if (editor_pid == 0) {
chmod(temp, 0600);
- execlp(editor_path, editor_path, temp, NULL);
+ execlp(editor_paths[0], editor_paths[0], temp, NULL);
exit(1);
}
if (editor_pid > 0)
b = ka_wait(&editor_exit);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
- scr_printf("Executed %s\n", editor_path);
+ scr_printf("Executed %s\n", editor_paths[0]);
sttybbs(0);
screen_set();
} else {
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;
}