Skip to content

Commit 683de53

Browse files
committed
node.c: Make node printout more compact.
Since not all nodes have menu/location, but a lot of space was allocated to printing this, move this to the end of the line and make it not fixed width anymore. In many cases, depending on terminal width, this is enough to make each node listing take up just one line instead of two.
1 parent 5201d13 commit 683de53

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bbs/node.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -862,23 +862,20 @@ static int cli_nodes(struct bbs_cli_args *a)
862862
int c = 0;
863863
time_t now = time(NULL);
864864

865-
bbs_dprintf(a->fdout, "%3s %9s %9s %-15s %-25s"
865+
bbs_dprintf(a->fdout, "%3s %9s %9s %-15s"
866866
" %15s %5s %7s %3s %3s %3s %3s"
867867
" %3s %3s %3s"
868868
" %1s %1s %1s"
869-
" %7s %8s %4s %5s %6s %6s %4s"
869+
" %7s %8s %4s %5s %6s %6s %4s %s"
870870
"\n",
871-
"#", "PROTOCOL", "ELAPSED", "USER", "MENU/PAGE/LOCATION",
871+
"#", "PROTOCOL", "ELAPSED", "USER",
872872
"IP ADDRESS", "RPORT", "TID", "SFD", "FD", "RFD", "WFD",
873873
"MST", "SLV", "SPY",
874874
"E", "B", "!",
875-
"TRM SZE", "TYPE", "ANSI", "SPEED", "BPS", "(RPT)", "SLOW");
875+
"TRM SZE", "TYPE", "ANSI", "SPEED", "BPS", "(RPT)", "SLOW", "MENU/PG/LOC.");
876876

877877
RWLIST_RDLOCK(&nodes);
878878
RWLIST_TRAVERSE(&nodes, n, entry) {
879-
char menufull[26];
880-
char termsize[8];
881-
char speed[NODE_SPEED_BUFSIZ_SMALL];
882879
int lwp;
883880
/* Do not lock the node here.
884881
* Even though we are accessing some properties of the node which could change,
@@ -889,25 +886,28 @@ static int cli_nodes(struct bbs_cli_args *a)
889886
* besides the node thread tries to write to it, that could cause that thread to
890887
* block waiting on the lock, causing a cascading deadlock. */
891888
print_time_elapsed(n->created, now, elapsed, sizeof(elapsed));
892-
snprintf(menufull, sizeof(menufull), "%s%s%s%s", S_IF(n->menu), n->menuitem ? " (" : "", S_IF(n->menuitem), n->menuitem ? ")" : "");
893889
lwp = bbs_pthread_tid(n->thread);
894890

895-
bbs_dprintf(a->fdout, "%3d %9s %9s %-15s %-25s"
891+
bbs_dprintf(a->fdout, "%3d %9s %9s %-15s"
896892
" %15s %5u %7d %3d %3d %3d %3d",
897-
n->id, n->protname, elapsed, bbs_username(n->user), menufull,
893+
n->id, n->protname, elapsed, bbs_username(n->user),
898894
n->ip, n->rport, lwp, n->sfd, n->fd, n->rfd, n->wfd);
899895
if (NODE_INTERACTIVE(n)) {
896+
char menufull[26];
897+
char termsize[8];
898+
char speed[NODE_SPEED_BUFSIZ_SMALL];
900899
/* If the size is speculative, put a '?' afterwards */
901900
snprintf(termsize, sizeof(termsize), "%dx%d%s", n->cols, n->rows, n->dimensions ? "" : "?");
901+
snprintf(menufull, sizeof(menufull), "%s%s%s%s", S_IF(n->menu), n->menuitem ? " (" : "", S_IF(n->menuitem), n->menuitem ? ")" : "");
902902
bbs_node_format_speed(n, speed, sizeof(speed));
903903
bbs_dprintf(a->fdout,
904904
" %3d %3d %3d"
905905
" %1s %1s %1s"
906-
" %7s %8s %4s %5s %6u %6u %4s"
906+
" %7s %8s %4s %5s %6u %6u %4s %s"
907907
"\n",
908908
n->amaster, n->slavefd, n->spyfd,
909909
BBS_YN(n->echo), BBS_YN(n->buffered), bbs_node_interrupted(n) ? "*" : "",
910-
termsize, S_IF(n->term), BBS_YESNO(n->ansi), speed, n->bps, n->reportedbps, BBS_YN(n->slow));
910+
termsize, S_IF(n->term), BBS_YESNO(n->ansi), speed, n->bps, n->reportedbps, BBS_YN(n->slow), menufull);
911911
} else {
912912
bbs_dprintf(a->fdout, "\n");
913913
}

0 commit comments

Comments
 (0)