static int collecty_graph_bus_render(sd_bus_message* m, void* data, sd_bus_error* error) {
collecty_graph* graph = data;
sd_bus_message* reply = NULL;
- const char* format = NULL;
+ const char* object = NULL;
char* buffer = NULL;
size_t length = 0;
int r;
// Parse the arguments
- r = sd_bus_message_read(m, "s", &format);
+ r = sd_bus_message_read(m, "s", &object);
if (r < 0)
goto ERROR;
+ // If an empty string has been sent, set it to NULL
+ if (object && !*object)
+ object = NULL;
+
// Render the graph
- r = collecty_graph_render(graph, format, &buffer, &length);
+ r = collecty_graph_render(graph, object, &buffer, &length);
if (r < 0)
goto ERROR;
SD_BUS_VTABLE_START(0),
// Operations
- SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("s", format), SD_BUS_RESULT("ay", graph),
+ SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("s", object), SD_BUS_RESULT("ay", graph),
collecty_graph_bus_render, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END
}
int collecty_graph_render(collecty_graph* self,
- const char* format, char** buffer, size_t* length) {
+ const char* object, char** buffer, size_t* length) {
char* p = NULL;
int r;
char* collecty_graph_get_bus_path(collecty_graph* self);
int collecty_graph_render(collecty_graph* self,
- const char* format, char** buffer, size_t* length);
+ const char* object, char** buffer, size_t* length);
#endif /* COLLECTY_GRAPH_H */