Compare commits
No commits in common. "3b68f2dfda6fa9b07209b989c8565079076fbddc" and "f69e3599e1006bbdd71c05343dce7190cd04decb" have entirely different histories.
3b68f2dfda
...
f69e3599e1
|
@ -3,17 +3,15 @@
|
||||||
#define _H_PLUG
|
#define _H_PLUG
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
typedef void (*plug_init_f) (void);
|
typedef void (*plug_init_f) ();
|
||||||
typedef void (*plug_reload_f) (void);
|
typedef void (*plug_reload_f) ();
|
||||||
typedef void (*plug_poll_f) (char*, size_t);
|
typedef void (*plug_poll_f) (char*, size_t);
|
||||||
typedef void (*plug_free_f) (void);
|
typedef void (*plug_free_f) ();
|
||||||
|
|
||||||
typedef struct plug_t {
|
typedef struct plug_t {
|
||||||
char* name;
|
char* name;
|
||||||
char* version;
|
char* version;
|
||||||
bool is_ready;
|
|
||||||
} plug_t;
|
} plug_t;
|
||||||
|
|
||||||
typedef struct plug_int_t {
|
typedef struct plug_int_t {
|
||||||
|
@ -25,8 +23,8 @@ typedef struct plug_int_t {
|
||||||
} plug_int_t;
|
} plug_int_t;
|
||||||
|
|
||||||
void setup_plugins(char* plugin_path);
|
void setup_plugins(char* plugin_path);
|
||||||
char* poll_plugins(char* sep);
|
char* poll_plugins();
|
||||||
void free_plugins(void);
|
void free_plugins();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@ void plug_init(void) {
|
||||||
printf("MODULE: ERROR: Unable to find battery\n");
|
printf("MODULE: ERROR: Unable to find battery\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUG.is_ready = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plug_reload(void) { /* Unused */ }
|
void plug_reload(void) { /* Unused */ }
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#include "plug.h"
|
#include "plug.h"
|
||||||
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
plug_t PLUG = {0};
|
plug_t PLUG = {0};
|
||||||
|
|
||||||
void plug_init(void) {
|
void plug_init(void) {
|
||||||
PLUG.name = "time";
|
PLUG.name = "time";
|
||||||
PLUG.version = "0.0.1";
|
PLUG.version = "0.0.1";
|
||||||
PLUG.is_ready = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plug_reload(void) { /* Unused */ }
|
void plug_reload(void) { /* Unused */ }
|
||||||
|
|
|
@ -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++) {
|
for (size_t i = 0; i < PLUGMAN.plug_count; i++) {
|
||||||
plug_int_t* plug = PLUGMAN.plugs[i];
|
plug_int_t* plug = PLUGMAN.plugs[i];
|
||||||
(plug->f_free)();
|
(plug->f_free)();
|
||||||
|
@ -147,10 +147,9 @@ char* poll_plugins(char* sep) {
|
||||||
|
|
||||||
for (size_t i = 0; i < PLUGMAN.plug_count; i++) {
|
for (size_t i = 0; i < PLUGMAN.plug_count; i++) {
|
||||||
plug_int_t* plug = PLUGMAN.plugs[i];
|
plug_int_t* plug = PLUGMAN.plugs[i];
|
||||||
if (!plug->s_plug_info->is_ready) continue;
|
|
||||||
|
|
||||||
|
|
||||||
printf("Polling plug id %zu\n", i);
|
printf("Polling plug id %zu\n", i);
|
||||||
|
|
||||||
size_t len = strlen(buf);
|
size_t len = strlen(buf);
|
||||||
(plug->f_poll)(buf + len, PLUG_POLL_BUF_SZ - len);
|
(plug->f_poll)(buf + len, PLUG_POLL_BUF_SZ - len);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user