Some simplification / cleanup in dcc_glist().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@429 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
39
source/dcc.c
39
source/dcc.c
@@ -2373,7 +2373,6 @@ int count = 0;
|
|||||||
DCC_List *c;
|
DCC_List *c;
|
||||||
char stats[80];
|
char stats[80];
|
||||||
char kilobytes[20];
|
char kilobytes[20];
|
||||||
int barlen = BAR_LENGTH;
|
|
||||||
double barsize = 0.0;
|
double barsize = 0.0;
|
||||||
char spec[BIG_BUFFER_SIZE];
|
char spec[BIG_BUFFER_SIZE];
|
||||||
char *filename, *p;
|
char *filename, *p;
|
||||||
@@ -2539,12 +2538,12 @@ char *filename, *p;
|
|||||||
seconds = minutes = perc = 0;
|
seconds = minutes = perc = 0;
|
||||||
|
|
||||||
iperc = ((int)perc) / 10;
|
iperc = ((int)perc) / 10;
|
||||||
barsize = ((double) (n->filesize)) / (double) barlen;
|
barsize = ((double) (n->filesize)) / (double) BAR_LENGTH;
|
||||||
|
|
||||||
size = (int) ((double) bytes / (double)barsize);
|
size = (int) ((double) bytes / (double)barsize);
|
||||||
|
|
||||||
if (n->filesize == 0)
|
if (n->filesize == 0)
|
||||||
size = barlen;
|
size = BAR_LENGTH;
|
||||||
sprintf(stats, "%4.1f", perc);
|
sprintf(stats, "%4.1f", perc);
|
||||||
if (!get_int_var(DCC_BAR_TYPE_VAR))
|
if (!get_int_var(DCC_BAR_TYPE_VAR))
|
||||||
sprintf(spec, "%s %s%s %02d:%02d", get_bar_percent(iperc), stats, "%%", minutes, seconds);
|
sprintf(spec, "%s %s%s %02d:%02d", get_bar_percent(iperc), stats, "%%", minutes, seconds);
|
||||||
@@ -2570,31 +2569,27 @@ char *filename, *p;
|
|||||||
strip_path(filename)));
|
strip_path(filename)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This prints the second DCC stat line, if DCC_BAR_TYPE is non-zero. */
|
||||||
if (do_hook(DCC_STATF1_LIST, "%s %lu %lu %d %d", stats, (unsigned long)bytes, (unsigned long)n->filesize, minutes, seconds))
|
if (do_hook(DCC_STATF1_LIST, "%s %lu %lu %d %d", stats, (unsigned long)bytes, (unsigned long)n->filesize, minutes, seconds))
|
||||||
{
|
{
|
||||||
char *bar_end, *c;
|
char *stat_ptr, *spec_ptr;
|
||||||
if (!get_int_var(DCC_BAR_TYPE_VAR))
|
if (!get_int_var(DCC_BAR_TYPE_VAR))
|
||||||
continue;
|
continue;
|
||||||
memset(spec, 0, 500);
|
|
||||||
sprintf(stats, "%4.1f%% (%lu of %lu bytes)", perc, (unsigned long)bytes, (unsigned long)n->filesize);
|
snprintf(stats, sizeof stats, "%4.1f%% (%lu of %lu bytes)",
|
||||||
strcpy( spec, "\002[\026");
|
perc, (unsigned long)bytes, (unsigned long)n->filesize);
|
||||||
sprintf(spec+3, "%*s", size+1, space);
|
snprintf(spec, sizeof spec, BOLD_TOG_STR "["
|
||||||
bar_end = spec + strlen(spec);
|
REV_TOG_STR "%*.*s" REV_TOG_STR "%*.*s]" BOLD_TOG_STR
|
||||||
sprintf(bar_end, "%*s", barlen-size+1, space);
|
" ETA " BOLD_TOG_STR "%02d:%02d",
|
||||||
if (size <= barlen)
|
size, size, space, BAR_LENGTH - size, BAR_LENGTH - size,
|
||||||
|
space, minutes, seconds);
|
||||||
|
spec_ptr = spec + 3 + (BAR_LENGTH - strlen(stats)) / 2;
|
||||||
|
for (stat_ptr = stats; *stat_ptr && *spec_ptr; spec_ptr++)
|
||||||
{
|
{
|
||||||
memmove(bar_end+1, bar_end, strlen(bar_end));
|
if (*spec_ptr != REV_TOG && *spec_ptr != BOLD_TOG)
|
||||||
*bar_end = '\026';
|
*spec_ptr = *stat_ptr++;
|
||||||
}
|
}
|
||||||
strcat(spec, "]\002 ETA \002%02d:%02d\002");
|
put_it("%s", spec);
|
||||||
bar_end = (spec+(((BAR_LENGTH+2) / 2) - (strlen(stats) / 2)));
|
|
||||||
for (c = stats;*c; bar_end++)
|
|
||||||
{
|
|
||||||
if (*bar_end == '\026' || *bar_end == '\002')
|
|
||||||
continue;
|
|
||||||
*bar_end = *c++;
|
|
||||||
}
|
|
||||||
put_it(spec, minutes, seconds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user