1 /* disp.c: BetaFTPD full-screen stats
2 Copyright (C) 1999-2000 Steinar H. Gunderson
4 This program is is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2 if the
6 License as published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <sys/types.h>
31 #include <netinet/in.h>
45 time_t last_update = 0;
47 void update_display(const struct conn * const first_conn)
49 struct conn *c = first_conn->next_conn;
54 if (now - last_update < 1) return;
57 printf("%c[H", (char)27); /* clear the screen */
58 printf("%c[44m \n", (char)27);
59 printf("%c[44m \n", (char)27);
60 printf("%c[38m BetaFTPD FTP server \n", (char)27);
61 printf("%c[44m \n", (char)27);
62 printf("%c[44m \n", (char)27);
63 printf("%c[40m", (char)27);
64 while (c != NULL && ++i < 20) {
65 const struct ftran * const f = c->transfer;
66 printf("%4u ", c->sock);
68 printf("%-16s %-50s\n", c->username, c->last_cmd);
70 char trunc_filename[256];
71 strcpy(trunc_filename, f->filename);
72 trunc_filename[22] = 0;
76 printf("%-16s%-22s%12lu %7.2fkb/s (upl)\n", c->username,
77 trunc_filename, f->size, (float)(f->pos - c->rest_pos) /
78 (float)(difftime(now, f->tran_start)) / 1024);
81 printf("%-16s%-22s%12lu %7.2fkb/s %.2f%%\n", c->username,
82 trunc_filename, f->size, (float)(f->pos - c->rest_pos) /
83 (float)(difftime(now, f->tran_start)) / 1024,
84 (float)(f->pos) / (float)(f->size) * 100.0f);