1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-03-20 01:52:23 +00:00

Merge branch 'master' of git://nwl.cc/~n0-1/conky

This commit is contained in:
Brenden Matthews 2008-12-17 17:03:33 -07:00
commit 35a2d09c5f
2 changed files with 16 additions and 15 deletions

View File

@ -1,3 +1,6 @@
2008-12-17
* Make gateway objects also detect routes with missing RTF_GATEWAY flag
2008-12-15 2008-12-15
* Have a maximum width for all variable length mpd vars * Have a maximum width for all variable length mpd vars
* Patch to allow escaping newlines in the config (thanks Itai) * Patch to allow escaping newlines in the config (thanks Itai)

View File

@ -272,6 +272,10 @@ void update_gateway_info_failure(const char *reason)
info.gw_info.ip = strndup("failed", text_buffer_size); info.gw_info.ip = strndup("failed", text_buffer_size);
} }
/* Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT */
#define RT_ENTRY_FORMAT "%63s %lx %lx %x %*d %*d %*d %lx %*d %*d %*d\n"
void update_gateway_info(void) void update_gateway_info(void)
{ {
FILE *fp; FILE *fp;
@ -279,7 +283,6 @@ void update_gateway_info(void)
char iface[64]; char iface[64];
unsigned long dest, gate, mask; unsigned long dest, gate, mask;
unsigned int flags; unsigned int flags;
short ref, use, metric, mtu, win, irtt;
struct gateway_info *gw_info = &info.gw_info; struct gateway_info *gw_info = &info.gw_info;
@ -291,22 +294,17 @@ void update_gateway_info(void)
update_gateway_info_failure("fopen()"); update_gateway_info_failure("fopen()");
return; return;
} }
if (fscanf(fp, "%*[^\n]\n") == EOF) {
//NULL because a empty table is not a error /* skip over the table header line, which is always present */
update_gateway_info_failure(NULL); fscanf(fp, "%*[^\n]\n");
fclose(fp);
return;
}
while (!feof(fp)) { while (!feof(fp)) {
// Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT if(fscanf(fp, RT_ENTRY_FORMAT,
if(fscanf(fp, "%63s %lx %lx %x %hd %hd %hd %lx %hd %hd %hd\n", iface, &dest, &gate, &flags, &mask) != 5) {
iface, &dest, &gate, &flags, &ref, &use,
&metric, &mask, &mtu, &win, &irtt) != 11) {
update_gateway_info_failure("fscanf()"); update_gateway_info_failure("fscanf()");
fclose(fp); break;
return;
} }
if (flags & RTF_GATEWAY && dest == 0 && mask == 0) { if (!(dest || mask) && ((flags & RTF_GATEWAY) || !gate) ) {
gw_info->count++; gw_info->count++;
SAVE_SET_STRING(gw_info->iface, iface) SAVE_SET_STRING(gw_info->iface, iface)
ina.s_addr = gate; ina.s_addr = gate;