mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
Added wireless_link_qual_perc. Cleaned unused variables from wireless code. Updated prss source. Had 6 hours of sleep.
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@898 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
f5c69ca5a5
commit
602998c06d
24
src/conky.c
24
src/conky.c
@ -96,6 +96,9 @@ static void print_version()
|
||||
#ifdef RSS
|
||||
" * rss\n"
|
||||
#endif /* RSS */
|
||||
#ifdef HAVE_IWLIB
|
||||
" * wireless\n"
|
||||
#endif
|
||||
"\n");
|
||||
|
||||
exit(0);
|
||||
@ -1004,10 +1007,11 @@ enum text_object_type {
|
||||
OBJ_wireless_essid,
|
||||
OBJ_wireless_mode,
|
||||
OBJ_wireless_bitrate,
|
||||
OBJ_wireless_ap,
|
||||
OBJ_wireless_link_qual,
|
||||
OBJ_wireless_link_qual_max,
|
||||
OBJ_wireless_link_qual_perc,
|
||||
OBJ_wireless_link_bar,
|
||||
OBJ_wireless_ap,
|
||||
#endif /* __linux__ */
|
||||
OBJ_if_empty,
|
||||
OBJ_if_existing,
|
||||
@ -2184,16 +2188,16 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_mode: needs an argument");
|
||||
END OBJ(wireless_ap, INFO_NET)
|
||||
if(arg)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_ap: needs an argument");
|
||||
END OBJ(wireless_bitrate, INFO_NET)
|
||||
if(arg)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_bitrate: needs an argument");
|
||||
END OBJ(wireless_ap, INFO_NET)
|
||||
if(arg)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_ap: needs an argument");
|
||||
END OBJ(wireless_link_qual, INFO_NET)
|
||||
if(arg)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
@ -2204,6 +2208,11 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_link_qual_max: needs an argument");
|
||||
END OBJ(wireless_link_qual_perc, INFO_NET)
|
||||
if(arg)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
else
|
||||
CRIT_ERR("wireless_link_qual_perc: needs an argument");
|
||||
END OBJ(wireless_link_bar, INFO_NET)
|
||||
if(arg) {
|
||||
arg = scan_bar(arg, &obj->a, &obj->b);
|
||||
@ -3548,6 +3557,9 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
OBJ(wireless_link_qual_max) {
|
||||
snprintf(p, p_max_size, "%d", obj->data.net->link_qual_max);
|
||||
}
|
||||
OBJ(wireless_link_qual_perc) {
|
||||
snprintf(p, p_max_size, "%.0f%%", (double)obj->data.net->link_qual / obj->data.net->link_qual_max * 100);
|
||||
}
|
||||
OBJ(wireless_link_bar) {
|
||||
new_bar(p, obj->a, obj->b, ((double)obj->data.net->link_qual/obj->data.net->link_qual_max)*255.0);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ inline void update_net_stats()
|
||||
|
||||
#ifdef HAVE_IWLIB
|
||||
// wireless info variables
|
||||
int skfd, has_bitrate = 0, link_qual = 0, link_qual_max = 0;
|
||||
int skfd, has_bitrate = 0;
|
||||
struct wireless_info *winfo;
|
||||
struct iwreq wrq;
|
||||
#endif
|
||||
|
41
src/prss.c
41
src/prss.c
@ -52,6 +52,7 @@ void prss_free(PRSS* data)
|
||||
if (!data)
|
||||
return;
|
||||
xmlFreeDoc(data->_data);
|
||||
free(data->version);
|
||||
free(data->items);
|
||||
free(data);
|
||||
}
|
||||
@ -77,17 +78,17 @@ static inline void read_item(PRSS_Item* res, xmlNodePtr data)
|
||||
if (!child)
|
||||
continue;
|
||||
|
||||
if (!strcmp((char*)data->name, "title")) {
|
||||
if (!strcasecmp((char*)data->name, "title")) {
|
||||
res->title = (char*)child->content;
|
||||
} else if (!strcmp((char*)data->name, "link")) {
|
||||
} else if (!strcasecmp((char*)data->name, "link")) {
|
||||
res->link = (char*)child->content;
|
||||
} else if (!strcmp((char*)data->name, "description")) {
|
||||
} else if (!strcasecmp((char*)data->name, "description")) {
|
||||
res->description = (char*)child->content;
|
||||
} else if (!strcmp((char*)data->name, "category")) {
|
||||
} else if (!strcasecmp((char*)data->name, "category")) {
|
||||
res->category = (char*)child->content;
|
||||
} else if (!strcmp((char*)data->name, "pubDate")) {
|
||||
} else if (!strcasecmp((char*)data->name, "pubDate")) {
|
||||
res->pubdate = (char*)child->content;
|
||||
} else if (!strcmp((char*)data->name, "guid")) {
|
||||
} else if (!strcasecmp((char*)data->name, "guid")) {
|
||||
res->guid = (char*)child->content;
|
||||
}
|
||||
}
|
||||
@ -100,27 +101,31 @@ static inline void read_element(PRSS* res, xmlNodePtr n)
|
||||
if (!child)
|
||||
return;
|
||||
|
||||
if (!strcmp((char*)n->name, "title")) {
|
||||
if (!strcasecmp((char*)n->name, "title")) {
|
||||
res->title = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "link")) {
|
||||
} else if (!strcasecmp((char*)n->name, "link")) {
|
||||
res->link = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "description")) {
|
||||
} else if (!strcasecmp((char*)n->name, "description")) {
|
||||
res->description = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "language")) {
|
||||
} else if (!strcasecmp((char*)n->name, "language")) {
|
||||
res->language = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "pubDate")) {
|
||||
} else if (!strcasecmp((char*)n->name, "pubDate")) {
|
||||
res->pubdate = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "lastBuildDate")) {
|
||||
} else if (!strcasecmp((char*)n->name, "lastBuildDate")) {
|
||||
res->lastbuilddate = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "generator")) {
|
||||
} else if (!strcasecmp((char*)n->name, "generator")) {
|
||||
res->generator = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "docs")) {
|
||||
} else if (!strcasecmp((char*)n->name, "docs")) {
|
||||
res->docs = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "managingEditor")) {
|
||||
} else if (!strcasecmp((char*)n->name, "managingEditor")) {
|
||||
res->managingeditor = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "webMaster")) {
|
||||
} else if (!strcasecmp((char*)n->name, "webMaster")) {
|
||||
res->webmaster = (char*)child->content;
|
||||
} else if (!strcmp((char*)n->name, "item")) {
|
||||
} else if (!strcasecmp((char*)n->name, "copyright")) {
|
||||
res->copyright = (char*)child->content;
|
||||
} else if (!strcasecmp((char*)n->name, "ttl")) {
|
||||
res->ttl = (char*)child->content;
|
||||
} else if (!strcasecmp((char*)n->name, "item")) {
|
||||
read_item(&res->items[res->item_count++], n->children);
|
||||
}
|
||||
}
|
||||
@ -141,6 +146,7 @@ static inline int parse_rss_2_0(PRSS* res, xmlNodePtr root)
|
||||
if (n->type==XML_ELEMENT_NODE && !strcmp((char*)n->name, "item"))
|
||||
++items;
|
||||
|
||||
res->version = strdup("2.0");
|
||||
res->items = malloc(items*sizeof(PRSS_Item));
|
||||
res->item_count = 0;
|
||||
|
||||
@ -167,6 +173,7 @@ static inline int parse_rss_1_0(PRSS* res, xmlNodePtr root)
|
||||
}
|
||||
}
|
||||
|
||||
res->version = strdup("1.0");
|
||||
res->items = malloc(items*sizeof(PRSS_Item));
|
||||
res->item_count = 0;
|
||||
|
||||
|
@ -31,6 +31,7 @@ typedef struct PRSS_Item_ {
|
||||
|
||||
typedef struct PRSS_ {
|
||||
xmlDocPtr _data;
|
||||
char* version;
|
||||
|
||||
char* title;
|
||||
char* link;
|
||||
@ -42,6 +43,8 @@ typedef struct PRSS_ {
|
||||
char* docs;
|
||||
char* lastbuilddate;
|
||||
char* pubdate;
|
||||
char* copyright;
|
||||
char* ttl;
|
||||
|
||||
PRSS_Item* items;
|
||||
int item_count;
|
||||
|
Loading…
Reference in New Issue
Block a user