Compare commits

..

No commits in common. "3b68f2dfda6fa9b07209b989c8565079076fbddc" and "f69e3599e1006bbdd71c05343dce7190cd04decb" have entirely different histories.

4 changed files with 10 additions and 16 deletions

View File

@ -3,17 +3,15 @@
#define _H_PLUG
#include <stddef.h>
#include <stdbool.h>
typedef void (*plug_init_f) (void);
typedef void (*plug_reload_f) (void);
typedef void (*plug_init_f) ();
typedef void (*plug_reload_f) ();
typedef void (*plug_poll_f) (char*, size_t);
typedef void (*plug_free_f) (void);
typedef void (*plug_free_f) ();
typedef struct plug_t {
char* name;
char* version;
bool is_ready;
} plug_t;
typedef struct plug_int_t {
@ -25,8 +23,8 @@ typedef struct plug_int_t {
} plug_int_t;
void setup_plugins(char* plugin_path);
char* poll_plugins(char* sep);
void free_plugins(void);
char* poll_plugins();
void free_plugins();
#endif

View File

@ -28,8 +28,6 @@ void plug_init(void) {
printf("MODULE: ERROR: Unable to find battery\n");
return;
}
PLUG.is_ready = true;
}
void plug_reload(void) { /* Unused */ }

View File

@ -1,12 +1,11 @@
#include "plug.h"
#include <stdio.h>
#include <time.h>
plug_t PLUG = {0};
void plug_init(void) {
PLUG.name = "time";
PLUG.version = "0.0.1";
PLUG.is_ready = true;
}
void plug_reload(void) { /* Unused */ }

View File

@ -124,7 +124,7 @@ void setup_plugins(char* plugin_path) {
}
}
void free_plugins(void) {
void free_plugins() {
for (size_t i = 0; i < PLUGMAN.plug_count; i++) {
plug_int_t* plug = PLUGMAN.plugs[i];
(plug->f_free)();
@ -146,11 +146,10 @@ char* poll_plugins(char* sep) {
}
for (size_t i = 0; i < PLUGMAN.plug_count; i++) {
plug_int_t* plug = PLUGMAN.plugs[i];
if (!plug->s_plug_info->is_ready) continue;
plug_int_t* plug = PLUGMAN.plugs[i];
printf("Polling plug id %zu\n", i);
size_t len = strlen(buf);
(plug->f_poll)(buf + len, PLUG_POLL_BUF_SZ - len);