Too lazy to make propper edit but i changed the

polling system to a message one so we can have
more ways we can interract with plugins
(reload/ reset/ on click events)
This commit is contained in:
2024-06-26 04:00:44 +03:00
parent 9f53240807
commit 026a68364b
33 changed files with 694 additions and 271 deletions

View File

@@ -1,7 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// Only use this define once, cause it defines funcitons
#define PLUG_IMPL
#include "dim_sdk.h"
PLUG_INFO("example_c", "0.0.1", "GPLv3")
@@ -9,31 +10,38 @@ PLUG_INFO("example_c", "0.0.1", "GPLv3")
typedef struct plug_t {
char* some_data;
int count;
plug_ctx_t ctx;
} plug_t;
plug_t* p = {0};
void plug_init(plug_ctx_t* ctx) {
(void) ctx;
// If any function returns 0/NULL the plugin will be disabled
int plug_init(plug_ctx_t* ctx) {
setup_ctx(ctx);
p = malloc(sizeof(plug_t));
assert(p != NULL && "Buy more ram KEKW");
p->count = 0;
p->ctx = *ctx;
printf("Hello from plugin");
// log(INFO, "Hewo fwom C :3");
return 0;
}
void* plug_pre_reload() {
return p;
}
void plug_post_reload(void *state) {
int plug_post_reload(void *state) {
p = state;
return 0;
}
void plug_poll(char *buf, size_t len) {
snprintf(buf, len, "Hello from C! (%d)", p->count++);
int plug_on_msg(plug_msg_t* msg) {
snprintf(p->ctx.buf, BUF_SZ, "Hello from C! (%d)", p->count++);
return 0;
}
void plug_free() {
int plug_free() {
free(p);
return 0;
}