"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/image.c" between
vnstat-2.7.tar.gz and vnstat-2.8.tar.gz

About: vnStat is a console-based network traffic monitor (using the /proc filesystem).

image.c  (vnstat-2.7):image.c  (vnstat-2.8)
skipping to change at line 346 skipping to change at line 346
} }
daybuff[0] = '\0'; daybuff[0] = '\0';
db_getdata_range(&datalist, &datainfo, ic->interface.name, listname, (uin t32_t)limit, ic->databegin, ic->dataend); db_getdata_range(&datalist, &datainfo, ic->interface.name, listname, (uin t32_t)limit, ic->databegin, ic->dataend);
datalist_i = datalist; datalist_i = datalist;
if (strlen(ic->dataend) == 0 && datainfo.count > 0 && listtype != LT_Top) { if (strlen(ic->dataend) == 0 && datainfo.count > 0 && listtype != LT_Top) {
getestimates(&e_rx, &e_tx, listtype, ic->interface.updated, &data list); getestimates(&e_rx, &e_tx, listtype, ic->interface.updated, &data list);
if (cfg.estimatestyle > 0 && e_rx + e_tx > datainfo.max) { if ((cfg.estimatestyle > 0 || cfg.barshowsrate > 0) && e_rx + e_t x > datainfo.max) {
datainfo.max = e_rx + e_tx; datainfo.max = e_rx + e_tx;
} }
estimateavailable = 1; estimateavailable = 1;
if (listtype == LT_Day || listtype == LT_Month || listtype == LT_ Year) { if (listtype == LT_Day || listtype == LT_Month || listtype == LT_ Year) {
estimatevisible = 1; estimatevisible = 1;
} }
} }
if (listtype == LT_Top) { if (listtype == LT_Top) {
if (limit > 0 && datainfo.count < (uint32_t)limit) { if (limit > 0 && datainfo.count < (uint32_t)limit) {
skipping to change at line 519 skipping to change at line 519
if (datalist_i->next == NULL && issametimeslot(listtype, datalist_i->timestamp, ic->interface.updated)) { if (datalist_i->next == NULL && issametimeslot(listtype, datalist_i->timestamp, ic->interface.updated)) {
e_secs = getperiodseconds(listtype, datalist_i->t imestamp, ic->interface.updated, 1); e_secs = getperiodseconds(listtype, datalist_i->t imestamp, ic->interface.updated, 1);
} else { } else {
e_secs = getperiodseconds(listtype, datalist_i->t imestamp, ic->interface.updated, 0); e_secs = getperiodseconds(listtype, datalist_i->t imestamp, ic->interface.updated, 0);
} }
strncat(buffer, gettrafficrate(datalist_i->rx + datalist_ i->tx, (time_t)e_secs, 14), 32); strncat(buffer, gettrafficrate(datalist_i->rx + datalist_ i->tx, (time_t)e_secs, 14), 32);
} }
gdImageString(ic->im, ic->font, textx, texty, (unsigned char *)bu ffer, ic->ctext); gdImageString(ic->im, ic->font, textx, texty, (unsigned char *)bu ffer, ic->ctext);
if (listtype == LT_Top) { if (listtype == LT_Top) {
if (cfg.ostyle > 2) { if (cfg.ostyle > 2) {
drawbar(ic, textx + (71 * ic->font->w) + 2, texty + 4, 9 * ic->font->w - 2, datalist_i->rx, datalist_i->tx, datainfo.max, 0); drawbar(ic, textx + (71 * ic->font->w) + 2, texty + 4, 9 * ic->font->w - 1, datalist_i->rx, datalist_i->tx, datainfo.max, 0);
} else { } else {
drawbar(ic, textx + (56 * ic->font->w), texty + 4 , 23 * ic->font->w + 2, datalist_i->rx, datalist_i->tx, datainfo.max, 0); drawbar(ic, textx + (56 * ic->font->w), texty + 4 , 23 * ic->font->w + 3, datalist_i->rx, datalist_i->tx, datainfo.max, 0);
} }
} else { // everything else } else { // everything else
if (cfg.ostyle > 2) { if (cfg.ostyle > 2) {
if (datalist_i->next == NULL && estimateavailable && cfg.barshowsrate) { if (datalist_i->next == NULL && estimateavailable && cfg.barshowsrate) {
drawbar(ic, textx + (67 * ic->font->w) - 2, texty + 4, 13 * ic->font->w, e_rx, e_tx, datainfo.max, 0); drawbar(ic, textx + (67 * ic->font->w) - 2, texty + 4, 13 * ic->font->w + 1, e_rx, e_tx, datainfo.max, 0);
} else { } else {
drawbar(ic, textx + (67 * ic->font->w) - 2, texty + 4, 13 * ic->font->w, datalist_i->rx, datalist_i->tx, datainfo.max, 0) ; drawbar(ic, textx + (67 * ic->font->w) - 2, texty + 4, 13 * ic->font->w + 1, datalist_i->rx, datalist_i->tx, datainfo.max , 0);
} }
} else { } else {
drawbar(ic, textx + (51 * ic->font->w) - 2, texty + 4, 28 * ic->font->w + 2, datalist_i->rx, datalist_i->tx, datainfo.max, 0); drawbar(ic, textx + (51 * ic->font->w) - 2, texty + 4, 28 * ic->font->w + 3, datalist_i->rx, datalist_i->tx, datainfo.max, 0);
} }
} }
texty += ic->lineheight + cfg.linespaceadjust; texty += ic->lineheight + cfg.linespaceadjust;
if (datalist_i->next == NULL) { if (datalist_i->next == NULL) {
texty -= cfg.linespaceadjust; texty -= cfg.linespaceadjust;
break; break;
} }
datalist_i = datalist_i->next; datalist_i = datalist_i->next;
i++; i++;
} }
skipping to change at line 571 skipping to change at line 571
if (estimatevisible) { if (estimatevisible) {
snprintf(buffer, 32, " estimated "); snprintf(buffer, 32, " estimated ");
strncat(buffer, getvalue(e_rx, 10, RT_Estimate), 32); strncat(buffer, getvalue(e_rx, 10, RT_Estimate), 32);
strcat(buffer, " "); strcat(buffer, " ");
strncat(buffer, getvalue(e_tx, 10, RT_Estimate), 32); strncat(buffer, getvalue(e_tx, 10, RT_Estimate), 32);
strcat(buffer, " "); strcat(buffer, " ");
strncat(buffer, getvalue(e_rx + e_tx, 10, RT_Estimate), 32); strncat(buffer, getvalue(e_rx + e_tx, 10, RT_Estimate), 32);
if (cfg.estimatestyle) { if (cfg.estimatestyle) {
if (cfg.ostyle > 2) { if (cfg.ostyle > 2) {
drawbar(ic, textx + (67 * ic->font->w) - 2, texty drawbar(ic, textx + (67 * ic->font->w) - 2, texty
- ic->lineheight + 4, 13 * ic->font->w, e_rx, e_tx, datainfo.max, 1); - ic->lineheight + 4, 13 * ic->font->w + 1, e_rx, e_tx, datainfo.max, 1);
drawbar(ic, textx + (67 * ic->font->w) - 2, texty drawbar(ic, textx + (67 * ic->font->w) - 2, texty
- ic->lineheight + 4, 13 * ic->font->w, datalist_i->rx, datalist_i->tx, datainf - ic->lineheight + 4, 13 * ic->font->w + 1, datalist_i->rx, datalist_i->tx, dat
o.max, 0); ainfo.max, 0);
} else { } else {
drawbar(ic, textx + (51 * ic->font->w) - 2, texty drawbar(ic, textx + (51 * ic->font->w) - 2, texty
- ic->lineheight + 4, 28 * ic->font->w + 2, e_rx, e_tx, datainfo.max, 1); - ic->lineheight + 4, 28 * ic->font->w + 3, e_rx, e_tx, datainfo.max, 1);
drawbar(ic, textx + (51 * ic->font->w) - 2, texty drawbar(ic, textx + (51 * ic->font->w) - 2, texty
- ic->lineheight + 4, 28 * ic->font->w + 2, datalist_i->rx, datalist_i->tx, dat - ic->lineheight + 4, 28 * ic->font->w + 3, datalist_i->rx, datalist_i->tx, dat
ainfo.max, 0); ainfo.max, 0);
} }
} }
/* sum visible */ /* sum visible */
} else if (strlen(ic->dataend) > 0 && datainfo.count > 1 && listtype != L T_Top) { } else if (strlen(ic->dataend) > 0 && datainfo.count > 1 && listtype != L T_Top) {
if (datainfo.count < 100) { if (datainfo.count < 100) {
snprintf(datebuff, 16, "sum of %" PRIu32 "", datainfo.cou nt); snprintf(datebuff, 16, "sum of %" PRIu32 "", datainfo.cou nt);
} else { } else {
snprintf(datebuff, 16, "sum"); snprintf(datebuff, 16, "sum");
} }
skipping to change at line 705 skipping to change at line 705
d = localtime(&ic->interface.created); d = localtime(&ic->interface.created);
strftime(datebuff, 16, cfg.tformat, d); strftime(datebuff, 16, cfg.tformat, d);
snprintf(daytemp, 24, "since %s", datebuff); snprintf(daytemp, 24, "since %s", datebuff);
snprintf(buffer, 32, "%23s", daytemp); snprintf(buffer, 32, "%23s", daytemp);
gdImageString(ic->im, ic->font, x - 8 * ic->font->w, y + (5 * ic->linehei ght) + 10 + (ic->large * 4), (unsigned char *)buffer, ic->ctext); gdImageString(ic->im, ic->font, x - 8 * ic->font->w, y + (5 * ic->linehei ght) + 10 + (ic->large * 4), (unsigned char *)buffer, ic->ctext);
} }
void drawsummary_digest(IMAGECONTENT *ic, const int x, const int y, const char * mode) void drawsummary_digest(IMAGECONTENT *ic, const int x, const int y, const char * mode)
{ {
int textx, texty, offset = 0; int textx, texty, offset = 0;
double rxp = 50, txp = 50, mod; double rxp, txp, mod;
char buffer[512], datebuff[16], daytemp[32]; char buffer[512], datebuff[16], daytemp[32];
time_t yesterday; time_t yesterday;
struct tm *d = NULL; struct tm *d = NULL;
dbdatalist *datalist = NULL; dbdatalist *datalist = NULL;
dbdatalist *data_current = NULL, *data_previous = NULL; dbdatalist *data_current = NULL, *data_previous = NULL;
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
gdFontPtr titlefont; gdFontPtr titlefont;
if (ic->large) { if (ic->large) {
titlefont = gdFontGetGiant(); titlefont = gdFontGetGiant();
skipping to change at line 915 skipping to change at line 915
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
gdFontPtr font; gdFontPtr font;
if (ic->large) { if (ic->large) {
font = gdFontGetSmall(); font = gdFontGetSmall();
} else { } else {
font = gdFontGetTiny(); font = gdFontGetTiny();
} }
if (!db_getdata(&datalist, &datainfo, ic->interface.name, "fiveminute", ( uint32_t)resultcount) || datainfo.count == 0) { if (!db_getdata(&datalist, &datainfo, ic->interface.name, "fiveminute", ( uint32_t)resultcount) || datainfo.count == 0) {
gdImageString(ic->im, ic->font, x + 330 - (8 * ic->font->w), y - x = (resultcount + FIVEMINEXTRASPACE + (ic->large * 14)) / 2 - (8
(height / 2) - ic->font->h, (unsigned char *)"no data available", ic->ctext); * ic->font->w + ic->font->w / 2);
gdImageString(ic->im, ic->font, x, y - (height / 2) - ic->font->h
, (unsigned char *)"no data available", ic->ctext);
return 0; return 0;
} }
datalist_i = datalist; datalist_i = datalist;
if (cfg.rateunit) { if (cfg.rateunit) {
ratediv = 37.5; /* x * 8 / 300 */ ratediv = 37.5; /* x * 8 / 300 */
} else { } else {
ratediv = 300; ratediv = 300;
} }
skipping to change at line 973 skipping to change at line 974
s = (int)lrint(((double)scaleunit / (double)max) * t); s = (int)lrint(((double)scaleunit / (double)max) * t);
if (s == 0) { if (s == 0) {
s = 1; // force to show something when there's not much or any tr affic, scale is likely to be wrong in this case s = 1; // force to show something when there's not much or any tr affic, scale is likely to be wrong in this case
} }
while (s * step < SCALEMINPIXELS) { while (s * step < SCALEMINPIXELS) {
step++; step++;
} }
if (debug) { if (debug) {
printf("maxrx: %lu\n", datainfo.maxrx); printf("maxrx: %" PRIu64 "\n", datainfo.maxrx);
printf("maxtx: %lu\n", datainfo.maxtx); printf("maxtx: %" PRIu64 "\n", datainfo.maxtx);
printf("rxh: %d txh: %d\n", rxh, txh); printf("rxh: %d txh: %d\n", rxh, txh);
printf("max divided: %lu\n", max); printf("max divided: %" PRIu64 "\n", max);
printf("scaleunit: %lu\nstep: %d\n", scaleunit, step); printf("scaleunit: %" PRIu64 "\nstep: %d\n", scaleunit, step);
printf("pixels per step: %d\n", s); printf("pixels per step: %d\n", s);
printf("mintime: %lu\nmaxtime: %lu\n", (uint64_t)datainfo.mintime , (uint64_t)datainfo.maxtime); printf("mintime: %" PRIu64 "\nmaxtime: %" PRIu64 "\n", (uint64_t) datainfo.mintime, (uint64_t)datainfo.maxtime);
printf("count: %u\n", datainfo.count); printf("count: %u\n", datainfo.count);
} }
/* upper part scale values */ /* upper part scale values */
y--; // adjust to start above center line y--; // adjust to start above center line
for (i = step; i * s <= rxh; i = i + step) { for (i = step; i * s <= rxh; i = i + step) {
gdImageDashedLine(ic->im, x, y - (i * s), x + (resultcount + FIVE MINWIDTHPADDING), y - (i * s), ic->cline); gdImageDashedLine(ic->im, x, y - (i * s), x + (resultcount + FIVE MINWIDTHPADDING), y - (i * s), ic->cline);
gdImageDashedLine(ic->im, x, y - prev - (step * s) / 2, x + (resu ltcount + FIVEMINWIDTHPADDING), y - prev - (step * s) / 2, ic->clinel); gdImageDashedLine(ic->im, x, y - prev - (step * s) / 2, x + (resu ltcount + FIVEMINWIDTHPADDING), y - prev - (step * s) / 2, ic->clinel);
gdImageString(ic->im, font, x - 21 - (ic->large * 3), y - 3 - (i * s) - (ic->large * 3), (unsigned char *)getimagevalue(scaleunit * (unsigned int )i, 3, rate), ic->ctext); gdImageString(ic->im, font, x - 21 - (ic->large * 3), y - 3 - (i * s) - (ic->large * 3), (unsigned char *)getimagevalue(scaleunit * (unsigned int )i, 3, rate), ic->ctext);
prev = i * s; prev = i * s;
skipping to change at line 1018 skipping to change at line 1019
y--; // y is now back on center line y--; // y is now back on center line
/* scale text */ /* scale text */
gdImageStringUp(ic->im, font, x - 39 - (ic->large * 14), ypos - height / 2 + (rate * 10), (unsigned char *)getimagescale(scaleunit * (unsigned int)step, rate), ic->ctext); gdImageStringUp(ic->im, font, x - 39 - (ic->large * 14), ypos - height / 2 + (rate * 10), (unsigned char *)getimagescale(scaleunit * (unsigned int)step, rate), ic->ctext);
timestamp = datainfo.maxtime - (resultcount * 300); timestamp = datainfo.maxtime - (resultcount * 300);
while (datalist_i != NULL && datalist_i->timestamp < timestamp + 300) { while (datalist_i != NULL && datalist_i->timestamp < timestamp + 300) {
if (debug) { if (debug) {
printf("Skip data, %lu < %lu\n", datalist_i->timestamp, t imestamp + 300); printf("Skip data, %" PRIu64 " < %" PRIu64 "\n", (uint64_ t)datalist_i->timestamp, (uint64_t)timestamp + 300);
} }
datalist_i = datalist_i->next; datalist_i = datalist_i->next;
} }
for (i = 0; i < resultcount; i++) { for (i = 0; i < resultcount; i++) {
if (datalist_i == NULL) { if (datalist_i == NULL) {
break; break;
} }
 End of changes. 14 change blocks. 
25 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)