From 4e24d12860437059e37688792f6a121dea367ff5 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 15 Jul 2002 11:58:32 +0000 Subject: [PATCH] Explicitly set stdio buffer for /dev/isdninfo to 2048, as it has happened that stdio used 1024, and /dev/isdninfo doesn't support partial reads (0 bytes are returned). Usually not a problem, but with more than one channel connected, a line of > 1024 bytes is returned. Also optimized the curses usage a bit, explicitly writing spaces so that background colours are set correctly everywhere. Bumped displayed version to 2.2. --- imon/imon.c | 123 +++++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 58 deletions(-) diff --git a/imon/imon.c b/imon/imon.c index 20bf1f50..afb45091 100644 --- a/imon/imon.c +++ b/imon/imon.c @@ -1,4 +1,4 @@ -/* $Id: imon.c,v 1.5 2001/08/22 11:12:00 paul Exp $ +/* $Id: imon.c,v 1.6 2002/07/15 11:58:32 paul Exp $ * * iMON , extended version. * original iMON source (c) Michael Knigge @@ -19,6 +19,16 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: imon.c,v $ + * Revision 1.6 2002/07/15 11:58:32 paul + * Explicitly set stdio buffer for /dev/isdninfo to 2048, as it has + * happened that stdio used 1024, and /dev/isdninfo doesn't support + * partial reads (0 bytes are returned). Usually not a problem, but + * with more than one channel connected, a line of > 1024 bytes is + * returned. + * Also optimized the curses usage a bit, explicitly writing spaces + * so that background colours are set correctly everywhere. + * Bumped displayed version to 2.2. + * * Revision 1.5 2001/08/22 11:12:00 paul * imon wasn't devfs-compliant yet. * @@ -90,12 +100,12 @@ static FILE *isdninfo; static int color; static char *phonebook; static struct phone_entry *phones; -static char idmap_line[4096]; -static char chmap_line[4096]; -static char drmap_line[4096]; -static char usage_line[4096]; -static char flags_line[4096]; -static char phone_line[4096]; +static char idmap_line[2048]; +static char chmap_line[2048]; +static char drmap_line[2048]; +static char usage_line[2048]; +static char flags_line[2048]; +static char phone_line[2048]; WINDOW *statwin; WINDOW *stathdr; @@ -198,14 +208,14 @@ static void readphonebook() { */ char *find_name(char *num) { struct phone_entry *p = phones; - static char tmp[100]; + static char tmp[30]; - sprintf(tmp, "%-28s", num); + sprintf(tmp, "%-28.28s", num); if (!show_names) return(tmp); while (p) { if (wildmat(num, p->phone)) { - sprintf(tmp, "%-28s", p->name); + sprintf(tmp, "%-28.28s", p->name); break; } p = p->next; @@ -229,7 +239,7 @@ void cleanup(int dummy) { void usage(void) { fprintf(stderr,"usage: imon [-q][-p PhoneBookFile]\n"); - exit(-1); + exit(1); } /* @@ -279,7 +289,7 @@ int imon_draw_mask(int color) { move(line, 0); addch(ACS_VLINE); for(col=2; coltm_hour,now->tm_min,now->tm_sec); if (color == TRUE) attron(COLOR_PAIR(YELLOW_ON_BLUE)); - mvaddstr(1, COLS-10, temp); + now = localtime(current_time); + mvprintw(1, COLS-21, "%04d-%02d-%02d %02d:%02d:%02d", now->tm_year+1900, now->tm_mon+1, now->tm_mday, now->tm_hour,now->tm_min,now->tm_sec); prefresh(stathdr, 0, stat_x, 3, 2, 5, COLS-3); prefresh(statwin, stat_y, stat_x, 5, 2, LINES-5, COLS-3); return(TRUE); @@ -489,6 +493,7 @@ int main(int argc, char **argv) { int quit , i; fd_set fdset; struct timeval timeout; + static char fbuf[2048]; /* * check parameters @@ -519,6 +524,8 @@ int main(int argc, char **argv) { return 1; } } + setvbuf(isdninfo, fbuf, _IOFBF, sizeof(fbuf)); /* up to 2048 needed */ + if (phonebook) readphonebook();