1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-11 10:38:12 +00:00

eve: convert to generic object payload

This commit is contained in:
Phil Sutter 2009-10-04 18:53:17 +02:00
parent 94ac89e091
commit 9202a9da87
4 changed files with 28 additions and 18 deletions

View File

@ -1544,6 +1544,7 @@ void free_text_objects(struct text_object *root, int internal)
#endif
#ifdef EVE
case OBJ_eve:
free_eve(obj);
break;
#endif
#ifdef HAVE_CURL

View File

@ -22,7 +22,6 @@
*
*/
#include "eve.h"
#include "config.h"
#include "text_object.h"
#include <stdio.h>
@ -66,6 +65,12 @@ struct xmlData {
size_t size;
};
struct eve_data {
char apikey[64];
char charid[20];
char userid[20];
};
int num_chars = 0;
Character eveCharacters[MAXCHARS];
@ -406,21 +411,31 @@ static char *eve(char *userid, char *apikey, char *charid)
void scan_eve(struct text_object *obj, const char *arg)
{
int argc;
char *userid = (char *) malloc(20 * sizeof(char));
char *apikey = (char *) malloc(64 * sizeof(char));
char *charid = (char *) malloc(20 * sizeof(char));
struct eve_data *ed;
argc = sscanf(arg, "%20s %64s %20s", userid, apikey, charid);
obj->data.eve.charid = charid;
obj->data.eve.userid = userid;
obj->data.eve.apikey = apikey;
ed = malloc(sizeof(struct eve_data));
memset(ed, 0, sizeof(struct eve_data));
argc = sscanf(arg, "%20s %64s %20s", ed->userid, ed->apikey, ed->charid);
init_eve();
obj->data.opaque = ed;
}
void print_eve(struct text_object *obj, char *p, int p_max_size)
{
snprintf(p, p_max_size, "%s",
eve(obj->data.eve.userid,
obj->data.eve.apikey, obj->data.eve.charid));
struct eve_data *ed = obj->data.opaque;
if (!ed)
return;
snprintf(p, p_max_size, "%s", eve(ed->userid, ed->apikey, ed->charid));
}
void free_eve(struct text_object *obj)
{
if (obj->data.opaque) {
free(obj->data.opaque);
obj->data.opaque = NULL;
}
}

View File

@ -26,5 +26,6 @@
void scan_eve(struct text_object *, const char *);
void print_eve(struct text_object *, char *, int);
void free_eve(struct text_object *);
#endif /* _EVE_H */

View File

@ -487,13 +487,6 @@ struct text_object {
struct {
int a, b;
} pair; /* 2 */
#ifdef EVE
struct {
char *apikey;
char *charid;
char *userid;
} eve;
#endif
#ifdef HAVE_CURL
struct {
char *uri;