mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-26 00:28:25 +00:00
eve: convert to generic object payload
This commit is contained in:
parent
94ac89e091
commit
9202a9da87
@ -1544,6 +1544,7 @@ void free_text_objects(struct text_object *root, int internal)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef EVE
|
#ifdef EVE
|
||||||
case OBJ_eve:
|
case OBJ_eve:
|
||||||
|
free_eve(obj);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
|
37
src/eve.c
37
src/eve.c
@ -22,7 +22,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "eve.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "text_object.h"
|
#include "text_object.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -66,6 +65,12 @@ struct xmlData {
|
|||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct eve_data {
|
||||||
|
char apikey[64];
|
||||||
|
char charid[20];
|
||||||
|
char userid[20];
|
||||||
|
};
|
||||||
|
|
||||||
int num_chars = 0;
|
int num_chars = 0;
|
||||||
Character eveCharacters[MAXCHARS];
|
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)
|
void scan_eve(struct text_object *obj, const char *arg)
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
char *userid = (char *) malloc(20 * sizeof(char));
|
struct eve_data *ed;
|
||||||
char *apikey = (char *) malloc(64 * sizeof(char));
|
|
||||||
char *charid = (char *) malloc(20 * sizeof(char));
|
|
||||||
|
|
||||||
argc = sscanf(arg, "%20s %64s %20s", userid, apikey, charid);
|
ed = malloc(sizeof(struct eve_data));
|
||||||
obj->data.eve.charid = charid;
|
memset(ed, 0, sizeof(struct eve_data));
|
||||||
obj->data.eve.userid = userid;
|
|
||||||
obj->data.eve.apikey = apikey;
|
argc = sscanf(arg, "%20s %64s %20s", ed->userid, ed->apikey, ed->charid);
|
||||||
|
|
||||||
init_eve();
|
init_eve();
|
||||||
|
obj->data.opaque = ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_eve(struct text_object *obj, char *p, int p_max_size)
|
void print_eve(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
snprintf(p, p_max_size, "%s",
|
struct eve_data *ed = obj->data.opaque;
|
||||||
eve(obj->data.eve.userid,
|
|
||||||
obj->data.eve.apikey, obj->data.eve.charid));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,6 @@
|
|||||||
|
|
||||||
void scan_eve(struct text_object *, const char *);
|
void scan_eve(struct text_object *, const char *);
|
||||||
void print_eve(struct text_object *, char *, int);
|
void print_eve(struct text_object *, char *, int);
|
||||||
|
void free_eve(struct text_object *);
|
||||||
|
|
||||||
#endif /* _EVE_H */
|
#endif /* _EVE_H */
|
||||||
|
@ -487,13 +487,6 @@ struct text_object {
|
|||||||
struct {
|
struct {
|
||||||
int a, b;
|
int a, b;
|
||||||
} pair; /* 2 */
|
} pair; /* 2 */
|
||||||
#ifdef EVE
|
|
||||||
struct {
|
|
||||||
char *apikey;
|
|
||||||
char *charid;
|
|
||||||
char *userid;
|
|
||||||
} eve;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
struct {
|
struct {
|
||||||
char *uri;
|
char *uri;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user