int td_graph_render(td_graph* self, const char* object,
const td_graph_render_options* options, char** buffer, size_t* length);
+/*
+ This is a convenience type that can be used when the render state
+ has to be passed to a callback. Instead of defining it multiple times,
+ I felt that it was handy to define it globally.
+*/
+typedef struct td_graph_render_state {
+ // Graph
+ td_graph* graph;
+
+ // Options
+ const td_graph_render_options* options;
+
+ // Args
+ td_args* args;
+} td_graph_render_state;
+
/*
Temperatures
*/
#include "graph.h"
#include "processor-temperature.h"
-typedef struct processor_temperature_state {
- td_graph* graph;
- const td_graph_render_options* options;
- td_args* args;
-} processor_temperature_state;
-
const char* supported_sensors[] = {
// Intel
"coretemp-*",
static int processor_temperature_render_sensor(td_ctx* ctx, td_source* source,
const sensors_feature_type type, const sensors_chip_name* chip,
const sensors_feature* feature, void* data) {
- const processor_temperature_state* state = data;
+ const td_graph_render_state* state = data;
char name[NAME_MAX];
int r;
static int processor_temperature_render(td_ctx* ctx, td_graph* graph,
const td_graph_render_options* options, td_args* args, const char* object) {
- processor_temperature_state state = {
+ td_graph_render_state state = {
.graph = graph,
.options = options,
.args = args,