43 lines
663 B
C
43 lines
663 B
C
#include <time.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
typedef struct plug_t {
|
|
char* name;
|
|
char* version;
|
|
int i;
|
|
} plug_t;
|
|
|
|
|
|
plug_t* p = {0};
|
|
|
|
void* plug_init(void) {
|
|
p = malloc(sizeof(plug_t));
|
|
p->name = "time";
|
|
p->version = "0.0.1";
|
|
p->i = 0;
|
|
return p;
|
|
}
|
|
|
|
void* plug_pre_reload(void) {
|
|
return p;
|
|
}
|
|
|
|
void plug_post_reload(void* pp) {
|
|
p = pp;
|
|
p->i += 1;
|
|
}
|
|
|
|
void plug_poll(char* buf, size_t len) {
|
|
time_t rawtime;
|
|
struct tm *timeinfo;
|
|
|
|
time(&rawtime);
|
|
timeinfo = localtime(&rawtime);
|
|
|
|
strftime(buf, len, "Time: %H:%M (%Y-%m-%d)", timeinfo);
|
|
}
|
|
|
|
void plug_free(void) {}
|