From 30cff7427b406571a0edf1c342573c0844f387f1 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 22 Oct 2006 05:15:36 +0000 Subject: [PATCH] Patches submitted by matt: Added: ** .RC .RS Read configuration, Read system info (citadel.c) ** .> .< .+ .- Same as <>+- But skips instead. (citadel.c) Fixed: ** .Z not displaying zapped rooms. (rooms.c) ** U .U Ungoto wasn't restoring the # of last read in rooms in which the last message read was zero (rooms visited for the first time). The work-around I chose was to set it to 1 instead of 0 in these cases. (rooms.c) ** .aide edituser() spaces in front of 'Permission to send internet mail' (routines.c) ** .rb? list_bio() segfaults if no users have a bio (routines2.c) --- citadel/citadel.c | 161 +++++++++++++++++++++++++++++++++++++-- citadel/citadel.rc | 6 ++ citadel/help/summary | 4 +- citadel/messages/readopt | 2 + citadel/rooms.c | 8 +- citadel/routines.c | 10 ++- citadel/routines2.c | 2 +- 7 files changed, 175 insertions(+), 18 deletions(-) diff --git a/citadel/citadel.c b/citadel/citadel.c index 9621e3528..383ba6632 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -733,7 +733,7 @@ void room_tree_list_query(struct ctdlroomlisting *rp, char *findrmname, int find /* * step through rooms on current floor */ -void gotoroomstep(CtdlIPC *ipc, int direction) +void gotoroomstep(CtdlIPC *ipc, int direction, int mode) { struct march *listing = NULL; struct march *mptr; @@ -823,7 +823,13 @@ void gotoroomstep(CtdlIPC *ipc, int direction) /* Free the tree */ room_tree_list_query(rl, NULL, 0, NULL, NULL, NULL); - updatels(ipc); + if (mode == 0) { /* not skipping */ + updatels(ipc); + } else { + if (rc_alt_semantics) { + updatelsa(ipc); + } + } dotgoto(ipc, rmname, 1, 0); } @@ -831,7 +837,7 @@ void gotoroomstep(CtdlIPC *ipc, int direction) /* * step through floors on system */ -void gotofloorstep(CtdlIPC *ipc, int direction) +void gotofloorstep(CtdlIPC *ipc, int direction, int mode) { int tofloor; @@ -855,9 +861,124 @@ void gotofloorstep(CtdlIPC *ipc, int direction) scr_printf("(%s)\n", floorlist[tofloor] ); } - gotofloor(ipc, floorlist[tofloor], GF_GOTO); + gotofloor(ipc, floorlist[tofloor], mode); } +/* + * Display user 'preferences'. + */ +extern int rc_prompt_control; +void read_config(CtdlIPC *ipc) +{ + char buf[SIZ]; + char *resp = NULL; + int r; /* IPC response code */ + char _fullname[USERNAME_SIZE]; + long _usernum; + int _axlevel, _timescalled, _posted; + time_t _lastcall; + struct ctdluser *user = NULL; + + /* get misc user info */ + r = CtdlIPCGetBio(ipc, fullname, &resp, buf); + if (r / 100 != 1) { + pprintf("%s\n", buf); + return; + } + extract_token(_fullname, buf, 1, '|', sizeof fullname); + _usernum = extract_long(buf, 2); + _axlevel = extract_int(buf, 3); + _lastcall = extract_long(buf, 4); + _timescalled = extract_int(buf, 5); + _posted = extract_int(buf, 6); + free(resp); + resp = NULL; + + /* get preferences */ + r = CtdlIPCGetConfig(ipc, &user, buf); + if (r / 100 != 2) { + scr_printf("%s\n", buf); + free(user); + return; + } + + /* show misc user info */ + scr_printf("%s\nAccess level: %d (%s)\n" + "User #%ld / %d Calls / %d Posts", + _fullname, _axlevel, axdefs[(int) _axlevel], + _usernum, _timescalled, _posted); + if (_lastcall > 0L) { + scr_printf(" / Curr login: %s", + asctime(localtime(&_lastcall))); + } + scr_printf("\n"); + + /* show preferences */ + scr_printf("Your screen width: "); color(BRIGHT_CYAN); scr_printf("%d", /*user->USscreenwidth*/ screenwidth); color(DIM_WHITE); + scr_printf(", height: "); color(BRIGHT_CYAN); scr_printf("%d\n", /*user->USscreenheight*/ screenheight); color(DIM_WHITE); + scr_printf("Are you an experienced Citadel user: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No"); color(DIM_WHITE); + scr_printf("Print last old message on New message request: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_LASTOLD)? "Yes" : "No"); color(DIM_WHITE); + scr_printf("Prompt after each message: "); color(BRIGHT_CYAN); scr_printf("%s\n", (!(user->flags & US_NOPROMPT))? "Yes" : "No"); color(DIM_WHITE); + if ((user->flags & US_NOPROMPT) == 0) { + scr_printf("Use 'disappearing' prompts: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_DISAPPEAR)? "Yes" : "No"); color(DIM_WHITE); + } + scr_printf("Pause after each screenful of text: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PAGINATOR)? "Yes" : "No"); color(DIM_WHITE); + if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) { + scr_printf("ext and top work at paginator prompt: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PROMPTCTL)? "Yes" : "No"); color(DIM_WHITE); + } + if (rc_floor_mode == RC_DEFAULT) { + scr_printf("View rooms by floor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_FLOORS)? "Yes" : "No"); color(DIM_WHITE); + } + if (rc_ansi_color == 3) { + scr_printf("Enable color support: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_COLOR)? "Yes" : "No"); color(DIM_WHITE); + } + scr_printf("Be unlisted in userlog: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_UNLISTED)? "Yes" : "No"); color(DIM_WHITE); + if (strlen(editor_paths[0]) > 0) { + scr_printf("Always enter messages with the full-screen editor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXTEDIT)? "Yes" : "No"); color(DIM_WHITE); + } + free(user); +} + +/* + * Display system statistics. + */ +void system_info(CtdlIPC *ipc) +{ + char buf[SIZ]; + char *resp = NULL; + size_t bytes; + int mrtg_users, mrtg_active_users; + char mrtg_server_uptime[40]; + long mrtg_himessage; + int ret; /* IPC response code */ + + /* get #users, #active & server uptime */ + ret = CtdlIPCGenericCommand(ipc, "MRTG|users", NULL, 0, &resp, &bytes, buf); + mrtg_users = extract_int(resp, 0); + remove_token(resp, 0, '\n'); + mrtg_active_users = extract_int(resp, 0); + remove_token(resp, 0, '\n'); + extract_token(mrtg_server_uptime, resp, 0, '\n', sizeof mrtg_server_uptime); + free(resp); + resp = NULL; + + /* get high message# */ + ret = CtdlIPCGenericCommand(ipc, "MRTG|messages", NULL, 0, &resp, &bytes, buf); + mrtg_himessage = extract_long(resp, 0); + free(resp); + resp = NULL; + + /* refresh server info just in case */ + CtdlIPCServerInfo(ipc, buf); + + scr_printf("You are connected to %s (%s) @%s\n", ipc->ServInfo.nodename, ipc->ServInfo.humannode, ipc->ServInfo.fqdn); + scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)REV_LEVEL/100); + scr_printf("and located in %s.\n", ipc->ServInfo.site_location); + scr_printf("Connected users %d / Active users %d / Highest message #%ld\n", mrtg_users, mrtg_active_users, mrtg_himessage); + scr_printf("Server uptime: %s\n", mrtg_server_uptime); + scr_printf("Your system administrator is %s.\n", ipc->ServInfo.sysadm); + scr_printf("Copyright (C)1987-2006 by the Citadel development team\n"); +} /* * forget all rooms on current floor @@ -2033,19 +2154,43 @@ NEWUSR: if (strlen(rc_password) == 0) { break; case 110: /* <+> Next room */ - gotoroomstep(ipc, 1); + gotoroomstep(ipc, 1, 0); break; case 111: /* <-> Previous room */ - gotoroomstep(ipc, 0); + gotoroomstep(ipc, 0, 0); break; case 112: /* <>> Next floor */ - gotofloorstep(ipc, 1); + gotofloorstep(ipc, 1, GF_GOTO); break; case 113: /* <<> Previous floor */ - gotofloorstep(ipc, 0); + gotofloorstep(ipc, 0, GF_GOTO); + break; + + case 116: /* <.> skip to <+> Next room */ + gotoroomstep(ipc, 1, 1); + break; + + case 117: /* <.> skip to <-> Previous room */ + gotoroomstep(ipc, 0, 1); + break; + + case 118: /* <.> skip to <>> Next floor */ + gotofloorstep(ipc, 1, GF_SKIP); + break; + + case 119: /* <.> skip to <<> Previous floor */ + gotofloorstep(ipc, 0, GF_SKIP); + break; + + case 114: + read_config(ipc); + break; + + case 115: + system_info(ipc); break; default: /* allow some math on the command */ diff --git a/citadel/citadel.rc b/citadel/citadel.rc index 2ad908f51..2a726fe65 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -332,6 +332,8 @@ cmd=71,0,&.,read &Last: cmd=9,0,&.,&Read,&Last five msgs cmd=14,0,&.,&Read,&Directory cmd=49,0,&.,&Read,&Info file +cmd=114,0,&.,&Read,&Configuration +cmd=115,0,&.,&Read,&System info cmd=35,0,&.,&Enter,&Password cmd=36,0,&.,&Enter,&ASCII message cmd=37,0,&.,&Enter,&Configuration @@ -382,6 +384,10 @@ cmd=110,0,&+Next room cmd=111,0,&-Previous room cmd=112,0,&>Next floor cmd=113,0,&Next floor +cmd=119,0,&.,skip to & ead nfo file Read the room info file. <.> ead io Read other users' "bio" files. - + <.> ead onfiguration Display your 'preferences'. + <.> ead ystem info Display system statistics. + Enter commands: diff --git a/citadel/messages/readopt b/citadel/messages/readopt index 6a5a4acfa..f206d172c 100644 --- a/citadel/messages/readopt +++ b/citadel/messages/readopt @@ -1,12 +1,14 @@ One of: io irectory + onfiguration ile unformatted nfo file ast five messages ew messages ld messages everse + ystem info extfile serlist file using modem diff --git a/citadel/rooms.c b/citadel/rooms.c index ca9219c79..c1a066bd0 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -248,7 +248,7 @@ void list_other_floors(void) /* * List known rooms. kn_floor_mode should be set to 0 for a 'flat' listing, - * 1 to list rooms on the current floor, or 1 to list rooms on all floors. + * 1 to list rooms on the current floor, or 2 to list rooms on all floors. */ void knrooms(CtdlIPC *ipc, int kn_floor_mode) { @@ -326,7 +326,7 @@ void listzrooms(CtdlIPC *ipc) /* Ask the server for a room list */ - r = CtdlIPCKnownRooms(ipc, UnsubscribedRooms, 1, &listing, buf); + r = CtdlIPCKnownRooms(ipc, UnsubscribedRooms, (-1), &listing, buf); if (r / 100 != 1) { listing = NULL; } @@ -649,7 +649,7 @@ void dotungoto(CtdlIPC *ipc, char *towhere) scr_printf("%s\n", buf); return; } - r = CtdlIPCSetLastRead(ipc, uglistlsn[found], buf); + r = CtdlIPCSetLastRead(ipc, uglistlsn[found] ? uglistlsn[found] : 1, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); } @@ -675,7 +675,7 @@ void ungoto(CtdlIPC *ipc) scr_printf("%s\n", buf); return; } - r = CtdlIPCSetLastRead(ipc, uglistlsn[uglistsize-1], buf); + r = CtdlIPCSetLastRead(ipc, uglistlsn[uglistsize-1] ? uglistlsn[uglistsize-1] : 1, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); } diff --git a/citadel/routines.c b/citadel/routines.c index 65798e27f..a023dafe8 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -136,11 +136,13 @@ void edituser(CtdlIPC *ipc, int cmd) } user->axlevel = intprompt("Access level", user->axlevel, 0, 6); - - user->flags = set_attr(ipc, user->flags, +/* user->flags = set_attr(ipc, user->flags, "Permission to send Internet mail", - US_INTERNET, 0); - + US_INTERNET, 0); */ + if (boolprompt("Permission to send Internet mail", (user->flags & US_INTERNET))) + user->flags |= US_INTERNET; + else + user->flags &= ~US_INTERNET; if (boolprompt("Ask user to register again", !(user->flags & US_REGIS))) user->flags &= ~US_REGIS; else diff --git a/citadel/routines2.c b/citadel/routines2.c index 5264df344..07012ab1a 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -592,7 +592,7 @@ void list_bio(CtdlIPC *ipc) pprintf("%s\n", buf); return; } - while (strlen(resp)) { + while (resp && strlen(resp)) { extract_token(buf, resp, 0, '\n', sizeof buf); remove_token(resp, 0, '\n'); if ((pos + strlen(buf) + 5) > screenwidth) { -- 2.39.2