1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 20:11:11 +00:00

Added support for EVE-Online skill monitoring (thanks Asbjørn); fixed up/downspeedgraph segfault

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1197 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2008-06-28 20:14:04 +00:00
parent 66079c5585
commit 896863e2d8
11 changed files with 1750 additions and 1190 deletions

View File

@ -19,6 +19,9 @@ affinity <affy at users dot sourceforge dot net>
akash <akash at users dot sourceforge dot net>
battery_percent and battery_bar
Asbjørn Zweidorff Kjær <bunjiboys at users dot sourceforge dot net>
support for EVE-Online skill monitoring
Aseem Mohanty <amohanty at myrealbox dot com>
if_up patch

View File

@ -2,6 +2,7 @@
2008-06-28
* Added sysfs AC adapter support patch (thanks Byron)
* Added support for EVE-Online skill monitoring (thanks Asbjørn)
2008-06-25
* new variables smapi_bat_temp and smapi_bat_power

1085
README

File diff suppressed because it is too large Load Diff

View File

@ -202,6 +202,23 @@ if test x$want_xmms2 = xyes; then
AC_DEFINE(XMMS2, 1, [Define if you want XMMS2 support])
fi
dnl
dnl EVE Skill Monitor
dnl
AC_ARG_ENABLE([eve],
EC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]),
[want_eve="$enableval"], [want_eve=no])
AM_CONDITIONAL(BUILD_EVE, test x$want_eve = xyes)
if test x$want_eve = xyes; then
PKG_CHECK_MODULES([libxml2], libxml-2.0)
PKG_CHECK_MODULES([libcurl], libcurl)
CFLAGS="$CFLAGS $libxml2_CFLAGS $libcurl_CFLAGS"
LIBS="$LIBS $libxml2_LIBS $libcurl_LIBS"
AC_DEFINE(EVE, 1, [Define if you want Eve-Online Skill monitor support])
fi
dnl
dnl RSS
dnl
@ -643,4 +660,5 @@ $PACKAGE $VERSION configured successfully:
wireless: $want_wlan
SMAPI: $want_smapi
nvidia: $want_nvidia
eve-online: $want_eve
EOF

View File

@ -30,7 +30,7 @@ using scripts and other external programs.
Conky has more than 250 built in objects, including support for
a plethora of OS stats (uname, uptime, CPU usage, mem usage, disk
usage, "top" like process stats, and network monitoring, just to name a few),
built in IMAP and POP3 support, built in support for many popular
built in IMAP and POP3 support, built in support for many popular
music players (MPD, XMMS2, BMPx, Audacious), and much much more.
Conky can display this info either as text, or using simple progress
bars and graph widgets, with different fonts and colours.
@ -42,11 +42,11 @@ or stop by #conky on irc.freenode.net if you have questions or want to contribut
Thanks for your interest in Conky.
.SH COMPILING
For users compiling from source on a binary distro, make sure you have the X development
libraries installed. This should be a package along the lines of "libx11-dev" or
libraries installed. This should be a package along the lines of "libx11-dev" or
"xorg-x11-dev" for X11 libs, and similar "-dev" format for the other libs required (depending
on your configure options).
.PP
Conky has (for some time) been available in the repositories of most popular distributions.
Conky has (for some time) been available in the repositories of most popular distributions.
Here are some installation instructions for a few:
.PP
Gentoo users -- Conky is in Gentoo's Portage... simply use "emerge app-admin/conky" for installation.
@ -139,7 +139,7 @@ Y position
Number of times to update Conky (and quit)
.SH "CONFIGURATION SETTINGS"
Default configuration file location is $HOME/.conkyrc or
Default configuration file location is $HOME/.conkyrc or
${sysconfdir}/conky/conky.conf. On most systems, sysconfdir is /etc,
and you can find the sample config file there (/etc/conky/conky.conf).
.PP
@ -384,7 +384,7 @@ Colors are parsed using XParsecolor(), there might be a list of them:
Color can be also in #rrggbb format (hex).
.TP
\fB\*(T<\fBaddr\fR\*(T>\fR \*(T<\fBinterface\fR\*(T>
IP address for an interface
IP address for an interface, or "No Address" if no address is assigned.
.TP
\fB\*(T<\fBaddrs\fR\*(T>\fR \*(T<\fBinterface\fR\*(T>
@ -662,23 +662,19 @@ Specify a different font. This new font will apply to the current line and every
.TP
\fB\*(T<\fBfreq\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
Returns CPU #n's frequency in MHz. CPUs are
counted from 1. If omitted, the parameter
defaults to 1.
Returns CPU #n's frequency in MHz. CPUs are counted from 1. If omitted, the parameter defaults to 1.
.TP
\fB\*(T<\fBfreq_g\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
Returns CPU #n's frequency in GHz. CPUs are
counted from 1. If omitted, the parameter
defaults to 1.
Returns CPU #n's frequency in GHz. CPUs are counted from 1. If omitted, the parameter defaults to 1.
.TP
\fB\*(T<\fBfreq_dyn\fR\*(T>\fR
Returns CPU frequency in MHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
\fB\*(T<\fBfreq_dyn\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
Returns CPU #n's frequency in MHz (defaults to 1), but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
.TP
\fB\*(T<\fBfreq_dyn_g\fR\*(T>\fR
Returns CPU frequency in GHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
\fB\*(T<\fBfreq_dyn_g\fR\*(T>\fR \*(T<\fB(n)\fR\*(T>
Returns CPU #n's frequency in GHz (defaults to 1), but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
.TP
\fB\*(T<\fBfs_bar\fR\*(T>\fR \*(T<\fB(height),(width) fs\fR\*(T>
@ -857,10 +853,6 @@ Kernel version
\fB\*(T<\fBlaptop_mode\fR\*(T>\fR
The value of /proc/sys/vm/laptop_mode
.TP
\fB\*(T<\fBlines\fR\*(T>\fR \*(T<\fBtextfile\fR\*(T>
Displays the number of lines in the given file
.TP
\fB\*(T<\fBloadavg\fR\*(T>\fR
(1,2,3)> System load average, 1 is for past 1 minute, 2 for past 5 minutes and 3 for past 15 minutes.
@ -869,6 +861,10 @@ Displays the number of lines in the given file
\fB\*(T<\fBloadgraph\fR\*(T>\fR \*(T<\fBnormal|log (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
Load1 average graph, similar to xload, with optional colours in hex, minus the #. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
\fB\*(T<\fBlines\fR\*(T>\fR \*(T<\fBtextfile\fR\*(T>
Displays the number of lines in the given file
.TP
\fB\*(T<\fBmachine\fR\*(T>\fR
Machine, i686 for example
@ -892,6 +888,10 @@ Amount of memory in use
\fB\*(T<\fBmembar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
Bar that shows amount of memory in use
.TP
\fB\*(T<\fBmemgraph\fR\*(T>\fR \*(T<\fBnormal|log (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
Memory usage graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
\fB\*(T<\fBmemeasyfree\fR\*(T>\fR
Amount of free memory including the memory that is very easily freed (buffers/cache)
@ -900,10 +900,6 @@ Amount of free memory including the memory that is very easily freed (buffers/ca
\fB\*(T<\fBmemfree\fR\*(T>\fR
Amount of free memory
.TP
\fB\*(T<\fBmemgraph\fR\*(T>\fR \*(T<\fBnormal|log (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
Memory usage graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
\fB\*(T<\fBmemmax\fR\*(T>\fR
Total amount of memory
@ -1059,6 +1055,10 @@ Total processes (sleeping and running)
\fB\*(T<\fBrunning_processes\fR\*(T>\fR
Running processes (not sleeping), requires Linux 2.6
.TP
\fB\*(T<\fBscroll\fR\*(T>\fR \*(T<\fBlength text\fR\*(T>
Scroll 'text' showing 'length' number of characters at the same time. The text may also contain variables. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
.TP
\fB\*(T<\fBshadecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T>
Change shading color
@ -1067,13 +1067,21 @@ Change shading color
\fB\*(T<\fBsmapi\fR\*(T>\fR \*(T<\fB(ARGS)\fR\*(T>
when using smapi, display contents of the /sys/devices/platform/smapi directory. ARGS are either '(FILENAME)' or 'bat (INDEX) (FILENAME)' to display the corresponding files' content. This is a very raw method of accessing the smapi values. When available, better use one of the smapi_* variables instead.
.TP
\fB\*(T<\fBsmapi_bat_bar\fR\*(T>\fR \*(T<\fB(INDEX),(height),(width)\fR\*(T>
when using smapi, display the remaining capacity of the battery with index INDEX as a bar.
.TP
\fB\*(T<\fBsmapi_bat_perc\fR\*(T>\fR \*(T<\fB(INDEX)\fR\*(T>
when using smapi, display the remaining capacity in percent of the battery with index INDEX. This is a separate variable because it supports the 'use_spacer' configuration option.
.TP
\fB\*(T<\fBsmapi_bat_bar\fR\*(T>\fR \*(T<\fB(INDEX),(height),(width)\fR\*(T>
when using smapi, display the remaining capacity of the battery with index INDEX as a bar.
\fB\*(T<\fBsmapi_bat_power\fR\*(T>\fR \*(T<\fBINDEX\fR\*(T>
when using smapi, display the current power of the battery with index INDEX in watt. This is a separate variable because the original read out value is being converted from mW. The sign of the output reflects charging (positive) or discharging (negative) state.
.TP
\fB\*(T<\fBsmapi_bat_temp\fR\*(T>\fR \*(T<\fBINDEX\fR\*(T>
when using smapi, display the current temperature of the battery with index INDEX in degree Celsius. This is a separate variable because the original read out value is being converted from milli degree Celsius.
.TP
\fB\*(T<\fBstippled_hr\fR\*(T>\fR \*(T<\fB(space)\fR\*(T>
@ -1156,10 +1164,6 @@ Move text over by N pixels. See also $voffset.
\fB\*(T<\fBrss\fR\*(T>\fR \*(T<\fBurl delay_in_minutes action item_num\fR\*(T>
Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles.
.TP
\fB\*(T<\fBscroll\fR\*(T>\fR \*(T<\fBlength text\fR\*(T>
Scroll 'text' showing 'length' number of characters at the same time. The text may also contain variables. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
.TP
\fB\*(T<\fBtab\fR\*(T>\fR \*(T<\fB(width, (start))\fR\*(T>
Puts a tab of the specified width, starting from column 'start'.
@ -1360,6 +1364,10 @@ Bar of XMMS2's progress
\fB\*(T<\fBxmms2_smart\fR\*(T>\fR
Prints the song name in either the form "artist - title" or file name, depending on whats available
.TP
\fB\*(T<\fBeve\fR\*(T>\fR \*(T<\fBapi_userid api_key character_id\fR\*(T>
Fetches your currently training skill from the Eve Online API servers (http://www.eve-online.com/) and displays the skill along with the remaining training time.
.SH EXAMPLES
.TP
\*(T<conky \*(T>\*(T<\fB\-t '${time %D %H:%M}' \-o \-u 30\fR\*(T>

View File

@ -2239,4 +2239,14 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>eve</option></command>
<option>api_userid api_key character_id</option>
</term>
<listitem>
Fetches your currently training skill from the Eve Online API servers (http://www.eve-online.com/) and displays the skill along with the remaining training time.
<para></para></listitem>
</varlistentry>
</variablelist>

View File

@ -80,6 +80,10 @@ if BUILD_HDDTEMP
hddtemp = hddtemp.c
endif
if BUILD_EVE
eve = eve.c eve.h
endif
if BUILD_RSS
rss = rss.c prss.c prss.h
endif
@ -109,6 +113,7 @@ conky_SOURCES = \
$(netbsd) \
$(openbsd) \
$(port_monitors) \
$(eve) \
$(rss) \
$(solaris) \
timed_thread.c \

File diff suppressed because it is too large Load Diff

View File

@ -80,6 +80,10 @@ char *strndup(const char *s, size_t n);
#include "rss.h"
#endif
#ifdef EVE
#include "eve.h"
#endif
#ifdef SMAPI
#include "smapi.h"
#endif

376
src/eve.c Normal file
View File

@ -0,0 +1,376 @@
/* Conky, a system monitor, based on torsmo
*
* Copyright (c) 2008 Asbjørn Zweidorff Kjær
* Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id$ */
#include "eve.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <utime.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <time.h>
int num_chars = 0;
Character eveCharacters[MAXCHARS];
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t realsize = 0;
struct xmlData *data = 0;
data = (struct xmlData *)stream;
realsize = size * nmemb;
data->data = (char *)realloc(data->data, data->size + realsize + 1);
if (data->data) {
memcpy(&(data->data[data->size]), ptr, realsize);
data->size += realsize;
data->data[data->size] = '\0';
}
return realsize;
}
int parseTrainingXml(char *data, Character * s)
{
char *skill, *level, *ends, *cache;
xmlNodePtr n;
xmlDocPtr doc = 0;
xmlNodePtr root = 0;
struct tm end_tm, cache_tm;
if (!data)
return 1;
doc = xmlReadMemory(data, strlen(data), "", NULL, 0);
root = xmlDocGetRootElement(doc);
for (n = root->children; n; n = n->next) {
if (n->type == XML_ELEMENT_NODE) {
if (!strcasecmp((const char *)n->name, "error")) {
return 1;
} else if (!strcasecmp((const char *)n->name, "result")) {
xmlNodePtr c;
for (c = n->children; c; c = c->next) {
if (!strcasecmp((const char *)c->name, "trainingEndTime")) {
ends = (char *)c->children->content;
} else if (!strcasecmp((const char *)c->name, "trainingTypeID")) {
if (c->children->content)
skill = (char *)c->children->content;
} else if (!strcasecmp((const char *)c->name, "trainingToLevel")) {
level = (char *)c->children->content;
}
}
} else if (!strcasecmp((const char *)n->name, "cachedUntil")) {
cache = (char *)n->children->content;
}
}
}
strptime(ends, "%Y-%m-%d %H:%M:%S", &end_tm);
strptime(cache, "%Y-%m-%d %H:%M:%S", &cache_tm);
s->skill = atoi(skill);
s->level = atoi(level);
s->ends = end_tm;
s->cache = cache_tm;
xmlFreeDoc(doc);
return 0;
}
char *getXmlFromAPI(const char *userid, const char *apikey, const char *charid, const char *url)
{
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
struct xmlData chr;
char *content;
CURL *curl_handle;
int rc = 0;
chr.data = NULL;
chr.size = 0;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chr);
if (userid != NULL && apikey != NULL && charid != NULL) {
curl_formadd(&post, &last, CURLFORM_COPYNAME, "userID", CURLFORM_COPYCONTENTS, userid, CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_COPYNAME, "apiKey", CURLFORM_COPYCONTENTS, apikey, CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_COPYNAME, "characterID", CURLFORM_COPYCONTENTS, charid, CURLFORM_END);
curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, post);
}
if ((rc = curl_easy_perform(curl_handle)) != CURLE_OK) {
return NULL;
}
content = strdup(chr.data);
curl_easy_cleanup(curl_handle);
return content;
}
void init_eve(void)
{
int i;
for (i = 0; i < MAXCHARS; i++) {
eveCharacters[i].charid = NULL;
eveCharacters[i].skillname = NULL;
eveCharacters[i].time = NULL;
eveCharacters[i].level = 0;
eveCharacters[i].skill = 0;
eveCharacters[i].delay = 0;
}
}
char *eve(char *userid, char *apikey, char *charid)
{
Character *chr = NULL;
const char *skillfile = "/tmp/.cesf";
int i = 0;
char *output = 0;
char *timel = 0;
char *skill = 0;
char *content = 0;
time_t now = 0;
char *error = 0;
for (i = 0; i < MAXCHARS; i++) {
if (eveCharacters[i].charid != NULL) {
if (strcasecmp(eveCharacters[i].charid, charid) == 0) {
chr = &eveCharacters[i];
break;
}
}
}
if (!chr) {
if (num_chars == MAXCHARS - 1)
return NULL;
chr = &eveCharacters[num_chars];
chr->charid = strdup(charid);
num_chars++;
}
if (chr->delay > 0) {
now = time(NULL);
if (now < chr->delay) {
output = strdup("Server error");
return output;
} else
chr->delay = 0;
}
if (isCacheValid(chr->cache)) {
output = (char *)malloc(200 * sizeof(char));
timel = strdup(formatTime(&chr->ends));
sprintf(output, EVE_OUTPUT_FORMAT, chr->skillname, chr->level, timel);
free(timel);
return output;
} else {
content = getXmlFromAPI(userid, apikey, charid, EVEURL_TRAINING);
if (content == NULL) {
error = strdup("Server error");
now = time(NULL);
now += (time_t) 1800;
chr->delay = now;
return error;
}
if (parseTrainingXml(content, chr)) {
output = (char *)malloc(200 * sizeof(char));
sprintf(output, "API error");
return output;
}
output = (char *)malloc(200 * sizeof(char));
timel = formatTime(&chr->ends);
skill = getSkillname(skillfile, chr->skill);
chr->skillname = strdup(skill);
sprintf(output, EVE_OUTPUT_FORMAT, chr->skillname, chr->level, timel);
free(skill);
return output;
}
}
char *formatTime(struct tm *ends)
{
struct timeval tv;
struct timezone tz;
double offset = 0;
time_t now = 0;
time_t tEnds = 0;
long lin = 0;
long lie = 0;
long diff = 0;
gettimeofday(&tv, &tz);
offset = (double)(tz.tz_minuteswest * 60);
now = time(NULL);
tEnds = mktime(ends);
lin = (long)now;
lin += (long)offset;
lie = (long)tEnds;
diff = (lie - lin);
if (diff > 0) {
int days = (int)(diff / 60 / 60 / 24);
int hours = (int)((diff / 60 / 60) - (days * 24));
int minutes = (int)((diff / 60) - ((hours * 60) + (days * 60 * 24)));
int seconds = (int)(diff - ((minutes * 60) + (hours * 60 * 60) + (days * 60 * 60 * 24)));
char *output = malloc(100 * sizeof(char));
if (days > 0)
sprintf(output, "%dd, %dh, %02dm and %02ds", days, hours, minutes, seconds);
else if (hours > 0)
sprintf(output, "%dh, %02dm and %02ds", hours, minutes, seconds);
else
sprintf(output, "%02dm and %02ds", minutes, seconds);
return output;
} else {
char *output = strdup("Done");
return output;
}
}
int isCacheValid(struct tm cached)
{
struct timeval tv;
struct timezone tz;
double offset = 0;
time_t now = 0;
time_t cache = 0;
double diff = 0;
gettimeofday(&tv, &tz);
offset = (double)(tz.tz_minuteswest * 60);
now = time(NULL);
cache = mktime(&cached);
diff = difftime(cache, now);
if (diff < offset)
return 0;
else
return 1;
}
int file_exists(const char *filename)
{
struct stat fi;
if ((stat(filename, &fi)) == 0) {
if (fi.st_size > 0)
return 1;
else
return 0;
} else
return 0;
}
void writeSkilltree(char *content, const char *filename)
{
FILE *fp = fopen(filename, "w");
fwrite(content, sizeof(char), strlen(content), fp);
fclose(fp);
}
char *getSkillname(const char *file, int skillid)
{
char *skilltree;
char *skill = NULL;
xmlNodePtr n;
xmlDocPtr doc = 0;
xmlNodePtr root = 0;
if (!file_exists(file)) {
skilltree = getXmlFromAPI(NULL, NULL, NULL, EVEURL_SKILLTREE);
writeSkilltree(skilltree, file);
free(skilltree);
}
doc = xmlReadFile(file, NULL, 0);
if (!doc)
return NULL;
root = xmlDocGetRootElement(doc);
for (n = root->children; n; n = n->next) {
xmlNodePtr o;
for (o = n->children; o; o = o->next) {
xmlNodePtr p;
for (p = o->children; p; p = p->next) {
xmlNodePtr q;
for (q = p->children; q; q = q->next) {
xmlNodePtr r;
for (r = q->children; r; r = r->next) {
xmlElementPtr ele = (xmlElementPtr) r;
xmlAttrPtr attr = (xmlAttrPtr) ele->attributes;
char *mySkill;
int id, assigned = 0;
while (attr != NULL) {
if (!strcasecmp((const char *)attr->name, "typeName")) {
mySkill = strdup((const char *)attr->children->content);
assigned = 1;
} else if (!strcasecmp((const char *)attr->name, "typeID")) {
id = atoi((const char *)attr->children->content);
}
attr = attr->next;
}
if (id == skillid) {
skill = strdup(mySkill);
/* free(mySkill); */
goto END;
}
if (assigned)
free(mySkill);
}
}
}
}
}
END:
xmlFreeDoc(doc);
return skill;
}

66
src/eve.h Normal file
View File

@ -0,0 +1,66 @@
/* Conky, a system monitor, based on torsmo
*
* Copyright (c) 2008 Asbjørn Zweidorff Kjær
* Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id$ */
#define _GNU_SOURCE
#define MAXCHARS 4
#define EVE_UPDATE_DELAY 60
#define MY_ENCODING "ISO-8859-1"
#define EVEURL_TRAINING "http://api.eve-online.com/char/SkillInTraining.xml.aspx"
#define EVEURL_SKILLTREE "http://api.eve-online.com/eve/Skilltree.xml.aspx"
#define EVE_OUTPUT_FORMAT "%s %d in %s"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
typedef struct {
char *charid;
char *skillname;
char *time;
char *lastOutput;
struct tm ends;
struct tm cache;
time_t delay;
int level;
int skill;
} Character;
struct xmlData {
char *data;
size_t size;
};
char *eve(char *, char *, char *);
char *getXmlFromAPI(const char *, const char *, const char *, const char *);
char *getSkillname(const char *, int);
char *formatTime(struct tm *);
int parseTrainingXml(char *, Character *);
int parseSkilltreeXml(char *, char *);
int isCacheValid(struct tm);
int file_exists(const char *);
void writeSkilltree(char *, const char *);
void init_eve(void);