--- projects/libstatgrab/src/saidar/saidar.c 2004/11/07 12:36:04 1.32 +++ projects/libstatgrab/src/saidar/saidar.c 2005/09/07 14:15:40 1.34 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: saidar.c,v 1.32 2004/11/07 12:36:04 ats Exp $ + * $Id: saidar.c,v 1.34 2005/09/07 14:15:40 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -69,8 +69,14 @@ stats_t stats; char *size_conv(long long number){ char type[] = {'B', 'K', 'M', 'G', 'T'}; int x=0; + int sign=1; static char string[10]; + if(number < 0){ + sign=-1; + number=-number; + } + for(;x<5;x++){ if( (number/1024) < (100)) { break; @@ -78,7 +84,9 @@ char *size_conv(long long number){ number = (number/1024); } - snprintf(string, 10, "%lld%c", number, type[x]); + number = number*sign; + + snprintf(string, 10, "%lld%c", number, type[x]); return string; } @@ -327,8 +335,11 @@ void display_data(){ r=0; w=0; for(counter=0;counterdisk_name, sizeof(name)); + name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */ move(line, 0); - printw("%s", disk_io_stat_ptr->disk_name); + printw("%s", name); move(line, 12); rt = (disk_io_stat_ptr->systime)? (disk_io_stat_ptr->read_bytes/disk_io_stat_ptr->systime): disk_io_stat_ptr->read_bytes; printw("%7s", size_conv(rt)); @@ -354,8 +365,11 @@ void display_data(){ /* Network */ network_stat_ptr = stats.network_io_stats; for(counter=0;counterinterface_name, sizeof(name)); + name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */ move(line, 42); - printw("%s", network_stat_ptr->interface_name); + printw("%s", name); move(line, 62); rt = (network_stat_ptr->systime)? (network_stat_ptr->rx / network_stat_ptr->systime): network_stat_ptr->rx; printw("%7s", size_conv(rt)); @@ -372,8 +386,11 @@ void display_data(){ /* Disk */ disk_stat_ptr = stats.fs_stats; for(counter=0;countermnt_point, sizeof(name)); + name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */ move(line, 42); - printw("%s", disk_stat_ptr->mnt_point); + printw("%s", name); move(line, 62); printw("%7s", size_conv(disk_stat_ptr->avail)); move(line, 73);